Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 38128DACA for ; Wed, 17 Oct 2012 23:27:02 +0000 (UTC) Received: (qmail 5200 invoked by uid 500); 17 Oct 2012 23:27:01 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 5095 invoked by uid 500); 17 Oct 2012 23:27:01 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 4805 invoked by uid 99); 17 Oct 2012 23:27:01 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Oct 2012 23:27:01 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C232B944F; Wed, 17 Oct 2012 23:27:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: purplecabbage@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [10/50] [abbrv] Merging+Moving Windows7 specifics Message-Id: <20121017232700.C232B944F@tyr.zones.apache.org> Date: Wed, 17 Oct 2012 23:27:00 +0000 (UTC) http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/Cordova/www/device.html ---------------------------------------------------------------------- diff --git a/Cordova/www/device.html b/Cordova/www/device.html deleted file mode 100644 index 42a4774..0000000 --- a/Cordova/www/device.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - Device Info - - - -
- - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/Cordova/www/events.html ---------------------------------------------------------------------- diff --git a/Cordova/www/events.html b/Cordova/www/events.html deleted file mode 100644 index 5d9c5e3..0000000 --- a/Cordova/www/events.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - Events Test - - - -
- - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/Cordova/www/file.html ---------------------------------------------------------------------- diff --git a/Cordova/www/file.html b/Cordova/www/file.html deleted file mode 100644 index 4419ed5..0000000 --- a/Cordova/www/file.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - Device Info - - - -
-
-
-
- - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/Cordova/www/index.html ---------------------------------------------------------------------- diff --git a/Cordova/www/index.html b/Cordova/www/index.html deleted file mode 100644 index 2b509c1..0000000 --- a/Cordova/www/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - Welcome to Cordova - - - - - Device
- Network
- Accelerometer
- Capture
- Events
- Notification
- Storage
- File
- \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/Cordova/www/network.html ---------------------------------------------------------------------- diff --git a/Cordova/www/network.html b/Cordova/www/network.html deleted file mode 100644 index fb0891c..0000000 --- a/Cordova/www/network.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - Connectivity Info - - - -
- - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/Cordova/www/notification.html ---------------------------------------------------------------------- diff --git a/Cordova/www/notification.html b/Cordova/www/notification.html deleted file mode 100644 index aaea533..0000000 --- a/Cordova/www/notification.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - Notification - - - -

Tap on the Launch PopUp button below to open the modal window.

-
- - - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/Cordova/www/storage.html ---------------------------------------------------------------------- diff --git a/Cordova/www/storage.html b/Cordova/www/storage.html deleted file mode 100644 index 8ebfdfb..0000000 --- a/Cordova/www/storage.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/README ---------------------------------------------------------------------- diff --git a/README b/README deleted file mode 100644 index 9b6ad62..0000000 --- a/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 http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/windows7/Cordova.sln ---------------------------------------------------------------------- diff --git a/windows7/Cordova.sln b/windows7/Cordova.sln new file mode 100644 index 0000000..5e07fda --- /dev/null +++ b/windows7/Cordova.sln @@ -0,0 +1,20 @@ + +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/incubator-cordova-windows/blob/3711f4bc/windows7/Cordova/Cordova.vcxproj ---------------------------------------------------------------------- diff --git a/windows7/Cordova/Cordova.vcxproj b/windows7/Cordova/Cordova.vcxproj new file mode 100644 index 0000000..944fa99 --- /dev/null +++ b/windows7/Cordova/Cordova.vcxproj @@ -0,0 +1,161 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {3FE6EDB1-A141-4CC2-BA28-FD7761F2E9A9} + Win32Proj + PGA + + + + Application + true + Unicode + v110 + + + Application + false + true + Unicode + v110 + + + + + + + + + + + + + true + $(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include\um;$(WindowsSdkDir)include\shared;$(FrameworkSDKDir)\include + $(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 + + + false + $(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include\um;$(WindowsSdkDir)include\shared;$(FrameworkSDKDir)\include + $(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 + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + + + Windows + true + %(AdditionalDependencies) + + + + + + Level3 + + + MinSpace + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + Size + true + true + MultiThreaded + StreamingSIMDExtensions2 + + + Windows + true + true + true + %(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Designer + + + + + + + + Designer + + + + + + Designer + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/windows7/Cordova/Cordova.vcxproj.filters ---------------------------------------------------------------------- diff --git a/windows7/Cordova/Cordova.vcxproj.filters b/windows7/Cordova/Cordova.vcxproj.filters new file mode 100644 index 0000000..6a13dd9 --- /dev/null +++ b/windows7/Cordova/Cordova.vcxproj.filters @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + javascript + + + javascript + + + javascript + + + javascript + + + html + + + html + + + html + + + html + + + html + + + javascript + + + javascript + + + html + + + javascript + + + html + + + html + + + html + + + html + + + html + + + html + + + + + {03872dca-8198-4d19-a847-612e33652f00} + + + {56894366-d156-48a1-a4ac-68ebf29c4442} + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/3711f4bc/windows7/Cordova/accel.c ---------------------------------------------------------------------- diff --git a/windows7/Cordova/accel.c b/windows7/Cordova/accel.c new file mode 100644 index 0000000..bbfc2ec --- /dev/null +++ b/windows7/Cordova/accel.c @@ -0,0 +1,251 @@ +// 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 +#include +#include +#include +#include +#include +#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/incubator-cordova-windows/blob/3711f4bc/windows7/Cordova/accel.h ---------------------------------------------------------------------- diff --git a/windows7/Cordova/accel.h b/windows7/Cordova/accel.h new file mode 100644 index 0000000..807cf49 --- /dev/null +++ b/windows7/Cordova/accel.h @@ -0,0 +1,22 @@ +// 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)