You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/06/12 03:38:29 UTC
[01/10] Removed Windows7 which is now in it's own branch. This closes
#29
Repository: cordova-windows
Updated Branches:
refs/heads/master fcb1f6642 -> dfb81f0af
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/device.html
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/device.html b/windows7/Cordova/www/device.html
deleted file mode 100644
index 42a4774..0000000
--- a/windows7/Cordova/www/device.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html lang='en'>
- <head>
- <title>Device Info</title>
- <script src='cordova.win7.js'></script>
- </head>
- <body>
- <div id='state'></div>
- <script>
- document.addEventListener('deviceready', function () {
- document.getElementById('state').innerHTML = 'Platform: ' + device.platform + ' v' + device.version + '<br>Name: ' + device.name + '<br>UUID: ' + device.uuid;
- }, false);
- </script>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/events.html
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/events.html b/windows7/Cordova/www/events.html
deleted file mode 100644
index 5d9c5e3..0000000
--- a/windows7/Cordova/www/events.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html lang='en'>
- <head>
- <title>Events Test</title>
- <script src='cordova.win7.js'></script>
- </head>
- <body>
- <div id='state'></div>
- <script>
- document.addEventListener('deviceready', function () { document.getElementById('state').innerHTML = 'Ready!'; }, false);
- document.addEventListener('pause', function () { document.getElementById('state').innerHTML = 'Paused!'; }, false);
- document.addEventListener('resume', function () { document.getElementById('state').innerHTML = 'Resumed!'; }, false);
- document.addEventListener('backbutton', function () { document.getElementById('state').innerHTML = 'Back!'; }, false);
- </script>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/file.html
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/file.html b/windows7/Cordova/www/file.html
deleted file mode 100644
index 4419ed5..0000000
--- a/windows7/Cordova/www/file.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html>
-<html lang='en'>
- <head>
- <title>Device Info</title>
- <script type="text/javascript" src='cordova.win7.js'></script>
- </head>
- <body>
- <div id='state'></div>
- <div id='filesystem'></div>
- <br/>
- <div id='entry'></div>
- <script type="text/javascript">
- function onFileSystemSuccess(fileSystem) {
- document.getElementById('filesystem').innerHTML = 'File system name: ' + fileSystem.name
- + '<br>Root name: ' + fileSystem.root.name
- + '<br>Root path: ' + fileSystem.root.fullPath;
- }
-
- function fail(error) {
- document.getElementById('state').innerHTML = 'Error, code: ' + error.code;
- }
-
- document.addEventListener('deviceready', function () {
- window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
- }, false);
- </script>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/index.html
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/index.html b/windows7/Cordova/www/index.html
deleted file mode 100644
index 2b509c1..0000000
--- a/windows7/Cordova/www/index.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<html lang='en'>
- <head>
- <title>Welcome to Cordova</title>
- <script src='cordova.win7.js'></script>
- </head>
-
- <body>
- <a href='device.html'>Device</a><br>
- <a href='network.html'>Network</a><br>
- <a href='accel_game.html'>Accelerometer</a><br>
- <a href='capture.html'>Capture</a><br>
- <a href='events.html'>Events</a><br>
- <a href='notification.html'>Notification</a><br>
- <a href='storage.html'>Storage</a><br>
- <a href='file.html'>File</a><br>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/network.html
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/network.html b/windows7/Cordova/www/network.html
deleted file mode 100644
index fb0891c..0000000
--- a/windows7/Cordova/www/network.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html lang='en'>
- <head>
- <title>Connectivity Info</title>
- <script src='cordova.win7.js'></script>
- </head>
- <body>
- <div id='state'></div>
- <script>
- document.addEventListener('deviceready', function () {
- document.getElementById('state').innerHTML = 'Network connectivity type: ' + navigator.network.connection.type;
- }, false);
- </script>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/notification.html
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/notification.html b/windows7/Cordova/www/notification.html
deleted file mode 100644
index aaea533..0000000
--- a/windows7/Cordova/www/notification.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!DOCTYPE html>
-<html lang='en'>
- <head>
- <title>Notification</title>
- <script src='cordova.win7.js'></script>
- </head>
- <body>
- <p>Tap on the Launch PopUp button below to open the modal window.</p>
- <br />
- <input type="button" id="popUpBtn" value="Launch PopUp" />
- <script type="text/javascript">
- document.addEventListener('deviceready', function () {
- initApp();
- }, false);
-
- function initApp() {
- setTimeout(function () { window.scrollTo(0, 1); }, 10);
- document.getElementById("popUpBtn").addEventListener("click", function () {
- showPopUpMessage();
- }, false);
- }
-
- // Show the modal overlay and popup window
- function showPopUpMessage() {
- function alertDismissed(button) {
- console.log("Alert dismissed: " + button);
- }
-
- navigator.notification.beep(1);
- navigator.notification.confirm(
- 'Hello from JavaScript through Cordova!',
- alertDismissed,
- 'Test Alert',
- 'Done,Yes,No'
- );
- }
- </script>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/storage.html
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/storage.html b/windows7/Cordova/www/storage.html
deleted file mode 100644
index 8ebfdfb..0000000
--- a/windows7/Cordova/www/storage.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE html>
-<html lang='en'>
- <head>
- <script src='cordova.win7.js'></script>
- </head>
- <body>
- <script type="text/javascript">
- function QuerySuccessCB(Tx, results) {
- alert("Results: " + results.rows.length);
- alert("resultSet[0].data: " + results.rows.resultSet[0].data);
- }
-
- function populateDB(tx) {
- tx.executeSql('DROP TABLE IF EXISTS DEMO');
- tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
- tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
- tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
- tx.executeSql('INSERT INTO DEMO (id, data) VALUES (3, "Third one")');
- tx.executeSql('SELECT * FROM DEMO WHERE data LIKE "%row"', [], QuerySuccessCB);
- }
- function TxErrorCB() {
- alert("Error processing SQL!");
- }
-
- document.addEventListener('deviceready', function () {
- var db = window.openDatabase("test", "1.0", "Test DB", 1000000);
- db.transaction(populateDB, TxErrorCB);
- }, false);
- </script>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/README
----------------------------------------------------------------------
diff --git a/windows7/README b/windows7/README
deleted file mode 100644
index 9b6ad62..0000000
--- a/windows7/README
+++ /dev/null
@@ -1,44 +0,0 @@
-This is a draft implementation of a Cordova layer for Windows 7.
-
-This project can be built using Visual Studio 2012. Doing so creates a Win32
-program that hosts a IE-based web view and loads www/index.html inside it. The
-supplied cordova.win7.js file has partial support for Cordova events and API
-sets, and is able to interact with the hosting program (native side).
-
-This is still very much work in progress, and further development, including
-bug fixing, will be required before this can be considered suitable for
-deployment.
-
-Internet Explorer 9 or newer is required.
-
-Major files are:
-
-shell.c: initialization, web view control and native <-> javascript interface
-accel.c: accelerometer sensing
-capture.c: video, audio and photo recording
-device.c: support routines for Cordova Device API
-network.c: network connectivity sensing
-notification.c: dialog boxes support
-
-There are some basic usage samples in www/
-
--
-
-Copyright 2012 Intel Corporation
-
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
\ No newline at end of file
[09/10] Removed Windows7 which is now in it's own branch. This closes
#29
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/capture.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/capture.c b/windows7/Cordova/capture.c
deleted file mode 100644
index c182366..0000000
--- a/windows7/Cordova/capture.c
+++ /dev/null
@@ -1,2334 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include <mfapi.h> // Media Foundation
-#include <mfidl.h> // Media session
-#include <evr.h> // Enhanced Video Renderer
-#include <ks.h> // Required by codecapi.h...
-#include <codecapi.h> // H.264 codec profiles
-#include <wmcodecdsp.h> // Color converter transform
-#include "capture.h"
-#include "jpeg.h" // JPEG compression utility
-#include <commctrl.h> // Toolbar
-#include <windowsx.h> // Common control macros
-#include <mferror.h> // MF_E_NOTACCEPTING and friends
-#include "resource.h"
-#include <wchar.h>
-#include "common.h"
-#include "mp4patch.h"
-
-// Workaround for a declaration in the Windows 8 SDK that's mistakenly missing for non C++ files
-STDAPI MFCreateCollection(_Out_ IMFCollection **ppIMFCollection);
-
-#pragma comment(lib, "mfuuid.lib") // Media Foundation UUIDs
-#pragma comment(lib, "mfplat.lib") // MF attributes
-#pragma comment(lib, "mf.lib") // MF topology, session, device enumeration and video renderer
-#pragma comment(lib, "wmcodecdspuuid.lib") // Color converter
-#pragma comment(lib, "strmiids.lib") // DirectShow UUIDs, ID_IMFVideoDisplayControl
-
-HWND hCaptureWnd;
-HWND hPreviewWnd;
-extern HWND hWnd;
-
-#define PHOTO_CAPTURE_TOPO 1 // Video capture + video preview + frame grabber
-#define VIDEO_FRAMING_TOPO 2 // Video capture + video preview
-#define VIDEO_CAPTURE_TOPO 3 // Video capture + audio capture + video preview + audio capture + h264 + aac + mp4 output
-#define AUDIO_CAPTURE_TOPO 4 // Audio capture + aac + mp4 output
-#define AUDIO_PLAYBACK_TOPO 5 // Playing an audio recording from a file
-
-IMFMediaSession* media_session_if; // MF session and topology
-
-IMFVideoDisplayControl* video_display_control_if; // Video renderer position / snapshot retrieval
-
-IMFMediaType* cam_config_if; // Video capture device output configuration
-IMFMediaType* conv_config_if; // Color converter encoder output configuration
-IMFMediaType* h264_config_if; // AVC encoder output configuration
-IMFMediaType* aac_config_if; // AAC encoder output configuration
-
-IMFMediaType* mic_config_if; // Audio capture device output configuration
-
-IMFMediaSource* video_source_if; // These need to be shutdown before being released, so keep keep pointers around
-IMFMediaSource* audio_source_if;
-IMFMediaSink* media_sink_if;
-IMFTransform* video_compr_transform_if;
-IMFTransform* audio_compr_transform_if;
-IMFTransform* color_transform_if;
-
-BOOL mjpeg_mode;
-
-struct IMFSampleGrabberSinkCallback2 sgsc; // Sample grabber sink callback, used in photo mode to retrieve video frames
-
-
-// Video capture settings
-UINT64 frame_size; // Ex: 640:480
-UINT64 frame_rate; // Ex: 30:1
-INT32 scan_len; // Scan line len (negative if scanning happens upwards)
-
-// Flag raised when capturing photos
-BOOL grab_first_available_frame = FALSE;
-
-HANDLE session_control_thread;
-
-#define MAX_FILE_NAME_LEN 255 // NUL not included
-
-wchar_t temp_directory_win[MAX_FILE_NAME_LEN + 1]; // C:\Temp syntax
-wchar_t temp_directory_url[MAX_FILE_NAME_LEN + 8]; // file://C:/Temp syntax
-wchar_t last_recorded_file_name_full[MAX_FILE_NAME_LEN+1]; // Full path
-wchar_t last_recorded_file_name[MAX_FILE_NAME_LEN+1]; // Name only
-
-LONGLONG start_time; // Marker used to compute the duration of the last recording
-
-// Note: the MPEG 4 sink is limited to 4 GB
-
-#define VIDEO_BIT_RATE 4000000
-#define AUDIO_BIT_RATE 160000
-
-
-#define ACTION_PHOTO_CAPTURE 0
-#define ACTION_VIDEO_FRAMING 1
-#define ACTION_VIDEO_CAPTURE 2
-
-int current_action_code;
-
-
-#define RELEASE(x) { if (x) (x)->lpVtbl->Release(x); }
-#define ADDREF(x) {if (x) x->lpVtbl->AddRef(x);}
-#define RELEASE_D(x) {if (x) { OutputDebugString(L"Unreleased COM interface: " L ## #x L"\n"); x->lpVtbl->Release(x); }}
-#define RELEASE_Z(x) {if (x) { x->lpVtbl->Release(x); x = 0;} }
-
-
-// @@@ handle removal
-#define MAX_DEVICE_NAME_LEN 80 // NUL not included
-
-wchar_t preferred_video_capture_dev[MAX_DEVICE_NAME_LEN+1];
-wchar_t preferred_audio_capture_dev[MAX_DEVICE_NAME_LEN+1];
-wchar_t preferred_video_encoder[MAX_DEVICE_NAME_LEN+1];
-wchar_t preferred_video_resolution[MAX_DEVICE_NAME_LEN+1];
-wchar_t preferred_photo_resolution[MAX_DEVICE_NAME_LEN+1];
-
-#define PREF_VIDEO_DEVICE L"DefaultVideoCaptureDevice"
-#define PREF_AUDIO_DEVICE L"DefaultAudioCaptureDevice"
-#define PREF_VIDEO_ENCODER L"DefaultVideoEncoder"
-#define PREF_VIDEO_RESOLUTION L"DefaultVideoResolution"
-#define PREF_PHOTO_RESOLUTION L"DefaultPhotoResolution"
-
-int load_pref(wchar_t* pref_name, wchar_t buf[MAX_DEVICE_NAME_LEN])
-{
- DWORD info;
- HKEY key;
- LONG ret;
- DWORD len;
- DWORD type;
-
- buf[0] = L'\0';
-
- ret = RegCreateKeyEx(HKEY_CURRENT_USER, CORDOVA_REG_KEY, 0, 0, 0, KEY_READ | KEY_WRITE, 0, &key, &info);
-
- if (ret != ERROR_SUCCESS)
- return -1;
-
- if (info == REG_OPENED_EXISTING_KEY)
- {
- len = MAX_DEVICE_NAME_LEN * sizeof(wchar_t);
-
- ret = RegQueryValueEx(key, pref_name, 0, &type, (LPBYTE) buf, &len);
-
- if (ret == ERROR_SUCCESS)
- {
- // Return successfully
- RegCloseKey(key);
- return 0;
- }
- }
-
- RegCloseKey(key);
- return -1;
-}
-
-int save_pref(wchar_t* pref_name, wchar_t buf[MAX_DEVICE_NAME_LEN])
-{
- DWORD info;
- HKEY key;
- LONG ret;
- DWORD len;
-
- ret = RegCreateKeyEx(HKEY_CURRENT_USER, CORDOVA_REG_KEY, 0, 0, 0, KEY_READ | KEY_WRITE, 0, &key, &info);
-
- if (ret != ERROR_SUCCESS)
- return -1;
-
- // Store it
- len = wcslen(buf) + 1;
- RegSetValueEx(key, pref_name, 0, REG_SZ, (LPBYTE) buf, len*sizeof(wchar_t));
-
- // There's a slight chance of race condition here ; in that case several different ids would be returned by concurrent executions
- // That can be avoided using a named mutex if that turns out to be a problem
-
- RegCloseKey(key);
- return 0;
-}
-
-// Little utility function that computes the length in bytes of a line
-HRESULT get_stride(IMFMediaType* media_type_if, INT32* stride_p, UINT32 width)
-{
- GUID sub_type = GUID_NULL;
- INT32 stride = 0;
- HRESULT hr = media_type_if->lpVtbl->GetUINT32(media_type_if, &MF_MT_DEFAULT_STRIDE, (UINT32*)&stride);
-
- if (hr != S_OK)
- {
- // Get the subtype
- hr = media_type_if->lpVtbl->GetGUID(media_type_if, &MF_MT_SUBTYPE, &sub_type);
-
- if (hr == S_OK)
- hr = MFGetStrideForBitmapInfoHeader(sub_type.Data1, width, &stride);
- }
-
- *stride_p = stride;
-
- return hr;
-}
-
-typedef struct
-{
- const GUID* format_id;
- const wchar_t* format_name;
-}
-format_t;
-
-format_t fmt_array[] =
-{
- { &MFVideoFormat_RGB32, L"RGB32" },
- { &MFVideoFormat_ARGB32,L"ARGB32" },
- { &MFVideoFormat_RGB24, L"RGB24" },
- { &MFVideoFormat_RGB555,L"RGB555" },
- { &MFVideoFormat_RGB565,L"RGB565" },
- { &MFVideoFormat_RGB8, L"RGB8" },
- { &MFVideoFormat_AI44, L"AI44" },
- { &MFVideoFormat_AYUV, L"AYUV" },
- { &MFVideoFormat_YUY2, L"YUY2" },
- { &MFVideoFormat_YVYU, L"YVYU" },
- { &MFVideoFormat_YVU9, L"YVU9" },
- { &MFVideoFormat_UYVY, L"UYVY" },
- { &MFVideoFormat_NV11, L"NV11" },
- { &MFVideoFormat_NV12, L"NV12" },
- { &MFVideoFormat_YV12, L"YV12" },
- { &MFVideoFormat_I420, L"I420" },
- { &MFVideoFormat_IYUV, L"IYUV" },
- { &MFVideoFormat_Y210, L"Y210" },
- { &MFVideoFormat_Y216, L"Y216" },
- { &MFVideoFormat_Y410, L"Y410" },
- { &MFVideoFormat_Y416, L"Y416" },
- { &MFVideoFormat_Y41P, L"Y41P" },
- { &MFVideoFormat_Y41T, L"Y41T" },
- { &MFVideoFormat_Y42T, L"Y42T" },
- { &MFVideoFormat_P210, L"P210" },
- { &MFVideoFormat_P216, L"P216" },
- { &MFVideoFormat_P010, L"P010" },
- { &MFVideoFormat_P016, L"P016" },
- { &MFVideoFormat_v210, L"v210" },
- { &MFVideoFormat_v216, L"v216" },
- { &MFVideoFormat_v410, L"v410" },
- { &MFVideoFormat_MP43, L"MP43" },
- { &MFVideoFormat_MP4S, L"MP4S" },
- { &MFVideoFormat_M4S2, L"M4S2" },
- { &MFVideoFormat_MP4V, L"MP4V" },
- { &MFVideoFormat_WMV1, L"WMV1" },
- { &MFVideoFormat_WMV2, L"WMV2" },
- { &MFVideoFormat_WMV3, L"WMV3" },
- { &MFVideoFormat_WVC1, L"WVC1" },
- { &MFVideoFormat_MSS1, L"MSS1" },
- { &MFVideoFormat_MSS2, L"MSS2" },
- { &MFVideoFormat_MPG1, L"MPG1" },
- { &MFVideoFormat_DVSL, L"DVSL" },
- { &MFVideoFormat_DVSD, L"DVSD" },
- { &MFVideoFormat_DVHD, L"DVHD" },
- { &MFVideoFormat_DV25, L"DV25" },
- { &MFVideoFormat_DV50, L"DV50" },
- { &MFVideoFormat_DVH1, L"DVH1" },
- { &MFVideoFormat_DVC, L"DVC" },
- { &MFVideoFormat_H264, L"H264" },
- { &MFVideoFormat_MJPG, L"MJPG" }
-};
-
-const wchar_t* identify_format(const GUID* format)
-{
- int i;
-
- for (i=0; i<sizeof(fmt_array)/sizeof(fmt_array[0]); i++)
- if (IsEqualGUID(format, fmt_array[i].format_id))
- return fmt_array[i].format_name;
-
- return L"<unknown>";
-}
-
-
-HRESULT add_video_capture_node(IMFTopology* topology_if, IMFMediaSource* av_source_if, IMFPresentationDescriptor* av_pres_descr_if, IMFTopologyNode** video_capture_node_ifp)
-{
- // Initialize the video capture node and add it to our topology
- HRESULT hr;
- IMFStreamDescriptor* stream_desc_if = 0;
- BOOL selected;
- DWORD stream_count;
- DWORD i;
- GUID media_type;
- IMFMediaTypeHandler* cam_type_handler_if = 0;
- IMFTopologyNode* node_if = 0;
- int selected_index = -1;
- DWORD count;
- DWORD w, h;
- DWORD fr1, fr2;
- GUID format;
- int buf_len;
- wchar_t buf[80];
- wchar_t* pref_res;
- BOOL found_video_stream = FALSE;
- UINT32 interlace_mode = 0;
-
- if (current_action_code == ACTION_PHOTO_CAPTURE)
- pref_res = preferred_photo_resolution;
- else
- pref_res = preferred_video_resolution;
-
- // Create source node
- hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &node_if);
-
- // Set our aggregate AV source as media source for this node
- hr = node_if->lpVtbl->SetUnknown(node_if, &MF_TOPONODE_SOURCE, (IUnknown*) av_source_if);
-
- // Select combined AV presentation descriptor for this node
- hr = node_if->lpVtbl->SetUnknown(node_if, &MF_TOPONODE_PRESENTATION_DESCRIPTOR, (IUnknown*) av_pres_descr_if);
-
- // Select video stream from AV source
- hr = av_pres_descr_if->lpVtbl->GetStreamDescriptorCount(av_pres_descr_if, &stream_count);
-
- for (i=0; i<stream_count; i++)
- {
- hr = av_pres_descr_if->lpVtbl->GetStreamDescriptorByIndex(av_pres_descr_if, i, &selected, &stream_desc_if);
-
- if (selected)
- {
- hr = stream_desc_if->lpVtbl->GetMediaTypeHandler(stream_desc_if, &cam_type_handler_if);
- hr = cam_type_handler_if->lpVtbl->GetMajorType(cam_type_handler_if, &media_type);
-
- if (IsEqualGUID(&media_type, &MFMediaType_Video))
- {
- hr = node_if->lpVtbl->SetUnknown(node_if, &MF_TOPONODE_STREAM_DESCRIPTOR, (IUnknown*) stream_desc_if);
-
- // Enumerate supported media types
- {
- cam_type_handler_if->lpVtbl->GetMediaTypeCount(cam_type_handler_if, &count);
-
- for (i=0; i<count && selected_index == -1; i++)
- {
- cam_type_handler_if->lpVtbl->GetMediaTypeByIndex(cam_type_handler_if, i, &cam_config_if);
-
- hr = cam_config_if->lpVtbl->GetGUID(cam_config_if, &MF_MT_SUBTYPE, &format);
- hr = cam_config_if->lpVtbl->GetUINT64(cam_config_if, &MF_MT_FRAME_SIZE, &frame_size);
- hr = cam_config_if->lpVtbl->GetUINT64(cam_config_if, &MF_MT_FRAME_RATE, &frame_rate);
- hr = cam_config_if->lpVtbl->GetUINT32(cam_config_if, &MF_MT_INTERLACE_MODE, &interlace_mode);
-
- if (interlace_mode == MFVideoInterlace_Progressive)
- {
- w = frame_size >> 32;
- h = (DWORD) frame_size;
- fr1 = frame_rate >> 32;
- fr2 = (DWORD) frame_rate;
-
- buf_len = wsprintf(buf, L"%d x %d @ %d fps %s", w, h, fr1/fr2, identify_format(&format)/*, interlace_mode == 2 ? L'p' : L'i'*/);
-
- if (!wmemcmp(buf, pref_res, buf_len))
- selected_index = i;
- }
-
- RELEASE(cam_config_if);
- }
- }
-
- if (selected_index == -1)
- selected_index = 0; // No match... use whatever is available (presumably VGA)
-
- // Switch camera to desired mode
- hr = cam_type_handler_if->lpVtbl->GetMediaTypeByIndex(cam_type_handler_if, selected_index, &cam_config_if);
- hr = cam_type_handler_if->lpVtbl->SetCurrentMediaType(cam_type_handler_if, cam_config_if);
-
- // Gather configuration info that is needed downstream
- hr = cam_config_if->lpVtbl->GetUINT64(cam_config_if, &MF_MT_FRAME_SIZE, &frame_size);
- hr = cam_config_if->lpVtbl->GetUINT64(cam_config_if, &MF_MT_FRAME_RATE, &frame_rate);
- hr = get_stride(cam_config_if, &scan_len, frame_size >> 32);
-
- // Finally add this node to the topology
- hr = topology_if->lpVtbl->AddNode(topology_if, node_if);
- found_video_stream = TRUE;
- RELEASE(stream_desc_if);
- break;
- }
- }
-
- RELEASE(stream_desc_if);
- }
-
- if (found_video_stream)
- *video_capture_node_ifp = node_if;
- else
- *video_capture_node_ifp = 0;
-
- RELEASE(node_if);
- RELEASE(cam_type_handler_if);
- return hr;
-}
-
-
-HRESULT add_frame_grabber_node (IMFTopology* topology_if, IMFMediaType* input_type_if, IMFTopologyNode** frame_grabber_node_ifp)
-{
- HRESULT hr;
- IMFActivate* sink_activate_if = 0;
- IMFTopologyNode* grabber_node_if = 0;
- IMFMediaType* grabber_config_if = 0;
- GUID input_format;
-
- hr = input_type_if->lpVtbl->GetGUID(input_type_if, &MF_MT_SUBTYPE, &input_format);
-
- hr = MFCreateMediaType(&grabber_config_if);
- hr = grabber_config_if->lpVtbl->SetGUID(grabber_config_if, &MF_MT_MAJOR_TYPE, &MFMediaType_Video);
-
- // If the cam is sending JPEG frames use that for the frame grabber node, otherwise request RGB 24 bpp representation
- mjpeg_mode = 0; // IsEqualGUID(&input_format, &MFVideoFormat_MJPG); disabled for now ; some webcams send JFIF frames,
- // others AVI1 MJPEG frames (JPEG minus DHT segment) ; the missing Huffman table contents is fixed,
- // so it can be added programatically, but for single-frame capture we don't really need to optimize,
- // and using MJPEG rather than YUV or RGB modes may make the preview more costly
-
- if (mjpeg_mode)
- hr = grabber_config_if->lpVtbl->SetGUID(grabber_config_if, &MF_MT_SUBTYPE, &MFVideoFormat_MJPG);
- else
- hr = grabber_config_if->lpVtbl->SetGUID(grabber_config_if, &MF_MT_SUBTYPE, &MFVideoFormat_RGB24);
-
- hr = MFCreateSampleGrabberSinkActivate(grabber_config_if, (IMFSampleGrabberSinkCallback*) &sgsc, &sink_activate_if);
-
- RELEASE_Z(grabber_config_if);
-
- // Create output node
- hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &grabber_node_if);
-
- // Associate sink to node
- hr = grabber_node_if->lpVtbl->SetObject(grabber_node_if, (IUnknown*) sink_activate_if);
-
- // Add node to the topology
- hr = topology_if->lpVtbl->AddNode(topology_if, grabber_node_if);
-
- *frame_grabber_node_ifp = grabber_node_if;
-
- RELEASE(grabber_node_if);
- RELEASE(sink_activate_if);
-
- return hr;
-}
-
-
-HRESULT add_audio_capture_node(IMFTopology* topology_if, IMFMediaSource* av_source_if, IMFPresentationDescriptor* av_pres_descr_if, IMFTopologyNode** audio_capture_node_ifp)
-{
- // Initialize the audio capture node and add it to our topology
- HRESULT hr;
- IMFStreamDescriptor* stream_desc_if = 0;
- BOOL selected = 0;
- DWORD stream_count = 0;
- DWORD i;
- GUID media_type;
- IMFMediaTypeHandler* mic_type_handler_if = 0;
- IMFTopologyNode* node_if = 0;
- int num_channels = 2;
- BOOL found_audio_stream = FALSE;
- IMFMediaType* test_config_if = 0;
-
- // Create source node
- hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &node_if);
-
- // Set our aggregate AV source as media source for this node
- hr = node_if->lpVtbl->SetUnknown(node_if, &MF_TOPONODE_SOURCE, (IUnknown*) av_source_if);
-
- // Select combined AV presentation descriptor for this node
- hr = node_if->lpVtbl->SetUnknown(node_if, &MF_TOPONODE_PRESENTATION_DESCRIPTOR, (IUnknown*) av_pres_descr_if);
-
- // Select audio stream from AV source
- hr = av_pres_descr_if->lpVtbl->GetStreamDescriptorCount(av_pres_descr_if, &stream_count);
-
- for (i=0; i<stream_count; i++)
- {
- hr = av_pres_descr_if->lpVtbl->GetStreamDescriptorByIndex(av_pres_descr_if, i, &selected, &stream_desc_if);
-
- if (selected)
- {
- hr = stream_desc_if->lpVtbl->GetMediaTypeHandler(stream_desc_if, &mic_type_handler_if);
- hr = mic_type_handler_if->lpVtbl->GetMajorType(mic_type_handler_if, &media_type);
-
- if (IsEqualGUID(&media_type, &MFMediaType_Audio))
- {
-// hr = mic_type_handler_if->lpVtbl->GetCurrentMediaType(mic_type_handler_if, &mic_config_if);
- hr = MFCreateMediaType(&test_config_if);
-
- // Switch to PCM 16 bits @ 48 KHz format as that's what the AAC encoder takes as input
-
- hr = test_config_if->lpVtbl->SetGUID(test_config_if, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
- hr = test_config_if->lpVtbl->SetGUID(test_config_if, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
- hr = test_config_if->lpVtbl->SetUINT32(test_config_if, &MF_MT_AUDIO_BITS_PER_SAMPLE, 16);
- hr = test_config_if->lpVtbl->SetUINT32(test_config_if, &MF_MT_AUDIO_SAMPLES_PER_SECOND, 48000);
-
- // Check if the format is supported ; the call optionally returns a related media type if it isn't
- hr = mic_type_handler_if->lpVtbl->IsMediaTypeSupported(mic_type_handler_if, test_config_if, &mic_config_if);
-
- if (hr == S_OK)
- {
- mic_config_if = test_config_if;
- }
- else
- {
- RELEASE(test_config_if);
- }
-
- if (mic_config_if)
- hr = mic_type_handler_if->lpVtbl->SetCurrentMediaType(mic_type_handler_if, mic_config_if);
- else
- hr = mic_type_handler_if->lpVtbl->GetCurrentMediaType(mic_type_handler_if, &mic_config_if);
-
- hr = node_if->lpVtbl->SetUnknown(node_if, &MF_TOPONODE_STREAM_DESCRIPTOR, (IUnknown*) stream_desc_if);
-
- // Finally add this node to the topology
- hr = topology_if->lpVtbl->AddNode(topology_if, node_if);
- found_audio_stream = TRUE;
- break;
- }
- }
-
- RELEASE(stream_desc_if);
- }
-
- if (found_audio_stream)
- *audio_capture_node_ifp = node_if;
- else
- *audio_capture_node_ifp = 0;
-
- RELEASE(node_if);
- RELEASE(mic_type_handler_if);
-
- return hr;
-}
-
-
-HRESULT configure_mft(IMFTransform* mft_if)
-{
- IMFAttributes *attributes_if = 0;
- HRESULT hr;
-
- hr = mft_if->lpVtbl->GetAttributes(mft_if, &attributes_if);
-
- if (attributes_if)
- {
- hr = attributes_if->lpVtbl->SetUINT32(attributes_if, &MF_TRANSFORM_ASYNC_UNLOCK, TRUE);
- hr = attributes_if->lpVtbl->SetUINT32(attributes_if, &MF_LOW_LATENCY, TRUE);
-
- RELEASE(attributes_if);
- }
-
- return hr;
-}
-
-
-IMFTransform* get_encoder (BOOL video)
-{
- HRESULT hr;
- DWORD count = 0;
- DWORD i;
- IMFActivate** activate_array = 0;
- IMFTransform* encoder_if = 0;
- int selected_encoder;
- DWORD additional_flags = MFT_ENUM_FLAG_HARDWARE;
- GUID mft_category;
- MFT_REGISTER_TYPE_INFO codec;
-
- selected_encoder = 0;
-
- if (video)
- {
- mft_category = MFT_CATEGORY_VIDEO_ENCODER;
- codec.guidMajorType = MFMediaType_Video;
- codec.guidSubtype = MFVideoFormat_H264;
- }
- else
- {
- mft_category = MFT_CATEGORY_AUDIO_ENCODER;
- codec.guidMajorType = MFMediaType_Audio;
- codec.guidSubtype = MFAudioFormat_AAC;
- }
-
-please_try_again:
-
- hr = MFTEnumEx(mft_category, MFT_ENUM_FLAG_SYNCMFT | MFT_ENUM_FLAG_ASYNCMFT | additional_flags | MFT_ENUM_FLAG_SORTANDFILTER, 0, &codec, &activate_array, &count);
-
- if (count > 0)
- {
- if (video)
- {
- // List names, looking for a match
- for (i=0; i<count; i++)
- {
- LPWSTR name = 0;
-
- hr = activate_array[i]->lpVtbl->GetAllocatedString(activate_array[i], &MFT_FRIENDLY_NAME_Attribute, &name, 0);
-
- if (!wmemcmp(name, preferred_video_encoder, wcslen(name)))
- selected_encoder = i;
-
- CoTaskMemFree(name);
- }
- }
-
- // Instanciate encoder
- hr = activate_array[selected_encoder]->lpVtbl->ActivateObject(activate_array[0], &IID_IMFTransform, &encoder_if);
-
- for (i=0; i<count; i++)
- RELEASE(activate_array[i]);
-
- CoTaskMemFree(activate_array);
- }
-
- // Some drivers list hardware accelerated encoders but don't allow instanciating them... fall back to first available software encoder
- if (!encoder_if && additional_flags)
- {
- additional_flags = 0;
- selected_encoder = 0;
- goto please_try_again;
- }
-
- return encoder_if; // Return MFT interface to caller, which is responsible for shutting it down / releasing it
-}
-
-
-HRESULT add_video_compression_node (IMFTopology* topology_if, IMFTopologyNode** video_compression_node_ifp)
-{
- HRESULT hr;
- IMFTopologyNode* node_if = 0;
- int video_bit_rate;
-
- // Create transform
- video_compr_transform_if = get_encoder(TRUE);
-
- configure_mft(video_compr_transform_if);
-
- hr = MFCreateMediaType(&h264_config_if);
-
- hr = h264_config_if->lpVtbl->SetGUID(h264_config_if, &MF_MT_MAJOR_TYPE, &MFMediaType_Video);
- hr = h264_config_if->lpVtbl->SetUINT64(h264_config_if, &MF_MT_FRAME_SIZE, frame_size);
- hr = h264_config_if->lpVtbl->SetUINT64(h264_config_if, &MF_MT_FRAME_RATE, frame_rate);
- hr = h264_config_if->lpVtbl->SetUINT32(h264_config_if, &MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
-
- hr = h264_config_if->lpVtbl->SetGUID(h264_config_if, &MF_MT_SUBTYPE, &MFVideoFormat_H264);
-
- video_bit_rate = VIDEO_BIT_RATE;
-
- hr = h264_config_if->lpVtbl->SetUINT32(h264_config_if, &MF_MT_AVG_BITRATE, video_bit_rate);
- hr = h264_config_if->lpVtbl->SetUINT32(h264_config_if, &MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_Main);
- hr = h264_config_if->lpVtbl->SetUINT32(h264_config_if, &MF_MT_MPEG2_LEVEL, eAVEncH264VLevel4_1);
-
-
- hr = video_compr_transform_if->lpVtbl->SetOutputType(video_compr_transform_if, 0, h264_config_if, 0);
- hr = video_compr_transform_if->lpVtbl->SetInputType(video_compr_transform_if, 0, conv_config_if, 0);
-
- RELEASE_Z(conv_config_if);
-
- // Create node
- hr = MFCreateTopologyNode(MF_TOPOLOGY_TRANSFORM_NODE, &node_if);
-
- // Set object pointer
- hr = node_if->lpVtbl->SetObject(node_if, (IUnknown*) video_compr_transform_if);
-
- // Add node
- hr = topology_if->lpVtbl->AddNode(topology_if, node_if);
-
- *video_compression_node_ifp = node_if;
-
- RELEASE(node_if);
-
-
- return hr;
-}
-
-
-HRESULT add_audio_compression_node (IMFTopology* topology_if, IMFTopologyNode** audio_compression_node_ifp)
-{
- HRESULT hr;
- IMFTopologyNode* node_if = 0;
-
- // Create AAC encoding transform
- audio_compr_transform_if = get_encoder(FALSE);
-
- hr = MFCreateMediaType(&aac_config_if);
-
- hr = aac_config_if->lpVtbl->SetGUID(aac_config_if, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
- hr = aac_config_if->lpVtbl->SetGUID(aac_config_if, &MF_MT_SUBTYPE, &MFAudioFormat_AAC);
-
- hr = aac_config_if->lpVtbl->SetUINT32(aac_config_if, &MF_MT_AUDIO_NUM_CHANNELS, 2);
- hr = aac_config_if->lpVtbl->SetUINT32(aac_config_if, &MF_MT_AUDIO_SAMPLES_PER_SECOND, 48000);
- hr = aac_config_if->lpVtbl->SetUINT32(aac_config_if, &MF_MT_AUDIO_BITS_PER_SAMPLE, 16);
- hr = aac_config_if->lpVtbl->SetUINT32(aac_config_if, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, AUDIO_BIT_RATE/8);
-
- // Set audio compression engine parameters
- hr = audio_compr_transform_if->lpVtbl->SetOutputType(audio_compr_transform_if, 0, aac_config_if, 0);
- hr = audio_compr_transform_if->lpVtbl->SetInputType(audio_compr_transform_if, 0, mic_config_if, 0);
-
- RELEASE_Z(mic_config_if);
-
- // Create node
- hr = MFCreateTopologyNode(MF_TOPOLOGY_TRANSFORM_NODE, &node_if);
-
- // Set object pointer
- hr = node_if->lpVtbl->SetObject(node_if, (IUnknown*) audio_compr_transform_if);
-
- // Add node
- hr = topology_if->lpVtbl->AddNode(topology_if, node_if);
-
- *audio_compression_node_ifp = node_if;
-
- RELEASE(node_if);
-
- return hr;
-}
-
-
-HRESULT add_color_transform_node (IMFTopology* topology_if, IMFTopologyNode** color_transform_node_ifp)
-{
- // The webcam sends a RGB stream that needs to be converted to YUV before it reaches the h264 encoder
- // The NV12 encoding is suitable for use by h264 hardware encoders ;
- // MFVideoFormat_YUY2 might be more appropriate if the Microsoft H.264 software encoder is used
- HRESULT hr;
- IMFTopologyNode* node_if = 0;
-
- hr = MFCreateMediaType(&conv_config_if);
-
- hr = conv_config_if->lpVtbl->SetGUID(conv_config_if, &MF_MT_MAJOR_TYPE, &MFMediaType_Video);
- hr = conv_config_if->lpVtbl->SetGUID(conv_config_if, &MF_MT_SUBTYPE, &MFVideoFormat_NV12);
- hr = conv_config_if->lpVtbl->SetUINT64(conv_config_if, &MF_MT_FRAME_SIZE, frame_size);
- hr = conv_config_if->lpVtbl->SetUINT64(conv_config_if, &MF_MT_FRAME_RATE, frame_rate);
- hr = conv_config_if->lpVtbl->SetUINT32(conv_config_if, &MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
-
- // Create output node
- hr = MFCreateTopologyNode(MF_TOPOLOGY_TRANSFORM_NODE, &node_if);
-
- color_transform_if = 0;
-
- hr = CoCreateInstance(&CLSID_CColorConvertDMO, NULL, CLSCTX_INPROC, &IID_IMFTransform, (void**) &color_transform_if);
-
- hr = color_transform_if->lpVtbl->SetOutputType(color_transform_if, 0, conv_config_if, 0);
- hr = color_transform_if->lpVtbl->SetInputType(color_transform_if, 0, cam_config_if, 0);
-
- RELEASE_Z(cam_config_if);
-
- hr = node_if->lpVtbl->SetObject(node_if, (IUnknown*) color_transform_if);
-
- // Add this node to the topology
- hr = topology_if->lpVtbl->AddNode(topology_if, node_if);
-
- *color_transform_node_ifp = node_if;
-
- RELEASE(node_if);
-
- return hr;
-}
-
-
-HRESULT add_file_output_nodes (IMFTopology* topology_if, IMFTopologyNode** video_output_node_ifp, IMFTopologyNode** audio_output_node_ifp, wchar_t* file_name)
-{
- // Create an archive sink for AVC/AAC output then initialize a matching node and add it to the topology
-
- HRESULT hr;
- IMFStreamSink *video_stream_sink_if = 0;
- IMFStreamSink *audio_stream_sink_if = 0;
- IMFTopologyNode* v_node_if = 0;
- IMFTopologyNode* a_node_if = 0;
- IMFByteStream* byte_stream_if = 0;
-
- hr = MFCreateFile(MF_ACCESSMODE_READWRITE, MF_OPENMODE_DELETE_IF_EXIST, MF_FILEFLAGS_NONE, file_name, &byte_stream_if);
-
- hr = MFCreateMPEG4MediaSink(byte_stream_if, h264_config_if, aac_config_if, &media_sink_if);
-
- if (hr == S_OK)
- {
- if (h264_config_if)
- {
- // Get video sink
- hr = media_sink_if->lpVtbl->GetStreamSinkByIndex(media_sink_if, 0, &video_stream_sink_if);
-
- // Create video output node
- hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &v_node_if);
-
- // Associate video sink to node
- hr = v_node_if->lpVtbl->SetObject(v_node_if, (IUnknown*) video_stream_sink_if);
-
- // Add node to the topology
- hr = topology_if->lpVtbl->AddNode(topology_if, v_node_if);
- }
-
- if (aac_config_if)
- {
- hr = media_sink_if->lpVtbl->GetStreamSinkByIndex(media_sink_if, h264_config_if ? 1 : 0, &audio_stream_sink_if);
- hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &a_node_if);
- hr = a_node_if->lpVtbl->SetObject(a_node_if, (IUnknown*) audio_stream_sink_if);
- hr = topology_if->lpVtbl->AddNode(topology_if, a_node_if);
- }
- }
-
- *video_output_node_ifp = v_node_if;
- *audio_output_node_ifp = a_node_if;
-
- RELEASE_Z(h264_config_if);
- RELEASE_Z(aac_config_if);
- RELEASE(v_node_if);
- RELEASE(a_node_if);
- RELEASE(video_stream_sink_if);
- RELEASE(audio_stream_sink_if);
- RELEASE(byte_stream_if);
-
- return hr;
-}
-
-
-HRESULT add_tee_node(IMFTopology* topology_if, IMFTopologyNode** tee_node_ifp)
-{
- // We'll use a tee node to split the video stream towards EVR (for preview) and media sink
- HRESULT hr;
- IMFTopologyNode* node_if = 0;
-
- // Create node
- hr = MFCreateTopologyNode(MF_TOPOLOGY_TEE_NODE, &node_if);
-
-/* hr = node_if->lpVtbl->SetInputPrefType(node_if, 0, cam_config_if);
- hr = node_if->lpVtbl->SetOutputPrefType(node_if, 0, cam_config_if);
- hr = node_if->lpVtbl->SetOutputPrefType(node_if, 1, cam_config_if);*/
-
- // Add node
- hr = topology_if->lpVtbl->AddNode(topology_if, node_if);
-
- *tee_node_ifp = node_if;
-
- RELEASE(node_if);
-
- return hr;
-}
-
-
-HRESULT create_av_source (IMFMediaSource** av_source_ifp)
-{
- // We may get video from a cam and audio from a separate mic - Handle them as two streams coming out of a single media source
- HRESULT hr;
- IMFCollection* collection_if = 0;
-
- hr = MFCreateCollection(&collection_if);
-
- if (video_source_if)
- hr = collection_if->lpVtbl->AddElement(collection_if, (IUnknown*) video_source_if);
-
- if (audio_source_if)
- hr = collection_if->lpVtbl->AddElement(collection_if, (IUnknown*) audio_source_if);
-
- hr = MFCreateAggregateSource(collection_if, av_source_ifp);
-
- RELEASE(collection_if);
-
- return hr;
-}
-
-
-HRESULT select_video_capture_device (IMFMediaSource** video_source_ifp, wchar_t* preferred_device_name)
-{
- // Select a suitable video capture device and initialize video source object
-
- HRESULT hr;
- IMFAttributes* attributes_if = 0;
- IMFActivate** activate_array;
- UINT32 count = 0;
- IMFActivate* activate_if;
- UINT32 i;
- int selected_video_capture_dev = 0;
-
- *video_source_ifp = 0;
-
- // Create a container for enumeration criteria
- hr = MFCreateAttributes(&attributes_if, 1);
-
- // List video capture devices
- hr = attributes_if->lpVtbl->SetGUID(attributes_if, &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
- hr = MFEnumDeviceSources(attributes_if, &activate_array, &count);
-
- // Release attributes
- RELEASE(attributes_if);
-
- // List names
- for (i=0; i<count; i++)
- {
- LPWSTR name = 0;
-
- hr = activate_array[i]->lpVtbl->GetAllocatedString(activate_array[i], &MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &name, 0);
-
- if (!wmemcmp(name, preferred_device_name, wcslen(name)))
- selected_video_capture_dev = i;
-
- CoTaskMemFree(name);
- }
-
- // No camera
- if (count == 0)
- return S_OK;
-
- activate_if = activate_array[selected_video_capture_dev];
-
- // Get media source for selected capture device
- hr = activate_if->lpVtbl->ActivateObject(activate_if, &IID_IMFMediaSource, video_source_ifp);
-
- // Release array elements
- for (i=0; i<count; i++)
- {
- RELEASE(activate_array[i]);
- }
-
- CoTaskMemFree(activate_array);
-
- return hr;
-}
-
-
-HRESULT select_audio_capture_device (IMFMediaSource** audio_source_ifp)
-{
- // Select a suitable video audio device and initialize audio source object
-
- HRESULT hr;
- IMFAttributes* attributes_if = 0;
- IMFActivate** activate_array;
- UINT32 count = 0;
- IMFActivate* activate_if = 0;
- UINT32 i;
- int selected_audio_capture_dev = 0;
-
- *audio_source_ifp = 0;
-
- // Create a container for enumeration criteria
- hr = MFCreateAttributes(&attributes_if, 1);
-
- // List audio capture devices
- hr = attributes_if->lpVtbl->SetGUID(attributes_if, &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_GUID);
- hr = MFEnumDeviceSources(attributes_if, &activate_array, &count);
-
- // List names
- for (i=0; i<count; i++)
- {
- LPWSTR name = 0;
-
- hr = activate_array[i]->lpVtbl->GetAllocatedString(activate_array[i], &MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &name, 0);
-
- if (!wmemcmp(name, preferred_audio_capture_dev, wcslen(name)))
- selected_audio_capture_dev = i;
-
- CoTaskMemFree(name);
- }
-
- if (count)
- activate_if = activate_array[selected_audio_capture_dev];
-
-
- // Release attributes
- RELEASE(attributes_if);
-
- // Get media source for selected capture device
- if (activate_if)
- hr = activate_if->lpVtbl->ActivateObject(activate_if, &IID_IMFMediaSource, audio_source_ifp);
-
- // Release array elements
- for (i=0; i<count; i++)
- {
- RELEASE(activate_array[i]);
- }
-
- CoTaskMemFree(activate_array);
-
- return hr;
-}
-
-
-HRESULT add_video_preview_node (IMFTopology* topology_if, IMFTopologyNode** video_preview_node_ifp)
-{
- // Initialize the video preview sink and add it to the topology
- HRESULT hr;
- IMFActivate* activate_if = 0;
- IMFTopologyNode* node_if = 0;
-
- // Create output node
- hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &node_if);
-
- // Create activation object for EVR sink - clip to preview window
- hr = MFCreateVideoRendererActivate(hPreviewWnd, &activate_if);
-
- // Associate it to our newly created output node
- hr = node_if->lpVtbl->SetObject(node_if, (IUnknown*) activate_if);
-
- // Add this node to the topology
- hr = topology_if->lpVtbl->AddNode(topology_if, node_if);
-
- *video_preview_node_ifp = node_if;
-
- RELEASE(node_if);
- RELEASE(activate_if);
-
- return S_OK;
-}
-
-
-void camera_resize_window(int width, int height)
-{
- HRESULT hr;
-
- if (video_display_control_if)
- {
- RECT rc = {0, 0, width, height};
- hr = video_display_control_if->lpVtbl->SetVideoPosition(video_display_control_if, NULL, &rc);
- }
-}
-
-void camera_notify_display_change (void)
-{
-}
-
-void prepare_video_framing (IMFTopology* topology_if)
-{
- HRESULT hr;
- IMFPresentationDescriptor* av_pres_descr_if = 0;
- IMFTopologyNode* video_capture_node_if = 0;
- IMFTopologyNode* video_preview_node_if = 0;
- IMFMediaSource* av_source_if = 0;
-
- // Select video input device
- hr = select_video_capture_device(&video_source_if, preferred_video_capture_dev);
-
- // Create combined AV source - a media session can only be associated to a single source
- // Not required since we're not dealing with audio here though, but let's share code with the video case
- hr = create_av_source(&av_source_if);
-
- if (av_source_if)
- {
- // Create a presentation descriptor
- hr = av_source_if->lpVtbl->CreatePresentationDescriptor(av_source_if, &av_pres_descr_if);
-
- // Add capture node and connect it to the topology
- hr = add_video_capture_node(topology_if, av_source_if, av_pres_descr_if, &video_capture_node_if);
-
- // Our AV source object is now referenced by its users, let's release our own ref
- RELEASE(av_source_if);
-
- // The presentation descriptor isn't needed anymore either
- RELEASE(av_pres_descr_if);
-
- // Create video renderer
- hr = add_video_preview_node(topology_if, &video_preview_node_if);
-
- RELEASE_Z(cam_config_if);
-
- // Video stream connected to preview node
- if (video_capture_node_if)
- hr = video_capture_node_if->lpVtbl->ConnectOutput(video_capture_node_if, 0, video_preview_node_if, 0);
- }
-
- // OK we're done with nodes - release our COM references
- RELEASE(video_capture_node_if);
- RELEASE(video_preview_node_if);
-}
-
-void prepare_video_capture (IMFTopology* topology_if, wchar_t* file_name)
-{
- // Record video to file_name
-
- HRESULT hr;
- IMFPresentationDescriptor* av_pres_descr_if = 0;
- IMFTopologyNode* video_capture_node_if = 0;
- IMFTopologyNode* audio_capture_node_if = 0;
- IMFTopologyNode* video_preview_node_if = 0;
- IMFTopologyNode* tee_node_if = 0;
- IMFTopologyNode* color_transform_node_if = 0;
- IMFTopologyNode* video_compression_node_if = 0;
- IMFTopologyNode* audio_compression_node_if = 0;
- IMFTopologyNode* video_output_node_if = 0;
- IMFTopologyNode* audio_output_node_if = 0;
- IMFMediaSource* av_source_if = 0;
-
- // Select video and audio input devices
- hr = select_video_capture_device(&video_source_if, preferred_video_capture_dev);
- hr = select_audio_capture_device(&audio_source_if);
-
- // Create combined AV source - a media session can only be associated to a single source
- hr = create_av_source(&av_source_if);
-
- if (av_source_if)
- {
- // Create a presentation descriptor in charge of both audio and video streams
- hr = av_source_if->lpVtbl->CreatePresentationDescriptor(av_source_if, &av_pres_descr_if);
-
- // Add video and audio capture nodes and connect them to the topology
- hr = add_video_capture_node(topology_if, av_source_if, av_pres_descr_if, &video_capture_node_if);
- hr = add_audio_capture_node(topology_if, av_source_if, av_pres_descr_if, &audio_capture_node_if);
-
-
- if (video_capture_node_if)
- {
- // Create video renderer
- hr = add_video_preview_node(topology_if, &video_preview_node_if);
-
- // Create video stream splitter
- hr = add_tee_node(topology_if, &tee_node_if);
-
- // Create video compression node, as well as colorspace conversion node, required for RGB->YUV conversion prior to H.264 compression
- hr = add_color_transform_node(topology_if, &color_transform_node_if);
- hr = add_video_compression_node(topology_if, &video_compression_node_if);
- }
-
- if (audio_capture_node_if)
- {
- // AAC transform
- hr = add_audio_compression_node(topology_if, &audio_compression_node_if);
- }
-
- // Our AV source object is now referenced by its users, let's release our own ref
- RELEASE(av_source_if);
-
- // The presentation descriptor isn't needed anymore either
- RELEASE(av_pres_descr_if);
-
- // Create sink nodes
- hr = add_file_output_nodes(topology_if, &video_output_node_if, &audio_output_node_if, file_name);
-
- if (hr == S_OK)
- {
- if (video_capture_node_if)
- {
- // Video stream connected to colorspace conversion node ; better do it before going through the tee
- hr = video_capture_node_if->lpVtbl->ConnectOutput(video_capture_node_if, 0, color_transform_node_if, 0);
-
- // Colorspace conversion output connected to tee
- hr = color_transform_node_if->lpVtbl->ConnectOutput(color_transform_node_if, 0, tee_node_if, 0);
-
- // Tee outputs connected to video preview node and video compression node
- hr = tee_node_if->lpVtbl->ConnectOutput(tee_node_if, 0, video_preview_node_if, 0);
- hr = tee_node_if->lpVtbl->ConnectOutput(tee_node_if, 1, video_compression_node_if, 0);
-
- // Direct compressed video stream to video archival sink
- hr = video_compression_node_if->lpVtbl->ConnectOutput(video_compression_node_if, 0, video_output_node_if, 0);
- }
-
- if (audio_capture_node_if)
- {
- // Audio input connected to audio encoder
- hr = audio_capture_node_if->lpVtbl->ConnectOutput(audio_capture_node_if, 0, audio_compression_node_if, 0);
-
- // Direct audio stream to audio sink
- hr = audio_compression_node_if->lpVtbl->ConnectOutput(audio_compression_node_if, 0, audio_output_node_if, 0);
- }
- }
- }
-
- // OK we're done with nodes - release our COM references
- RELEASE(video_capture_node_if);
- RELEASE(audio_capture_node_if);
- RELEASE(video_preview_node_if);
- RELEASE(color_transform_node_if);
- RELEASE(video_compression_node_if);
- RELEASE(audio_compression_node_if);
- RELEASE(tee_node_if);
- RELEASE(video_output_node_if);
- RELEASE(audio_output_node_if);
-}
-
-
-void prepare_photo_capture (IMFTopology* topology_if)
-{
- HRESULT hr;
- IMFPresentationDescriptor* av_pres_descr_if = 0;
- IMFTopologyNode* video_capture_node_if = 0;
- IMFTopologyNode* video_preview_node_if = 0;
- IMFTopologyNode* tee_node_if = 0;
- IMFTopologyNode* frame_grabber_if = 0;
- IMFMediaSource* av_source_if = 0;
-
- // Select video input device
- hr = select_video_capture_device(&video_source_if, preferred_video_capture_dev);
-
- // Create combined AV source - a media session can only be associated to a single source
- // Not required since we're not dealing with audio here though, but let's share code with the video case
- hr = create_av_source(&av_source_if);
-
- if (av_source_if)
- {
- // Create a presentation descriptor
- hr = av_source_if->lpVtbl->CreatePresentationDescriptor(av_source_if, &av_pres_descr_if);
-
- // Add capture node and connect it to the topology
- hr = add_video_capture_node(topology_if, av_source_if, av_pres_descr_if, &video_capture_node_if);
-
- // Our AV source object is now referenced by its users, let's release our own ref
- RELEASE(av_source_if);
-
- // The presentation descriptor isn't needed anymore either
- RELEASE(av_pres_descr_if);
-
- // Create video renderer
- hr = add_video_preview_node(topology_if, &video_preview_node_if);
-
- // Create video stream splitter
- hr = add_tee_node(topology_if, &tee_node_if);
-
- // Create frame grabber sink node
- hr = add_frame_grabber_node(topology_if, cam_config_if, &frame_grabber_if);
-
- RELEASE_Z(cam_config_if);
-
- // Video stream connected to tee input
- hr = video_capture_node_if->lpVtbl->ConnectOutput(video_capture_node_if, 0, tee_node_if, 0);
-
- // Tee outputs connected to video preview node and frame grabber node
- hr = tee_node_if->lpVtbl->ConnectOutput(tee_node_if, 0, video_preview_node_if, 0);
- hr = tee_node_if->lpVtbl->ConnectOutput(tee_node_if, 1, frame_grabber_if, 0);
- }
-
- // OK we're done with nodes - release our COM references
- RELEASE(video_capture_node_if);
- RELEASE(video_preview_node_if);
- RELEASE(tee_node_if);
- RELEASE(frame_grabber_if);
-}
-
-
-IMFTopology* build_topology (int topo_type)
-{
- // Build a topology suitable for the specified task
- // The topology will then be associated to a media session, and destroyed when the session completes
- HRESULT hr;
- IMFTopology* topology_if = 0;
- SYSTEMTIME t;
-
- hr = MFStartup(MF_VERSION, MFSTARTUP_NOSOCKET);
-
- // Create a blank topology
- hr = MFCreateTopology(&topology_if);
-
- // Since we're targeting Windows 7 and newer, enable available hardware acceleration
- topology_if->lpVtbl->SetUINT32(topology_if, &MF_TOPOLOGY_DXVA_MODE, MFTOPOLOGY_DXVA_FULL);
- topology_if->lpVtbl->SetUINT32(topology_if, &MF_TOPOLOGY_HARDWARE_MODE, MFTOPOLOGY_HWMODE_USE_HARDWARE);
-
- switch (topo_type)
- {
- case PHOTO_CAPTURE_TOPO:
- prepare_photo_capture(topology_if);
- break;
-
- case VIDEO_FRAMING_TOPO:
- prepare_video_framing(topology_if);
- break;
-
- case VIDEO_CAPTURE_TOPO:
- GetLocalTime(&t);
- swprintf(last_recorded_file_name, MAX_FILE_NAME_LEN, L"%0d%02d%02d-%02d%02d%02d.mp4", t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond);
- swprintf(last_recorded_file_name_full, MAX_FILE_NAME_LEN, L"%s%s", temp_directory_win, last_recorded_file_name);
- last_recorded_file_name_full[MAX_FILE_NAME_LEN] = 0;
- prepare_video_capture(topology_if, last_recorded_file_name_full);
- break;
-
- case AUDIO_CAPTURE_TOPO:
- case AUDIO_PLAYBACK_TOPO:
- break;
- }
-
- return topology_if;
-}
-
-//-------------------------------------------------------------------------------------------------
-
-unsigned int __stdcall session_control_proc(void* param)
-{
- // Create a session for the current topology and manage its lifecycle
- // The session can be stopped from another thread
-
- HRESULT hr;
- PROPVARIANT var;
- BOOL done = FALSE;
- IMFTopology* topology_if = (IMFTopology*) param;
-
- set_thread_name(-1, "Media Session Control");
-
- CoInitialize(0);
-
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
-
- hr = MFCreateMediaSession(0, &media_session_if);
-
- if (!media_session_if)
- goto the_end;
-
- // Associate topology to session
- hr = media_session_if->lpVtbl->SetTopology(media_session_if, MFSESSION_SETTOPOLOGY_IMMEDIATE, topology_if);
-
- if (hr != S_OK)
- goto the_end;
-
- do
- {
- HRESULT status = 0;
- IMFMediaEvent *event_if = 0;
- MediaEventType media_event_type = 0;
- MF_TOPOSTATUS topo_status = 0;
-
- hr = media_session_if->lpVtbl->GetEvent(media_session_if, 0, &event_if);
- hr = event_if->lpVtbl->GetStatus(event_if, &status);
- hr = event_if->lpVtbl->GetType(event_if, &media_event_type);
-
- if (SUCCEEDED(hr) && SUCCEEDED(status))
- {
- switch (media_event_type)
- {
- case MESessionTopologyStatus:
-
- hr = event_if->lpVtbl->GetUINT32(event_if, &MF_EVENT_TOPOLOGY_STATUS, (UINT32*) &topo_status);
-
- if (SUCCEEDED(hr))
- {
- switch (topo_status)
- {
- case MF_TOPOSTATUS_READY:
- // Get IMFVideoDisplayControl interface - we'll need it around to control the video renderer rectangle
- hr = MFGetService((IUnknown*) media_session_if, &MR_VIDEO_RENDER_SERVICE, &IID_IMFVideoDisplayControl, (void**) &video_display_control_if);
-
- // Fire up media playback (with no particular starting position)
- PropVariantInit(&var);
- var.vt = VT_EMPTY;
- hr = media_session_if->lpVtbl->Start(media_session_if, &GUID_NULL, &var);
- PropVariantClear(&var);
- break;
-
- case MF_TOPOSTATUS_STARTED_SOURCE:
- start_time = MFGetSystemTime();
- break;
-
- case MF_TOPOSTATUS_ENDED:
- break;
- }
- }
- break;
-
- case MESessionStarted:
- break;
-
- case MESessionEnded:
- // In the case of capture, another thread will call Stop
- hr = media_session_if->lpVtbl->Stop(media_session_if);
- break;
-
- case MESessionStopped:
- // The MPEG 4 media sink is finalizable, and the session should invoke the finalization routines at this point
- hr = media_session_if->lpVtbl->Close(media_session_if);
- break;
-
- case MESessionClosed:
- done = TRUE;
- break;
-
- default:
- break;
- }
- }
-
- RELEASE(event_if);
-
- if (FAILED(hr) || FAILED(status))
- {
- done = TRUE;
- }
-
- }
- while (!done);
-
- // Session closed - sources, sinks and activated objects need to be closed before being released
-
-the_end:
-
- if (audio_source_if)
- {
- audio_source_if->lpVtbl->Shutdown(audio_source_if);
- RELEASE_Z(audio_source_if);
- }
-
- if (video_source_if)
- {
- video_source_if->lpVtbl->Shutdown(video_source_if);
- RELEASE_Z(video_source_if);
- }
-
- if (color_transform_if)
- {
- MFShutdownObject((IUnknown*) color_transform_if);
- RELEASE_Z(color_transform_if);
- }
-
- if (video_compr_transform_if)
- {
- MFShutdownObject((IUnknown*) video_compr_transform_if);
- RELEASE_Z(video_compr_transform_if);
- }
-
- if (audio_compr_transform_if)
- {
- MFShutdownObject((IUnknown*) audio_compr_transform_if);
- RELEASE_Z(audio_compr_transform_if);
- }
-
- if (media_sink_if)
- {
- media_sink_if->lpVtbl->Shutdown(media_sink_if);
- RELEASE_Z(media_sink_if);
- }
-
- RELEASE_Z(video_display_control_if); // @@@ possible concurrent usage from another thread
-
- if (media_session_if)
- {
- media_session_if->lpVtbl->Shutdown(media_session_if);
- RELEASE_Z(media_session_if);
- }
-
- // Exit thread
- return 0;
-}
-
-void start_session (int topo_type)
-{
- IMFTopology* topology_if;
-
- topology_if = build_topology(topo_type);
-
- session_control_thread = CreateThread(0, 0, session_control_proc, (void*) topology_if, 0, 0);
-}
-
-void start_photo_capture (void)
-{
- // Check if a session is already running
- if (session_control_thread)
- return;
-
- // Show video preview and prepare to grab frames
- start_session(PHOTO_CAPTURE_TOPO);
-}
-
-void start_video_framing (void)
-{
- // Check if a session is already running
- if (session_control_thread)
- return;
-
- // Show video preview
- start_session(VIDEO_FRAMING_TOPO);
-}
-
-void start_video_capture (void)
-{
- // Check if a session is already running
- if (session_control_thread)
- return;
-
- // Show video preview and prepare to output to a mp4 file
- start_session(VIDEO_CAPTURE_TOPO);
-}
-
-void start_audio_capture (void)
-{
- // Check if a session is already running
- if (session_control_thread)
- return;
-
- // Prepare to capture audio
- start_session(AUDIO_CAPTURE_TOPO);
-}
-
-void start_audio_playback (void)
-{
- // Check if a session is already running
- if (session_control_thread)
- return;
-
- // Prepare to play audio
- start_session(AUDIO_PLAYBACK_TOPO);
-}
-
-LONGLONG end_active_session (void)
-{
- HRESULT hr;
- LONGLONG session_duration = 0;
-
- if (media_session_if)
- {
- session_duration = MFGetSystemTime() - start_time;
-
- hr = media_session_if->lpVtbl->Stop(media_session_if);
-
- // Wait until the session control thread exits
- WaitForSingleObject(session_control_thread, INFINITE);
- }
-
- MFShutdown();
-
- session_control_thread = 0;
-
- return session_duration;
-}
-
-void stop_video_capture (void)
-{
- LONGLONG duration = end_active_session();
-
- fix_mp4_duration(last_recorded_file_name_full, duration);
-}
-
-void stop_video_framing (void)
-{
- end_active_session();
-}
-
-void snap_picture (void)
-{
- // Raise frame grab flag
- grab_first_available_frame = TRUE;
-}
-
-//-------------------------------------------------------------------------------------------------
-
-#define PREVIEW_WINDOW_CLASS L"Preview Area"
-
-LRESULT CALLBACK PreviewWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- // WindowProc for the simple window where the video preview goes
- int width, height;
-
- switch (uMsg)
- {
- case WM_SIZE:
- width = LOWORD(lParam);
- height = HIWORD(lParam);
-
- // Resize video preview area
- camera_resize_window(width, height);
- break;
-
- case WM_RBUTTONDOWN:
- // Display the configuration dialog if a right click is detected
- SendMessage(GetParent(hWnd), WM_COMMAND, ID_PARAMETERS, 0);
- break;
-
- default:
- break;
- }
-
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
-}
-
-//-------------------------------------------------------------------------------------------------
-
-#define CAPTURE_WINDOW_CLASS L"Cordova Capture Window"
-#define RIGHT_MARGIN 32
-
-#define TOOLBAR_ID 1
-
-#define NUM_BUTTONS 5
-#define NUM_IMAGES 5
-
-#define BUTTON_WIDTH 24
-#define BUTTON_HEIGHT 25
-#define BITMAP_WIDTH 120
-#define BITMAP_HEIGHT 24
-
-HWND hToolBar;
-
-TBBUTTON button_array_video_framing[] =
-{
- { 0, ID_START_VIDEO,TBSTATE_ENABLED | TBSTATE_WRAP, BTNS_BUTTON },
- { 1, ID_STOP_VIDEO, TBSTATE_ENABLED | TBSTATE_WRAP | TBSTATE_HIDDEN, BTNS_BUTTON },
- { 3, ID_PARAMETERS, TBSTATE_ENABLED | TBSTATE_WRAP, BTNS_BUTTON },
- { 4, ID_RETURN, TBSTATE_ENABLED | TBSTATE_WRAP, BTNS_BUTTON }
-};
-
-TBBUTTON button_array_video_capture[] =
-{
- { 0, ID_START_VIDEO,TBSTATE_ENABLED | TBSTATE_WRAP | TBSTATE_HIDDEN, BTNS_BUTTON },
- { 1, ID_STOP_VIDEO, TBSTATE_ENABLED | TBSTATE_WRAP, BTNS_BUTTON },
- { 3, ID_PARAMETERS, TBSTATE_ENABLED | TBSTATE_WRAP, BTNS_BUTTON },
- { 4, ID_RETURN, TBSTATE_ENABLED | TBSTATE_WRAP, BTNS_BUTTON }
-};
-
-TBBUTTON button_array_photo[] =
-{
- { 2, ID_TAKE_PHOTO, TBSTATE_ENABLED | TBSTATE_WRAP, BTNS_BUTTON },
- { 3, ID_PARAMETERS, TBSTATE_ENABLED | TBSTATE_WRAP, BTNS_BUTTON },
- { 4, ID_RETURN, TBSTATE_ENABLED | TBSTATE_WRAP, BTNS_BUTTON }
-};
-
-//-------------------------------------------------------------------------------------------------
-
-int populate_capture_device_list (HWND hList, const GUID* category, wchar_t* suggested_name)
-{
- HRESULT hr;
- IMFAttributes* attributes_if = 0;
- IMFActivate** activate_array = 0;
- UINT32 count = 0;
- UINT32 i;
- int selection = 0;
-
- // Create a container for enumeration criteria
- hr = MFCreateAttributes(&attributes_if, 1);
-
- // List video capture devices
- hr = attributes_if->lpVtbl->SetGUID(attributes_if, &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, category);
- hr = MFEnumDeviceSources(attributes_if, &activate_array, &count);
-
- // Release attributes
- RELEASE(attributes_if);
-
- // List names
- for (i=0; i<count; i++)
- {
- LPWSTR name = 0;
-
- hr = activate_array[i]->lpVtbl->GetAllocatedString(activate_array[i], &MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &name, 0);
-
- ComboBox_AddString(hList, name);
-
- if (!wmemcmp(name, suggested_name, wcslen(name)))
- selection = i;
-
- CoTaskMemFree(name);
- }
-
-
- // Release array elements
- for (i=0; i<count; i++)
- {
- RELEASE(activate_array[i]);
- }
-
- CoTaskMemFree(activate_array);
-
- ComboBox_SetCurSel(hList, selection);
-
- return count;
-}
-
-void populate_video_encoder_list (HWND hList)
-{
- HRESULT hr;
- DWORD count = 0;
- DWORD i;
- IMFActivate** activate_array = 0;
- DWORD additional_flags = MFT_ENUM_FLAG_HARDWARE;
- GUID mft_category;
- MFT_REGISTER_TYPE_INFO codec;
- int selection = 0;
-
- mft_category = MFT_CATEGORY_VIDEO_ENCODER;
- codec.guidMajorType = MFMediaType_Video;
- codec.guidSubtype = MFVideoFormat_H264;
-
- hr = MFTEnumEx(mft_category, MFT_ENUM_FLAG_SYNCMFT | MFT_ENUM_FLAG_ASYNCMFT | additional_flags | MFT_ENUM_FLAG_SORTANDFILTER, 0, &codec, &activate_array, &count);
-
- // List names
- for (i=0; i<count; i++)
- {
- LPWSTR name = 0;
-
- hr = activate_array[i]->lpVtbl->GetAllocatedString(activate_array[i], &MFT_FRIENDLY_NAME_Attribute, &name, 0);
-
- if (!wmemcmp(name, preferred_video_encoder, wcslen(name)))
- selection = i;
-
- ComboBox_AddString(hList, name);
-
- CoTaskMemFree(name);
- }
-
- for (i=0; i<count; i++)
- RELEASE(activate_array[i]);
-
- ComboBox_SetCurSel(hList, selection);
-
- CoTaskMemFree(activate_array);
-}
-
-//-------------------------------------------------------------------------------------------------
-
-void populate_resolution_list(HWND hList, wchar_t* preferred_resolution, wchar_t* preferred_device_name)
-{
- HRESULT hr;
- IMFMediaSource* source_if = 0;
- IMFPresentationDescriptor* pres_descr_if = 0;
- BOOL selected;
- DWORD stream_count;
- DWORD i;
- GUID media_type;
- IMFMediaTypeHandler* cam_type_handler_if = 0;
- IMFStreamDescriptor* stream_desc_if = 0;
- wchar_t buf[80];
- int selected_index = -1;
- DWORD count;
- DWORD w, h;
- DWORD fr1, fr2;
- GUID format;
- int buf_len;
- UINT32 interlace_mode = 0;
-
- ComboBox_ResetContent(hList);
-
- select_video_capture_device(&source_if, preferred_device_name);
-
- if (!source_if)
- return;
-
- hr = source_if->lpVtbl->CreatePresentationDescriptor(source_if, &pres_descr_if);
-
- hr = pres_descr_if->lpVtbl->GetStreamDescriptorCount(pres_descr_if, &stream_count);
-
- for (i=0; i<stream_count; i++)
- {
- hr = pres_descr_if->lpVtbl->GetStreamDescriptorByIndex(pres_descr_if, i, &selected, &stream_desc_if);
-
- if (selected)
- {
- hr = stream_desc_if->lpVtbl->GetMediaTypeHandler(stream_desc_if, &cam_type_handler_if);
- hr = cam_type_handler_if->lpVtbl->GetMajorType(cam_type_handler_if, &media_type);
-
- if (IsEqualGUID(&media_type, &MFMediaType_Video))
- {
- // Enumerate supported media types
- {
- cam_type_handler_if->lpVtbl->GetMediaTypeCount(cam_type_handler_if, &count);
-
- for (i=0; i<count; i++)
- {
- cam_type_handler_if->lpVtbl->GetMediaTypeByIndex(cam_type_handler_if, i, &cam_config_if);
-
- hr = cam_config_if->lpVtbl->GetGUID(cam_config_if, &MF_MT_SUBTYPE, &format);
- hr = cam_config_if->lpVtbl->GetUINT64(cam_config_if, &MF_MT_FRAME_SIZE, &frame_size);
- hr = cam_config_if->lpVtbl->GetUINT64(cam_config_if, &MF_MT_FRAME_RATE, &frame_rate);
- hr = cam_config_if->lpVtbl->GetUINT32(cam_config_if, &MF_MT_INTERLACE_MODE, &interlace_mode);
-
- if (interlace_mode == MFVideoInterlace_Progressive)
- {
- w = frame_size >> 32;
- h = (DWORD) frame_size;
- fr1 = frame_rate >> 32;
- fr2 = (DWORD) frame_rate;
-
- buf_len = wsprintf(buf, L"%d x %d @ %d fps %s", w, h, fr1/fr2, identify_format(&format)/*, interlace_mode == 2 ? L'p' : L'i'*/);
-
- ComboBox_AddString(hList, buf);
-
- if (!wmemcmp(buf, preferred_resolution, buf_len))
- {
- selected_index = i;
- ComboBox_SetCurSel(hList, i);
- }
- }
- RELEASE(cam_config_if);
- }
- }
- }
-
- RELEASE(cam_type_handler_if);
- }
-
- RELEASE(stream_desc_if);
-
- // If no match was found with requested resolution, select first available resolution
- if (selected_index == -1)
- ComboBox_SetCurSel(hList, 0);
- }
-
- RELEASE(pres_descr_if);
-}
-
-//-------------------------------------------------------------------------------------------------
-
-BOOL update_selected_video_capture_device(wchar_t* new_val)
-{
- int len = wcslen(new_val);
-
- if (len > MAX_DEVICE_NAME_LEN)
- len = MAX_DEVICE_NAME_LEN;
-
- if (wmemcmp(new_val, preferred_video_capture_dev, len))
- {
- wmemcpy(preferred_video_capture_dev, new_val, len);
- preferred_video_capture_dev[len] = 0;
- save_pref(PREF_VIDEO_DEVICE, preferred_video_capture_dev);
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-BOOL update_selected_audio_capture_device(wchar_t* new_val)
-{
- int len = wcslen(new_val);
-
- if (len > MAX_DEVICE_NAME_LEN)
- len = MAX_DEVICE_NAME_LEN;
-
- if (wmemcmp(new_val, preferred_audio_capture_dev, len))
- {
- wmemcpy(preferred_audio_capture_dev, new_val, len);
- preferred_audio_capture_dev[len] = 0;
- save_pref(PREF_AUDIO_DEVICE, preferred_audio_capture_dev);
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-BOOL update_selected_resolution(wchar_t* new_val)
-{
- wchar_t* pref_name;
- wchar_t* pref_val;
-
- int len = wcslen(new_val);
-
- if (len > MAX_DEVICE_NAME_LEN)
- len = MAX_DEVICE_NAME_LEN;
-
- if (current_action_code == ACTION_PHOTO_CAPTURE)
- {
- pref_name = PREF_PHOTO_RESOLUTION;
- pref_val = preferred_photo_resolution;
- }
- else
- {
- pref_name = PREF_VIDEO_RESOLUTION;
- pref_val = preferred_video_resolution;
- }
-
- if (wmemcmp(new_val, pref_val, len))
- {
- wmemcpy(pref_val, new_val, len);
- pref_val[len] = 0;
- save_pref(pref_name, pref_val);
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-BOOL update_selected_video_encoder(wchar_t* new_val)
-{
- int len = wcslen(new_val);
-
- if (len > MAX_DEVICE_NAME_LEN)
- len = MAX_DEVICE_NAME_LEN;
-
- if (wmemcmp(new_val, preferred_video_encoder, len))
- {
- wmemcpy(preferred_video_encoder, new_val, len);
- preferred_video_encoder[len] = 0;
- save_pref(PREF_VIDEO_ENCODER, preferred_video_encoder);
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-//-------------------------------------------------------------------------------------------------
-
-
-LRESULT CALLBACK CaptureSettingsDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- BOOL refresh_required;
- wchar_t buf[MAX_DEVICE_NAME_LEN+1];
- HWND hParent;
- RECT parent_rect;
- RECT dialog_rect;
- RECT rc;
- int video_count;
- int audio_count;
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- video_count = populate_capture_device_list(GetDlgItem(hWnd, IDC_Camera), &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID, preferred_video_capture_dev);
- audio_count = populate_capture_device_list(GetDlgItem(hWnd, IDC_Microphone), &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_GUID, preferred_audio_capture_dev);
- populate_resolution_list(GetDlgItem(hWnd, IDC_Resolution), current_action_code == ACTION_PHOTO_CAPTURE ? preferred_photo_resolution : preferred_video_resolution, preferred_video_capture_dev);
- populate_video_encoder_list(GetDlgItem(hWnd, IDC_VideoEncoder));
-
- if (video_count == 0)
- {
- EnableWindow(GetDlgItem(hWnd, IDC_Camera), FALSE);
- EnableWindow(GetDlgItem(hWnd, IDC_Resolution), FALSE);
- EnableWindow(GetDlgItem(hWnd, IDC_VideoEncoder), FALSE);
- }
-
- if (audio_count == 0)
- {
- EnableWindow(GetDlgItem(hWnd, IDC_Microphone), FALSE);
- }
-
- // Disable audio an encoder settings in photo mode
- if (current_action_code == ACTION_PHOTO_CAPTURE)
- {
- EnableWindow(GetDlgItem(hWnd, IDC_Microphone), FALSE);
- EnableWindow(GetDlgItem(hWnd, IDC_VideoEncoder), FALSE);
- }
-
- // Move the dialog towards the right edge of the window, near the toolbar
-
- hParent = GetParent(hWnd);
-
- GetWindowRect(hParent, &parent_rect);
- GetWindowRect(hWnd, &dialog_rect);
- rc = parent_rect;
-
- OffsetRect(&dialog_rect, -dialog_rect.left, -dialog_rect.top);
- OffsetRect(&rc, -rc.left, -rc.top);
- OffsetRect(&rc, -dialog_rect.right, -dialog_rect.bottom);
-
- SetWindowPos(hWnd, HWND_TOP, parent_rect.left + rc.right*15/16, parent_rect.top + rc.bottom/8, 0, 0, SWP_NOSIZE);
-
- return TRUE;
-
- case WM_COMMAND:
- switch (wParam)
- {
- case ((CBN_SELCHANGE << 16) | IDC_Camera):
- // New camera selected ; update resolution list
- buf[0] = 0;
- ComboBox_GetText(GetDlgItem(hWnd, IDC_Camera), buf, MAX_DEVICE_NAME_LEN+1);
- populate_resolution_list(GetDlgItem(hWnd, IDC_Resolution), current_action_code == ACTION_PHOTO_CAPTURE ? preferred_photo_resolution : preferred_video_resolution, buf);
- break;
-
- case IDOK:
- refresh_required = FALSE;
-
- buf[0] = 0;
- ComboBox_GetText(GetDlgItem(hWnd, IDC_Camera), buf, MAX_DEVICE_NAME_LEN+1);
- refresh_required |= update_selected_video_capture_device(buf);
-
- buf[0] = 0;
- ComboBox_GetText(GetDlgItem(hWnd, IDC_Microphone), buf, MAX_DEVICE_NAME_LEN+1);
- refresh_required |= update_selected_audio_capture_device(buf);
-
- buf[0] = 0;
- ComboBox_GetText(GetDlgItem(hWnd, IDC_VideoEncoder), buf, MAX_DEVICE_NAME_LEN+1);
- refresh_required |= update_selected_video_encoder(buf);
-
- buf[0] = 0;
- ComboBox_GetText(GetDlgItem(hWnd, IDC_Resolution), buf, MAX_DEVICE_NAME_LEN+1);
- refresh_required |= update_selected_resolution(buf);
-
- // The function returns 1 if settings have been modified
- EndDialog(hWnd, refresh_required);
- return FALSE;
-
- case IDCANCEL:
- EndDialog(hWnd, 0);
- return FALSE;
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-LRESULT CALLBACK CaptureWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- // WindowProc for the video/photo capture window
- int width, height;
- int num_buttons;
- TBBUTTON* selected_toolbar;
-
- switch (uMsg)
- {
- case WM_CREATE:
- {
- WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, PreviewWndProc, 0, 0, 0, 0, LoadCursor(NULL, IDC_ARROW), GetStockObject(BLACK_BRUSH), 0, PREVIEW_WINDOW_CLASS };
-
- RegisterClassEx(&wc);
- }
-
- hPreviewWnd = CreateWindow(PREVIEW_WINDOW_CLASS, L"", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, 0, 0, 0);
-
- switch (current_action_code)
- {
- case ACTION_PHOTO_CAPTURE:
- selected_toolbar = button_array_photo;
- num_buttons = sizeof(button_array_photo)/sizeof(TBBUTTON);
- break;
-
- case ACTION_VIDEO_FRAMING:
- selected_toolbar = button_array_video_framing;
- num_buttons = sizeof(button_array_video_framing)/sizeof(TBBUTTON);
- break;
-
- case ACTION_VIDEO_CAPTURE: // Not sure this will be used ; probably better start with framing
- selected_toolbar = button_array_video_capture;
- num_buttons = sizeof(button_array_video_capture)/sizeof(TBBUTTON);
- break;
-
- default:
- selected_toolbar = 0;
- num_buttons = 0;
- break;
-
- }
-
- // We have a vertical toolbar on the right side of the video preview area
- hToolBar = CreateToolbarEx(hWnd, WS_VISIBLE | WS_CHILD | CCS_RIGHT | CCS_NOMOVEX | CCS_NOMOVEY | CCS_NOPARENTALIGN | CCS_NORESIZE | TBSTYLE_TRANSPARENT | TBSTYLE_FLAT,
- TOOLBAR_ID, NUM_IMAGES, GetModuleHandle(0), IDB_ToolBar, selected_toolbar, num_buttons,
- BUTTON_WIDTH, BUTTON_HEIGHT, BITMAP_WIDTH, BITMAP_HEIGHT, sizeof(TBBUTTON));
-
- return 0;
-
- case WM_COMMAND:
- switch (wParam)
- {
- case ID_START_VIDEO:
- stop_video_framing();
- SendMessage(hToolBar, TB_HIDEBUTTON, ID_START_VIDEO, TRUE);
- SendMessage(hToolBar, TB_HIDEBUTTON, ID_STOP_VIDEO, FALSE);
- SendMessage(hToolBar, TB_ENABLEBUTTON, ID_PARAMETERS, FALSE);
- start_video_capture();
- break;
-
- case ID_STOP_VIDEO:
- stop_video_capture();
- SendMessage(hToolBar, TB_HIDEBUTTON, ID_STOP_VIDEO, TRUE);
- SendMessage(hToolBar, TB_HIDEBUTTON, ID_START_VIDEO, FALSE);
- SendMessage(hToolBar, TB_ENABLEBUTTON, ID_PARAMETERS, TRUE);
- start_video_framing();
- break;
-
- case ID_TAKE_PHOTO:
- snap_picture();
- break;
-
- case ID_PARAMETERS:
- end_active_session();
- DialogBox(GetModuleHandle(0), MAKEINTRESOURCE(IDD_CaptureSettings), hWnd, CaptureSettingsDialogProc);
- if (current_action_code == ACTION_PHOTO_CAPTURE)
- start_photo_capture();
- else
- start_video_framing();
- break;
-
- case ID_RETURN:
- end_active_session();
- DestroyWindow(hWnd);
- break;
- }
- return 0;
-
- case WM_DESTROY:
- DestroyWindow(hToolBar);
- DestroyWindow(hPreviewWnd);
- hCaptureWnd = 0;
- hPreviewWnd = 0;
- hToolBar = 0;
- break;
-
- case WM_SIZE:
- width = LOWORD(lParam);
- height = HIWORD(lParam);
-
- if (width > RIGHT_MARGIN)
- width = width - RIGHT_MARGIN;
- else
- width = 0;
-
- // Resize video preview area
- SetWindowPos(hPreviewWnd, 0, 0, 0, width, height, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOZORDER);
-
- // Also reposition and resize toolbar ; shift up to avoid disgracious border
- SetWindowPos(hToolBar, 0, width, -2, RIGHT_MARGIN, height, SWP_NOZORDER);
- return 0;
-
- default:
- break;
- }
-
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
-}
-
-
-HWND setup_capture_window (HWND hParent, BOOL video_mode)
-{
- RECT rc;
- WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, CaptureWndProc, 0, 0, 0, 0, LoadCursor(NULL, IDC_ARROW), GetStockObject(BLACK_BRUSH), 0, CAPTURE_WINDOW_CLASS };
-
- RegisterClassEx(&wc);
-
- GetClientRect(hParent, &rc);
-
- if (video_mode)
- current_action_code = ACTION_VIDEO_FRAMING;
- else
- current_action_code = ACTION_PHOTO_CAPTURE;
-
- hCaptureWnd = CreateWindow(CAPTURE_WINDOW_CLASS, L"", WS_CHILD | WS_VISIBLE, 0, 0, rc.right, rc.bottom, hParent, 0, 0, 0);
-
- BringWindowToTop(hCaptureWnd);
-
- return hCaptureWnd;
-}
-
-//-------------------------------------------------------------------------------------------------
-
-
-static int sgsc_ref_count = 0;
-
-HRESULT STDMETHODCALLTYPE SGSC_QueryInterface(IMFSampleGrabberSinkCallback2 * This, REFIID riid, void **ppvObject)
-{
- if (IsEqualIID(riid,&IID_IUnknown) || IsEqualIID(riid,&IID_IMFSampleGrabberSinkCallback) ||
- IsEqualIID(riid,&IID_IMFSampleGrabberSinkCallback2) || IsEqualIID(riid,&IID_IMFClockStateSink))
- {
- *ppvObject = &sgsc;
- sgsc.lpVtbl->AddRef(&sgsc);
- return NOERROR;
- }
-
- *ppvObject = 0;
- return E_NOINTERFACE;
-}
-
-ULONG STDMETHODCALLTYPE SGSC_AddRef(IMFSampleGrabberSinkCallback2 * This)
-{
- sgsc_ref_count++;
-
- return sgsc_ref_count;
-}
-
-ULONG STDMETHODCALLTYPE SGSC_Release(IMFSampleGrabberSinkCallback2 * This)
-{
- sgsc_ref_count--;
-
- return sgsc_ref_count;
-}
-
-HRESULT STDMETHODCALLTYPE SGSC_OnClockStart(IMFSampleGrabberSinkCallback2 * This, MFTIME hnsSystemTime, LONGLONG llClockStartOffset)
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE SGSC_OnClockStop(IMFSampleGrabberSinkCallback2 * This, MFTIME hnsSystemTime)
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE SGSC_OnClockPause(IMFSampleGrabberSinkCallback2 * This, MFTIME hnsSystemTime)
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE SGSC_OnClockRestart(IMFSampleGrabberSinkCallback2 * This, MFTIME hnsSystemTime)
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE SGSC_OnClockSetRate(IMFSampleGrabberSinkCallback2 * This, MFTIME hnsSystemTime, float flRate)
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE SGSC_OnSetPresentationClock(IMFSampleGrabberSinkCallback2 * This, IMFPresentationClock *pPresentationClock)
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE SGSC_OnProcessSample(IMFSampleGrabberSinkCallback2 * This, REFGUID guidMajorMediaType, DWORD dwSampleFlags,
- LONGLONG llSampleTime, LONGLONG llSampleDuration, const BYTE *pSampleBuffer, DWORD dwSampleSize)
-{
- return E_NOTIMPL; // Superseded by OnProcessSampleEx (see below)
-}
-
-HRESULT STDMETHODCALLTYPE SGSC_OnShutdown(IMFSampleGrabberSinkCallback2 * This)
-{
- // Make sure there is no left over command from the current session
- grab_first_available_frame = FALSE;
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE SGSC_OnProcessSampleEx (IMFSampleGrabberSinkCallback2 * This, REFGUID guidMajorMediaType, DWORD dwSampleFlags,
- LONGLONG llSampleTime, LONGLONG llSampleDuration, const BYTE *pSampleBuffer, DWORD dwSampleSize, IMFAttributes *pAttributes)
-{
- if (grab_first_available_frame)
- {
- SYSTEMTIME t;
-
- GetLocalTime(&t);
- swprintf(last_recorded_file_name, MAX_FILE_NAME_LEN, L"%d%02d%02d-%02d%02d%02d.jpg", t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond);
- swprintf(last_recorded_file_name_full, MAX_FILE_NAME_LEN, L"%s%s", temp_directory_win, last_recorded_file_name);
- last_recorded_file_name_full[MAX_FILE_NAME_LEN] = 0;
-
- if (mjpeg_mode)
- {
- // Direct JPEG frames
- HANDLE h = CreateFile(last_recorded_file_name_full, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
- DWORD written = 0;
- WriteFile(h, pSampleBuffer, dwSampleSize, &written, 0);
- CloseHandle(h);
- }
- else
- {
- // RGB 24 bpp input
- DWORD width = frame_size >> 32;
- DWORD height = (DWORD) frame_size;
-
- save_bitmap_as_jpeg(width, height, (unsigned char*) pSampleBuffer, dwSampleSize, last_recorded_file_name_full, scan_len);
- }
-
- // Lower flag and don't try capturing another photo until it gets raised again
- grab_first_available_frame = FALSE;
- }
-
- return S_OK;
-}
-
-
-// IMFSampleGrabberSinkCallback2 vtable
-static IMFSampleGrabberSinkCallback2Vtbl sgsc_vtable =
-{
- SGSC_QueryInterface,
- SGSC_AddRef,
- SGSC_Release,
- SGSC_OnClockStart,
- SGSC_OnClockStop,
- SGSC_OnClockPause,
- SGSC_OnClockRestart,
- SGSC_OnClockSetRate,
- SGSC_OnSetPresentationClock,
- SGSC_OnProcessSample,
- SGSC_OnShutdown,
- SGSC_OnProcessSampleEx,
-};
-
-
-void setup_capture(void)
-{
- wchar_t* cursor;
-
- load_pref(PREF_VIDEO_DEVICE, preferred_video_capture_dev);
- load_pref(PREF_AUDIO_DEVICE, preferred_audio_capture_dev);
- load_pref(PREF_VIDEO_ENCODER, preferred_video_encoder);
- load_pref(PREF_VIDEO_RESOLUTION, preferred_video_resolution);
- load_pref(PREF_PHOTO_RESOLUTION, preferred_photo_resolution);
-
- // One-time initialization, required before capture services can be used
- sgsc.lpVtbl = &sgsc_vtable;
-
- // Locate temp directory and make a HTML friendly of it
-
- GetTempPath(MAX_FILE_NAME_LEN - 16, temp_directory_win);
- swprintf(temp_directory_url, MAX_FILE_NAME_LEN + 7, L"file://%s", temp_directory_win);
-
- cursor = temp_directory_url;
-
- while (*cursor)
- {
- if (*cursor == L'\\')
- *cursor = '/';
-
- cursor++;
- }
-
- // The Win32 version includes a \ at the end, which is converted into / for the HTML version
-}
-
-BSTR last_callback_id;
-
-void notify_capture_result (void)
-{
- wchar_t reply[30 + MAX_FILE_NAME_LEN + 1];
-
- // Send back our reply to the JS side
- swprintf(reply, sizeof(reply)/sizeof(reply[0]), L"[{fullPath: '%s%s'}]", temp_directory_url, last_recorded_file_name);
-
- cordova_success_callback(last_callback_id, FALSE, reply);
-
- SysFreeString(last_callback_id);
- last_callback_id = 0;
-}
-
-HRESULT camera_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- if (!wcscmp(action, L"getPicture"))
- {
- last_callback_id = SysAllocString(callback_id);
- setup_capture_window(hWnd, FALSE);
- start_photo_capture();
- return S_OK;
- }
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-HRESULT capture_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- if (!wcscmp(action, L"captureImage"))
- {
- last_callback_id = SysAllocString(callback_id);
- setup_capture_window(hWnd, FALSE);
- start_photo_capture();
- return S_OK;
- }
-
- if (!wcscmp(action, L"captureVideo"))
- {
- last_callback_id = SysAllocString(callback_id);
- setup_capture_window(hWnd, TRUE);
- start_video_framing();
- return S_OK;
- }
-
- if (!wcscmp(action, L"captureAudio"))
- {
- last_callback_id = 0;
- return S_OK;
- }
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-DEFINE_CORDOVA_MODULE(Camera, L"Camera", camera_exec, NULL, NULL)
-DEFINE_CORDOVA_MODULE(Capture, L"Capture", capture_exec, NULL, NULL)
-
-
-// @@@ need to handle device lost events - MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK
-
-// @@@ feedback for key presses ?
-
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/capture.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/capture.h b/windows7/Cordova/capture.h
deleted file mode 100644
index bcd9719..0000000
--- a/windows7/Cordova/capture.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "shell.h"
-
-void setup_capture (void);
-
-void snap_picture (void);
-
-void camera_resize_window (int width, int height);
-
-void camera_notify_display_change (void);
-
-void start_photo_capture (void);
-
-void start_video_capture (void);
-void start_video_framing (void);
-void stop_video_capture (void);
-
-HWND setup_capture_window (HWND hParent, BOOL video_mode);
-
-void notify_capture_result (void);
-
-DECLARE_CORDOVA_MODULE(Camera)
-DECLARE_CORDOVA_MODULE(Capture)
-
-
-
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/common.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/common.c b/windows7/Cordova/common.c
deleted file mode 100644
index 5c7721f..0000000
--- a/windows7/Cordova/common.c
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <malloc.h>
-#include <wchar.h>
-
-#include "common.h"
-
-#define TEXT_BUF_INC_SIZE 100
-
-struct _TextBuf {
- wchar_t *wbuf;
- size_t len;
- size_t max;
-};
-
-TextBuf text_buf_new(void)
-{
- return (TextBuf) calloc(1, sizeof(struct _TextBuf));
-}
-
-BOOL text_buf_append_len(TextBuf buf, const wchar_t *text, size_t text_len)
-{
- size_t inc = (text_len > TEXT_BUF_INC_SIZE) ? text_len : TEXT_BUF_INC_SIZE;
-
- // If needed, increase buf size
- if (buf->len + text_len >= buf->max) {
- void *ptr = realloc(buf->wbuf, sizeof(wchar_t) * (buf->max + inc + 1));
- if (!ptr)
- return FALSE;
- buf->wbuf = (wchar_t *) ptr;
-
- buf->max += inc;
- }
-
- if (buf->len == 0)
- buf->wbuf[0] = 0;
-
- wcsncat_s(buf->wbuf + buf->len, buf->max - buf->len, text, text_len);
- buf->len += text_len;
- buf->wbuf[buf->len] = 0;
-
- return TRUE;
-}
-
-BOOL text_buf_append(TextBuf buf, const wchar_t *text)
-{
- return text_buf_append_len(buf, text, wcslen(text));
-}
-
-wchar_t *text_buf_get(const TextBuf buf)
-{
- return buf->wbuf;
-}
-
-size_t text_buf_get_len(const TextBuf buf)
-{
- return buf->len;
-}
-
-void text_buf_reset(TextBuf buf)
-{
- buf->len = 0;
-}
-
-void text_buf_free(TextBuf buf)
-{
- if (buf->wbuf)
- free(buf->wbuf);
- free(buf);
-}
-
-// Thread naming utility - see http://msdn.microsoft.com/en-us/library/xcb2z8hs%28VS.90%29.aspx
-
-const DWORD MS_VC_EXCEPTION=0x406D1388;
-
-#pragma pack(push,8)
-typedef struct tagTHREADNAME_INFO
-{
- DWORD dwType; // Must be 0x1000.
- LPCSTR szName; // Pointer to name (in user addr space).
- DWORD dwThreadID; // Thread ID (-1=caller thread).
- DWORD dwFlags; // Reserved for future use, must be zero.
-} THREADNAME_INFO;
-#pragma pack(pop)
-
-void set_thread_name (DWORD thread_id, char* thread_name)
-{
- THREADNAME_INFO info;
- info.dwType = 0x1000;
- info.szName = thread_name;
- info.dwThreadID = thread_id;
- info.dwFlags = 0;
-
- __try
- {
- RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/common.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/common.h b/windows7/Cordova/common.h
deleted file mode 100644
index 2e13cd7..0000000
--- a/windows7/Cordova/common.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#define CORDOVA_REG_KEY L"Software\\Intel\\Cordova"
-
-typedef enum {
- WM_EXEC_JS_SCRIPT = WM_USER,
- WM_USER_ACCEL,
- WM_USER_COMPASS
-};
-
-#define ASSERT(x) if (!(x)) __debugbreak()
-
-struct _TextBuf;
-typedef struct _TextBuf *TextBuf;
-
-TextBuf text_buf_new(void);
-
-BOOL text_buf_append(TextBuf buf, const wchar_t *text);
-BOOL text_buf_append_len(TextBuf buf, const wchar_t *text, size_t text_len);
-
-wchar_t *text_buf_get(const TextBuf buf);
-size_t text_buf_get_len(const TextBuf buf);
-
-void text_buf_reset(TextBuf buf);
-void text_buf_free(TextBuf buf);
-
-void set_thread_name (DWORD thread_id, char* thread_name);
-
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/compass.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/compass.c b/windows7/Cordova/compass.c
deleted file mode 100644
index c321771..0000000
--- a/windows7/Cordova/compass.c
+++ /dev/null
@@ -1,277 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <windows.h>
-#include <sensors.h>
-#include <sensorsapi.h>
-#include <propvarutil.h>
-#include <portabledevicetypes.h>
-#include <wchar.h>
-#include "common.h"
-
-#pragma comment(lib, "sensorsapi.lib")
-#pragma comment(lib, "portabledeviceguids.lib")
-
-#include "shell.h"
-extern HWND hWnd; // Main window, used as a way to request routine calls from the main thread
-
-ISensorManager* sensor_manager_if;
-ISensorCollection* sensor_collection_if;
-ISensor* compass_if;
-
-int orientation_sensor_count;
-
-double last_x, last_y, last_z;
-double prev_x, prev_y, prev_z;
-
-double last_h;
-double prev_h;
-
-
-// See http://dev.w3.org/geo/api/spec-source-orientation.html
-
-// Definitions missing from Windows 7 SDK...
-#define INITGUID
-#include <propkeydef.h>
-DEFINE_PROPERTYKEY(SENSOR_DATA_TYPE_MAGNETIC_HEADING_COMPENSATED_MAGNETIC_NORTH_DEGREES, 0X1637D8A2, 0X4248, 0X4275, 0X86, 0X5D, 0X55, 0X8D, 0XE8, 0X4A, 0XED, 0XFD, 11);
-DEFINE_PROPERTYKEY(SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_X_MILLIGAUSS, 0X1637D8A2, 0X4248, 0X4275, 0X86, 0X5D, 0X55, 0X8D, 0XE8, 0X4A, 0XED, 0XFD, 19);
-DEFINE_PROPERTYKEY(SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Y_MILLIGAUSS, 0X1637D8A2, 0X4248, 0X4275, 0X86, 0X5D, 0X55, 0X8D, 0XE8, 0X4A, 0XED, 0XFD, 20);
-DEFINE_PROPERTYKEY(SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Z_MILLIGAUSS, 0X1637D8A2, 0X4248, 0X4275, 0X86, 0X5D, 0X55, 0X8D, 0XE8, 0X4A, 0XED, 0XFD, 21);
-
-
-HANDLE compass_thread; // Data acquisition thread handle
-BOOL stop_flag; // Flag raised to indicate that the acquisition thread should exit
-
-BSTR new_sample_callback;
-
-void propagate_compass_sample (void)
-{
- if (new_sample_callback)
- {
- wchar_t buf[100];
- swprintf(buf, sizeof(buf)/sizeof(buf[0]), L"{magneticHeading:%f}", last_h);
-
- cordova_success_callback(new_sample_callback, TRUE, buf);
- }
-}
-
-unsigned int __stdcall compass_thread_proc(void* param)
-{
- ISensorDataReport* data_report_if;
- PROPVARIANT v;
-// SYSTEMTIME timestamp;
- static int counter;
- HRESULT hr;
- ULONG ulCount = 0;
-
- set_thread_name(-1, "Compass Sampling");
-
- CoInitialize(0);
-
- // Retrieve sensor manager object
- hr = CoCreateInstance(&CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &IID_ISensorManager, (void**) &sensor_manager_if);
-
- if (hr == HRESULT_FROM_WIN32(ERROR_ACCESS_DISABLED_BY_POLICY))
- {
- // The user hasn't granted access to sensors
- return -1;
- }
-
- if (!SUCCEEDED(hr))
- // Sensor API not available...
- return -2;
-
- // Get the list of available orientation sensors
- hr = sensor_manager_if->lpVtbl->GetSensorsByCategory(sensor_manager_if, &SENSOR_CATEGORY_ORIENTATION, &sensor_collection_if);
-
- sensor_manager_if->lpVtbl->RequestPermissions(sensor_manager_if, GetForegroundWindow(), sensor_collection_if, TRUE);
-
- if (SUCCEEDED(hr))
- {
- // Check sensor count
- hr = sensor_collection_if->lpVtbl->GetCount(sensor_collection_if, &orientation_sensor_count);
-
- if (SUCCEEDED(hr))
- {
- if (orientation_sensor_count == 0)
- {
- // No orientation sensor
- }
- else
- {
- // Get the first available orientation sensor
- hr = sensor_collection_if->lpVtbl->GetAt(sensor_collection_if, 0, &compass_if);
-
- }
- }
- }
-
-
-
- if (SUCCEEDED(hr))
- {
- IPortableDeviceValues* params_in = NULL;
- IPortableDeviceValues* params_out = NULL;
-
- // Need a properties object...
- hr = CoCreateInstance(&CLSID_PortableDeviceValues, NULL, CLSCTX_INPROC_SERVER, &IID_IPortableDeviceValues, (void**) ¶ms_in);
-
- if (SUCCEEDED(hr))
- {
- // Request 20 ms update interval
- hr = params_in->lpVtbl->SetUnsignedIntegerValue(params_in, &SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL, 20);
- }
-
- if (SUCCEEDED(hr))
- {
- // Set property
- hr = compass_if->lpVtbl->SetProperties(compass_if, params_in, ¶ms_out);
- }
-
- if (params_in)
- params_in->lpVtbl->Release(params_in);
-
- if (params_out)
- params_out->lpVtbl->Release(params_out);
- }
-
- while (!stop_flag)
- {
- prev_x = last_x;
- prev_y = last_y;
- prev_z = last_z;
-
- if (!compass_if || !SUCCEEDED(compass_if->lpVtbl->GetData(compass_if, &data_report_if)))
- {
- last_x = .002 * (rand()%1000) -1;
- last_y = .002 * (rand()%1000) -1;
- last_z = .002 * (rand()%1000) -1;
- }
- else
- {
- PropVariantInit(&v);
- hr = data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_MAGNETIC_HEADING_COMPENSATED_MAGNETIC_NORTH_DEGREES, &v);
- if (v.vt == VT_R4)
- last_h = v.fltVal;
- if (v.vt == VT_R8)
- last_h = v.dblVal;
- PropVariantClear(&v);
-
- PropVariantInit(&v);
- hr = data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_X_MILLIGAUSS, &v);
- if (v.vt == VT_R4)
- last_x = v.fltVal;
- if (v.vt == VT_R8)
- last_x = v.dblVal;
- PropVariantClear(&v);
-
- PropVariantInit(&v);
- hr = data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Y_MILLIGAUSS, &v);
- if (v.vt == VT_R4)
- last_y = v.fltVal;
- if (v.vt == VT_R8)
- last_y = v.dblVal;
- PropVariantClear(&v);
-
- PropVariantInit(&v);
- hr = data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Z_MILLIGAUSS, &v);
- if (v.vt == VT_R4)
- last_z = v.fltVal;
- if (v.vt == VT_R8)
- last_z = v.dblVal;
- PropVariantClear(&v);
-
- //data_report_if->lpVtbl->GetTimestamp(data_report_if, ×tamp);
- //*ts = 0;
-
- data_report_if->lpVtbl->Release(data_report_if);
- }
-
- if (last_x != prev_x || last_y != prev_y || last_z != prev_z)
- SendMessage(hWnd, WM_USER_COMPASS, 0, 0); // Request the main thread to invoke a JS call for us ; will call propagate_compass_sample in response
-
- Sleep(10);
- }
-
- return 0;
-}
-
-static int start_compass_acquisition (void)
-{
- if (compass_thread)
- return -1;
-
- // Return 0 x/y/z and 0 timestamp until samples start coming in
- last_x = 0;
- last_y = 0;
- last_z = 0;
-
- stop_flag = FALSE;
-
- // Reading sensor values seem to block the calling thread ; do this in a dedicated thread
- compass_thread = CreateThread(0, 0, compass_thread_proc, 0, 0, 0);
- return 0;
-}
-
-int stop_compass_acquisition (void)
-{
- if (compass_thread == 0)
- return -1;
-
- stop_flag = TRUE;
-
- // Wait until the acquisition thread exits
- WaitForSingleObject(compass_thread, INFINITE);
-
- compass_thread = 0;
-
- if (new_sample_callback)
- {
- SysFreeString(new_sample_callback);
- new_sample_callback = 0;
- }
-
- return 0;
-}
-
-
-HRESULT compass_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- if (!wcscmp(action, L"getHeading"))
- {
- new_sample_callback = SysAllocString(callback_id);
- last_x = last_y = last_z = 0;
- propagate_compass_sample();
- start_compass_acquisition();
- return S_OK;
- }
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-DEFINE_CORDOVA_MODULE(Compass, L"Compass", compass_exec, NULL, NULL)
-
- /*
-
- magneticHeading: The heading in degrees from 0 - 359.99 at a single moment in time. (Number)
- trueHeading: The heading relative to the geographic North Pole in degrees 0 - 359.99 at a single moment in time. A negative value indicates that the true heading could not be determined. (Number)
- headingAccuracy: The deviation in degrees between the reported heading and the true heading. (Number)
- timestamp: The time at which this heading was determined. (milliseconds)
-
- */
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/compass.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/compass.h b/windows7/Cordova/compass.h
deleted file mode 100644
index 8958ea7..0000000
--- a/windows7/Cordova/compass.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-void propagate_compass_sample(void);
-
-DECLARE_CORDOVA_MODULE(Compass)
-
[08/10] Removed Windows7 which is now in it's own branch. This closes
#29
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/device.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/device.c b/windows7/Cordova/device.c
deleted file mode 100644
index 618f743..0000000
--- a/windows7/Cordova/device.c
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include <wchar.h>
-#include <rpc.h>
-
-#pragma comment(lib,"rpcrt4.lib")
-
-// GetComputerName
-// GetVersionEx
-
-#include "shell.h"
-#include "device.h"
-#include "common.h"
-
-#define CORDOVA_MACHINE_ID L"MachineID"
-#define CORDOVA_VERSION L"2.1.0"
-#define CORDOVA_VERSION_LEN 5
-
-// A valid UUID string should look like this: f7b38bf1-2ece-4e2a-94a6-e791863f0109
-
-#define UUID_BUF_LEN_IN_BYTES (sizeof(wchar_t) * UUID_BUF_LEN)
-
-static wchar_t uuid[UUID_BUF_LEN];
-
-wchar_t *get_device_uuid(void)
-{
- return uuid;
-}
-
-int acquire_unique_id(wchar_t buf[UUID_BUF_LEN])
-{
- DWORD info;
- HKEY key;
- LONG ret;
- DWORD len;
- RPC_WSTR string;
- RPC_STATUS status;
- UUID uuid;
- DWORD type;
-
- // Check if a previous run generated an ID and recorded it
- buf[0] = L'\0';
-
- ret = RegCreateKeyEx(HKEY_CURRENT_USER, CORDOVA_REG_KEY, 0, 0, 0, KEY_READ | KEY_WRITE, 0, &key, &info);
-
- if (ret != ERROR_SUCCESS)
- return -1;
-
- if (info == REG_OPENED_EXISTING_KEY)
- {
- len = UUID_BUF_LEN_IN_BYTES;
-
- ret = RegQueryValueEx(key, CORDOVA_MACHINE_ID, 0, &type, (LPBYTE) buf, &len);
-
- // If we read something that looks good
- if (ret == ERROR_SUCCESS && UuidFromString(buf, &uuid) == RPC_S_OK)
- {
- // Return successfully
- RegCloseKey(key);
- return 0;
- }
- }
-
- // Generate a new id - we're willing to accept ids that are not guaranteed to be globally unique
- status = UuidCreate(&uuid);
-
- if (status == RPC_S_OK || status == RPC_S_UUID_LOCAL_ONLY)
- {
- UuidToString (&uuid, &string);
-
- wmemcpy(buf, string, UUID_BUF_LEN);
-
- RpcStringFree(&string);
-
- // Store it
- len = UUID_BUF_LEN_IN_BYTES;
- RegSetValueEx(key, CORDOVA_MACHINE_ID, 0, REG_SZ, (LPBYTE) buf, len);
-
- // There's a slight chance of race condition here ; in that case several different ids would be returned by concurrent executions
- // That can be avoided using a named mutex if that turns out to be a problem
-
- RegCloseKey(key);
- return 0;
- }
-
- RegCloseKey(key);
- return -1;
-}
-
-
-static HRESULT get_device_info(BSTR callback_id)
-{
- // Set initial Cordova global variables and fire up deviceready event
- static wchar_t buf[100 + UUID_BUF_LEN + COMPUTER_NAME_BUF_LEN + CORDOVA_VERSION_LEN];
- wchar_t computer_name[COMPUTER_NAME_BUF_LEN];
- DWORD len = COMPUTER_NAME_BUF_LEN;
- OSVERSIONINFOEX osver;
- wchar_t* platform = L"Windows";
-
- computer_name[0] = L'\0';
- GetComputerName(computer_name, &len);
-
- osver.dwOSVersionInfoSize = sizeof(osver);
- GetVersionEx((LPOSVERSIONINFO)&osver);
-
- wsprintf(buf, L"{uuid:'%s',name:'%s',platform:'%s',version:'%d.%d',cordova:'%s'}",
- uuid, computer_name, platform, osver.dwMajorVersion, osver.dwMinorVersion, CORDOVA_VERSION);
-
- cordova_success_callback(callback_id, FALSE, buf);
-
- return S_OK;
-}
-
-HRESULT device_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- if (!wcscmp(action, L"getDeviceInfo"))
- return get_device_info(callback_id);
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-static void device_module_init(void)
-{
- acquire_unique_id(uuid);
-}
-
-DEFINE_CORDOVA_MODULE(Device, L"Device", device_exec, device_module_init, NULL)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/device.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/device.h b/windows7/Cordova/device.h
deleted file mode 100644
index 01604e5..0000000
--- a/windows7/Cordova/device.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "shell.h"
-
-#define UUID_BUF_LEN (32+4+1)
-#define COMPUTER_NAME_BUF_LEN 100
-
-wchar_t *get_device_uuid(void);
-
-DECLARE_CORDOVA_MODULE(Device)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/file.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/file.c b/windows7/Cordova/file.c
deleted file mode 100644
index 63ba34d..0000000
--- a/windows7/Cordova/file.c
+++ /dev/null
@@ -1,1280 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <Shlwapi.h>
-#include <Shlobj.h>
-#include <Shellapi.h>
-#include <wininet.h>
-#include <WinReg.h>
-
-#include "file.h"
-#include "common.h"
-#include "device.h"
-#include "json.h"
-
-#pragma comment(lib, "shlwapi.lib")
-
-static DWORD full_path_size;
-static wchar_t full_path[MAX_PATH + 1];
-static wchar_t url[INTERNET_MAX_URL_LENGTH + 1];
-
-static const wchar_t *temporary_dir;
-static const wchar_t *persistent_dir = L"persistent";
-#define MAX_CORDOVA_FS_NAME 32
-#define URL_START L"file:///"
-#define DRIVE_COLUMN_POS 9
-
-typedef enum {
- TEMPORARY_FS = 0,
- PERSISTENT_FS
-} CordovaFsType;
-
-static wchar_t temporary_root_path[MAX_PATH + 1];
-static wchar_t persistent_root_path[MAX_PATH + 1];
-
-// Tools
-// ---------------------------------------------------------------------------
-
-wchar_t *make_entry(BOOL is_dir, wchar_t *root_path, wchar_t *rel_path)
-{
- wchar_t *response;
- wchar_t name[MAX_PATH + 1];
- const wchar_t *format = L"{isFile:%s,isDirectory:%s,name:'%s',fullPath:'%s'}";
- size_t root_len = wcslen(root_path);
- DWORD url_size = INTERNET_MAX_URL_LENGTH;
-
- wcscpy_s(full_path, MAX_PATH, root_path);
- if (rel_path && wcscmp(rel_path, L"\\"))
- wcscat_s(full_path + root_len, MAX_PATH - root_len, rel_path);
- if (UrlCreateFromPath(full_path, url, &url_size, 0) != S_OK)
- return NULL;
- url[DRIVE_COLUMN_POS] = L'_'; // Replace drive ':' due to wrong Cordova check in common/plugin/resolveLocalFileSystemURI.js file
-
- // Comply with wrong unit test: replace %20 with space char
- if (UrlUnescapeInPlace(url, 0) != S_OK)
- return NULL;
-
- if (rel_path && !wcscmp(rel_path, L"\\"))
- wcscpy_s(name, MAX_PATH, L"/");
- else
- wcscpy_s(name, MAX_PATH, wcsrchr(full_path, L'\\') + 1);
-
- response = (wchar_t *)malloc(sizeof(wchar_t) * (1 + wcslen(format) + 5 + 5 + wcslen(name) + wcslen(url)));
- wsprintf(response, format, is_dir?L"false":L"true", is_dir?L"true":L"false", name, url);
-
- return response;
-}
-
-static BOOL path_is_valid(wchar_t *path)
-{
- size_t x = wcscspn(path, L"<>:\"/|?*");
- if (x == wcslen(path))
- return TRUE;
-
- return FALSE;
-}
-
-CordovaFsError path_from_uri(wchar_t *uri, wchar_t *path, DWORD *len, BOOL must_exist, BOOL *is_dir)
-{
- uri[DRIVE_COLUMN_POS] = L':'; // Restore drive ':'
-
- if (PathCreateFromUrl(uri, path, len, 0) != S_OK)
- return ENCODING_ERR;
-
- if (!path_is_valid(path + 2)) // skip drive letter
- return ENCODING_ERR;
-
- if (wcsncmp(path, temporary_root_path, wcslen(temporary_root_path)) &&
- wcsncmp(path, persistent_root_path, wcslen(persistent_root_path)))
- return NOT_FOUND_ERR;
-
- if (must_exist) {
- DWORD attributes;
-
- if ((attributes = GetFileAttributes(path)) == INVALID_FILE_ATTRIBUTES) {
- return NOT_FOUND_ERR;
- }
-
- if (is_dir != NULL)
- *is_dir = (attributes & FILE_ATTRIBUTE_DIRECTORY) ? TRUE : FALSE;
- }
-
- return FILE_NO_ERR;
-}
-
-static void file_fail_callback(wchar_t *callback_id, CordovaFsError err)
-{
- wchar_t *error_text;
-
- switch (err) {
- case NOT_FOUND_ERR:
- error_text = L"FileError.NOT_FOUND_ERR";
- break;
- case SECURITY_ERR:
- error_text = L"FileError.SECURITY_ERR";
- break;
- case ABORT_ERR:
- error_text = L"FileError.ABORT_ERR";
- break;
- case NOT_READABLE_ERR:
- error_text = L"FileError.NOT_READABLE_ERR";
- break;
- case ENCODING_ERR:
- error_text = L"FileError.ENCODING_ERR";
- break;
- case NO_MODIFICATION_ALLOWED_ERR:
- error_text = L"FileError.NO_MODIFICATION_ALLOWED_ERR";
- break;
- case INVALID_STATE_ERR:
- error_text = L"FileError.INVALID_STATE_ERR";
- break;
- case SYNTAX_ERR:
- error_text = L"FileError.SYNTAX_ERR";
- break;
- case INVALID_MODIFICATION_ERR:
- error_text = L"FileError.INVALID_MODIFICATION_ERR";
- break;
- case QUOTA_EXCEEDED_ERR:
- error_text = L"FileError.QUOTA_EXCEEDED_ERR";
- break;
- case TYPE_MISMATCH_ERR:
- error_text = L"FileError.TYPE_MISMATCH_ERR";
- break;
- case PATH_EXISTS_ERR:
- error_text = L"FileError.PATH_EXISTS_ERR";
- break;
- default:
- ASSERT(FALSE);
- }
-
- cordova_fail_callback(callback_id, FALSE, CB_GENERIC_ERROR, error_text);
-}
-
-time_t filetime_to_timet(FILETIME *ft)
-{
- ULARGE_INTEGER ull;
-
- ull.LowPart = ft->dwLowDateTime;
- ull.HighPart = ft->dwHighDateTime;
-
- return ull.QuadPart / 10000000ULL - 11644473600ULL;
-}
-
-wchar_t *type_from_file_name(wchar_t *file_name)
-{
- wchar_t *extension = wcsrchr(file_name, L'.');
-
- if(extension) {
- HKEY key;
- DWORD data_size;
- wchar_t *type;
-
- if (RegOpenKeyEx(HKEY_CLASSES_ROOT, extension, 0, KEY_READ, &key) != ERROR_SUCCESS)
- goto on_default;
-
- if (RegQueryValueEx(key, L"Content Type", NULL, NULL, NULL, &data_size) != ERROR_SUCCESS)
- goto on_default;
-
- type = (wchar_t *)malloc(data_size + 1);
- if (RegQueryValueEx(key, L"Content Type", NULL, NULL, (LPBYTE)type, &data_size) != ERROR_SUCCESS) {
- free(type);
- goto on_default;
- }
-
- RegCloseKey(key);
- return type;
- }
-
-on_default:
- return _wcsdup(L"application/octetstream");
-}
-
-// FileSystem
-// ---------------------------------------------------------------------------
-
-static HRESULT request_file_system(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- JsonItem item;
- CordovaFsType type;
- UINT64 size;
- wchar_t *response;
- wchar_t *entry;
- wchar_t *root;
- const wchar_t *format = L"{name:'%s',root:%s}";
- ULARGE_INTEGER available;
-
- // Validate array contents
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_INT,
- JSON_VALUE_INT64,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- item = json_array_get_first(array);
- type = (CordovaFsType) json_get_int_value(item);
- item = json_array_get_next(item);
- size = (UINT64) json_get_int64_value(item);
-
- root = (type == TEMPORARY_FS) ? temporary_root_path : persistent_root_path;
-
- if (GetDiskFreeSpaceEx(root, &available, NULL, NULL)) {
- if (size > available.QuadPart) {
- file_fail_callback(callback_id, QUOTA_EXCEEDED_ERR);
- goto out;
- }
- }
-
- entry = make_entry(TRUE, root, L"\\");
- if (!entry) {
- res = E_FAIL;
- goto out;
- }
-
- response = (wchar_t *)malloc(sizeof(wchar_t) * (1 + MAX_CORDOVA_FS_NAME + wcslen(entry)));
- wsprintf(response, format, (type == TEMPORARY_FS)?L"temporary":L"persistent", entry);
- cordova_success_callback(callback_id, FALSE, response);
-
- free(entry);
- free(response);
-
-out:
- json_free_args(array);
-
- return res;
-}
-
-static HRESULT resolve_file_system_uri(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- wchar_t *uri = NULL;
- wchar_t *entry;
- BOOL is_dir;
- CordovaFsError err;
-
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- uri = json_get_string_value(array);
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, TRUE, &is_dir);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
-
- entry = make_entry(is_dir, full_path, NULL);
- if (!entry) {
- res = E_FAIL;
- goto out;
- }
-
- cordova_success_callback(callback_id, FALSE, entry);
- free(entry);
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
-
- return res;
-}
-
-// DirectoryReader
-// ---------------------------------------------------------------------------
-
-static HRESULT read_entries(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- wchar_t *uri = NULL;
- BOOL is_dir;
- CordovaFsError err;
- HANDLE hFind = INVALID_HANDLE_VALUE;
- WIN32_FIND_DATA ffd;
- TextBuf response;
- BOOL next;
- wchar_t cur_path[MAX_PATH + 1];
-
- response = text_buf_new();
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- // Convert to path
- uri = json_get_string_value(array);
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, TRUE, &is_dir);
- if (err == FILE_NO_ERR && !is_dir)
- err = TYPE_MISMATCH_ERR;
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
-
- // Read dir entries
- wsprintf(cur_path, L"%s%s", full_path, L"*");
-
- text_buf_append(response, L"[");
-
- hFind = FindFirstFile(cur_path, &ffd);
- if (INVALID_HANDLE_VALUE == hFind)
- {
- if (GetLastError() == ERROR_FILE_NOT_FOUND) {
- text_buf_append(response, L"]");
- goto success;
- }
-
- res = E_FAIL;
- goto out;
- }
-
- do {
- wchar_t *entry = NULL;
-
- wsprintf(cur_path, L"%s%s", full_path, ffd.cFileName);
- if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- if(wcscmp(ffd.cFileName, L".") && wcscmp(ffd.cFileName, L".."))
- entry = make_entry(TRUE, cur_path, NULL);
- }
- else
- entry = make_entry(FALSE, cur_path, NULL);
-
- if (entry) {
- text_buf_append(response, entry);
- free(entry);
- }
-
- next = FindNextFile(hFind, &ffd);
- if (next && entry) {
- text_buf_append(response, L",");
- entry = NULL;
- }
- } while (next);
-
- FindClose(hFind);
-
- text_buf_append(response, L"]");
-
-success:
- FindClose(hFind);
- cordova_success_callback(callback_id, FALSE, text_buf_get(response));
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
- text_buf_free(response);
-
- return res;
-}
-
-// Entry
-// ---------------------------------------------------------------------------
-
-static HRESULT get_metadata(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- wchar_t *uri = NULL;
-
- CordovaFsError err;
- HANDLE hFind = INVALID_HANDLE_VALUE;
- WIN32_FIND_DATA ffd;
- wchar_t response[20];
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- // Convert to path
- uri = json_get_string_value(array);
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, TRUE, NULL);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
-
- // Get file info
- hFind = FindFirstFile(full_path, &ffd);
- if (INVALID_HANDLE_VALUE == hFind) {
- if (GetLastError() == ERROR_FILE_NOT_FOUND) {
- file_fail_callback(callback_id, NOT_FOUND_ERR);
- } else {
- res = E_FAIL;
- goto out;
- }
- }
-
- wsprintf(response, L"%I64d", filetime_to_timet(&ffd.ftLastWriteTime));
- cordova_success_callback(callback_id, FALSE, response);
-
- FindClose(hFind);
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
-
- return res;
-}
-
-static HRESULT move_or_copy_to(BSTR callback_id, BSTR args, BOOL is_move)
-{
- HRESULT res = S_OK;
- JsonArray array;
- JsonItem item;
- wchar_t *uri = NULL;
- TextBuf dst_uri = NULL;
- wchar_t *str;
- BOOL src_is_dir;
- BOOL dst_is_dir;
- CordovaFsError err;
- wchar_t dest_path[MAX_PATH + 1];
- wchar_t *entry;
- SHFILEOPSTRUCT fileOp;
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_STRING,
- JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
- item = json_array_get_first(array);
-
- // Convert source to path
- uri = json_get_string_value(item);
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, TRUE, &src_is_dir);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
- if (!wcscmp(full_path, temporary_root_path) || !wcscmp(full_path, persistent_root_path)) {
- file_fail_callback(callback_id, NO_MODIFICATION_ALLOWED_ERR);
- goto out;
- }
-
- // Convert parent to path
- item = json_array_get_next(item);
- dst_uri = text_buf_new();
-
- str = json_get_string_value(item);
- text_buf_append(dst_uri, str);
- free(str);
-
- full_path_size = MAX_PATH;
- err = path_from_uri(text_buf_get(dst_uri), dest_path, &full_path_size, TRUE, &dst_is_dir);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
- if (!dst_is_dir) {
- file_fail_callback(callback_id, TYPE_MISMATCH_ERR);
- goto out;
- }
-
- item = json_array_get_next(item);
- text_buf_append(dst_uri, L"/");
- str = json_get_string_value(item);
- text_buf_append(dst_uri, str); // dest name
-
- full_path_size = MAX_PATH;
- err = path_from_uri(text_buf_get(dst_uri), dest_path, &full_path_size, FALSE, NULL);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
-
- if (!wcscmp(full_path, dest_path)) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
-
- if ((!src_is_dir && PathFileExists(dest_path) && PathIsDirectory(dest_path)) ||
- (src_is_dir && PathFileExists(dest_path) && PathIsDirectory(dest_path) && !PathIsDirectoryEmpty(dest_path)) ||
- (src_is_dir && PathFileExists(dest_path) && !PathIsDirectory(dest_path))) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
-
- // Special handling for moving dir to empty dir
- if (src_is_dir && PathFileExists(dest_path) && PathIsDirectory(dest_path) && PathIsDirectoryEmpty(dest_path)) {
- if (!RemoveDirectory(dest_path)) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
- }
-
- // Move or Copy
- full_path[wcslen(full_path) + 1] = 0; // double-null terminated required by SHFileOperation()
- dest_path[wcslen(dest_path) + 1] = 0; // double-null terminated required by SHFileOperation()
- memset(&fileOp, 0, sizeof(SHFILEOPSTRUCT));
- fileOp.wFunc = is_move?FO_MOVE:FO_COPY;
- fileOp.pFrom = full_path;
- fileOp.pTo = dest_path;
- fileOp.fFlags = FOF_NO_UI;
-
- if (SHFileOperation(&fileOp) != 0) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
-
- entry = make_entry(src_is_dir, dest_path, NULL);
- cordova_success_callback(callback_id, FALSE, entry);
- free(entry);
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
- if (dst_uri)
- text_buf_free(dst_uri);
-
- return res;
-}
-
-static HRESULT move_to(BSTR callback_id, BSTR args)
-{
- return move_or_copy_to(callback_id, args, TRUE);
-}
-
-static HRESULT copy_to(BSTR callback_id, BSTR args)
-{
- return move_or_copy_to(callback_id, args, FALSE);
-}
-
-static HRESULT private_remove(BSTR callback_id, BSTR args, BOOL recursive)
-{
- HRESULT res = S_OK;
- JsonArray array;
- wchar_t *uri = NULL;
- CordovaFsError err;
- SHFILEOPSTRUCT fileOp;
- BOOL is_dir;
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- // Convert to path
- uri = json_get_string_value(array);
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, TRUE, &is_dir);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
- if (!wcscmp(full_path, temporary_root_path) || !wcscmp(full_path, persistent_root_path)) {
- file_fail_callback(callback_id, NO_MODIFICATION_ALLOWED_ERR);
- goto out;
- }
-
- if (!recursive && is_dir && !PathIsDirectoryEmpty(full_path)) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
-
- // Remove
- full_path[wcslen(full_path) + 1] = 0; // double-null terminated required by SHFileOperation()
- memset(&fileOp, 0, sizeof(SHFILEOPSTRUCT));
- fileOp.wFunc = FO_DELETE;
- fileOp.pFrom = full_path;
- fileOp.fFlags = FOF_NO_UI;
-
- if (SHFileOperation(&fileOp)) {
- file_fail_callback(callback_id, NOT_FOUND_ERR);
- }
-
- cordova_success_callback(callback_id, FALSE, NULL_MESSAGE);
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
-
- return res;
-}
-
-static HRESULT remove(BSTR callback_id, BSTR args)
-{
- return private_remove(callback_id, args, FALSE);
-}
-
-static HRESULT get_parent(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- wchar_t *uri = NULL;
- CordovaFsError err;
- wchar_t *entry;
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- // Convert to path
- uri = json_get_string_value(array);
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, TRUE, NULL);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
- if (wcscmp(full_path, temporary_root_path) && wcscmp(full_path, persistent_root_path))
- *wcsrchr(full_path, L'\\') = 0;
-
- // Get parent
- entry = make_entry(TRUE, full_path, NULL);
- cordova_success_callback(callback_id, FALSE, entry);
- free(entry);
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
-
- return res;
-}
-
-// FileEntry
-// ---------------------------------------------------------------------------
-
-static HRESULT get_file_metadata(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- wchar_t *uri = NULL;
- CordovaFsError err;
- HANDLE hFind = INVALID_HANDLE_VALUE;
- WIN32_FIND_DATA ffd;
- wchar_t *format = L"{name:'%s',fullPath:'%s',type:'%s',lastModifiedDate:new Date(%I64d),size:%I64d}";
- wchar_t *response;
- ULARGE_INTEGER ull;
- wchar_t *type = NULL;
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- // Convert to path
- uri = json_get_string_value(array);
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, TRUE, NULL);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
-
- // Get file info
- hFind = FindFirstFile(full_path, &ffd);
- if (INVALID_HANDLE_VALUE == hFind) {
- if (GetLastError() == ERROR_FILE_NOT_FOUND) {
- file_fail_callback(callback_id, NOT_FOUND_ERR);
- } else {
- res = E_FAIL;
- goto out;
- }
- }
-
- ull.LowPart = ffd.nFileSizeLow;
- ull.HighPart = ffd.nFileSizeHigh;
- type = type_from_file_name(ffd.cFileName);
- uri[DRIVE_COLUMN_POS] = L'_'; // Replace drive ':'
-
- // Build & send response
- response = (wchar_t *)malloc(sizeof(wchar_t) * (1 + wcslen(format) + wcslen(ffd.cFileName) +
- wcslen(uri) + wcslen(type) + 40));
- wsprintf(response, format, ffd.cFileName, uri, type,
- filetime_to_timet(&ffd.ftLastWriteTime), ull.QuadPart);
- cordova_success_callback(callback_id, FALSE, response);
-
- FindClose(hFind);
- free(response);
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
- if (type)
- free(type);
-
- return res;
-}
-
-// DirectoryEntry
-// ---------------------------------------------------------------------------
-
-static HRESULT get_fs_object(BSTR callback_id, BSTR args, BOOL is_dir)
-{
- HRESULT res = S_OK;
- JsonArray array;
- JsonItem item;
- wchar_t *uri = NULL;
- CordovaFsError err;
- JsonObjectItem options;
- HANDLE hFind = INVALID_HANDLE_VALUE;
- WIN32_FIND_DATA ffd;
- BOOL option_create = FALSE;
- BOOL option_exclusive = FALSE;
- JsonObjectItem object;
- wchar_t *entry;
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_STRING,
- JSON_VALUE_OBJECT | JSON_VALUE_NULL,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
- item = json_array_get_first(array);
-
- // Convert src uri to path
- uri = json_get_string_value(item);
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, TRUE, NULL);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
-
- // Convert dst uri to path
- item = json_array_get_next(item);
- free(uri);
-
- uri = json_get_string_value(item);
-
- if (!wcsncmp(uri, URL_START, wcslen(URL_START))) { // absolute path
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, FALSE, NULL);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
-
- if (!wcscmp(full_path, temporary_root_path) || !wcscmp(full_path, persistent_root_path)) {
- file_fail_callback(callback_id, NO_MODIFICATION_ALLOWED_ERR);
- goto out;
- }
- } else { // relative to src path
- wchar_t *ptr = uri;
-
- while (*ptr++) {
- if (*ptr == L'/')
- *ptr = L'\\';
- }
-
- if (!path_is_valid(uri)) {
- file_fail_callback(callback_id, ENCODING_ERR);
- goto out;
- }
-
- if (!PathAppend(full_path, uri)) {
- file_fail_callback(callback_id, ENCODING_ERR);
- goto out;
- }
- }
-
- item = json_array_get_next(item);
- if (json_get_value_type(item) != JSON_VALUE_NULL) {
- options = json_object_get_first(json_get_object_value(item));
- object = json_object_find_prop(options, L"create", JSON_VALUE_BOOL);
- if (object)
- option_create = json_get_bool_value(to_item(object));
-
- object = json_object_find_prop(options, L"exclusive", JSON_VALUE_BOOL);
- if (object)
- option_exclusive = json_get_bool_value(to_item(object));
- }
-
- // Get file info
- hFind = FindFirstFile(full_path, &ffd);
- if (INVALID_HANDLE_VALUE == hFind) {
- DWORD err = GetLastError();
- if (err == ERROR_INVALID_NAME) {
- file_fail_callback(callback_id, ENCODING_ERR);
- goto out;
- }
-
- if (option_create) {
- if (is_dir) {
- if (!SUCCEEDED(SHCreateDirectory(NULL,full_path))) {
- res = E_FAIL;
- goto out;
- }
- } else {
- HANDLE file;
- if ((file = CreateFile(full_path, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) {
- res = E_FAIL;
- goto out;
- }
- CloseHandle(file);
- }
- } else {
- file_fail_callback(callback_id, NOT_FOUND_ERR);
- goto out;
- }
- } else { // exists
- if (option_create && option_exclusive) {
- file_fail_callback(callback_id, PATH_EXISTS_ERR);
- goto out;
- }
- if (((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)?TRUE:FALSE) != is_dir) {
- file_fail_callback(callback_id, TYPE_MISMATCH_ERR);
- goto out;
- }
- }
-
- // Return entry
- entry = make_entry(TRUE, full_path, NULL);
- cordova_success_callback(callback_id, FALSE, entry);
- free(entry);
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
-
- return res;
-}
-
-static HRESULT get_directory(BSTR callback_id, BSTR args)
-{
- return get_fs_object(callback_id, args, TRUE);
-}
-
-static HRESULT get_file(BSTR callback_id, BSTR args)
-{
- return get_fs_object(callback_id, args, FALSE);
-}
-
-static HRESULT remove_recursively(BSTR callback_id, BSTR args)
-{
- return private_remove(callback_id, args, TRUE);
-}
-
-// FileReader
-// ---------------------------------------------------------------------------
-
-static HRESULT read_file(BSTR callback_id, wchar_t *uri, wchar_t *encoding, BOOL is_base64)
-{
- HRESULT res = S_OK;
- CordovaFsError err;
- HANDLE file = INVALID_HANDLE_VALUE;
- ULARGE_INTEGER file_size;
- BOOL is_dir;
- char *buf = NULL;
- int utf16_len;
- wchar_t *utf16_text = NULL;
- DWORD read;
- wchar_t *base64_prefix = L"data:text/plain;base64,";
- size_t extra_len = is_base64?wcslen(base64_prefix):0;
-
- // Convert src uri to path
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, TRUE, &is_dir);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
-
- if (is_dir) {
- file_fail_callback(callback_id, TYPE_MISMATCH_ERR);
- goto out;
- }
-
- // Open file
- file = CreateFile(full_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (file == INVALID_HANDLE_VALUE) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
-
- // Read file contents
- file_size.LowPart = GetFileSize(file, &file_size.HighPart);
- if (file_size.HighPart) {
- file_fail_callback(callback_id, ABORT_ERR);
- goto out;
- }
-
- buf = (char *) malloc(file_size.LowPart + 1);
- buf[file_size.LowPart] = 0;
- if (!ReadFile(file, buf, file_size.LowPart, &read, NULL)) {
- file_fail_callback(callback_id, ABORT_ERR);
- goto out;
- }
-
- // Convert buffer
- if (_wcsicmp(encoding, L"UTF-8")) {
- file_fail_callback(callback_id, ABORT_ERR);
- goto out;
- }
-
- utf16_len = MultiByteToWideChar(CP_UTF8, 0, buf, -1, NULL, 0); // First call to get length
- utf16_text = (wchar_t *) malloc(sizeof(wchar_t) * (2 + utf16_len + extra_len));
- utf16_text[1 + utf16_len + extra_len] = 0;
- if (!MultiByteToWideChar(CP_UTF8, 0, buf, -1, utf16_text + 1 + extra_len, utf16_len)) {
- file_fail_callback(callback_id, ABORT_ERR);
- goto out;
- }
-
- utf16_text[0] = L'\'';
- if (is_base64)
- memcpy(utf16_text + 1, base64_prefix, sizeof(wchar_t) * wcslen(base64_prefix));
- utf16_text[utf16_len + extra_len] = L'\'';
- cordova_success_callback(callback_id, FALSE, utf16_text);
-
-out:
- if (buf)
- free(buf);
- if (utf16_text)
- free(utf16_text);
- if (file != INVALID_HANDLE_VALUE)
- CloseHandle(file);
-
- return res;
-}
-
-static HRESULT read_as_text(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- JsonItem item;
- wchar_t *uri = NULL;
- wchar_t *encoding = NULL;
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- item = json_array_get_first(array);
- uri = json_get_string_value(item);
- item = json_array_get_next(item);
- encoding = json_get_string_value(item);
-
- res = read_file(callback_id, uri, encoding, FALSE);
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
- if (encoding)
- free(encoding);
-
- return res;
-}
-
-static HRESULT read_as_data_url(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- wchar_t *uri = NULL;
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- uri = json_get_string_value(array);
-
- res = read_file(callback_id, uri, L"UTF-8", TRUE);
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
-
- return res;
-}
-
-// FileWriter
-// ---------------------------------------------------------------------------
-
-static HRESULT write(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- JsonItem item;
- wchar_t *uri = NULL;
- CordovaFsError err;
- HANDLE file = INVALID_HANDLE_VALUE;
- char *utf8_text = NULL;
- int utf8_len;
- DWORD written;
- LARGE_INTEGER seek;
- wchar_t response[20];
- wchar_t *data = NULL;
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_STRING,
- JSON_VALUE_INT64,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
- item = json_array_get_first(array);
-
- // Convert src uri to path
- uri = json_get_string_value(item);
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, FALSE, NULL);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
-
- // Open file
- file = CreateFile(full_path, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (file == INVALID_HANDLE_VALUE) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
-
- // Write file
- item = json_array_get_next(item);
- data = json_get_string_value(item);
- utf8_len = WideCharToMultiByte(CP_UTF8, 0, data, wcslen(data), NULL, 0, NULL, NULL); // First call to get length
- utf8_text = (char *) malloc(utf8_len + 1);
- if (!WideCharToMultiByte(CP_UTF8, 0, data, wcslen(data), utf8_text, utf8_len, NULL, NULL)) {
- file_fail_callback(callback_id, ABORT_ERR);
- goto out;
- }
-
- item = json_array_get_next(item);
- seek.QuadPart = json_get_int64_value(item);
- if (!SetFilePointerEx(file, seek, NULL, FILE_BEGIN)) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
-
- if (!WriteFile(file, utf8_text, utf8_len, &written, NULL)) {
- file_fail_callback(callback_id, ABORT_ERR);
- goto out;
- }
-
- wsprintf(response, L"%d", written);
- cordova_success_callback(callback_id, FALSE, response);
-
-out:
- json_free_args(array);
- if (uri)
- free(uri);
- if (data)
- free(data);
- if (utf8_text)
- free(utf8_text);
- if (file != INVALID_HANDLE_VALUE)
- CloseHandle(file);
-
- return res;
-}
-
-static HRESULT truncate(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- JsonItem item;
- wchar_t *uri = NULL;
- CordovaFsError err;
- HANDLE file = INVALID_HANDLE_VALUE;
- LARGE_INTEGER seek;
- wchar_t response[20];
- BOOL is_dir;
-
- // Check args
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_INT64,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
- item = json_array_get_first(array);
-
- // Convert src uri to path
- uri = json_get_string_value(item);
- full_path_size = MAX_PATH;
- err = path_from_uri(uri, full_path, &full_path_size, TRUE, &is_dir);
- if (err != FILE_NO_ERR) {
- file_fail_callback(callback_id, err);
- goto out;
- }
-
- if (is_dir) {
- file_fail_callback(callback_id, TYPE_MISMATCH_ERR);
- goto out;
- }
-
- // Open file
- file = CreateFile(full_path, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (file == INVALID_HANDLE_VALUE) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
-
- // Truncate file
- item = json_array_get_next(item);
- seek.QuadPart = json_get_int64_value(item);
- if (!SetFilePointerEx(file, seek, NULL, FILE_BEGIN)) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
-
- if (!SetEndOfFile(file)) {
- file_fail_callback(callback_id, INVALID_MODIFICATION_ERR);
- goto out;
- }
-
- wsprintf(response, L"%I64d", seek.QuadPart);
- cordova_success_callback(callback_id, FALSE, response);
-out:
- json_free_args(array);
- if (uri)
- free(uri);
- if (file != INVALID_HANDLE_VALUE)
- CloseHandle(file);
-
- return res;
-}
-
-// Module
-// ---------------------------------------------------------------------------
-
-static HRESULT file_module_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- // FileSystem
- if (!wcscmp(action, L"requestFileSystem"))
- return request_file_system(callback_id, args);
- if (!wcscmp(action, L"resolveLocalFileSystemURI"))
- return resolve_file_system_uri(callback_id, args);
- // DirectoryReader
- if (!wcscmp(action, L"readEntries"))
- return read_entries(callback_id, args);
- // Entry
- if (!wcscmp(action, L"getMetadata"))
- return get_metadata(callback_id, args);
- if (!wcscmp(action, L"moveTo"))
- return move_to(callback_id, args);
- if (!wcscmp(action, L"copyTo"))
- return copy_to(callback_id, args);
- if (!wcscmp(action, L"remove"))
- return remove(callback_id, args);
- if (!wcscmp(action, L"getParent"))
- return get_parent(callback_id, args);
- // FileEntry
- if (!wcscmp(action, L"getFileMetadata"))
- return get_file_metadata(callback_id, args);
- // DirectoryEntry
- if (!wcscmp(action, L"getDirectory"))
- return get_directory(callback_id, args);
- if (!wcscmp(action, L"removeRecursively"))
- return remove_recursively(callback_id, args);
- if (!wcscmp(action, L"getFile"))
- return get_file(callback_id, args);
- // FileReader
- if (!wcscmp(action, L"readAsText"))
- return read_as_text(callback_id, args);
- if (!wcscmp(action, L"readAsDataURL"))
- return read_as_data_url(callback_id, args);
- // FileWriter
- if (!wcscmp(action, L"write"))
- return write(callback_id, args);
- if (!wcscmp(action, L"truncate"))
- return truncate(callback_id, args);
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-static void file_module_init(void)
-{
- int result;
-
- // Initialize root paths
- *temporary_root_path = 0;
- *persistent_root_path = 0;
-
- if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, persistent_root_path))) {
- PathAppend(persistent_root_path, L"Cordova\\fs");
- wcscpy_s(temporary_root_path, MAX_PATH, persistent_root_path);
-
- temporary_dir = get_device_uuid();
- PathAppend(temporary_root_path, temporary_dir);
- PathAppend(persistent_root_path, persistent_dir);
-
- result = SHCreateDirectory(NULL,temporary_root_path);
- if(!SUCCEEDED(result) && (result != ERROR_FILE_EXISTS) && (result != ERROR_ALREADY_EXISTS))
- *temporary_root_path = 0;
-
- result = SHCreateDirectory(NULL,persistent_root_path);
- if(!SUCCEEDED(result) && (result != ERROR_FILE_EXISTS) && (result != ERROR_ALREADY_EXISTS))
- *persistent_root_path = 0;
- }
-}
-
-static void file_module_close(void)
-{
- int res;
- SHFILEOPSTRUCT fileOp;
-
- // Remove temporary filesystem (uuid based)
- wcscpy_s(full_path, MAX_PATH, temporary_root_path);
- full_path[wcslen(temporary_root_path) + 1] = 0; // double-null terminated required by SHFileOperation()
- memset(&fileOp, 0, sizeof(SHFILEOPSTRUCT));
- fileOp.wFunc = FO_DELETE;
- fileOp.pFrom = full_path;
- fileOp.fFlags = FOF_NO_UI | FOF_NOCONFIRMATION;
-
- res = SHFileOperation(&fileOp);
-}
-
-DEFINE_CORDOVA_MODULE(File, L"File", file_module_exec, file_module_init, file_module_close)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/file.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/file.h b/windows7/Cordova/file.h
deleted file mode 100644
index bdef226..0000000
--- a/windows7/Cordova/file.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <WTypes.h>
-
-#include "shell.h"
-
-typedef enum {
- FILE_NO_ERR = 0,
- NOT_FOUND_ERR,
- SECURITY_ERR,
- ABORT_ERR,
- NOT_READABLE_ERR,
- ENCODING_ERR,
- NO_MODIFICATION_ALLOWED_ERR,
- INVALID_STATE_ERR,
- SYNTAX_ERR,
- INVALID_MODIFICATION_ERR,
- QUOTA_EXCEEDED_ERR,
- TYPE_MISMATCH_ERR,
- PATH_EXISTS_ERR
-} CordovaFsError;
-
-CordovaFsError path_from_uri(wchar_t *uri, wchar_t *path, DWORD *len, BOOL must_exist, BOOL *is_dir);
-wchar_t *make_entry(BOOL is_dir, wchar_t *root_path, wchar_t *rel_path);
-
-DECLARE_CORDOVA_MODULE(File)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/filetransfer.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/filetransfer.c b/windows7/Cordova/filetransfer.c
deleted file mode 100644
index cd3cbb8..0000000
--- a/windows7/Cordova/filetransfer.c
+++ /dev/null
@@ -1,486 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <Shlwapi.h>
-#include <WinInet.h>
-#include <stdio.h>
-
-#include "filetransfer.h"
-#include "common.h"
-#include "file.h"
-#include "json.h"
-
-#pragma comment(lib, "wininet.lib")
-
-
-#define CHUNK_SIZE (1024 * 1024) // 1 MB
-
-#define BOUNDARY "--------------------------cordova"
-
-#define _WIDE_CHAR(text) L##text
-#define WIDE_CHAR(text) _WIDE_CHAR(text)
-
-typedef enum {
- TRANSFER_NO_ERR = 0,
- FILE_NOT_FOUND_ERR,
- INVALID_URL_ERR,
- CONNECTION_ERR
-} FileTransferError;
-
-static void file_transfer_fail_callback(wchar_t *callback_id, wchar_t *src, wchar_t *target, DWORD http_status, FileTransferError err)
-{
- const wchar_t *format = L"{code:%d,source:'%s',target:'%s',http_status:%d}";
- wchar_t *error_text;
-
- error_text = (wchar_t *) malloc(sizeof(wchar_t) * (1 + wcslen(format) + 2 + wcslen(src) + wcslen(target) + 5));
- wsprintf(error_text, format, err, src, target, http_status);
-
- cordova_fail_callback(callback_id, FALSE, CB_GENERIC_ERROR, error_text);
-
- free(error_text);
-}
-
-static HRESULT download(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- JsonItem item;
- CordovaFsError fs_err;
- wchar_t *src_uri = NULL;
- wchar_t *dst_uri = NULL;
- HINTERNET inet = NULL;
- HINTERNET file = NULL;
- DWORD context = (DWORD) callback_id;
- DWORD read;
- HANDLE local_file = INVALID_HANDLE_VALUE;
- wchar_t *entry;
- DWORD index = 0;
- DWORD status;
- DWORD status_len = sizeof(status);
- wchar_t full_path[MAX_PATH + 1];
- DWORD full_path_size;
- BYTE *buf = NULL;
-
- // Validate array contents
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING, // 0- source uri
- JSON_VALUE_STRING, // 1- target path
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- // Get args
- item = json_array_get_first(array);
- src_uri = json_get_string_value(item);
- item = json_array_get_next(item);
- dst_uri = json_get_string_value(item);
-
- // Check target path
- full_path_size = MAX_PATH;
- fs_err = path_from_uri(dst_uri, full_path, &full_path_size, FALSE, NULL);
- if (fs_err != FILE_NO_ERR) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, FILE_NOT_FOUND_ERR);
- goto out;
- }
-
- // Open source url
- inet = InternetOpen(L"Cordova", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
- if (!inet) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto out;
- }
-
- file = InternetOpenUrl(inet, src_uri, NULL, 0, 0, context);
- if (!file) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, INVALID_URL_ERR);
- goto out;
- }
-
- if (!HttpQueryInfo(file, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &status_len, &index)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto out;
- }
- if (status != 200) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, status, CONNECTION_ERR);
- goto out;
- }
-
- // Create local file
- local_file = CreateFile(full_path, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (local_file == INVALID_HANDLE_VALUE) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, FILE_NOT_FOUND_ERR);
- goto out;
- }
-
- // Read data
- buf = (BYTE *) malloc(CHUNK_SIZE);
- read = 0;
- while (InternetReadFile(file, buf, CHUNK_SIZE, &read)) {
- DWORD written;
-
- if (read == 0)
- break;
-
- if (!WriteFile(local_file, buf, read, &written, NULL)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, FILE_NOT_FOUND_ERR);
- goto out;
- }
- }
- if (GetLastError() != ERROR_SUCCESS) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto out;
- }
-
- // Return entry
- entry = make_entry(FALSE, full_path, NULL);
- cordova_success_callback(callback_id, FALSE, entry);
- free(entry);
-
-out:
- json_free_args(array);
- if (local_file != INVALID_HANDLE_VALUE)
- CloseHandle(local_file);
- if (file)
- InternetCloseHandle(file);
- if (inet)
- InternetCloseHandle(inet);
- if (src_uri)
- free(src_uri);
- if (dst_uri)
- free(dst_uri);
- if (buf)
- free(buf);
-
- return res;
-}
-
-static int get_internet_port(const wchar_t *uri)
-{
- wchar_t inet_buf[INTERNET_MAX_PORT_NUMBER_LENGTH + 1];
- DWORD size = INTERNET_MAX_PORT_NUMBER_LENGTH;
- int res = INTERNET_DEFAULT_HTTP_PORT;
-
- // Try to get explicit port number
- if (UrlGetPart(uri, inet_buf, &size, URL_PART_PORT, 0) != S_OK) {
- // Or default to scheme port
- if (UrlGetPart(uri, inet_buf, &size, URL_PART_SCHEME, 0) == S_OK) {
- if (!wcscmp(inet_buf, L"https"))
- res = INTERNET_DEFAULT_HTTPS_PORT;
- }
- } else
- swscanf_s(inet_buf, L"%d", &res);
-
- return res;
-}
-
-static const wchar_t *find_oject_name(const wchar_t *uri)
-{
- wchar_t inet_buf[INTERNET_MAX_SCHEME_LENGTH + 1];
- DWORD size = INTERNET_MAX_SCHEME_LENGTH;
- unsigned int pos = 0;
-
- if (UrlGetPart(uri, inet_buf, &size, URL_PART_SCHEME, 0) == S_OK)
- pos += wcslen(inet_buf) + 3;
-
- while (pos < wcslen(uri) && uri[pos] != L'/')
- pos++;
-
- return (uri + pos);
-}
-
-static HRESULT upload(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- JsonArray array;
- JsonItem item;
- JsonObjectItem param;
- CordovaFsError fs_err;
- wchar_t *item_val;
- size_t item_len;
- wchar_t *src_uri = NULL;
- wchar_t *dst_uri = NULL;
- wchar_t full_path[MAX_PATH + 1];
- wchar_t server_name[INTERNET_MAX_HOST_NAME_LENGTH + 1];
- wchar_t user_name[INTERNET_MAX_USER_NAME_LENGTH + 1];
- wchar_t passwd[INTERNET_MAX_PASSWORD_LENGTH + 1];
- BOOL is_dir;
- HINTERNET inet = NULL;
- HINTERNET server = NULL;
- HINTERNET req = NULL;
- DWORD context = (DWORD) callback_id;
- TextBuf txt_buf = NULL;
- char *utf8_text = NULL;
- int utf8_len;
- DWORD written;
- HANDLE file = INVALID_HANDLE_VALUE;
- const char *end_contents = "\r\n--" BOUNDARY "--\r\n";
- ULARGE_INTEGER file_size;
- DWORD index = 0;
- DWORD status;
- DWORD status_len = sizeof(status);
- DWORD size;
- BYTE *buf = NULL;
-
- // Validate array contents
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING, // 0- file path
- JSON_VALUE_STRING, // 1- server
- JSON_VALUE_STRING | JSON_VALUE_NULL,// 2- file key
- JSON_VALUE_STRING | JSON_VALUE_NULL,// 3- file name
- JSON_VALUE_STRING | JSON_VALUE_NULL,// 4- mime type
- JSON_VALUE_OBJECT | JSON_VALUE_NULL,// 5- params (key/value pairs)
- JSON_VALUE_BOOL | JSON_VALUE_NULL, // 6- trust all hosts
- JSON_VALUE_BOOL | JSON_VALUE_NULL, // 7- chunkedMode
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- // Get source & target uri
- item = json_array_get_first(array);
- src_uri = json_get_string_value(item);
- item = json_array_get_next(item);
- dst_uri = json_get_string_value(item);
-
- // Check source path
- size = MAX_PATH;
- fs_err = path_from_uri(src_uri, full_path, &size, TRUE, &is_dir);
- if (fs_err != FILE_NO_ERR || is_dir) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, FILE_NOT_FOUND_ERR);
- goto out;
- }
-
- file = CreateFile(full_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (file == INVALID_HANDLE_VALUE) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto out;
- }
-
- file_size.LowPart = GetFileSize(file, &file_size.HighPart);
-
- // Connect to server
- inet = InternetOpen(L"Cordova", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
- if (!inet) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto out;
- }
-
- size = INTERNET_MAX_HOST_NAME_LENGTH;
- UrlGetPart(dst_uri, server_name, &size, URL_PART_HOSTNAME, 0);
- size = INTERNET_MAX_USER_NAME_LENGTH;
- UrlGetPart(dst_uri, user_name, &size, URL_PART_USERNAME, 0);
- size = INTERNET_MAX_PASSWORD_LENGTH;
- UrlGetPart(dst_uri, passwd, &size, URL_PART_PASSWORD, 0);
- server = InternetConnect(inet, server_name, get_internet_port(dst_uri), user_name, passwd, INTERNET_SERVICE_HTTP, 0, 0);
- if (!server) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, INVALID_URL_ERR);
- goto out;
- }
-
- // Build send request
- req = HttpOpenRequest(server, L"POST", find_oject_name(dst_uri), NULL, NULL, NULL, 0, context);
- if (!req) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, INVALID_URL_ERR);
- goto out;
- }
-
- // 1- Headers
- buf = (BYTE *) malloc(CHUNK_SIZE);
- txt_buf = text_buf_new();
-
- text_buf_append(txt_buf, L"Content-Type: multipart/form-data; boundary=" WIDE_CHAR(BOUNDARY));
- if (!HttpAddRequestHeaders(req, text_buf_get(txt_buf), text_buf_get_len(txt_buf), HTTP_ADDREQ_FLAG_ADD)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto end_req;
- }
-
- item = json_array_item_at(array, 5);
- if (json_get_value_type(item) != JSON_VALUE_NULL) {
- param = json_get_object_value(item);
- while (param && json_get_value_type(to_item(param)) != JSON_VALUE_EMPTY) {
- wchar_t *tag;
-
- tag = json_object_get_prop_id(param);
- item_val = json_get_string_value(to_item(param));
-
- text_buf_reset(txt_buf);
- text_buf_append_len(txt_buf, tag, wcslen(tag));
- text_buf_append(txt_buf, L":\"");
- text_buf_append_len(txt_buf, item_val, wcslen(item_val));
- text_buf_append(txt_buf, L"\"");
-
- free(tag);
- free(item_val);
-
- if (!HttpAddRequestHeaders(req, text_buf_get(txt_buf), text_buf_get_len(txt_buf), HTTP_ADDREQ_FLAG_ADD)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto out;
- }
-
- param = json_object_get_next(param);
- }
- }
-
- // 2- Contents
- // 2.1 Contents headers
- text_buf_reset(txt_buf);
- text_buf_append(txt_buf, L"--" WIDE_CHAR(BOUNDARY) L"\r\nContent-Disposition: form-data; name=\"");
-
- item = json_array_item_at(array, 2);
- if (json_get_value_type(item) == JSON_VALUE_NULL)
- item_val = _wcsdup(L"uploaded_name");
- else
- item_val = json_get_string_value(item);
- item_len = wcslen(item_val);
- text_buf_append_len(txt_buf, item_val, item_len);
- text_buf_append(txt_buf, L"\"; filename=\"");
- free(item_val);
-
- item = json_array_item_at(array, 3);
- if (json_get_value_type(item) == JSON_VALUE_NULL)
- item_val = _wcsdup(L"uploaded_file");
- else
- item_val = json_get_string_value(item);
- item_len = wcslen(item_val);
- text_buf_append_len(txt_buf, item_val, item_len);
- text_buf_append(txt_buf, L"\"\r\nContent-Type: ");
- free(item_val);
-
- item = json_array_item_at(array, 4);
- if (json_get_value_type(item) == JSON_VALUE_NULL)
- item_val = _wcsdup(L"application/octet-stream");
- else
- item_val = json_get_string_value(item);
- item_len = wcslen(item_val);
- text_buf_append_len(txt_buf, item_val, item_len);
- text_buf_append(txt_buf, L"\r\n\r\n");
- free(item_val);
-
- utf8_len = WideCharToMultiByte(CP_UTF8, 0, text_buf_get(txt_buf), text_buf_get_len(txt_buf), NULL, 0, NULL, NULL); // First call to get length
- utf8_text = (char *) malloc(utf8_len + 1);
- if (!WideCharToMultiByte(CP_UTF8, 0, text_buf_get(txt_buf), text_buf_get_len(txt_buf), utf8_text, utf8_len, NULL, NULL)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto end_req;
- }
-
- wsprintf((wchar_t *) buf, L"Content-Length: %I64d", file_size.QuadPart + utf8_len + strlen(end_contents));
- if (!HttpAddRequestHeaders(req, (wchar_t *) buf, wcslen((wchar_t *) buf), HTTP_ADDREQ_FLAG_ADD)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto end_req;
- }
-
- if (!HttpSendRequestEx(req, NULL, NULL, 0, context)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto end_req;
- }
-
- if (!InternetWriteFile(req, utf8_text, utf8_len, &written)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto end_req;
- }
-
- // 2.2 Contents data
- do {
- if (!ReadFile(file, buf, CHUNK_SIZE, &size, NULL)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto out;
- }
-
- if (size == 0)
- break;
-
- if (!InternetWriteFile(req, buf, size, &written)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto end_req;
- }
- } while (TRUE);
-
- // 2.3 Contents footer
- if (!InternetWriteFile(req, end_contents, strlen(end_contents), &written)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto end_req;
- }
-
-end_req:
-
- // Close request
- if (!HttpEndRequest(req, NULL, 0, 0)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto out;
- }
-
- if (!HttpQueryInfo(req, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &status_len, &index)) {
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, 0, CONNECTION_ERR);
- goto out;
- }
-
- if (status != 200) { // Either failure
- file_transfer_fail_callback(callback_id, src_uri, dst_uri, status, CONNECTION_ERR);
- goto out;
- } else { // Or success
- text_buf_reset(txt_buf);
- text_buf_append(txt_buf, L"{responseCode:200,response:'");
- ((wchar_t *) buf)[0] = 0;
- InternetReadFile(req, buf, CHUNK_SIZE - 1, &size);
- ((wchar_t *) buf)[size] = 0;
- text_buf_append(txt_buf, (wchar_t *) buf);
- text_buf_append(txt_buf, L"',bytesSent:");
- wsprintf((wchar_t *) buf, L"%I64d", file_size.QuadPart);
- text_buf_append(txt_buf, (wchar_t *) buf);
- text_buf_append(txt_buf, L"}");
-
- cordova_success_callback(callback_id, FALSE, text_buf_get(txt_buf));
- }
-
-out:
- json_free_args(array);
- if (req)
- InternetCloseHandle(req);
- if (server)
- InternetCloseHandle(server);
- if (inet)
- InternetCloseHandle(inet);
- if (src_uri)
- free(src_uri);
- if (dst_uri)
- free(dst_uri);
- if (buf)
- free(buf);
- if (txt_buf)
- text_buf_free(txt_buf);
- if (utf8_text)
- free(utf8_text);
- if (file != INVALID_HANDLE_VALUE)
- CloseHandle(file);
-
- return res;
-}
-
-HRESULT file_transfer_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- if (!wcscmp(action, L"download"))
- return download(callback_id, args);
- if (!wcscmp(action, L"upload"))
- return upload(callback_id, args);
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-DEFINE_CORDOVA_MODULE(FileTransfer, L"FileTransfer", file_transfer_exec, NULL, NULL)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/filetransfer.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/filetransfer.h b/windows7/Cordova/filetransfer.h
deleted file mode 100644
index c331ad6..0000000
--- a/windows7/Cordova/filetransfer.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "shell.h"
-
-DECLARE_CORDOVA_MODULE(FileTransfer)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/jpeg.cpp
----------------------------------------------------------------------
diff --git a/windows7/Cordova/jpeg.cpp b/windows7/Cordova/jpeg.cpp
deleted file mode 100644
index 9aeb8a7..0000000
--- a/windows7/Cordova/jpeg.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <windows.h>
-#include <gdiplus.h>
-
-#include "jpeg.h"
-
-#pragma comment(lib, "gdiplus.lib")
-
-using namespace Gdiplus;
-
-
-int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
-{
- UINT num = 0; // number of image encoders
- UINT size = 0; // size of the image encoder array in bytes
-
- ImageCodecInfo* pImageCodecInfo = NULL;
-
- GetImageEncodersSize(&num, &size);
- if(size == 0)
- return -1; // Failure
-
- pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
- if(pImageCodecInfo == NULL)
- return -1; // Failure
-
- GetImageEncoders(num, size, pImageCodecInfo);
-
- for(UINT j = 0; j < num; ++j)
- {
- if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
- {
- *pClsid = pImageCodecInfo[j].Clsid;
- free(pImageCodecInfo);
- return j; // Success
- }
- }
-
- free(pImageCodecInfo);
- return -1; // Failure
-}
-
-
-int save_bitmap_as_jpeg (int width, int height, unsigned char* data, unsigned int sample_size, wchar_t* filename, int scan_len)
-{
- int success;
- GdiplusStartupInput gdiplusStartupInput;
- ULONG_PTR gdiplusToken;
- CLSID encoderClsid;
- EncoderParameters encoderParameters;
- ULONG quality;
- int row_bytes = (width * 3 +3)/4*4; // 24 bpp padded format
- Bitmap* image;
-
- GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
-
- if (height <= 1 || scan_len >= 0)
- {
- image = new Bitmap(width, height, row_bytes, PixelFormat24bppRGB, data);
- }
- else
- {
- image = new Bitmap(width, height, -row_bytes, PixelFormat24bppRGB, data + row_bytes*(height-1));
- }
-
- // If we can find the JPEG encoder
- if (GetEncoderClsid(L"image/jpeg", &encoderClsid) != -1)
- {
- // Save the image at JPEG quality level 85
-
- encoderParameters.Count = 1;
- encoderParameters.Parameter[0].Guid = EncoderQuality;
- encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
- encoderParameters.Parameter[0].NumberOfValues = 1;
-
- quality = 85;
- encoderParameters.Parameter[0].Value = &quality;
- success = (image->Save(filename, &encoderClsid, &encoderParameters) == Ok);
- }
- else
- success = 0;
-
- delete image;
- GdiplusShutdown(gdiplusToken);
-
- return success;
-}
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/jpeg.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/jpeg.h b/windows7/Cordova/jpeg.h
deleted file mode 100644
index 404c93a..0000000
--- a/windows7/Cordova/jpeg.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <wchar.h>
-
-#ifdef __cplusplus
-extern "C"
-#endif
-
-int save_bitmap_as_jpeg (int width, int height, unsigned char* data, unsigned int sample_size, wchar_t* filename, int scan_len);
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/json.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/json.c b/windows7/Cordova/json.c
deleted file mode 100644
index b99ba07..0000000
--- a/windows7/Cordova/json.c
+++ /dev/null
@@ -1,545 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <wchar.h>
-#include <assert.h>
-
-#include "json.h"
-
-#define JSON_TRUE L"true"
-#define JSON_FALSE L"false"
-#define JSON_NULL L"null"
-
-struct _JsonItem {
- // Common fields
- JsonValueType value_type;
- union {
- wchar_t *as_string;
- int as_int;
- INT64 as_int64;
- double as_double;
- BOOL as_bool;
- JsonArray as_array;
- JsonObject as_object;
- } value;
- size_t value_as_string_len;
- struct _JsonItem *next;
-};
-
-struct _JsonObjectItem {
- // Common fields
- JsonValueType value_type;
- union {
- wchar_t *as_string;
- int as_int;
- double as_double;
- JsonArray as_array;
- JsonObject as_object;
- } value;
- size_t value_as_string_len;
- struct _JsonItem *next;
- // Specific fields
- wchar_t *tag;
- size_t tag_len;
-};
-
-struct _JsonCursor {
- wchar_t *buf;
- size_t max;
- size_t pos;
-};
-typedef struct _JsonCursor JsonCursor;
-
-static BOOL json_parse_array(JsonCursor *cursor, JsonArray array);
-static BOOL json_parse_object(JsonCursor *cursor, JsonObject object);
-
-static void json_init_cursor(wchar_t * buf, JsonCursor *cursor)
-{
- memset((void *)cursor, 0, sizeof(JsonCursor));
- cursor->buf = buf;
- cursor->max = wcslen(buf);
-}
-
-static BOOL json_parse_string(JsonCursor *cursor, JsonItem item)
-{
- wchar_t *buf = cursor->buf;
- BOOL escape;
-
- cursor->pos++; // Initial '"'
- item->value.as_string = buf + cursor->pos;
- while (cursor->pos < cursor->max) {
- if (buf[cursor->pos] == '"' && !escape) {
- cursor->pos++; // Trailing '"'
- break;
- }
-
- if (buf[cursor->pos] == '\\' && !escape)
- escape = TRUE;
- else
- escape = FALSE;
-
- cursor->pos++;
- item->value_as_string_len++;
- }
-
- return (cursor->pos == cursor->max) ? FALSE : TRUE;
-}
-
-static BOOL json_parse_number(JsonCursor *cursor, JsonItem item)
-{
- wchar_t *buf = cursor->buf;
- wchar_t *value = buf + cursor->pos;
- size_t value_len = 0;
- BOOL has_dot = (buf[cursor->pos] == '.') ? TRUE : FALSE;
- INT64 val64;
-
- cursor->pos++;
- value_len++;
- while (cursor->pos < cursor->max) {
- if (buf[cursor->pos] == '.') {
- if (has_dot)
- return FALSE;
- else
- has_dot = TRUE;
- } else if (!iswdigit(buf[cursor->pos]))
- break;
-
- cursor->pos++;
- value_len++;
- }
-
- if (cursor->pos == cursor->max)
- return FALSE;
-
- item->value_type = (has_dot) ? JSON_VALUE_DOUBLE : JSON_VALUE_INT;
- if (item->value_type == JSON_VALUE_INT) {
- if (_snwscanf_s(value, value_len, L"%I64d", &val64) != 1)
- return FALSE;
- if (val64 > MAXINT) {
- item->value.as_int64 = val64;
- item->value_type = JSON_VALUE_INT64;
- } else
- item->value.as_int = (int) val64;
- item->value.as_int64 = val64;
- } else {
- if (_snwscanf_s(value, value_len, L"%f", &item->value.as_double) != 1)
- return FALSE;
- }
-
- return TRUE;
-}
-
-static BOOL json_parse_value(JsonCursor *cursor, JsonItem item)
-{
- wchar_t *buf = cursor->buf;
-
- if (buf[cursor->pos] == '\"') {
- item->value_type = JSON_VALUE_STRING;
- return json_parse_string(cursor, item);
- } else if (iswdigit(buf[cursor->pos]) || buf[cursor->pos] == '-' || buf[cursor->pos] == '.') {
- return json_parse_number(cursor, item);
- } else if (buf[cursor->pos] == '[') {
- item->value_type = JSON_VALUE_ARRAY;
- item->value.as_array = (JsonArray) calloc(1, sizeof(struct _JsonItem));
- return json_parse_array(cursor, item->value.as_array);
- } else if (buf[cursor->pos] == '{') {
- item->value_type = JSON_VALUE_OBJECT;
- item->value.as_object = (JsonObject) calloc(1, sizeof(struct _JsonObjectItem));
- return json_parse_object(cursor, item->value.as_object);
- } else if ((cursor->pos + wcslen(JSON_TRUE)) < cursor->max && !wcsncmp(buf + cursor->pos, JSON_TRUE, wcslen(JSON_TRUE))) {
- item->value_type = JSON_VALUE_BOOL;
- item->value.as_bool = TRUE;
- cursor->pos += wcslen(JSON_TRUE);
- return TRUE;
- } else if ((cursor->pos + wcslen(JSON_FALSE)) < cursor->max && !wcsncmp(buf + cursor->pos, JSON_FALSE, wcslen(JSON_FALSE))) {
- item->value_type = JSON_VALUE_BOOL;
- item->value.as_bool = FALSE;
- cursor->pos += wcslen(JSON_FALSE);
- return TRUE;
- } else if ((cursor->pos + wcslen(JSON_NULL)) < cursor->max && !wcsncmp(buf + cursor->pos, JSON_NULL, wcslen(JSON_NULL))) {
- item->value_type = JSON_VALUE_NULL;
- item->value.as_string = buf + cursor->pos;
- item->value_as_string_len = wcslen(JSON_NULL);
- cursor->pos += item->value_as_string_len;
- return TRUE;
- }
-
- return FALSE;
-}
-
-static BOOL json_parse_object(JsonCursor *cursor, JsonObject object)
-{
- wchar_t *buf = cursor->buf;
- struct _JsonObjectItem *item = (struct _JsonObjectItem *) object;
-
- cursor->pos++;
- if (buf[cursor->pos] == '}') {
- cursor->pos++;
- item->value_type = JSON_VALUE_EMPTY;
- return TRUE;
- }
-
- while (cursor->pos < cursor->max) {
- if (buf[cursor->pos] != '\"')
- return FALSE;
-
- // Tag
- cursor->pos++;
- item->tag = buf + cursor->pos;
- while (cursor->pos < cursor->max && buf[cursor->pos] != '\"') {
- cursor->pos++;
- item->tag_len++;
- }
- if (cursor->pos == cursor->max)
- return FALSE;
-
- // Seprator
- cursor->pos++;
- if (buf[cursor->pos] != ':')
- return FALSE;
-
- // Value
- cursor->pos++;
- if(!json_parse_value(cursor, (JsonItem) item))
- return FALSE;
-
- // Next
- if (buf[cursor->pos] == '}') {
- cursor->pos++;
- break;
- }
- if (buf[cursor->pos] != ',')
- return FALSE;
-
- cursor->pos++;
- item->next = (JsonItem) calloc(1, sizeof(struct _JsonObjectItem));
- item = (JsonObjectItem) item->next;
- }
-
- return TRUE;
-}
-
-static BOOL json_parse_array(JsonCursor *cursor, JsonArray item)
-{
- wchar_t *buf = cursor->buf;
-
- if (buf[cursor->pos] != '[')
- return FALSE;
-
- cursor->pos++;
- if (buf[cursor->pos] == ']') {
- cursor->pos++;
- item->value_type = JSON_VALUE_EMPTY;
- return TRUE;
- }
-
- while (cursor->pos < cursor->max) {
- if (!json_parse_value(cursor, (JsonItem) item))
- return FALSE;
-
- // Next
- if (buf[cursor->pos] == ']') {
- cursor->pos++;
- break;
- }
- if (buf[cursor->pos] != ',')
- return FALSE;
-
- cursor->pos++;
- item->next = (JsonItem) calloc(1, sizeof(struct _JsonItem));
- item = (JsonItem) item->next;
- }
-
- return TRUE;
-}
-
-BOOL json_parse_args(wchar_t * buf, JsonArray *item)
-{
- JsonCursor cursor;
- BOOL success;
-
- json_init_cursor(buf, &cursor);
-
- *item = (JsonArray) calloc(1, sizeof(struct _JsonItem));
- success = json_parse_array(&cursor, *item);
- if (success && cursor.pos == cursor.max)
- return TRUE;
-
- return FALSE;
-}
-
-static void json_free_item(JsonItem item)
-{
- JsonItem current;
-
- while (item != NULL) {
- current = item;
- switch (item->value_type) {
- case JSON_VALUE_ARRAY:
- json_free_item((JsonItem) current->value.as_array);
- break;
- case JSON_VALUE_OBJECT:
- json_free_item((JsonItem) current->value.as_object);
- break;
- default:
- break;
- }
-
- item = item->next;
- free(current);
- }
-}
-
-void json_free_args(JsonArray item)
-{
- json_free_item((JsonItem) item);
-}
-
-JsonItem json_array_get_next(JsonItem item)
-{
- return item->next;
-}
-
-JsonValueType json_get_value_type(JsonItem item)
-{
- return item->value_type;
-}
-
-int json_get_int_value(JsonItem item)
-{
- return item->value.as_int;
-}
-
-INT64 json_get_int64_value(JsonItem item)
-{
- return item->value.as_int64;
-}
-
-BOOL json_get_bool_value(JsonItem item)
-{
- return item->value.as_bool;
-}
-
-double json_get_double_value(JsonItem item)
-{
- return item->value.as_double;
-}
-
-static wchar_t decode_unicode_char(const wchar_t *text)
-{
- wchar_t val = 0;
- int i;
- const BYTE *buf = (const BYTE *) text;
-
- for(i = 1; i <= 4; i++) {
- BYTE c = buf[i];
- val <<= 4;
- if(isdigit(c))
- val += c - '0';
- else if(c >= 'a' && c <= 'f')
- val += c - 'a' + 10;
- else if(c >= 'A' && c <= 'F')
- val += c - 'A' + 10;
- else
- return 0;
- }
-
- return val;
-}
-
-wchar_t *json_get_string_value(JsonItem item)
-{
- size_t src_index = 0;
- size_t val_index = 0;
- const wchar_t *text = item->value.as_string;
-
- wchar_t *val = (wchar_t*) malloc(sizeof(wchar_t) * (item->value_as_string_len + 1));
-
- while (src_index < item->value_as_string_len) {
- if (text[src_index] == '\\') {
- src_index++;
- if (src_index == item->value_as_string_len)
- break;
-
- switch(text[src_index]) {
- case 'u':
- if ((item->value_as_string_len - src_index) > 3) {
- wchar_t unicode_val = decode_unicode_char(text + src_index);
- if (val) {
- val[val_index] = unicode_val;
- src_index += 3;
- } else
- val[val_index] = text[src_index];
- } else
- val[val_index] = text[src_index];
- break;
- case '"':
- case '\\':
- case '/':
- val[val_index] = text[src_index];
- break;
- case 'b':
- val[val_index] = '\b';
- break;
- case 'f':
- val[val_index] = '\f';
- break;
- case 'n':
- val[val_index] = '\n';
- break;
- case 'r':
- val[val_index] = '\r';
- break;
- case 't':
- val[val_index] = '\t';
- break;
- default:
- val[val_index] = text[src_index];
- }
-
- val_index++;
- src_index++;
- } else
- val[val_index++] = text[src_index++];
- }
-
- val[val_index] = 0;
-
- return val;
-}
-
-JsonObject json_get_object_value(JsonItem item)
-{
- return item->value.as_object;
-}
-
-JsonArray json_get_array_value(JsonItem item)
-{
- return item->value.as_array;
-}
-
-static int json_container_item_count(JsonItem item)
-{
- int count = 0;
-
- while (item != NULL) {
- item = item->next;
- count++;
- }
-
- return count;
-}
-
-static JsonItem json_container_item_at(JsonItem item, int position)
-{
- while (item != NULL && position) {
- item = item->next;
- position--;
- }
-
- return item;
-}
-
-int json_array_item_count(JsonArray array)
-{
- return json_container_item_count((JsonItem) array);
-}
-
-JsonItem json_array_item_at(JsonArray array, int position)
-{
- return json_container_item_at((JsonItem) array, position);
-}
-
-static BOOL is_type_compatible(JsonValueType current, JsonValueType expected)
-{
- if (expected & JSON_VALUE_INT64)
- return ((expected & current) || (JSON_VALUE_INT & current));
-
- return (expected & current);
-}
-
-static BOOL internal_json_array_validate_contents(JsonArray array, JsonValueType type, va_list args)
-{
- while(type != JSON_VALUE_INVALID) {
- if (!array)
- return FALSE;
- if (!is_type_compatible(array->value_type, type))
- return FALSE;
-
- array = array->next;
- type = va_arg(args, JsonValueType);
- }
-
- return TRUE;
-}
-
-BOOL json_array_validate_contents(JsonArray array, JsonValueType type, ...)
-{
- va_list args;
-
- va_start(args, type);
- return internal_json_array_validate_contents(array, type, args);
-}
-
-BOOL json_parse_and_validate_args(wchar_t * buf, JsonArray *array, JsonValueType type, ...)
-{
- va_list args;
-
- if (!json_parse_args(buf, array))
- return FALSE;
-
- va_start(args, type);
- return internal_json_array_validate_contents(*array, type, args);
-}
-
-int json_object_prop_count(JsonObject object)
-{
- return json_container_item_count((JsonItem) object);
-}
-
-JsonObjectItem json_object_prop_at(JsonObject object, int position)
-{
- return (JsonObjectItem) json_container_item_at((JsonItem) object, position);
-}
-
-JsonObjectItem json_object_find_prop(JsonObject object, const wchar_t *id, JsonValueType type)
-{
- while (object != NULL) {
- if (!wcsncmp(id, (wchar_t *) object->tag, wcslen(id)) &&
- wcslen(id) == object->tag_len && is_type_compatible(object->value_type, type))
- return (JsonObjectItem) object;
- object = (struct _JsonObjectItem *) object->next;
- }
-
- return NULL;
-}
-
-wchar_t *json_object_get_prop_id(JsonObject object)
-{
- wchar_t *id = (wchar_t*) malloc(sizeof(wchar_t) * (object->tag_len + 1));
-
- wcsncpy_s(id, object->tag_len + 1, object->tag, object->tag_len);
-
- return id;
-}
-
-JsonObjectItem json_object_get_next(JsonObjectItem item)
-{
- return (JsonObjectItem) item->next;
-}
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/json.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/json.h b/windows7/Cordova/json.h
deleted file mode 100644
index 36aaa48..0000000
--- a/windows7/Cordova/json.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <WTypes.h>
-
-typedef enum {
- JSON_VALUE_EMPTY = (1 << 0),
- JSON_VALUE_STRING = (1 << 1),
- JSON_VALUE_INT = (1 << 2),
- JSON_VALUE_INT64 = (1 << 3),
- JSON_VALUE_DOUBLE = (1 << 4),
- JSON_VALUE_ARRAY = (1 << 5),
- JSON_VALUE_BOOL = (1 << 6),
- JSON_VALUE_NULL = (1 << 7),
- JSON_VALUE_OBJECT = (1 << 8),
- JSON_VALUE_INVALID = (1 << 9) // Used in validation functions
-} JsonValueType;
-
-struct _JsonItem;
-struct _JsonObjectItem; // Inherits from _JsonItem
-
-typedef struct _JsonItem *JsonItem;
-typedef struct _JsonObjectItem *JsonObjectItem;
-typedef struct _JsonItem *JsonArray;
-typedef struct _JsonObjectItem *JsonObject;
-
-__inline JsonItem to_item(JsonObjectItem item) { return (JsonItem) item; }
-
-BOOL json_parse_args(wchar_t * buf, JsonArray *array);
-BOOL json_parse_and_validate_args(wchar_t * buf, JsonArray *array, JsonValueType type, ...);
-void json_free_args(JsonArray array);
-int json_array_item_count(JsonArray array);
-JsonItem json_array_item_at(JsonArray array, int position);
-BOOL json_array_validate_contents(JsonArray array, JsonValueType type, ...);
-__inline JsonItem json_array_get_first(JsonArray array) { return (JsonItem) array; }
-JsonItem json_array_get_next(JsonItem item);
-
-JsonValueType json_get_value_type(JsonItem item);
-int json_get_int_value(JsonItem item);
-INT64 json_get_int64_value(JsonItem item);
-BOOL json_get_bool_value(JsonItem item);
-double json_get_double_value(JsonItem item);
-wchar_t *json_get_string_value(JsonItem item);
-JsonObject json_get_object_value(JsonItem item);
-JsonArray json_get_array_value(JsonItem item);
-
-int json_object_prop_count(JsonObject object);
-JsonObjectItem json_object_prop_at(JsonObject object, int position);
-JsonObjectItem json_object_find_prop(JsonObject object, const wchar_t *id, JsonValueType type);
-wchar_t *json_object_get_prop_id(JsonObjectItem item);
-__inline JsonObjectItem json_object_get_first(JsonObject object) { return (JsonObjectItem) object; }
-JsonObjectItem json_object_get_next(JsonObjectItem item);
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/lib/js/exec.js
----------------------------------------------------------------------
diff --git a/windows7/Cordova/lib/js/exec.js b/windows7/Cordova/lib/js/exec.js
deleted file mode 100644
index 03f61d9..0000000
--- a/windows7/Cordova/lib/js/exec.js
+++ /dev/null
@@ -1,63 +0,0 @@
-var jsHandler = require('cordova/plugin/win7/jsHandler'),
- cordova = require('cordova');
-
-module.exports = function exec(success, fail, service, action, args) {
- try {
- // Try JS implementation
- var v = jsHandler.exec(success, fail, service, action, args);
-
- // If status is OK, then return value back to caller
- if (v.status == cordova.callbackStatus.OK) {
-
- // If there is a success callback, then call it now with returned value
- if (success) {
- try {
- success(v.message);
- }
- catch (e) {
- console.log("Error in success callback: " + service + "." + action + " = " + e);
- }
-
- }
- return v.message;
- } else if (v.status == cordova.callbackStatus.NO_RESULT) {
- // Nothing to do here
- } else if (v.status == cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION) {
- // Try native implementation
- var callbackId = service + cordova.callbackId++;
- if (typeof success == 'function' || typeof fail == 'function') {
- cordova.callbacks[callbackId] = { success: success, fail: fail };
- }
-
- try {
- if (window.external) {
- return window.external.CordovaExec(callbackId, service, action, JSON.stringify(args));
- }
- else {
- console.log('window.external not available');
- }
- }
- catch (e) {
- console.log('Exception calling native with for ' + service + '/' + action + ' - exception = ' + e);
- // Clear callback
- delete cordova.callbacks[callbackId];
- }
- } else {
- // If error, then display error
- console.log("Error: " + service + "." + action + " Status=" + v.status + " Message=" + v.message);
-
- // If there is a fail callback, then call it now with returned value
- if (fail) {
- try {
- fail(v.message);
- }
- catch (e) {
- console.log("Error in error callback: " + service + "." + action + " = " + e);
- }
- }
- return null;
- }
- } catch (e) {
- console.log('Exception calling native with for ' + service + '/' + action + ' - exception = ' + e);
- }
-};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/lib/js/platform.js
----------------------------------------------------------------------
diff --git a/windows7/Cordova/lib/js/platform.js b/windows7/Cordova/lib/js/platform.js
deleted file mode 100644
index c69aa12..0000000
--- a/windows7/Cordova/lib/js/platform.js
+++ /dev/null
@@ -1,58 +0,0 @@
-var device = require('cordova/plugin/win7/device');
-
-module.exports = {
- id: device.platform,
- initialize: function () {
- var channel = require("cordova/channel"),
- storage = require('cordova/plugin/win7/storage');
-
- // Inject a lsitener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
- var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
- onSubscribe: function () {
- if (this.numHandlers === 1) {
- exec(null, null, "Platform", "backButtonEventOn", []);
- }
- },
- onUnsubscribe: function () {
- if (this.numHandlers === 0) {
- exec(null, null, "Platform", "backButtonEventOff", []);
- }
- }
- });
-
- channel.onDestroy.subscribe(function () {
- // Remove session storage database
- storage.removeDatabase(device.uuid);
- });
-
- if (typeof window.openDatabase == 'undefined') {
- window.openDatabase = storage.openDatabase;
- }
-
- if (typeof window.localStorage == 'undefined' || window.localStorage === null) {
- Object.defineProperty(window, "localStorage", {
- writable: false,
- configurable: false,
- value: new storage.WinStorage('CordovaLocalStorage')
- });
- }
-
- channel.join(function () {
- if (typeof window.sessionStorage == 'undefined' || window.sessionStorage === null) {
- Object.defineProperty(window, "sessionStorage", {
- writable: false,
- configurable: false,
- value: new storage.WinStorage(device.uuid) // uuid is actually unique for application
- });
- }
- }, [channel.onCordovaInfoReady]);
- },
- objects: {
- device: {
- path: 'cordova/plugin/win7/device'
- },
- SQLError: {
- path: 'cordova/plugin/win7/SQLError'
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/lib/js/plugin/win7/SQLError.js
----------------------------------------------------------------------
diff --git a/windows7/Cordova/lib/js/plugin/win7/SQLError.js b/windows7/Cordova/lib/js/plugin/win7/SQLError.js
deleted file mode 100644
index 8e22794..0000000
--- a/windows7/Cordova/lib/js/plugin/win7/SQLError.js
+++ /dev/null
@@ -1,13 +0,0 @@
-var SQLError = function () {
-};
-
-SQLError.UNKNOWN_ERR = 0;
-SQLError.DATABASE_ERR = 1;
-SQLError.VERSION_ERR = 2;
-SQLError.TOO_LARGE_ERR = 3;
-SQLError.QUOTA_ERR = 4;
-SQLError.SYNTAX_ERR = 5;
-SQLError.CONSTRAINT_ERR = 6;
-SQLError.TIMEOUT_ERR = 7;
-
-module.exports = SQLError;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/lib/js/plugin/win7/device.js
----------------------------------------------------------------------
diff --git a/windows7/Cordova/lib/js/plugin/win7/device.js b/windows7/Cordova/lib/js/plugin/win7/device.js
deleted file mode 100644
index 1c72ee6..0000000
--- a/windows7/Cordova/lib/js/plugin/win7/device.js
+++ /dev/null
@@ -1,34 +0,0 @@
-var channel = require('cordova/channel'),
- exec = require('cordova/exec');
-
-function Device() {
-
- this.version = null;
- this.uuid = null;
- this.name = null;
- this.cordova = this.phonegap = '1.8.0';
- this.platform = null;
-
- var me = this;
-
- channel.onCordovaReady.subscribeOnce(function() {
- me.getInfo(function(info) {
- me.platform = info.platform;
- me.version = info.version;
- me.name = info.name;
- me.uuid = info.uuid;
- me.cordova = info.cordova;
- channel.onCordovaInfoReady.fire();
- },function(e) {
- console.log('Error initializing Cordova: ' + e);
- });
- });
-};
-
-Device.prototype.getInfo = function (successCallback, errorCallback) {
-
- // Get info
- exec(successCallback, errorCallback, 'Device', 'getDeviceInfo', []);
-};
-
-module.exports = new Device();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/lib/js/plugin/win7/jsHandler.js
----------------------------------------------------------------------
diff --git a/windows7/Cordova/lib/js/plugin/win7/jsHandler.js b/windows7/Cordova/lib/js/plugin/win7/jsHandler.js
deleted file mode 100644
index de18217..0000000
--- a/windows7/Cordova/lib/js/plugin/win7/jsHandler.js
+++ /dev/null
@@ -1,19 +0,0 @@
-var cordova = require('cordova');
-
-module.exports = {
- exec: function (successCallback, errorCallback, clazz, action, args) {
- try {
- var plugin = require('cordova/plugin/win7/' + clazz);
-
- if (plugin && typeof plugin[action] === 'function') {
- var result = plugin[action](successCallback, errorCallback, args);
- return result || { status: cordova.callbackStatus.NO_RESULT };
- }
- // action not found
- return { "status": cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION, "message": "Function " + clazz + "::" + action + " cannot be found" };
- } catch (e) {
- // clazz not found
- return { "status": cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION, "message": "Function " + clazz + "::" + action + " cannot be found" };
- }
- }
-};
\ No newline at end of file
[07/10] Removed Windows7 which is now in it's own branch. This closes
#29
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/lib/js/plugin/win7/storage.js
----------------------------------------------------------------------
diff --git a/windows7/Cordova/lib/js/plugin/win7/storage.js b/windows7/Cordova/lib/js/plugin/win7/storage.js
deleted file mode 100644
index 78a49c3..0000000
--- a/windows7/Cordova/lib/js/plugin/win7/storage.js
+++ /dev/null
@@ -1,300 +0,0 @@
-var channel = require("cordova/channel"),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-var queryQueue = {};
-
-var Rows = function () {
- this.resultSet = []; // results array
- this.length = 0; // number of rows
-};
-
-Rows.prototype.item = function (row) {
- return this.resultSet[row];
-};
-
-var Result = function () {
- this.rows = new Rows();
-};
-
-function completeQuery(result) {
- var id = result.id;
- var data = result.data;
- var query = queryQueue[id];
- if (query) {
- try {
- delete queryQueue[id];
-
- // Get transaction
- var tx = query.tx;
-
- // If transaction hasn't failed
- // Note: We ignore all query results if previous query
- // in the same transaction failed.
- if (tx && tx.queryList[id]) {
-
- // Save query results
- var r = new Result();
- r.rows.resultSet = data;
- r.rows.length = data.length;
- try {
- if (typeof query.successCallback === 'function') {
- query.successCallback(query.tx, r);
- }
- } catch (ex) {
- console.log("executeSql error calling user success callback: " + ex);
- }
-
- tx.queryComplete(id);
- }
- } catch (e) {
- console.log("executeSql error: " + e);
- }
- }
-}
-
-function failQuery(result) {
- var id = result.id;
- var reason = result.reason;
- var query = queryQueue[id];
- if (query) {
- try {
- delete queryQueue[id];
-
- // Get transaction
- var tx = query.tx;
-
- // If transaction hasn't failed
- // Note: We ignore all query results if previous query
- // in the same transaction failed.
- if (tx && tx.queryList[id]) {
- tx.queryList = {};
-
- try {
- if (typeof query.errorCallback === 'function') {
- query.errorCallback(query.tx, reason);
- }
- } catch (ex) {
- console.log("executeSql error calling user error callback: " + ex);
- }
-
- tx.queryFailed(id, reason);
- }
-
- } catch (e) {
- console.log("executeSql error: " + e);
- }
- }
-}
-
-var Query = function (tx) {
-
- // Set the id of the query
- this.id = utils.createUUID();
-
- // Add this query to the queue
- queryQueue[this.id] = this;
-
- // Init result
- this.resultSet = [];
-
- // Set transaction that this query belongs to
- this.tx = tx;
-
- // Add this query to transaction list
- this.tx.queryList[this.id] = this;
-
- // Callbacks
- this.successCallback = null;
- this.errorCallback = null;
-
-};
-
-var Transaction = function (database) {
- this.db = database;
- // Set the id of the transaction
- this.id = utils.createUUID();
-
- // Callbacks
- this.successCallback = null;
- this.errorCallback = null;
-
- // Query list
- this.queryList = {};
-};
-
-Transaction.prototype.queryComplete = function (id) {
- delete this.queryList[id];
-
- // If no more outstanding queries, then fire transaction success
- if (this.successCallback) {
- var count = 0;
- var i;
- for (i in this.queryList) {
- if (this.queryList.hasOwnProperty(i)) {
- count++;
- }
- }
- if (count === 0) {
- try {
- this.successCallback();
- } catch (e) {
- console.log("Transaction error calling user success callback: " + e);
- }
- }
- }
-};
-
-Transaction.prototype.queryFailed = function (id, reason) {
-
- // The sql queries in this transaction have already been run, since
- // we really don't have a real transaction implemented in native code.
- // However, the user callbacks for the remaining sql queries in transaction
- // will not be called.
- this.queryList = {};
-
- if (this.errorCallback) {
- try {
- this.errorCallback(reason);
- } catch (e) {
- console.log("Transaction error calling user error callback: " + e);
- }
- }
-};
-
-Transaction.prototype.executeSql = function (sql, params, successCallback, errorCallback) {
- // Init params array
- if (typeof params === 'undefined') {
- params = [];
- }
-
- // Create query and add to queue
- var query = new Query(this);
- queryQueue[query.id] = query;
-
- // Save callbacks
- query.successCallback = successCallback;
- query.errorCallback = errorCallback;
-
- // Call native code
- exec(completeQuery, failQuery, "Storage", "executeSql", [this.db.id, sql, params, query.id]);
-};
-
-var Database = function (dbId) {
- this.id = dbId;
-};
-
-Database.prototype.transaction = function (process, errorCallback, successCallback) {
- var tx = new Transaction(this);
- tx.successCallback = successCallback;
- tx.errorCallback = errorCallback;
-
- try {
- process(tx);
- } catch (e) {
- console.log("Transaction error: " + e);
- if (tx.errorCallback) {
- try {
- tx.errorCallback(e);
- } catch (ex) {
- console.log("Transaction error calling user error callback: " + e);
- }
- }
- }
-};
-
-var WinStorage = function (dbName) {
- channel.waitForInitialization("winStorage" + dbName);
-
- try {
-
- this.db = openDatabase(dbName, '1.0', dbName, 2621440);
- var storage = {};
- this.length = 0;
- function setLength(length) {
- this.length = length;
- }
- this.db.transaction(
- function (transaction) {
- var i;
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
- transaction.executeSql('SELECT * FROM storage', [], function (tx, result) {
- for (var i = 0; i < result.rows.length; i++) {
- storage[result.rows.item(i).id] = result.rows.item(i).body;
- }
- setLength(result.rows.length);
- channel.initializationComplete("winStorage" + dbName);
- });
-
- },
- function (err) {
- utils.alert(err.message);
- }
- );
- this.setItem = function (key, val) {
- if (typeof (storage[key]) == 'undefined') {
- this.length++;
- }
- storage[key] = val;
- this.db.transaction(
- function (transaction) {
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
- transaction.executeSql('REPLACE INTO storage (id, body) values(?,?)', [key, val]);
- }
- );
- };
- this.getItem = function (key) {
- return (typeof (storage[key]) == 'undefined') ? null : storage[key];
- };
- this.removeItem = function (key) {
- delete storage[key];
- this.length--;
- this.db.transaction(
- function (transaction) {
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
- transaction.executeSql('DELETE FROM storage where id=?', [key]);
- }
- );
- };
- this.clear = function () {
- storage = {};
- this.length = 0;
- this.db.transaction(
- function (transaction) {
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
- transaction.executeSql('DELETE FROM storage', []);
- }
- );
- };
- this.key = function (index) {
- var i = 0;
- for (var j in storage) {
- if (i == index) {
- return j;
- } else {
- i++;
- }
- }
- return null;
- };
-
- } catch (e) {
- utils.alert("Database error " + e + ".");
- return;
- }
-};
-
-function openDatabase(name, version, display_name, size) {
- var dbId = exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
- return new Database(dbId);
-}
-
-function removeDatabase(name) {
- exec(null, null, "Storage", "removeDatabase", [name]);
-}
-
-module.exports = {
- openDatabase: openDatabase,
- removeDatabase: removeDatabase,
- WinStorage: WinStorage
-};
\ No newline at end of file
[03/10] Removed Windows7 which is now in it's own branch. This closes
#29
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/accel_game.html
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/accel_game.html b/windows7/Cordova/www/accel_game.html
deleted file mode 100644
index e11fa7b..0000000
--- a/windows7/Cordova/www/accel_game.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE HTML>
-<html>
- <head>
- <title>Accelerometer Game</title>
- <script type='text/javascript' charset='utf-8' src='cordova.win7.js'></script>
- <script src='accel_game.js'></script>
- <link rel='stylesheet' href='accel_game.css' />
- </head>
- <body>
- <h1>Accelerometer Game</h1>
-
- <div id='box'>
- <canvas id='game_area' width='500' height='500'>
- HTML Canvas unsupported!
- </canvas>
- </div>
-
- <div id='valueX'></div>
- <div id='valueY'></div>
- <div id='valueZ'></div>
-
- <div id='valueL'></div>
- <div id='valueR'></div>
- <div id='valueU'></div>
- <div id='valueD'></div>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/accel_game.js
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/accel_game.js b/windows7/Cordova/www/accel_game.js
deleted file mode 100644
index 633d4cb..0000000
--- a/windows7/Cordova/www/accel_game.js
+++ /dev/null
@@ -1,165 +0,0 @@
-document.addEventListener('deviceready', onDeviceReady, false);
-
-// Values read from the accelerometer
-var valueX;
-var valueY;
-var valueZ;
-
-// Game variables
-var x_speed=0;
-var y_speed=0;
-var y=250;
-var x=250;
-var left=false;
-var right=false;
-var up=false;
-var down=false;
-var friction = 0.95;
-var context;
-
-// Bind vars & start acquisition
-
-function onDeviceReady() {
-
- valueX = document.getElementById('valueX');
- valueY = document.getElementById('valueY');
- valueZ = document.getElementById('valueZ');
-
- left = document.getElementById('valueL');
- right = document.getElementById('valueR');
- up = document.getElementById('valueU');
- down = document.getElementById('valueD');
-
- startWatch();
-}
-
-function startWatch() {
-
- var options = { frequency: 50 };
-
- // Start machinery
- navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
-}
-
-
-// Got sample
-
-function onSuccess(acceleration) {
-
- valueX.innerHTML = 'X: ' + acceleration.x;
- valueY.innerHTML = 'Y: ' + acceleration.y;
- valueZ.innerHTML = 'Z: ' + acceleration.z;
-
- if (acceleration.x < -0.2) {
- right = false;
- left = true;
- }
-
- else if (acceleration.x > 0.2) {
- right = true;
- left = false;
- }
-
- else if (acceleration.x < 0.2 && acceleration.x > -0.2) {
- left = true;
- right = true;
- }
-
- if (acceleration.y < -0.2) {
- up = false;
- down = true;
- }
-
- else if (acceleration.y > 0.2) {
- up = true;
- down = false;
- }
-
- else if(acceleration.y < 0.2 && acceleration.y > -0.2) {
- up = true;
- down = true;
- }
-
- valueR.innerHTML = 'Right :' + right;
- valueL.innerHTML = 'Left :' + left;
- valueU.innerHTML = 'Up :' + up;
- valueD.innerHTML = 'Down :' + down;
-}
-
-// Trouble acquiring samples
-function onError() {
- alert('Error!');
-}
-
-function on_enter_frame() {
-
- if (left) {
- x_speed--;
- }
-
- if (right) {
- x_speed++;
- }
-
- if (up) {
- y_speed--;
- }
-
- if (down) {
- y_speed++;
- }
-
- context.clearRect(0, 0, 500, 500); // Redraw
- context.beginPath();
- context.fillStyle = '#000000';
- context.arc(x, y, 30, 0, Math.PI * 2, true);
- context.closePath();
- context.fill();
-
- x += (x_speed / 3); // Compute new X for ball
-
- // X clipping
- if (x > (game_area.width - 30)) {
- x = game_area.width - 30;
- }
-
- if (x < 30) {
- x = 30;
- }
-
- y += (y_speed / 3); // Compute new Y for ball
-
- // Y clipping
- if (y > (game_area.height - 30)) {
- y = game_area.height - 30;
- }
-
- if (y < 30) {
- y = 30;
- }
-
- // Reduce speed as a way to simulate friction
- x_speed *= friction;
- y_speed *= friction;
-}
-
-
-window.onload = function()
-{
- var game_area = document.getElementById('game_area'); // Get access to the canvas
-
- if (!game_area) {
- alert("Can't connect to canvas!");
- return;
- }
-
- context = game_area.getContext('2d'); // Get canvas context
-
- if (!context) {
- alert("Can't get canvas context!");
- return;
- }
-
- setInterval(on_enter_frame, 20); // Frame interval
-}
-
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/capture.html
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/capture.html b/windows7/Cordova/www/capture.html
deleted file mode 100644
index fe11f49..0000000
--- a/windows7/Cordova/www/capture.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Video & Photo Recording Test</title>
-
- <script type='text/javascript' charset='utf-8' src='cordova.win7.js'></script>
-
- <script language='javascript'>
- function got_video(media_array) {
- var video = document.getElementById('video');
- video.src = media_array[0].fullPath;
- }
- function got_photo(media_array) {
- var photo = document.getElementById('photo');
- photo.src = media_array[0].fullPath;
- }
- function get_video() {
- navigator.device.capture.captureVideo(got_video);
- }
- function get_photo() {
- navigator.device.capture.captureImage(got_photo);
- }
- </script>
- </head>
- <body>
- <input type='button' onclick='get_video()' value='Get Video'/>
- <video width=640 controls='controls' id='video'>
- <source src='' type='video/mp4'/>
- </video>
- <br>
- <input type='button' onclick='get_photo()' value='Get Photo'/>
- <img src='' id='photo' width=640/>
- </body>
-</html>
[04/10] Removed Windows7 which is now in it's own branch. This closes
#29
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/mp4patch.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/mp4patch.c b/windows7/Cordova/mp4patch.c
deleted file mode 100644
index b377cc0..0000000
--- a/windows7/Cordova/mp4patch.c
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-// For some reason, the mp4 files we generate using MF topologies show incorrect durations if several tracks are used
-
-// Pending a root cause explanation for this, work around the problem by overwriting the values in the duration field
-// in the movie header
-
-// The mp4 files are structured as a collection of 'atoms' starting with two fields:
-
-// size (4 bytes)
-// type (4 bytes)
-
-// Among the top level atoms, we're interested in the the movie (moov) atom, which should contain other atoms,
-// including the movie header
-
-// movie duration should be the duration of the longest track
-// time scale is the number of time units per second
-// time in seconds since midnight, January 1, 1904, UTC
-
-// All integer values are stored in big endian form (most significant byte first)
-
-// Each track (track) contains an header (tkhd)
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-// Couple of big-endian read/write macros
-#define READ_BE4(addr) (*(addr) << 24) | (*(addr+1) << 16) | (*(addr+2) << 8) | *(addr+3)
-#define WRITE_BE4(addr, val) *(addr) = val >> 24; *(addr+1) = (BYTE) (val >> 16); *(addr+2) = (BYTE) (val >> 8); *(addr+3) = (BYTE) val
-
-// The implementation is limited to 32 bits mp4 files for now as Media Foundation does not generate larger files
-
-void locate_moov(BYTE* start, DWORD size, BYTE** moov_start, DWORD* moov_size)
-{
- // Check top level atoms
-
- DWORD cursor = 0;
- DWORD atom_size;
- DWORD atom_type;
-
- while (cursor + 8 < size)
- {
- atom_size = READ_BE4(start + cursor);
- atom_type = READ_BE4(start + 4 + cursor);
-
- if (atom_type == 'moov')
- {
- *moov_start = start + cursor;
- *moov_size = atom_size;
- return;
- }
-
- if (atom_size < 8)
- return;
-
- cursor += atom_size;
- }
-}
-
-void locate_mvhd(BYTE* start, DWORD size, BYTE** mvhd_start, DWORD* mvhd_size)
-{
- // Check atoms within moov, looking for mvhd
-
- DWORD cursor = 0;
- DWORD atom_size;
- DWORD atom_type;
-
- while (cursor + 8 < size)
- {
- atom_size = READ_BE4(start + cursor);
- atom_type = READ_BE4(start + 4 + cursor);
-
- if (atom_type == 'mvhd')
- {
- *mvhd_start = start + cursor;
- *mvhd_size = atom_size;
- return;
- }
-
- if (atom_size < 8)
- return;
-
- cursor += atom_size;
- }
-}
-
-
-void fix_mp4_duration (wchar_t* file_name, LONGLONG duration)
-{
- HANDLE file_handle;
- HANDLE mapping_handle;
-
- DWORD file_size;
- BYTE* mapping_addr;
- BYTE* moov_addr = 0;
- BYTE* mvhd_addr = 0;
- DWORD moov_size;
- DWORD mvhd_size;
- DWORD time_scale;
- DWORD fixed_duration;
- DWORD time_ratio;
-
- // Open file for read & write
- file_handle = CreateFile(file_name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
-
- if (file_handle == INVALID_HANDLE_VALUE)
- return;
-
- file_size = GetFileSize(file_handle, 0);
-
- // Create mapping
- mapping_handle = CreateFileMapping(file_handle, 0, PAGE_READWRITE, 0, 0, 0);
-
- if (mapping_handle == NULL)
- goto close_file;
-
- // Create view
- mapping_addr = (BYTE*) MapViewOfFile(mapping_handle, FILE_MAP_WRITE, 0, 0, file_size);
-
- // Locate top level movie atom
- locate_moov(mapping_addr, file_size, &moov_addr, &moov_size);
-
- if (moov_addr)
- {
- // Inside it, locate movie header
- locate_mvhd(moov_addr + 8, moov_size, &mvhd_addr, &mvhd_size);
-
- if (mvhd_addr)
- {
- // The movie header (mvhd) atom has the following fields:
- // version (1 byte)
- // flags (3 bytes)
- // creation time, modification time, time scale, duration (4 bytes each)
-
- time_scale = READ_BE4(mvhd_addr + 4 + 4 + 1 + 3 + 4 + 4);
-
- if (time_scale)
- {
- time_ratio = (DWORD) (10000000L / time_scale); // Duration is passed as a number of 100 ns units - there are 10 million ticks per sec
- fixed_duration = (DWORD) (duration/time_ratio);
-
- WRITE_BE4(mvhd_addr + 4 + 4 + 1 + 3 + 4 + 4 + 4, fixed_duration);
- }
- }
- }
-
- if (mapping_addr)
- UnmapViewOfFile(mapping_addr);
-
- CloseHandle(mapping_handle);
-
-close_file:
-
- CloseHandle(file_handle);
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/mp4patch.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/mp4patch.h b/windows7/Cordova/mp4patch.h
deleted file mode 100644
index 377f0de..0000000
--- a/windows7/Cordova/mp4patch.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-void fix_mp4_duration (wchar_t* file_name, LONGLONG duration);
-
-
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/network.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/network.c b/windows7/Cordova/network.c
deleted file mode 100644
index 17951ea..0000000
--- a/windows7/Cordova/network.c
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#define _WIN32_WINNT 0x0600 // Get access to GetIfEntry2 (Vista and newer), so we can distinguish hardware network interfaces from software ones
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include <ws2def.h>
-#include <ws2ipdef.h>
-#include <iphlpapi.h>
-
-#pragma comment(lib, "IPHLPAPI.lib")
-
-#include "network.h"
-
-//-------------------------------------------------------------------------------------------------
-
-// Determine type of the first network interface that's up
-static HRESULT get_network_interface_type (BSTR callback_id)
-{
- int if_type = 0;
- MIB_IF_TABLE2 *if_table = 0;
- unsigned int i;
- wchar_t *type_as_text;
-
- // Retrieve list of network interfaces ; return -1 in case of error
- if (GetIfTable2(&if_table))
- goto outahere;
-
- // Look for an active ethernet interface
- for (i = 0; i < if_table->NumEntries; i++)
- if (if_table->Table[i].InterfaceAndOperStatusFlags.HardwareInterface && if_table->Table[i].OperStatus == IfOperStatusUp && if_table->Table[i].Type == IF_TYPE_ETHERNET_CSMACD)
- {
- if_type = IF_TYPE_ETHERNET_CSMACD;
- goto outahere;
- }
-
- // Look for wifi
- for (i = 0; i < if_table->NumEntries; i++)
- if (if_table->Table[i].InterfaceAndOperStatusFlags.HardwareInterface && if_table->Table[i].OperStatus == IfOperStatusUp && if_table->Table[i].Type == IF_TYPE_IEEE80211)
- {
- if_type = IF_TYPE_IEEE80211;
- goto outahere;
- }
-
- // Look for anything marked as physical and up
- for (i = 0; i < if_table->NumEntries; i++)
- if (if_table->Table[i].InterfaceAndOperStatusFlags.HardwareInterface && if_table->Table[i].OperStatus == IfOperStatusUp)
- {
- if_type = if_table->Table[i].Type;
- break;
- }
-
-outahere:
- // The returned value is 0 if there aren't any active interface, or one of the IF_TYPE_* codes from ipifcons.h
- if (if_table)
- FreeMibTable(if_table);
-
- switch (if_type)
- {
- case 0:
- type_as_text = L"'none'";
- break;
-
- case IF_TYPE_ETHERNET_CSMACD:
- type_as_text = L"'ethernet'";
- break;
-
- case IF_TYPE_IEEE80211:
- type_as_text = L"'wifi'";
- break;
-
- default:
- type_as_text = L"'unknown'";
- break;
- }
-
- cordova_success_callback(callback_id, FALSE, type_as_text);
-
- return S_OK;
-}
-
-HRESULT network_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- if (!wcscmp(action, L"getConnectionInfo"))
- return get_network_interface_type(callback_id);
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-DEFINE_CORDOVA_MODULE(Network, L"NetworkStatus", network_exec, NULL, NULL)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/network.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/network.h b/windows7/Cordova/network.h
deleted file mode 100644
index 8eda9c1..0000000
--- a/windows7/Cordova/network.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "shell.h"
-
-DECLARE_CORDOVA_MODULE(Network)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/notification.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/notification.c b/windows7/Cordova/notification.c
deleted file mode 100644
index a185b11..0000000
--- a/windows7/Cordova/notification.c
+++ /dev/null
@@ -1,324 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <stdlib.h>
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <wchar.h>
-
-#include "notification.h"
-#include "json.h"
-
-extern HWND hWnd;
-
-#define FONT_SIZE 10
-#define FONT_NAME L"Arial"
-#define MAX_BUTTONS 10
-#define ID_BASE 100
-
-LRESULT CALLBACK NotificationDialogProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- int btn_id;
- HWND hParent;
- RECT parent_rect;
- RECT dialog_rect;
- RECT rc;
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
-
- // Center the dialog within parent window
- hParent = GetParent(hDlg);
-
- GetWindowRect(hParent, &parent_rect);
- GetWindowRect(hDlg, &dialog_rect);
- rc = parent_rect;
-
- OffsetRect(&dialog_rect, -dialog_rect.left, -dialog_rect.top);
- OffsetRect(&rc, -rc.left, -rc.top);
- OffsetRect(&rc, -dialog_rect.right, -dialog_rect.bottom);
-
- SetWindowPos(hDlg, HWND_TOP, parent_rect.left + rc.right*1/2, parent_rect.top + rc.bottom*1/2, 0, 0, SWP_NOSIZE);
- return TRUE;
-
- case WM_COMMAND:
- if (wParam == IDCANCEL)
- {
- EndDialog(hDlg, -1);
- return FALSE;
- }
- else
- {
- btn_id = (SHORT) (LOWORD(wParam));
- EndDialog(hDlg, btn_id - ID_BASE); // Use large button IDs to avoid collisions with IDOK, IDCANCEL and friends
- return TRUE;
- }
-
- default:
- return FALSE;
- }
-}
-
-
-// Align an USHORT pointer to a 4 bytes aligned boundary, padding with zero if necessary
-#define ALIGN4(cursor) if (((BYTE) cursor) & 2) *cursor++ = 0;
-
-// See http://msdn.microsoft.com/en-us/library/ms645394%28v=vs.85%29.aspx
-
-
-LRESULT DisplayMessage(wchar_t* title, int title_len, wchar_t* message, int message_len, wchar_t* button_label[], int button_len[], int num_buttons)
-{
- DLGTEMPLATE* dlg_template;
- DLGITEMTEMPLATE* item_template;
- WORD* cursor; // 16 bits words pointer
- LRESULT ret_code;
- void* buf;
- int i;
- int next_x;
- int button_width = 80; // Width of a button
- int button_gap = 6; // Width of the space separating two buttons
- int left_margin = 10; // Left dialog margin
- int right_margin = 10; // Right dialog margin
- int top_margin = 10;
- int bottom_margin = 10;
- int static_height = 40; // Height of the space where static text is displayed
- int static_to_buttons_margin = num_buttons > 0 ? 5 : 0;
- int button_height = num_buttons > 0 ? 15 : 0;
- int num_gaps = num_buttons ? num_buttons -1 : 0;
- int static_width = num_buttons ? num_buttons * button_width + button_gap * num_gaps : 80;
- int buf_len;
- int font_len = wcslen(FONT_NAME);
-
- // Compute length of work buffer and allocate it
- buf_len = sizeof(DLGTEMPLATE) + 4 + title_len + 1 + font_len + 1 + message_len + 1 + sizeof(DLGITEMTEMPLATE) + 4 + 2 + num_buttons * sizeof(DLGITEMTEMPLATE) +
- + 100; // Allow for into account possible alignment padding as well as extra fields (class atoms, user data)
-
- for (i=0; i<num_buttons; i++)
- buf_len += button_len[i] + 1;
-
- buf = malloc(buf_len);
-
- dlg_template = (DLGTEMPLATE*) buf;
-
- // Dialog header
-
- dlg_template->style = WS_POPUP | WS_BORDER | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION | DS_SETFONT;
- dlg_template->dwExtendedStyle = 0;
- dlg_template->cdit = 1 + num_buttons; // Number of controls
- dlg_template->x = 0; // In Dialog Box Units
- dlg_template->y = 0;
- dlg_template->cx = left_margin + static_width + right_margin;
- dlg_template->cy = top_margin + static_height + static_to_buttons_margin + button_height + bottom_margin;
-
- cursor = (WORD*)(dlg_template + 1); // Point past DLGTEMPLATE structure
- *cursor++ = 0; // Menu
- *cursor++ = 0; // Default Dialog class
-
- // Copy title, add NUL and shift cursor
- wmemcpy(cursor, title, title_len);
- cursor += title_len;
- *cursor++ = 0;
-
- // Type point and font name (as DS_FONT was specified)
- *cursor++ = FONT_SIZE;
- wmemcpy(cursor, FONT_NAME, font_len);
- cursor += font_len;
- *cursor++ = 0;
-
- // Item templates need to be DWORD aligned
- ALIGN4(cursor);
-
- // Static control
-
- item_template = (DLGITEMTEMPLATE*) cursor;
- item_template->style = WS_CHILD | WS_VISIBLE | SS_CENTER;
- item_template->dwExtendedStyle = 0;
- item_template->x = left_margin;
- item_template->y = top_margin;
- item_template->cx = static_width;
- item_template->cy = static_height;
- item_template->id = -1;
-
- // Move past DLGITEMTEMPLATE structure
- cursor = (WORD*)(item_template + 1);
-
- // Static class
- *cursor++ = 0xFFFF;
- *cursor++ = 0x0082;
-
- // Title
- wmemcpy(cursor, message, message_len);
- cursor += message_len;
- *cursor++ = 0;
-
- // Empty user data block
- *cursor++ = 0;
-
- next_x = left_margin;
-
- // Additional controls
- for (i=0; i<num_buttons; i++)
- {
- ALIGN4(cursor);
-
- item_template = (DLGITEMTEMPLATE*) cursor;
- item_template->style = WS_CHILD | WS_VISIBLE;
- item_template->dwExtendedStyle = 0;
- item_template->x = next_x;
- item_template->y = top_margin + static_height + static_to_buttons_margin;
- item_template->cx = button_width;
- item_template->cy = button_height;
- item_template->id = ID_BASE + i;
-
- next_x += button_width + button_gap;
-
- // Move past DLGITEMTEMPLATE structure
- cursor = (WORD*)(item_template + 1);
-
- // Button class
- *cursor++ = 0xFFFF;
- *cursor++ = 0x0080;
-
- // Title
- wmemcpy(cursor, button_label[i], button_len[i]);
- cursor += button_len[i];
- *cursor++ = 0;
-
- // Empty user data block
- *cursor++ = 0;
- }
-
- ret_code = DialogBoxIndirect(GetModuleHandle(0), dlg_template, hWnd, NotificationDialogProc);
- free(buf);
- return ret_code;
-}
-
-static HRESULT show_dialog(BSTR callback_id, BSTR args)
-{
- wchar_t buf[10];
- int ret_code;
- wchar_t* message = 0;
- wchar_t* buttons = 0;
- wchar_t* title = 0;
- int num_buttons = 0;
- wchar_t* btn_text[MAX_BUTTONS];
- int btn_text_len[MAX_BUTTONS];
- unsigned int cursor = 0;
-
- JsonArray array;
- JsonItem item;
-
- // args should be like "["message","title","button1,button2"]"
-
- // Validate array contents
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_STRING,
- JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- json_free_args(array);
- return -1;
- }
-
- // message
- item = json_array_get_first(array);
- message = json_get_string_value(item);
-
- // title
- item = json_array_get_next(item);
- title = json_get_string_value(item);
-
- // buttons
- item = json_array_get_next(item);
- buttons = json_get_string_value(item);
- if (*buttons == 0)
- goto button_done; // No button ; consider that a valid use case
-
-button_parsing:
-
- btn_text[num_buttons] = buttons + cursor;
- btn_text_len[num_buttons] = 0;
-
- // Search for separator
- while (cursor < wcslen(buttons) && *(buttons + cursor) != L',') {
- cursor++;
- btn_text_len[num_buttons]++;
- }
-
- num_buttons++;
-
- cursor++;
-
- if (cursor < wcslen(buttons) && num_buttons < MAX_BUTTONS)
- goto button_parsing;
-
-button_done:
-
- json_free_args(array);
-
- ret_code = DisplayMessage(title, wcslen(title), message, wcslen(message), btn_text, btn_text_len, num_buttons);
-
- if (message)
- free(message);
- if (title)
- free(title);
- if (buttons)
- free(buttons);
-
- wsprintf(buf, L"%d", ret_code);
-
- cordova_success_callback(callback_id, FALSE, buf);
-
- return S_OK;
-}
-
-static HRESULT vibrate(BSTR callback_id, BSTR args)
-{
- return S_OK;
-}
-
-static HRESULT beep(BSTR callback_id, BSTR args)
-{
- int count;
-
- args++; // skip initial '['
- *(args + wcslen(args) - 1) = 0; // remove trailing ']'
-
- for (count = _wtoi(args); count > 0; count--) {
- MessageBeep(0xFFFFFFFF);
- Sleep(100);
- }
-
- return S_OK;
-}
-
-HRESULT notification_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- if(!wcscmp(action, L"alert") || !wcscmp(action, L"confirm"))
- return show_dialog(callback_id, args);
- if (!wcscmp(action, L"vibrate"))
- return vibrate(callback_id, args);
- if (!wcscmp(action, L"beep"))
- return beep(callback_id, args);
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-DEFINE_CORDOVA_MODULE(Notification, L"Notification", notification_exec, NULL, NULL)
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/notification.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/notification.h b/windows7/Cordova/notification.h
deleted file mode 100644
index 8c43551..0000000
--- a/windows7/Cordova/notification.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "shell.h"
-
-DECLARE_CORDOVA_MODULE(Notification)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/platform.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/platform.c b/windows7/Cordova/platform.c
deleted file mode 100644
index 3b4f14a..0000000
--- a/windows7/Cordova/platform.c
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include "platform.h"
-
-static BOOL event_on = TRUE;
-
-BOOL is_back_button_event_enabled(void)
-{
- return event_on;
-}
-
-static HRESULT platform_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- if (!wcscmp(action, L"backButtonEventOn"))
- {
- event_on = TRUE;
- return S_OK;
- }
-
- if (!wcscmp(action, L"backButtonEventOff"))
- {
- event_on = FALSE;
- return S_OK;
- }
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-DEFINE_CORDOVA_MODULE(Platform, L"Platform", platform_exec, NULL, NULL)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/platform.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/platform.h b/windows7/Cordova/platform.h
deleted file mode 100644
index 398a58d..0000000
--- a/windows7/Cordova/platform.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "shell.h"
-
-BOOL is_back_button_event_enabled (void);
-
-DECLARE_CORDOVA_MODULE(Platform)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/resource.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/resource.h b/windows7/Cordova/resource.h
deleted file mode 100644
index 143eeef..0000000
--- a/windows7/Cordova/resource.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#define IDB_ToolBar 100
-#define IDD_CaptureSettings 101
-
-// Lists in capture settings dialog
-#define IDC_Camera 102
-#define IDC_Microphone 103
-#define IDC_Resolution 104
-#define IDC_VideoEncoder 105
-
-#define IDC_STATIC -1
-
-// Toolbar buttons
-#define ID_START_VIDEO 1
-#define ID_STOP_VIDEO 2
-#define ID_TAKE_PHOTO 3
-#define ID_PARAMETERS 4
-#define ID_RETURN 5
-
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/resource.rc
----------------------------------------------------------------------
diff --git a/windows7/Cordova/resource.rc b/windows7/Cordova/resource.rc
deleted file mode 100644
index 584fc9a..0000000
--- a/windows7/Cordova/resource.rc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "resource.h"
-#include "winuser.rh"
-
-IDD_CaptureSettings DIALOGEX 0, 0, 350, 130
-
-CAPTION "Capture Settings"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- DEFPUSHBUTTON "OK",IDOK,236,109,50,14
- PUSHBUTTON "Cancel",IDCANCEL,290,109,50,14
- COMBOBOX IDC_Camera,85,11,250,300,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- COMBOBOX IDC_Microphone,85,35,250,300,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- COMBOBOX IDC_Resolution,85,59,250,300,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- COMBOBOX IDC_VideoEncoder,85,83,250,300,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "Camera:",IDC_STATIC,15,14,60,8
- LTEXT "Microphone:",IDC_STATIC,15,37,60,8
- LTEXT "Resolution:",IDC_STATIC,15,61,60,8
- LTEXT "Video Encoder:",IDC_STATIC,15,85,60,8
-END
-
-IDB_ToolBar BITMAP "toolbar.bmp"
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/shell.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/shell.c b/windows7/Cordova/shell.c
deleted file mode 100644
index 6235476..0000000
--- a/windows7/Cordova/shell.c
+++ /dev/null
@@ -1,1471 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <windows.h>
-#include <wchar.h> // Unicode only for us
-
-#define CINTERFACE 1 // Get C definitions for COM header files
-#include <oleidl.h> // IOleClientSite, IOleInPlaceFrame, IOleInPlaceSite
-#include <exdisp.h> // IWebBrowser2
-#include <mshtml.h> // IHTMLDocument2
-#include <mshtmhst.h> // IDocHostUIHandler
-#include <exdispid.h> // DISPID_TITLECHANGE
-
-#include <ipifcons.h> // Network types
-
-#include <commctrl.h> // Let's initialize the common controls library
-#pragma comment(lib, "comctl32.lib") // so they can be used with the process
-
-#include "shell.h"
-#include "common.h"
-#include "device.h"
-#include "accel.h"
-#include "capture.h"
-#include "network.h"
-#include "notification.h"
-#include "storage.h"
-#include "platform.h"
-#include "file.h"
-#include "filetransfer.h"
-#include "compass.h"
-
-//-------------------------------------------------------------------------------------------------
-
-#define NOT_IMPLEMENTED __debugbreak(); OutputDebugStringA(__FUNCTION__); return 0;
-
-IWebBrowser2* browser_web_if; // IWebBrowser2 interface to the browser control
-IOleObject* browser_ole_if; // IOleObject interface to the browser control, required to pass various OLE related parameters
-IOleInPlaceObject* browser_ipo_if; // IOleInPlaceObject interface to the browser control, required to implement IOleInPlaceSite:OnPosRectChange
-
-IOleClientSite* browser_cs;
-IOleInPlaceSite* browser_ips;
-IOleInPlaceFrame* browser_ipf;
-IDispatch* browser_dsp; // Browser event dispatcher
-IDocHostUIHandler* browser_dui;
-IDispatch* browser_ext;
-IOleCommandTarget* browser_oct;
-
-DWORD browser_dsp_cookie; // Dispatcher connection id, as returned by the connection point Advise call
-
-IDispatch* document_dispatch_if; // Needed to get document interface
-IHTMLDocument2* document_html2_if; // Needed to get window interface
-IHTMLWindow2* html_window2_if; // Needed to run scripts
-
-static struct IOleClientSite clsi;
-static struct IOleInPlaceSite inplsi;
-static struct IOleInPlaceFrame inplfr;
-static struct IDispatch disp;
-static struct IDocHostUIHandler duih;
-static struct IDispatch ext;
-static struct IOleCommandTarget oct;
-
-int clsi_ref_count;
-int inplsi_ref_count;
-int inplfr_ref_count;
-int disp_ref_count;
-int inplfr_ref_count;
-int duih_ref_count;
-int ext_ref_count;
-int oct_ref_count;
-
-const wchar_t gate_name[]= L"CordovaExec";
-#define DISPID_GATE 8086
-
-#define APP_NAME L"Cordova Application"
-#define BASE_URL L"www\\index.html"
-
-#define IE_GPU_REG_KEY L"Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_GPU_RENDERING" // Registry key enabling GPU acceleration
-#define IE_COMPAT_REG_KEY L"Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION" // Registry key controlling browser version emulation
-
-wchar_t full_path[_MAX_PATH]; // We record our initial current directory name in there
-
-HWND hWnd; // Our main window handle
-extern HWND hCaptureWnd; // Child window handle, when capturing video
-
-BSTR javascript; // Small utility object, used whenever invoking a js method
-
-void invoke_js_routine (wchar_t* wcs);
-
-#define STATE_STARTING 0 // Machinery starting
-#define STATE_NATIVE_READY 1 // Native Ready event sent
-#define STATE_PAUSED 2 // Paused
-#define STATE_ENDING 3 // Machinery shutting down
-
-int current_state; // Rough operating state : not ready / ready / temporarily paused
-
-int skip_title_update = 1; // Title update skip counter, used to avoid initial "index.html"
-
-// Browser window subclassing
-static WNDPROC initial_browser_wnd_proc;
-LRESULT CALLBACK BrowserWndProcWrapper(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
-//-------------------------------------------------------------------------------------------------
-
-static CordovaModule *module_list = NULL;
-
-static void register_cordova_module(CordovaModule *module)
-{
- CordovaModule *item = module_list;
-
- if (module->init != NULL)
- module->init();
-
- if (!item) {
- module_list = module;
- return;
- }
-
- module->next = module_list;
- module_list = module;
-}
-
-
-static void close_cordova_module(CordovaModule *module)
-{
- if (module->close != NULL)
- module->close();
-}
-
-static void register_cordova_modules()
-{
- register_cordova_module(CORDOVA_MODULE(Device));
- register_cordova_module(CORDOVA_MODULE(Camera));
- register_cordova_module(CORDOVA_MODULE(Capture));
- register_cordova_module(CORDOVA_MODULE(Accelerometer));
- register_cordova_module(CORDOVA_MODULE(Network));
- register_cordova_module(CORDOVA_MODULE(Notification));
- register_cordova_module(CORDOVA_MODULE(Storage));
- register_cordova_module(CORDOVA_MODULE(Platform));
- register_cordova_module(CORDOVA_MODULE(File));
- register_cordova_module(CORDOVA_MODULE(FileTransfer));
- register_cordova_module(CORDOVA_MODULE(Compass));
-}
-
-static void close_cordova_modules()
-{
- close_cordova_module(CORDOVA_MODULE(Device));
- close_cordova_module(CORDOVA_MODULE(Camera));
- close_cordova_module(CORDOVA_MODULE(Capture));
- close_cordova_module(CORDOVA_MODULE(Accelerometer));
- close_cordova_module(CORDOVA_MODULE(Network));
- close_cordova_module(CORDOVA_MODULE(Notification));
- close_cordova_module(CORDOVA_MODULE(Storage));
- close_cordova_module(CORDOVA_MODULE(Platform));
- close_cordova_module(CORDOVA_MODULE(File));
- close_cordova_module(CORDOVA_MODULE(FileTransfer));
- close_cordova_module(CORDOVA_MODULE(Compass));
-}
-
-static CordovaModule *find_cordova_module(BSTR module_id)
-{
- CordovaModule *item = module_list;
-
- while (item) {
- if (!wcscmp(item->module_id, module_id))
- return item;
- item = item->next;
- }
-
- return NULL;
-}
-
-static wchar_t *error_string_from_code(CallbackStatus code)
-{
- switch (code) {
- case CB_NO_RESULT: return L"cordova.callbackStatus.NO_RESULT";
- case CB_OK: return L"cordova.callbackStatus.OK";
- case CB_CLASS_NOT_FOUND_EXCEPTION: return L"cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION";
- case CB_ILLEGAL_ACCESS_EXCEPTION: return L"cordova.callbackStatus.ILLEGAL_ACCESS_EXCEPTION";
- case CB_INSTANTIATION_EXCEPTION: return L"cordova.callbackStatus.INSTANTIATION_EXCEPTION";
- case CB_MALFORMED_URL_EXCEPTION: return L"cordova.callbackStatus.MALFORMED_URL_EXCEPTION";
- case CB_IO_EXCEPTION: return L"cordova.callbackStatus.IO_EXCEPTION";
- case CB_INVALID_ACTION: return L"cordova.callbackStatus.INVALID_ACTION";
- case CB_JSON_EXCEPTION: return L"cordova.callbackStatus.JSON_EXCEPTION";
- default: return L"cordova.callbackStatus.ERROR";
- }
-}
-
-void cordova_success_callback(BSTR callback_id, BOOL keep_callback, const wchar_t *message)
-{
- wchar_t *status_str = (message == NULL) ? error_string_from_code(CB_NO_RESULT) : error_string_from_code(CB_OK);
- wchar_t *result = L"window.cordova.callbackSuccess('%s',{status:%s,keepCallback:%s,message:%s});";
- wchar_t *buf;
-
- buf = (wchar_t *) malloc(sizeof(wchar_t) * (1 + wcslen(result) + wcslen(callback_id) + wcslen(status_str) + wcslen(L"false") + wcslen(message)));
-
- wsprintf(buf, result, callback_id, status_str, keep_callback?L"true":L"false", message);
- invoke_js_routine(buf);
-
- free(buf);
-}
-
-void cordova_fail_callback(BSTR callback_id, BOOL keep_callback, CallbackStatus status, const wchar_t *message)
-{
- wchar_t *status_str = error_string_from_code(status);
- wchar_t *result = L"window.cordova.callbackError('%s',{status:%s,keepCallback:%s,message:%s});";
- wchar_t *buf;
-
- buf = (wchar_t *) malloc(sizeof(wchar_t) * (1 + wcslen(result) + wcslen(callback_id) + wcslen(status_str) + wcslen(L"false") + wcslen(message)));
-
- wsprintf(buf, result, callback_id, status_str, keep_callback?L"true":L"false", message);
- invoke_js_routine(buf);
-
- free(buf);
-}
-
-//-------------------------------------------------------------------------------------------------
-
-HRESULT STDMETHODCALLTYPE InPlFr_QueryInterface(IOleInPlaceFrame * This, REFIID riid, void **ppvObject)
-{
- NOT_IMPLEMENTED
-}
-
-ULONG STDMETHODCALLTYPE InPlFr_AddRef(IOleInPlaceFrame * This)
-{
- NOT_IMPLEMENTED
-}
-
-ULONG STDMETHODCALLTYPE InPlFr_Release(IOleInPlaceFrame * This)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_GetWindow(IOleInPlaceFrame * This, HWND *phwnd)
-{
- *phwnd = hWnd;
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_ContextSensitiveHelp(IOleInPlaceFrame * This, BOOL fEnterMode)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_GetBorder(IOleInPlaceFrame * This, LPRECT lprectBorder)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_RequestBorderSpace(IOleInPlaceFrame * This, LPCBORDERWIDTHS pborderwidths)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_SetBorderSpace(IOleInPlaceFrame * This, LPCBORDERWIDTHS pborderwidths)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_SetActiveObject(IOleInPlaceFrame * This, IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_InsertMenus(IOleInPlaceFrame * This, HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_SetMenu(IOleInPlaceFrame * This, HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_RemoveMenus(IOleInPlaceFrame * This, HMENU hmenuShared)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_SetStatusText(IOleInPlaceFrame * This, LPCOLESTR pszStatusText)
-{
- // Status updates
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_EnableModeless(IOleInPlaceFrame * This, BOOL fEnable)
-{
- // We don't track the modeless flag state, but as this gets called, reply something meaningful
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE InPlFr_TranslateAccelerator(IOleInPlaceFrame * This, LPMSG lpmsg, WORD wID)
-{
- NOT_IMPLEMENTED
-}
-
-//-------------------------------------------------------------------------------------------------
-
-// IOleInPlaceFrame vtable
-static IOleInPlaceFrameVtbl inplfr_vtable =
-{
- InPlFr_QueryInterface,
- InPlFr_AddRef,
- InPlFr_Release,
- InPlFr_GetWindow,
- InPlFr_ContextSensitiveHelp,
- InPlFr_GetBorder,
- InPlFr_RequestBorderSpace,
- InPlFr_SetBorderSpace,
- InPlFr_SetActiveObject,
- InPlFr_InsertMenus, // Enables the container to insert menu groups
- InPlFr_SetMenu, // Adds a composite menu to the window frame containing the object being activated in place
- InPlFr_RemoveMenus, // Removes a container's menu elements from the composite menu
- InPlFr_SetStatusText, // Sets and displays status text about the in-place object in the container's frame window status line
- InPlFr_EnableModeless, // Enables or disables a frame's modeless dialog boxes
- InPlFr_TranslateAccelerator // Translates accelerator keystrokes intended for the container's frame while an object is active in place
-};
-
-//-------------------------------------------------------------------------------------------------
-
-HRESULT STDMETHODCALLTYPE InPlSi_QueryInterface(IOleInPlaceSite * This, REFIID riid, void **ppvObject)
-{
- if (IsEqualIID(riid,&IID_IUnknown) || IsEqualIID(riid,&IID_IOleInPlaceSite))
- {
- *ppvObject = browser_ips;
- browser_ips->lpVtbl->AddRef(browser_ips);
- return NOERROR;
- }
-
- // We get queries for IID_ServiceProvider, IID_IOleCommandTarget
-
- *ppvObject = 0;
- return E_NOINTERFACE;
-}
-
-ULONG STDMETHODCALLTYPE InPlSi_AddRef(IOleInPlaceSite * This)
-{
- inplsi_ref_count++;
-
- return inplsi_ref_count;
-}
-
-ULONG STDMETHODCALLTYPE InPlSi_Release(IOleInPlaceSite * This)
-{
- inplsi_ref_count--;
-
- ASSERT(inplsi_ref_count >= 0);
-
- return inplsi_ref_count;
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_GetWindow(IOleInPlaceSite * This, HWND *phwnd)
-{
- *phwnd = hWnd;
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_ContextSensitiveHelp(IOleInPlaceSite * This, BOOL fEnterMode)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_CanInPlaceActivate(IOleInPlaceSite * This)
-{
- return S_OK; // Allow activation
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_OnInPlaceActivate(IOleInPlaceSite * This)
-{
- return S_OK; // Go ahead and activate object
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_OnUIActivate(IOleInPlaceSite * This)
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_GetWindowContext(IOleInPlaceSite * This, IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
-{
- *ppFrame = browser_ipf;
- *ppDoc = 0;
- GetClientRect(hWnd, lprcPosRect);
- GetClientRect(hWnd, lprcClipRect);
-
- // The OLEINPLACEFRAMEINFO structure will need to be modified if we ever want custom keystrokes/accelerators
- lpFrameInfo->cb = sizeof(OLEINPLACEFRAMEINFO);
- lpFrameInfo->fMDIApp = FALSE;
- lpFrameInfo->hwndFrame = hWnd;
- lpFrameInfo->haccel = 0;
- lpFrameInfo->cAccelEntries = 0;
-
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_Scroll(IOleInPlaceSite * This, SIZE scrollExtant)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_OnUIDeactivate(IOleInPlaceSite * This, BOOL fUndoable)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_OnInPlaceDeactivate(IOleInPlaceSite * This)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_DiscardUndoState(IOleInPlaceSite * This)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_DeactivateAndUndo(IOleInPlaceSite * This)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE InPlSi_OnPosRectChange(IOleInPlaceSite * This, LPCRECT lprcPosRect)
-{
- if (browser_ipo_if && browser_ipo_if->lpVtbl)
- browser_ipo_if->lpVtbl->SetObjectRects(browser_ipo_if, lprcPosRect, lprcPosRect);
-
- return S_OK;
-}
-
-//-------------------------------------------------------------------------------------------------
-
-// IOleInPlaceSite vtable
-static IOleInPlaceSiteVtbl inplsi_vtable =
-{
- InPlSi_QueryInterface,
- InPlSi_AddRef,
- InPlSi_Release,
- InPlSi_GetWindow,
- InPlSi_ContextSensitiveHelp,
- InPlSi_CanInPlaceActivate, // Determines whether the container can activate the object in place
- InPlSi_OnInPlaceActivate, // Notifies the container that one of its objects is being activated in place
- InPlSi_OnUIActivate, // Notifies the container that the object is about to be activated in place and that the object is going to replace the container's main menu with an in-place composite menu
- InPlSi_GetWindowContext, // Enables an in-place object to retrieve the window interfaces that form the window object hierarchy, and the position in the parent window where the object's in-place activation window should be located
- InPlSi_Scroll, // Instructs the container to scroll the view of the object by the specified number of pixels
- InPlSi_OnUIDeactivate, // Notifies the container to reinstall its user interface and take focus
- InPlSi_OnInPlaceDeactivate, // Notifies the container that it should reinstall its user interface and take focus, and whether the object has an undoable state
- InPlSi_DiscardUndoState, // Instructs the container to discard its undo state
- InPlSi_DeactivateAndUndo, // Deactivates the object, ends the in-place session, and reverts to the container's saved undo state
- InPlSi_OnPosRectChange // Notifies the container that the object extents have changed
-};
-
-//-------------------------------------------------------------------------------------------------
-
-HRESULT STDMETHODCALLTYPE DUIH_QueryInterface(IDocHostUIHandler * This, REFIID riid, void **ppvObject)
-{
- if (IsEqualIID(riid,&IID_IUnknown) || IsEqualIID(riid,&IID_IDocHostUIHandler))
- {
- *ppvObject = browser_dui;
- browser_dui->lpVtbl->AddRef(browser_dui);
- return NOERROR;
- }
-
- // We're using IOleCommandTarget to intercept javascript error dialogs
- if (IsEqualIID(riid,&IID_IOleCommandTarget))
- {
- *ppvObject = browser_oct;
- browser_oct->lpVtbl->AddRef(browser_oct);
- return NOERROR;
- }
-
- *ppvObject = 0;
- return E_NOINTERFACE;
-}
-
-ULONG STDMETHODCALLTYPE DUIH_AddRef(IDocHostUIHandler * This)
-{
- duih_ref_count++;
-
- return duih_ref_count;
-}
-
-ULONG STDMETHODCALLTYPE DUIH_Release(IDocHostUIHandler * This)
-{
- duih_ref_count--;
-
- ASSERT(duih_ref_count >= 0);
-
- return duih_ref_count;
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_ShowContextMenu(IDocHostUIHandler * This, DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
-{
- // Pretend we take care of all menus but copy & paste - so the HTML control does not show its own contextual menus
- if (dwID == CONTEXT_MENU_TEXTSELECT)
- return S_FALSE;
- else
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_GetHostInfo(IDocHostUIHandler * This, DOCHOSTUIINFO *pInfo)
-{
- // Specify some of our UI tastes to the HTML control
- pInfo->cbSize = sizeof(DOCHOSTUIINFO);
- pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE | DOCHOSTUIFLAG_NO3DOUTERBORDER | DOCHOSTUIFLAG_SCROLL_NO |
- DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION | DOCHOSTUIFLAG_NOTHEME | DOCHOSTUIFLAG_DPI_AWARE | DOCHOSTUIFLAG_ENABLE_ACTIVEX_INACTIVATE_MODE;
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_ShowUI(IDocHostUIHandler * This, DWORD dwID, IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
-{
- return S_FALSE; // Use the HTML control's UI rather than our own, for now
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_HideUI(IDocHostUIHandler * This)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_UpdateUI(IDocHostUIHandler * This)
-{
- // We don't have any special UI to update at the host application level
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_EnableModeless(IDocHostUIHandler * This, BOOL fEnable)
-{
- // We don't track the modeless flag state, but as this gets called, reply something meaningful
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_OnDocWindowActivate(IDocHostUIHandler * This, BOOL fActivate)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_OnFrameWindowActivate(IDocHostUIHandler * This, BOOL fActivate)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_ResizeBorder(IDocHostUIHandler * This, LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_TranslateAccelerator(IDocHostUIHandler * This, LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_GetOptionKeyPath(IDocHostUIHandler * This, LPOLESTR *pchKey, DWORD dw)
-{
- return S_FALSE; // Don't use customized settings : use whatever is stored in the default IE registry area
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_GetDropTarget(IDocHostUIHandler * This, IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
-{
- return E_NOTIMPL; // We don't supply a customized drop target
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_GetExternal(IDocHostUIHandler * This, IDispatch **ppDispatch)
-{
- // Plug generic dispatcher that will allow calls from the javascript side
- browser_ext->lpVtbl->AddRef(browser_ext);
- *ppDispatch = browser_ext;
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_TranslateUrl(IDocHostUIHandler * This, DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
-{
- return S_FALSE; // Don't translate
-}
-
-HRESULT STDMETHODCALLTYPE DUIH_FilterDataObject(IDocHostUIHandler * This, IDataObject *pDO, IDataObject **ppDORet)
-{
- NOT_IMPLEMENTED
-}
-
-//-------------------------------------------------------------------------------------------------
-
-// IDocHostUIHandler vtable
-static IDocHostUIHandlerVtbl duih_vtable =
-{
- DUIH_QueryInterface,
- DUIH_AddRef,
- DUIH_Release,
- DUIH_ShowContextMenu,
- DUIH_GetHostInfo,
- DUIH_ShowUI,
- DUIH_HideUI,
- DUIH_UpdateUI,
- DUIH_EnableModeless,
- DUIH_OnDocWindowActivate,
- DUIH_OnFrameWindowActivate,
- DUIH_ResizeBorder,
- DUIH_TranslateAccelerator,
- DUIH_GetOptionKeyPath,
- DUIH_GetDropTarget,
- DUIH_GetExternal,
- DUIH_TranslateUrl,
- DUIH_FilterDataObject
-};
-
-//-------------------------------------------------------------------------------------------------
-
-HRESULT STDMETHODCALLTYPE OCT_QueryInterface (IOleCommandTarget* This, REFIID riid, void **ppvObject)
-{
- if (IsEqualIID(riid,&IID_IUnknown) || IsEqualIID(riid,&IID_IOleCommandTarget))
- {
- *ppvObject = browser_oct;
- browser_oct->lpVtbl->AddRef(browser_oct);
- return NOERROR;
- }
-
- *ppvObject = 0;
- return E_NOINTERFACE;
-}
-
-ULONG STDMETHODCALLTYPE OCT_AddRef (IOleCommandTarget* This)
-{
- oct_ref_count++;
-
- return oct_ref_count;
-}
-
-ULONG STDMETHODCALLTYPE OCT_Release (IOleCommandTarget* This)
-{
- oct_ref_count--;
-
- ASSERT(oct_ref_count >= 0);
-
- return oct_ref_count;
-}
-
-HRESULT STDMETHODCALLTYPE OCT_QueryStatus (IOleCommandTarget* This,const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText)
-{
- return E_NOTIMPL;
-}
-
-HRESULT STDMETHODCALLTYPE OCT_Exec (IOleCommandTarget* This, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut)
-{
- if (pguidCmdGroup && IsEqualGUID(pguidCmdGroup, &CGID_DocHostCommandHandler))
- switch (nCmdID)
- {
- case OLECMDID_SHOWMESSAGE:
- return OLECMDERR_E_NOTSUPPORTED;
-
- case OLECMDID_SHOWSCRIPTERROR:
- // The JavaScript engine reported an error: stop running scripts on the page
- pvaOut->vt = VT_BOOL;
- pvaOut->boolVal = VARIANT_FALSE;
- return S_OK;
-
- default:
- return OLECMDERR_E_NOTSUPPORTED;
- }
-
- return OLECMDERR_E_UNKNOWNGROUP;
-}
-
-// IOleCommandTarget vtable
-static IOleCommandTargetVtbl oct_vtable =
-{
- OCT_QueryInterface,
- OCT_AddRef,
- OCT_Release,
- OCT_QueryStatus,
- OCT_Exec
-};
-
-//-------------------------------------------------------------------------------------------------
-
-HRESULT STDMETHODCALLTYPE ClSi_QueryInterface(IOleClientSite * This, REFIID riid, void **ppvObject)
-{
- if (IsEqualIID(riid,&IID_IUnknown) || IsEqualIID(riid,&IID_IOleClientSite))
- {
- *ppvObject = browser_cs;
- browser_cs->lpVtbl->AddRef(browser_cs);
- return NOERROR;
- }
-
- if (IsEqualIID(riid,&IID_IOleInPlaceSite))
- {
- *ppvObject = browser_ips;
- browser_ips->lpVtbl->AddRef(browser_ips);
- return NOERROR;
- }
-
- if (IsEqualIID(riid,&IID_IServiceProvider))
- {
- *ppvObject = 0;
- return E_NOINTERFACE;
- }
-
- if (IsEqualIID(riid,&IID_IDispatch))
- {
- *ppvObject = 0;
- return E_NOINTERFACE;
- }
-
- if (IsEqualIID(riid,&IID_IDocHostUIHandler))
- {
- *ppvObject = browser_dui;
- browser_dui->lpVtbl->AddRef(browser_dui);
- return NOERROR;
- }
-
- *ppvObject = 0;
- return E_NOINTERFACE;
-}
-
-ULONG STDMETHODCALLTYPE ClSi_AddRef(IOleClientSite * This)
-{
- clsi_ref_count++;
- if (clsi_ref_count == 1)
- {
- // Initialize sub-objects
- }
-
- return clsi_ref_count;
-}
-
-ULONG STDMETHODCALLTYPE ClSi_Release(IOleClientSite * This)
-{
- clsi_ref_count--;
-
- ASSERT(clsi_ref_count >= 0);
-
- // Dispose of our sub-objects here
- return clsi_ref_count;
-}
-
-HRESULT STDMETHODCALLTYPE ClSi_SaveObject(IOleClientSite * This)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE ClSi_GetMoniker(IOleClientSite * This, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE ClSi_GetContainer(IOleClientSite * This, IOleContainer **ppContainer)
-{
- // We don't support IOleContainer interface at that time
- *ppContainer = 0;
- return E_NOINTERFACE;
-}
-
-HRESULT STDMETHODCALLTYPE ClSi_ShowObject(IOleClientSite * This)
-{
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE ClSi_OnShowWindow(IOleClientSite * This, BOOL fShow)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE ClSi_RequestNewObjectLayout(IOleClientSite * This)
-{
- NOT_IMPLEMENTED
-}
-
-//-------------------------------------------------------------------------------------------------
-
-// IOleClientSite vtable
-static IOleClientSiteVtbl clsi_vtable =
-{
- ClSi_QueryInterface,
- ClSi_AddRef,
- ClSi_Release,
- ClSi_SaveObject, // Saves the embedded object associated with the client site
- ClSi_GetMoniker, // Retrieves a moniker for the object's client site
- ClSi_GetContainer, // Retrieves a pointer to the object's container
- ClSi_ShowObject, // Asks a container to display its object to the user
- ClSi_OnShowWindow, // Notifies a container when an embedded object's window is about to become visible or invisible
- ClSi_RequestNewObjectLayout // Asks a container to resize the display site for embedded objects
-};
-
-//-------------------------------------------------------------------------------------------------
-
-void invoke_js_routine (wchar_t* wcs)
-{
- BSTR wcs_as_bstr;
-
- wcs_as_bstr = SysAllocString(wcs);
- PostMessage(hWnd, WM_EXEC_JS_SCRIPT, 0, (LPARAM) wcs_as_bstr);
-}
-
-//-------------------------------------------------------------------------------------------------
-
-BOOL CALLBACK enum_proc(HWND window, LPARAM reply)
-{
- static wchar_t wanted[] = L"Internet Explorer_Server";
- char buf[sizeof(wanted)];
-
- if (GetClassName(window, (wchar_t*) buf, sizeof(wanted)/sizeof(wanted[0]))
- && !memcmp(buf, wanted, sizeof(wanted)))
- {
- // Report success and stop enumeration
- (*(HWND*) reply) = window;
- return FALSE;
- }
- else
- return TRUE;
-}
-
-void set_native_ready (void)
-{
- // Find browser window and subclass its window proc so we can intercept back key presses...
- HWND hBrowserWnd = 0;
- WNDPROC browser_wnd_proc;
-
- EnumChildWindows(hWnd, enum_proc, (LPARAM) &hBrowserWnd);
-
- browser_wnd_proc = (WNDPROC) GetWindowLong(hBrowserWnd, GWL_WNDPROC);
- if (browser_wnd_proc && browser_wnd_proc != BrowserWndProcWrapper)
- {
- initial_browser_wnd_proc = browser_wnd_proc;
- SetWindowLong(hBrowserWnd, GWL_WNDPROC, (LONG) BrowserWndProcWrapper);
- BringWindowToTop(hBrowserWnd);
- }
-
- // Fire onNativeReady event
- invoke_js_routine(L"cordova.require('cordova/channel').onNativeReady.fire();");
-}
-
-//-------------------------------------------------------------------------------------------------
-
-HRESULT STDMETHODCALLTYPE Ext_QueryInterface(IDispatch * This, REFIID riid, void **ppvObject)
-{
- if (IsEqualIID(riid,&IID_IUnknown) || IsEqualIID(riid,&IID_IDispatch))
- {
- *ppvObject = browser_ext;
- browser_ext->lpVtbl->AddRef(browser_ext);
- return NOERROR;
- }
-
- *ppvObject = 0;
- return E_NOINTERFACE;
-}
-
-ULONG STDMETHODCALLTYPE Ext_AddRef(IDispatch * This)
-{
- ext_ref_count++;
-
- return ext_ref_count;
-}
-
-ULONG STDMETHODCALLTYPE Ext_Release(IDispatch * This)
-{
- ext_ref_count--;
-
- ASSERT(ext_ref_count >= 0);
-
- return ext_ref_count;
-}
-
-HRESULT STDMETHODCALLTYPE Ext_GetTypeInfoCount(IDispatch * This, UINT *pctinfo)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE Ext_GetTypeInfo(IDispatch * This, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE Ext_GetIDsOfNames(IDispatch * This, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
-{
- HRESULT hr = S_OK;
- UINT i;
-
- // Map method name to integer
- for ( i=0; i < cNames; i++)
- if (CompareString( lcid, NORM_IGNORECASE, gate_name, -1, rgszNames[i], -1 ) == CSTR_EQUAL)
- rgDispId[i] = DISPID_GATE;
- else
- {
- // At least one unknown selector
- rgDispId[i] = DISPID_UNKNOWN;
- hr = DISP_E_UNKNOWNNAME;
- }
-
- return hr;
-}
-
-HRESULT STDMETHODCALLTYPE Ext_Invoke(IDispatch * This, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
-{
- if (dispIdMember == DISPID_GATE)
- {
- if (wFlags & DISPATCH_METHOD)
- {
- CordovaModule *module;
-
- // Check params
- if (pDispParams->cArgs != 4)
- return DISP_E_BADPARAMCOUNT;
-
- if (pDispParams->rgvarg[0].vt != VT_BSTR ||
- pDispParams->rgvarg[1].vt != VT_BSTR ||
- pDispParams->rgvarg[2].vt != VT_BSTR ||
- pDispParams->rgvarg[3].vt != VT_BSTR)
- return DISP_E_TYPEMISMATCH;
-
- // Find module
- module = find_cordova_module(pDispParams->rgvarg[2].bstrVal);
- if (module == NULL)
- return DISP_E_MEMBERNOTFOUND;
-
- // Execute command
- return module->exec(pDispParams->rgvarg[3].bstrVal, pDispParams->rgvarg[1].bstrVal, pDispParams->rgvarg[0].bstrVal, pVarResult);
- }
- }
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-//-------------------------------------------------------------------------------------------------
-//-------------------------------------------------------------------------------------------------
-
-HRESULT STDMETHODCALLTYPE Disp_QueryInterface(IDispatch * This, REFIID riid, void **ppvObject)
-{
- if (IsEqualIID(riid,&IID_IUnknown) || IsEqualIID(riid,&IID_IDispatch))
- {
- *ppvObject = browser_dsp;
- browser_dsp->lpVtbl->AddRef(browser_dsp);
- return NOERROR;
- }
-
- // We also get called for DIID_DWebBrowserEvents2, but IDispatch is fine
-
- *ppvObject = 0;
- return E_NOINTERFACE;
-}
-
-ULONG STDMETHODCALLTYPE Disp_AddRef(IDispatch * This)
-{
- disp_ref_count++;
-
- return disp_ref_count;
-}
-
-ULONG STDMETHODCALLTYPE Disp_Release(IDispatch * This)
-{
- disp_ref_count--;
-
- ASSERT(disp_ref_count >= 0);
-
- return disp_ref_count;
-}
-
-HRESULT STDMETHODCALLTYPE Disp_GetTypeInfoCount(IDispatch * This, UINT *pctinfo)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE Disp_GetTypeInfo(IDispatch * This, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE Disp_GetIDsOfNames(IDispatch * This, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
-{
- NOT_IMPLEMENTED
-}
-
-HRESULT STDMETHODCALLTYPE Disp_Invoke(IDispatch * This, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
-{
- HRESULT hr;
- wchar_t* title;
-
- // That's our DIID_DWebBrowserEvents2 event sink callback
-
- switch (dispIdMember)
- {
- case DISPID_DOCUMENTCOMPLETE:
- // Get access to the document IDispatch interface
- // Note: in the presence of frames, we would receive several of these events and would need
- // to check that the IUnknown interfaces for This and browser_web_if are identical
- // We may get a nil pointer if the base document fails to load
- hr = browser_web_if->lpVtbl->get_Document(browser_web_if, &document_dispatch_if);
-
- if (document_dispatch_if)
- {
- // Retrieve IHTMLDocument2 interface
- hr = document_dispatch_if->lpVtbl->QueryInterface(document_dispatch_if, &IID_IHTMLDocument2, &document_html2_if);
-
- // Retrieve IHTMLWindow2 interface
- document_html2_if->lpVtbl->get_parentWindow(document_html2_if, &html_window2_if);
-
- // Set initial Cordova state and release application
- set_native_ready();
- current_state = STATE_NATIVE_READY;
- }
- break;
-
- case DISPID_TITLECHANGE:
- if (skip_title_update)
- {
- skip_title_update--;
- break;
- }
-
- // Update window caption
- title = pDispParams->rgvarg[0].bstrVal;
- SetWindowText(hWnd, title);
- break;
-
- case DISPID_NAVIGATEERROR:
- {
- // Silently dismiss navigation errors for now
- VARIANT_BOOL * cancel = pDispParams->rgvarg[0].pboolVal;
- *cancel = VARIANT_TRUE;
- }
- return S_OK;
-
- default:
- ;
- }
-
- return S_OK;
-}
-
-//-------------------------------------------------------------------------------------------------
-
-static IDispatchVtbl disp_vtable =
-{
- Disp_QueryInterface,
- Disp_AddRef,
- Disp_Release,
- Disp_GetTypeInfoCount,
- Disp_GetTypeInfo,
- Disp_GetIDsOfNames,
- Disp_Invoke
-};
-
-//-------------------------------------------------------------------------------------------------
-
-static IDispatchVtbl ext_vtable =
-{
- Ext_QueryInterface,
- Ext_AddRef,
- Ext_Release,
- Ext_GetTypeInfoCount,
- Ext_GetTypeInfo,
- Ext_GetIDsOfNames,
- Ext_Invoke
-};
-
-//-------------------------------------------------------------------------------------------------
-
-#define MAIN_WINDOW_CLASS L"Cordova Shell Window"
-#define MAIN_WINDOW_NAME APP_NAME
-#define MAIN_WINDOW_STYLE WS_OVERLAPPEDWINDOW
-
-//-------------------------------------------------------------------------------------------------
-
-static void call_js_script(BSTR wcs_as_bstr)
-{
- VARIANT v;
-
- if (html_window2_if)
- {
- VariantInit(&v);
- html_window2_if->lpVtbl->execScript(html_window2_if, wcs_as_bstr, javascript, &v);
- SysFreeString(wcs_as_bstr);
- }
-}
-
-
-void ProcessBackKeyStroke (void)
-{
- // I there are listeners for back button down notifications
- if (is_back_button_event_enabled())
- {
- call_js_script(SysAllocString(L"cordova.fireDocumentEvent('backbutton');"));
- }
-}
-
-LRESULT CALLBACK CordovaShellWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- // WindowProc for the main host application window
-
- switch (uMsg)
- {
- case WM_KEYDOWN:
- if (wParam == VK_BACK)
- ProcessBackKeyStroke();
- break;
-
- case WM_CLOSE:
- current_state = STATE_ENDING; // The window will get deactivated before being destroyed
- // Do not bother sending "pause" event
- // But send the "destroy" event
- call_js_script(SysAllocString(L"cordova.require('cordova/channel').onDestroy.fire();"));
- break;
-
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
-
- case WM_SIZE:
- if (browser_web_if && browser_web_if->lpVtbl)
- {
- browser_web_if->lpVtbl->put_Width(browser_web_if, LOWORD(lParam));
- browser_web_if->lpVtbl->put_Height(browser_web_if, HIWORD(lParam));
- }
-
- if (hCaptureWnd)
- SetWindowPos(hCaptureWnd, 0, 0, 0, LOWORD(lParam), HIWORD(lParam), SWP_NOMOVE | SWP_NOZORDER);
- return 0;
-
- case WM_DISPLAYCHANGE:
- camera_notify_display_change();
- return 0;
-
- case WM_EXEC_JS_SCRIPT:
- call_js_script((BSTR) lParam);
- return 0;
-
- case WM_USER_ACCEL:
- // New accelerometer sample available ; propagate to the JS side
- propagate_accel_sample();
- return 0;
-
- case WM_USER_COMPASS:
- // New compass sample available ; propagate to the JS side
- propagate_compass_sample();
- return 0;
-
- case WM_PARENTNOTIFY:
- // The capture window got destroyed, time to let the JS side know the outcome of the last requested service
- if (LOWORD(wParam) == WM_DESTROY && (HWND) lParam == hCaptureWnd)
- {
- notify_capture_result();
- }
- break;
-
- case WM_ACTIVATE:
- if (LOWORD(wParam))
- {
- // Window activated ; send resume event if in paused state
- if (current_state == STATE_PAUSED)
- {
- invoke_js_routine(L"cordova.require('cordova/channel').onResume.fire();");
- current_state = STATE_NATIVE_READY;
- }
- }
- else
- {
- // Window deactivated ; send pause event if we're in active state
- if (current_state == STATE_NATIVE_READY)
- {
- invoke_js_routine(L"cordova.require('cordova/channel').onPause.fire();");
- current_state = STATE_PAUSED;
- }
- }
- break;
-
- default:
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
- }
-
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
-}
-
-//-------------------------------------------------------------------------------------------------
-
-LRESULT CALLBACK BrowserWndProcWrapper(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- if (uMsg == WM_KEYDOWN && wParam == VK_BACK)
- ProcessBackKeyStroke();
-
- return initial_browser_wnd_proc(hWnd, uMsg, wParam, lParam);
-}
-
-//-------------------------------------------------------------------------------------------------
-
-void create_browser_object (void)
-{
- HRESULT hr;
- BSTR base_url;
- VARIANT nil;
- BSTR app_name;
- IConnectionPointContainer* cp_container_if;
- IConnectionPoint* cp_if;
-
- // Initialize client site object
- browser_cs = &clsi;
- browser_cs->lpVtbl = &clsi_vtable;
-
- // Initialize in place site object
- browser_ips = &inplsi;
- browser_ips->lpVtbl = &inplsi_vtable;
-
- // Initialize in place frame object
- browser_ipf = &inplfr;
- browser_ipf->lpVtbl = &inplfr_vtable;
-
- // Initialize event dispatcher object
- browser_dsp = &disp;
- browser_dsp->lpVtbl = &disp_vtable;
-
- // Initialize external interface dispatcher object
- browser_ext = &ext;
- browser_ext->lpVtbl = &ext_vtable;
-
- // Initialize host doc ui handler object
- browser_dui = &duih;
- browser_dui->lpVtbl = &duih_vtable;
-
- // Initialize OLE command target object
- browser_oct = &oct;
- browser_oct->lpVtbl = &oct_vtable;
-
- CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER, &IID_IWebBrowser2, (void**)&browser_web_if);
-
- if (browser_web_if)
- {
- // Get IOleObject interface
- browser_web_if->lpVtbl->QueryInterface(browser_web_if, &IID_IOleObject, &browser_ole_if);
-
- if (browser_ole_if)
- {
- app_name = SysAllocString(APP_NAME);
-
- hr = browser_ole_if->lpVtbl->SetClientSite(browser_ole_if, browser_cs);
- hr = browser_ole_if->lpVtbl->SetHostNames(browser_ole_if, app_name, 0);
-
- // Activate object
- hr = browser_ole_if->lpVtbl->DoVerb(browser_ole_if, OLEIVERB_INPLACEACTIVATE, 0, browser_cs, 0, hWnd, 0);
- }
-
- // Also get a IOleInPlaceObject interface, as it's the expected way to resize the browser control
- browser_web_if->lpVtbl->QueryInterface(browser_web_if, &IID_IOleInPlaceObject, &browser_ipo_if);
-
- // Connect an event sink to the browser so we can get notified when there's an update to the document title
-
- hr = browser_web_if->lpVtbl->QueryInterface(browser_web_if, &IID_IConnectionPointContainer, &cp_container_if);
- hr = cp_container_if->lpVtbl->FindConnectionPoint(cp_container_if, &DIID_DWebBrowserEvents2, &cp_if);
- hr = cp_if->lpVtbl->Advise(cp_if, (IUnknown*) browser_dsp, &browser_dsp_cookie);
-
- // Disable drag & drop on our window
- hr = browser_web_if->lpVtbl->put_RegisterAsDropTarget(browser_web_if, VARIANT_FALSE);
-
- // Direct the browser to our index.html file
-
- base_url = SysAllocString(full_path);
- VariantInit(&nil);
-
- hr = browser_web_if->lpVtbl->Navigate(browser_web_if, base_url, &nil, &nil, &nil, &nil);
-
- if (hr == S_OK)
- // Display our HTML window
- hr = browser_web_if->lpVtbl->put_Visible(browser_web_if, VARIANT_TRUE);
- else
- browser_web_if->lpVtbl->Quit(browser_web_if);
-
- SysFreeString(base_url);
-
- browser_web_if->lpVtbl->Release(browser_web_if);
- }
-}
-
-//-------------------------------------------------------------------------------------------------
-
-void set_ie_feature (wchar_t* key_name, DWORD new_val)
-{
- wchar_t filename[_MAX_PATH];
- wchar_t* last_component;
- DWORD info;
- HKEY key;
- LONG ret;
- DWORD len;
- DWORD val;
- DWORD type;
-
- filename[0] = L'\0';
-
- // First retrieve the current executable name
- GetModuleFileName(0, filename, _MAX_PATH);
-
- last_component = wcsrchr(filename, L'\\');
-
- if (last_component && *last_component == '\\')
- last_component++;
- else
- return;
-
-
- ret = RegCreateKeyEx(HKEY_CURRENT_USER, key_name, 0, 0, 0, KEY_READ | KEY_WRITE, 0, &key, &info);
-
- if (ret != ERROR_SUCCESS)
- return;
-
- len = sizeof(DWORD);
-
- ret = RegQueryValueEx(key, last_component, 0, &type, (LPBYTE) &val, &len);
-
- // If no value exists for our exe name (e.g. it hasn't been explicitly enabled or disabled)
- if (ret != ERROR_SUCCESS || type != REG_DWORD)
- // Stick a value there named after our exe name
- RegSetValueEx(key, last_component, 0, REG_DWORD, (LPBYTE) &new_val, sizeof(DWORD));
-
- RegCloseKey(key);
-}
-
-//-------------------------------------------------------------------------------------------------
-
-int get_ie_version (void)
-{
- DWORD info;
- HKEY key;
- LONG ret;
- DWORD len;
- DWORD type;
- wchar_t buf[20];
- int major;
-
- buf[0] = L'\0';
-
- ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Internet Explorer" , 0, 0, 0, KEY_READ, 0, &key, &info);
-
- if (ret != ERROR_SUCCESS)
- return -1;
-
- if (info == REG_OPENED_EXISTING_KEY)
- {
- len = sizeof(buf);
-
- ret = RegQueryValueEx(key, L"Version", 0, &type, (LPBYTE) buf, &len);
-
- if (ret == ERROR_SUCCESS)
- {
- major = _wtoi(buf);
- RegCloseKey(key);
- return major;
- }
- }
-
- RegCloseKey(key);
- return -1;
-}
-
-//-------------------------------------------------------------------------------------------------
-
-void early_init (void)
-{
- DWORD major, minor;
- INITCOMMONCONTROLSEX ccex;
- DWORD winver = GetVersion();
-
- major = (DWORD)(LOBYTE(LOWORD(winver)));
- minor = (DWORD)(HIBYTE(LOWORD(winver)));
-
- // We need at least Windows Seven
- if (major < 6 || (major == 6 && minor < 1))
- {
- MessageBox(GetForegroundWindow(), L"This program requires Windows 7 or newer.", L"Missing Prerequisites", MB_OK);
- ExitProcess(61);
- }
-
- // IE 9 or newer required
- if (get_ie_version() < 9)
- {
- MessageBox(GetForegroundWindow(), L"This program requires Internet Explorer 9 or newer", L"Missing Prerequisites", MB_OK);
- ExitProcess(90);
- }
-
- // Form full path for our base URL file ; better do this early, as the current directory can be changed later
- GetFullPathName(BASE_URL, _MAX_PATH, full_path, 0); // Possible failure if the base directory has a very long name
-
-
- // A little BSTR object that we'll need to invoke js routines
- javascript = SysAllocString(L"javascript");
-
- // IE GPU acceleration is disabled by default for apps hosting the HTML control
- set_ie_feature(IE_GPU_REG_KEY, 1);
-
- // Disable pre-IE9 emulation
- set_ie_feature(IE_COMPAT_REG_KEY, 9999);
-
- // We need both COM (sensor API, etc) and OLE (WebBrowser control) services
- if (!SUCCEEDED(OleInitialize(0)))
- ExitProcess(0x01e);
-
- // Ensure the common controls library is setup to allow toolbar creation
- ccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
- ccex.dwICC = ICC_BAR_CLASSES;
- InitCommonControlsEx(&ccex);
-}
-
-//-------------------------------------------------------------------------------------------------
-
-int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
-{
- MSG msg;
- int code;
- WNDCLASSEX wc = {
- sizeof(WNDCLASSEX),
- CS_HREDRAW | CS_VREDRAW,
- CordovaShellWndProc,
- 0,
- 0,
- 0,
- 0, // >>> icon
- LoadCursor(NULL, IDC_ARROW),
- 0, // must handle background paint
- 0,
- MAIN_WINDOW_CLASS,
- 0 // >>> small icon update
- };
-
- set_thread_name(-1, "Primary Thread");
-
- early_init();
- register_cordova_modules();
-
- RegisterClassEx(&wc);
-
- hWnd = CreateWindow(MAIN_WINDOW_CLASS, MAIN_WINDOW_NAME, MAIN_WINDOW_STYLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0);
-
- if (!hWnd)
- return 0;
-
- create_browser_object();
-
- ShowWindow(hWnd, nCmdShow);
- UpdateWindow(hWnd);
-
- setup_capture();
-
- while ((code = GetMessage( &msg, 0, 0, 0 )) != 0)
- {
- if (code == -1)
- {
- }
- else
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
-
- close_cordova_modules();
- OleUninitialize();
-
- return msg.wParam;
-}
-
-
-// http://msdn.microsoft.com/en-us/ie/aa740471 for IE9 headers & libs
-// $(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\include
-// http://msdn.microsoft.com/en-us/library/ie/bb508516%28v=vs.85%29.aspx for MSHTML usage notes
-// http://support.microsoft.com/kb/261003/en-us for error handling
-
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/shell.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/shell.h b/windows7/Cordova/shell.h
deleted file mode 100644
index e463f67..0000000
--- a/windows7/Cordova/shell.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#ifndef __SHELL_H__
-#define __SHELL_H__
-
-#include <WTypes.h>
-#include <OaIdl.h>
-
-#define NULL_MESSAGE L"null"
-
-typedef enum {
- CB_NO_RESULT = 0,
- CB_OK = 1,
- CB_CLASS_NOT_FOUND_EXCEPTION = 2,
- CB_ILLEGAL_ACCESS_EXCEPTION = 3,
- CB_INSTANTIATION_EXCEPTION = 4,
- CB_MALFORMED_URL_EXCEPTION = 5,
- CB_IO_EXCEPTION = 6,
- CB_INVALID_ACTION = 7,
- CB_JSON_EXCEPTION = 8,
- CB_GENERIC_ERROR = 9
-} CallbackStatus;
-
-typedef HRESULT (*module_exec_func) (BSTR callback_id, BSTR action, BSTR args, VARIANT *result);
-typedef void (*module_close_func) (void);
-typedef void (*module_init_func) (void);
-
-struct _CordovaModule {
- BSTR module_id;
- module_exec_func exec;
- module_init_func init;
- module_close_func close;
- struct _CordovaModule *next;
-};
-typedef struct _CordovaModule CordovaModule;
-
-#define CORDOVA_MODULE(name) &Cordova##name
-#define DECLARE_CORDOVA_MODULE(name) extern CordovaModule Cordova##name;
-#define DEFINE_CORDOVA_MODULE(name, id, exec_func, init_func, close_func) CordovaModule Cordova##name = { id, exec_func, init_func, close_func, NULL };
-
-void cordova_success_callback(BSTR callback_id, BOOL keep_callback, const wchar_t *message);
-void cordova_fail_callback(BSTR callback_id, BOOL keep_callback, CallbackStatus status, const wchar_t *message);
-
-#endif
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/storage.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/storage.c b/windows7/Cordova/storage.c
deleted file mode 100644
index f723132..0000000
--- a/windows7/Cordova/storage.c
+++ /dev/null
@@ -1,384 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <Shlwapi.h>
-#include <Shlobj.h>
-#include <wchar.h>
-#define CINTERFACE 1 // Get C definitions for COM header files
-
-#include "lib/sqlite/sqlite3.h"
-#include "storage.h"
-#include "json.h"
-#include "common.h"
-
-#define DROP_QUERY L"drop"
-#define ALTER_QUERY L"alter"
-#define CREATE_QUERY L"create"
-#define TRUNCATE_QUERY L"truncate"
-
-struct _CordovaDb {
- sqlite3 *db;
- wchar_t *name;
- struct _CordovaDb *next;
-};
-typedef struct _CordovaDb CordovaDb;
-
-static CordovaDb *db_list = NULL;
-
-static CordovaDb *find_cordova_db(const wchar_t *name)
-{
- CordovaDb *item = db_list;
-
- while (item != NULL) {
- if (!wcscmp(name, item->name))
- return item;
-
- item = item->next;
- }
-
- return NULL;
-}
-
-static void remove_cordova_db(CordovaDb *db)
-{
- CordovaDb *item;
-
- if (db_list == db)
- db_list = NULL;
- else {
- item = db_list;
- while (item) {
- if (item->next == db) {
- item->next = db->next;
- break;
- }
-
- item = item->next;
- }
- }
-
- sqlite3_close(db->db);
- free(db->name);
- free(db);
-}
-
-static HRESULT remove_database(BSTR callback_id, BSTR args)
-{
- wchar_t path[MAX_PATH];
- CordovaDb *cordova_db;
- JsonArray array;
- JsonItem item;
- wchar_t *db_name = NULL;
-
- if (db_list == NULL)
- goto out;
-
- // Extract db name
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- json_free_args(array);
- return E_FAIL;
- }
- item = json_array_get_first(array);
-
- if (json_get_value_type(item) != JSON_VALUE_STRING) {
- json_free_args(array);
- return E_FAIL;
- }
- db_name = json_get_string_value(item);
- json_free_args(array);
-
- // Find & remove
- cordova_db = find_cordova_db(db_name);
- if (cordova_db) {
- remove_cordova_db(cordova_db);
-
- if(!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path)))
- goto out;
- PathAppend(path, L"Cordova\\db");
- PathAppend(path, db_name);
-
- DeleteFile(path);
- }
-
-out:
- if (db_name)
- free(db_name);
-
- return S_OK;
-}
-
-static HRESULT open_database(BSTR callback_id, BSTR args, VARIANT *result)
-{
- int res;
- wchar_t path[MAX_PATH];
- sqlite3 *db;
- CordovaDb *cordova_db;
- JsonArray array;
- JsonItem item;
- wchar_t *db_name;
-
- if(!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path)))
- return E_FAIL;
-
- PathAppend(path, L"Cordova\\db");
- res = SHCreateDirectory(NULL,path);
- if(!SUCCEEDED(res) && (res != ERROR_FILE_EXISTS) && (res != ERROR_ALREADY_EXISTS))
- return E_FAIL;
-
- // Validate array contents
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_STRING,
- JSON_VALUE_STRING,
- JSON_VALUE_STRING,
- JSON_VALUE_INT,
- JSON_VALUE_INVALID)) {
- json_free_args(array);
- return E_FAIL;
- }
- item = json_array_get_first(array);
-
- db_name = json_get_string_value(item);
- json_free_args(array);
-
- cordova_db = find_cordova_db(db_name);
- if (cordova_db != NULL)
- db = cordova_db->db;
- else {
- PathAppend(path, db_name);
- res = sqlite3_open16((const char *) path, &db);
- if (res != SQLITE_OK) {
- sqlite3_close(db);
- free (db_name);
- return E_FAIL;
- }
-
- cordova_db = (CordovaDb *)calloc(1, sizeof(CordovaDb));
- cordova_db->db = db;
- cordova_db->name = db_name;
- cordova_db->next = db_list;
-
- db_list = cordova_db;
- }
-
- VariantInit(result);
- result->vt = VT_INT;
- result->intVal = (int) db;
-
- return S_OK;
-}
-
-static BOOL is_ddl(const wchar_t *query)
-{
- if (!_wcsnicmp(query, DROP_QUERY, wcslen(DROP_QUERY)) ||
- !_wcsnicmp(query, ALTER_QUERY, wcslen(ALTER_QUERY)) ||
- !_wcsnicmp(query, CREATE_QUERY, wcslen(CREATE_QUERY)) ||
- !_wcsnicmp(query, TRUNCATE_QUERY, wcslen(TRUNCATE_QUERY)))
- return TRUE;
-
- return FALSE;
-}
-
-static HRESULT execute_sql(BSTR callback_id, BSTR args)
-{
- HRESULT res = S_OK;
- sqlite3 *db;
- sqlite3_stmt *stmt = NULL;
- JsonArray array;
- JsonItem item;
- TextBuf response;
- wchar_t *tx_id = NULL;
- wchar_t *command = NULL;
-
- response = text_buf_new();
-
- // Validate array contents
- if (!json_parse_and_validate_args(args, &array, JSON_VALUE_INT,
- JSON_VALUE_STRING,
- JSON_VALUE_ARRAY,
- JSON_VALUE_STRING,
- JSON_VALUE_INVALID)) {
- res = E_FAIL;
- goto out;
- }
-
- item = json_array_item_at(array, 3);
- tx_id = json_get_string_value(item);
-
- item = json_array_get_first(array);
- db = (sqlite3 *) json_get_int_value(item);
-
- item = json_array_get_next(item);
- command = json_get_string_value(item);
-
- if (is_ddl(command)) {
- if (sqlite3_prepare16_v2(db, command, wcslen(command) * sizeof(wchar_t), &stmt, NULL) != SQLITE_OK) {
- cordova_fail_callback(callback_id, FALSE, CB_GENERIC_ERROR, L"{code:SQLError.SYNTAX_ERR,message:\"Syntax error\"}");
- goto out;
- }
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- cordova_fail_callback(callback_id, FALSE, CB_GENERIC_ERROR, L"{code:SQLError.DATABASE_ERR,message:\"Database error\"}");
- goto out;
- }
-
- text_buf_append(response, L"{id:'");
- text_buf_append(response, tx_id);
- text_buf_append(response, L"',data:''}");
-
- cordova_success_callback(callback_id, FALSE, text_buf_get(response));
- } else {
- JsonItem sql_arg;
- int db_res = SQLITE_OK;
- int index = 1;
-
- // Prepare
- if (sqlite3_prepare16_v2(db, command, wcslen(command) * sizeof(wchar_t), &stmt, NULL) != SQLITE_OK) {
- cordova_fail_callback(callback_id, FALSE, CB_GENERIC_ERROR, L"{code:SQLError.SYNTAX_ERR,message:\"Syntax error\"}");
- goto out;
- }
-
- // Bind arguments
- item = json_array_get_next(item);
- sql_arg = json_get_array_value(item);
- while (sql_arg != NULL) {
- switch (json_get_value_type(sql_arg)) {
- case JSON_VALUE_EMPTY:
- break;
- case JSON_VALUE_INT:
- db_res = sqlite3_bind_int(stmt, index, json_get_int_value(sql_arg));
- break;
- case JSON_VALUE_DOUBLE:
- db_res = sqlite3_bind_double(stmt, index, json_get_double_value(sql_arg));
- break;
- case JSON_VALUE_STRING:
- {
- wchar_t *str = json_get_string_value(sql_arg);
- db_res = sqlite3_bind_text16(stmt, index, str, wcslen(str) * sizeof(wchar_t), NULL);
- free(str);
- break;
- }
- case JSON_VALUE_NULL:
- db_res = sqlite3_bind_null(stmt, index);
- break;
- default:
- cordova_fail_callback(callback_id, FALSE, CB_GENERIC_ERROR, L"{code:SQLError.SYNTAX_ERR,message:\"Syntax error\"}");
- goto out;
- }
- if (db_res != SQLITE_OK) {
- cordova_fail_callback(callback_id, FALSE, CB_GENERIC_ERROR,L"{code:SQLError.SYNTAX_ERR,message:\"Syntax error\"}");
- goto out;
- }
-
- sql_arg = json_array_get_next(sql_arg);
- index++;
- }
-
- // Execute & prepare response
- text_buf_append(response, L"{id:'");
- text_buf_append(response, tx_id);
- text_buf_append(response, L"',data:[");
-
- db_res = sqlite3_step(stmt);
- if (db_res == SQLITE_ROW) {
- do {
- int j;
-
- text_buf_append(response, L"{");
- for (j = 0; j < sqlite3_column_count(stmt); j++) {
- if (j > 0)
- text_buf_append(response, L",");
-
- text_buf_append(response, L"\"");
- text_buf_append(response, (wchar_t *) sqlite3_column_name16(stmt, j));
- text_buf_append(response, L"\":");
- if (sqlite3_column_type(stmt, j) == SQLITE_INTEGER) {
- static wchar_t number[20];
- swprintf(number, 19, L"%d", sqlite3_column_int(stmt, j));
- text_buf_append(response, number);
- } else if (sqlite3_column_type(stmt, j) == SQLITE_TEXT) {
- text_buf_append(response, L"\"");
- text_buf_append(response, (wchar_t *) sqlite3_column_text16(stmt, j));
- text_buf_append(response, L"\"");
- } else if (sqlite3_column_type(stmt, j) == SQLITE_NULL) {
- text_buf_append(response, L"null");
- } else {
- cordova_fail_callback(callback_id, FALSE, CB_GENERIC_ERROR, L"{code:SQLError.DATABASE_ERR,message:\"Database error\"}");
- goto out;
- }
- }
- text_buf_append(response, L"}");
-
- // Next
- db_res = sqlite3_step(stmt);
- if (db_res == SQLITE_ROW)
- text_buf_append(response, L",");
- } while (db_res == SQLITE_ROW);
- } else if (db_res != SQLITE_DONE) {
- cordova_fail_callback(callback_id, FALSE, CB_GENERIC_ERROR, L"{code:SQLError.DATABASE_ERR,message:\"Database error\"}");
- goto out;
- }
-
- text_buf_append(response, L"]}");
-
- // Success
- cordova_success_callback(callback_id, FALSE, text_buf_get(response));
- }
-
-out:
- json_free_args(array);
- if (stmt)
- sqlite3_finalize(stmt);
- text_buf_free(response);
- if (tx_id)
- free(tx_id);
- if (command)
- free(command);
-
- return res;
-}
-
-HRESULT storage_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- if (!wcscmp(action, L"openDatabase"))
- return open_database(callback_id, args, result);
- if (!wcscmp(action, L"removeDatabase"))
- return remove_database(callback_id, args);
- if (!wcscmp(action, L"executeSql"))
- return execute_sql(callback_id, args);
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-void storage_close(void)
-{
- while (db_list != NULL) {
- CordovaDb *item;
-
- sqlite3_close(db_list->db);
- free(db_list->name);
-
- item = db_list;
- db_list = db_list->next;
-
- free(item);
- }
-}
-
-DEFINE_CORDOVA_MODULE(Storage, L"Storage", storage_exec, NULL, storage_close)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/storage.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/storage.h b/windows7/Cordova/storage.h
deleted file mode 100644
index 311092f..0000000
--- a/windows7/Cordova/storage.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include "shell.h"
-
-DECLARE_CORDOVA_MODULE(Storage)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/toolbar.bmp
----------------------------------------------------------------------
diff --git a/windows7/Cordova/toolbar.bmp b/windows7/Cordova/toolbar.bmp
deleted file mode 100644
index 1c3965f..0000000
Binary files a/windows7/Cordova/toolbar.bmp and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/accel_game.css
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/accel_game.css b/windows7/Cordova/www/accel_game.css
deleted file mode 100644
index e6672fd..0000000
--- a/windows7/Cordova/www/accel_game.css
+++ /dev/null
@@ -1,23 +0,0 @@
-body{
-background-color:#000;
-}
-
-#box{
-width: 500px;
-height: 500px;
-border: 1px solid #333;
-margin: 0 auto;
-background: #FFF;
-text-align: center;
-}
-
-h1 {
-text-align: center;
-font-variant: small-caps;
-color: #FFF;
-}
-
-#valueX, #valueY, #valueZ, #valueL, #valueR,#valueU,#valueD {
-font-variant: small-caps;
-color: #FFF;
-}
[06/10] Removed Windows7 which is now in it's own branch. This closes
#29
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/lib/sqlite/sqlite3.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/lib/sqlite/sqlite3.c b/windows7/Cordova/lib/sqlite/sqlite3.c
deleted file mode 100644
index f69816e..0000000
--- a/windows7/Cordova/lib/sqlite/sqlite3.c
+++ /dev/null
@@ -1,138243 +0,0 @@
-/******************************************************************************
-** This file is an amalgamation of many separate C source files from SQLite
-** version 3.7.13. By combining all the individual C code files into this
-** single large file, the entire code can be compiled as a single translation
-** unit. This allows many compilers to do optimizations that would not be
-** possible if the files were compiled separately. Performance improvements
-** of 5% or more are commonly seen when SQLite is compiled as a single
-** translation unit.
-**
-** This file is all you need to compile SQLite. To use SQLite in other
-** programs, you need this file and the "sqlite3.h" header file that defines
-** the programming interface to the SQLite library. (If you do not have
-** the "sqlite3.h" header file at hand, you will find a copy embedded within
-** the text of this file. Search for "Begin file sqlite3.h" to find the start
-** of the embedded sqlite3.h header file.) Additional code files may be needed
-** if you want a wrapper to interface SQLite with your choice of programming
-** language. The code for the "sqlite3" command-line shell is also in a
-** separate file. This file contains only code for the core SQLite library.
-*/
-#define SQLITE_CORE 1
-#define SQLITE_AMALGAMATION 1
-#ifndef SQLITE_PRIVATE
-# define SQLITE_PRIVATE static
-#endif
-#ifndef SQLITE_API
-# define SQLITE_API
-#endif
-/************** Begin file sqliteInt.h ***************************************/
-/*
-** 2001 September 15
-**
-** The author disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
-**
-*************************************************************************
-** Internal interface definitions for SQLite.
-**
-*/
-#ifndef _SQLITEINT_H_
-#define _SQLITEINT_H_
-
-/*
-** These #defines should enable >2GB file support on POSIX if the
-** underlying operating system supports it. If the OS lacks
-** large file support, or if the OS is windows, these should be no-ops.
-**
-** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any
-** system #includes. Hence, this block of code must be the very first
-** code in all source files.
-**
-** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
-** on the compiler command line. This is necessary if you are compiling
-** on a recent machine (ex: Red Hat 7.2) but you want your code to work
-** on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2
-** without this option, LFS is enable. But LFS does not exist in the kernel
-** in Red Hat 6.0, so the code won't work. Hence, for maximum binary
-** portability you should omit LFS.
-**
-** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later.
-*/
-#ifndef SQLITE_DISABLE_LFS
-# define _LARGE_FILE 1
-# ifndef _FILE_OFFSET_BITS
-# define _FILE_OFFSET_BITS 64
-# endif
-# define _LARGEFILE_SOURCE 1
-#endif
-
-/*
-** Include the configuration header output by 'configure' if we're using the
-** autoconf-based build
-*/
-#ifdef _HAVE_SQLITE_CONFIG_H
-#include "config.h"
-#endif
-
-/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
-/************** Begin file sqliteLimit.h *************************************/
-/*
-** 2007 May 7
-**
-** The author disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
-**
-*************************************************************************
-**
-** This file defines various limits of what SQLite can process.
-*/
-
-/*
-** The maximum length of a TEXT or BLOB in bytes. This also
-** limits the size of a row in a table or index.
-**
-** The hard limit is the ability of a 32-bit signed integer
-** to count the size: 2^31-1 or 2147483647.
-*/
-#ifndef SQLITE_MAX_LENGTH
-# define SQLITE_MAX_LENGTH 1000000000
-#endif
-
-/*
-** This is the maximum number of
-**
-** * Columns in a table
-** * Columns in an index
-** * Columns in a view
-** * Terms in the SET clause of an UPDATE statement
-** * Terms in the result set of a SELECT statement
-** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
-** * Terms in the VALUES clause of an INSERT statement
-**
-** The hard upper limit here is 32676. Most database people will
-** tell you that in a well-normalized database, you usually should
-** not have more than a dozen or so columns in any table. And if
-** that is the case, there is no point in having more than a few
-** dozen values in any of the other situations described above.
-*/
-#ifndef SQLITE_MAX_COLUMN
-# define SQLITE_MAX_COLUMN 2000
-#endif
-
-/*
-** The maximum length of a single SQL statement in bytes.
-**
-** It used to be the case that setting this value to zero would
-** turn the limit off. That is no longer true. It is not possible
-** to turn this limit off.
-*/
-#ifndef SQLITE_MAX_SQL_LENGTH
-# define SQLITE_MAX_SQL_LENGTH 1000000000
-#endif
-
-/*
-** The maximum depth of an expression tree. This is limited to
-** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might
-** want to place more severe limits on the complexity of an
-** expression.
-**
-** A value of 0 used to mean that the limit was not enforced.
-** But that is no longer true. The limit is now strictly enforced
-** at all times.
-*/
-#ifndef SQLITE_MAX_EXPR_DEPTH
-# define SQLITE_MAX_EXPR_DEPTH 1000
-#endif
-
-/*
-** The maximum number of terms in a compound SELECT statement.
-** The code generator for compound SELECT statements does one
-** level of recursion for each term. A stack overflow can result
-** if the number of terms is too large. In practice, most SQL
-** never has more than 3 or 4 terms. Use a value of 0 to disable
-** any limit on the number of terms in a compount SELECT.
-*/
-#ifndef SQLITE_MAX_COMPOUND_SELECT
-# define SQLITE_MAX_COMPOUND_SELECT 500
-#endif
-
-/*
-** The maximum number of opcodes in a VDBE program.
-** Not currently enforced.
-*/
-#ifndef SQLITE_MAX_VDBE_OP
-# define SQLITE_MAX_VDBE_OP 25000
-#endif
-
-/*
-** The maximum number of arguments to an SQL function.
-*/
-#ifndef SQLITE_MAX_FUNCTION_ARG
-# define SQLITE_MAX_FUNCTION_ARG 127
-#endif
-
-/*
-** The maximum number of in-memory pages to use for the main database
-** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE
-*/
-#ifndef SQLITE_DEFAULT_CACHE_SIZE
-# define SQLITE_DEFAULT_CACHE_SIZE 2000
-#endif
-#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
-# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
-#endif
-
-/*
-** The default number of frames to accumulate in the log file before
-** checkpointing the database in WAL mode.
-*/
-#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
-# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000
-#endif
-
-/*
-** The maximum number of attached databases. This must be between 0
-** and 62. The upper bound on 62 is because a 64-bit integer bitmap
-** is used internally to track attached databases.
-*/
-#ifndef SQLITE_MAX_ATTACHED
-# define SQLITE_MAX_ATTACHED 10
-#endif
-
-
-/*
-** The maximum value of a ?nnn wildcard that the parser will accept.
-*/
-#ifndef SQLITE_MAX_VARIABLE_NUMBER
-# define SQLITE_MAX_VARIABLE_NUMBER 999
-#endif
-
-/* Maximum page size. The upper bound on this value is 65536. This a limit
-** imposed by the use of 16-bit offsets within each page.
-**
-** Earlier versions of SQLite allowed the user to change this value at
-** compile time. This is no longer permitted, on the grounds that it creates
-** a library that is technically incompatible with an SQLite library
-** compiled with a different limit. If a process operating on a database
-** with a page-size of 65536 bytes crashes, then an instance of SQLite
-** compiled with the default page-size limit will not be able to rollback
-** the aborted transaction. This could lead to database corruption.
-*/
-#ifdef SQLITE_MAX_PAGE_SIZE
-# undef SQLITE_MAX_PAGE_SIZE
-#endif
-#define SQLITE_MAX_PAGE_SIZE 65536
-
-
-/*
-** The default size of a database page.
-*/
-#ifndef SQLITE_DEFAULT_PAGE_SIZE
-# define SQLITE_DEFAULT_PAGE_SIZE 1024
-#endif
-#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
-# undef SQLITE_DEFAULT_PAGE_SIZE
-# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
-#endif
-
-/*
-** Ordinarily, if no value is explicitly provided, SQLite creates databases
-** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
-** device characteristics (sector-size and atomic write() support),
-** SQLite may choose a larger value. This constant is the maximum value
-** SQLite will choose on its own.
-*/
-#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
-# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
-#endif
-#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
-# undef SQLITE_MAX_DEFAULT_PAGE_SIZE
-# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
-#endif
-
-
-/*
-** Maximum number of pages in one database file.
-**
-** This is really just the default value for the max_page_count pragma.
-** This value can be lowered (or raised) at run-time using that the
-** max_page_count macro.
-*/
-#ifndef SQLITE_MAX_PAGE_COUNT
-# define SQLITE_MAX_PAGE_COUNT 1073741823
-#endif
-
-/*
-** Maximum length (in bytes) of the pattern in a LIKE or GLOB
-** operator.
-*/
-#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
-# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
-#endif
-
-/*
-** Maximum depth of recursion for triggers.
-**
-** A value of 1 means that a trigger program will not be able to itself
-** fire any triggers. A value of 0 means that no trigger programs at all
-** may be executed.
-*/
-#ifndef SQLITE_MAX_TRIGGER_DEPTH
-# define SQLITE_MAX_TRIGGER_DEPTH 1000
-#endif
-
-/************** End of sqliteLimit.h *****************************************/
-/************** Continuing where we left off in sqliteInt.h ******************/
-
-/* Disable nuisance warnings on Borland compilers */
-#if defined(__BORLANDC__)
-#pragma warn -rch /* unreachable code */
-#pragma warn -ccc /* Condition is always true or false */
-#pragma warn -aus /* Assigned value is never used */
-#pragma warn -csu /* Comparing signed and unsigned */
-#pragma warn -spa /* Suspicious pointer arithmetic */
-#endif
-
-/* Needed for various definitions... */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-#endif
-
-/*
-** Include standard header files as necessary
-*/
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-
-/*
-** The following macros are used to cast pointers to integers and
-** integers to pointers. The way you do this varies from one compiler
-** to the next, so we have developed the following set of #if statements
-** to generate appropriate macros for a wide range of compilers.
-**
-** The correct "ANSI" way to do this is to use the intptr_t type.
-** Unfortunately, that typedef is not available on all compilers, or
-** if it is available, it requires an #include of specific headers
-** that vary from one machine to the next.
-**
-** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
-** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
-** So we have to define the macros in different ways depending on the
-** compiler.
-*/
-#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
-# define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
-# define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
-#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
-# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
-# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
-#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
-# define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
-# define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
-#else /* Generates a warning - but it always works */
-# define SQLITE_INT_TO_PTR(X) ((void*)(X))
-# define SQLITE_PTR_TO_INT(X) ((int)(X))
-#endif
-
-/*
-** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
-** 0 means mutexes are permanently disable and the library is never
-** threadsafe. 1 means the library is serialized which is the highest
-** level of threadsafety. 2 means the libary is multithreaded - multiple
-** threads can use SQLite as long as no two threads try to use the same
-** database connection at the same time.
-**
-** Older versions of SQLite used an optional THREADSAFE macro.
-** We support that for legacy.
-*/
-#if !defined(SQLITE_THREADSAFE)
-#if defined(THREADSAFE)
-# define SQLITE_THREADSAFE THREADSAFE
-#else
-# define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */
-#endif
-#endif
-
-/*
-** Powersafe overwrite is on by default. But can be turned off using
-** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option.
-*/
-#ifndef SQLITE_POWERSAFE_OVERWRITE
-# define SQLITE_POWERSAFE_OVERWRITE 1
-#endif
-
-/*
-** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
-** It determines whether or not the features related to
-** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
-** be overridden at runtime using the sqlite3_config() API.
-*/
-#if !defined(SQLITE_DEFAULT_MEMSTATUS)
-# define SQLITE_DEFAULT_MEMSTATUS 1
-#endif
-
-/*
-** Exactly one of the following macros must be defined in order to
-** specify which memory allocation subsystem to use.
-**
-** SQLITE_SYSTEM_MALLOC // Use normal system malloc()
-** SQLITE_WIN32_MALLOC // Use Win32 native heap API
-** SQLITE_MEMDEBUG // Debugging version of system malloc()
-**
-** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
-** assert() macro is enabled, each call into the Win32 native heap subsystem
-** will cause HeapValidate to be called. If heap validation should fail, an
-** assertion will be triggered.
-**
-** (Historical note: There used to be several other options, but we've
-** pared it down to just these three.)
-**
-** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
-** the default.
-*/
-#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_WIN32_MALLOC)+defined(SQLITE_MEMDEBUG)>1
-# error "At most one of the following compile-time configuration options\
- is allows: SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG"
-#endif
-#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_WIN32_MALLOC)+defined(SQLITE_MEMDEBUG)==0
-# define SQLITE_SYSTEM_MALLOC 1
-#endif
-
-/*
-** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the
-** sizes of memory allocations below this value where possible.
-*/
-#if !defined(SQLITE_MALLOC_SOFT_LIMIT)
-# define SQLITE_MALLOC_SOFT_LIMIT 1024
-#endif
-
-/*
-** We need to define _XOPEN_SOURCE as follows in order to enable
-** recursive mutexes on most Unix systems. But Mac OS X is different.
-** The _XOPEN_SOURCE define causes problems for Mac OS X we are told,
-** so it is omitted there. See ticket #2673.
-**
-** Later we learn that _XOPEN_SOURCE is poorly or incorrectly
-** implemented on some systems. So we avoid defining it at all
-** if it is already defined or if it is unneeded because we are
-** not doing a threadsafe build. Ticket #2681.
-**
-** See also ticket #2741.
-*/
-#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__) && SQLITE_THREADSAFE
-# define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */
-#endif
-
-/*
-** The TCL headers are only needed when compiling the TCL bindings.
-*/
-#if defined(SQLITE_TCL) || defined(TCLSH)
-# include <tcl.h>
-#endif
-
-/*
-** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
-** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
-** make it true by defining or undefining NDEBUG.
-**
-** Setting NDEBUG makes the code smaller and run faster by disabling the
-** number assert() statements in the code. So we want the default action
-** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
-** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
-** feature.
-*/
-#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
-# define NDEBUG 1
-#endif
-#if defined(NDEBUG) && defined(SQLITE_DEBUG)
-# undef NDEBUG
-#endif
-
-/*
-** The testcase() macro is used to aid in coverage testing. When
-** doing coverage testing, the condition inside the argument to
-** testcase() must be evaluated both true and false in order to
-** get full branch coverage. The testcase() macro is inserted
-** to help ensure adequate test coverage in places where simple
-** condition/decision coverage is inadequate. For example, testcase()
-** can be used to make sure boundary values are tested. For
-** bitmask tests, testcase() can be used to make sure each bit
-** is significant and used at least once. On switch statements
-** where multiple cases go to the same block of code, testcase()
-** can insure that all cases are evaluated.
-**
-*/
-#ifdef SQLITE_COVERAGE_TEST
-SQLITE_PRIVATE void sqlite3Coverage(int);
-# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
-#else
-# define testcase(X)
-#endif
-
-/*
-** The TESTONLY macro is used to enclose variable declarations or
-** other bits of code that are needed to support the arguments
-** within testcase() and assert() macros.
-*/
-#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)
-# define TESTONLY(X) X
-#else
-# define TESTONLY(X)
-#endif
-
-/*
-** Sometimes we need a small amount of code such as a variable initialization
-** to setup for a later assert() statement. We do not want this code to
-** appear when assert() is disabled. The following macro is therefore
-** used to contain that setup code. The "VVA" acronym stands for
-** "Verification, Validation, and Accreditation". In other words, the
-** code within VVA_ONLY() will only run during verification processes.
-*/
-#ifndef NDEBUG
-# define VVA_ONLY(X) X
-#else
-# define VVA_ONLY(X)
-#endif
-
-/*
-** The ALWAYS and NEVER macros surround boolean expressions which
-** are intended to always be true or false, respectively. Such
-** expressions could be omitted from the code completely. But they
-** are included in a few cases in order to enhance the resilience
-** of SQLite to unexpected behavior - to make the code "self-healing"
-** or "ductile" rather than being "brittle" and crashing at the first
-** hint of unplanned behavior.
-**
-** In other words, ALWAYS and NEVER are added for defensive code.
-**
-** When doing coverage testing ALWAYS and NEVER are hard-coded to
-** be true and false so that the unreachable code then specify will
-** not be counted as untested code.
-*/
-#if defined(SQLITE_COVERAGE_TEST)
-# define ALWAYS(X) (1)
-# define NEVER(X) (0)
-#elif !defined(NDEBUG)
-# define ALWAYS(X) ((X)?1:(assert(0),0))
-# define NEVER(X) ((X)?(assert(0),1):0)
-#else
-# define ALWAYS(X) (X)
-# define NEVER(X) (X)
-#endif
-
-/*
-** Return true (non-zero) if the input is a integer that is too large
-** to fit in 32-bits. This macro is used inside of various testcase()
-** macros to verify that we have tested SQLite for large-file support.
-*/
-#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
-
-/*
-** The macro unlikely() is a hint that surrounds a boolean
-** expression that is usually false. Macro likely() surrounds
-** a boolean expression that is usually true. GCC is able to
-** use these hints to generate better code, sometimes.
-*/
-#if defined(__GNUC__) && 0
-# define likely(X) __builtin_expect((X),1)
-# define unlikely(X) __builtin_expect((X),0)
-#else
-# define likely(X) !!(X)
-# define unlikely(X) !!(X)
-#endif
-
-/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
-/************** Begin file sqlite3.h *****************************************/
-/*
-** 2001 September 15
-**
-** The author disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
-**
-*************************************************************************
-** This header file defines the interface that the SQLite library
-** presents to client programs. If a C-function, structure, datatype,
-** or constant definition does not appear in this file, then it is
-** not a published API of SQLite, is subject to change without
-** notice, and should not be referenced by programs that use SQLite.
-**
-** Some of the definitions that are in this file are marked as
-** "experimental". Experimental interfaces are normally new
-** features recently added to SQLite. We do not anticipate changes
-** to experimental interfaces but reserve the right to make minor changes
-** if experience from use "in the wild" suggest such changes are prudent.
-**
-** The official C-language API documentation for SQLite is derived
-** from comments in this file. This file is the authoritative source
-** on how SQLite interfaces are suppose to operate.
-**
-** The name of this file under configuration management is "sqlite.h.in".
-** The makefile makes some minor changes to this file (such as inserting
-** the version number) and changes its name to "sqlite3.h" as
-** part of the build process.
-*/
-#ifndef _SQLITE3_H_
-#define _SQLITE3_H_
-#include <stdarg.h> /* Needed for the definition of va_list */
-
-/*
-** Make sure we can call this stuff from C++.
-*/
-#if 0
-extern "C" {
-#endif
-
-
-/*
-** Add the ability to override 'extern'
-*/
-#ifndef SQLITE_EXTERN
-# define SQLITE_EXTERN extern
-#endif
-
-#ifndef SQLITE_API
-# define SQLITE_API
-#endif
-
-
-/*
-** These no-op macros are used in front of interfaces to mark those
-** interfaces as either deprecated or experimental. New applications
-** should not use deprecated interfaces - they are support for backwards
-** compatibility only. Application writers should be aware that
-** experimental interfaces are subject to change in point releases.
-**
-** These macros used to resolve to various kinds of compiler magic that
-** would generate warning messages when they were used. But that
-** compiler magic ended up generating such a flurry of bug reports
-** that we have taken it all out and gone back to using simple
-** noop macros.
-*/
-#define SQLITE_DEPRECATED
-#define SQLITE_EXPERIMENTAL
-
-/*
-** Ensure these symbols were not defined by some previous header file.
-*/
-#ifdef SQLITE_VERSION
-# undef SQLITE_VERSION
-#endif
-#ifdef SQLITE_VERSION_NUMBER
-# undef SQLITE_VERSION_NUMBER
-#endif
-
-/*
-** CAPI3REF: Compile-Time Library Version Numbers
-**
-** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
-** evaluates to a string literal that is the SQLite version in the
-** format "X.Y.Z" where X is the major version number (always 3 for
-** SQLite3) and Y is the minor version number and Z is the release number.)^
-** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
-** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
-** numbers used in [SQLITE_VERSION].)^
-** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
-** be larger than the release from which it is derived. Either Y will
-** be held constant and Z will be incremented or else Y will be incremented
-** and Z will be reset to zero.
-**
-** Since version 3.6.18, SQLite source code has been stored in the
-** <a href="http://www.fossil-scm.org/">Fossil configuration management
-** system</a>. ^The SQLITE_SOURCE_ID macro evaluates to
-** a string which identifies a particular check-in of SQLite
-** within its configuration management system. ^The SQLITE_SOURCE_ID
-** string contains the date and time of the check-in (UTC) and an SHA1
-** hash of the entire source tree.
-**
-** See also: [sqlite3_libversion()],
-** [sqlite3_libversion_number()], [sqlite3_sourceid()],
-** [sqlite_version()] and [sqlite_source_id()].
-*/
-#define SQLITE_VERSION "3.7.13"
-#define SQLITE_VERSION_NUMBER 3007013
-#define SQLITE_SOURCE_ID "2012-06-11 02:05:22 f5b5a13f7394dc143aa136f1d4faba6839eaa6dc"
-
-/*
-** CAPI3REF: Run-Time Library Version Numbers
-** KEYWORDS: sqlite3_version, sqlite3_sourceid
-**
-** These interfaces provide the same information as the [SQLITE_VERSION],
-** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
-** but are associated with the library instead of the header file. ^(Cautious
-** programmers might include assert() statements in their application to
-** verify that values returned by these interfaces match the macros in
-** the header, and thus insure that the application is
-** compiled with matching library and header files.
-**
-** <blockquote><pre>
-** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
-** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
-** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
-** </pre></blockquote>)^
-**
-** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
-** macro. ^The sqlite3_libversion() function returns a pointer to the
-** to the sqlite3_version[] string constant. The sqlite3_libversion()
-** function is provided for use in DLLs since DLL users usually do not have
-** direct access to string constants within the DLL. ^The
-** sqlite3_libversion_number() function returns an integer equal to
-** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns
-** a pointer to a string constant whose value is the same as the
-** [SQLITE_SOURCE_ID] C preprocessor macro.
-**
-** See also: [sqlite_version()] and [sqlite_source_id()].
-*/
-SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
-SQLITE_API const char *sqlite3_libversion(void);
-SQLITE_API const char *sqlite3_sourceid(void);
-SQLITE_API int sqlite3_libversion_number(void);
-
-/*
-** CAPI3REF: Run-Time Library Compilation Options Diagnostics
-**
-** ^The sqlite3_compileoption_used() function returns 0 or 1
-** indicating whether the specified option was defined at
-** compile time. ^The SQLITE_ prefix may be omitted from the
-** option name passed to sqlite3_compileoption_used().
-**
-** ^The sqlite3_compileoption_get() function allows iterating
-** over the list of options that were defined at compile time by
-** returning the N-th compile time option string. ^If N is out of range,
-** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_
-** prefix is omitted from any strings returned by
-** sqlite3_compileoption_get().
-**
-** ^Support for the diagnostic functions sqlite3_compileoption_used()
-** and sqlite3_compileoption_get() may be omitted by specifying the
-** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
-**
-** See also: SQL functions [sqlite_compileoption_used()] and
-** [sqlite_compileoption_get()] and the [compile_options pragma].
-*/
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
-SQLITE_API const char *sqlite3_compileoption_get(int N);
-#endif
-
-/*
-** CAPI3REF: Test To See If The Library Is Threadsafe
-**
-** ^The sqlite3_threadsafe() function returns zero if and only if
-** SQLite was compiled with mutexing code omitted due to the
-** [SQLITE_THREADSAFE] compile-time option being set to 0.
-**
-** SQLite can be compiled with or without mutexes. When
-** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
-** are enabled and SQLite is threadsafe. When the
-** [SQLITE_THREADSAFE] macro is 0,
-** the mutexes are omitted. Without the mutexes, it is not safe
-** to use SQLite concurrently from more than one thread.
-**
-** Enabling mutexes incurs a measurable performance penalty.
-** So if speed is of utmost importance, it makes sense to disable
-** the mutexes. But for maximum safety, mutexes should be enabled.
-** ^The default behavior is for mutexes to be enabled.
-**
-** This interface can be used by an application to make sure that the
-** version of SQLite that it is linking against was compiled with
-** the desired setting of the [SQLITE_THREADSAFE] macro.
-**
-** This interface only reports on the compile-time mutex setting
-** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
-** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
-** can be fully or partially disabled using a call to [sqlite3_config()]
-** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
-** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the
-** sqlite3_threadsafe() function shows only the compile-time setting of
-** thread safety, not any run-time changes to that setting made by
-** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
-** is unchanged by calls to sqlite3_config().)^
-**
-** See the [threading mode] documentation for additional information.
-*/
-SQLITE_API int sqlite3_threadsafe(void);
-
-/*
-** CAPI3REF: Database Connection Handle
-** KEYWORDS: {database connection} {database connections}
-**
-** Each open SQLite database is represented by a pointer to an instance of
-** the opaque structure named "sqlite3". It is useful to think of an sqlite3
-** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
-** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
-** is its destructor. There are many other interfaces (such as
-** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
-** [sqlite3_busy_timeout()] to name but three) that are methods on an
-** sqlite3 object.
-*/
-typedef struct sqlite3 sqlite3;
-
-/*
-** CAPI3REF: 64-Bit Integer Types
-** KEYWORDS: sqlite_int64 sqlite_uint64
-**
-** Because there is no cross-platform way to specify 64-bit integer types
-** SQLite includes typedefs for 64-bit signed and unsigned integers.
-**
-** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
-** The sqlite_int64 and sqlite_uint64 types are supported for backwards
-** compatibility only.
-**
-** ^The sqlite3_int64 and sqlite_int64 types can store integer values
-** between -9223372036854775808 and +9223372036854775807 inclusive. ^The
-** sqlite3_uint64 and sqlite_uint64 types can store integer values
-** between 0 and +18446744073709551615 inclusive.
-*/
-#ifdef SQLITE_INT64_TYPE
- typedef SQLITE_INT64_TYPE sqlite_int64;
- typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
-#elif defined(_MSC_VER) || defined(__BORLANDC__)
- typedef __int64 sqlite_int64;
- typedef unsigned __int64 sqlite_uint64;
-#else
- typedef long long int sqlite_int64;
- typedef unsigned long long int sqlite_uint64;
-#endif
-typedef sqlite_int64 sqlite3_int64;
-typedef sqlite_uint64 sqlite3_uint64;
-
-/*
-** If compiling for a processor that lacks floating point support,
-** substitute integer for floating-point.
-*/
-#ifdef SQLITE_OMIT_FLOATING_POINT
-# define double sqlite3_int64
-#endif
-
-/*
-** CAPI3REF: Closing A Database Connection
-**
-** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.
-** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is
-** successfully destroyed and all associated resources are deallocated.
-**
-** Applications must [sqlite3_finalize | finalize] all [prepared statements]
-** and [sqlite3_blob_close | close] all [BLOB handles] associated with
-** the [sqlite3] object prior to attempting to close the object. ^If
-** sqlite3_close() is called on a [database connection] that still has
-** outstanding [prepared statements] or [BLOB handles], then it returns
-** SQLITE_BUSY.
-**
-** ^If [sqlite3_close()] is invoked while a transaction is open,
-** the transaction is automatically rolled back.
-**
-** The C parameter to [sqlite3_close(C)] must be either a NULL
-** pointer or an [sqlite3] object pointer obtained
-** from [sqlite3_open()], [sqlite3_open16()], or
-** [sqlite3_open_v2()], and not previously closed.
-** ^Calling sqlite3_close() with a NULL pointer argument is a
-** harmless no-op.
-*/
-SQLITE_API int sqlite3_close(sqlite3 *);
-
-/*
-** The type for a callback function.
-** This is legacy and deprecated. It is included for historical
-** compatibility and is not documented.
-*/
-typedef int (*sqlite3_callback)(void*,int,char**, char**);
-
-/*
-** CAPI3REF: One-Step Query Execution Interface
-**
-** The sqlite3_exec() interface is a convenience wrapper around
-** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
-** that allows an application to run multiple statements of SQL
-** without having to use a lot of C code.
-**
-** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
-** semicolon-separate SQL statements passed into its 2nd argument,
-** in the context of the [database connection] passed in as its 1st
-** argument. ^If the callback function of the 3rd argument to
-** sqlite3_exec() is not NULL, then it is invoked for each result row
-** coming out of the evaluated SQL statements. ^The 4th argument to
-** sqlite3_exec() is relayed through to the 1st argument of each
-** callback invocation. ^If the callback pointer to sqlite3_exec()
-** is NULL, then no callback is ever invoked and result rows are
-** ignored.
-**
-** ^If an error occurs while evaluating the SQL statements passed into
-** sqlite3_exec(), then execution of the current statement stops and
-** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec()
-** is not NULL then any error message is written into memory obtained
-** from [sqlite3_malloc()] and passed back through the 5th parameter.
-** To avoid memory leaks, the application should invoke [sqlite3_free()]
-** on error message strings returned through the 5th parameter of
-** of sqlite3_exec() after the error message string is no longer needed.
-** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
-** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
-** NULL before returning.
-**
-** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
-** routine returns SQLITE_ABORT without invoking the callback again and
-** without running any subsequent SQL statements.
-**
-** ^The 2nd argument to the sqlite3_exec() callback function is the
-** number of columns in the result. ^The 3rd argument to the sqlite3_exec()
-** callback is an array of pointers to strings obtained as if from
-** [sqlite3_column_text()], one for each column. ^If an element of a
-** result row is NULL then the corresponding string pointer for the
-** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the
-** sqlite3_exec() callback is an array of pointers to strings where each
-** entry represents the name of corresponding result column as obtained
-** from [sqlite3_column_name()].
-**
-** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
-** to an empty string, or a pointer that contains only whitespace and/or
-** SQL comments, then no SQL statements are evaluated and the database
-** is not changed.
-**
-** Restrictions:
-**
-** <ul>
-** <li> The application must insure that the 1st parameter to sqlite3_exec()
-** is a valid and open [database connection].
-** <li> The application must not close [database connection] specified by
-** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
-** <li> The application must not modify the SQL statement text passed into
-** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
-** </ul>
-*/
-SQLITE_API int sqlite3_exec(
- sqlite3*, /* An open database */
- const char *sql, /* SQL to be evaluated */
- int (*callback)(void*,int,char**,char**), /* Callback function */
- void *, /* 1st argument to callback */
- char **errmsg /* Error msg written here */
-);
-
-/*
-** CAPI3REF: Result Codes
-** KEYWORDS: SQLITE_OK {error code} {error codes}
-** KEYWORDS: {result code} {result codes}
-**
-** Many SQLite functions return an integer result code from the set shown
-** here in order to indicate success or failure.
-**
-** New error codes may be added in future versions of SQLite.
-**
-** See also: [SQLITE_IOERR_READ | extended result codes],
-** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].
-*/
-#define SQLITE_OK 0 /* Successful result */
-/* beginning-of-error-codes */
-#define SQLITE_ERROR 1 /* SQL error or missing database */
-#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
-#define SQLITE_PERM 3 /* Access permission denied */
-#define SQLITE_ABORT 4 /* Callback routine requested an abort */
-#define SQLITE_BUSY 5 /* The database file is locked */
-#define SQLITE_LOCKED 6 /* A table in the database is locked */
-#define SQLITE_NOMEM 7 /* A malloc() failed */
-#define SQLITE_READONLY 8 /* Attempt to write a readonly database */
-#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/
-#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
-#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
-#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
-#define SQLITE_FULL 13 /* Insertion failed because database is full */
-#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
-#define SQLITE_PROTOCOL 15 /* Database lock protocol error */
-#define SQLITE_EMPTY 16 /* Database is empty */
-#define SQLITE_SCHEMA 17 /* The database schema changed */
-#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
-#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
-#define SQLITE_MISMATCH 20 /* Data type mismatch */
-#define SQLITE_MISUSE 21 /* Library used incorrectly */
-#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
-#define SQLITE_AUTH 23 /* Authorization denied */
-#define SQLITE_FORMAT 24 /* Auxiliary database format error */
-#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
-#define SQLITE_NOTADB 26 /* File opened that is not a database file */
-#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
-#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
-/* end-of-error-codes */
-
-/*
-** CAPI3REF: Extended Result Codes
-** KEYWORDS: {extended error code} {extended error codes}
-** KEYWORDS: {extended result code} {extended result codes}
-**
-** In its default configuration, SQLite API routines return one of 26 integer
-** [SQLITE_OK | result codes]. However, experience has shown that many of
-** these result codes are too coarse-grained. They do not provide as
-** much information about problems as programmers might like. In an effort to
-** address this, newer versions of SQLite (version 3.3.8 and later) include
-** support for additional result codes that provide more detailed information
-** about errors. The extended result codes are enabled or disabled
-** on a per database connection basis using the
-** [sqlite3_extended_result_codes()] API.
-**
-** Some of the available extended result codes are listed here.
-** One may expect the number of extended result codes will be expand
-** over time. Software that uses extended result codes should expect
-** to see new result codes in future releases of SQLite.
-**
-** The SQLITE_OK result code will never be extended. It will always
-** be exactly zero.
-*/
-#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
-#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
-#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
-#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
-#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
-#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8))
-#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))
-#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))
-#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))
-#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8))
-#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8))
-#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8))
-#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
-#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
-#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
-#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
-#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
-#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8))
-#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
-#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
-#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
-#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
-#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
-#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
-#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
-#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
-#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
-#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
-#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
-#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
-
-/*
-** CAPI3REF: Flags For File Open Operations
-**
-** These bit values are intended for use in the
-** 3rd parameter to the [sqlite3_open_v2()] interface and
-** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
-*/
-#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */
-#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */
-#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */
-#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_MEMORY 0x00000080 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */
-#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */
-#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */
-#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */
-#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */
-#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */
-#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */
-#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
-
-/* Reserved: 0x00F00000 */
-
-/*
-** CAPI3REF: Device Characteristics
-**
-** The xDeviceCharacteristics method of the [sqlite3_io_methods]
-** object returns an integer which is a vector of the these
-** bit values expressing I/O characteristics of the mass storage
-** device that holds the file that the [sqlite3_io_methods]
-** refers to.
-**
-** The SQLITE_IOCAP_ATOMIC property means that all writes of
-** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
-** mean that writes of blocks that are nnn bytes in size and
-** are aligned to an address which is an integer multiple of
-** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
-** that when data is appended to a file, the data is appended
-** first then the size of the file is extended, never the other
-** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
-** information is written to disk in the same order as calls
-** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
-** after reboot following a crash or power loss, the only bytes in a
-** file that were written at the application level might have changed
-** and that adjacent bytes, even bytes within the same sector are
-** guaranteed to be unchanged.
-*/
-#define SQLITE_IOCAP_ATOMIC 0x00000001
-#define SQLITE_IOCAP_ATOMIC512 0x00000002
-#define SQLITE_IOCAP_ATOMIC1K 0x00000004
-#define SQLITE_IOCAP_ATOMIC2K 0x00000008
-#define SQLITE_IOCAP_ATOMIC4K 0x00000010
-#define SQLITE_IOCAP_ATOMIC8K 0x00000020
-#define SQLITE_IOCAP_ATOMIC16K 0x00000040
-#define SQLITE_IOCAP_ATOMIC32K 0x00000080
-#define SQLITE_IOCAP_ATOMIC64K 0x00000100
-#define SQLITE_IOCAP_SAFE_APPEND 0x00000200
-#define SQLITE_IOCAP_SEQUENTIAL 0x00000400
-#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800
-#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
-
-/*
-** CAPI3REF: File Locking Levels
-**
-** SQLite uses one of these integer values as the second
-** argument to calls it makes to the xLock() and xUnlock() methods
-** of an [sqlite3_io_methods] object.
-*/
-#define SQLITE_LOCK_NONE 0
-#define SQLITE_LOCK_SHARED 1
-#define SQLITE_LOCK_RESERVED 2
-#define SQLITE_LOCK_PENDING 3
-#define SQLITE_LOCK_EXCLUSIVE 4
-
-/*
-** CAPI3REF: Synchronization Type Flags
-**
-** When SQLite invokes the xSync() method of an
-** [sqlite3_io_methods] object it uses a combination of
-** these integer values as the second argument.
-**
-** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
-** sync operation only needs to flush data to mass storage. Inode
-** information need not be flushed. If the lower four bits of the flag
-** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
-** If the lower four bits equal SQLITE_SYNC_FULL, that means
-** to use Mac OS X style fullsync instead of fsync().
-**
-** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags
-** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL
-** settings. The [synchronous pragma] determines when calls to the
-** xSync VFS method occur and applies uniformly across all platforms.
-** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how
-** energetic or rigorous or forceful the sync operations are and
-** only make a difference on Mac OSX for the default SQLite code.
-** (Third-party VFS implementations might also make the distinction
-** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the
-** operating systems natively supported by SQLite, only Mac OSX
-** cares about the difference.)
-*/
-#define SQLITE_SYNC_NORMAL 0x00002
-#define SQLITE_SYNC_FULL 0x00003
-#define SQLITE_SYNC_DATAONLY 0x00010
-
-/*
-** CAPI3REF: OS Interface Open File Handle
-**
-** An [sqlite3_file] object represents an open file in the
-** [sqlite3_vfs | OS interface layer]. Individual OS interface
-** implementations will
-** want to subclass this object by appending additional fields
-** for their own use. The pMethods entry is a pointer to an
-** [sqlite3_io_methods] object that defines methods for performing
-** I/O operations on the open file.
-*/
-typedef struct sqlite3_file sqlite3_file;
-struct sqlite3_file {
- const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
-};
-
-/*
-** CAPI3REF: OS Interface File Virtual Methods Object
-**
-** Every file opened by the [sqlite3_vfs.xOpen] method populates an
-** [sqlite3_file] object (or, more commonly, a subclass of the
-** [sqlite3_file] object) with a pointer to an instance of this object.
-** This object defines the methods used to perform various operations
-** against the open file represented by the [sqlite3_file] object.
-**
-** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element
-** to a non-NULL pointer, then the sqlite3_io_methods.xClose method
-** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The
-** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]
-** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element
-** to NULL.
-**
-** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
-** [SQLITE_SYNC_FULL]. The first choice is the normal fsync().
-** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY]
-** flag may be ORed in to indicate that only the data of the file
-** and not its inode needs to be synced.
-**
-** The integer values to xLock() and xUnlock() are one of
-** <ul>
-** <li> [SQLITE_LOCK_NONE],
-** <li> [SQLITE_LOCK_SHARED],
-** <li> [SQLITE_LOCK_RESERVED],
-** <li> [SQLITE_LOCK_PENDING], or
-** <li> [SQLITE_LOCK_EXCLUSIVE].
-** </ul>
-** xLock() increases the lock. xUnlock() decreases the lock.
-** The xCheckReservedLock() method checks whether any database connection,
-** either in this process or in some other process, is holding a RESERVED,
-** PENDING, or EXCLUSIVE lock on the file. It returns true
-** if such a lock exists and false otherwise.
-**
-** The xFileControl() method is a generic interface that allows custom
-** VFS implementations to directly control an open file using the
-** [sqlite3_file_control()] interface. The second "op" argument is an
-** integer opcode. The third argument is a generic pointer intended to
-** point to a structure that may contain arguments or space in which to
-** write return values. Potential uses for xFileControl() might be
-** functions to enable blocking locks with timeouts, to change the
-** locking strategy (for example to use dot-file locks), to inquire
-** about the status of a lock, or to break stale locks. The SQLite
-** core reserves all opcodes less than 100 for its own use.
-** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available.
-** Applications that define a custom xFileControl method should use opcodes
-** greater than 100 to avoid conflicts. VFS implementations should
-** return [SQLITE_NOTFOUND] for file control opcodes that they do not
-** recognize.
-**
-** The xSectorSize() method returns the sector size of the
-** device that underlies the file. The sector size is the
-** minimum write that can be performed without disturbing
-** other bytes in the file. The xDeviceCharacteristics()
-** method returns a bit vector describing behaviors of the
-** underlying device:
-**
-** <ul>
-** <li> [SQLITE_IOCAP_ATOMIC]
-** <li> [SQLITE_IOCAP_ATOMIC512]
-** <li> [SQLITE_IOCAP_ATOMIC1K]
-** <li> [SQLITE_IOCAP_ATOMIC2K]
-** <li> [SQLITE_IOCAP_ATOMIC4K]
-** <li> [SQLITE_IOCAP_ATOMIC8K]
-** <li> [SQLITE_IOCAP_ATOMIC16K]
-** <li> [SQLITE_IOCAP_ATOMIC32K]
-** <li> [SQLITE_IOCAP_ATOMIC64K]
-** <li> [SQLITE_IOCAP_SAFE_APPEND]
-** <li> [SQLITE_IOCAP_SEQUENTIAL]
-** </ul>
-**
-** The SQLITE_IOCAP_ATOMIC property means that all writes of
-** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
-** mean that writes of blocks that are nnn bytes in size and
-** are aligned to an address which is an integer multiple of
-** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
-** that when data is appended to a file, the data is appended
-** first then the size of the file is extended, never the other
-** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
-** information is written to disk in the same order as calls
-** to xWrite().
-**
-** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
-** in the unread portions of the buffer with zeros. A VFS that
-** fails to zero-fill short reads might seem to work. However,
-** failure to zero-fill short reads will eventually lead to
-** database corruption.
-*/
-typedef struct sqlite3_io_methods sqlite3_io_methods;
-struct sqlite3_io_methods {
- int iVersion;
- int (*xClose)(sqlite3_file*);
- int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
- int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
- int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
- int (*xSync)(sqlite3_file*, int flags);
- int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
- int (*xLock)(sqlite3_file*, int);
- int (*xUnlock)(sqlite3_file*, int);
- int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
- int (*xFileControl)(sqlite3_file*, int op, void *pArg);
- int (*xSectorSize)(sqlite3_file*);
- int (*xDeviceCharacteristics)(sqlite3_file*);
- /* Methods above are valid for version 1 */
- int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
- int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
- void (*xShmBarrier)(sqlite3_file*);
- int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
- /* Methods above are valid for version 2 */
- /* Additional methods may be added in future releases */
-};
-
-/*
-** CAPI3REF: Standard File Control Opcodes
-**
-** These integer constants are opcodes for the xFileControl method
-** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
-** interface.
-**
-** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
-** opcode causes the xFileControl method to write the current state of
-** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
-** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
-** into an integer that the pArg argument points to. This capability
-** is used during testing and only needs to be supported when SQLITE_TEST
-** is defined.
-** <ul>
-** <li>[[SQLITE_FCNTL_SIZE_HINT]]
-** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
-** layer a hint of how large the database file will grow to be during the
-** current transaction. This hint is not guaranteed to be accurate but it
-** is often close. The underlying VFS might choose to preallocate database
-** file space based on this hint in order to help writes to the database
-** file run faster.
-**
-** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
-** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
-** extends and truncates the database file in chunks of a size specified
-** by the user. The fourth argument to [sqlite3_file_control()] should
-** point to an integer (type int) containing the new chunk-size to use
-** for the nominated database. Allocating database file space in large
-** chunks (say 1MB at a time), may reduce file-system fragmentation and
-** improve performance on some systems.
-**
-** <li>[[SQLITE_FCNTL_FILE_POINTER]]
-** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
-** to the [sqlite3_file] object associated with a particular database
-** connection. See the [sqlite3_file_control()] documentation for
-** additional information.
-**
-** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
-** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by
-** SQLite and sent to all VFSes in place of a call to the xSync method
-** when the database connection has [PRAGMA synchronous] set to OFF.)^
-** Some specialized VFSes need this signal in order to operate correctly
-** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most
-** VFSes do not need this signal and should silently ignore this opcode.
-** Applications should not call [sqlite3_file_control()] with this
-** opcode as doing so may disrupt the operation of the specialized VFSes
-** that do require it.
-**
-** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]
-** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
-** retry counts and intervals for certain disk I/O operations for the
-** windows [VFS] in order to provide robustness in the presence of
-** anti-virus programs. By default, the windows VFS will retry file read,
-** file write, and file delete operations up to 10 times, with a delay
-** of 25 milliseconds before the first retry and with the delay increasing
-** by an additional 25 milliseconds with each subsequent retry. This
-** opcode allows these two values (10 retries and 25 milliseconds of delay)
-** to be adjusted. The values are changed for all database connections
-** within the same process. The argument is a pointer to an array of two
-** integers where the first integer i the new retry count and the second
-** integer is the delay. If either integer is negative, then the setting
-** is not changed but instead the prior value of that setting is written
-** into the array entry, allowing the current retry settings to be
-** interrogated. The zDbName parameter is ignored.
-**
-** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
-** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
-** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary
-** write ahead log and shared memory files used for transaction control
-** are automatically deleted when the latest connection to the database
-** closes. Setting persistent WAL mode causes those files to persist after
-** close. Persisting the files is useful when other processes that do not
-** have write permission on the directory containing the database file want
-** to read the database file, as the WAL and shared memory files must exist
-** in order for the database to be readable. The fourth parameter to
-** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
-** That integer is 0 to disable persistent WAL mode or 1 to enable persistent
-** WAL mode. If the integer is -1, then it is overwritten with the current
-** WAL persistence setting.
-**
-** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]
-** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the
-** persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting
-** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the
-** xDeviceCharacteristics methods. The fourth parameter to
-** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
-** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage
-** mode. If the integer is -1, then it is overwritten with the current
-** zero-damage mode setting.
-**
-** <li>[[SQLITE_FCNTL_OVERWRITE]]
-** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening
-** a write transaction to indicate that, unless it is rolled back for some
-** reason, the entire database file will be overwritten by the current
-** transaction. This is used by VACUUM operations.
-**
-** <li>[[SQLITE_FCNTL_VFSNAME]]
-** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of
-** all [VFSes] in the VFS stack. The names are of all VFS shims and the
-** final bottom-level VFS are written into memory obtained from
-** [sqlite3_malloc()] and the result is stored in the char* variable
-** that the fourth parameter of [sqlite3_file_control()] points to.
-** The caller is responsible for freeing the memory when done. As with
-** all file-control actions, there is no guarantee that this will actually
-** do anything. Callers should initialize the char* variable to a NULL
-** pointer in case this file-control is not implemented. This file-control
-** is intended for diagnostic use only.
-**
-** <li>[[SQLITE_FCNTL_PRAGMA]]
-** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA]
-** file control is sent to the open [sqlite3_file] object corresponding
-** to the database file to which the pragma statement refers. ^The argument
-** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
-** pointers to strings (char**) in which the second element of the array
-** is the name of the pragma and the third element is the argument to the
-** pragma or NULL if the pragma has no argument. ^The handler for an
-** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element
-** of the char** argument point to a string obtained from [sqlite3_mprintf()]
-** or the equivalent and that string will become the result of the pragma or
-** the error message if the pragma fails. ^If the
-** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
-** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
-** file control returns [SQLITE_OK], then the parser assumes that the
-** VFS has handled the PRAGMA itself and the parser generates a no-op
-** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns
-** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
-** that the VFS encountered an error while handling the [PRAGMA] and the
-** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
-** file control occurs at the beginning of pragma statement analysis and so
-** it is able to override built-in [PRAGMA] statements.
-** </ul>
-*/
-#define SQLITE_FCNTL_LOCKSTATE 1
-#define SQLITE_GET_LOCKPROXYFILE 2
-#define SQLITE_SET_LOCKPROXYFILE 3
-#define SQLITE_LAST_ERRNO 4
-#define SQLITE_FCNTL_SIZE_HINT 5
-#define SQLITE_FCNTL_CHUNK_SIZE 6
-#define SQLITE_FCNTL_FILE_POINTER 7
-#define SQLITE_FCNTL_SYNC_OMITTED 8
-#define SQLITE_FCNTL_WIN32_AV_RETRY 9
-#define SQLITE_FCNTL_PERSIST_WAL 10
-#define SQLITE_FCNTL_OVERWRITE 11
-#define SQLITE_FCNTL_VFSNAME 12
-#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13
-#define SQLITE_FCNTL_PRAGMA 14
-
-/*
-** CAPI3REF: Mutex Handle
-**
-** The mutex module within SQLite defines [sqlite3_mutex] to be an
-** abstract type for a mutex object. The SQLite core never looks
-** at the internal representation of an [sqlite3_mutex]. It only
-** deals with pointers to the [sqlite3_mutex] object.
-**
-** Mutexes are created using [sqlite3_mutex_alloc()].
-*/
-typedef struct sqlite3_mutex sqlite3_mutex;
-
-/*
-** CAPI3REF: OS Interface Object
-**
-** An instance of the sqlite3_vfs object defines the interface between
-** the SQLite core and the underlying operating system. The "vfs"
-** in the name of the object stands for "virtual file system". See
-** the [VFS | VFS documentation] for further information.
-**
-** The value of the iVersion field is initially 1 but may be larger in
-** future versions of SQLite. Additional fields may be appended to this
-** object when the iVersion value is increased. Note that the structure
-** of the sqlite3_vfs object changes in the transaction between
-** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not
-** modified.
-**
-** The szOsFile field is the size of the subclassed [sqlite3_file]
-** structure used by this VFS. mxPathname is the maximum length of
-** a pathname in this VFS.
-**
-** Registered sqlite3_vfs objects are kept on a linked list formed by
-** the pNext pointer. The [sqlite3_vfs_register()]
-** and [sqlite3_vfs_unregister()] interfaces manage this list
-** in a thread-safe way. The [sqlite3_vfs_find()] interface
-** searches the list. Neither the application code nor the VFS
-** implementation should use the pNext pointer.
-**
-** The pNext field is the only field in the sqlite3_vfs
-** structure that SQLite will ever modify. SQLite will only access
-** or modify this field while holding a particular static mutex.
-** The application should never modify anything within the sqlite3_vfs
-** object once the object has been registered.
-**
-** The zName field holds the name of the VFS module. The name must
-** be unique across all VFS modules.
-**
-** [[sqlite3_vfs.xOpen]]
-** ^SQLite guarantees that the zFilename parameter to xOpen
-** is either a NULL pointer or string obtained
-** from xFullPathname() with an optional suffix added.
-** ^If a suffix is added to the zFilename parameter, it will
-** consist of a single "-" character followed by no more than
-** 11 alphanumeric and/or "-" characters.
-** ^SQLite further guarantees that
-** the string will be valid and unchanged until xClose() is
-** called. Because of the previous sentence,
-** the [sqlite3_file] can safely store a pointer to the
-** filename if it needs to remember the filename for some reason.
-** If the zFilename parameter to xOpen is a NULL pointer then xOpen
-** must invent its own temporary name for the file. ^Whenever the
-** xFilename parameter is NULL it will also be the case that the
-** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
-**
-** The flags argument to xOpen() includes all bits set in
-** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()]
-** or [sqlite3_open16()] is used, then flags includes at least
-** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE].
-** If xOpen() opens a file read-only then it sets *pOutFlags to
-** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set.
-**
-** ^(SQLite will also add one of the following flags to the xOpen()
-** call, depending on the object being opened:
-**
-** <ul>
-** <li> [SQLITE_OPEN_MAIN_DB]
-** <li> [SQLITE_OPEN_MAIN_JOURNAL]
-** <li> [SQLITE_OPEN_TEMP_DB]
-** <li> [SQLITE_OPEN_TEMP_JOURNAL]
-** <li> [SQLITE_OPEN_TRANSIENT_DB]
-** <li> [SQLITE_OPEN_SUBJOURNAL]
-** <li> [SQLITE_OPEN_MASTER_JOURNAL]
-** <li> [SQLITE_OPEN_WAL]
-** </ul>)^
-**
-** The file I/O implementation can use the object type flags to
-** change the way it deals with files. For example, an application
-** that does not care about crash recovery or rollback might make
-** the open of a journal file a no-op. Writes to this journal would
-** also be no-ops, and any attempt to read the journal would return
-** SQLITE_IOERR. Or the implementation might recognize that a database
-** file will be doing page-aligned sector reads and writes in a random
-** order and set up its I/O subsystem accordingly.
-**
-** SQLite might also add one of the following flags to the xOpen method:
-**
-** <ul>
-** <li> [SQLITE_OPEN_DELETEONCLOSE]
-** <li> [SQLITE_OPEN_EXCLUSIVE]
-** </ul>
-**
-** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
-** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE]
-** will be set for TEMP databases and their journals, transient
-** databases, and subjournals.
-**
-** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
-** with the [SQLITE_OPEN_CREATE] flag, which are both directly
-** analogous to the O_EXCL and O_CREAT flags of the POSIX open()
-** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the
-** SQLITE_OPEN_CREATE, is used to indicate that file should always
-** be created, and that it is an error if it already exists.
-** It is <i>not</i> used to indicate the file should be opened
-** for exclusive access.
-**
-** ^At least szOsFile bytes of memory are allocated by SQLite
-** to hold the [sqlite3_file] structure passed as the third
-** argument to xOpen. The xOpen method does not have to
-** allocate the structure; it should just fill it in. Note that
-** the xOpen method must set the sqlite3_file.pMethods to either
-** a valid [sqlite3_io_methods] object or to NULL. xOpen must do
-** this even if the open fails. SQLite expects that the sqlite3_file.pMethods
-** element will be valid after xOpen returns regardless of the success
-** or failure of the xOpen call.
-**
-** [[sqlite3_vfs.xAccess]]
-** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
-** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
-** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
-** to test whether a file is at least readable. The file can be a
-** directory.
-**
-** ^SQLite will always allocate at least mxPathname+1 bytes for the
-** output buffer xFullPathname. The exact size of the output buffer
-** is also passed as a parameter to both methods. If the output buffer
-** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
-** handled as a fatal error by SQLite, vfs implementations should endeavor
-** to prevent this by setting mxPathname to a sufficiently large value.
-**
-** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
-** interfaces are not strictly a part of the filesystem, but they are
-** included in the VFS structure for completeness.
-** The xRandomness() function attempts to return nBytes bytes
-** of good-quality randomness into zOut. The return value is
-** the actual number of bytes of randomness obtained.
-** The xSleep() method causes the calling thread to sleep for at
-** least the number of microseconds given. ^The xCurrentTime()
-** method returns a Julian Day Number for the current date and time as
-** a floating point value.
-** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
-** Day Number multiplied by 86400000 (the number of milliseconds in
-** a 24-hour day).
-** ^SQLite will use the xCurrentTimeInt64() method to get the current
-** date and time if that method is available (if iVersion is 2 or
-** greater and the function pointer is not NULL) and will fall back
-** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
-**
-** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
-** are not used by the SQLite core. These optional interfaces are provided
-** by some VFSes to facilitate testing of the VFS code. By overriding
-** system calls with functions under its control, a test program can
-** simulate faults and error conditions that would otherwise be difficult
-** or impossible to induce. The set of system calls that can be overridden
-** varies from one VFS to another, and from one version of the same VFS to the
-** next. Applications that use these interfaces must be prepared for any
-** or all of these interfaces to be NULL or for their behavior to change
-** from one release to the next. Applications must not attempt to access
-** any of these methods if the iVersion of the VFS is less than 3.
-*/
-typedef struct sqlite3_vfs sqlite3_vfs;
-typedef void (*sqlite3_syscall_ptr)(void);
-struct sqlite3_vfs {
- int iVersion; /* Structure version number (currently 3) */
- int szOsFile; /* Size of subclassed sqlite3_file */
- int mxPathname; /* Maximum file pathname length */
- sqlite3_vfs *pNext; /* Next registered VFS */
- const char *zName; /* Name of this virtual file system */
- void *pAppData; /* Pointer to application-specific data */
- int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
- int flags, int *pOutFlags);
- int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
- int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
- int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
- void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
- void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
- void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
- void (*xDlClose)(sqlite3_vfs*, void*);
- int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
- int (*xSleep)(sqlite3_vfs*, int microseconds);
- int (*xCurrentTime)(sqlite3_vfs*, double*);
- int (*xGetLastError)(sqlite3_vfs*, int, char *);
- /*
- ** The methods above are in version 1 of the sqlite_vfs object
- ** definition. Those that follow are added in version 2 or later
- */
- int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
- /*
- ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
- ** Those below are for version 3 and greater.
- */
- int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
- sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
- const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
- /*
- ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
- ** New fields may be appended in figure versions. The iVersion
- ** value will increment whenever this happens.
- */
-};
-
-/*
-** CAPI3REF: Flags for the xAccess VFS method
-**
-** These integer constants can be used as the third parameter to
-** the xAccess method of an [sqlite3_vfs] object. They determine
-** what kind of permissions the xAccess method is looking for.
-** With SQLITE_ACCESS_EXISTS, the xAccess method
-** simply checks whether the file exists.
-** With SQLITE_ACCESS_READWRITE, the xAccess method
-** checks whether the named directory is both readable and writable
-** (in other words, if files can be added, removed, and renamed within
-** the directory).
-** The SQLITE_ACCESS_READWRITE constant is currently used only by the
-** [temp_store_directory pragma], though this could change in a future
-** release of SQLite.
-** With SQLITE_ACCESS_READ, the xAccess method
-** checks whether the file is readable. The SQLITE_ACCESS_READ constant is
-** currently unused, though it might be used in a future release of
-** SQLite.
-*/
-#define SQLITE_ACCESS_EXISTS 0
-#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
-#define SQLITE_ACCESS_READ 2 /* Unused */
-
-/*
-** CAPI3REF: Flags for the xShmLock VFS method
-**
-** These integer constants define the various locking operations
-** allowed by the xShmLock method of [sqlite3_io_methods]. The
-** following are the only legal combinations of flags to the
-** xShmLock method:
-**
-** <ul>
-** <li> SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
-** <li> SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
-** <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
-** <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
-** </ul>
-**
-** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
-** was given no the corresponding lock.
-**
-** The xShmLock method can transition between unlocked and SHARED or
-** between unlocked and EXCLUSIVE. It cannot transition between SHARED
-** and EXCLUSIVE.
-*/
-#define SQLITE_SHM_UNLOCK 1
-#define SQLITE_SHM_LOCK 2
-#define SQLITE_SHM_SHARED 4
-#define SQLITE_SHM_EXCLUSIVE 8
-
-/*
-** CAPI3REF: Maximum xShmLock index
-**
-** The xShmLock method on [sqlite3_io_methods] may use values
-** between 0 and this upper bound as its "offset" argument.
-** The SQLite core will never attempt to acquire or release a
-** lock outside of this range
-*/
-#define SQLITE_SHM_NLOCK 8
-
-
-/*
-** CAPI3REF: Initialize The SQLite Library
-**
-** ^The sqlite3_initialize() routine initializes the
-** SQLite library. ^The sqlite3_shutdown() routine
-** deallocates any resources that were allocated by sqlite3_initialize().
-** These routines are designed to aid in process initialization and
-** shutdown on embedded systems. Workstation applications using
-** SQLite normally do not need to invoke either of these routines.
-**
-** A call to sqlite3_initialize() is an "effective" call if it is
-** the first time sqlite3_initialize() is invoked during the lifetime of
-** the process, or if it is the first time sqlite3_initialize() is invoked
-** following a call to sqlite3_shutdown(). ^(Only an effective call
-** of sqlite3_initialize() does any initialization. All other calls
-** are harmless no-ops.)^
-**
-** A call to sqlite3_shutdown() is an "effective" call if it is the first
-** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only
-** an effective call to sqlite3_shutdown() does any deinitialization.
-** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
-**
-** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
-** is not. The sqlite3_shutdown() interface must only be called from a
-** single thread. All open [database connections] must be closed and all
-** other SQLite resources must be deallocated prior to invoking
-** sqlite3_shutdown().
-**
-** Among other things, ^sqlite3_initialize() will invoke
-** sqlite3_os_init(). Similarly, ^sqlite3_shutdown()
-** will invoke sqlite3_os_end().
-**
-** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
-** ^If for some reason, sqlite3_initialize() is unable to initialize
-** the library (perhaps it is unable to allocate a needed resource such
-** as a mutex) it returns an [error code] other than [SQLITE_OK].
-**
-** ^The sqlite3_initialize() routine is called internally by many other
-** SQLite interfaces so that an application usually does not need to
-** invoke sqlite3_initialize() directly. For example, [sqlite3_open()]
-** calls sqlite3_initialize() so the SQLite library will be automatically
-** initialized when [sqlite3_open()] is called if it has not be initialized
-** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
-** compile-time option, then the automatic calls to sqlite3_initialize()
-** are omitted and the application must call sqlite3_initialize() directly
-** prior to using any other SQLite interface. For maximum portability,
-** it is recommended that applications always invoke sqlite3_initialize()
-** directly prior to using any other SQLite interface. Future releases
-** of SQLite may require this. In other words, the behavior exhibited
-** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the
-** default behavior in some future release of SQLite.
-**
-** The sqlite3_os_init() routine does operating-system specific
-** initialization of the SQLite library. The sqlite3_os_end()
-** routine undoes the effect of sqlite3_os_init(). Typical tasks
-** performed by these routines include allocation or deallocation
-** of static resources, initialization of global variables,
-** setting up a default [sqlite3_vfs] module, or setting up
-** a default configuration using [sqlite3_config()].
-**
-** The application should never invoke either sqlite3_os_init()
-** or sqlite3_os_end() directly. The application should only invoke
-** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init()
-** interface is called automatically by sqlite3_initialize() and
-** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate
-** implementations for sqlite3_os_init() and sqlite3_os_end()
-** are built into SQLite when it is compiled for Unix, Windows, or OS/2.
-** When [custom builds | built for other platforms]
-** (using the [SQLITE_OS_OTHER=1] compile-time
-** option) the application must supply a suitable implementation for
-** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
-** implementation of sqlite3_os_init() or sqlite3_os_end()
-** must return [SQLITE_OK] on success and some other [error code] upon
-** failure.
-*/
-SQLITE_API int sqlite3_initialize(void);
-SQLITE_API int sqlite3_shutdown(void);
-SQLITE_API int sqlite3_os_init(void);
-SQLITE_API int sqlite3_os_end(void);
-
-/*
-** CAPI3REF: Configuring The SQLite Library
-**
-** The sqlite3_config() interface is used to make global configuration
-** changes to SQLite in order to tune SQLite to the specific needs of
-** the application. The default configuration is recommended for most
-** applications and so this routine is usually not necessary. It is
-** provided to support rare applications with unusual needs.
-**
-** The sqlite3_config() interface is not threadsafe. The application
-** must insure that no other SQLite interfaces are invoked by other
-** threads while sqlite3_config() is running. Furthermore, sqlite3_config()
-** may only be invoked prior to library initialization using
-** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
-** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
-** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
-** Note, however, that ^sqlite3_config() can be called as part of the
-** implementation of an application-defined [sqlite3_os_init()].
-**
-** The first argument to sqlite3_config() is an integer
-** [configuration option] that determines
-** what property of SQLite is to be configured. Subsequent arguments
-** vary depending on the [configuration option]
-** in the first argument.
-**
-** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
-** ^If the option is unknown or SQLite is unable to set the option
-** then this routine returns a non-zero [error code].
-*/
-SQLITE_API int sqlite3_config(int, ...);
-
-/*
-** CAPI3REF: Configure database connections
-**
-** The sqlite3_db_config() interface is used to make configuration
-** changes to a [database connection]. The interface is similar to
-** [sqlite3_config()] except that the changes apply to a single
-** [database connection] (specified in the first argument).
-**
-** The second argument to sqlite3_db_config(D,V,...) is the
-** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code
-** that indicates what aspect of the [database connection] is being configured.
-** Subsequent arguments vary depending on the configuration verb.
-**
-** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
-** the call is considered successful.
-*/
-SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
-
-/*
-** CAPI3REF: Memory Allocation Routines
-**
-** An instance of this object defines the interface between SQLite
-** and low-level memory allocation routines.
-**
-** This object is used in only one place in the SQLite interface.
-** A pointer to an instance of this object is the argument to
-** [sqlite3_config()] when the configuration option is
-** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].
-** By creating an instance of this object
-** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
-** during configuration, an application can specify an alternative
-** memory allocation subsystem for SQLite to use for all of its
-** dynamic memory needs.
-**
-** Note that SQLite comes with several [built-in memory allocators]
-** that are perfectly adequate for the overwhelming majority of applications
-** and that this object is only useful to a tiny minority of applications
-** with specialized memory allocation requirements. This object is
-** also used during testing of SQLite in order to specify an alternative
-** memory allocator that simulates memory out-of-memory conditions in
-** order to verify that SQLite recovers gracefully from such
-** conditions.
-**
-** The xMalloc, xRealloc, and xFree methods must work like the
-** malloc(), realloc() and free() functions from the standard C library.
-** ^SQLite guarantees that the second argument to
-** xRealloc is always a value returned by a prior call to xRoundup.
-**
-** xSize should return the allocated size of a memory allocation
-** previously obtained from xMalloc or xRealloc. The allocated size
-** is always at least as big as the requested size but may be larger.
-**
-** The xRoundup method returns what would be the allocated size of
-** a memory allocation given a particular requested size. Most memory
-** allocators round up memory allocations at least to the next multiple
-** of 8. Some allocators round up to a larger multiple or to a power of 2.
-** Every memory allocation request coming in through [sqlite3_malloc()]
-** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0,
-** that causes the corresponding memory allocation to fail.
-**
-** The xInit method initializes the memory allocator. (For example,
-** it might allocate any require mutexes or initialize internal data
-** structures. The xShutdown method is invoked (indirectly) by
-** [sqlite3_shutdown()] and should deallocate any resources acquired
-** by xInit. The pAppData pointer is used as the only parameter to
-** xInit and xShutdown.
-**
-** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes
-** the xInit method, so the xInit method need not be threadsafe. The
-** xShutdown method is only called from [sqlite3_shutdown()] so it does
-** not need to be threadsafe either. For all other methods, SQLite
-** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the
-** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which
-** it is by default) and so the methods are automatically serialized.
-** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other
-** methods must be threadsafe or else make their own arrangements for
-** serialization.
-**
-** SQLite will never invoke xInit() more than once without an intervening
-** call to xShutdown().
-*/
-typedef struct sqlite3_mem_methods sqlite3_mem_methods;
-struct sqlite3_mem_methods {
- void *(*xMalloc)(int); /* Memory allocation function */
- void (*xFree)(void*); /* Free a prior allocation */
- void *(*xRealloc)(void*,int); /* Resize an allocation */
- int (*xSize)(void*); /* Return the size of an allocation */
- int (*xRoundup)(int); /* Round up request size to allocation size */
- int (*xInit)(void*); /* Initialize the memory allocator */
- void (*xShutdown)(void*); /* Deinitialize the memory allocator */
- void *pAppData; /* Argument to xInit() and xShutdown() */
-};
-
-/*
-** CAPI3REF: Configuration Options
-** KEYWORDS: {configuration option}
-**
-** These constants are the available integer configuration options that
-** can be passed as the first argument to the [sqlite3_config()] interface.
-**
-** New configuration options may be added in future releases of SQLite.
-** Existing configuration options might be discontinued. Applications
-** should check the return code from [sqlite3_config()] to make sure that
-** the call worked. The [sqlite3_config()] interface will return a
-** non-zero [error code] if a discontinued or unsupported configuration option
-** is invoked.
-**
-** <dl>
-** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
-** <dd>There are no arguments to this option. ^This option sets the
-** [threading mode] to Single-thread. In other words, it disables
-** all mutexing and puts SQLite into a mode where it can only be used
-** by a single thread. ^If SQLite is compiled with
-** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
-** it is not possible to change the [threading mode] from its default
-** value of Single-thread and so [sqlite3_config()] will return
-** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
-** configuration option.</dd>
-**
-** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>
-** <dd>There are no arguments to this option. ^This option sets the
-** [threading mode] to Multi-thread. In other words, it disables
-** mutexing on [database connection] and [prepared statement] objects.
-** The application is responsible for serializing access to
-** [database connections] and [prepared statements]. But other mutexes
-** are enabled so that SQLite will be safe to use in a multi-threaded
-** environment as long as no two threads attempt to use the same
-** [database connection] at the same time. ^If SQLite is compiled with
-** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
-** it is not possible to set the Multi-thread [threading mode] and
-** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
-** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
-**
-** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>
-** <dd>There are no arguments to this option. ^This option sets the
-** [threading mode] to Serialized. In other words, this option enables
-** all mutexes including the recursive
-** mutexes on [database connection] and [prepared statement] objects.
-** In this mode (which is the default when SQLite is compiled with
-** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
-** to [database connections] and [prepared statements] so that the
-** application is free to use the same [database connection] or the
-** same [prepared statement] in different threads at the same time.
-** ^If SQLite is compiled with
-** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
-** it is not possible to set the Serialized [threading mode] and
-** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
-** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
-**
-** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mem_methods] structure. The argument specifies
-** alternative low-level memory allocation routines to be used in place of
-** the memory allocation routines built into SQLite.)^ ^SQLite makes
-** its own private copy of the content of the [sqlite3_mem_methods] structure
-** before the [sqlite3_config()] call returns.</dd>
-**
-** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
-** <dd> ^(This option takes a single argument whi
<TRUNCATED>
[05/10] Removed Windows7 which is now in it's own branch. This closes
#29
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/lib/sqlite/sqlite3.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/lib/sqlite/sqlite3.h b/windows7/Cordova/lib/sqlite/sqlite3.h
deleted file mode 100644
index 0a1cf9d..0000000
--- a/windows7/Cordova/lib/sqlite/sqlite3.h
+++ /dev/null
@@ -1,7055 +0,0 @@
-/*
-** 2001 September 15
-**
-** The author disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
-**
-*************************************************************************
-** This header file defines the interface that the SQLite library
-** presents to client programs. If a C-function, structure, datatype,
-** or constant definition does not appear in this file, then it is
-** not a published API of SQLite, is subject to change without
-** notice, and should not be referenced by programs that use SQLite.
-**
-** Some of the definitions that are in this file are marked as
-** "experimental". Experimental interfaces are normally new
-** features recently added to SQLite. We do not anticipate changes
-** to experimental interfaces but reserve the right to make minor changes
-** if experience from use "in the wild" suggest such changes are prudent.
-**
-** The official C-language API documentation for SQLite is derived
-** from comments in this file. This file is the authoritative source
-** on how SQLite interfaces are suppose to operate.
-**
-** The name of this file under configuration management is "sqlite.h.in".
-** The makefile makes some minor changes to this file (such as inserting
-** the version number) and changes its name to "sqlite3.h" as
-** part of the build process.
-*/
-#ifndef _SQLITE3_H_
-#define _SQLITE3_H_
-#include <stdarg.h> /* Needed for the definition of va_list */
-
-/*
-** Make sure we can call this stuff from C++.
-*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*
-** Add the ability to override 'extern'
-*/
-#ifndef SQLITE_EXTERN
-# define SQLITE_EXTERN extern
-#endif
-
-#ifndef SQLITE_API
-# define SQLITE_API
-#endif
-
-
-/*
-** These no-op macros are used in front of interfaces to mark those
-** interfaces as either deprecated or experimental. New applications
-** should not use deprecated interfaces - they are support for backwards
-** compatibility only. Application writers should be aware that
-** experimental interfaces are subject to change in point releases.
-**
-** These macros used to resolve to various kinds of compiler magic that
-** would generate warning messages when they were used. But that
-** compiler magic ended up generating such a flurry of bug reports
-** that we have taken it all out and gone back to using simple
-** noop macros.
-*/
-#define SQLITE_DEPRECATED
-#define SQLITE_EXPERIMENTAL
-
-/*
-** Ensure these symbols were not defined by some previous header file.
-*/
-#ifdef SQLITE_VERSION
-# undef SQLITE_VERSION
-#endif
-#ifdef SQLITE_VERSION_NUMBER
-# undef SQLITE_VERSION_NUMBER
-#endif
-
-/*
-** CAPI3REF: Compile-Time Library Version Numbers
-**
-** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
-** evaluates to a string literal that is the SQLite version in the
-** format "X.Y.Z" where X is the major version number (always 3 for
-** SQLite3) and Y is the minor version number and Z is the release number.)^
-** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
-** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
-** numbers used in [SQLITE_VERSION].)^
-** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
-** be larger than the release from which it is derived. Either Y will
-** be held constant and Z will be incremented or else Y will be incremented
-** and Z will be reset to zero.
-**
-** Since version 3.6.18, SQLite source code has been stored in the
-** <a href="http://www.fossil-scm.org/">Fossil configuration management
-** system</a>. ^The SQLITE_SOURCE_ID macro evaluates to
-** a string which identifies a particular check-in of SQLite
-** within its configuration management system. ^The SQLITE_SOURCE_ID
-** string contains the date and time of the check-in (UTC) and an SHA1
-** hash of the entire source tree.
-**
-** See also: [sqlite3_libversion()],
-** [sqlite3_libversion_number()], [sqlite3_sourceid()],
-** [sqlite_version()] and [sqlite_source_id()].
-*/
-#define SQLITE_VERSION "3.7.13"
-#define SQLITE_VERSION_NUMBER 3007013
-#define SQLITE_SOURCE_ID "2012-06-11 02:05:22 f5b5a13f7394dc143aa136f1d4faba6839eaa6dc"
-
-/*
-** CAPI3REF: Run-Time Library Version Numbers
-** KEYWORDS: sqlite3_version, sqlite3_sourceid
-**
-** These interfaces provide the same information as the [SQLITE_VERSION],
-** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
-** but are associated with the library instead of the header file. ^(Cautious
-** programmers might include assert() statements in their application to
-** verify that values returned by these interfaces match the macros in
-** the header, and thus insure that the application is
-** compiled with matching library and header files.
-**
-** <blockquote><pre>
-** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
-** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
-** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
-** </pre></blockquote>)^
-**
-** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
-** macro. ^The sqlite3_libversion() function returns a pointer to the
-** to the sqlite3_version[] string constant. The sqlite3_libversion()
-** function is provided for use in DLLs since DLL users usually do not have
-** direct access to string constants within the DLL. ^The
-** sqlite3_libversion_number() function returns an integer equal to
-** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns
-** a pointer to a string constant whose value is the same as the
-** [SQLITE_SOURCE_ID] C preprocessor macro.
-**
-** See also: [sqlite_version()] and [sqlite_source_id()].
-*/
-SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
-SQLITE_API const char *sqlite3_libversion(void);
-SQLITE_API const char *sqlite3_sourceid(void);
-SQLITE_API int sqlite3_libversion_number(void);
-
-/*
-** CAPI3REF: Run-Time Library Compilation Options Diagnostics
-**
-** ^The sqlite3_compileoption_used() function returns 0 or 1
-** indicating whether the specified option was defined at
-** compile time. ^The SQLITE_ prefix may be omitted from the
-** option name passed to sqlite3_compileoption_used().
-**
-** ^The sqlite3_compileoption_get() function allows iterating
-** over the list of options that were defined at compile time by
-** returning the N-th compile time option string. ^If N is out of range,
-** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_
-** prefix is omitted from any strings returned by
-** sqlite3_compileoption_get().
-**
-** ^Support for the diagnostic functions sqlite3_compileoption_used()
-** and sqlite3_compileoption_get() may be omitted by specifying the
-** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
-**
-** See also: SQL functions [sqlite_compileoption_used()] and
-** [sqlite_compileoption_get()] and the [compile_options pragma].
-*/
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
-SQLITE_API const char *sqlite3_compileoption_get(int N);
-#endif
-
-/*
-** CAPI3REF: Test To See If The Library Is Threadsafe
-**
-** ^The sqlite3_threadsafe() function returns zero if and only if
-** SQLite was compiled with mutexing code omitted due to the
-** [SQLITE_THREADSAFE] compile-time option being set to 0.
-**
-** SQLite can be compiled with or without mutexes. When
-** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
-** are enabled and SQLite is threadsafe. When the
-** [SQLITE_THREADSAFE] macro is 0,
-** the mutexes are omitted. Without the mutexes, it is not safe
-** to use SQLite concurrently from more than one thread.
-**
-** Enabling mutexes incurs a measurable performance penalty.
-** So if speed is of utmost importance, it makes sense to disable
-** the mutexes. But for maximum safety, mutexes should be enabled.
-** ^The default behavior is for mutexes to be enabled.
-**
-** This interface can be used by an application to make sure that the
-** version of SQLite that it is linking against was compiled with
-** the desired setting of the [SQLITE_THREADSAFE] macro.
-**
-** This interface only reports on the compile-time mutex setting
-** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
-** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
-** can be fully or partially disabled using a call to [sqlite3_config()]
-** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
-** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the
-** sqlite3_threadsafe() function shows only the compile-time setting of
-** thread safety, not any run-time changes to that setting made by
-** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
-** is unchanged by calls to sqlite3_config().)^
-**
-** See the [threading mode] documentation for additional information.
-*/
-SQLITE_API int sqlite3_threadsafe(void);
-
-/*
-** CAPI3REF: Database Connection Handle
-** KEYWORDS: {database connection} {database connections}
-**
-** Each open SQLite database is represented by a pointer to an instance of
-** the opaque structure named "sqlite3". It is useful to think of an sqlite3
-** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
-** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
-** is its destructor. There are many other interfaces (such as
-** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
-** [sqlite3_busy_timeout()] to name but three) that are methods on an
-** sqlite3 object.
-*/
-typedef struct sqlite3 sqlite3;
-
-/*
-** CAPI3REF: 64-Bit Integer Types
-** KEYWORDS: sqlite_int64 sqlite_uint64
-**
-** Because there is no cross-platform way to specify 64-bit integer types
-** SQLite includes typedefs for 64-bit signed and unsigned integers.
-**
-** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
-** The sqlite_int64 and sqlite_uint64 types are supported for backwards
-** compatibility only.
-**
-** ^The sqlite3_int64 and sqlite_int64 types can store integer values
-** between -9223372036854775808 and +9223372036854775807 inclusive. ^The
-** sqlite3_uint64 and sqlite_uint64 types can store integer values
-** between 0 and +18446744073709551615 inclusive.
-*/
-#ifdef SQLITE_INT64_TYPE
- typedef SQLITE_INT64_TYPE sqlite_int64;
- typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
-#elif defined(_MSC_VER) || defined(__BORLANDC__)
- typedef __int64 sqlite_int64;
- typedef unsigned __int64 sqlite_uint64;
-#else
- typedef long long int sqlite_int64;
- typedef unsigned long long int sqlite_uint64;
-#endif
-typedef sqlite_int64 sqlite3_int64;
-typedef sqlite_uint64 sqlite3_uint64;
-
-/*
-** If compiling for a processor that lacks floating point support,
-** substitute integer for floating-point.
-*/
-#ifdef SQLITE_OMIT_FLOATING_POINT
-# define double sqlite3_int64
-#endif
-
-/*
-** CAPI3REF: Closing A Database Connection
-**
-** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.
-** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is
-** successfully destroyed and all associated resources are deallocated.
-**
-** Applications must [sqlite3_finalize | finalize] all [prepared statements]
-** and [sqlite3_blob_close | close] all [BLOB handles] associated with
-** the [sqlite3] object prior to attempting to close the object. ^If
-** sqlite3_close() is called on a [database connection] that still has
-** outstanding [prepared statements] or [BLOB handles], then it returns
-** SQLITE_BUSY.
-**
-** ^If [sqlite3_close()] is invoked while a transaction is open,
-** the transaction is automatically rolled back.
-**
-** The C parameter to [sqlite3_close(C)] must be either a NULL
-** pointer or an [sqlite3] object pointer obtained
-** from [sqlite3_open()], [sqlite3_open16()], or
-** [sqlite3_open_v2()], and not previously closed.
-** ^Calling sqlite3_close() with a NULL pointer argument is a
-** harmless no-op.
-*/
-SQLITE_API int sqlite3_close(sqlite3 *);
-
-/*
-** The type for a callback function.
-** This is legacy and deprecated. It is included for historical
-** compatibility and is not documented.
-*/
-typedef int (*sqlite3_callback)(void*,int,char**, char**);
-
-/*
-** CAPI3REF: One-Step Query Execution Interface
-**
-** The sqlite3_exec() interface is a convenience wrapper around
-** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
-** that allows an application to run multiple statements of SQL
-** without having to use a lot of C code.
-**
-** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
-** semicolon-separate SQL statements passed into its 2nd argument,
-** in the context of the [database connection] passed in as its 1st
-** argument. ^If the callback function of the 3rd argument to
-** sqlite3_exec() is not NULL, then it is invoked for each result row
-** coming out of the evaluated SQL statements. ^The 4th argument to
-** sqlite3_exec() is relayed through to the 1st argument of each
-** callback invocation. ^If the callback pointer to sqlite3_exec()
-** is NULL, then no callback is ever invoked and result rows are
-** ignored.
-**
-** ^If an error occurs while evaluating the SQL statements passed into
-** sqlite3_exec(), then execution of the current statement stops and
-** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec()
-** is not NULL then any error message is written into memory obtained
-** from [sqlite3_malloc()] and passed back through the 5th parameter.
-** To avoid memory leaks, the application should invoke [sqlite3_free()]
-** on error message strings returned through the 5th parameter of
-** of sqlite3_exec() after the error message string is no longer needed.
-** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
-** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
-** NULL before returning.
-**
-** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
-** routine returns SQLITE_ABORT without invoking the callback again and
-** without running any subsequent SQL statements.
-**
-** ^The 2nd argument to the sqlite3_exec() callback function is the
-** number of columns in the result. ^The 3rd argument to the sqlite3_exec()
-** callback is an array of pointers to strings obtained as if from
-** [sqlite3_column_text()], one for each column. ^If an element of a
-** result row is NULL then the corresponding string pointer for the
-** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the
-** sqlite3_exec() callback is an array of pointers to strings where each
-** entry represents the name of corresponding result column as obtained
-** from [sqlite3_column_name()].
-**
-** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
-** to an empty string, or a pointer that contains only whitespace and/or
-** SQL comments, then no SQL statements are evaluated and the database
-** is not changed.
-**
-** Restrictions:
-**
-** <ul>
-** <li> The application must insure that the 1st parameter to sqlite3_exec()
-** is a valid and open [database connection].
-** <li> The application must not close [database connection] specified by
-** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
-** <li> The application must not modify the SQL statement text passed into
-** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
-** </ul>
-*/
-SQLITE_API int sqlite3_exec(
- sqlite3*, /* An open database */
- const char *sql, /* SQL to be evaluated */
- int (*callback)(void*,int,char**,char**), /* Callback function */
- void *, /* 1st argument to callback */
- char **errmsg /* Error msg written here */
-);
-
-/*
-** CAPI3REF: Result Codes
-** KEYWORDS: SQLITE_OK {error code} {error codes}
-** KEYWORDS: {result code} {result codes}
-**
-** Many SQLite functions return an integer result code from the set shown
-** here in order to indicate success or failure.
-**
-** New error codes may be added in future versions of SQLite.
-**
-** See also: [SQLITE_IOERR_READ | extended result codes],
-** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].
-*/
-#define SQLITE_OK 0 /* Successful result */
-/* beginning-of-error-codes */
-#define SQLITE_ERROR 1 /* SQL error or missing database */
-#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
-#define SQLITE_PERM 3 /* Access permission denied */
-#define SQLITE_ABORT 4 /* Callback routine requested an abort */
-#define SQLITE_BUSY 5 /* The database file is locked */
-#define SQLITE_LOCKED 6 /* A table in the database is locked */
-#define SQLITE_NOMEM 7 /* A malloc() failed */
-#define SQLITE_READONLY 8 /* Attempt to write a readonly database */
-#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/
-#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
-#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
-#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
-#define SQLITE_FULL 13 /* Insertion failed because database is full */
-#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
-#define SQLITE_PROTOCOL 15 /* Database lock protocol error */
-#define SQLITE_EMPTY 16 /* Database is empty */
-#define SQLITE_SCHEMA 17 /* The database schema changed */
-#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
-#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
-#define SQLITE_MISMATCH 20 /* Data type mismatch */
-#define SQLITE_MISUSE 21 /* Library used incorrectly */
-#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
-#define SQLITE_AUTH 23 /* Authorization denied */
-#define SQLITE_FORMAT 24 /* Auxiliary database format error */
-#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
-#define SQLITE_NOTADB 26 /* File opened that is not a database file */
-#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
-#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
-/* end-of-error-codes */
-
-/*
-** CAPI3REF: Extended Result Codes
-** KEYWORDS: {extended error code} {extended error codes}
-** KEYWORDS: {extended result code} {extended result codes}
-**
-** In its default configuration, SQLite API routines return one of 26 integer
-** [SQLITE_OK | result codes]. However, experience has shown that many of
-** these result codes are too coarse-grained. They do not provide as
-** much information about problems as programmers might like. In an effort to
-** address this, newer versions of SQLite (version 3.3.8 and later) include
-** support for additional result codes that provide more detailed information
-** about errors. The extended result codes are enabled or disabled
-** on a per database connection basis using the
-** [sqlite3_extended_result_codes()] API.
-**
-** Some of the available extended result codes are listed here.
-** One may expect the number of extended result codes will be expand
-** over time. Software that uses extended result codes should expect
-** to see new result codes in future releases of SQLite.
-**
-** The SQLITE_OK result code will never be extended. It will always
-** be exactly zero.
-*/
-#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
-#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
-#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
-#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
-#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
-#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8))
-#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))
-#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))
-#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))
-#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8))
-#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8))
-#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8))
-#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
-#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
-#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
-#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
-#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
-#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8))
-#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
-#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
-#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
-#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
-#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
-#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
-#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
-#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
-#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
-#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
-#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
-#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
-
-/*
-** CAPI3REF: Flags For File Open Operations
-**
-** These bit values are intended for use in the
-** 3rd parameter to the [sqlite3_open_v2()] interface and
-** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
-*/
-#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */
-#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */
-#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */
-#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_MEMORY 0x00000080 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */
-#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */
-#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */
-#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */
-#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */
-#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */
-#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */
-#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
-#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
-
-/* Reserved: 0x00F00000 */
-
-/*
-** CAPI3REF: Device Characteristics
-**
-** The xDeviceCharacteristics method of the [sqlite3_io_methods]
-** object returns an integer which is a vector of the these
-** bit values expressing I/O characteristics of the mass storage
-** device that holds the file that the [sqlite3_io_methods]
-** refers to.
-**
-** The SQLITE_IOCAP_ATOMIC property means that all writes of
-** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
-** mean that writes of blocks that are nnn bytes in size and
-** are aligned to an address which is an integer multiple of
-** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
-** that when data is appended to a file, the data is appended
-** first then the size of the file is extended, never the other
-** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
-** information is written to disk in the same order as calls
-** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
-** after reboot following a crash or power loss, the only bytes in a
-** file that were written at the application level might have changed
-** and that adjacent bytes, even bytes within the same sector are
-** guaranteed to be unchanged.
-*/
-#define SQLITE_IOCAP_ATOMIC 0x00000001
-#define SQLITE_IOCAP_ATOMIC512 0x00000002
-#define SQLITE_IOCAP_ATOMIC1K 0x00000004
-#define SQLITE_IOCAP_ATOMIC2K 0x00000008
-#define SQLITE_IOCAP_ATOMIC4K 0x00000010
-#define SQLITE_IOCAP_ATOMIC8K 0x00000020
-#define SQLITE_IOCAP_ATOMIC16K 0x00000040
-#define SQLITE_IOCAP_ATOMIC32K 0x00000080
-#define SQLITE_IOCAP_ATOMIC64K 0x00000100
-#define SQLITE_IOCAP_SAFE_APPEND 0x00000200
-#define SQLITE_IOCAP_SEQUENTIAL 0x00000400
-#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800
-#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
-
-/*
-** CAPI3REF: File Locking Levels
-**
-** SQLite uses one of these integer values as the second
-** argument to calls it makes to the xLock() and xUnlock() methods
-** of an [sqlite3_io_methods] object.
-*/
-#define SQLITE_LOCK_NONE 0
-#define SQLITE_LOCK_SHARED 1
-#define SQLITE_LOCK_RESERVED 2
-#define SQLITE_LOCK_PENDING 3
-#define SQLITE_LOCK_EXCLUSIVE 4
-
-/*
-** CAPI3REF: Synchronization Type Flags
-**
-** When SQLite invokes the xSync() method of an
-** [sqlite3_io_methods] object it uses a combination of
-** these integer values as the second argument.
-**
-** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
-** sync operation only needs to flush data to mass storage. Inode
-** information need not be flushed. If the lower four bits of the flag
-** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
-** If the lower four bits equal SQLITE_SYNC_FULL, that means
-** to use Mac OS X style fullsync instead of fsync().
-**
-** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags
-** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL
-** settings. The [synchronous pragma] determines when calls to the
-** xSync VFS method occur and applies uniformly across all platforms.
-** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how
-** energetic or rigorous or forceful the sync operations are and
-** only make a difference on Mac OSX for the default SQLite code.
-** (Third-party VFS implementations might also make the distinction
-** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the
-** operating systems natively supported by SQLite, only Mac OSX
-** cares about the difference.)
-*/
-#define SQLITE_SYNC_NORMAL 0x00002
-#define SQLITE_SYNC_FULL 0x00003
-#define SQLITE_SYNC_DATAONLY 0x00010
-
-/*
-** CAPI3REF: OS Interface Open File Handle
-**
-** An [sqlite3_file] object represents an open file in the
-** [sqlite3_vfs | OS interface layer]. Individual OS interface
-** implementations will
-** want to subclass this object by appending additional fields
-** for their own use. The pMethods entry is a pointer to an
-** [sqlite3_io_methods] object that defines methods for performing
-** I/O operations on the open file.
-*/
-typedef struct sqlite3_file sqlite3_file;
-struct sqlite3_file {
- const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
-};
-
-/*
-** CAPI3REF: OS Interface File Virtual Methods Object
-**
-** Every file opened by the [sqlite3_vfs.xOpen] method populates an
-** [sqlite3_file] object (or, more commonly, a subclass of the
-** [sqlite3_file] object) with a pointer to an instance of this object.
-** This object defines the methods used to perform various operations
-** against the open file represented by the [sqlite3_file] object.
-**
-** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element
-** to a non-NULL pointer, then the sqlite3_io_methods.xClose method
-** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The
-** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]
-** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element
-** to NULL.
-**
-** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
-** [SQLITE_SYNC_FULL]. The first choice is the normal fsync().
-** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY]
-** flag may be ORed in to indicate that only the data of the file
-** and not its inode needs to be synced.
-**
-** The integer values to xLock() and xUnlock() are one of
-** <ul>
-** <li> [SQLITE_LOCK_NONE],
-** <li> [SQLITE_LOCK_SHARED],
-** <li> [SQLITE_LOCK_RESERVED],
-** <li> [SQLITE_LOCK_PENDING], or
-** <li> [SQLITE_LOCK_EXCLUSIVE].
-** </ul>
-** xLock() increases the lock. xUnlock() decreases the lock.
-** The xCheckReservedLock() method checks whether any database connection,
-** either in this process or in some other process, is holding a RESERVED,
-** PENDING, or EXCLUSIVE lock on the file. It returns true
-** if such a lock exists and false otherwise.
-**
-** The xFileControl() method is a generic interface that allows custom
-** VFS implementations to directly control an open file using the
-** [sqlite3_file_control()] interface. The second "op" argument is an
-** integer opcode. The third argument is a generic pointer intended to
-** point to a structure that may contain arguments or space in which to
-** write return values. Potential uses for xFileControl() might be
-** functions to enable blocking locks with timeouts, to change the
-** locking strategy (for example to use dot-file locks), to inquire
-** about the status of a lock, or to break stale locks. The SQLite
-** core reserves all opcodes less than 100 for its own use.
-** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available.
-** Applications that define a custom xFileControl method should use opcodes
-** greater than 100 to avoid conflicts. VFS implementations should
-** return [SQLITE_NOTFOUND] for file control opcodes that they do not
-** recognize.
-**
-** The xSectorSize() method returns the sector size of the
-** device that underlies the file. The sector size is the
-** minimum write that can be performed without disturbing
-** other bytes in the file. The xDeviceCharacteristics()
-** method returns a bit vector describing behaviors of the
-** underlying device:
-**
-** <ul>
-** <li> [SQLITE_IOCAP_ATOMIC]
-** <li> [SQLITE_IOCAP_ATOMIC512]
-** <li> [SQLITE_IOCAP_ATOMIC1K]
-** <li> [SQLITE_IOCAP_ATOMIC2K]
-** <li> [SQLITE_IOCAP_ATOMIC4K]
-** <li> [SQLITE_IOCAP_ATOMIC8K]
-** <li> [SQLITE_IOCAP_ATOMIC16K]
-** <li> [SQLITE_IOCAP_ATOMIC32K]
-** <li> [SQLITE_IOCAP_ATOMIC64K]
-** <li> [SQLITE_IOCAP_SAFE_APPEND]
-** <li> [SQLITE_IOCAP_SEQUENTIAL]
-** </ul>
-**
-** The SQLITE_IOCAP_ATOMIC property means that all writes of
-** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
-** mean that writes of blocks that are nnn bytes in size and
-** are aligned to an address which is an integer multiple of
-** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
-** that when data is appended to a file, the data is appended
-** first then the size of the file is extended, never the other
-** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
-** information is written to disk in the same order as calls
-** to xWrite().
-**
-** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
-** in the unread portions of the buffer with zeros. A VFS that
-** fails to zero-fill short reads might seem to work. However,
-** failure to zero-fill short reads will eventually lead to
-** database corruption.
-*/
-typedef struct sqlite3_io_methods sqlite3_io_methods;
-struct sqlite3_io_methods {
- int iVersion;
- int (*xClose)(sqlite3_file*);
- int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
- int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
- int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
- int (*xSync)(sqlite3_file*, int flags);
- int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
- int (*xLock)(sqlite3_file*, int);
- int (*xUnlock)(sqlite3_file*, int);
- int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
- int (*xFileControl)(sqlite3_file*, int op, void *pArg);
- int (*xSectorSize)(sqlite3_file*);
- int (*xDeviceCharacteristics)(sqlite3_file*);
- /* Methods above are valid for version 1 */
- int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
- int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
- void (*xShmBarrier)(sqlite3_file*);
- int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
- /* Methods above are valid for version 2 */
- /* Additional methods may be added in future releases */
-};
-
-/*
-** CAPI3REF: Standard File Control Opcodes
-**
-** These integer constants are opcodes for the xFileControl method
-** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
-** interface.
-**
-** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
-** opcode causes the xFileControl method to write the current state of
-** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
-** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
-** into an integer that the pArg argument points to. This capability
-** is used during testing and only needs to be supported when SQLITE_TEST
-** is defined.
-** <ul>
-** <li>[[SQLITE_FCNTL_SIZE_HINT]]
-** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
-** layer a hint of how large the database file will grow to be during the
-** current transaction. This hint is not guaranteed to be accurate but it
-** is often close. The underlying VFS might choose to preallocate database
-** file space based on this hint in order to help writes to the database
-** file run faster.
-**
-** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
-** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
-** extends and truncates the database file in chunks of a size specified
-** by the user. The fourth argument to [sqlite3_file_control()] should
-** point to an integer (type int) containing the new chunk-size to use
-** for the nominated database. Allocating database file space in large
-** chunks (say 1MB at a time), may reduce file-system fragmentation and
-** improve performance on some systems.
-**
-** <li>[[SQLITE_FCNTL_FILE_POINTER]]
-** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
-** to the [sqlite3_file] object associated with a particular database
-** connection. See the [sqlite3_file_control()] documentation for
-** additional information.
-**
-** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
-** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by
-** SQLite and sent to all VFSes in place of a call to the xSync method
-** when the database connection has [PRAGMA synchronous] set to OFF.)^
-** Some specialized VFSes need this signal in order to operate correctly
-** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most
-** VFSes do not need this signal and should silently ignore this opcode.
-** Applications should not call [sqlite3_file_control()] with this
-** opcode as doing so may disrupt the operation of the specialized VFSes
-** that do require it.
-**
-** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]
-** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
-** retry counts and intervals for certain disk I/O operations for the
-** windows [VFS] in order to provide robustness in the presence of
-** anti-virus programs. By default, the windows VFS will retry file read,
-** file write, and file delete operations up to 10 times, with a delay
-** of 25 milliseconds before the first retry and with the delay increasing
-** by an additional 25 milliseconds with each subsequent retry. This
-** opcode allows these two values (10 retries and 25 milliseconds of delay)
-** to be adjusted. The values are changed for all database connections
-** within the same process. The argument is a pointer to an array of two
-** integers where the first integer i the new retry count and the second
-** integer is the delay. If either integer is negative, then the setting
-** is not changed but instead the prior value of that setting is written
-** into the array entry, allowing the current retry settings to be
-** interrogated. The zDbName parameter is ignored.
-**
-** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
-** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
-** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary
-** write ahead log and shared memory files used for transaction control
-** are automatically deleted when the latest connection to the database
-** closes. Setting persistent WAL mode causes those files to persist after
-** close. Persisting the files is useful when other processes that do not
-** have write permission on the directory containing the database file want
-** to read the database file, as the WAL and shared memory files must exist
-** in order for the database to be readable. The fourth parameter to
-** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
-** That integer is 0 to disable persistent WAL mode or 1 to enable persistent
-** WAL mode. If the integer is -1, then it is overwritten with the current
-** WAL persistence setting.
-**
-** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]
-** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the
-** persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting
-** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the
-** xDeviceCharacteristics methods. The fourth parameter to
-** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
-** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage
-** mode. If the integer is -1, then it is overwritten with the current
-** zero-damage mode setting.
-**
-** <li>[[SQLITE_FCNTL_OVERWRITE]]
-** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening
-** a write transaction to indicate that, unless it is rolled back for some
-** reason, the entire database file will be overwritten by the current
-** transaction. This is used by VACUUM operations.
-**
-** <li>[[SQLITE_FCNTL_VFSNAME]]
-** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of
-** all [VFSes] in the VFS stack. The names are of all VFS shims and the
-** final bottom-level VFS are written into memory obtained from
-** [sqlite3_malloc()] and the result is stored in the char* variable
-** that the fourth parameter of [sqlite3_file_control()] points to.
-** The caller is responsible for freeing the memory when done. As with
-** all file-control actions, there is no guarantee that this will actually
-** do anything. Callers should initialize the char* variable to a NULL
-** pointer in case this file-control is not implemented. This file-control
-** is intended for diagnostic use only.
-**
-** <li>[[SQLITE_FCNTL_PRAGMA]]
-** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA]
-** file control is sent to the open [sqlite3_file] object corresponding
-** to the database file to which the pragma statement refers. ^The argument
-** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
-** pointers to strings (char**) in which the second element of the array
-** is the name of the pragma and the third element is the argument to the
-** pragma or NULL if the pragma has no argument. ^The handler for an
-** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element
-** of the char** argument point to a string obtained from [sqlite3_mprintf()]
-** or the equivalent and that string will become the result of the pragma or
-** the error message if the pragma fails. ^If the
-** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
-** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
-** file control returns [SQLITE_OK], then the parser assumes that the
-** VFS has handled the PRAGMA itself and the parser generates a no-op
-** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns
-** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
-** that the VFS encountered an error while handling the [PRAGMA] and the
-** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
-** file control occurs at the beginning of pragma statement analysis and so
-** it is able to override built-in [PRAGMA] statements.
-** </ul>
-*/
-#define SQLITE_FCNTL_LOCKSTATE 1
-#define SQLITE_GET_LOCKPROXYFILE 2
-#define SQLITE_SET_LOCKPROXYFILE 3
-#define SQLITE_LAST_ERRNO 4
-#define SQLITE_FCNTL_SIZE_HINT 5
-#define SQLITE_FCNTL_CHUNK_SIZE 6
-#define SQLITE_FCNTL_FILE_POINTER 7
-#define SQLITE_FCNTL_SYNC_OMITTED 8
-#define SQLITE_FCNTL_WIN32_AV_RETRY 9
-#define SQLITE_FCNTL_PERSIST_WAL 10
-#define SQLITE_FCNTL_OVERWRITE 11
-#define SQLITE_FCNTL_VFSNAME 12
-#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13
-#define SQLITE_FCNTL_PRAGMA 14
-
-/*
-** CAPI3REF: Mutex Handle
-**
-** The mutex module within SQLite defines [sqlite3_mutex] to be an
-** abstract type for a mutex object. The SQLite core never looks
-** at the internal representation of an [sqlite3_mutex]. It only
-** deals with pointers to the [sqlite3_mutex] object.
-**
-** Mutexes are created using [sqlite3_mutex_alloc()].
-*/
-typedef struct sqlite3_mutex sqlite3_mutex;
-
-/*
-** CAPI3REF: OS Interface Object
-**
-** An instance of the sqlite3_vfs object defines the interface between
-** the SQLite core and the underlying operating system. The "vfs"
-** in the name of the object stands for "virtual file system". See
-** the [VFS | VFS documentation] for further information.
-**
-** The value of the iVersion field is initially 1 but may be larger in
-** future versions of SQLite. Additional fields may be appended to this
-** object when the iVersion value is increased. Note that the structure
-** of the sqlite3_vfs object changes in the transaction between
-** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not
-** modified.
-**
-** The szOsFile field is the size of the subclassed [sqlite3_file]
-** structure used by this VFS. mxPathname is the maximum length of
-** a pathname in this VFS.
-**
-** Registered sqlite3_vfs objects are kept on a linked list formed by
-** the pNext pointer. The [sqlite3_vfs_register()]
-** and [sqlite3_vfs_unregister()] interfaces manage this list
-** in a thread-safe way. The [sqlite3_vfs_find()] interface
-** searches the list. Neither the application code nor the VFS
-** implementation should use the pNext pointer.
-**
-** The pNext field is the only field in the sqlite3_vfs
-** structure that SQLite will ever modify. SQLite will only access
-** or modify this field while holding a particular static mutex.
-** The application should never modify anything within the sqlite3_vfs
-** object once the object has been registered.
-**
-** The zName field holds the name of the VFS module. The name must
-** be unique across all VFS modules.
-**
-** [[sqlite3_vfs.xOpen]]
-** ^SQLite guarantees that the zFilename parameter to xOpen
-** is either a NULL pointer or string obtained
-** from xFullPathname() with an optional suffix added.
-** ^If a suffix is added to the zFilename parameter, it will
-** consist of a single "-" character followed by no more than
-** 11 alphanumeric and/or "-" characters.
-** ^SQLite further guarantees that
-** the string will be valid and unchanged until xClose() is
-** called. Because of the previous sentence,
-** the [sqlite3_file] can safely store a pointer to the
-** filename if it needs to remember the filename for some reason.
-** If the zFilename parameter to xOpen is a NULL pointer then xOpen
-** must invent its own temporary name for the file. ^Whenever the
-** xFilename parameter is NULL it will also be the case that the
-** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
-**
-** The flags argument to xOpen() includes all bits set in
-** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()]
-** or [sqlite3_open16()] is used, then flags includes at least
-** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE].
-** If xOpen() opens a file read-only then it sets *pOutFlags to
-** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set.
-**
-** ^(SQLite will also add one of the following flags to the xOpen()
-** call, depending on the object being opened:
-**
-** <ul>
-** <li> [SQLITE_OPEN_MAIN_DB]
-** <li> [SQLITE_OPEN_MAIN_JOURNAL]
-** <li> [SQLITE_OPEN_TEMP_DB]
-** <li> [SQLITE_OPEN_TEMP_JOURNAL]
-** <li> [SQLITE_OPEN_TRANSIENT_DB]
-** <li> [SQLITE_OPEN_SUBJOURNAL]
-** <li> [SQLITE_OPEN_MASTER_JOURNAL]
-** <li> [SQLITE_OPEN_WAL]
-** </ul>)^
-**
-** The file I/O implementation can use the object type flags to
-** change the way it deals with files. For example, an application
-** that does not care about crash recovery or rollback might make
-** the open of a journal file a no-op. Writes to this journal would
-** also be no-ops, and any attempt to read the journal would return
-** SQLITE_IOERR. Or the implementation might recognize that a database
-** file will be doing page-aligned sector reads and writes in a random
-** order and set up its I/O subsystem accordingly.
-**
-** SQLite might also add one of the following flags to the xOpen method:
-**
-** <ul>
-** <li> [SQLITE_OPEN_DELETEONCLOSE]
-** <li> [SQLITE_OPEN_EXCLUSIVE]
-** </ul>
-**
-** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
-** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE]
-** will be set for TEMP databases and their journals, transient
-** databases, and subjournals.
-**
-** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
-** with the [SQLITE_OPEN_CREATE] flag, which are both directly
-** analogous to the O_EXCL and O_CREAT flags of the POSIX open()
-** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the
-** SQLITE_OPEN_CREATE, is used to indicate that file should always
-** be created, and that it is an error if it already exists.
-** It is <i>not</i> used to indicate the file should be opened
-** for exclusive access.
-**
-** ^At least szOsFile bytes of memory are allocated by SQLite
-** to hold the [sqlite3_file] structure passed as the third
-** argument to xOpen. The xOpen method does not have to
-** allocate the structure; it should just fill it in. Note that
-** the xOpen method must set the sqlite3_file.pMethods to either
-** a valid [sqlite3_io_methods] object or to NULL. xOpen must do
-** this even if the open fails. SQLite expects that the sqlite3_file.pMethods
-** element will be valid after xOpen returns regardless of the success
-** or failure of the xOpen call.
-**
-** [[sqlite3_vfs.xAccess]]
-** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
-** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
-** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
-** to test whether a file is at least readable. The file can be a
-** directory.
-**
-** ^SQLite will always allocate at least mxPathname+1 bytes for the
-** output buffer xFullPathname. The exact size of the output buffer
-** is also passed as a parameter to both methods. If the output buffer
-** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
-** handled as a fatal error by SQLite, vfs implementations should endeavor
-** to prevent this by setting mxPathname to a sufficiently large value.
-**
-** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
-** interfaces are not strictly a part of the filesystem, but they are
-** included in the VFS structure for completeness.
-** The xRandomness() function attempts to return nBytes bytes
-** of good-quality randomness into zOut. The return value is
-** the actual number of bytes of randomness obtained.
-** The xSleep() method causes the calling thread to sleep for at
-** least the number of microseconds given. ^The xCurrentTime()
-** method returns a Julian Day Number for the current date and time as
-** a floating point value.
-** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
-** Day Number multiplied by 86400000 (the number of milliseconds in
-** a 24-hour day).
-** ^SQLite will use the xCurrentTimeInt64() method to get the current
-** date and time if that method is available (if iVersion is 2 or
-** greater and the function pointer is not NULL) and will fall back
-** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
-**
-** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
-** are not used by the SQLite core. These optional interfaces are provided
-** by some VFSes to facilitate testing of the VFS code. By overriding
-** system calls with functions under its control, a test program can
-** simulate faults and error conditions that would otherwise be difficult
-** or impossible to induce. The set of system calls that can be overridden
-** varies from one VFS to another, and from one version of the same VFS to the
-** next. Applications that use these interfaces must be prepared for any
-** or all of these interfaces to be NULL or for their behavior to change
-** from one release to the next. Applications must not attempt to access
-** any of these methods if the iVersion of the VFS is less than 3.
-*/
-typedef struct sqlite3_vfs sqlite3_vfs;
-typedef void (*sqlite3_syscall_ptr)(void);
-struct sqlite3_vfs {
- int iVersion; /* Structure version number (currently 3) */
- int szOsFile; /* Size of subclassed sqlite3_file */
- int mxPathname; /* Maximum file pathname length */
- sqlite3_vfs *pNext; /* Next registered VFS */
- const char *zName; /* Name of this virtual file system */
- void *pAppData; /* Pointer to application-specific data */
- int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
- int flags, int *pOutFlags);
- int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
- int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
- int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
- void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
- void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
- void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
- void (*xDlClose)(sqlite3_vfs*, void*);
- int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
- int (*xSleep)(sqlite3_vfs*, int microseconds);
- int (*xCurrentTime)(sqlite3_vfs*, double*);
- int (*xGetLastError)(sqlite3_vfs*, int, char *);
- /*
- ** The methods above are in version 1 of the sqlite_vfs object
- ** definition. Those that follow are added in version 2 or later
- */
- int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
- /*
- ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
- ** Those below are for version 3 and greater.
- */
- int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
- sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
- const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
- /*
- ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
- ** New fields may be appended in figure versions. The iVersion
- ** value will increment whenever this happens.
- */
-};
-
-/*
-** CAPI3REF: Flags for the xAccess VFS method
-**
-** These integer constants can be used as the third parameter to
-** the xAccess method of an [sqlite3_vfs] object. They determine
-** what kind of permissions the xAccess method is looking for.
-** With SQLITE_ACCESS_EXISTS, the xAccess method
-** simply checks whether the file exists.
-** With SQLITE_ACCESS_READWRITE, the xAccess method
-** checks whether the named directory is both readable and writable
-** (in other words, if files can be added, removed, and renamed within
-** the directory).
-** The SQLITE_ACCESS_READWRITE constant is currently used only by the
-** [temp_store_directory pragma], though this could change in a future
-** release of SQLite.
-** With SQLITE_ACCESS_READ, the xAccess method
-** checks whether the file is readable. The SQLITE_ACCESS_READ constant is
-** currently unused, though it might be used in a future release of
-** SQLite.
-*/
-#define SQLITE_ACCESS_EXISTS 0
-#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
-#define SQLITE_ACCESS_READ 2 /* Unused */
-
-/*
-** CAPI3REF: Flags for the xShmLock VFS method
-**
-** These integer constants define the various locking operations
-** allowed by the xShmLock method of [sqlite3_io_methods]. The
-** following are the only legal combinations of flags to the
-** xShmLock method:
-**
-** <ul>
-** <li> SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
-** <li> SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
-** <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
-** <li> SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
-** </ul>
-**
-** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
-** was given no the corresponding lock.
-**
-** The xShmLock method can transition between unlocked and SHARED or
-** between unlocked and EXCLUSIVE. It cannot transition between SHARED
-** and EXCLUSIVE.
-*/
-#define SQLITE_SHM_UNLOCK 1
-#define SQLITE_SHM_LOCK 2
-#define SQLITE_SHM_SHARED 4
-#define SQLITE_SHM_EXCLUSIVE 8
-
-/*
-** CAPI3REF: Maximum xShmLock index
-**
-** The xShmLock method on [sqlite3_io_methods] may use values
-** between 0 and this upper bound as its "offset" argument.
-** The SQLite core will never attempt to acquire or release a
-** lock outside of this range
-*/
-#define SQLITE_SHM_NLOCK 8
-
-
-/*
-** CAPI3REF: Initialize The SQLite Library
-**
-** ^The sqlite3_initialize() routine initializes the
-** SQLite library. ^The sqlite3_shutdown() routine
-** deallocates any resources that were allocated by sqlite3_initialize().
-** These routines are designed to aid in process initialization and
-** shutdown on embedded systems. Workstation applications using
-** SQLite normally do not need to invoke either of these routines.
-**
-** A call to sqlite3_initialize() is an "effective" call if it is
-** the first time sqlite3_initialize() is invoked during the lifetime of
-** the process, or if it is the first time sqlite3_initialize() is invoked
-** following a call to sqlite3_shutdown(). ^(Only an effective call
-** of sqlite3_initialize() does any initialization. All other calls
-** are harmless no-ops.)^
-**
-** A call to sqlite3_shutdown() is an "effective" call if it is the first
-** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only
-** an effective call to sqlite3_shutdown() does any deinitialization.
-** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
-**
-** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
-** is not. The sqlite3_shutdown() interface must only be called from a
-** single thread. All open [database connections] must be closed and all
-** other SQLite resources must be deallocated prior to invoking
-** sqlite3_shutdown().
-**
-** Among other things, ^sqlite3_initialize() will invoke
-** sqlite3_os_init(). Similarly, ^sqlite3_shutdown()
-** will invoke sqlite3_os_end().
-**
-** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
-** ^If for some reason, sqlite3_initialize() is unable to initialize
-** the library (perhaps it is unable to allocate a needed resource such
-** as a mutex) it returns an [error code] other than [SQLITE_OK].
-**
-** ^The sqlite3_initialize() routine is called internally by many other
-** SQLite interfaces so that an application usually does not need to
-** invoke sqlite3_initialize() directly. For example, [sqlite3_open()]
-** calls sqlite3_initialize() so the SQLite library will be automatically
-** initialized when [sqlite3_open()] is called if it has not be initialized
-** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
-** compile-time option, then the automatic calls to sqlite3_initialize()
-** are omitted and the application must call sqlite3_initialize() directly
-** prior to using any other SQLite interface. For maximum portability,
-** it is recommended that applications always invoke sqlite3_initialize()
-** directly prior to using any other SQLite interface. Future releases
-** of SQLite may require this. In other words, the behavior exhibited
-** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the
-** default behavior in some future release of SQLite.
-**
-** The sqlite3_os_init() routine does operating-system specific
-** initialization of the SQLite library. The sqlite3_os_end()
-** routine undoes the effect of sqlite3_os_init(). Typical tasks
-** performed by these routines include allocation or deallocation
-** of static resources, initialization of global variables,
-** setting up a default [sqlite3_vfs] module, or setting up
-** a default configuration using [sqlite3_config()].
-**
-** The application should never invoke either sqlite3_os_init()
-** or sqlite3_os_end() directly. The application should only invoke
-** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init()
-** interface is called automatically by sqlite3_initialize() and
-** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate
-** implementations for sqlite3_os_init() and sqlite3_os_end()
-** are built into SQLite when it is compiled for Unix, Windows, or OS/2.
-** When [custom builds | built for other platforms]
-** (using the [SQLITE_OS_OTHER=1] compile-time
-** option) the application must supply a suitable implementation for
-** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
-** implementation of sqlite3_os_init() or sqlite3_os_end()
-** must return [SQLITE_OK] on success and some other [error code] upon
-** failure.
-*/
-SQLITE_API int sqlite3_initialize(void);
-SQLITE_API int sqlite3_shutdown(void);
-SQLITE_API int sqlite3_os_init(void);
-SQLITE_API int sqlite3_os_end(void);
-
-/*
-** CAPI3REF: Configuring The SQLite Library
-**
-** The sqlite3_config() interface is used to make global configuration
-** changes to SQLite in order to tune SQLite to the specific needs of
-** the application. The default configuration is recommended for most
-** applications and so this routine is usually not necessary. It is
-** provided to support rare applications with unusual needs.
-**
-** The sqlite3_config() interface is not threadsafe. The application
-** must insure that no other SQLite interfaces are invoked by other
-** threads while sqlite3_config() is running. Furthermore, sqlite3_config()
-** may only be invoked prior to library initialization using
-** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
-** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
-** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
-** Note, however, that ^sqlite3_config() can be called as part of the
-** implementation of an application-defined [sqlite3_os_init()].
-**
-** The first argument to sqlite3_config() is an integer
-** [configuration option] that determines
-** what property of SQLite is to be configured. Subsequent arguments
-** vary depending on the [configuration option]
-** in the first argument.
-**
-** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
-** ^If the option is unknown or SQLite is unable to set the option
-** then this routine returns a non-zero [error code].
-*/
-SQLITE_API int sqlite3_config(int, ...);
-
-/*
-** CAPI3REF: Configure database connections
-**
-** The sqlite3_db_config() interface is used to make configuration
-** changes to a [database connection]. The interface is similar to
-** [sqlite3_config()] except that the changes apply to a single
-** [database connection] (specified in the first argument).
-**
-** The second argument to sqlite3_db_config(D,V,...) is the
-** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code
-** that indicates what aspect of the [database connection] is being configured.
-** Subsequent arguments vary depending on the configuration verb.
-**
-** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
-** the call is considered successful.
-*/
-SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
-
-/*
-** CAPI3REF: Memory Allocation Routines
-**
-** An instance of this object defines the interface between SQLite
-** and low-level memory allocation routines.
-**
-** This object is used in only one place in the SQLite interface.
-** A pointer to an instance of this object is the argument to
-** [sqlite3_config()] when the configuration option is
-** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].
-** By creating an instance of this object
-** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
-** during configuration, an application can specify an alternative
-** memory allocation subsystem for SQLite to use for all of its
-** dynamic memory needs.
-**
-** Note that SQLite comes with several [built-in memory allocators]
-** that are perfectly adequate for the overwhelming majority of applications
-** and that this object is only useful to a tiny minority of applications
-** with specialized memory allocation requirements. This object is
-** also used during testing of SQLite in order to specify an alternative
-** memory allocator that simulates memory out-of-memory conditions in
-** order to verify that SQLite recovers gracefully from such
-** conditions.
-**
-** The xMalloc, xRealloc, and xFree methods must work like the
-** malloc(), realloc() and free() functions from the standard C library.
-** ^SQLite guarantees that the second argument to
-** xRealloc is always a value returned by a prior call to xRoundup.
-**
-** xSize should return the allocated size of a memory allocation
-** previously obtained from xMalloc or xRealloc. The allocated size
-** is always at least as big as the requested size but may be larger.
-**
-** The xRoundup method returns what would be the allocated size of
-** a memory allocation given a particular requested size. Most memory
-** allocators round up memory allocations at least to the next multiple
-** of 8. Some allocators round up to a larger multiple or to a power of 2.
-** Every memory allocation request coming in through [sqlite3_malloc()]
-** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0,
-** that causes the corresponding memory allocation to fail.
-**
-** The xInit method initializes the memory allocator. (For example,
-** it might allocate any require mutexes or initialize internal data
-** structures. The xShutdown method is invoked (indirectly) by
-** [sqlite3_shutdown()] and should deallocate any resources acquired
-** by xInit. The pAppData pointer is used as the only parameter to
-** xInit and xShutdown.
-**
-** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes
-** the xInit method, so the xInit method need not be threadsafe. The
-** xShutdown method is only called from [sqlite3_shutdown()] so it does
-** not need to be threadsafe either. For all other methods, SQLite
-** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the
-** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which
-** it is by default) and so the methods are automatically serialized.
-** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other
-** methods must be threadsafe or else make their own arrangements for
-** serialization.
-**
-** SQLite will never invoke xInit() more than once without an intervening
-** call to xShutdown().
-*/
-typedef struct sqlite3_mem_methods sqlite3_mem_methods;
-struct sqlite3_mem_methods {
- void *(*xMalloc)(int); /* Memory allocation function */
- void (*xFree)(void*); /* Free a prior allocation */
- void *(*xRealloc)(void*,int); /* Resize an allocation */
- int (*xSize)(void*); /* Return the size of an allocation */
- int (*xRoundup)(int); /* Round up request size to allocation size */
- int (*xInit)(void*); /* Initialize the memory allocator */
- void (*xShutdown)(void*); /* Deinitialize the memory allocator */
- void *pAppData; /* Argument to xInit() and xShutdown() */
-};
-
-/*
-** CAPI3REF: Configuration Options
-** KEYWORDS: {configuration option}
-**
-** These constants are the available integer configuration options that
-** can be passed as the first argument to the [sqlite3_config()] interface.
-**
-** New configuration options may be added in future releases of SQLite.
-** Existing configuration options might be discontinued. Applications
-** should check the return code from [sqlite3_config()] to make sure that
-** the call worked. The [sqlite3_config()] interface will return a
-** non-zero [error code] if a discontinued or unsupported configuration option
-** is invoked.
-**
-** <dl>
-** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
-** <dd>There are no arguments to this option. ^This option sets the
-** [threading mode] to Single-thread. In other words, it disables
-** all mutexing and puts SQLite into a mode where it can only be used
-** by a single thread. ^If SQLite is compiled with
-** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
-** it is not possible to change the [threading mode] from its default
-** value of Single-thread and so [sqlite3_config()] will return
-** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
-** configuration option.</dd>
-**
-** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>
-** <dd>There are no arguments to this option. ^This option sets the
-** [threading mode] to Multi-thread. In other words, it disables
-** mutexing on [database connection] and [prepared statement] objects.
-** The application is responsible for serializing access to
-** [database connections] and [prepared statements]. But other mutexes
-** are enabled so that SQLite will be safe to use in a multi-threaded
-** environment as long as no two threads attempt to use the same
-** [database connection] at the same time. ^If SQLite is compiled with
-** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
-** it is not possible to set the Multi-thread [threading mode] and
-** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
-** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
-**
-** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>
-** <dd>There are no arguments to this option. ^This option sets the
-** [threading mode] to Serialized. In other words, this option enables
-** all mutexes including the recursive
-** mutexes on [database connection] and [prepared statement] objects.
-** In this mode (which is the default when SQLite is compiled with
-** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
-** to [database connections] and [prepared statements] so that the
-** application is free to use the same [database connection] or the
-** same [prepared statement] in different threads at the same time.
-** ^If SQLite is compiled with
-** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
-** it is not possible to set the Serialized [threading mode] and
-** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
-** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
-**
-** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mem_methods] structure. The argument specifies
-** alternative low-level memory allocation routines to be used in place of
-** the memory allocation routines built into SQLite.)^ ^SQLite makes
-** its own private copy of the content of the [sqlite3_mem_methods] structure
-** before the [sqlite3_config()] call returns.</dd>
-**
-** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
-** structure is filled with the currently defined memory allocation routines.)^
-** This option can be used to overload the default memory allocation
-** routines with a wrapper that simulations memory allocation failure or
-** tracks memory usage, for example. </dd>
-**
-** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
-** <dd> ^This option takes single argument of type int, interpreted as a
-** boolean, which enables or disables the collection of memory allocation
-** statistics. ^(When memory allocation statistics are disabled, the
-** following SQLite interfaces become non-operational:
-** <ul>
-** <li> [sqlite3_memory_used()]
-** <li> [sqlite3_memory_highwater()]
-** <li> [sqlite3_soft_heap_limit64()]
-** <li> [sqlite3_status()]
-** </ul>)^
-** ^Memory allocation statistics are enabled by default unless SQLite is
-** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
-** allocation statistics are disabled by default.
-** </dd>
-**
-** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
-** <dd> ^This option specifies a static memory buffer that SQLite can use for
-** scratch memory. There are three arguments: A pointer an 8-byte
-** aligned memory buffer from which the scratch allocations will be
-** drawn, the size of each scratch allocation (sz),
-** and the maximum number of scratch allocations (N). The sz
-** argument must be a multiple of 16.
-** The first argument must be a pointer to an 8-byte aligned buffer
-** of at least sz*N bytes of memory.
-** ^SQLite will use no more than two scratch buffers per thread. So
-** N should be set to twice the expected maximum number of threads.
-** ^SQLite will never require a scratch buffer that is more than 6
-** times the database page size. ^If SQLite needs needs additional
-** scratch memory beyond what is provided by this configuration option, then
-** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
-**
-** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
-** <dd> ^This option specifies a static memory buffer that SQLite can use for
-** the database page cache with the default page cache implementation.
-** This configuration should not be used if an application-define page
-** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
-** There are three arguments to this option: A pointer to 8-byte aligned
-** memory, the size of each page buffer (sz), and the number of pages (N).
-** The sz argument should be the size of the largest database page
-** (a power of two between 512 and 32768) plus a little extra for each
-** page header. ^The page header size is 20 to 40 bytes depending on
-** the host architecture. ^It is harmless, apart from the wasted memory,
-** to make sz a little too large. The first
-** argument should point to an allocation of at least sz*N bytes of memory.
-** ^SQLite will use the memory provided by the first argument to satisfy its
-** memory needs for the first N pages that it adds to cache. ^If additional
-** page cache memory is needed beyond what is provided by this option, then
-** SQLite goes to [sqlite3_malloc()] for the additional storage space.
-** The pointer in the first argument must
-** be aligned to an 8-byte boundary or subsequent behavior of SQLite
-** will be undefined.</dd>
-**
-** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
-** <dd> ^This option specifies a static memory buffer that SQLite will use
-** for all of its dynamic memory allocation needs beyond those provided
-** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
-** There are three arguments: An 8-byte aligned pointer to the memory,
-** the number of bytes in the memory buffer, and the minimum allocation size.
-** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
-** to using its default memory allocator (the system malloc() implementation),
-** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the
-** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
-** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
-** allocator is engaged to handle all of SQLites memory allocation needs.
-** The first pointer (the memory pointer) must be aligned to an 8-byte
-** boundary or subsequent behavior of SQLite will be undefined.
-** The minimum allocation size is capped at 2**12. Reasonable values
-** for the minimum allocation size are 2**5 through 2**8.</dd>
-**
-** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mutex_methods] structure. The argument specifies
-** alternative low-level mutex routines to be used in place
-** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the
-** content of the [sqlite3_mutex_methods] structure before the call to
-** [sqlite3_config()] returns. ^If SQLite is compiled with
-** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
-** the entire mutexing subsystem is omitted from the build and hence calls to
-** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
-** return [SQLITE_ERROR].</dd>
-**
-** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mutex_methods] structure. The
-** [sqlite3_mutex_methods]
-** structure is filled with the currently defined mutex routines.)^
-** This option can be used to overload the default mutex allocation
-** routines with a wrapper used to track mutex usage for performance
-** profiling or testing, for example. ^If SQLite is compiled with
-** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
-** the entire mutexing subsystem is omitted from the build and hence calls to
-** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
-** return [SQLITE_ERROR].</dd>
-**
-** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
-** <dd> ^(This option takes two arguments that determine the default
-** memory allocation for the lookaside memory allocator on each
-** [database connection]. The first argument is the
-** size of each lookaside buffer slot and the second is the number of
-** slots allocated to each database connection.)^ ^(This option sets the
-** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
-** verb to [sqlite3_db_config()] can be used to change the lookaside
-** configuration on individual connections.)^ </dd>
-**
-** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
-** <dd> ^(This option takes a single argument which is a pointer to
-** an [sqlite3_pcache_methods2] object. This object specifies the interface
-** to a custom page cache implementation.)^ ^SQLite makes a copy of the
-** object and uses it for page cache memory allocations.</dd>
-**
-** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** [sqlite3_pcache_methods2] object. SQLite copies of the current
-** page cache implementation into that object.)^ </dd>
-**
-** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
-** <dd> ^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
-** function with a call signature of void(*)(void*,int,const char*),
-** and a pointer to void. ^If the function pointer is not NULL, it is
-** invoked by [sqlite3_log()] to process each logging event. ^If the
-** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.
-** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is
-** passed through as the first parameter to the application-defined logger
-** function whenever that function is invoked. ^The second parameter to
-** the logger function is a copy of the first parameter to the corresponding
-** [sqlite3_log()] call and is intended to be a [result code] or an
-** [extended result code]. ^The third parameter passed to the logger is
-** log message after formatting via [sqlite3_snprintf()].
-** The SQLite logging interface is not reentrant; the logger function
-** supplied by the application must not invoke any SQLite interface.
-** In a multi-threaded application, the application-defined logger
-** function must be threadsafe. </dd>
-**
-** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
-** <dd> This option takes a single argument of type int. If non-zero, then
-** URI handling is globally enabled. If the parameter is zero, then URI handling
-** is globally disabled. If URI handling is globally enabled, all filenames
-** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
-** specified as part of [ATTACH] commands are interpreted as URIs, regardless
-** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
-** connection is opened. If it is globally disabled, filenames are
-** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
-** database connection is opened. By default, URI handling is globally
-** disabled. The default value may be changed by compiling with the
-** [SQLITE_USE_URI] symbol defined.
-**
-** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
-** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
-** <dd> These options are obsolete and should not be used by new code.
-** They are retained for backwards compatibility but are now no-ops.
-** </dl>
-*/
-#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
-#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
-#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
-#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
-#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
-#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */
-#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
-#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
-#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
-#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
-#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
-/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
-#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
-#define SQLITE_CONFIG_PCACHE 14 /* no-op */
-#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
-#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
-#define SQLITE_CONFIG_URI 17 /* int */
-#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
-#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
-
-/*
-** CAPI3REF: Database Connection Configuration Options
-**
-** These constants are the available integer configuration options that
-** can be passed as the second argument to the [sqlite3_db_config()] interface.
-**
-** New configuration options may be added in future releases of SQLite.
-** Existing configuration options might be discontinued. Applications
-** should check the return code from [sqlite3_db_config()] to make sure that
-** the call worked. ^The [sqlite3_db_config()] interface will return a
-** non-zero [error code] if a discontinued or unsupported configuration option
-** is invoked.
-**
-** <dl>
-** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
-** <dd> ^This option takes three additional arguments that determine the
-** [lookaside memory allocator] configuration for the [database connection].
-** ^The first argument (the third parameter to [sqlite3_db_config()] is a
-** pointer to a memory buffer to use for lookaside memory.
-** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
-** may be NULL in which case SQLite will allocate the
-** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
-** size of each lookaside buffer slot. ^The third argument is the number of
-** slots. The size of the buffer in the first argument must be greater than
-** or equal to the product of the second and third arguments. The buffer
-** must be aligned to an 8-byte boundary. ^If the second argument to
-** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
-** rounded down to the next smaller multiple of 8. ^(The lookaside memory
-** configuration for a database connection can only be changed when that
-** connection is not currently using lookaside memory, or in other words
-** when the "current value" returned by
-** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
-** Any attempt to change the lookaside memory configuration when lookaside
-** memory is in use leaves the configuration unchanged and returns
-** [SQLITE_BUSY].)^</dd>
-**
-** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
-** <dd> ^This option is used to enable or disable the enforcement of
-** [foreign key constraints]. There should be two additional arguments.
-** The first argument is an integer which is 0 to disable FK enforcement,
-** positive to enable FK enforcement or negative to leave FK enforcement
-** unchanged. The second parameter is a pointer to an integer into which
-** is written 0 or 1 to indicate whether FK enforcement is off or on
-** following this call. The second parameter may be a NULL pointer, in
-** which case the FK enforcement setting is not reported back. </dd>
-**
-** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
-** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
-** There should be two additional arguments.
-** The first argument is an integer which is 0 to disable triggers,
-** positive to enable triggers or negative to leave the setting unchanged.
-** The second parameter is a pointer to an integer into which
-** is written 0 or 1 to indicate whether triggers are disabled or enabled
-** following this call. The second parameter may be a NULL pointer, in
-** which case the trigger setting is not reported back. </dd>
-**
-** </dl>
-*/
-#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
-#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
-#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
-
-
-/*
-** CAPI3REF: Enable Or Disable Extended Result Codes
-**
-** ^The sqlite3_extended_result_codes() routine enables or disables the
-** [extended result codes] feature of SQLite. ^The extended result
-** codes are disabled by default for historical compatibility.
-*/
-SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
-
-/*
-** CAPI3REF: Last Insert Rowid
-**
-** ^Each entry in an SQLite table has a unique 64-bit signed
-** integer key called the [ROWID | "rowid"]. ^The rowid is always available
-** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
-** names are not also used by explicitly declared columns. ^If
-** the table has a column of type [INTEGER PRIMARY KEY] then that column
-** is another alias for the rowid.
-**
-** ^This routine returns the [rowid] of the most recent
-** successful [INSERT] into the database from the [database connection]
-** in the first argument. ^As of SQLite version 3.7.7, this routines
-** records the last insert rowid of both ordinary tables and [virtual tables].
-** ^If no successful [INSERT]s
-** have ever occurred on that database connection, zero is returned.
-**
-** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
-** method, then this routine will return the [rowid] of the inserted
-** row as long as the trigger or virtual table method is running.
-** But once the trigger or virtual table method ends, the value returned
-** by this routine reverts to what it was before the trigger or virtual
-** table method began.)^
-**
-** ^An [INSERT] that fails due to a constraint violation is not a
-** successful [INSERT] and does not change the value returned by this
-** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
-** and INSERT OR ABORT make no changes to the return value of this
-** routine when their insertion fails. ^(When INSERT OR REPLACE
-** encounters a constraint violation, it does not fail. The
-** INSERT continues to completion after deleting rows that caused
-** the constraint problem so INSERT OR REPLACE will always change
-** the return value of this interface.)^
-**
-** ^For the purposes of this routine, an [INSERT] is considered to
-** be successful even if it is subsequently rolled back.
-**
-** This function is accessible to SQL statements via the
-** [last_insert_rowid() SQL function].
-**
-** If a separate thread performs a new [INSERT] on the same
-** database connection while the [sqlite3_last_insert_rowid()]
-** function is running and thus changes the last insert [rowid],
-** then the value returned by [sqlite3_last_insert_rowid()] is
-** unpredictable and might not equal either the old or the new
-** last insert [rowid].
-*/
-SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
-
-/*
-** CAPI3REF: Count The Number Of Rows Modified
-**
-** ^This function returns the number of database rows that were changed
-** or inserted or deleted by the most recently completed SQL statement
-** on the [database connection] specified by the first parameter.
-** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
-** or [DELETE] statement are counted. Auxiliary changes caused by
-** triggers or [foreign key actions] are not counted.)^ Use the
-** [sqlite3_total_changes()] function to find the total number of changes
-** including changes caused by triggers and foreign key actions.
-**
-** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
-** are not counted. Only real table changes are counted.
-**
-** ^(A "row change" is a change to a single row of a single table
-** caused by an INSERT, DELETE, or UPDATE statement. Rows that
-** are changed as side effects of [REPLACE] constraint resolution,
-** rollback, ABORT processing, [DROP TABLE], or by any other
-** mechanisms do not count as direct row changes.)^
-**
-** A "trigger context" is a scope of execution that begins and
-** ends with the script of a [CREATE TRIGGER | trigger].
-** Most SQL statements are
-** evaluated outside of any trigger. This is the "top level"
-** trigger context. If a trigger fires from the top level, a
-** new trigger context is entered for the duration of that one
-** trigger. Subtriggers create subcontexts for their duration.
-**
-** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
-** not create a new trigger context.
-**
-** ^This function returns the number of direct row changes in the
-** most recent INSERT, UPDATE, or DELETE statement within the same
-** trigger context.
-**
-** ^Thus, when called from the top level, this function returns the
-** number of changes in the most recent INSERT, UPDATE, or DELETE
-** that also occurred at the top level. ^(Within the body of a trigger,
-** the sqlite3_changes() interface can be called to find the number of
-** changes in the most recently completed INSERT, UPDATE, or DELETE
-** statement within the body of the same trigger.
-** However, the number returned does not include changes
-** caused by subtriggers since those have their own context.)^
-**
-** See also the [sqlite3_total_changes()] interface, the
-** [count_changes pragma], and the [changes() SQL function].
-**
-** If a separate thread makes changes on the same database connection
-** while [sqlite3_changes()] is running then the value returned
-** is unpredictable and not meaningful.
-*/
-SQLITE_API int sqlite3_changes(sqlite3*);
-
-/*
-** CAPI3REF: Total Number Of Rows Modified
-**
-** ^This function returns the number of row changes caused by [INSERT],
-** [UPDATE] or [DELETE] statements since the [database connection] was opened.
-** ^(The count returned by sqlite3_total_changes() includes all changes
-** from all [CREATE TRIGGER | trigger] contexts and changes made by
-** [foreign key actions]. However,
-** the count does not include changes used to implement [REPLACE] constraints,
-** do rollbacks or ABORT processing, o
<TRUNCATED>
[10/10] git commit: Removed Windows7 which is now in it's own branch.
This closes #29
Posted by pu...@apache.org.
Removed Windows7 which is now in it's own branch. This closes #29
Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/dfb81f0a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/dfb81f0a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/dfb81f0a
Branch: refs/heads/master
Commit: dfb81f0af720dd7f1223e59640d901141a290120
Parents: fcb1f66
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed Jun 11 18:38:49 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed Jun 11 18:38:49 2014 -0700
----------------------------------------------------------------------
README.md | 53 +-
windows7/Cordova.sln | 20 -
windows7/Cordova/Cordova.vcxproj | 161 -
windows7/Cordova/Cordova.vcxproj.filters | 110 -
windows7/Cordova/accel.c | 251 -
windows7/Cordova/accel.h | 22 -
windows7/Cordova/capture.c | 2334 -
windows7/Cordova/capture.h | 44 -
windows7/Cordova/common.c | 120 -
windows7/Cordova/common.h | 45 -
windows7/Cordova/compass.c | 277 -
windows7/Cordova/compass.h | 23 -
windows7/Cordova/device.c | 147 -
windows7/Cordova/device.h | 27 -
windows7/Cordova/file.c | 1280 -
windows7/Cordova/file.h | 43 -
windows7/Cordova/filetransfer.c | 486 -
windows7/Cordova/filetransfer.h | 22 -
windows7/Cordova/jpeg.cpp | 105 -
windows7/Cordova/jpeg.h | 26 -
windows7/Cordova/json.c | 545 -
windows7/Cordova/json.h | 68 -
windows7/Cordova/lib/js/exec.js | 63 -
windows7/Cordova/lib/js/platform.js | 58 -
windows7/Cordova/lib/js/plugin/win7/SQLError.js | 13 -
windows7/Cordova/lib/js/plugin/win7/device.js | 34 -
.../Cordova/lib/js/plugin/win7/jsHandler.js | 19 -
windows7/Cordova/lib/js/plugin/win7/storage.js | 300 -
windows7/Cordova/lib/sqlite/sqlite3.c | 138243 ----------------
windows7/Cordova/lib/sqlite/sqlite3.h | 7055 -
windows7/Cordova/mp4patch.c | 175 -
windows7/Cordova/mp4patch.h | 22 -
windows7/Cordova/network.c | 108 -
windows7/Cordova/network.h | 22 -
windows7/Cordova/notification.c | 324 -
windows7/Cordova/notification.h | 22 -
windows7/Cordova/platform.c | 49 -
windows7/Cordova/platform.h | 24 -
windows7/Cordova/resource.h | 37 -
windows7/Cordova/resource.rc | 40 -
windows7/Cordova/shell.c | 1471 -
windows7/Cordova/shell.h | 61 -
windows7/Cordova/storage.c | 384 -
windows7/Cordova/storage.h | 22 -
windows7/Cordova/toolbar.bmp | Bin 1558 -> 0 bytes
windows7/Cordova/www/accel_game.css | 23 -
windows7/Cordova/www/accel_game.html | 27 -
windows7/Cordova/www/accel_game.js | 165 -
windows7/Cordova/www/capture.html | 34 -
windows7/Cordova/www/cordova.win7.js | 5322 -
windows7/Cordova/www/device.html | 15 -
windows7/Cordova/www/events.html | 16 -
windows7/Cordova/www/file.html | 28 -
windows7/Cordova/www/index.html | 17 -
windows7/Cordova/www/network.html | 15 -
windows7/Cordova/www/notification.html | 39 -
windows7/Cordova/www/storage.html | 31 -
windows7/README | 44 -
58 files changed, 51 insertions(+), 160480 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index e9de5b2..f1be939 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,54 @@
-# Apache Cordova for Windows
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+-->
+
+
+Apache Cordova for Windows 8
===
-This repo may eventually hold, Windows8, Windows7, Win32, win.net, or other windows desktop related implementations of the Apache Cordova API.
+This repo includes code to build Apache Cordova applications that target Windows 8 SDK.
+
+An Apache Cordova based applications is, at the core, an application written with web technology: HTML, CSS and JavaScript.
+
+[Apache Cordova][] is a project at The Apache Software Foundation (ASF).
+
+Requires
+---
+
+- [Windows 8 SDK][]
+-- Windows 8 development requires Windows 8 Professional, and Visual Studio 2012 ( express works )
+
+BUGS?
+-----
+
+- File them at the [Apache Cordova Issue Tracker][]
+
+
+Further Reading
+---
+
+- [Apache Cordova Documentation][]
+- [Apache Cordova Wiki][]
+
+[Apache Cordova]: http://cordova.io "Apache Cordova"
+[Apache Cordova Issue Tracker]: https://issues.apache.org/jira/browse/CB "Apache Cordova Issue Tracker"
+[Apache Cordova Documentation]: http://cordova.io/docs "Apache Cordova Documentation"
+[Apache Cordova Wiki]: http://wiki.apache.org/cordova "Apache Cordova Wiki"
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova.sln
----------------------------------------------------------------------
diff --git a/windows7/Cordova.sln b/windows7/Cordova.sln
deleted file mode 100644
index 5e07fda..0000000
--- a/windows7/Cordova.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cordova", "Cordova\Cordova.vcxproj", "{3FE6EDB1-A141-4CC2-BA28-FD7761F2E9A9}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3FE6EDB1-A141-4CC2-BA28-FD7761F2E9A9}.Debug|Win32.ActiveCfg = Debug|Win32
- {3FE6EDB1-A141-4CC2-BA28-FD7761F2E9A9}.Debug|Win32.Build.0 = Debug|Win32
- {3FE6EDB1-A141-4CC2-BA28-FD7761F2E9A9}.Release|Win32.ActiveCfg = Release|Win32
- {3FE6EDB1-A141-4CC2-BA28-FD7761F2E9A9}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/Cordova.vcxproj
----------------------------------------------------------------------
diff --git a/windows7/Cordova/Cordova.vcxproj b/windows7/Cordova/Cordova.vcxproj
deleted file mode 100644
index 944fa99..0000000
--- a/windows7/Cordova/Cordova.vcxproj
+++ /dev/null
@@ -1,161 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{3FE6EDB1-A141-4CC2-BA28-FD7761F2E9A9}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>PGA</RootNamespace>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- <IncludePath>$(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include\um;$(WindowsSdkDir)include\shared;$(FrameworkSDKDir)\include</IncludePath>
- <LibraryPath>$(WindowsSdkDir)lib\win8\um\x86;$(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\lib;$(DXSDK_DIR)lib\x86;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- <IncludePath>$(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include\um;$(WindowsSdkDir)include\shared;$(FrameworkSDKDir)\include</IncludePath>
- <LibraryPath>$(WindowsSdkDir)lib\win8\um\x86;$(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\lib;$(DXSDK_DIR)lib\x86;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <ProjectReference />
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <Optimization>MinSpace</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
- <OmitFramePointers>true</OmitFramePointers>
- <StringPooling>true</StringPooling>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <ProjectReference />
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="accel.c" />
- <ClCompile Include="capture.c" />
- <ClCompile Include="common.c" />
- <ClCompile Include="compass.c" />
- <ClCompile Include="device.c" />
- <ClCompile Include="file.c" />
- <ClCompile Include="filetransfer.c" />
- <ClCompile Include="jpeg.cpp" />
- <ClCompile Include="json.c" />
- <ClCompile Include="lib\sqlite\sqlite3.c" />
- <ClCompile Include="mp4patch.c" />
- <ClCompile Include="network.c" />
- <ClCompile Include="notification.c" />
- <ClCompile Include="platform.c" />
- <ClCompile Include="shell.c" />
- <ClCompile Include="storage.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="accel.h" />
- <ClInclude Include="capture.h" />
- <ClInclude Include="common.h" />
- <ClInclude Include="compass.h" />
- <ClInclude Include="device.h" />
- <ClInclude Include="file.h" />
- <ClInclude Include="filetransfer.h" />
- <ClInclude Include="jpeg.h" />
- <ClInclude Include="json.h" />
- <ClInclude Include="mp4patch.h" />
- <ClInclude Include="network.h" />
- <ClInclude Include="notification.h" />
- <ClInclude Include="platform.h" />
- <ClInclude Include="resource.h" />
- <ClInclude Include="shell.h" />
- <ClInclude Include="storage.h" />
- </ItemGroup>
- <ItemGroup>
- <None Include="lib\js\exec.js" />
- <None Include="lib\js\platform.js" />
- <None Include="lib\js\plugin\win7\device.js" />
- <None Include="lib\js\plugin\win7\jsHandler.js" />
- <None Include="lib\js\plugin\win7\SQLError.js" />
- <None Include="lib\js\plugin\win7\storage.js" />
- <None Include="toolbar.bmp" />
- <None Include="www\accel_game.css" />
- <None Include="www\accel_game.html">
- <SubType>Designer</SubType>
- </None>
- <None Include="www\accel_game.js" />
- <None Include="www\capture.html" />
- <None Include="www\compass.html" />
- <None Include="www\cordova.win7.js" />
- <None Include="www\device.html" />
- <None Include="www\events.html">
- <SubType>Designer</SubType>
- </None>
- <None Include="www\file.html" />
- <None Include="www\index.html" />
- <None Include="www\network.html" />
- <None Include="www\notification.html">
- <SubType>Designer</SubType>
- </None>
- <None Include="www\storage.html" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="resource.rc" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/Cordova.vcxproj.filters
----------------------------------------------------------------------
diff --git a/windows7/Cordova/Cordova.vcxproj.filters b/windows7/Cordova/Cordova.vcxproj.filters
deleted file mode 100644
index 6a13dd9..0000000
--- a/windows7/Cordova/Cordova.vcxproj.filters
+++ /dev/null
@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <ClCompile Include="accel.c" />
- <ClCompile Include="capture.c" />
- <ClCompile Include="device.c" />
- <ClCompile Include="jpeg.cpp" />
- <ClCompile Include="network.c" />
- <ClCompile Include="shell.c" />
- <ClCompile Include="notification.c" />
- <ClCompile Include="storage.c" />
- <ClCompile Include="json.c" />
- <ClCompile Include="lib\sqlite\sqlite3.c" />
- <ClCompile Include="platform.c" />
- <ClCompile Include="file.c" />
- <ClCompile Include="common.c" />
- <ClCompile Include="filetransfer.c" />
- <ClCompile Include="mp4patch.c" />
- <ClCompile Include="compass.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="accel.h" />
- <ClInclude Include="capture.h" />
- <ClInclude Include="common.h" />
- <ClInclude Include="device.h" />
- <ClInclude Include="jpeg.h" />
- <ClInclude Include="network.h" />
- <ClInclude Include="resource.h" />
- <ClInclude Include="shell.h" />
- <ClInclude Include="notification.h" />
- <ClInclude Include="storage.h" />
- <ClInclude Include="json.h" />
- <ClInclude Include="platform.h" />
- <ClInclude Include="file.h" />
- <ClInclude Include="filetransfer.h" />
- <ClInclude Include="mp4patch.h" />
- <ClInclude Include="compass.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="resource.rc" />
- </ItemGroup>
- <ItemGroup>
- <None Include="toolbar.bmp" />
- <None Include="lib\js\plugin\win7\device.js">
- <Filter>javascript</Filter>
- </None>
- <None Include="lib\js\exec.js">
- <Filter>javascript</Filter>
- </None>
- <None Include="www\cordova.win7.js">
- <Filter>javascript</Filter>
- </None>
- <None Include="lib\js\platform.js">
- <Filter>javascript</Filter>
- </None>
- <None Include="www\index.html">
- <Filter>html</Filter>
- </None>
- <None Include="www\device.html">
- <Filter>html</Filter>
- </None>
- <None Include="www\network.html">
- <Filter>html</Filter>
- </None>
- <None Include="www\capture.html">
- <Filter>html</Filter>
- </None>
- <None Include="www\events.html">
- <Filter>html</Filter>
- </None>
- <None Include="lib\js\plugin\win7\jsHandler.js">
- <Filter>javascript</Filter>
- </None>
- <None Include="lib\js\plugin\win7\storage.js">
- <Filter>javascript</Filter>
- </None>
- <None Include="www\storage.html">
- <Filter>html</Filter>
- </None>
- <None Include="lib\js\plugin\win7\SQLError.js">
- <Filter>javascript</Filter>
- </None>
- <None Include="www\file.html">
- <Filter>html</Filter>
- </None>
- <None Include="www\compass.html">
- <Filter>html</Filter>
- </None>
- <None Include="www\accel_game.css">
- <Filter>html</Filter>
- </None>
- <None Include="www\accel_game.html">
- <Filter>html</Filter>
- </None>
- <None Include="www\accel_game.js">
- <Filter>html</Filter>
- </None>
- <None Include="www\notification.html">
- <Filter>html</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <Filter Include="javascript">
- <UniqueIdentifier>{03872dca-8198-4d19-a847-612e33652f00}</UniqueIdentifier>
- </Filter>
- <Filter Include="html">
- <UniqueIdentifier>{56894366-d156-48a1-a4ac-68ebf29c4442}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/accel.c
----------------------------------------------------------------------
diff --git a/windows7/Cordova/accel.c b/windows7/Cordova/accel.c
deleted file mode 100644
index bbfc2ec..0000000
--- a/windows7/Cordova/accel.c
+++ /dev/null
@@ -1,251 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#include <windows.h>
-#include <sensors.h>
-#include <sensorsapi.h>
-#include <propvarutil.h>
-#include <portabledevicetypes.h>
-#include <wchar.h>
-#include "common.h"
-
-#pragma comment(lib, "sensorsapi.lib")
-#pragma comment(lib, "portabledeviceguids.lib")
-
-#include "shell.h"
-extern HWND hWnd; // Main window, used as a way to request routine calls from the main thread
-
-ISensorManager* sensor_manager_if;
-ISensorCollection* sensor_collection_if;
-ISensor* accelerometer_if;
-
-int acceleration_sensor_count;
-
-double last_x, last_y, last_z;
-double prev_x, prev_y, prev_z;
-
-HANDLE accel_thread; // Data acquisition thread handle
-BOOL stop_flag; // Flag raised to indicate that the acquisition thread should exit
-
-BSTR new_sample_callback;
-
-void propagate_accel_sample (void)
-{
- if (new_sample_callback)
- {
- wchar_t buf[100];
- swprintf(buf, sizeof(buf)/sizeof(buf[0]), L"{x:%f,y:%f,z:%f}", last_x, last_y, last_z);
-
- cordova_success_callback(new_sample_callback, TRUE, buf);
- }
-}
-
-unsigned int __stdcall accel_thread_proc(void* param)
-{
- ISensorDataReport* data_report_if;
- PROPVARIANT v;
-// SYSTEMTIME timestamp;
- static int counter;
- HRESULT hr;
- ULONG ulCount = 0;
-
- set_thread_name(-1, "Accelerometer Sampling");
-
- CoInitialize(0);
-
- // Retrieve sensor manager object
- hr = CoCreateInstance(&CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &IID_ISensorManager, (void**) &sensor_manager_if);
-
- if (hr == HRESULT_FROM_WIN32(ERROR_ACCESS_DISABLED_BY_POLICY))
- {
- // The user hasn't granted access to sensors
- return -1;
- }
-
- if (!SUCCEEDED(hr))
- // Sensor API not available...
- return -2;
-
- // Get the list of available accelerometers
- hr = sensor_manager_if->lpVtbl->GetSensorsByCategory(sensor_manager_if, &SENSOR_CATEGORY_MOTION, &sensor_collection_if);
-
- sensor_manager_if->lpVtbl->RequestPermissions(sensor_manager_if, GetForegroundWindow(), sensor_collection_if, TRUE);
-
- if (SUCCEEDED(hr))
- {
- // Check sensor count
- hr = sensor_collection_if->lpVtbl->GetCount(sensor_collection_if, &acceleration_sensor_count);
-
- if (SUCCEEDED(hr))
- {
- if (acceleration_sensor_count == 0)
- {
- // No accelerometer
- }
- }
- }
-
- if (SUCCEEDED(hr))
- {
- // Get the first available accelerometer
- hr = sensor_collection_if->lpVtbl->GetAt(sensor_collection_if, 0, &accelerometer_if);
- }
-
-
- if (SUCCEEDED(hr))
- {
- IPortableDeviceValues* params_in = NULL;
- IPortableDeviceValues* params_out = NULL;
-
- // Need a properties object...
- hr = CoCreateInstance(&CLSID_PortableDeviceValues, NULL, CLSCTX_INPROC_SERVER, &IID_IPortableDeviceValues, (void**) ¶ms_in);
-
- if (SUCCEEDED(hr))
- {
- // Request 20 ms update interval
- hr = params_in->lpVtbl->SetUnsignedIntegerValue(params_in, &SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL, 20);
- }
-
- if (SUCCEEDED(hr))
- {
- // Set property
- hr = accelerometer_if->lpVtbl->SetProperties(accelerometer_if, params_in, ¶ms_out);
- }
-
- if (params_in)
- params_in->lpVtbl->Release(params_in);
-
- if (params_out)
- params_out->lpVtbl->Release(params_out);
- }
-
- while (!stop_flag)
- {
- prev_x = last_x;
- prev_y = last_y;
- prev_z = last_z;
-
- if (!accelerometer_if || !SUCCEEDED(accelerometer_if->lpVtbl->GetData(accelerometer_if, &data_report_if)))
- {
- last_x = .002 * (rand()%1000) -1;
- last_y = .002 * (rand()%1000) -1;
- last_z = .002 * (rand()%1000) -1;
- }
- else
- {
- PropVariantInit(&v);
- data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_ACCELERATION_X_G, &v);
- if (v.vt == VT_R4)
- last_x = v.fltVal;
- if (v.vt == VT_R8)
- last_x = v.dblVal;
- PropVariantClear(&v);
-
- PropVariantInit(&v);
- data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_ACCELERATION_Y_G, &v);
- if (v.vt == VT_R4)
- last_y = v.fltVal;
- if (v.vt == VT_R8)
- last_y = v.dblVal;
- PropVariantClear(&v);
-
- PropVariantInit(&v);
- data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_ACCELERATION_Z_G, &v);
- if (v.vt == VT_R4)
- last_z = v.fltVal;
- if (v.vt == VT_R8)
- last_z = v.dblVal;
- PropVariantClear(&v);
-
- //data_report_if->lpVtbl->GetTimestamp(data_report_if, ×tamp);
- //*ts = 0;
-
- data_report_if->lpVtbl->Release(data_report_if);
- }
-
- if (last_x != prev_x || last_y != prev_y || last_z != prev_z)
- SendMessage(hWnd, WM_USER_ACCEL, 0, 0); // Request the main thread to invoke a JS call for us ; will call propagate_accel_sample in response
-
- Sleep(10);
- }
-
- return 0;
-}
-
-int start_accel_acquisition (void)
-{
- if (accel_thread)
- return -1;
-
- // Return 0 x/y/z and 0 timestamp until samples start coming in
- last_x = 0;
- last_y = 0;
- last_z = 0;
-
- stop_flag = FALSE;
-
- // Reading sensor values seem to block the calling thread ; do this in a dedicated thread
- accel_thread = CreateThread(0, 0, accel_thread_proc, 0, 0, 0);
- return 0;
-}
-
-int stop_accel_acquisition (void)
-{
- if (accel_thread == 0)
- return -1;
-
- stop_flag = TRUE;
-
- // Wait until the acquisition thread exits
- WaitForSingleObject(accel_thread, INFINITE);
-
- accel_thread = 0;
-
- if (new_sample_callback)
- {
- SysFreeString(new_sample_callback);
- new_sample_callback = 0;
- }
-
- return 0;
-}
-
-
-HRESULT accel_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
-{
- if (!wcscmp(action, L"start"))
- {
- new_sample_callback = SysAllocString(callback_id);
- last_x = last_y = last_z = 0;
- propagate_accel_sample();
- start_accel_acquisition();
- return S_OK;
- }
-
- if (!wcscmp(action, L"stop"))
- {
- stop_accel_acquisition();
- cordova_success_callback(callback_id, FALSE, NULL_MESSAGE);
- return S_OK;
- }
-
- return DISP_E_MEMBERNOTFOUND;
-}
-
-DEFINE_CORDOVA_MODULE(Accelerometer, L"Accelerometer", accel_exec, NULL, NULL)
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/accel.h
----------------------------------------------------------------------
diff --git a/windows7/Cordova/accel.h b/windows7/Cordova/accel.h
deleted file mode 100644
index 807cf49..0000000
--- a/windows7/Cordova/accel.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 Intel Corporation
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-void propagate_accel_sample(void);
-
-DECLARE_CORDOVA_MODULE(Accelerometer)
[02/10] Removed Windows7 which is now in it's own branch. This closes
#29
Posted by pu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/dfb81f0a/windows7/Cordova/www/cordova.win7.js
----------------------------------------------------------------------
diff --git a/windows7/Cordova/www/cordova.win7.js b/windows7/Cordova/www/cordova.win7.js
deleted file mode 100644
index 82bc68a..0000000
--- a/windows7/Cordova/www/cordova.win7.js
+++ /dev/null
@@ -1,5322 +0,0 @@
-// commit 24969fba7ec490b3637569e573f7037015524c01
-
-// File generated at :: Thu Sep 20 2012 11:37:38 GMT+0200 (Romance Daylight Time)
-
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-
-;(function() {
-
-// file: lib/scripts/require.js
-var require,
- define;
-
-(function () {
- var modules = {};
-
- function build(module) {
- var factory = module.factory;
- module.exports = {};
- delete module.factory;
- factory(require, module.exports, module);
- return module.exports;
- }
-
- require = function (id) {
- if (!modules[id]) {
- throw "module " + id + " not found";
- }
- return modules[id].factory ? build(modules[id]) : modules[id].exports;
- };
-
- define = function (id, factory) {
- if (modules[id]) {
- throw "module " + id + " already defined";
- }
-
- modules[id] = {
- id: id,
- factory: factory
- };
- };
-
- define.remove = function (id) {
- delete modules[id];
- };
-
-})();
-
-//Export for use in node
-if (typeof module === "object" && typeof require === "function") {
- module.exports.require = require;
- module.exports.define = define;
-}
-// file: lib/cordova.js
-define("cordova", function(require, exports, module) {
-var channel = require('cordova/channel');
-
-/**
- * Listen for DOMContentLoaded and notify our channel subscribers.
- */
-document.addEventListener('DOMContentLoaded', function() {
- channel.onDOMContentLoaded.fire();
-}, false);
-if (document.readyState == 'complete' || document.readyState == 'interactive') {
- channel.onDOMContentLoaded.fire();
-}
-
-/**
- * Intercept calls to addEventListener + removeEventListener and handle deviceready,
- * resume, and pause events.
- */
-var m_document_addEventListener = document.addEventListener;
-var m_document_removeEventListener = document.removeEventListener;
-var m_window_addEventListener = window.addEventListener;
-var m_window_removeEventListener = window.removeEventListener;
-
-/**
- * Houses custom event handlers to intercept on document + window event listeners.
- */
-var documentEventHandlers = {},
- windowEventHandlers = {};
-
-document.addEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- if (typeof documentEventHandlers[e] != 'undefined') {
- if (evt === 'deviceready') {
- documentEventHandlers[e].subscribeOnce(handler);
- } else {
- documentEventHandlers[e].subscribe(handler);
- }
- } else {
- m_document_addEventListener.call(document, evt, handler, capture);
- }
-};
-
-window.addEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- if (typeof windowEventHandlers[e] != 'undefined') {
- windowEventHandlers[e].subscribe(handler);
- } else {
- m_window_addEventListener.call(window, evt, handler, capture);
- }
-};
-
-document.removeEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- // If unsubcribing from an event that is handled by a plugin
- if (typeof documentEventHandlers[e] != "undefined") {
- documentEventHandlers[e].unsubscribe(handler);
- } else {
- m_document_removeEventListener.call(document, evt, handler, capture);
- }
-};
-
-window.removeEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- // If unsubcribing from an event that is handled by a plugin
- if (typeof windowEventHandlers[e] != "undefined") {
- windowEventHandlers[e].unsubscribe(handler);
- } else {
- m_window_removeEventListener.call(window, evt, handler, capture);
- }
-};
-
-function createEvent(type, data) {
- var event = document.createEvent('Events');
- event.initEvent(type, false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
- }
- }
- return event;
-}
-
-if(typeof window.console === "undefined") {
- window.console = {
- log:function(){}
- };
-}
-
-var cordova = {
- define:define,
- require:require,
- /**
- * Methods to add/remove your own addEventListener hijacking on document + window.
- */
- addWindowEventHandler:function(event, opts) {
- return (windowEventHandlers[event] = channel.create(event, opts));
- },
- addDocumentEventHandler:function(event, opts) {
- return (documentEventHandlers[event] = channel.create(event, opts));
- },
- removeWindowEventHandler:function(event) {
- delete windowEventHandlers[event];
- },
- removeDocumentEventHandler:function(event) {
- delete documentEventHandlers[event];
- },
- /**
- * Retreive original event handlers that were replaced by Cordova
- *
- * @return object
- */
- getOriginalHandlers: function() {
- return {'document': {'addEventListener': m_document_addEventListener, 'removeEventListener': m_document_removeEventListener},
- 'window': {'addEventListener': m_window_addEventListener, 'removeEventListener': m_window_removeEventListener}};
- },
- /**
- * Method to fire event from native code
- */
- fireDocumentEvent: function(type, data) {
- var evt = createEvent(type, data);
- if (typeof documentEventHandlers[type] != 'undefined') {
- setTimeout(function() {
- documentEventHandlers[type].fire(evt);
- }, 0);
- } else {
- document.dispatchEvent(evt);
- }
- },
- fireWindowEvent: function(type, data) {
- var evt = createEvent(type,data);
- if (typeof windowEventHandlers[type] != 'undefined') {
- setTimeout(function() {
- windowEventHandlers[type].fire(evt);
- }, 0);
- } else {
- window.dispatchEvent(evt);
- }
- },
- // TODO: this is Android only; think about how to do this better
- shuttingDown:false,
- UsePolling:false,
- // END TODO
-
- // TODO: iOS only
- // This queue holds the currently executing command and all pending
- // commands executed with cordova.exec().
- commandQueue:[],
- // Indicates if we're currently in the middle of flushing the command
- // queue on the native side.
- commandQueueFlushing:false,
- // END TODO
- /**
- * Plugin callback mechanism.
- */
- callbackId: 0,
- callbacks: {},
- callbackStatus: {
- NO_RESULT: 0,
- OK: 1,
- CLASS_NOT_FOUND_EXCEPTION: 2,
- ILLEGAL_ACCESS_EXCEPTION: 3,
- INSTANTIATION_EXCEPTION: 4,
- MALFORMED_URL_EXCEPTION: 5,
- IO_EXCEPTION: 6,
- INVALID_ACTION: 7,
- JSON_EXCEPTION: 8,
- ERROR: 9
- },
-
- /**
- * Called by native code when returning successful result from an action.
- *
- * @param callbackId
- * @param args
- */
- callbackSuccess: function(callbackId, args) {
- if (cordova.callbacks[callbackId]) {
-
- // If result is to be sent to callback
- if (args.status == cordova.callbackStatus.OK) {
- try {
- if (cordova.callbacks[callbackId].success) {
- cordova.callbacks[callbackId].success(args.message);
- }
- }
- catch (e) {
- console.log("Error in success callback: "+callbackId+" = "+e);
- }
- }
-
- // Clear callback if not expecting any more results
- if (!args.keepCallback) {
- delete cordova.callbacks[callbackId];
- }
- }
- },
-
- /**
- * Called by native code when returning error result from an action.
- *
- * @param callbackId
- * @param args
- */
- callbackError: function(callbackId, args) {
- if (cordova.callbacks[callbackId]) {
- try {
- if (cordova.callbacks[callbackId].fail) {
- cordova.callbacks[callbackId].fail(args.message);
- }
- }
- catch (e) {
- console.log("Error in error callback: "+callbackId+" = "+e);
- }
-
- // Clear callback if not expecting any more results
- if (!args.keepCallback) {
- delete cordova.callbacks[callbackId];
- }
- }
- },
- addConstructor: function(func) {
- channel.onCordovaReady.subscribeOnce(function() {
- try {
- func();
- } catch(e) {
- console.log("Failed to run constructor: " + e);
- }
- });
- }
-};
-
-// Register pause, resume and deviceready channels as events on document.
-channel.onPause = cordova.addDocumentEventHandler('pause');
-channel.onResume = cordova.addDocumentEventHandler('resume');
-channel.onDeviceReady = cordova.addDocumentEventHandler('deviceready');
-
-module.exports = cordova;
-
-});
-
-// file: lib/common/builder.js
-define("cordova/builder", function(require, exports, module) {
-var utils = require('cordova/utils');
-
-function each(objects, func, context) {
- for (var prop in objects) {
- if (objects.hasOwnProperty(prop)) {
- func.apply(context, [objects[prop], prop]);
- }
- }
-}
-
-function include(parent, objects, clobber, merge) {
- each(objects, function (obj, key) {
- try {
- var result = obj.path ? require(obj.path) : {};
-
- if (clobber) {
- // Clobber if it doesn't exist.
- if (typeof parent[key] === 'undefined') {
- parent[key] = result;
- } else if (typeof obj.path !== 'undefined') {
- // If merging, merge properties onto parent, otherwise, clobber.
- if (merge) {
- recursiveMerge(parent[key], result);
- } else {
- parent[key] = result;
- }
- }
- result = parent[key];
- } else {
- // Overwrite if not currently defined.
- if (typeof parent[key] == 'undefined') {
- parent[key] = result;
- } else if (merge && typeof obj.path !== 'undefined') {
- // If merging, merge parent onto result
- recursiveMerge(result, parent[key]);
- parent[key] = result;
- } else {
- // Set result to what already exists, so we can build children into it if they exist.
- result = parent[key];
- }
- }
-
- if (obj.children) {
- include(result, obj.children, clobber, merge);
- }
- } catch(e) {
- utils.alert('Exception building cordova JS globals: ' + e + ' for key "' + key + '"');
- }
- });
-}
-
-/**
- * Merge properties from one object onto another recursively. Properties from
- * the src object will overwrite existing target property.
- *
- * @param target Object to merge properties into.
- * @param src Object to merge properties from.
- */
-function recursiveMerge(target, src) {
- for (var prop in src) {
- if (src.hasOwnProperty(prop)) {
- if (typeof target.prototype !== 'undefined' && target.prototype.constructor === target) {
- // If the target object is a constructor override off prototype.
- target.prototype[prop] = src[prop];
- } else {
- target[prop] = typeof src[prop] === 'object' ? recursiveMerge(
- target[prop], src[prop]) : src[prop];
- }
- }
- }
- return target;
-}
-
-module.exports = {
- build: function (objects) {
- return {
- intoButDontClobber: function (target) {
- include(target, objects, false, false);
- },
- intoAndClobber: function(target) {
- include(target, objects, true, false);
- },
- intoAndMerge: function(target) {
- include(target, objects, true, true);
- }
- };
- }
-};
-
-});
-
-// file: lib/common/channel.js
-define("cordova/channel", function(require, exports, module) {
-var utils = require('cordova/utils');
-
-/**
- * Custom pub-sub "channel" that can have functions subscribed to it
- * This object is used to define and control firing of events for
- * cordova initialization.
- *
- * The order of events during page load and Cordova startup is as follows:
- *
- * onDOMContentLoaded Internal event that is received when the web page is loaded and parsed.
- * onNativeReady Internal event that indicates the Cordova native side is ready.
- * onCordovaReady Internal event fired when all Cordova JavaScript objects have been created.
- * onCordovaInfoReady Internal event fired when device properties are available.
- * onCordovaConnectionReady Internal event fired when the connection property has been set.
- * onDeviceReady User event fired to indicate that Cordova is ready
- * onResume User event fired to indicate a start/resume lifecycle event
- * onPause User event fired to indicate a pause lifecycle event
- * onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
- *
- * The only Cordova events that user code should register for are:
- * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
- * pause App has moved to background
- * resume App has returned to foreground
- *
- * Listeners can be registered as:
- * document.addEventListener("deviceready", myDeviceReadyListener, false);
- * document.addEventListener("resume", myResumeListener, false);
- * document.addEventListener("pause", myPauseListener, false);
- *
- * The DOM lifecycle events should be used for saving and restoring state
- * window.onload
- * window.onunload
- *
- */
-
-/**
- * Channel
- * @constructor
- * @param type String the channel name
- * @param opts Object options to pass into the channel, currently
- * supports:
- * onSubscribe: callback that fires when
- * something subscribes to the Channel. Sets
- * context to the Channel.
- * onUnsubscribe: callback that fires when
- * something unsubscribes to the Channel. Sets
- * context to the Channel.
- */
-var Channel = function(type, opts) {
- this.type = type;
- this.handlers = {};
- this.numHandlers = 0;
- this.guid = 1;
- this.fired = false;
- this.enabled = true;
- this.events = {
- onSubscribe:null,
- onUnsubscribe:null
- };
- if (opts) {
- if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
- if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
- }
-},
- channel = {
- /**
- * Calls the provided function only after all of the channels specified
- * have been fired.
- */
- join: function (h, c) {
- var i = c.length;
- var len = i;
- var f = function() {
- if (!(--i)) h();
- };
- for (var j=0; j<len; j++) {
- !c[j].fired?c[j].subscribeOnce(f):i--;
- }
- if (!i) h();
- },
- create: function (type, opts) {
- channel[type] = new Channel(type, opts);
- return channel[type];
- },
-
- /**
- * cordova Channels that must fire before "deviceready" is fired.
- */
- deviceReadyChannelsArray: [],
- deviceReadyChannelsMap: {},
-
- /**
- * Indicate that a feature needs to be initialized before it is ready to be used.
- * This holds up Cordova's "deviceready" event until the feature has been initialized
- * and Cordova.initComplete(feature) is called.
- *
- * @param feature {String} The unique feature name
- */
- waitForInitialization: function(feature) {
- if (feature) {
- var c = null;
- if (this[feature]) {
- c = this[feature];
- }
- else {
- c = this.create(feature);
- }
- this.deviceReadyChannelsMap[feature] = c;
- this.deviceReadyChannelsArray.push(c);
- }
- },
-
- /**
- * Indicate that initialization code has completed and the feature is ready to be used.
- *
- * @param feature {String} The unique feature name
- */
- initializationComplete: function(feature) {
- var c = this.deviceReadyChannelsMap[feature];
- if (c) {
- c.fire();
- }
- }
- };
-
-function forceFunction(f) {
- if (f === null || f === undefined || typeof f != 'function') throw "Function required as first argument!";
-}
-
-/**
- * Subscribes the given function to the channel. Any time that
- * Channel.fire is called so too will the function.
- * Optionally specify an execution context for the function
- * and a guid that can be used to stop subscribing to the channel.
- * Returns the guid.
- */
-Channel.prototype.subscribe = function(f, c, g) {
- // need a function to call
- forceFunction(f);
-
- var func = f;
- if (typeof c == "object") { func = utils.close(c, f); }
-
- g = g || func.observer_guid || f.observer_guid;
- if (!g) {
- // first time we've seen this subscriber
- g = this.guid++;
- }
- else {
- // subscriber already handled; dont set it twice
- return g;
- }
- func.observer_guid = g;
- f.observer_guid = g;
- this.handlers[g] = func;
- this.numHandlers++;
- if (this.events.onSubscribe) this.events.onSubscribe.call(this);
- if (this.fired) func.call(this);
- return g;
-};
-
-/**
- * Like subscribe but the function is only called once and then it
- * auto-unsubscribes itself.
- */
-Channel.prototype.subscribeOnce = function(f, c) {
- // need a function to call
- forceFunction(f);
-
- var g = null;
- var _this = this;
- var m = function() {
- f.apply(c || null, arguments);
- _this.unsubscribe(g);
- };
- if (this.fired) {
- if (typeof c == "object") { f = utils.close(c, f); }
- f.apply(this, this.fireArgs);
- } else {
- g = this.subscribe(m);
- }
- return g;
-};
-
-/**
- * Unsubscribes the function with the given guid from the channel.
- */
-Channel.prototype.unsubscribe = function(g) {
- // need a function to unsubscribe
- if (g === null || g === undefined) { throw "You must pass _something_ into Channel.unsubscribe"; }
-
- if (typeof g == 'function') { g = g.observer_guid; }
- var handler = this.handlers[g];
- if (handler) {
- if (handler.observer_guid) handler.observer_guid=null;
- this.handlers[g] = null;
- delete this.handlers[g];
- this.numHandlers--;
- if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
- }
-};
-
-/**
- * Calls all functions subscribed to this channel.
- */
-Channel.prototype.fire = function(e) {
- if (this.enabled) {
- var fail = false;
- this.fired = true;
- for (var item in this.handlers) {
- var handler = this.handlers[item];
- if (typeof handler == 'function') {
- var rv = (handler.apply(this, arguments)===false);
- fail = fail || rv;
- }
- }
- this.fireArgs = arguments;
- return !fail;
- }
- return true;
-};
-
-// defining them here so they are ready super fast!
-// DOM event that is received when the web page is loaded and parsed.
-channel.create('onDOMContentLoaded');
-
-// Event to indicate the Cordova native side is ready.
-channel.create('onNativeReady');
-
-// Event to indicate that all Cordova JavaScript objects have been created
-// and it's time to run plugin constructors.
-channel.create('onCordovaReady');
-
-// Event to indicate that device properties are available
-channel.create('onCordovaInfoReady');
-
-// Event to indicate that the connection property has been set.
-channel.create('onCordovaConnectionReady');
-
-// Event to indicate that Cordova is ready
-channel.create('onDeviceReady');
-
-// Event to indicate a resume lifecycle event
-channel.create('onResume');
-
-// Event to indicate a pause lifecycle event
-channel.create('onPause');
-
-// Event to indicate a destroy lifecycle event
-channel.create('onDestroy');
-
-// Channels that must fire before "deviceready" is fired.
-channel.waitForInitialization('onCordovaReady');
-channel.waitForInitialization('onCordovaConnectionReady');
-
-module.exports = channel;
-
-});
-
-// file: lib/common/common.js
-define("cordova/common", function(require, exports, module) {
-module.exports = {
- objects: {
- cordova: {
- path: 'cordova',
- children: {
- exec: {
- path: 'cordova/exec'
- },
- logger: {
- path: 'cordova/plugin/logger'
- }
- }
- },
- Cordova: {
- children: {
- exec: {
- path: 'cordova/exec'
- }
- }
- },
- PhoneGap:{
- children: {
- exec: {
- path: 'cordova/exec'
- }
- }
- },
- navigator: {
- children: {
- notification: {
- path: 'cordova/plugin/notification'
- },
- accelerometer: {
- path: 'cordova/plugin/accelerometer'
- },
- battery: {
- path: 'cordova/plugin/battery'
- },
- camera:{
- path: 'cordova/plugin/Camera'
- },
- compass:{
- path: 'cordova/plugin/compass'
- },
- contacts: {
- path: 'cordova/plugin/contacts'
- },
- device:{
- children:{
- capture: {
- path: 'cordova/plugin/capture'
- }
- }
- },
- geolocation: {
- path: 'cordova/plugin/geolocation'
- },
- network: {
- children: {
- connection: {
- path: 'cordova/plugin/network'
- }
- }
- },
- splashscreen: {
- path: 'cordova/plugin/splashscreen'
- }
- }
- },
- Acceleration: {
- path: 'cordova/plugin/Acceleration'
- },
- Camera:{
- path: 'cordova/plugin/CameraConstants'
- },
- CameraPopoverOptions: {
- path: 'cordova/plugin/CameraPopoverOptions'
- },
- CaptureError: {
- path: 'cordova/plugin/CaptureError'
- },
- CaptureAudioOptions:{
- path: 'cordova/plugin/CaptureAudioOptions'
- },
- CaptureImageOptions: {
- path: 'cordova/plugin/CaptureImageOptions'
- },
- CaptureVideoOptions: {
- path: 'cordova/plugin/CaptureVideoOptions'
- },
- CompassHeading:{
- path: 'cordova/plugin/CompassHeading'
- },
- CompassError:{
- path: 'cordova/plugin/CompassError'
- },
- ConfigurationData: {
- path: 'cordova/plugin/ConfigurationData'
- },
- Connection: {
- path: 'cordova/plugin/Connection'
- },
- Contact: {
- path: 'cordova/plugin/Contact'
- },
- ContactAddress: {
- path: 'cordova/plugin/ContactAddress'
- },
- ContactError: {
- path: 'cordova/plugin/ContactError'
- },
- ContactField: {
- path: 'cordova/plugin/ContactField'
- },
- ContactFindOptions: {
- path: 'cordova/plugin/ContactFindOptions'
- },
- ContactName: {
- path: 'cordova/plugin/ContactName'
- },
- ContactOrganization: {
- path: 'cordova/plugin/ContactOrganization'
- },
- Coordinates: {
- path: 'cordova/plugin/Coordinates'
- },
- device: {
- path: 'cordova/plugin/device'
- },
- DirectoryEntry: {
- path: 'cordova/plugin/DirectoryEntry'
- },
- DirectoryReader: {
- path: 'cordova/plugin/DirectoryReader'
- },
- Entry: {
- path: 'cordova/plugin/Entry'
- },
- File: {
- path: 'cordova/plugin/File'
- },
- FileEntry: {
- path: 'cordova/plugin/FileEntry'
- },
- FileError: {
- path: 'cordova/plugin/FileError'
- },
- FileReader: {
- path: 'cordova/plugin/FileReader'
- },
- FileSystem: {
- path: 'cordova/plugin/FileSystem'
- },
- FileTransfer: {
- path: 'cordova/plugin/FileTransfer'
- },
- FileTransferError: {
- path: 'cordova/plugin/FileTransferError'
- },
- FileUploadOptions: {
- path: 'cordova/plugin/FileUploadOptions'
- },
- FileUploadResult: {
- path: 'cordova/plugin/FileUploadResult'
- },
- FileWriter: {
- path: 'cordova/plugin/FileWriter'
- },
- Flags: {
- path: 'cordova/plugin/Flags'
- },
- LocalFileSystem: {
- path: 'cordova/plugin/LocalFileSystem'
- },
- Media: {
- path: 'cordova/plugin/Media'
- },
- MediaError: {
- path: 'cordova/plugin/MediaError'
- },
- MediaFile: {
- path: 'cordova/plugin/MediaFile'
- },
- MediaFileData:{
- path: 'cordova/plugin/MediaFileData'
- },
- Metadata:{
- path: 'cordova/plugin/Metadata'
- },
- Position: {
- path: 'cordova/plugin/Position'
- },
- PositionError: {
- path: 'cordova/plugin/PositionError'
- },
- ProgressEvent: {
- path: 'cordova/plugin/ProgressEvent'
- },
- requestFileSystem:{
- path: 'cordova/plugin/requestFileSystem'
- },
- resolveLocalFileSystemURI:{
- path: 'cordova/plugin/resolveLocalFileSystemURI'
- }
- }
-};
-
-});
-
-// file: lib/win7/exec.js
-define("cordova/exec", function(require, exports, module) {
-var jsHandler = require('cordova/plugin/win7/jsHandler'),
- cordova = require('cordova');
-
-module.exports = function exec(success, fail, service, action, args) {
- try {
- // Try JS implementation
- var v = jsHandler.exec(success, fail, service, action, args);
-
- // If status is OK, then return value back to caller
- if (v.status == cordova.callbackStatus.OK) {
-
- // If there is a success callback, then call it now with returned value
- if (success) {
- try {
- success(v.message);
- }
- catch (e) {
- console.log("Error in success callback: " + service + "." + action + " = " + e);
- }
-
- }
- return v.message;
- } else if (v.status == cordova.callbackStatus.NO_RESULT) {
- // Nothing to do here
- } else if (v.status == cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION) {
- // Try native implementation
- var callbackId = service + cordova.callbackId++;
- if (typeof success == 'function' || typeof fail == 'function') {
- cordova.callbacks[callbackId] = { success: success, fail: fail };
- }
-
- try {
- if (window.external) {
- return window.external.CordovaExec(callbackId, service, action, JSON.stringify(args));
- }
- else {
- console.log('window.external not available');
- }
- }
- catch (e) {
- console.log('Exception calling native with for ' + service + '/' + action + ' - exception = ' + e);
- // Clear callback
- delete cordova.callbacks[callbackId];
- }
- } else {
- // If error, then display error
- console.log("Error: " + service + "." + action + " Status=" + v.status + " Message=" + v.message);
-
- // If there is a fail callback, then call it now with returned value
- if (fail) {
- try {
- fail(v.message);
- }
- catch (e) {
- console.log("Error in error callback: " + service + "." + action + " = " + e);
- }
- }
- return null;
- }
- } catch (e) {
- console.log('Exception calling native with for ' + service + '/' + action + ' - exception = ' + e);
- }
-};
-});
-
-// file: lib/win7/platform.js
-define("cordova/platform", function(require, exports, module) {
-var device = require('cordova/plugin/win7/device');
-
-module.exports = {
- id: device.platform,
- initialize: function () {
- var channel = require("cordova/channel"),
- storage = require('cordova/plugin/win7/storage');
-
- // Inject a lsitener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
- var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
- onSubscribe: function () {
- if (this.numHandlers === 1) {
- exec(null, null, "Platform", "backButtonEventOn", []);
- }
- },
- onUnsubscribe: function () {
- if (this.numHandlers === 0) {
- exec(null, null, "Platform", "backButtonEventOff", []);
- }
- }
- });
-
- channel.onDestroy.subscribe(function () {
- // Remove session storage database
- storage.removeDatabase(device.uuid);
- });
-
- if (typeof window.openDatabase == 'undefined') {
- window.openDatabase = storage.openDatabase;
- }
-
- if (typeof window.localStorage == 'undefined' || window.localStorage === null) {
- Object.defineProperty(window, "localStorage", {
- writable: false,
- configurable: false,
- value: new storage.WinStorage('CordovaLocalStorage')
- });
- }
-
- channel.join(function () {
- if (typeof window.sessionStorage == 'undefined' || window.sessionStorage === null) {
- Object.defineProperty(window, "sessionStorage", {
- writable: false,
- configurable: false,
- value: new storage.WinStorage(device.uuid) // uuid is actually unique for application
- });
- }
- }, [channel.onCordovaInfoReady]);
- },
- objects: {
- device: {
- path: 'cordova/plugin/win7/device'
- },
- SQLError: {
- path: 'cordova/plugin/win7/SQLError'
- }
- }
-};
-
-});
-
-// file: lib/common/plugin/Acceleration.js
-define("cordova/plugin/Acceleration", function(require, exports, module) {
-var Acceleration = function(x, y, z, timestamp) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.timestamp = timestamp || (new Date()).getTime();
-};
-
-module.exports = Acceleration;
-
-});
-
-// file: lib/common/plugin/Camera.js
-define("cordova/plugin/Camera", function(require, exports, module) {
-var exec = require('cordova/exec'),
- Camera = require('cordova/plugin/CameraConstants');
-
-var cameraExport = {};
-
-// Tack on the Camera Constants to the base camera plugin.
-for (var key in Camera) {
- cameraExport[key] = Camera[key];
-}
-
-/**
- * Gets a picture from source defined by "options.sourceType", and returns the
- * image as defined by the "options.destinationType" option.
-
- * The defaults are sourceType=CAMERA and destinationType=FILE_URI.
- *
- * @param {Function} successCallback
- * @param {Function} errorCallback
- * @param {Object} options
- */
-cameraExport.getPicture = function(successCallback, errorCallback, options) {
- // successCallback required
- if (typeof successCallback != "function") {
- console.log("Camera Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback != "function")) {
- console.log("Camera Error: errorCallback is not a function");
- return;
- }
-
- var quality = 50;
- if (options && typeof options.quality == "number") {
- quality = options.quality;
- } else if (options && typeof options.quality == "string") {
- var qlity = parseInt(options.quality, 10);
- if (isNaN(qlity) === false) {
- quality = qlity.valueOf();
- }
- }
-
- var destinationType = Camera.DestinationType.FILE_URI;
- if (typeof options.destinationType == "number") {
- destinationType = options.destinationType;
- }
-
- var sourceType = Camera.PictureSourceType.CAMERA;
- if (typeof options.sourceType == "number") {
- sourceType = options.sourceType;
- }
-
- var targetWidth = -1;
- if (typeof options.targetWidth == "number") {
- targetWidth = options.targetWidth;
- } else if (typeof options.targetWidth == "string") {
- var width = parseInt(options.targetWidth, 10);
- if (isNaN(width) === false) {
- targetWidth = width.valueOf();
- }
- }
-
- var targetHeight = -1;
- if (typeof options.targetHeight == "number") {
- targetHeight = options.targetHeight;
- } else if (typeof options.targetHeight == "string") {
- var height = parseInt(options.targetHeight, 10);
- if (isNaN(height) === false) {
- targetHeight = height.valueOf();
- }
- }
-
- var encodingType = Camera.EncodingType.JPEG;
- if (typeof options.encodingType == "number") {
- encodingType = options.encodingType;
- }
-
- var mediaType = Camera.MediaType.PICTURE;
- if (typeof options.mediaType == "number") {
- mediaType = options.mediaType;
- }
- var allowEdit = false;
- if (typeof options.allowEdit == "boolean") {
- allowEdit = options.allowEdit;
- } else if (typeof options.allowEdit == "number") {
- allowEdit = options.allowEdit <= 0 ? false : true;
- }
- var correctOrientation = false;
- if (typeof options.correctOrientation == "boolean") {
- correctOrientation = options.correctOrientation;
- } else if (typeof options.correctOrientation == "number") {
- correctOrientation = options.correctOrientation <=0 ? false : true;
- }
- var saveToPhotoAlbum = false;
- if (typeof options.saveToPhotoAlbum == "boolean") {
- saveToPhotoAlbum = options.saveToPhotoAlbum;
- } else if (typeof options.saveToPhotoAlbum == "number") {
- saveToPhotoAlbum = options.saveToPhotoAlbum <=0 ? false : true;
- }
- var popoverOptions = null;
- if (typeof options.popoverOptions == "object") {
- popoverOptions = options.popoverOptions;
- }
-
- var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
- mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions];
-
- exec(successCallback, errorCallback, "Camera", "takePicture", args);
-};
-
-cameraExport.cleanup = function(successCallback, errorCallback) {
- exec(successCallback, errorCallback, "Camera", "cleanup", []);
-};
-
-module.exports = cameraExport;
-});
-
-// file: lib/common/plugin/CameraConstants.js
-define("cordova/plugin/CameraConstants", function(require, exports, module) {
-module.exports = {
- DestinationType:{
- DATA_URL: 0, // Return base64 encoded string
- FILE_URI: 1 // Return file uri (content://media/external/images/media/2 for Android)
- },
- EncodingType:{
- JPEG: 0, // Return JPEG encoded image
- PNG: 1 // Return PNG encoded image
- },
- MediaType:{
- PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
- VIDEO: 1, // allow selection of video only, ONLY RETURNS URL
- ALLMEDIA : 2 // allow selection from all media types
- },
- PictureSourceType:{
- PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
- CAMERA : 1, // Take picture from camera
- SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
- },
- PopoverArrowDirection:{
- ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants to specify arrow location on popover
- ARROW_DOWN : 2,
- ARROW_LEFT : 4,
- ARROW_RIGHT : 8,
- ARROW_ANY : 15
- }
-};
-});
-
-// file: lib/common/plugin/CameraPopoverOptions.js
-define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
-var Camera = require('cordova/plugin/CameraConstants');
-
-/**
- * Encapsulates options for iOS Popover image picker
- */
-var CameraPopoverOptions = function(x,y,width,height,arrowDir){
- // information of rectangle that popover should be anchored to
- this.x = x || 0;
- this.y = y || 32;
- this.width = width || 320;
- this.height = height || 480;
- // The direction of the popover arrow
- this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
-};
-
-module.exports = CameraPopoverOptions;
-});
-
-// file: lib/common/plugin/CaptureAudioOptions.js
-define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
-/**
- * Encapsulates all audio capture operation configuration options.
- */
-var CaptureAudioOptions = function(){
- // Upper limit of sound clips user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single sound clip in seconds.
- this.duration = 0;
- // The selected audio mode. Must match with one of the elements in supportedAudioModes array.
- this.mode = null;
-};
-
-module.exports = CaptureAudioOptions;
-});
-
-// file: lib/common/plugin/CaptureError.js
-define("cordova/plugin/CaptureError", function(require, exports, module) {
-/**
- * The CaptureError interface encapsulates all errors in the Capture API.
- */
-var CaptureError = function(c) {
- this.code = c || null;
-};
-
-// Camera or microphone failed to capture image or sound.
-CaptureError.CAPTURE_INTERNAL_ERR = 0;
-// Camera application or audio capture application is currently serving other capture request.
-CaptureError.CAPTURE_APPLICATION_BUSY = 1;
-// Invalid use of the API (e.g. limit parameter has value less than one).
-CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
-// User exited camera application or audio capture application before capturing anything.
-CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
-// The requested capture operation is not supported.
-CaptureError.CAPTURE_NOT_SUPPORTED = 20;
-
-module.exports = CaptureError;
-});
-
-// file: lib/common/plugin/CaptureImageOptions.js
-define("cordova/plugin/CaptureImageOptions", function(require, exports, module) {
-/**
- * Encapsulates all image capture operation configuration options.
- */
-var CaptureImageOptions = function(){
- // Upper limit of images user can take. Value must be equal or greater than 1.
- this.limit = 1;
- // The selected image mode. Must match with one of the elements in supportedImageModes array.
- this.mode = null;
-};
-
-module.exports = CaptureImageOptions;
-});
-
-// file: lib/common/plugin/CaptureVideoOptions.js
-define("cordova/plugin/CaptureVideoOptions", function(require, exports, module) {
-/**
- * Encapsulates all video capture operation configuration options.
- */
-var CaptureVideoOptions = function(){
- // Upper limit of videos user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single video clip in seconds.
- this.duration = 0;
- // The selected video mode. Must match with one of the elements in supportedVideoModes array.
- this.mode = null;
-};
-
-module.exports = CaptureVideoOptions;
-});
-
-// file: lib/common/plugin/CompassError.js
-define("cordova/plugin/CompassError", function(require, exports, module) {
-/**
- * CompassError.
- * An error code assigned by an implementation when an error has occured
- * @constructor
- */
-var CompassError = function(err) {
- this.code = (err !== undefined ? err : null);
-};
-
-CompassError.COMPASS_INTERNAL_ERR = 0;
-CompassError.COMPASS_NOT_SUPPORTED = 20;
-
-module.exports = CompassError;
-});
-
-// file: lib/common/plugin/CompassHeading.js
-define("cordova/plugin/CompassHeading", function(require, exports, module) {
-var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
- this.magneticHeading = (magneticHeading !== undefined ? magneticHeading : null);
- this.trueHeading = (trueHeading !== undefined ? trueHeading : null);
- this.headingAccuracy = (headingAccuracy !== undefined ? headingAccuracy : null);
- this.timestamp = (timestamp !== undefined ? timestamp : new Date().getTime());
-};
-
-module.exports = CompassHeading;
-});
-
-// file: lib/common/plugin/ConfigurationData.js
-define("cordova/plugin/ConfigurationData", function(require, exports, module) {
-/**
- * Encapsulates a set of parameters that the capture device supports.
- */
-function ConfigurationData() {
- // The ASCII-encoded string in lower case representing the media type.
- this.type = null;
- // The height attribute represents height of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0.
- this.height = 0;
- // The width attribute represents width of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0
- this.width = 0;
-}
-
-module.exports = ConfigurationData;
-});
-
-// file: lib/common/plugin/Connection.js
-define("cordova/plugin/Connection", function(require, exports, module) {
-/**
- * Network status
- */
-module.exports = {
- UNKNOWN: "unknown",
- ETHERNET: "ethernet",
- WIFI: "wifi",
- CELL_2G: "2g",
- CELL_3G: "3g",
- CELL_4G: "4g",
- NONE: "none"
-};
-});
-
-// file: lib/common/plugin/Contact.js
-define("cordova/plugin/Contact", function(require, exports, module) {
-var exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils');
-
-/**
-* Converts primitives into Complex Object
-* Currently only used for Date fields
-*/
-function convertIn(contact) {
- var value = contact.birthday;
- try {
- contact.birthday = new Date(parseFloat(value));
- } catch (exception){
- console.log("Cordova Contact convertIn error: exception creating date.");
- }
- return contact;
-}
-
-/**
-* Converts Complex objects into primitives
-* Only conversion at present is for Dates.
-**/
-
-function convertOut(contact) {
- var value = contact.birthday;
- if (value !== null) {
- // try to make it a Date object if it is not already
- if (!utils.isDate(value)){
- try {
- value = new Date(value);
- } catch(exception){
- value = null;
- }
- }
- if (utils.isDate(value)){
- value = value.valueOf(); // convert to milliseconds
- }
- contact.birthday = value;
- }
- return contact;
-}
-
-/**
-* Contains information about a single contact.
-* @constructor
-* @param {DOMString} id unique identifier
-* @param {DOMString} displayName
-* @param {ContactName} name
-* @param {DOMString} nickname
-* @param {Array.<ContactField>} phoneNumbers array of phone numbers
-* @param {Array.<ContactField>} emails array of email addresses
-* @param {Array.<ContactAddress>} addresses array of addresses
-* @param {Array.<ContactField>} ims instant messaging user ids
-* @param {Array.<ContactOrganization>} organizations
-* @param {DOMString} birthday contact's birthday
-* @param {DOMString} note user notes about contact
-* @param {Array.<ContactField>} photos
-* @param {Array.<ContactField>} categories
-* @param {Array.<ContactField>} urls contact's web sites
-*/
-var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
- ims, organizations, birthday, note, photos, categories, urls) {
- this.id = id || null;
- this.rawId = null;
- this.displayName = displayName || null;
- this.name = name || null; // ContactName
- this.nickname = nickname || null;
- this.phoneNumbers = phoneNumbers || null; // ContactField[]
- this.emails = emails || null; // ContactField[]
- this.addresses = addresses || null; // ContactAddress[]
- this.ims = ims || null; // ContactField[]
- this.organizations = organizations || null; // ContactOrganization[]
- this.birthday = birthday || null;
- this.note = note || null;
- this.photos = photos || null; // ContactField[]
- this.categories = categories || null; // ContactField[]
- this.urls = urls || null; // ContactField[]
-};
-
-/**
-* Removes contact from device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.remove = function(successCB, errorCB) {
- var fail = function(code) {
- errorCB(new ContactError(code));
- };
- if (this.id === null) {
- fail(ContactError.UNKNOWN_ERROR);
- }
- else {
- exec(successCB, fail, "Contacts", "remove", [this.id]);
- }
-};
-
-/**
-* Creates a deep copy of this Contact.
-* With the contact ID set to null.
-* @return copy of this Contact
-*/
-Contact.prototype.clone = function() {
- var clonedContact = utils.clone(this);
- var i;
- clonedContact.id = null;
- clonedContact.rawId = null;
- // Loop through and clear out any id's in phones, emails, etc.
- if (clonedContact.phoneNumbers) {
- for (i = 0; i < clonedContact.phoneNumbers.length; i++) {
- clonedContact.phoneNumbers[i].id = null;
- }
- }
- if (clonedContact.emails) {
- for (i = 0; i < clonedContact.emails.length; i++) {
- clonedContact.emails[i].id = null;
- }
- }
- if (clonedContact.addresses) {
- for (i = 0; i < clonedContact.addresses.length; i++) {
- clonedContact.addresses[i].id = null;
- }
- }
- if (clonedContact.ims) {
- for (i = 0; i < clonedContact.ims.length; i++) {
- clonedContact.ims[i].id = null;
- }
- }
- if (clonedContact.organizations) {
- for (i = 0; i < clonedContact.organizations.length; i++) {
- clonedContact.organizations[i].id = null;
- }
- }
- if (clonedContact.categories) {
- for (i = 0; i < clonedContact.categories.length; i++) {
- clonedContact.categories[i].id = null;
- }
- }
- if (clonedContact.photos) {
- for (i = 0; i < clonedContact.photos.length; i++) {
- clonedContact.photos[i].id = null;
- }
- }
- if (clonedContact.urls) {
- for (i = 0; i < clonedContact.urls.length; i++) {
- clonedContact.urls[i].id = null;
- }
- }
- return clonedContact;
-};
-
-/**
-* Persists contact to device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.save = function(successCB, errorCB) {
- var fail = function(code) {
- errorCB(new ContactError(code));
- };
- var success = function(result) {
- if (result) {
- if (typeof successCB === 'function') {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCB(convertIn(fullContact));
- }
- }
- else {
- // no Entry object returned
- fail(ContactError.UNKNOWN_ERROR);
- }
- };
- var dupContact = convertOut(utils.clone(this));
- exec(success, fail, "Contacts", "save", [dupContact]);
-};
-
-
-module.exports = Contact;
-
-});
-
-// file: lib/common/plugin/ContactAddress.js
-define("cordova/plugin/ContactAddress", function(require, exports, module) {
-/**
-* Contact address.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code
-* @param formatted // NOTE: not a W3C standard
-* @param streetAddress
-* @param locality
-* @param region
-* @param postalCode
-* @param country
-*/
-
-var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.formatted = formatted || null;
- this.streetAddress = streetAddress || null;
- this.locality = locality || null;
- this.region = region || null;
- this.postalCode = postalCode || null;
- this.country = country || null;
-};
-
-module.exports = ContactAddress;
-});
-
-// file: lib/common/plugin/ContactError.js
-define("cordova/plugin/ContactError", function(require, exports, module) {
-/**
- * ContactError.
- * An error code assigned by an implementation when an error has occured
- * @constructor
- */
-var ContactError = function(err) {
- this.code = (typeof err != 'undefined' ? err : null);
-};
-
-/**
- * Error codes
- */
-ContactError.UNKNOWN_ERROR = 0;
-ContactError.INVALID_ARGUMENT_ERROR = 1;
-ContactError.TIMEOUT_ERROR = 2;
-ContactError.PENDING_OPERATION_ERROR = 3;
-ContactError.IO_ERROR = 4;
-ContactError.NOT_SUPPORTED_ERROR = 5;
-ContactError.PERMISSION_DENIED_ERROR = 20;
-
-module.exports = ContactError;
-});
-
-// file: lib/common/plugin/ContactField.js
-define("cordova/plugin/ContactField", function(require, exports, module) {
-/**
-* Generic contact field.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param type
-* @param value
-* @param pref
-*/
-var ContactField = function(type, value, pref) {
- this.id = null;
- this.type = (type && type.toString()) || null;
- this.value = (value && value.toString()) || null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
-};
-
-module.exports = ContactField;
-});
-
-// file: lib/common/plugin/ContactFindOptions.js
-define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
-/**
- * ContactFindOptions.
- * @constructor
- * @param filter used to match contacts against
- * @param multiple boolean used to determine if more than one contact should be returned
- */
-
-var ContactFindOptions = function(filter, multiple) {
- this.filter = filter || '';
- this.multiple = (typeof multiple != 'undefined' ? multiple : false);
-};
-
-module.exports = ContactFindOptions;
-});
-
-// file: lib/common/plugin/ContactName.js
-define("cordova/plugin/ContactName", function(require, exports, module) {
-/**
-* Contact name.
-* @constructor
-* @param formatted // NOTE: not part of W3C standard
-* @param familyName
-* @param givenName
-* @param middle
-* @param prefix
-* @param suffix
-*/
-var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
- this.formatted = formatted || null;
- this.familyName = familyName || null;
- this.givenName = givenName || null;
- this.middleName = middle || null;
- this.honorificPrefix = prefix || null;
- this.honorificSuffix = suffix || null;
-};
-
-module.exports = ContactName;
-});
-
-// file: lib/common/plugin/ContactOrganization.js
-define("cordova/plugin/ContactOrganization", function(require, exports, module) {
-/**
-* Contact organization.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param name
-* @param dept
-* @param title
-* @param startDate
-* @param endDate
-* @param location
-* @param desc
-*/
-
-var ContactOrganization = function(pref, type, name, dept, title) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.name = name || null;
- this.department = dept || null;
- this.title = title || null;
-};
-
-module.exports = ContactOrganization;
-});
-
-// file: lib/common/plugin/Coordinates.js
-define("cordova/plugin/Coordinates", function(require, exports, module) {
-/**
- * This class contains position information.
- * @param {Object} lat
- * @param {Object} lng
- * @param {Object} alt
- * @param {Object} acc
- * @param {Object} head
- * @param {Object} vel
- * @param {Object} altacc
- * @constructor
- */
-var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
- /**
- * The latitude of the position.
- */
- this.latitude = lat;
- /**
- * The longitude of the position,
- */
- this.longitude = lng;
- /**
- * The accuracy of the position.
- */
- this.accuracy = acc;
- /**
- * The altitude of the position.
- */
- this.altitude = (alt !== undefined ? alt : null);
- /**
- * The direction the device is moving at the position.
- */
- this.heading = (head !== undefined ? head : null);
- /**
- * The velocity with which the device is moving at the position.
- */
- this.speed = (vel !== undefined ? vel : null);
-
- if (this.speed === 0 || this.speed === null) {
- this.heading = NaN;
- }
-
- /**
- * The altitude accuracy of the position.
- */
- this.altitudeAccuracy = (altacc !== undefined) ? altacc : null;
-};
-
-module.exports = Coordinates;
-
-});
-
-// file: lib/common/plugin/DirectoryEntry.js
-define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileError = require('cordova/plugin/FileError'),
- DirectoryReader = require('cordova/plugin/DirectoryReader');
-
-/**
- * An interface representing a directory on the file system.
- *
- * {boolean} isFile always false (readonly)
- * {boolean} isDirectory always true (readonly)
- * {DOMString} name of the directory, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the directory (readonly)
- * TODO: implement this!!! {FileSystem} filesystem on which the directory resides (readonly)
- */
-var DirectoryEntry = function(name, fullPath) {
- DirectoryEntry.__super__.constructor.apply(this, [false, true, name, fullPath]);
-};
-
-utils.extend(DirectoryEntry, Entry);
-
-/**
- * Creates a new DirectoryReader to read entries from this directory
- */
-DirectoryEntry.prototype.createReader = function() {
- return new DirectoryReader(this.fullPath);
-};
-
-/**
- * Creates or looks up a directory
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
- * @param {Flags} options to create or excluively create the directory
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]);
-};
-
-/**
- * Deletes a directory and all of it's contents
- *
- * @param {Function} successCallback is called with no parameters
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
-};
-
-/**
- * Creates or looks up a file
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
- * @param {Flags} options to create or excluively create the file
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var FileEntry = require('cordova/plugin/FileEntry');
- var entry = new FileEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFile", [this.fullPath, path, options]);
-};
-
-module.exports = DirectoryEntry;
-
-});
-
-// file: lib/common/plugin/DirectoryReader.js
-define("cordova/plugin/DirectoryReader", function(require, exports, module) {
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError') ;
-
-/**
- * An interface that lists the files and directories in a directory.
- */
-function DirectoryReader(path) {
- this.path = path || null;
-}
-
-/**
- * Returns a list of entries from a directory.
- *
- * @param {Function} successCallback is called with a list of entries
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var retVal = [];
- for (var i=0; i<result.length; i++) {
- var entry = null;
- if (result[i].isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result[i].isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result[i].isDirectory;
- entry.isFile = result[i].isFile;
- entry.name = result[i].name;
- entry.fullPath = result[i].fullPath;
- retVal.push(entry);
- }
- successCallback(retVal);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "readEntries", [this.path]);
-};
-
-module.exports = DirectoryReader;
-
-});
-
-// file: lib/common/plugin/Entry.js
-define("cordova/plugin/Entry", function(require, exports, module) {
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- Metadata = require('cordova/plugin/Metadata');
-
-/**
- * Represents a file or directory on the local file system.
- *
- * @param isFile
- * {boolean} true if Entry is a file (readonly)
- * @param isDirectory
- * {boolean} true if Entry is a directory (readonly)
- * @param name
- * {DOMString} name of the file or directory, excluding the path
- * leading to it (readonly)
- * @param fullPath
- * {DOMString} the absolute full path to the file or directory
- * (readonly)
- */
-function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
- this.isFile = (typeof isFile != 'undefined'?isFile:false);
- this.isDirectory = (typeof isDirectory != 'undefined'?isDirectory:false);
- this.name = name || '';
- this.fullPath = fullPath || '';
- this.filesystem = fileSystem || null;
-}
-
-/**
- * Look up the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- */
-Entry.prototype.getMetadata = function(successCallback, errorCallback) {
- var success = typeof successCallback !== 'function' ? null : function(lastModified) {
- var metadata = new Metadata(lastModified);
- successCallback(metadata);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
-
- exec(success, fail, "File", "getMetadata", [this.fullPath]);
-};
-
-/**
- * Set the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- * @param metadataObject
- * {Object} keys and values to set
- */
-Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
-
- exec(successCallback, errorCallback, "File", "setMetadata", [this.fullPath, metadataObject]);
-};
-
-/**
- * Move a file or directory to a new location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to move this entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new DirectoryEntry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
- var fail = function(code) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(code));
- }
- };
- // user must specify parent Entry
- if (!parent) {
- fail(FileError.NOT_FOUND_ERR);
- return;
- }
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- success = function(entry) {
- if (entry) {
- if (typeof successCallback === 'function') {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- try {
- successCallback(result);
- }
- catch (e) {
- console.log('Error invoking callback: ' + e);
- }
- }
- }
- else {
- // no Entry object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // copy
- exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Copy a directory to a different location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to copy the entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new Entry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
- var fail = function(code) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(code));
- }
- };
-
- // user must specify parent Entry
- if (!parent) {
- fail(FileError.NOT_FOUND_ERR);
- return;
- }
-
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- // success callback
- success = function(entry) {
- if (entry) {
- if (typeof successCallback === 'function') {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- try {
- successCallback(result);
- }
- catch (e) {
- console.log('Error invoking callback: ' + e);
- }
- }
- }
- else {
- // no Entry object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // copy
- exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Return a URL that can be used to identify this entry.
- */
-Entry.prototype.toURL = function() {
- // fullPath attribute contains the full URL
- return this.fullPath;
-};
-
-/**
- * Returns a URI that can be used to identify this entry.
- *
- * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
- * @return uri
- */
-Entry.prototype.toURI = function(mimeType) {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- // fullPath attribute contains the full URI
- return this.toURL();
-};
-
-/**
- * Remove a file or directory. It is an error to attempt to delete a
- * directory that is not empty. It is an error to attempt to delete a
- * root directory of a file system.
- *
- * @param successCallback {Function} called with no parameters
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.remove = function(successCallback, errorCallback) {
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "remove", [this.fullPath]);
-};
-
-/**
- * Look up the parent DirectoryEntry of this entry.
- *
- * @param successCallback {Function} called with the parent DirectoryEntry object
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.getParent = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getParent", [this.fullPath]);
-};
-
-module.exports = Entry;
-});
-
-// file: lib/common/plugin/File.js
-define("cordova/plugin/File", function(require, exports, module) {
-/**
- * Constructor.
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-
-var File = function(name, fullPath, type, lastModifiedDate, size){
- this.name = name || '';
- this.fullPath = fullPath || null;
- this.type = type || null;
- this.lastModifiedDate = lastModifiedDate || null;
- this.size = size || 0;
-};
-
-module.exports = File;
-});
-
-// file: lib/common/plugin/FileEntry.js
-define("cordova/plugin/FileEntry", function(require, exports, module) {
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileWriter = require('cordova/plugin/FileWriter'),
- File = require('cordova/plugin/File'),
- FileError = require('cordova/plugin/FileError');
-
-/**
- * An interface representing a file on the file system.
- *
- * {boolean} isFile always true (readonly)
- * {boolean} isDirectory always false (readonly)
- * {DOMString} name of the file, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the file (readonly)
- * {FileSystem} filesystem on which the file resides (readonly)
- */
-var FileEntry = function(name, fullPath) {
- FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
-};
-
-utils.extend(FileEntry, Entry);
-
-/**
- * Creates a new FileWriter associated with the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new FileWriter
- * @param {Function} errorCallback is called with a FileError
- */
-FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
- this.file(function(filePointer) {
- var writer = new FileWriter(filePointer);
-
- if (writer.fileName === null || writer.fileName === "") {
- if (typeof errorCallback === "function") {
- errorCallback(new FileError(FileError.INVALID_STATE_ERR));
- }
- } else {
- if (typeof successCallback === "function") {
- successCallback(writer);
- }
- }
- }, errorCallback);
-};
-
-/**
- * Returns a File that represents the current state of the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new File object
- * @param {Function} errorCallback is called with a FileError
- */
-FileEntry.prototype.file = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(f) {
- var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size);
- successCallback(file);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
-};
-
-
-module.exports = FileEntry;
-});
-
-// file: lib/common/plugin/FileError.js
-define("cordova/plugin/FileError", function(require, exports, module) {
-/**
- * FileError
- */
-function FileError(error) {
- this.code = error || null;
-}
-
-// File error codes
-// Found in DOMException
-FileError.NOT_FOUND_ERR = 1;
-FileError.SECURITY_ERR = 2;
-FileError.ABORT_ERR = 3;
-
-// Added by File API specification
-FileError.NOT_READABLE_ERR = 4;
-FileError.ENCODING_ERR = 5;
-FileError.NO_MODIFICATION_ALLOWED_ERR = 6;
-FileError.INVALID_STATE_ERR = 7;
-FileError.SYNTAX_ERR = 8;
-FileError.INVALID_MODIFICATION_ERR = 9;
-FileError.QUOTA_EXCEEDED_ERR = 10;
-FileError.TYPE_MISMATCH_ERR = 11;
-FileError.PATH_EXISTS_ERR = 12;
-
-module.exports = FileError;
-});
-
-// file: lib/common/plugin/FileReader.js
-define("cordova/plugin/FileReader", function(require, exports, module) {
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-/**
- * This class reads the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To read from the SD card, the file name is "sdcard/my_file.txt"
- * @constructor
- */
-var FileReader = function() {
- this.fileName = "";
-
- this.readyState = 0; // FileReader.EMPTY
-
- // File data
- this.result = null;
-
- // Error
- this.error = null;
-
- // Event handlers
- this.onloadstart = null; // When the read starts.
- this.onprogress = null; // While reading (and decoding) file or fileBlob data, and reporting partial file data (progess.loaded/progress.total)
- this.onload = null; // When the read has successfully completed.
- this.onerror = null; // When the read has failed (see errors).
- this.onloadend = null; // When the request has completed (either in success or failure).
- this.onabort = null; // When the read has been aborted. For instance, by invoking the abort() method.
-};
-
-// States
-FileReader.EMPTY = 0;
-FileReader.LOADING = 1;
-FileReader.DONE = 2;
-
-/**
- * Abort reading file.
- */
-FileReader.prototype.abort = function() {
- this.result = null;
-
- if (this.readyState == FileReader.DONE || this.readyState == FileReader.EMPTY) {
- return;
- }
-
- this.readyState = FileReader.DONE;
-
- // If abort callback
- if (typeof this.onabort === 'function') {
- this.onabort(new ProgressEvent('abort', {target:this}));
- }
- // If load end callback
- if (typeof this.onloadend === 'function') {
- this.onloadend(new ProgressEvent('loadend', {target:this}));
- }
-};
-
-/**
- * Read text file.
- *
- * @param file {File} File object containing file properties
- * @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)
- */
-FileReader.prototype.readAsText = function(file, encoding) {
- // Figure out pathing
- this.fileName = '';
- if (typeof file.fullPath === 'undefined') {
- this.fileName = file;
- } else {
- this.fileName = file.fullPath;
- }
-
- // Already loading something
- if (this.readyState == FileReader.LOADING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // LOADING state
- this.readyState = FileReader.LOADING;
-
- // If loadstart callback
- if (typeof this.onloadstart === "function") {
- this.onloadstart(new ProgressEvent("loadstart", {target:this}));
- }
-
- // Default encoding is UTF-8
- var enc = encoding ? encoding : "UTF-8";
-
- var me = this;
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
- return;
- }
-
- // Save result
- me.result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // DONE state
- me.readyState = FileReader.DONE;
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileReader.DONE;
-
- // null result
- me.result = null;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsText", [this.fileName, enc]);
-};
-
-
-/**
- * Read file and return data as a base64 encoded data url.
- * A data url is of the form:
- * data:[<mediatype>][;base64],<data>
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsDataURL = function(file) {
- this.fileName = "";
- if (typeof file.fullPath === "undefined") {
- this.fileName = file;
- } else {
- this.fileName = file.fullPath;
- }
-
- // Already loading something
- if (this.readyState == FileReader.LOADING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // LOADING state
- this.readyState = FileReader.LOADING;
-
- // If loadstart callback
- if (typeof this.onloadstart === "function") {
- this.onloadstart(new ProgressEvent("loadstart", {target:this}));
- }
-
- var me = this;
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileReader.DONE;
-
- // Save result
- me.result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileReader.DONE;
-
- me.result = null;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsDataURL", [this.fileName]);
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsBinaryString = function(file) {
- // TODO - Can't return binary data to browser.
- console.log('method "readAsBinaryString" is not supported at this time.');
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsArrayBuffer = function(file) {
- // TODO - Can't return binary data to browser.
- console.log('This method is not supported at this time.');
-};
-
-module.exports = FileReader;
-});
-
-// file: lib/common/plugin/FileSystem.js
-define("cordova/plugin/FileSystem", function(require, exports, module) {
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
-
-/**
- * An interface representing a file system
- *
- * @constructor
- * {DOMString} name the unique name of the file system (readonly)
- * {DirectoryEntry} root directory of the file system (readonly)
- */
-var FileSystem = function(name, root) {
- this.name = name || null;
- if (root) {
- this.root = new DirectoryEntry(root.name, root.fullPath);
- }
-};
-
-module.exports = FileSystem;
-
-});
-
-// file: lib/common/plugin/FileTransfer.js
-define("cordova/plugin/FileTransfer", function(require, exports, module) {
-var exec = require('cordova/exec'),
- FileTransferError = require('cordova/plugin/FileTransferError');
-
-/**
- * FileTransfer uploads a file to a remote server.
- * @constructor
- */
-var FileTransfer = function() {};
-
-/**
-* Given an absolute file path, uploads a file on the device to a remote server
-* using a multipart HTTP request.
-* @param filePath {String} Full path of the file on the device
-* @param server {String} URL of the server to receive the file
-* @param successCallback (Function} Callback to be invoked when upload has completed
-* @param errorCallback {Function} Callback to be invoked upon error
-* @param options {FileUploadOptions} Optional parameters such as file name and mimetype
-* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
-*/
-FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) {
- // sanity parameter checking
- if (!filePath || !server) throw new Error("FileTransfer.upload requires filePath and server URL parameters at the minimum.");
- // check for options
- var fileKey = null;
- var fileName = null;
- var mimeType = null;
- var params = null;
- var chunkedMode = true;
- var headers = null;
- if (options) {
- fileKey = options.fileKey;
- fileName = options.fileName;
- mimeType = options.mimeType;
- headers = options.headers;
- if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
- chunkedMode = options.chunkedMode;
- }
- if (options.params) {
- params = options.params;
- }
- else {
- params = {};
- }
- }
-
- var fail = function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
- errorCallback(error);
- };
-
- exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers]);
-};
-
-/**
- * Downloads a file form a given URL and saves it to the specified directory.
- * @param source {String} URL of the server to receive the file
- * @param target {String} Full path of the file on the device
- * @param successCallback (Function} Callback to be invoked when upload has completed
- * @param errorCallback {Function} Callback to be invoked upon error
- */
-FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
- // sanity parameter checking
- if (!source || !target) throw new Error("FileTransfer.download requires source URI and target URI parameters at the minimum.");
- var win = function(result) {
- var entry = null;
- if (result.isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result.isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result.isDirectory;
- entry.isFile = result.isFile;
- entry.name = result.name;
- entry.fullPath = result.fullPath;
- successCallback(entry);
- };
-
- var fail = function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
- errorCallback(error);
- };
-
- exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
-};
-
-module.exports = FileTransfer;
-
-});
-
-// file: lib/common/plugin/FileTransferError.js
-define("cordova/plugin/FileTransferError", function(require, exports, module) {
-/**
- * FileTransferError
- * @constructor
- */
-var FileTransferError = function(code, source, target, status) {
- this.code = code || null;
- this.source = source || null;
- this.target = target || null;
- this.http_status = status || null;
-};
-
-FileTransferError.FILE_NOT_FOUND_ERR = 1;
-FileTransferError.INVALID_URL_ERR = 2;
-FileTransferError.CONNECTION_ERR = 3;
-
-module.exports = FileTransferError;
-
-});
-
-// file: lib/common/plugin/FileUploadOptions.js
-define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
-/**
- * Options to customize the HTTP request used to upload files.
- * @constructor
- * @param fileKey {String} Name of file request parameter.
- * @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
- * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.
- * @param params {Object} Object with key: value params to send to the server.
- * @param headers {Object} Keys are header names, values are header values. Multiple
- * headers of the same name are not supported.
- */
-var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers) {
- this.fileKey = fileKey || null;
- this.fileName = fileName || null;
- this.mimeType = mimeType || null;
- this.params = params || null;
- this.headers = headers || null;
-};
-
-module.exports = FileUploadOptions;
-
-});
-
-// file: lib/common/plugin/FileUploadResult.js
-define("cordova/plugin/FileUploadResult", function(require, exports, module) {
-/**
- * FileUploadResult
- * @constructor
- */
-var FileUploadResult = function() {
- this.bytesSent = 0;
- this.responseCode = null;
- this.response = null;
-};
-
-module.exports = FileUploadResult;
-});
-
-// file: lib/common/plugin/FileWriter.js
-define("cordova/plugin/FileWriter", function(require, exports, module) {
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-/**
- * This class writes to the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To write to the SD card, the file name is "sdcard/my_file.txt"
- *
- * @constructor
- * @param file {File} File object containing file properties
- * @param append if true write to the end of the file, otherwise overwrite the file
- */
-var FileWriter = function(file) {
- this.fileName = "";
- this.length = 0;
- if (file) {
- this.fileName = file.fullPath || file;
- this.length = file.size || 0;
- }
- // default is to write at the beginning of the file
- this.position = 0;
-
- this.readyState = 0; // EMPTY
-
- this.result = null;
-
- // Error
- this.error = null;
-
- // Event handlers
- this.onwritestart = null; // When writing starts
- this.onprogress = null; // While writing the file, and reporting partial file data
- this.onwrite = null; // When the write has successfully completed.
- this.onwriteend = null; // When the request has completed (either in success or failure).
- this.onabort = null; // When the write has been aborted. For instance, by invoking the abort() method.
- this.onerror = null; // When the write has failed (see errors).
-};
-
-// States
-FileWriter.INIT = 0;
-FileWriter.WRITING = 1;
-FileWriter.DONE = 2;
-
-/**
- * Abort writing file.
- */
-FileWriter.prototype.abort = function() {
- // check for invalid state
- if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // set error
- this.error = new FileError(FileError.ABORT_ERR);
-
- this.readyState = FileWriter.DONE;
-
- // If abort callback
- if (typeof this.onabort === "function") {
- this.onabort(new ProgressEvent("abort", {"target":this}));
- }
-
- // If write end callback
- if (typeof this.onwriteend === "function") {
- this.onwriteend(new ProgressEvent("writeend", {"target":this}));
- }
-};
-
-/**
- * Writes data to the file
- *
- * @param text to be written
- */
-FileWriter.prototype.write = function(text) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":me}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
-
<TRUNCATED>