From 22bbec2c414f535551be9ddd9eb1af2f5aa81c4c Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Wed, 21 Oct 2015 22:32:39 -0700 Subject: [PATCH] Windows 10 RTM Release - October 2015 Update 3 --- Samples/Accelerometer/js/Package.appxmanifest | 8 +- Samples/Accelerometer/vb/Package.appxmanifest | 2 +- .../ActivitySensor/vb/Package.appxmanifest | 2 +- .../AdaptiveStreaming/js/package.appxmanifest | 2 +- .../AdaptiveStreaming/vb/Package.appxmanifest | 2 +- .../AdvancedCasting/vb/Package.appxmanifest | 2 +- .../ISecureInterfaceService.h | 2 +- .../SecureInterfaceConsumer.cpp | 144 ++--- .../SecureInterfaceConsumer.h | 90 +++- .../SecureInterfaceMethodResults.h | 11 + .../SecureInterfaceProducer.cpp | 61 ++- .../SecureInterfaceProducer.h | 89 +++- .../SecureInterfaceServiceEventAdapter.cpp | 12 +- .../SecureInterfaceServiceEventAdapter.h | 70 ++- .../SecureInterfaceServiceEventArgs.cpp | 6 +- .../SecureInterfaceSignals.cpp | 6 +- .../SecureInterfaceSignals.h | 23 +- .../SecureInterfaceWatcher.h | 45 +- .../IOnboardingService.h | 8 +- .../OnboardingConsumer.cpp | 175 +++--- .../OnboardingConsumer.h | 68 ++- .../OnboardingMethodResults.h | 23 + .../OnboardingProducer.cpp | 86 +-- .../OnboardingProducer.h | 89 +++- .../OnboardingServiceEventAdapter.cpp | 28 +- .../OnboardingServiceEventAdapter.h | 164 +++++- .../OnboardingServiceEventArgs.cpp | 14 +- .../OnboardingSignals.cpp | 6 +- .../OnboardingSignals.h | 23 +- .../OnboardingWatcher.h | 45 +- .../cs/OnboardingEnumTypes.cs | 2 +- .../ConsumerExperiences/cs/Scenario1.xaml | 2 +- .../cs/Scenario1ViewModel.cs | 22 +- .../ConsumerExperiences/cs/Scenario2.xaml | 4 +- .../cs/Scenario2ViewModel.cs | 22 +- .../js/AllJoynConsumerExperiences.jsproj | 138 +++++ .../js/AllJoynConsumerExperiences.sln | 68 +++ .../Microsoft.WinJS.4.0/css/placeholder.txt | 0 .../js/Microsoft.WinJS.4.0/fonts/placeholder | 0 .../js/en-US/placeholder.txt | 0 .../js/css/placeholder.txt | 0 .../js/html/scenario1.html | 38 ++ .../js/html/scenario2.html | 76 +++ .../js/images/placeholder.txt | 0 .../js/js/onboardingenumtypes.js | 85 +++ .../js/js/sample-configuration.js | 17 + .../ConsumerExperiences/js/js/scenario1.js | 265 ++++++++++ .../ConsumerExperiences/js/js/scenario2.js | 496 ++++++++++++++++++ .../js/package.appxmanifest | 54 ++ .../js/sample-utils/placeholder.txt | 0 .../cs/Scenario1ViewModel.cs | 4 +- .../ProducerExperiences/cs/Scenario2.xaml | 4 +- .../cs/Scenario2ViewModel.cs | 6 +- .../js/AllJoynProducerExperiences.jsproj | 141 +++++ .../js/AllJoynProducerExperiences.sln | 68 +++ .../Microsoft.WinJS.4.0/css/placeholder.txt | 0 .../js/Microsoft.WinJS.4.0/fonts/placeholder | 0 .../js/en-US/placeholder.txt | 0 .../ProducerExperiences/js/css/scenario.css | 9 + .../js/html/scenario1.html | 39 ++ .../js/html/scenario2.html | 38 ++ .../js/images/placeholder.txt | 0 .../ProducerExperiences/js/js/appdata.js | 163 ++++++ .../js/js/cryptographichelpers.js | 75 +++ .../js/js/onboardingenumtypes.js | 85 +++ .../js/js/sample-configuration.js | 17 + .../ProducerExperiences/js/js/scenario1.js | 170 ++++++ .../ProducerExperiences/js/js/scenario2.js | 282 ++++++++++ .../js/package.appxmanifest | 31 ++ .../js/sample-utils/placeholder.txt | 0 .../shared/AllJoynBusObjectManager.cpp | 7 +- Samples/AllJoyn/shared/AllJoynHelpers.cpp | 10 - Samples/AllJoyn/shared/AllJoynHelpers.h | 4 - .../AllJoyn/shared/TypeConversionHelpers.cpp | 4 +- .../AllJoyn/shared/TypeConversionHelpers.h | 58 +- Samples/Altimeter/js/Package.appxmanifest | 2 +- Samples/Altimeter/vb/Package.appxmanifest | 2 +- .../AnimationLibrary/js/Package.appxmanifest | 2 +- .../AnimationMetrics/js/Package.appxmanifest | 2 +- .../AnimationMetrics/vb/Package.appxmanifest | 2 +- .../vb/AppServicesClient/Package.appxmanifest | 2 +- .../AppServicesProvider/Package.appxmanifest | 2 +- .../ApplicationData/vb/Package.appxmanifest | 2 +- Samples/ApplicationResources/cpp/App.xaml | 34 -- Samples/ApplicationResources/cpp/App.xaml.cpp | 127 ----- Samples/ApplicationResources/cpp/App.xaml.h | 33 -- .../cpp/ApplicationResources.vcxproj | 86 +-- .../cpp/ApplicationResources.vcxproj.filters | 34 +- .../ApplicationResources/cpp/MainPage.xaml | 83 --- .../cpp/MainPage.xaml.cpp | 137 ----- .../ApplicationResources/cpp/MainPage.xaml.h | 45 -- .../cpp/Package.appxmanifest | 2 +- .../ApplicationResources/cpp/scenario10.xaml | 113 ---- .../ApplicationResources/cpp/scenario11.xaml | 65 --- .../ApplicationResources/cpp/scenario12.xaml | 85 --- .../ApplicationResources/cpp/scenario13.xaml | 74 --- .../ApplicationResources/cpp/scenario3.xaml | 53 -- .../cpp/scenario8.xaml.cpp | 142 ++--- .../ApplicationResources/cpp/scenario8.xaml.h | 32 +- .../AppResourceClassLibrary.csproj | 10 - .../cs/ApplicationResources.csproj | 50 +- .../cs/languageoverride.xaml | 17 - .../cs/languageoverride.xaml.cs | 132 ----- .../ApplicationResources/cs/scenario1.xaml | 58 -- .../ApplicationResources/cs/scenario2.xaml | 91 ---- .../ApplicationResources/cs/scenario4.xaml | 55 -- .../ApplicationResources/cs/scenario5.xaml | 55 -- .../ApplicationResources/cs/scenario7.xaml | 74 --- .../ApplicationResources/cs/scenario8.xaml | 89 ---- .../ApplicationResources/cs/scenario8.xaml.cs | 123 +++-- .../shared/strings/en/resources.resw | 13 + .../shared/strings/fr/resources.resw | 13 + .../shared/strings/ja/resources.resw | 13 + .../{cpp => shared/xaml}/scenario1.xaml | 0 .../{cs => shared/xaml}/scenario10.xaml | 0 .../{cs => shared/xaml}/scenario11.xaml | 0 .../{cs => shared/xaml}/scenario12.xaml | 0 .../{cs => shared/xaml}/scenario13.xaml | 0 .../{cpp => shared/xaml}/scenario2.xaml | 2 +- .../{cs => shared/xaml}/scenario3.xaml | 5 +- .../{cpp => shared/xaml}/scenario4.xaml | 0 .../{cpp => shared/xaml}/scenario5.xaml | 0 .../{cs => shared/xaml}/scenario6.xaml | 0 .../{cpp => shared/xaml}/scenario7.xaml | 17 +- .../{cpp => shared/xaml}/scenario8.xaml | 12 +- .../{cs => shared/xaml}/scenario9.xaml | 0 .../vb/ApplicationResources.vbproj | 48 +- .../vb/Package.appxmanifest | 2 +- .../vb/languageoverride.xaml | 17 - .../vb/languageoverride.xaml.vb | 89 ---- .../ApplicationResources/vb/scenario1.xaml | 58 -- .../ApplicationResources/vb/scenario10.xaml | 114 ---- .../ApplicationResources/vb/scenario11.xaml | 66 --- .../ApplicationResources/vb/scenario12.xaml | 86 --- .../ApplicationResources/vb/scenario13.xaml | 74 --- .../ApplicationResources/vb/scenario2.xaml | 91 ---- .../ApplicationResources/vb/scenario3.xaml | 53 -- .../ApplicationResources/vb/scenario4.xaml | 55 -- .../ApplicationResources/vb/scenario5.xaml | 55 -- .../ApplicationResources/vb/scenario6.xaml | 58 -- .../ApplicationResources/vb/scenario7.xaml | 74 --- .../ApplicationResources/vb/scenario8.xaml | 89 ---- .../ApplicationResources/vb/scenario8.xaml.vb | 107 +++- .../ApplicationResources/vb/scenario9.xaml | 68 --- Samples/Appointments/vb/Package.appxmanifest | 2 +- Samples/AssociationLaunching/cs/App.xaml.cs | 173 ------ .../cs/AssociationLaunching.csproj | 7 +- .../AssociationLaunching/cs/MainPage.xaml.cs | 170 ------ .../cs/Package.appxmanifest | 6 +- .../cs/SampleConfiguration.cs | 98 +++- .../cs/Scenario1_LaunchFile.xaml.cs | 110 ++-- .../cs/Scenario2_LaunchUri.xaml.cs | 98 +--- .../cs/Scenario3_ReceiveFile.xaml.cs | 82 ++- .../cs/Scenario4_ReceiveUri.xaml.cs | 28 +- .../shared/Scenario1_LaunchFile.xaml | 150 ++---- .../shared/Scenario2_LaunchUri.xaml | 153 ++---- .../shared/Scenario3_ReceiveFile.xaml | 83 ++- .../shared/Scenario4_ReceiveUri.xaml | 70 +-- Samples/AssociationLaunching/vb/App.xaml.vb | 123 ----- .../vb/AssociationLaunching.vbproj | 8 +- .../AssociationLaunching/vb/MainPage.xaml.vb | 145 ----- .../vb/Package.appxmanifest | 10 +- .../vb/SampleConfiguration.vb | 68 ++- .../vb/Scenario1_LaunchFile.xaml.vb | 107 ++-- .../vb/Scenario2_LaunchUri.xaml.vb | 82 +-- .../vb/Scenario3_ReceiveFile.xaml.vb | 68 ++- .../vb/Scenario4_ReceiveUri.xaml.vb | 26 +- .../AudioCategoryCompanion.csproj | 22 +- .../js/AudioCategory/package.appxmanifest | 2 +- .../vb/AudioCategory/Package.appxmanifest | 2 +- .../AudioCategoryCompanion.vbproj | 22 +- .../Package.appxmanifest | 2 +- Samples/BackButton/vb/Package.appxmanifest | 2 +- .../vb/BackgroundAudio/Package.appxmanifest | 2 +- .../vb/BackgroundAudio/Scenario1.xaml.vb | 108 +++- .../BackgroundSensors/vb/Package.appxmanifest | 2 +- .../vb/BackgroundTask/Package.appxmanifest | 2 +- .../BackgroundTransfer/Package.appxmanifest | 2 +- .../BarcodeScanner/js/Package.appxmanifest | 2 +- .../BarcodeScanner/vb/Package.appxmanifest | 2 +- Samples/Barometer/js/Package.appxmanifest | 2 +- Samples/Barometer/vb/Package.appxmanifest | 2 +- .../cpp/Package.appxmanifest | 2 +- .../cs/BasicFaceDetection.csproj | 2 +- .../cs/Package.appxmanifest | 2 +- .../vb/BasicFaceDetection.vbproj | 2 +- .../vb/Package.appxmanifest | 2 +- .../BasicFaceTracking/vb/Package.appxmanifest | 8 +- .../vb/SampleConfiguration.vb | 2 +- .../vb/Scenario1_TrackInWebcam.xaml.vb | 2 +- Samples/BasicInput/vb/Package.appxmanifest | 2 +- .../BasicMediaCasting/vb/Package.appxmanifest | 2 +- .../js/Package.appxmanifest | 4 +- .../vb/Package.appxmanifest | 2 +- .../cs/Package.appxmanifest | 2 +- Samples/Calendar/vb/Package.appxmanifest | 2 +- .../cpp/Package.appxmanifest | 2 +- .../cs/Package.appxmanifest | 2 +- .../vb/Package.appxmanifest | 2 +- Samples/CameraGetPreviewFrame/cpp/App.xaml | 20 - .../cpp/CameraGetPreviewFrame.vcxproj | 12 +- .../cpp/CameraGetPreviewFrame.vcxproj.filters | 4 +- .../CameraGetPreviewFrame/cpp/MainPage.xaml | 54 -- .../cpp/MainPage.xaml.cpp | 104 +++- .../CameraGetPreviewFrame/cpp/MainPage.xaml.h | 1 + .../cs/CameraGetPreviewFrame.csproj | 8 +- .../cs/Package.appxmanifest | 2 +- .../{cs => shared}/App.xaml | 0 .../{cs => shared}/MainPage.xaml | 0 Samples/CameraHdr/js/package.appxmanifest | 2 +- Samples/CameraHdr/vb/Package.appxmanifest | 2 +- .../CameraProfile/cpp/Package.appxmanifest | 4 +- .../CameraResolution/cpp/Package.appxmanifest | 2 +- .../CameraResolution/js/Package.appxmanifest | 2 +- .../CameraStarterKit/cs/Package.appxmanifest | 2 +- .../CameraStarterKit/js/Package.appxmanifest | 2 +- .../CameraStarterKit/vb/Package.appxmanifest | 2 +- .../cs/Package.appxmanifest | 2 +- .../vb/Package.appxmanifest | 2 +- Samples/CashDrawer/js/Package.appxmanifest | 2 +- Samples/CashDrawer/vb/Package.appxmanifest | 2 +- Samples/Clipboard/js/Package.appxmanifest | 2 +- Samples/Clipboard/vb/Package.appxmanifest | 2 +- .../cs/Package.appxmanifest | 2 +- Samples/Compass/js/Package.appxmanifest | 2 +- .../CompositionVisual/vb/Package.appxmanifest | 2 +- .../ContentIndexer/js/Package.appxmanifest | 2 +- Samples/ContextMenu/js/Package.appxmanifest | 2 +- .../CredentialPicker/js/Package.appxmanifest | 2 +- .../CustomSensors/cpp/Package.appxmanifest | 2 +- Samples/CustomSensors/js/Package.appxmanifest | 2 +- .../js/Package.appxmanifest | 2 +- .../js/Package.appxmanifest | 2 +- .../cpp/PixelShader/Package.appxmanifest | 2 +- .../DataReaderWriter/cpp/Package.appxmanifest | 2 +- .../DataReaderWriter/cs/Package.appxmanifest | 2 +- .../DataReaderWriter/js/Package.appxmanifest | 2 +- .../DeviceEnumerationCpp/Package.appxmanifest | 2 +- .../DeviceEnumerationCs/Package.appxmanifest | 2 +- .../cpp/Package.appxmanifest | 2 +- Samples/DpiScaling/js/Package.appxmanifest | 2 +- Samples/EasProtocol/js/Package.appxmanifest | 2 +- .../js/Package.appxmanifest | 4 +- .../cs/Package.appxmanifest | 4 +- Samples/FeedReader/js/Package.appxmanifest | 2 +- Samples/FileAccess/js/Package.appxmanifest | 2 +- Samples/FilePicker/js/Package.appxmanifest | 2 +- Samples/FileSearch/js/Package.appxmanifest | 2 +- .../FileThumbnails/js/Package.appxmanifest | 2 +- .../FolderEnumeration/js/Package.appxmanifest | 2 +- .../js/Package.appxmanifest | 4 +- Samples/IndexedDB/js/Package.appxmanifest | 4 +- Samples/IoT-I2C/cpp/Package.appxmanifest | 2 +- Samples/IoT-I2C/cs/Package.appxmanifest | 2 +- Samples/IoT-I2C/js/package.appxmanifest | 2 +- Samples/IoT-SPI/cs/Package.appxmanifest | 2 +- Samples/LampDevice/cpp/Package.appxmanifest | 2 +- Samples/LampDevice/cs/Package.appxmanifest | 2 +- Samples/MediaImport/cs/Import.csproj | 2 +- Samples/MediaImport/cs/Package.appxmanifest | 10 +- .../MediaTranscoding/cpp/Package.appxmanifest | 2 +- .../MediaTranscoding/cs/Package.appxmanifest | 2 +- .../MediaTranscoding/js/package.appxmanifest | 2 +- Samples/MsBlobBuilder/js/Package.appxmanifest | 4 +- .../NfcProvisioner/cs/Package.appxmanifest | 2 +- .../PackagedContent/js/package.appxmanifest | 2 +- .../cpp/cpp/Package.appxmanifest | 2 +- .../cpp/cs/Package.appxmanifest | 2 +- .../cpp/js/Package.appxmanifest | 2 +- .../cs/cpp/Package.appxmanifest | 2 +- .../cs/cs/Package.appxmanifest | 2 +- .../cs/js/Package.appxmanifest | 2 +- Samples/SerialArduino/cs/Package.appxmanifest | 2 +- Samples/Store/cpp/Package.appxmanifest | 2 +- Samples/Store/cs/Package.appxmanifest | 2 +- .../TextSuggestion/js/Package.appxmanifest | 4 +- Samples/UserSelection/js/Package.appxmanifest | 4 +- .../cpp/cpp/Package.appxmanifest | 2 +- .../cpp/cs/Package.appxmanifest | 2 +- .../cpp/js/Package.appxmanifest | 2 +- .../cpp/cpp/Package.appxmanifest | 2 +- .../cpp/cs/Package.appxmanifest | 2 +- .../cpp/js/Package.appxmanifest | 2 +- Samples/WebView/js/Package.appxmanifest | 4 +- Samples/WebWorkers/js/Package.appxmanifest | 4 +- Samples/XmlDocument/js/Package.appxmanifest | 2 +- 286 files changed, 4791 insertions(+), 4685 deletions(-) create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/AllJoynConsumerExperiences.jsproj create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/AllJoynConsumerExperiences.sln create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/Microsoft.WinJS.4.0/css/placeholder.txt create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/Microsoft.WinJS.4.0/fonts/placeholder create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/css/placeholder.txt create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/html/scenario1.html create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/html/scenario2.html create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/images/placeholder.txt create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/js/onboardingenumtypes.js create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/js/sample-configuration.js create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/js/scenario1.js create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/js/scenario2.js create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/package.appxmanifest create mode 100644 Samples/AllJoyn/ConsumerExperiences/js/sample-utils/placeholder.txt create mode 100644 Samples/AllJoyn/ProducerExperiences/js/AllJoynProducerExperiences.jsproj create mode 100644 Samples/AllJoyn/ProducerExperiences/js/AllJoynProducerExperiences.sln create mode 100644 Samples/AllJoyn/ProducerExperiences/js/Microsoft.WinJS.4.0/css/placeholder.txt create mode 100644 Samples/AllJoyn/ProducerExperiences/js/Microsoft.WinJS.4.0/fonts/placeholder create mode 100644 Samples/AllJoyn/ProducerExperiences/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt create mode 100644 Samples/AllJoyn/ProducerExperiences/js/css/scenario.css create mode 100644 Samples/AllJoyn/ProducerExperiences/js/html/scenario1.html create mode 100644 Samples/AllJoyn/ProducerExperiences/js/html/scenario2.html create mode 100644 Samples/AllJoyn/ProducerExperiences/js/images/placeholder.txt create mode 100644 Samples/AllJoyn/ProducerExperiences/js/js/appdata.js create mode 100644 Samples/AllJoyn/ProducerExperiences/js/js/cryptographichelpers.js create mode 100644 Samples/AllJoyn/ProducerExperiences/js/js/onboardingenumtypes.js create mode 100644 Samples/AllJoyn/ProducerExperiences/js/js/sample-configuration.js create mode 100644 Samples/AllJoyn/ProducerExperiences/js/js/scenario1.js create mode 100644 Samples/AllJoyn/ProducerExperiences/js/js/scenario2.js create mode 100644 Samples/AllJoyn/ProducerExperiences/js/package.appxmanifest create mode 100644 Samples/AllJoyn/ProducerExperiences/js/sample-utils/placeholder.txt delete mode 100644 Samples/ApplicationResources/cpp/App.xaml delete mode 100644 Samples/ApplicationResources/cpp/App.xaml.cpp delete mode 100644 Samples/ApplicationResources/cpp/App.xaml.h delete mode 100644 Samples/ApplicationResources/cpp/MainPage.xaml delete mode 100644 Samples/ApplicationResources/cpp/MainPage.xaml.cpp delete mode 100644 Samples/ApplicationResources/cpp/MainPage.xaml.h delete mode 100644 Samples/ApplicationResources/cpp/scenario10.xaml delete mode 100644 Samples/ApplicationResources/cpp/scenario11.xaml delete mode 100644 Samples/ApplicationResources/cpp/scenario12.xaml delete mode 100644 Samples/ApplicationResources/cpp/scenario13.xaml delete mode 100644 Samples/ApplicationResources/cpp/scenario3.xaml delete mode 100644 Samples/ApplicationResources/cs/languageoverride.xaml delete mode 100644 Samples/ApplicationResources/cs/languageoverride.xaml.cs delete mode 100644 Samples/ApplicationResources/cs/scenario1.xaml delete mode 100644 Samples/ApplicationResources/cs/scenario2.xaml delete mode 100644 Samples/ApplicationResources/cs/scenario4.xaml delete mode 100644 Samples/ApplicationResources/cs/scenario5.xaml delete mode 100644 Samples/ApplicationResources/cs/scenario7.xaml delete mode 100644 Samples/ApplicationResources/cs/scenario8.xaml rename Samples/ApplicationResources/{cpp => shared/xaml}/scenario1.xaml (100%) rename Samples/ApplicationResources/{cs => shared/xaml}/scenario10.xaml (100%) rename Samples/ApplicationResources/{cs => shared/xaml}/scenario11.xaml (100%) rename Samples/ApplicationResources/{cs => shared/xaml}/scenario12.xaml (100%) rename Samples/ApplicationResources/{cs => shared/xaml}/scenario13.xaml (100%) rename Samples/ApplicationResources/{cpp => shared/xaml}/scenario2.xaml (98%) rename Samples/ApplicationResources/{cs => shared/xaml}/scenario3.xaml (90%) rename Samples/ApplicationResources/{cpp => shared/xaml}/scenario4.xaml (100%) rename Samples/ApplicationResources/{cpp => shared/xaml}/scenario5.xaml (100%) rename Samples/ApplicationResources/{cs => shared/xaml}/scenario6.xaml (100%) rename Samples/ApplicationResources/{cpp => shared/xaml}/scenario7.xaml (83%) rename Samples/ApplicationResources/{cpp => shared/xaml}/scenario8.xaml (82%) rename Samples/ApplicationResources/{cs => shared/xaml}/scenario9.xaml (100%) delete mode 100644 Samples/ApplicationResources/vb/languageoverride.xaml delete mode 100644 Samples/ApplicationResources/vb/languageoverride.xaml.vb delete mode 100644 Samples/ApplicationResources/vb/scenario1.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario10.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario11.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario12.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario13.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario2.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario3.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario4.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario5.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario6.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario7.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario8.xaml delete mode 100644 Samples/ApplicationResources/vb/scenario9.xaml delete mode 100644 Samples/AssociationLaunching/cs/App.xaml.cs delete mode 100644 Samples/AssociationLaunching/cs/MainPage.xaml.cs delete mode 100644 Samples/AssociationLaunching/vb/App.xaml.vb delete mode 100644 Samples/AssociationLaunching/vb/MainPage.xaml.vb delete mode 100644 Samples/CameraGetPreviewFrame/cpp/App.xaml delete mode 100644 Samples/CameraGetPreviewFrame/cpp/MainPage.xaml rename Samples/CameraGetPreviewFrame/{cs => shared}/App.xaml (100%) rename Samples/CameraGetPreviewFrame/{cs => shared}/MainPage.xaml (100%) diff --git a/Samples/Accelerometer/js/Package.appxmanifest b/Samples/Accelerometer/js/Package.appxmanifest index 485064c191..71f2f2e7e2 100644 --- a/Samples/Accelerometer/js/Package.appxmanifest +++ b/Samples/Accelerometer/js/Package.appxmanifest @@ -6,14 +6,14 @@ IgnorableNamespaces="uap mp"> - Accelerometer JS SDK Sample + Accelerometer JS Sample Microsoft Corporation images\storelogo-sdk.png @@ -32,8 +32,8 @@ StartPage="default.html"> diff --git a/Samples/Accelerometer/vb/Package.appxmanifest b/Samples/Accelerometer/vb/Package.appxmanifest index d85ee1cf83..349522f9d7 100644 --- a/Samples/Accelerometer/vb/Package.appxmanifest +++ b/Samples/Accelerometer/vb/Package.appxmanifest @@ -12,7 +12,7 @@ Version="1.0.0.0" /> - + Accelerometer VB Sample diff --git a/Samples/ActivitySensor/vb/Package.appxmanifest b/Samples/ActivitySensor/vb/Package.appxmanifest index 533a09cea1..2fbc0bb2c8 100644 --- a/Samples/ActivitySensor/vb/Package.appxmanifest +++ b/Samples/ActivitySensor/vb/Package.appxmanifest @@ -11,7 +11,7 @@ Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="1.0.0.0" /> - + Activity Sensor VB Sample diff --git a/Samples/AdaptiveStreaming/js/package.appxmanifest b/Samples/AdaptiveStreaming/js/package.appxmanifest index 5ae7f6fced..a8879bab16 100644 --- a/Samples/AdaptiveStreaming/js/package.appxmanifest +++ b/Samples/AdaptiveStreaming/js/package.appxmanifest @@ -6,7 +6,7 @@ IgnorableNamespaces="uap mp"> diff --git a/Samples/AdaptiveStreaming/vb/Package.appxmanifest b/Samples/AdaptiveStreaming/vb/Package.appxmanifest index dd1fec9e41..b84f28c06a 100644 --- a/Samples/AdaptiveStreaming/vb/Package.appxmanifest +++ b/Samples/AdaptiveStreaming/vb/Package.appxmanifest @@ -1,7 +1,7 @@ - + AdaptiveStreaming Microsoft Corporation diff --git a/Samples/AdvancedCasting/vb/Package.appxmanifest b/Samples/AdvancedCasting/vb/Package.appxmanifest index d05a74c1ca..6096d37a91 100644 --- a/Samples/AdvancedCasting/vb/Package.appxmanifest +++ b/Samples/AdvancedCasting/vb/Package.appxmanifest @@ -1,7 +1,7 @@ - + ScreenCasting VB Sample Microsoft Corporation diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h index 45fa60fccb..019fef7ea2 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h @@ -37,7 +37,7 @@ public interface class ISecureInterfaceService { public: // Implement this function to handle calls to the Concatenate method. - Windows::Foundation::IAsyncOperation^ ConcatenateAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info , _In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2); + Windows::Foundation::IAsyncOperation^ ConcatenateAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info , _In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2); // Implement this function to handle requests for the value of the IsUpperCaseEnabled property. // diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp index 8b79c09f40..1386578f91 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp @@ -111,12 +111,8 @@ IAsyncOperation^ SecureInterfaceConsumer::Joi return create_async([serviceInfo, watcher]() -> SecureInterfaceJoinSessionResult^ { auto result = ref new SecureInterfaceJoinSessionResult(); - result->Status = AllJoynStatus::Ok; - result->Consumer = nullptr; - result->Consumer = ref new SecureInterfaceConsumer(watcher->BusAttachment); result->Status = result->Consumer->JoinSession(serviceInfo); - return result; }); } @@ -131,18 +127,26 @@ IAsyncOperation^ SecureInterfaceConsumer::Con size_t argCount = 2; alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount); - TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 0), "s", interfaceMemberInStr1); - TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 1), "s", interfaceMemberInStr2); - - QStatus status = alljoyn_proxybusobject_methodcall( - ProxyBusObject, - "com.microsoft.Samples.SecureInterface", - "Concatenate", - inputs, - argCount, - message, - c_MessageTimeoutInMilliseconds, - 0); + QStatus status = ER_OK; + status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 0), "s", interfaceMemberInStr1)); + + if (ER_OK == status) + { + status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 1), "s", interfaceMemberInStr2)); + } + + if (ER_OK == status) + { + status = alljoyn_proxybusobject_methodcall( + ProxyBusObject, + "com.microsoft.Samples.SecureInterface", + "Concatenate", + inputs, + argCount, + message, + c_MessageTimeoutInMilliseconds, + 0); + } result->Status = static_cast(status); if (ER_OK == status) { @@ -151,7 +155,7 @@ IAsyncOperation^ SecureInterfaceConsumer::Con status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &argument0)); result->OutStr = argument0; - if (status != ER_OK) + if (ER_OK != status) { result->Status = static_cast(status); } @@ -185,30 +189,33 @@ IAsyncOperation^ SecureInterfaceCon PropertySetContext setContext; alljoyn_msgarg inputArgument = alljoyn_msgarg_create(); - TypeConversionHelpers::SetAllJoynMessageArg(inputArgument, "b", value); - - alljoyn_proxybusobject_setpropertyasync( - ProxyBusObject, - "com.microsoft.Samples.SecureInterface", - "IsUpperCaseEnabled", - inputArgument, - [](QStatus status, alljoyn_proxybusobject obj, void* context) - { - UNREFERENCED_PARAMETER(obj); - auto propertyContext = static_cast(context); - propertyContext->SetStatus(status); - propertyContext->SetEvent(); - }, - c_MessageTimeoutInMilliseconds, - &setContext); - - alljoyn_msgarg_destroy(inputArgument); + QStatus status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(inputArgument, "b", value)); + if (ER_OK == status) + { + status = alljoyn_proxybusobject_setpropertyasync( + ProxyBusObject, + "com.microsoft.Samples.SecureInterface", + "IsUpperCaseEnabled", + inputArgument, + [](QStatus status, alljoyn_proxybusobject obj, void* context) + { + UNREFERENCED_PARAMETER(obj); + auto propertyContext = static_cast(context); + propertyContext->SetStatus(status); + propertyContext->SetEvent(); + }, + c_MessageTimeoutInMilliseconds, + &setContext); - setContext.Wait(); + alljoyn_msgarg_destroy(inputArgument); - auto result = ref new SecureInterfaceSetIsUpperCaseEnabledResult(); - result->Status = setContext.GetStatus(); - return result; + setContext.Wait(); + } + if (ER_OK == status) + { + return SecureInterfaceSetIsUpperCaseEnabledResult::CreateSuccessResult(); + } + return SecureInterfaceSetIsUpperCaseEnabledResult::CreateFailureResult(static_cast(status)); }); } @@ -230,7 +237,7 @@ IAsyncOperation^ SecureInterfaceCon if (ER_OK == status) { bool argument; - TypeConversionHelpers::GetAllJoynMessageArg(value, "b", &argument); + status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(value, "b", &argument)); propertyContext->SetValue(argument); } @@ -271,9 +278,12 @@ void SecureInterfaceConsumer::OnPropertyChanged(_In_ alljoyn_proxybusobject obj, return; } + if (strcmp("IsUpperCaseEnabled", propertyName) == 0) { - IsUpperCaseEnabledChanged(this, nullptr); + bool argument; + (void)TypeConversionHelpers::GetAllJoynMessageArg(propertyValue, "b", &argument); + IsUpperCaseEnabledChanged(this, (Platform::Object^)argument); } } } @@ -294,7 +304,7 @@ void SecureInterfaceConsumer::CallTextSentSignalHandler(_In_ const alljoyn_inter eventArgs->MessageInfo = callInfo; Platform::String^ argument0; - TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &argument0); + (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &argument0); eventArgs->Message = argument0; @@ -357,6 +367,25 @@ int32 SecureInterfaceConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo) return AllJoynStatus::Fail; } + RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::GetBusObject(m_nativeBusAttachment, AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath).data(), &m_busObject)); + + if (!AllJoynBusObjectManager::BusObjectIsRegistered(m_nativeBusAttachment, m_busObject)) + { + RETURN_IF_QSTATUS_ERROR(alljoyn_busobject_addinterface(BusObject, description)); + } + + QStatus result = AddSignalHandler( + m_nativeBusAttachment, + description, + "TextSent", + [](const alljoyn_interfacedescription_member* member, PCSTR srcPath, alljoyn_message message) { UNREFERENCED_PARAMETER(srcPath); CallTextSentSignalHandler(member, message); }); + if (ER_OK != result) + { + return static_cast(result); + } + + SourceInterfaces[description] = m_weak; + unsigned int noneMechanismIndex = 0; bool authenticationMechanismsContainsNone = m_busAttachment->AuthenticationMechanisms->IndexOf(AllJoynAuthenticationMechanism::None, &noneMechanismIndex); QCC_BOOL interfaceIsSecure = alljoyn_interfacedescription_issecure(description); @@ -369,7 +398,12 @@ int32 SecureInterfaceConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo) // is specified, or if None is not present in AuthenticationMechanisms. if (!authenticationMechanismsContainsNone || interfaceIsSecure) { - alljoyn_proxybusobject_secureconnection(ProxyBusObject, QCC_FALSE); + RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_secureconnection(ProxyBusObject, QCC_FALSE)); + RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, true)); + } + else + { + RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, false)); } } else @@ -380,28 +414,14 @@ int32 SecureInterfaceConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo) { return static_cast(ER_BUS_NO_AUTHENTICATION_MECHANISM); } + else + { + RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, false)); + } } - RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::GetBusObject(m_nativeBusAttachment, AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath).data(), &m_busObject)); RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_addinterface(ProxyBusObject, description)); - - if (!AllJoynBusObjectManager::BusObjectIsRegistered(m_nativeBusAttachment, m_busObject)) - { - RETURN_IF_QSTATUS_ERROR(alljoyn_busobject_addinterface(BusObject, description)); - } - - QStatus result = AddSignalHandler( - m_nativeBusAttachment, - description, - "TextSent", - [](const alljoyn_interfacedescription_member* member, PCSTR srcPath, alljoyn_message message) { UNREFERENCED_PARAMETER(srcPath); CallTextSentSignalHandler(member, message); }); - if (result != ER_OK) - { - return static_cast(result); - } - - SourceInterfaces[description] = m_weak; - RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, true)); + m_signals->Initialize(BusObject, m_sessionId); return AllJoynStatus::Ok; diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h index a6458b085f..f07c90fc13 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h @@ -55,8 +55,28 @@ public ref class SecureInterfaceConsumer sealed : [Windows::Foundation::Metadat // Call the Concatenate method Windows::Foundation::IAsyncOperation^ ConcatenateAsync(_In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2); + // This event fires whenever the value of IsUpperCaseEnabled changes. - virtual event Windows::Foundation::TypedEventHandler^ IsUpperCaseEnabledChanged; + virtual event Windows::Foundation::TypedEventHandler^ IsUpperCaseEnabledChanged + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _IsUpperCaseEnabledChanged += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _IsUpperCaseEnabledChanged -= token; + } + internal: + void raise(SecureInterfaceConsumer^ sender, Platform::Object^ args) + { + _IsUpperCaseEnabledChanged(sender, args); + } + } // Get the value of the IsUpperCaseEnabled property. Windows::Foundation::IAsyncOperation^ GetIsUpperCaseEnabledAsync(); @@ -71,13 +91,70 @@ public ref class SecureInterfaceConsumer sealed : [Windows::Foundation::Metadat } // This event will fire whenever the consumer loses the session that it is a member of. - virtual event Windows::Foundation::TypedEventHandler^ SessionLost; + virtual event Windows::Foundation::TypedEventHandler^ SessionLost + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionLost += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionLost -= token; + } + internal: + void raise(SecureInterfaceConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionLostEventArgs^ args) + { + _SessionLost(sender, args); + } + } // This event will fire whenever a member joins the session. - virtual event Windows::Foundation::TypedEventHandler^ SessionMemberAdded; + virtual event Windows::Foundation::TypedEventHandler^ SessionMemberAdded + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionMemberAdded += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionMemberAdded -= token; + } + internal: + void raise(SecureInterfaceConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberAddedEventArgs^ args) + { + _SessionMemberAdded(sender, args); + } + } // This event will fire whenever a member leaves the session. - virtual event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved; + virtual event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionMemberRemoved += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionMemberRemoved -= token; + } + internal: + void raise(SecureInterfaceConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberRemovedEventArgs^ args) + { + _SessionMemberRemoved(sender, args); + } + } internal: // Consumers do not support property get. @@ -130,6 +207,11 @@ public ref class SecureInterfaceConsumer sealed : [Windows::Foundation::Metadat } private: + virtual event Windows::Foundation::EventHandler^ _SessionLost; + virtual event Windows::Foundation::EventHandler^ _SessionMemberAdded; + virtual event Windows::Foundation::EventHandler^ _SessionMemberRemoved; + virtual event Windows::Foundation::EventHandler^ _IsUpperCaseEnabledChanged; + int32 JoinSession(_In_ Windows::Devices::AllJoyn::AllJoynServiceInfo^ serviceInfo); // Register a callback function to handle incoming signals. diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h index 309f856e8b..bf5dc3c795 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h @@ -31,6 +31,8 @@ //----------------------------------------------------------------------------- #pragma once +using namespace concurrency; + namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { ref class SecureInterfaceConsumer; @@ -57,6 +59,7 @@ public ref class SecureInterfaceConcatenateResult sealed auto result = ref new SecureInterfaceConcatenateResult(); result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; result->OutStr = interfaceMemberOutStr; + result->m_creationContext = Concurrency::task_continuation_context::use_current(); return result; } @@ -66,6 +69,8 @@ public ref class SecureInterfaceConcatenateResult sealed result->Status = status; return result; } +internal: + Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); private: int32 m_status; @@ -116,6 +121,7 @@ public ref class SecureInterfaceGetIsUpperCaseEnabledResult sealed auto result = ref new SecureInterfaceGetIsUpperCaseEnabledResult(); result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; result->IsUpperCaseEnabled = value; + result->m_creationContext = Concurrency::task_continuation_context::use_current(); return result; } @@ -125,6 +131,8 @@ public ref class SecureInterfaceGetIsUpperCaseEnabledResult sealed result->Status = status; return result; } +internal: + Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); private: int32 m_status; @@ -145,6 +153,7 @@ public ref class SecureInterfaceSetIsUpperCaseEnabledResult sealed { auto result = ref new SecureInterfaceSetIsUpperCaseEnabledResult(); result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; + result->m_creationContext = Concurrency::task_continuation_context::use_current(); return result; } @@ -154,6 +163,8 @@ public ref class SecureInterfaceSetIsUpperCaseEnabledResult sealed result->Status = status; return result; } +internal: + Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); private: int32 m_status; diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.cpp index ca583b5871..1a62a25ee3 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.cpp +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.cpp @@ -67,13 +67,13 @@ void SecureInterfaceProducer::UnregisterFromBus() m_busAttachment->StateChanged -= m_busAttachmentStateChangedToken; m_busAttachmentStateChangedToken.Value = 0; } - if (nullptr != SessionPortListener) + if ((nullptr != m_busAttachment) && (nullptr != SessionPortListener)) { alljoyn_busattachment_unbindsessionport(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_sessionPort); alljoyn_sessionportlistener_destroy(SessionPortListener); SessionPortListener = nullptr; } - if (nullptr != BusObject) + if ((nullptr != m_busAttachment) && (nullptr != BusObject)) { alljoyn_busattachment_unregisterbusobject(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject); alljoyn_busobject_destroy(BusObject); @@ -119,9 +119,7 @@ void SecureInterfaceProducer::OnSessionLost(_In_ alljoyn_sessionid sessionId, _I if (sessionId == m_sessionId) { AllJoynSessionLostEventArgs^ args = ref new AllJoynSessionLostEventArgs(static_cast(reason)); - AllJoynHelpers::DispatchEvent([=]() { - SessionLost(this, args); - }); + SessionLost(this, args); } } @@ -130,9 +128,7 @@ void SecureInterfaceProducer::OnSessionMemberAdded(_In_ alljoyn_sessionid sessio if (sessionId == m_sessionId) { auto args = ref new AllJoynSessionMemberAddedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName)); - AllJoynHelpers::DispatchEvent([=]() { - SessionMemberAdded(this, args); - }); + SessionMemberAdded(this, args); } } @@ -141,9 +137,7 @@ void SecureInterfaceProducer::OnSessionMemberRemoved(_In_ alljoyn_sessionid sess if (sessionId == m_sessionId) { auto args = ref new AllJoynSessionMemberRemovedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName)); - AllJoynHelpers::DispatchEvent([=]() { - SessionMemberRemoved(this, args); - }); + SessionMemberRemoved(this, args); } } @@ -178,11 +172,12 @@ void SecureInterfaceProducer::CallConcatenateHandler(_Inout_ alljoyn_busobject b AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); Platform::String^ inputArg0; - TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &inputArg0); + (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &inputArg0); Platform::String^ inputArg1; - TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 1), "s", &inputArg1); + (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 1), "s", &inputArg1); - create_task(producer->Service->ConcatenateAsync(callInfo, inputArg0, inputArg1)).then([busObject, message](SecureInterfaceConcatenateResult^ result) + SecureInterfaceConcatenateResult^ result = create_task(producer->Service->ConcatenateAsync(callInfo, inputArg0, inputArg1)).get(); + create_task([](){}).then([=] { int32 status; @@ -212,7 +207,7 @@ void SecureInterfaceProducer::CallConcatenateHandler(_Inout_ alljoyn_busobject b alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount); alljoyn_msgarg_destroy(outputs); - }).wait(); + }, result->m_creationContext).wait(); } } @@ -232,7 +227,7 @@ void SecureInterfaceProducer::CallTextSentSignalHandler(_In_ const alljoyn_inter eventArgs->MessageInfo = callInfo; Platform::String^ argument0; - TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &argument0); + (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &argument0); eventArgs->Message = argument0; producer->Signals->CallTextSentReceived(producer->Signals, eventArgs); @@ -273,13 +268,15 @@ QStatus SecureInterfaceProducer::OnPropertyGet(_In_ PCSTR interfaceName, _In_ PC { auto task = create_task(Service->GetIsUpperCaseEnabledAsync(nullptr)); auto result = task.get(); - - if (AllJoynStatus::Ok != result->Status) - { - return static_cast(result->Status); - } - return static_cast(TypeConversionHelpers::SetAllJoynMessageArg(value, "b", result->IsUpperCaseEnabled)); + return create_task([](){}).then([=]() -> QStatus + { + if (AllJoynStatus::Ok != result->Status) + { + return static_cast(result->Status); + } + return static_cast(TypeConversionHelpers::SetAllJoynMessageArg(value, "b", result->IsUpperCaseEnabled)); + }, result->m_creationContext).get(); } return ER_BUS_NO_SUCH_PROPERTY; @@ -292,12 +289,14 @@ QStatus SecureInterfaceProducer::OnPropertySet(_In_ PCSTR interfaceName, _In_ PC if (0 == strcmp(propertyName, "IsUpperCaseEnabled")) { bool argument; - TypeConversionHelpers::GetAllJoynMessageArg(value, "b", &argument); - - auto task = create_task(Service->SetIsUpperCaseEnabledAsync(nullptr, argument)); - auto result = task.get(); - - return static_cast(result->Status); + QStatus status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(value, "b", &argument)); + if (ER_OK == status) + { + auto task = create_task(Service->SetIsUpperCaseEnabledAsync(nullptr, argument)); + auto result = task.get(); + status = static_cast(result->Status); + } + return status; } return ER_BUS_NO_SUCH_PROPERTY; } @@ -440,17 +439,17 @@ PCSTR com::microsoft::Samples::SecureInterface::c_SecureInterfaceIntrospectionXm " A secure AllJoyn sample" " " " " -" Method that concatenates two input strings and returns the concatenated string as output" +" Concatenate two input strings and returns the concatenated string as output" " " " " " " " " " " -" Property to determine if the output of the Concatenate method is returned as upper case string or not" +" Determine if the output of the Concatenate method is returned as upper case string or not" " " " " " " -" Signal to send a text message" +" This signal is emitted when producer sends a text message to consumer" " " " " "" diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h index c16af8d209..f654408453 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h @@ -65,16 +65,92 @@ public ref class SecureInterfaceProducer sealed : [Windows::Foundation::Metadata } // This event will fire whenever this producer is stopped. - virtual event Windows::Foundation::TypedEventHandler^ Stopped; + virtual event Windows::Foundation::TypedEventHandler^ Stopped + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _Stopped += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _Stopped -= token; + } + internal: + void raise(SecureInterfaceProducer^ sender, Windows::Devices::AllJoyn::AllJoynProducerStoppedEventArgs^ args) + { + _Stopped(sender, args); + } + } // This event will fire whenever the producer loses the session that it created. - virtual event Windows::Foundation::TypedEventHandler^ SessionLost; + virtual event Windows::Foundation::TypedEventHandler^ SessionLost + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionLost += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionLost -= token; + } + internal: + void raise(SecureInterfaceProducer^ sender, Windows::Devices::AllJoyn::AllJoynSessionLostEventArgs^ args) + { + _SessionLost(sender, args); + } + } // This event will fire whenever a member joins the session. - virtual event Windows::Foundation::TypedEventHandler^ SessionMemberAdded; + virtual event Windows::Foundation::TypedEventHandler^ SessionMemberAdded + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionMemberAdded += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionMemberAdded -= token; + } + internal: + void raise(SecureInterfaceProducer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberAddedEventArgs^ args) + { + _SessionMemberAdded(sender, args); + } + } // This event will fire whenever a member leaves the session. - virtual event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved; + virtual event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionMemberRemoved += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionMemberRemoved -= token; + } + internal: + void raise(SecureInterfaceProducer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberRemovedEventArgs^ args) + { + _SessionMemberRemoved(sender, args); + } + } // Send a signal to all members of the session to notify them that the value of IsUpperCaseEnabled has changed. void EmitIsUpperCaseEnabledChanged(); @@ -139,6 +215,11 @@ public ref class SecureInterfaceProducer sealed : [Windows::Foundation::Metadata void BusAttachmentStateChanged(_In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ sender, _In_ Windows::Devices::AllJoyn::AllJoynBusAttachmentStateChangedEventArgs^ args); private: + virtual event Windows::Foundation::EventHandler^ _Stopped; + virtual event Windows::Foundation::EventHandler^ _SessionLost; + virtual event Windows::Foundation::EventHandler^ _SessionMemberAdded; + virtual event Windows::Foundation::EventHandler^ _SessionMemberRemoved; + static void CallConcatenateHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message); static void CallTextSentSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message); diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp index e784c0ed05..c994e0e9b5 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp @@ -47,9 +47,7 @@ using namespace com::microsoft::Samples::SecureInterface; IAsyncOperation^ SecureInterfaceServiceEventAdapter::ConcatenateAsync(_In_ AllJoynMessageInfo^ info, _In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2) { auto args = ref new SecureInterfaceConcatenateCalledEventArgs(info, interfaceMemberInStr1, interfaceMemberInStr2); - AllJoynHelpers::DispatchEvent([=]() { - ConcatenateCalled(this, args); - }); + ConcatenateCalled(this, args); return SecureInterfaceConcatenateCalledEventArgs::GetResultAsync(args); } @@ -57,9 +55,7 @@ IAsyncOperation^ SecureInterfaceServiceEventA IAsyncOperation^ SecureInterfaceServiceEventAdapter::GetIsUpperCaseEnabledAsync(_In_ AllJoynMessageInfo^ info) { auto args = ref new SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs(info); - AllJoynHelpers::DispatchEvent([=]() { - GetIsUpperCaseEnabledRequested(this, args); - }); + GetIsUpperCaseEnabledRequested(this, args); return SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::GetResultAsync(args); } @@ -67,9 +63,7 @@ IAsyncOperation^ SecureInterfaceSer IAsyncOperation^ SecureInterfaceServiceEventAdapter::SetIsUpperCaseEnabledAsync(_In_ AllJoynMessageInfo^ info, _In_ bool value) { auto args = ref new SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs(info, value); - AllJoynHelpers::DispatchEvent([=]() { - SetIsUpperCaseEnabledRequested(this, args); - }); + SetIsUpperCaseEnabledRequested(this, args); return SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::GetResultAsync(args); } diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h index f7ea8ccf46..02b0ffe768 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h @@ -40,13 +40,70 @@ public ref class SecureInterfaceServiceEventAdapter sealed : [Windows::Foundatio { public: // Method Invocation Events - event Windows::Foundation::TypedEventHandler^ ConcatenateCalled; + event Windows::Foundation::TypedEventHandler^ ConcatenateCalled + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _ConcatenateCalled += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _ConcatenateCalled -= token; + } + internal: + void raise(SecureInterfaceServiceEventAdapter^ sender, SecureInterfaceConcatenateCalledEventArgs^ args) + { + _ConcatenateCalled(sender, args); + } + } // Property Read Events - event Windows::Foundation::TypedEventHandler^ GetIsUpperCaseEnabledRequested; - + event Windows::Foundation::TypedEventHandler^ GetIsUpperCaseEnabledRequested + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _GetIsUpperCaseEnabledRequested += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _GetIsUpperCaseEnabledRequested -= token; + } + internal: + void raise(SecureInterfaceServiceEventAdapter^ sender, SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs^ args) + { + _GetIsUpperCaseEnabledRequested(sender, args); + } + } + // Property Write Events - event Windows::Foundation::TypedEventHandler^ SetIsUpperCaseEnabledRequested; + event Windows::Foundation::TypedEventHandler^ SetIsUpperCaseEnabledRequested + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SetIsUpperCaseEnabledRequested += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SetIsUpperCaseEnabledRequested -= token; + } + internal: + void raise(SecureInterfaceServiceEventAdapter^ sender, SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs^ args) + { + _SetIsUpperCaseEnabledRequested(sender, args); + } + } // ISecureInterfaceService Implementation virtual Windows::Foundation::IAsyncOperation^ ConcatenateAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info, _In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2); @@ -54,6 +111,11 @@ public ref class SecureInterfaceServiceEventAdapter sealed : [Windows::Foundatio virtual Windows::Foundation::IAsyncOperation^ GetIsUpperCaseEnabledAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); virtual Windows::Foundation::IAsyncOperation^ SetIsUpperCaseEnabledAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info, _In_ bool value); + +private: + event Windows::Foundation::EventHandler^ _ConcatenateCalled; + event Windows::Foundation::EventHandler^ _GetIsUpperCaseEnabledRequested; + event Windows::Foundation::EventHandler^ _SetIsUpperCaseEnabledRequested; }; } } } } diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.cpp index 5f09fe837f..2d384de757 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.cpp +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.cpp @@ -51,7 +51,7 @@ SecureInterfaceConcatenateCalledEventArgs::SecureInterfaceConcatenateCalledEvent m_interfaceMemberInStr1(interfaceMemberInStr1), m_interfaceMemberInStr2(interfaceMemberInStr2) { - m_result = SecureInterfaceConcatenateResult::CreateFailureResult(ER_NOT_IMPLEMENTED); + m_result = SecureInterfaceConcatenateResult::CreateFailureResult(ER_NOT_IMPLEMENTED); } Deferral^ SecureInterfaceConcatenateCalledEventArgs::GetDeferral() @@ -127,7 +127,7 @@ SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::SecureInterfaceGetIsUppe m_completionsRequired(0), m_messageInfo(info) { - m_result = SecureInterfaceGetIsUpperCaseEnabledResult::CreateFailureResult(ER_NOT_IMPLEMENTED); + m_result = SecureInterfaceGetIsUpperCaseEnabledResult::CreateFailureResult(ER_NOT_IMPLEMENTED); } Deferral^ SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::GetDeferral() @@ -205,7 +205,7 @@ SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::SecureInterfaceSetIsUppe m_messageInfo(info), m_value(value) { - m_result = SecureInterfaceSetIsUpperCaseEnabledResult::CreateFailureResult(ER_NOT_IMPLEMENTED); + m_result = SecureInterfaceSetIsUpperCaseEnabledResult::CreateFailureResult(ER_NOT_IMPLEMENTED); } Deferral^ SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::GetDeferral() diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp index d21b092fde..e7176f385e 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp @@ -55,7 +55,7 @@ void SecureInterfaceSignals::TextSent(_In_ Platform::String^ interfaceMemberMess size_t argCount = 1; alljoyn_msgarg arguments = alljoyn_msgarg_array_create(argCount); - TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "s", interfaceMemberMessage); + (void)TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "s", interfaceMemberMessage); alljoyn_busobject_signal( m_busObject, @@ -73,8 +73,6 @@ void SecureInterfaceSignals::TextSent(_In_ Platform::String^ interfaceMemberMess void SecureInterfaceSignals::CallTextSentReceived(_In_ SecureInterfaceSignals^ sender, _In_ SecureInterfaceTextSentReceivedEventArgs^ args) { - AllJoynHelpers::DispatchEvent([=]() { - TextSentReceived(sender, args); - }); + TextSentReceived(sender, args); } diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h index 71abc5428e..0348f38430 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h @@ -47,7 +47,26 @@ public ref class SecureInterfaceSignals sealed : [Windows::Foundation::Metadata: void TextSent(_In_ Platform::String^ interfaceMemberMessage); // This event fires whenever the TextSent signal is sent by another member of the session. - virtual event Windows::Foundation::TypedEventHandler^ TextSentReceived; + virtual event Windows::Foundation::TypedEventHandler^ TextSentReceived + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _TextSentReceived += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _TextSentReceived -= token; + } + internal: + void raise(SecureInterfaceSignals^ sender, SecureInterfaceTextSentReceivedEventArgs^ args) + { + _TextSentReceived(sender, args); + } + } internal: void Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId); @@ -57,6 +76,8 @@ public ref class SecureInterfaceSignals sealed : [Windows::Foundation::Metadata: alljoyn_busobject m_busObject; alljoyn_sessionid m_sessionId; + virtual event Windows::Foundation::EventHandler^ _TextSentReceived; + alljoyn_interfacedescription_member m_memberTextSent; }; diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceWatcher.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceWatcher.h index 80aff081f6..6b416b1cdd 100644 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceWatcher.h +++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceWatcher.h @@ -48,10 +48,48 @@ public ref class SecureInterfaceWatcher sealed : [Windows::Foundation::Metadata: virtual ~SecureInterfaceWatcher(); // This event will fire whenever a producer for this service is found. - virtual event Windows::Foundation::TypedEventHandler^ Added; + virtual event Windows::Foundation::TypedEventHandler^ Added + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _Added += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _Added -= token; + } + internal: + void raise(SecureInterfaceWatcher^ sender, Windows::Devices::AllJoyn::AllJoynServiceInfo^ args) + { + _Added(sender, args); + } + } // This event will fire whenever the watcher is stopped. - virtual event Windows::Foundation::TypedEventHandler^ Stopped; + virtual event Windows::Foundation::TypedEventHandler^ Stopped + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _Stopped += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _Stopped -= token; + } + internal: + void raise(SecureInterfaceWatcher^ sender, Windows::Devices::AllJoyn::AllJoynProducerStoppedEventArgs^ args) + { + _Stopped(sender, args); + } + } // Start watching for producers advertising this service. void Start(); @@ -83,6 +121,9 @@ public ref class SecureInterfaceWatcher sealed : [Windows::Foundation::Metadata: void BusAttachmentStateChanged(_In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ sender, _In_ Windows::Devices::AllJoyn::AllJoynBusAttachmentStateChangedEventArgs^ args); private: + virtual event Windows::Foundation::EventHandler^ _Added; + virtual event Windows::Foundation::EventHandler^ _Stopped; + void UnregisterFromBus(); Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment; diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h index 70419c155a..02e94b81a8 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h @@ -37,16 +37,16 @@ public interface class IOnboardingService { public: // Implement this function to handle calls to the ConfigureWiFi method. - Windows::Foundation::IAsyncOperation^ ConfigureWiFiAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info , _In_ Platform::String^ interfaceMemberSSID, _In_ Platform::String^ interfaceMemberPassphrase, _In_ int16 interfaceMemberAuthType); + Windows::Foundation::IAsyncOperation^ ConfigureWiFiAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info , _In_ Platform::String^ interfaceMemberSSID, _In_ Platform::String^ interfaceMemberPassphrase, _In_ int16 interfaceMemberAuthType); // Implement this function to handle calls to the Connect method. - Windows::Foundation::IAsyncOperation^ ConnectAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info ); + Windows::Foundation::IAsyncOperation^ ConnectAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info ); // Implement this function to handle calls to the Offboard method. - Windows::Foundation::IAsyncOperation^ OffboardAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info ); + Windows::Foundation::IAsyncOperation^ OffboardAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info ); // Implement this function to handle calls to the GetScanInfo method. - Windows::Foundation::IAsyncOperation^ GetScanInfoAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info ); + Windows::Foundation::IAsyncOperation^ GetScanInfoAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info ); // Implement this function to handle requests for the value of the Version property. // diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp index 41ce62edae..70561a11c3 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp @@ -111,12 +111,8 @@ IAsyncOperation^ OnboardingConsumer::JoinSessionAs return create_async([serviceInfo, watcher]() -> OnboardingJoinSessionResult^ { auto result = ref new OnboardingJoinSessionResult(); - result->Status = AllJoynStatus::Ok; - result->Consumer = nullptr; - result->Consumer = ref new OnboardingConsumer(watcher->BusAttachment); result->Status = result->Consumer->JoinSession(serviceInfo); - return result; }); } @@ -131,19 +127,31 @@ IAsyncOperation^ OnboardingConsumer::ConfigureWi size_t argCount = 3; alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount); - TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 0), "s", interfaceMemberSSID); - TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 1), "s", interfaceMemberPassphrase); - TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 2), "n", interfaceMemberAuthType); - - QStatus status = alljoyn_proxybusobject_methodcall( - ProxyBusObject, - "org.alljoyn.Onboarding", - "ConfigureWiFi", - inputs, - argCount, - message, - c_MessageTimeoutInMilliseconds, - 0); + QStatus status = ER_OK; + status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 0), "s", interfaceMemberSSID)); + + if (ER_OK == status) + { + status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 1), "s", interfaceMemberPassphrase)); + } + + if (ER_OK == status) + { + status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 2), "n", interfaceMemberAuthType)); + } + + if (ER_OK == status) + { + status = alljoyn_proxybusobject_methodcall( + ProxyBusObject, + "org.alljoyn.Onboarding", + "ConfigureWiFi", + inputs, + argCount, + message, + c_MessageTimeoutInMilliseconds, + 0); + } result->Status = static_cast(status); if (ER_OK == status) { @@ -152,7 +160,7 @@ IAsyncOperation^ OnboardingConsumer::ConfigureWi status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "n", &argument0)); result->Status2 = argument0; - if (status != ER_OK) + if (ER_OK != status) { result->Status = static_cast(status); } @@ -188,16 +196,19 @@ IAsyncOperation^ OnboardingConsumer::ConnectAsync() size_t argCount = 0; alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount); - - QStatus status = alljoyn_proxybusobject_methodcall( - ProxyBusObject, - "org.alljoyn.Onboarding", - "Connect", - inputs, - argCount, - message, - c_MessageTimeoutInMilliseconds, - 0); + QStatus status = ER_OK; + if (ER_OK == status) + { + status = alljoyn_proxybusobject_methodcall( + ProxyBusObject, + "org.alljoyn.Onboarding", + "Connect", + inputs, + argCount, + message, + c_MessageTimeoutInMilliseconds, + 0); + } result->Status = static_cast(status); alljoyn_message_destroy(message); @@ -216,16 +227,19 @@ IAsyncOperation^ OnboardingConsumer::OffboardAsync() size_t argCount = 0; alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount); - - QStatus status = alljoyn_proxybusobject_methodcall( - ProxyBusObject, - "org.alljoyn.Onboarding", - "Offboard", - inputs, - argCount, - message, - c_MessageTimeoutInMilliseconds, - 0); + QStatus status = ER_OK; + if (ER_OK == status) + { + status = alljoyn_proxybusobject_methodcall( + ProxyBusObject, + "org.alljoyn.Onboarding", + "Offboard", + inputs, + argCount, + message, + c_MessageTimeoutInMilliseconds, + 0); + } result->Status = static_cast(status); alljoyn_message_destroy(message); @@ -244,16 +258,19 @@ IAsyncOperation^ OnboardingConsumer::GetScanInfoAs size_t argCount = 0; alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount); - - QStatus status = alljoyn_proxybusobject_methodcall( - ProxyBusObject, - "org.alljoyn.Onboarding", - "GetScanInfo", - inputs, - argCount, - message, - c_MessageTimeoutInMilliseconds, - 0); + QStatus status = ER_OK; + if (ER_OK == status) + { + status = alljoyn_proxybusobject_methodcall( + ProxyBusObject, + "org.alljoyn.Onboarding", + "GetScanInfo", + inputs, + argCount, + message, + c_MessageTimeoutInMilliseconds, + 0); + } result->Status = static_cast(status); if (ER_OK == status) { @@ -262,7 +279,7 @@ IAsyncOperation^ OnboardingConsumer::GetScanInfoAs status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "q", &argument0)); result->Age = argument0; - if (status != ER_OK) + if (ER_OK != status) { result->Status = static_cast(status); } @@ -270,7 +287,7 @@ IAsyncOperation^ OnboardingConsumer::GetScanInfoAs status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 1), "a(sn)", &argument1)); result->ScanList = argument1; - if (status != ER_OK) + if (ER_OK != status) { result->Status = static_cast(status); } @@ -315,7 +332,7 @@ IAsyncOperation^ OnboardingConsumer::GetVersionAsyn if (ER_OK == status) { uint16 argument; - TypeConversionHelpers::GetAllJoynMessageArg(value, "q", &argument); + status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(value, "q", &argument)); propertyContext->SetValue(argument); } @@ -352,7 +369,7 @@ IAsyncOperation^ OnboardingConsumer::GetStateAsync() if (ER_OK == status) { int16 argument; - TypeConversionHelpers::GetAllJoynMessageArg(value, "n", &argument); + status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(value, "n", &argument)); propertyContext->SetValue(argument); } @@ -389,7 +406,7 @@ IAsyncOperation^ OnboardingConsumer::GetLastError if (ER_OK == status) { OnboardingLastError^ argument; - TypeConversionHelpers::GetAllJoynMessageArg(value, "(ns)", &argument); + status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(value, "(ns)", &argument)); propertyContext->SetValue(argument); } @@ -432,7 +449,7 @@ void OnboardingConsumer::CallConnectionResultSignalHandler(_In_ const alljoyn_in eventArgs->MessageInfo = callInfo; Onboarding^ argument0; - TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "(ns)", &argument0); + (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "(ns)", &argument0); eventArgs->Arg = argument0; @@ -485,6 +502,25 @@ int32 OnboardingConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo) return AllJoynStatus::Fail; } + RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::GetBusObject(m_nativeBusAttachment, AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath).data(), &m_busObject)); + + if (!AllJoynBusObjectManager::BusObjectIsRegistered(m_nativeBusAttachment, m_busObject)) + { + RETURN_IF_QSTATUS_ERROR(alljoyn_busobject_addinterface(BusObject, description)); + } + + QStatus result = AddSignalHandler( + m_nativeBusAttachment, + description, + "ConnectionResult", + [](const alljoyn_interfacedescription_member* member, PCSTR srcPath, alljoyn_message message) { UNREFERENCED_PARAMETER(srcPath); CallConnectionResultSignalHandler(member, message); }); + if (ER_OK != result) + { + return static_cast(result); + } + + SourceInterfaces[description] = m_weak; + unsigned int noneMechanismIndex = 0; bool authenticationMechanismsContainsNone = m_busAttachment->AuthenticationMechanisms->IndexOf(AllJoynAuthenticationMechanism::None, &noneMechanismIndex); QCC_BOOL interfaceIsSecure = alljoyn_interfacedescription_issecure(description); @@ -497,7 +533,12 @@ int32 OnboardingConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo) // is specified, or if None is not present in AuthenticationMechanisms. if (!authenticationMechanismsContainsNone || interfaceIsSecure) { - alljoyn_proxybusobject_secureconnection(ProxyBusObject, QCC_FALSE); + RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_secureconnection(ProxyBusObject, QCC_FALSE)); + RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, true)); + } + else + { + RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, false)); } } else @@ -508,28 +549,14 @@ int32 OnboardingConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo) { return static_cast(ER_BUS_NO_AUTHENTICATION_MECHANISM); } + else + { + RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, false)); + } } - RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::GetBusObject(m_nativeBusAttachment, AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath).data(), &m_busObject)); RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_addinterface(ProxyBusObject, description)); - - if (!AllJoynBusObjectManager::BusObjectIsRegistered(m_nativeBusAttachment, m_busObject)) - { - RETURN_IF_QSTATUS_ERROR(alljoyn_busobject_addinterface(BusObject, description)); - } - - QStatus result = AddSignalHandler( - m_nativeBusAttachment, - description, - "ConnectionResult", - [](const alljoyn_interfacedescription_member* member, PCSTR srcPath, alljoyn_message message) { UNREFERENCED_PARAMETER(srcPath); CallConnectionResultSignalHandler(member, message); }); - if (result != ER_OK) - { - return static_cast(result); - } - - SourceInterfaces[description] = m_weak; - RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, true)); + m_signals->Initialize(BusObject, m_sessionId); return AllJoynStatus::Ok; diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h index abcfb9a75a..8fd9f26d94 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h @@ -60,6 +60,7 @@ public ref class OnboardingConsumer sealed : [Windows::Foundation::Metadata::De Windows::Foundation::IAsyncOperation^ OffboardAsync(); // Call the GetScanInfo method Windows::Foundation::IAsyncOperation^ GetScanInfoAsync(); + // Get the value of the Version property. Windows::Foundation::IAsyncOperation^ GetVersionAsync(); @@ -77,13 +78,70 @@ public ref class OnboardingConsumer sealed : [Windows::Foundation::Metadata::De } // This event will fire whenever the consumer loses the session that it is a member of. - virtual event Windows::Foundation::TypedEventHandler^ SessionLost; + virtual event Windows::Foundation::TypedEventHandler^ SessionLost + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionLost += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionLost -= token; + } + internal: + void raise(OnboardingConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionLostEventArgs^ args) + { + _SessionLost(sender, args); + } + } // This event will fire whenever a member joins the session. - virtual event Windows::Foundation::TypedEventHandler^ SessionMemberAdded; + virtual event Windows::Foundation::TypedEventHandler^ SessionMemberAdded + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionMemberAdded += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionMemberAdded -= token; + } + internal: + void raise(OnboardingConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberAddedEventArgs^ args) + { + _SessionMemberAdded(sender, args); + } + } // This event will fire whenever a member leaves the session. - virtual event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved; + virtual event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionMemberRemoved += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionMemberRemoved -= token; + } + internal: + void raise(OnboardingConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberRemovedEventArgs^ args) + { + _SessionMemberRemoved(sender, args); + } + } internal: // Consumers do not support property get. @@ -136,6 +194,10 @@ public ref class OnboardingConsumer sealed : [Windows::Foundation::Metadata::De } private: + virtual event Windows::Foundation::EventHandler^ _SessionLost; + virtual event Windows::Foundation::EventHandler^ _SessionMemberAdded; + virtual event Windows::Foundation::EventHandler^ _SessionMemberRemoved; + int32 JoinSession(_In_ Windows::Devices::AllJoyn::AllJoynServiceInfo^ serviceInfo); // Register a callback function to handle incoming signals. diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h index 4b710c1bc5..1ac2a3f63b 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h @@ -31,6 +31,8 @@ //----------------------------------------------------------------------------- #pragma once +using namespace concurrency; + namespace org { namespace alljoyn { namespace Onboarding { ref class OnboardingConsumer; @@ -57,6 +59,7 @@ public ref class OnboardingConfigureWiFiResult sealed auto result = ref new OnboardingConfigureWiFiResult(); result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; result->Status2 = interfaceMemberStatus2; + result->m_creationContext = Concurrency::task_continuation_context::use_current(); return result; } @@ -66,6 +69,8 @@ public ref class OnboardingConfigureWiFiResult sealed result->Status = status; return result; } +internal: + Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); private: int32 m_status; @@ -87,6 +92,7 @@ public ref class OnboardingConnectResult sealed { auto result = ref new OnboardingConnectResult(); result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; + result->m_creationContext = Concurrency::task_continuation_context::use_current(); return result; } @@ -96,6 +102,8 @@ public ref class OnboardingConnectResult sealed result->Status = status; return result; } +internal: + Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); private: int32 m_status; @@ -116,6 +124,7 @@ public ref class OnboardingOffboardResult sealed { auto result = ref new OnboardingOffboardResult(); result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; + result->m_creationContext = Concurrency::task_continuation_context::use_current(); return result; } @@ -125,6 +134,8 @@ public ref class OnboardingOffboardResult sealed result->Status = status; return result; } +internal: + Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); private: int32 m_status; @@ -159,6 +170,7 @@ public ref class OnboardingGetScanInfoResult sealed result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; result->Age = interfaceMemberAge; result->ScanList = interfaceMemberScanList; + result->m_creationContext = Concurrency::task_continuation_context::use_current(); return result; } @@ -168,6 +180,8 @@ public ref class OnboardingGetScanInfoResult sealed result->Status = status; return result; } +internal: + Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); private: int32 m_status; @@ -219,6 +233,7 @@ public ref class OnboardingGetVersionResult sealed auto result = ref new OnboardingGetVersionResult(); result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; result->Version = value; + result->m_creationContext = Concurrency::task_continuation_context::use_current(); return result; } @@ -228,6 +243,8 @@ public ref class OnboardingGetVersionResult sealed result->Status = status; return result; } +internal: + Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); private: int32 m_status; @@ -256,6 +273,7 @@ public ref class OnboardingGetStateResult sealed auto result = ref new OnboardingGetStateResult(); result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; result->State = value; + result->m_creationContext = Concurrency::task_continuation_context::use_current(); return result; } @@ -265,6 +283,8 @@ public ref class OnboardingGetStateResult sealed result->Status = status; return result; } +internal: + Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); private: int32 m_status; @@ -293,6 +313,7 @@ public ref class OnboardingGetLastErrorResult sealed auto result = ref new OnboardingGetLastErrorResult(); result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; result->LastError = value; + result->m_creationContext = Concurrency::task_continuation_context::use_current(); return result; } @@ -302,6 +323,8 @@ public ref class OnboardingGetLastErrorResult sealed result->Status = status; return result; } +internal: + Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); private: int32 m_status; diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp index 4846c7e0be..29efb5785c 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp @@ -67,13 +67,13 @@ void OnboardingProducer::UnregisterFromBus() m_busAttachment->StateChanged -= m_busAttachmentStateChangedToken; m_busAttachmentStateChangedToken.Value = 0; } - if (nullptr != SessionPortListener) + if ((nullptr != m_busAttachment) && (nullptr != SessionPortListener)) { alljoyn_busattachment_unbindsessionport(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_sessionPort); alljoyn_sessionportlistener_destroy(SessionPortListener); SessionPortListener = nullptr; } - if (nullptr != BusObject) + if ((nullptr != m_busAttachment) && (nullptr != BusObject)) { alljoyn_busattachment_unregisterbusobject(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject); alljoyn_busobject_destroy(BusObject); @@ -119,9 +119,7 @@ void OnboardingProducer::OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ al if (sessionId == m_sessionId) { AllJoynSessionLostEventArgs^ args = ref new AllJoynSessionLostEventArgs(static_cast(reason)); - AllJoynHelpers::DispatchEvent([=]() { - SessionLost(this, args); - }); + SessionLost(this, args); } } @@ -130,9 +128,7 @@ void OnboardingProducer::OnSessionMemberAdded(_In_ alljoyn_sessionid sessionId, if (sessionId == m_sessionId) { auto args = ref new AllJoynSessionMemberAddedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName)); - AllJoynHelpers::DispatchEvent([=]() { - SessionMemberAdded(this, args); - }); + SessionMemberAdded(this, args); } } @@ -141,9 +137,7 @@ void OnboardingProducer::OnSessionMemberRemoved(_In_ alljoyn_sessionid sessionId if (sessionId == m_sessionId) { auto args = ref new AllJoynSessionMemberRemovedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName)); - AllJoynHelpers::DispatchEvent([=]() { - SessionMemberRemoved(this, args); - }); + SessionMemberRemoved(this, args); } } @@ -178,13 +172,14 @@ void OnboardingProducer::CallConfigureWiFiHandler(_Inout_ alljoyn_busobject busO AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); Platform::String^ inputArg0; - TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &inputArg0); + (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &inputArg0); Platform::String^ inputArg1; - TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 1), "s", &inputArg1); + (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 1), "s", &inputArg1); int16 inputArg2; - TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 2), "n", &inputArg2); + (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 2), "n", &inputArg2); - create_task(producer->Service->ConfigureWiFiAsync(callInfo, inputArg0, inputArg1, inputArg2)).then([busObject, message](OnboardingConfigureWiFiResult^ result) + OnboardingConfigureWiFiResult^ result = create_task(producer->Service->ConfigureWiFiAsync(callInfo, inputArg0, inputArg1, inputArg2)).get(); + create_task([](){}).then([=] { int32 status; @@ -214,7 +209,7 @@ void OnboardingProducer::CallConfigureWiFiHandler(_Inout_ alljoyn_busobject busO alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount); alljoyn_msgarg_destroy(outputs); - }).wait(); + }, result->m_creationContext).wait(); } } @@ -232,7 +227,8 @@ void OnboardingProducer::CallConnectHandler(_Inout_ alljoyn_busobject busObject, AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - create_task(producer->Service->ConnectAsync(callInfo)).then([busObject, message](OnboardingConnectResult^ result) + OnboardingConnectResult^ result = create_task(producer->Service->ConnectAsync(callInfo)).get(); + create_task([](){}).then([=] { int32 status; @@ -254,7 +250,7 @@ void OnboardingProducer::CallConnectHandler(_Inout_ alljoyn_busobject busObject, alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount); alljoyn_msgarg_destroy(outputs); - }).wait(); + }, result->m_creationContext).wait(); } } @@ -272,7 +268,8 @@ void OnboardingProducer::CallOffboardHandler(_Inout_ alljoyn_busobject busObject AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - create_task(producer->Service->OffboardAsync(callInfo)).then([busObject, message](OnboardingOffboardResult^ result) + OnboardingOffboardResult^ result = create_task(producer->Service->OffboardAsync(callInfo)).get(); + create_task([](){}).then([=] { int32 status; @@ -294,7 +291,7 @@ void OnboardingProducer::CallOffboardHandler(_Inout_ alljoyn_busobject busObject alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount); alljoyn_msgarg_destroy(outputs); - }).wait(); + }, result->m_creationContext).wait(); } } @@ -312,7 +309,8 @@ void OnboardingProducer::CallGetScanInfoHandler(_Inout_ alljoyn_busobject busObj AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - create_task(producer->Service->GetScanInfoAsync(callInfo)).then([busObject, message](OnboardingGetScanInfoResult^ result) + OnboardingGetScanInfoResult^ result = create_task(producer->Service->GetScanInfoAsync(callInfo)).get(); + create_task([](){}).then([=] { int32 status; @@ -350,7 +348,7 @@ void OnboardingProducer::CallGetScanInfoHandler(_Inout_ alljoyn_busobject busObj alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount); alljoyn_msgarg_destroy(outputs); - }).wait(); + }, result->m_creationContext).wait(); } } @@ -370,7 +368,7 @@ void OnboardingProducer::CallConnectionResultSignalHandler(_In_ const alljoyn_in eventArgs->MessageInfo = callInfo; Onboarding^ argument0; - TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "(ns)", &argument0); + (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "(ns)", &argument0); eventArgs->Arg = argument0; producer->Signals->CallConnectionResultReceived(producer->Signals, eventArgs); @@ -411,37 +409,43 @@ QStatus OnboardingProducer::OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR p { auto task = create_task(Service->GetVersionAsync(nullptr)); auto result = task.get(); - - if (AllJoynStatus::Ok != result->Status) - { - return static_cast(result->Status); - } - return static_cast(TypeConversionHelpers::SetAllJoynMessageArg(value, "q", result->Version)); + return create_task([](){}).then([=]() -> QStatus + { + if (AllJoynStatus::Ok != result->Status) + { + return static_cast(result->Status); + } + return static_cast(TypeConversionHelpers::SetAllJoynMessageArg(value, "q", result->Version)); + }, result->m_creationContext).get(); } if (0 == strcmp(propertyName, "State")) { auto task = create_task(Service->GetStateAsync(nullptr)); auto result = task.get(); - - if (AllJoynStatus::Ok != result->Status) - { - return static_cast(result->Status); - } - return static_cast(TypeConversionHelpers::SetAllJoynMessageArg(value, "n", result->State)); + return create_task([](){}).then([=]() -> QStatus + { + if (AllJoynStatus::Ok != result->Status) + { + return static_cast(result->Status); + } + return static_cast(TypeConversionHelpers::SetAllJoynMessageArg(value, "n", result->State)); + }, result->m_creationContext).get(); } if (0 == strcmp(propertyName, "LastError")) { auto task = create_task(Service->GetLastErrorAsync(nullptr)); auto result = task.get(); - - if (AllJoynStatus::Ok != result->Status) - { - return static_cast(result->Status); - } - return static_cast(TypeConversionHelpers::SetAllJoynMessageArg(value, "(ns)", result->LastError)); + return create_task([](){}).then([=]() -> QStatus + { + if (AllJoynStatus::Ok != result->Status) + { + return static_cast(result->Status); + } + return static_cast(TypeConversionHelpers::SetAllJoynMessageArg(value, "(ns)", result->LastError)); + }, result->m_creationContext).get(); } return ER_BUS_NO_SUCH_PROPERTY; diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h index 2ed07f74ce..7a3129c594 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h @@ -65,16 +65,92 @@ public ref class OnboardingProducer sealed : [Windows::Foundation::Metadata::Def } // This event will fire whenever this producer is stopped. - virtual event Windows::Foundation::TypedEventHandler^ Stopped; + virtual event Windows::Foundation::TypedEventHandler^ Stopped + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _Stopped += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _Stopped -= token; + } + internal: + void raise(OnboardingProducer^ sender, Windows::Devices::AllJoyn::AllJoynProducerStoppedEventArgs^ args) + { + _Stopped(sender, args); + } + } // This event will fire whenever the producer loses the session that it created. - virtual event Windows::Foundation::TypedEventHandler^ SessionLost; + virtual event Windows::Foundation::TypedEventHandler^ SessionLost + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionLost += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionLost -= token; + } + internal: + void raise(OnboardingProducer^ sender, Windows::Devices::AllJoyn::AllJoynSessionLostEventArgs^ args) + { + _SessionLost(sender, args); + } + } // This event will fire whenever a member joins the session. - virtual event Windows::Foundation::TypedEventHandler^ SessionMemberAdded; + virtual event Windows::Foundation::TypedEventHandler^ SessionMemberAdded + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionMemberAdded += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionMemberAdded -= token; + } + internal: + void raise(OnboardingProducer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberAddedEventArgs^ args) + { + _SessionMemberAdded(sender, args); + } + } // This event will fire whenever a member leaves the session. - virtual event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved; + virtual event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _SessionMemberRemoved += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _SessionMemberRemoved -= token; + } + internal: + void raise(OnboardingProducer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberRemovedEventArgs^ args) + { + _SessionMemberRemoved(sender, args); + } + } // Start advertising the service. void Start(); @@ -136,6 +212,11 @@ public ref class OnboardingProducer sealed : [Windows::Foundation::Metadata::Def void BusAttachmentStateChanged(_In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ sender, _In_ Windows::Devices::AllJoyn::AllJoynBusAttachmentStateChangedEventArgs^ args); private: + virtual event Windows::Foundation::EventHandler^ _Stopped; + virtual event Windows::Foundation::EventHandler^ _SessionLost; + virtual event Windows::Foundation::EventHandler^ _SessionMemberAdded; + virtual event Windows::Foundation::EventHandler^ _SessionMemberRemoved; + static void CallConfigureWiFiHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message); static void CallConnectHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message); static void CallOffboardHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message); diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp index 326ef44a3f..abdc80b635 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp @@ -47,36 +47,28 @@ using namespace org::alljoyn::Onboarding; IAsyncOperation^ OnboardingServiceEventAdapter::ConfigureWiFiAsync(_In_ AllJoynMessageInfo^ info, _In_ Platform::String^ interfaceMemberSSID, _In_ Platform::String^ interfaceMemberPassphrase, _In_ int16 interfaceMemberAuthType) { auto args = ref new OnboardingConfigureWiFiCalledEventArgs(info, interfaceMemberSSID, interfaceMemberPassphrase, interfaceMemberAuthType); - AllJoynHelpers::DispatchEvent([=]() { - ConfigureWiFiCalled(this, args); - }); + ConfigureWiFiCalled(this, args); return OnboardingConfigureWiFiCalledEventArgs::GetResultAsync(args); } IAsyncOperation^ OnboardingServiceEventAdapter::ConnectAsync(_In_ AllJoynMessageInfo^ info) { auto args = ref new OnboardingConnectCalledEventArgs(info); - AllJoynHelpers::DispatchEvent([=]() { - ConnectCalled(this, args); - }); + ConnectCalled(this, args); return OnboardingConnectCalledEventArgs::GetResultAsync(args); } IAsyncOperation^ OnboardingServiceEventAdapter::OffboardAsync(_In_ AllJoynMessageInfo^ info) { auto args = ref new OnboardingOffboardCalledEventArgs(info); - AllJoynHelpers::DispatchEvent([=]() { - OffboardCalled(this, args); - }); + OffboardCalled(this, args); return OnboardingOffboardCalledEventArgs::GetResultAsync(args); } IAsyncOperation^ OnboardingServiceEventAdapter::GetScanInfoAsync(_In_ AllJoynMessageInfo^ info) { auto args = ref new OnboardingGetScanInfoCalledEventArgs(info); - AllJoynHelpers::DispatchEvent([=]() { - GetScanInfoCalled(this, args); - }); + GetScanInfoCalled(this, args); return OnboardingGetScanInfoCalledEventArgs::GetResultAsync(args); } @@ -84,27 +76,21 @@ IAsyncOperation^ OnboardingServiceEventAdapter::Ge IAsyncOperation^ OnboardingServiceEventAdapter::GetVersionAsync(_In_ AllJoynMessageInfo^ info) { auto args = ref new OnboardingGetVersionRequestedEventArgs(info); - AllJoynHelpers::DispatchEvent([=]() { - GetVersionRequested(this, args); - }); + GetVersionRequested(this, args); return OnboardingGetVersionRequestedEventArgs::GetResultAsync(args); } IAsyncOperation^ OnboardingServiceEventAdapter::GetStateAsync(_In_ AllJoynMessageInfo^ info) { auto args = ref new OnboardingGetStateRequestedEventArgs(info); - AllJoynHelpers::DispatchEvent([=]() { - GetStateRequested(this, args); - }); + GetStateRequested(this, args); return OnboardingGetStateRequestedEventArgs::GetResultAsync(args); } IAsyncOperation^ OnboardingServiceEventAdapter::GetLastErrorAsync(_In_ AllJoynMessageInfo^ info) { auto args = ref new OnboardingGetLastErrorRequestedEventArgs(info); - AllJoynHelpers::DispatchEvent([=]() { - GetLastErrorRequested(this, args); - }); + GetLastErrorRequested(this, args); return OnboardingGetLastErrorRequestedEventArgs::GetResultAsync(args); } diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h index 2e69913a95..b9fcff51e7 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h @@ -40,18 +40,155 @@ public ref class OnboardingServiceEventAdapter sealed : [Windows::Foundation::Me { public: // Method Invocation Events - event Windows::Foundation::TypedEventHandler^ ConfigureWiFiCalled; - event Windows::Foundation::TypedEventHandler^ ConnectCalled; - event Windows::Foundation::TypedEventHandler^ OffboardCalled; - event Windows::Foundation::TypedEventHandler^ GetScanInfoCalled; + event Windows::Foundation::TypedEventHandler^ ConfigureWiFiCalled + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _ConfigureWiFiCalled += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _ConfigureWiFiCalled -= token; + } + internal: + void raise(OnboardingServiceEventAdapter^ sender, OnboardingConfigureWiFiCalledEventArgs^ args) + { + _ConfigureWiFiCalled(sender, args); + } + } + + event Windows::Foundation::TypedEventHandler^ ConnectCalled + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _ConnectCalled += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _ConnectCalled -= token; + } + internal: + void raise(OnboardingServiceEventAdapter^ sender, OnboardingConnectCalledEventArgs^ args) + { + _ConnectCalled(sender, args); + } + } + + event Windows::Foundation::TypedEventHandler^ OffboardCalled + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _OffboardCalled += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _OffboardCalled -= token; + } + internal: + void raise(OnboardingServiceEventAdapter^ sender, OnboardingOffboardCalledEventArgs^ args) + { + _OffboardCalled(sender, args); + } + } + + event Windows::Foundation::TypedEventHandler^ GetScanInfoCalled + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _GetScanInfoCalled += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _GetScanInfoCalled -= token; + } + internal: + void raise(OnboardingServiceEventAdapter^ sender, OnboardingGetScanInfoCalledEventArgs^ args) + { + _GetScanInfoCalled(sender, args); + } + } // Property Read Events - event Windows::Foundation::TypedEventHandler^ GetVersionRequested; - event Windows::Foundation::TypedEventHandler^ GetStateRequested; - event Windows::Foundation::TypedEventHandler^ GetLastErrorRequested; - - // Property Write Events + event Windows::Foundation::TypedEventHandler^ GetVersionRequested + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _GetVersionRequested += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _GetVersionRequested -= token; + } + internal: + void raise(OnboardingServiceEventAdapter^ sender, OnboardingGetVersionRequestedEventArgs^ args) + { + _GetVersionRequested(sender, args); + } + } + event Windows::Foundation::TypedEventHandler^ GetStateRequested + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _GetStateRequested += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _GetStateRequested -= token; + } + internal: + void raise(OnboardingServiceEventAdapter^ sender, OnboardingGetStateRequestedEventArgs^ args) + { + _GetStateRequested(sender, args); + } + } + + event Windows::Foundation::TypedEventHandler^ GetLastErrorRequested + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _GetLastErrorRequested += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _GetLastErrorRequested -= token; + } + internal: + void raise(OnboardingServiceEventAdapter^ sender, OnboardingGetLastErrorRequestedEventArgs^ args) + { + _GetLastErrorRequested(sender, args); + } + } + + // Property Write Events // IOnboardingService Implementation virtual Windows::Foundation::IAsyncOperation^ ConfigureWiFiAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info, _In_ Platform::String^ interfaceMemberSSID, _In_ Platform::String^ interfaceMemberPassphrase, _In_ int16 interfaceMemberAuthType); virtual Windows::Foundation::IAsyncOperation^ ConnectAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); @@ -62,6 +199,15 @@ public ref class OnboardingServiceEventAdapter sealed : [Windows::Foundation::Me virtual Windows::Foundation::IAsyncOperation^ GetStateAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); virtual Windows::Foundation::IAsyncOperation^ GetLastErrorAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); + +private: + event Windows::Foundation::EventHandler^ _ConfigureWiFiCalled; + event Windows::Foundation::EventHandler^ _ConnectCalled; + event Windows::Foundation::EventHandler^ _OffboardCalled; + event Windows::Foundation::EventHandler^ _GetScanInfoCalled; + event Windows::Foundation::EventHandler^ _GetVersionRequested; + event Windows::Foundation::EventHandler^ _GetStateRequested; + event Windows::Foundation::EventHandler^ _GetLastErrorRequested; }; } } } diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.cpp index 38dabbf887..19e7b05b6f 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.cpp +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.cpp @@ -53,7 +53,7 @@ OnboardingConfigureWiFiCalledEventArgs::OnboardingConfigureWiFiCalledEventArgs( m_interfaceMemberPassphrase(interfaceMemberPassphrase), m_interfaceMemberAuthType(interfaceMemberAuthType) { - m_result = OnboardingConfigureWiFiResult::CreateFailureResult(ER_NOT_IMPLEMENTED); + m_result = OnboardingConfigureWiFiResult::CreateFailureResult(ER_NOT_IMPLEMENTED); } Deferral^ OnboardingConfigureWiFiCalledEventArgs::GetDeferral() @@ -128,7 +128,7 @@ OnboardingConnectCalledEventArgs::OnboardingConnectCalledEventArgs( m_completionsRequired(0), m_messageInfo(info) { - m_result = OnboardingConnectResult::CreateFailureResult(ER_NOT_IMPLEMENTED); + m_result = OnboardingConnectResult::CreateFailureResult(ER_NOT_IMPLEMENTED); } Deferral^ OnboardingConnectCalledEventArgs::GetDeferral() @@ -203,7 +203,7 @@ OnboardingOffboardCalledEventArgs::OnboardingOffboardCalledEventArgs( m_completionsRequired(0), m_messageInfo(info) { - m_result = OnboardingOffboardResult::CreateFailureResult(ER_NOT_IMPLEMENTED); + m_result = OnboardingOffboardResult::CreateFailureResult(ER_NOT_IMPLEMENTED); } Deferral^ OnboardingOffboardCalledEventArgs::GetDeferral() @@ -278,7 +278,7 @@ OnboardingGetScanInfoCalledEventArgs::OnboardingGetScanInfoCalledEventArgs( m_completionsRequired(0), m_messageInfo(info) { - m_result = OnboardingGetScanInfoResult::CreateFailureResult(ER_NOT_IMPLEMENTED); + m_result = OnboardingGetScanInfoResult::CreateFailureResult(ER_NOT_IMPLEMENTED); } Deferral^ OnboardingGetScanInfoCalledEventArgs::GetDeferral() @@ -354,7 +354,7 @@ OnboardingGetVersionRequestedEventArgs::OnboardingGetVersionRequestedEventArgs( m_completionsRequired(0), m_messageInfo(info) { - m_result = OnboardingGetVersionResult::CreateFailureResult(ER_NOT_IMPLEMENTED); + m_result = OnboardingGetVersionResult::CreateFailureResult(ER_NOT_IMPLEMENTED); } Deferral^ OnboardingGetVersionRequestedEventArgs::GetDeferral() @@ -429,7 +429,7 @@ OnboardingGetStateRequestedEventArgs::OnboardingGetStateRequestedEventArgs( m_completionsRequired(0), m_messageInfo(info) { - m_result = OnboardingGetStateResult::CreateFailureResult(ER_NOT_IMPLEMENTED); + m_result = OnboardingGetStateResult::CreateFailureResult(ER_NOT_IMPLEMENTED); } Deferral^ OnboardingGetStateRequestedEventArgs::GetDeferral() @@ -504,7 +504,7 @@ OnboardingGetLastErrorRequestedEventArgs::OnboardingGetLastErrorRequestedEventAr m_completionsRequired(0), m_messageInfo(info) { - m_result = OnboardingGetLastErrorResult::CreateFailureResult(ER_NOT_IMPLEMENTED); + m_result = OnboardingGetLastErrorResult::CreateFailureResult(ER_NOT_IMPLEMENTED); } Deferral^ OnboardingGetLastErrorRequestedEventArgs::GetDeferral() diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp index b5d59b5cdd..d4622bed19 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp @@ -55,7 +55,7 @@ void OnboardingSignals::ConnectionResult(_In_ Onboarding^ interfaceMemberArg) size_t argCount = 1; alljoyn_msgarg arguments = alljoyn_msgarg_array_create(argCount); - TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "(ns)", interfaceMemberArg); + (void)TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "(ns)", interfaceMemberArg); alljoyn_busobject_signal( m_busObject, @@ -73,8 +73,6 @@ void OnboardingSignals::ConnectionResult(_In_ Onboarding^ interfaceMemberArg) void OnboardingSignals::CallConnectionResultReceived(_In_ OnboardingSignals^ sender, _In_ OnboardingConnectionResultReceivedEventArgs^ args) { - AllJoynHelpers::DispatchEvent([=]() { - ConnectionResultReceived(sender, args); - }); + ConnectionResultReceived(sender, args); } diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h index 8f34db21b2..b626babea8 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h @@ -47,7 +47,26 @@ public ref class OnboardingSignals sealed : [Windows::Foundation::Metadata::Defa void ConnectionResult(_In_ Onboarding^ interfaceMemberArg); // This event fires whenever the ConnectionResult signal is sent by another member of the session. - virtual event Windows::Foundation::TypedEventHandler^ ConnectionResultReceived; + virtual event Windows::Foundation::TypedEventHandler^ ConnectionResultReceived + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _ConnectionResultReceived += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _ConnectionResultReceived -= token; + } + internal: + void raise(OnboardingSignals^ sender, OnboardingConnectionResultReceivedEventArgs^ args) + { + _ConnectionResultReceived(sender, args); + } + } internal: void Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId); @@ -57,6 +76,8 @@ public ref class OnboardingSignals sealed : [Windows::Foundation::Metadata::Defa alljoyn_busobject m_busObject; alljoyn_sessionid m_sessionId; + virtual event Windows::Foundation::EventHandler^ _ConnectionResultReceived; + alljoyn_interfacedescription_member m_memberConnectionResult; }; diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingWatcher.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingWatcher.h index 7252e2180d..2496773ea5 100644 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingWatcher.h +++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingWatcher.h @@ -48,10 +48,48 @@ public ref class OnboardingWatcher sealed : [Windows::Foundation::Metadata::Defa virtual ~OnboardingWatcher(); // This event will fire whenever a producer for this service is found. - virtual event Windows::Foundation::TypedEventHandler^ Added; + virtual event Windows::Foundation::TypedEventHandler^ Added + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _Added += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _Added -= token; + } + internal: + void raise(OnboardingWatcher^ sender, Windows::Devices::AllJoyn::AllJoynServiceInfo^ args) + { + _Added(sender, args); + } + } // This event will fire whenever the watcher is stopped. - virtual event Windows::Foundation::TypedEventHandler^ Stopped; + virtual event Windows::Foundation::TypedEventHandler^ Stopped + { + Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler) + { + return _Stopped += ref new Windows::Foundation::EventHandler + ([handler](Platform::Object^ sender, Platform::Object^ args) + { + handler->Invoke(safe_cast(sender), safe_cast(args)); + }, Platform::CallbackContext::Same); + } + void remove(Windows::Foundation::EventRegistrationToken token) + { + _Stopped -= token; + } + internal: + void raise(OnboardingWatcher^ sender, Windows::Devices::AllJoyn::AllJoynProducerStoppedEventArgs^ args) + { + _Stopped(sender, args); + } + } // Start watching for producers advertising this service. void Start(); @@ -83,6 +121,9 @@ public ref class OnboardingWatcher sealed : [Windows::Foundation::Metadata::Defa void BusAttachmentStateChanged(_In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ sender, _In_ Windows::Devices::AllJoyn::AllJoynBusAttachmentStateChangedEventArgs^ args); private: + virtual event Windows::Foundation::EventHandler^ _Added; + virtual event Windows::Foundation::EventHandler^ _Stopped; + void UnregisterFromBus(); Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment; diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/OnboardingEnumTypes.cs b/Samples/AllJoyn/ConsumerExperiences/cs/OnboardingEnumTypes.cs index b214c150a2..364af134c7 100644 --- a/Samples/AllJoyn/ConsumerExperiences/cs/OnboardingEnumTypes.cs +++ b/Samples/AllJoyn/ConsumerExperiences/cs/OnboardingEnumTypes.cs @@ -33,7 +33,7 @@ enum OnboardingAuthenticationType enum ConfigureWiFiResultStatus { - NonConcurrent = 1, + NotConcurrent = 1, Concurrent = 2, } diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1.xaml b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1.xaml index ca8d354eb3..c3cdb2ed74 100644 --- a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1.xaml +++ b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1.xaml @@ -50,7 +50,7 @@ - The Secure Consumer will use About to find a Secure Producer and then make a call to the "Concatenate" method. + The SecureInterface consumer will use About to find a SecureInterface producer and then make a call to the "Concatenate" method. diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1ViewModel.cs b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1ViewModel.cs index d13d2c9190..42848321fc 100644 --- a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1ViewModel.cs +++ b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1ViewModel.cs @@ -156,6 +156,7 @@ public void ScenarioCleanup() m_busAttachment.AuthenticationComplete -= BusAttachment_AuthenticationComplete; m_busAttachment.StateChanged -= BusAttachment_StateChanged; m_busAttachment.Disconnect(); + m_busAttachment = null; } } @@ -173,6 +174,8 @@ await m_dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => private void Start() { + ScenarioCleanup(); + m_busAttachment = new AllJoynBusAttachment(); m_busAttachment.StateChanged += BusAttachment_StateChanged; m_busAttachment.AuthenticationMechanisms.Clear(); @@ -295,9 +298,18 @@ private async void BusAttachment_CredentialsRequested(AllJoynBusAttachment sende private async void Watcher_Added(SecureInterfaceWatcher sender, AllJoynServiceInfo args) { - // Optional - Get the about data of the producer. + // Optional - Get the About data of the producer. AllJoynAboutDataView aboutData = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, m_busAttachment, args.SessionPort); - UpdateStatusAsync(string.Format("Found {0} on {1} from manufacturer: {2}. Connecting...", aboutData.AppName, aboutData.DeviceName, aboutData.Manufacturer), NotifyType.StatusMessage); + + // Check to see if device name is populated in the about data, since device name is not a mandatory field. + if (string.IsNullOrEmpty(aboutData.DeviceName)) + { + UpdateStatusAsync(string.Format("Found {0} from manufacturer: {1}. Connecting...", aboutData.AppName, aboutData.Manufacturer), NotifyType.StatusMessage); + } + else + { + UpdateStatusAsync(string.Format("Found {0} on {1} from manufacturer: {2}. Connecting...", aboutData.AppName, aboutData.DeviceName, aboutData.Manufacturer), NotifyType.StatusMessage); + } // Attempt to join the session when a producer is discovered. SecureInterfaceJoinSessionResult joinSessionResult = await SecureInterfaceConsumer.JoinSessionAsync(args, sender); @@ -346,15 +358,15 @@ private void Consumer_SessionLost(SecureInterfaceConsumer sender, AllJoynSession private void Signals_TextSentReceived(SecureInterfaceSignals sender, SecureInterfaceTextSentReceivedEventArgs args) { - //Show UI Toast + // Show UI Toast. ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); - //Populate UI Toast + // Populate UI Toast. XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text"); toastTextElements[0].AppendChild(toastXml.CreateTextNode("Signal Received - " + args.Message)); - //Create and Send UI Toast + // Create and Send UI Toast. ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2.xaml b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2.xaml index 9c8ca0fb3d..7eb7117c91 100644 --- a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2.xaml +++ b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2.xaml @@ -56,8 +56,8 @@ - The Onboarding Consumer discovers and connects to an Onboarding Producer. - Once connected, the Consumer can pass an SSID and password to the Producer to onboard it, + The Onboarding consumer discovers and connects to an Onboarding producer. + Once connected, the consumer can pass an SSID and password to the producer to onboard it by using the "Configure" and "Connect" methods described in the Onboarding Service Framework XML. You can validate with an AllJoyn device which implements the onboarding interface. For more information: https://allseenalliance.org/developers/learn/base-services/onboarding/interface diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2ViewModel.cs b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2ViewModel.cs index 576c827260..1b6ab13846 100644 --- a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2ViewModel.cs +++ b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2ViewModel.cs @@ -520,6 +520,7 @@ public void ScenarioCleanup() m_busAttachment.AuthenticationComplete -= BusAttachment_AuthenticationComplete; m_busAttachment.StateChanged -= BusAttachment_StateChanged; m_busAttachment.Disconnect(); + m_busAttachment = null; } } @@ -571,7 +572,7 @@ private async void ScanForWiFiAdaptersAsync() } else { - UpdateStatusAsync("No WiFi Adapters detected on this machine.", NotifyType.ErrorMessage); + UpdateStatusAsync("No WiFi adapters detected on this machine.", NotifyType.ErrorMessage); } } } @@ -678,6 +679,8 @@ private async void ConnectToSoftAPAsync() private void ScanForOnboardingInterfaces() { + ScenarioCleanup(); + m_busAttachment = new AllJoynBusAttachment(); m_busAttachment.StateChanged += BusAttachment_StateChanged; m_busAttachment.AuthenticationMechanisms.Clear(); @@ -756,17 +759,10 @@ private async void Watcher_Added(OnboardingWatcher sender, AllJoynServiceInfo ar m_consumer = joinSessionResult.Consumer; m_consumer.SessionLost += Consumer_SessionLost; - if (!m_isCredentialsRequested) + if (!m_isCredentialsRequested || m_isAuthenticated) { GetOnboardeeNetworkListAsync(); } - else - { - if (m_isAuthenticated) - { - GetOnboardeeNetworkListAsync(); - } - } } else { @@ -880,8 +876,12 @@ private async void AttemptOnboardingAsync(string ssid, string password, short au UpdateStatusAsync("Onboardee sucessfully configured.", NotifyType.StatusMessage); if (configureWifiResult.Status2 == (short)ConfigureWiFiResultStatus.Concurrent) { - // Concurrent step used to validate the personal AP connection. In this case, the Onboarder application must - // wait for the ConnectionResult signal to arrive over the AllJoyn session established over the SoftAP link. + // The Onboardee has indicated that it will attempt to connect to the desired AP concurrently, while the SoftAP is enabled. In this case, + // the Onboarder application must wait for the ConnectionResult signal to arrive over the AllJoyn session established over the SoftAP link. + // If the Onboardee does not connect to the desired AP concurrently, then there is no guaranteed way for the Onboarder application to find + // out if the connection attempt was successful or not. In the NotConcurrent connection attempt, if the Onboardee fails to connect to + // the desired AP, the Onboarder application will have to again start over with scanning and connecting to the Onboardee SoftAP. + // For more information please visit https://allseenalliance.org/developers/learn/base-services/onboarding/interface m_consumer.Signals.ConnectionResultReceived += Signals_ConnectionResultReceived; } AttemptConnectionAsync(); diff --git a/Samples/AllJoyn/ConsumerExperiences/js/AllJoynConsumerExperiences.jsproj b/Samples/AllJoyn/ConsumerExperiences/js/AllJoynConsumerExperiences.jsproj new file mode 100644 index 0000000000..9a35e4b15a --- /dev/null +++ b/Samples/AllJoyn/ConsumerExperiences/js/AllJoynConsumerExperiences.jsproj @@ -0,0 +1,138 @@ + + + + + Debug + ARM + + + Debug + x64 + + + Debug + x86 + + + Release + ARM + + + Release + x64 + + + Release + x86 + + + + c2adb9af-edb3-4e57-8056-9d0531d4a6b2 + + + + 14.0 + + + + + UAP + 10.0.10240.0 + 10.0.10240.0 + $(VersionNumberMajor).$(VersionNumberMinor) + en-US + + + + Designer + + + + + + + + + default.html + + + images\microsoft-sdk.png + + + images\smallTile-sdk.png + + + images\splash-sdk.png + + + images\storeLogo-sdk.png + + + images\tile-sdk.png + + + images\windows-sdk.png + + + js\default.js + + + css\default.css + + + Microsoft.WinJS.4.0\css\ui-dark.css + + + Microsoft.WinJS.4.0\css\ui-light.css + + + Microsoft.WinJS.4.0\js\en-US\ui.strings.js + + + Microsoft.WinJS.4.0\js\WinJS.intellisense-setup.js + + + Microsoft.WinJS.4.0\js\WinJS.intellisense.js + + + Microsoft.WinJS.4.0\fonts\Symbols.ttf + + + Microsoft.WinJS.4.0\js\base.js + + + Microsoft.WinJS.4.0\js\ui.js + + + sample-utils\footer.html + + + sample-utils\header.html + + + sample-utils\sample-utils.js + + + sample-utils\scenario-select.css + + + sample-utils\scenario-select.html + + + + + + + + + \ No newline at end of file diff --git a/Samples/AllJoyn/ConsumerExperiences/js/AllJoynConsumerExperiences.sln b/Samples/AllJoyn/ConsumerExperiences/js/AllJoynConsumerExperiences.sln new file mode 100644 index 0000000000..4c12712006 --- /dev/null +++ b/Samples/AllJoyn/ConsumerExperiences/js/AllJoynConsumerExperiences.sln @@ -0,0 +1,68 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "AllJoynConsumerExperiences", "AllJoynConsumerExperiences.jsproj", "{C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scenario1WinRTComponent", "..\..\Common\Scenario1WinRTComponent\Scenario1WinRTComponent.vcxproj", "{0A9E8245-5676-4B45-B34B-756927D85B3C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scenario2WinRTComponent", "..\..\Common\Scenario2WinRTComponent\Scenario2WinRTComponent.vcxproj", "{F70F17CA-13C9-4386-80CF-BAC562425C16}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.ActiveCfg = Debug|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.Build.0 = Debug|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.Deploy.0 = Debug|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.ActiveCfg = Debug|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.Build.0 = Debug|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.Deploy.0 = Debug|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.ActiveCfg = Debug|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.Build.0 = Debug|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.Deploy.0 = Debug|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.ActiveCfg = Release|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.Build.0 = Release|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.Deploy.0 = Release|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.ActiveCfg = Release|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.Build.0 = Release|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.Deploy.0 = Release|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.ActiveCfg = Release|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.Build.0 = Release|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.Deploy.0 = Release|x86 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|ARM.ActiveCfg = Debug|ARM + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|ARM.Build.0 = Debug|ARM + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|x64.ActiveCfg = Debug|x64 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|x64.Build.0 = Debug|x64 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|x86.ActiveCfg = Debug|Win32 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|x86.Build.0 = Debug|Win32 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|ARM.ActiveCfg = Release|ARM + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|ARM.Build.0 = Release|ARM + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|x64.ActiveCfg = Release|x64 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|x64.Build.0 = Release|x64 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|x86.ActiveCfg = Release|Win32 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|x86.Build.0 = Release|Win32 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|ARM.ActiveCfg = Debug|ARM + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|ARM.Build.0 = Debug|ARM + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|x64.ActiveCfg = Debug|x64 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|x64.Build.0 = Debug|x64 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|x86.ActiveCfg = Debug|Win32 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|x86.Build.0 = Debug|Win32 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|ARM.ActiveCfg = Release|ARM + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|ARM.Build.0 = Release|ARM + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|x64.ActiveCfg = Release|x64 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|x64.Build.0 = Release|x64 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|x86.ActiveCfg = Release|Win32 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/AllJoyn/ConsumerExperiences/js/Microsoft.WinJS.4.0/css/placeholder.txt b/Samples/AllJoyn/ConsumerExperiences/js/Microsoft.WinJS.4.0/css/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/ConsumerExperiences/js/Microsoft.WinJS.4.0/fonts/placeholder b/Samples/AllJoyn/ConsumerExperiences/js/Microsoft.WinJS.4.0/fonts/placeholder new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/ConsumerExperiences/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt b/Samples/AllJoyn/ConsumerExperiences/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/ConsumerExperiences/js/css/placeholder.txt b/Samples/AllJoyn/ConsumerExperiences/js/css/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/ConsumerExperiences/js/html/scenario1.html b/Samples/AllJoyn/ConsumerExperiences/js/html/scenario1.html new file mode 100644 index 0000000000..b26753b01c --- /dev/null +++ b/Samples/AllJoyn/ConsumerExperiences/js/html/scenario1.html @@ -0,0 +1,38 @@ + + + + + + + + + +
+
+

Description:

+
+

+ The SecureInterface consumer will use About to find a SecureInterface producer and then make a call to the "Concatenate" method. +

+
+
+
+
+
+ + +
+
+
+ + + +
+
+
+
+
+ + diff --git a/Samples/AllJoyn/ConsumerExperiences/js/html/scenario2.html b/Samples/AllJoyn/ConsumerExperiences/js/html/scenario2.html new file mode 100644 index 0000000000..1794cc6b63 --- /dev/null +++ b/Samples/AllJoyn/ConsumerExperiences/js/html/scenario2.html @@ -0,0 +1,76 @@ + + + + + + + + + + +
+
+

Description:

+
+

+ The Onboarding consumer discovers and connects to an Onboarding producer. + Once connected, the consumer can pass an SSID and password to the producer to onboard it + by using the "Configure" and "Connect" methods described in the Onboarding Service Framework XML. + You can validate with an AllJoyn device which implements the onboarding interface. + For more information: https://allseenalliance.org/developers/learn/base-services/onboarding/interface +

+
+
+
+
Select the type of onboardee:
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+
+ SSID + + + + +
+
+ Password + +
+
+ Auth Type + +
+
+
+
+
+ + diff --git a/Samples/AllJoyn/ConsumerExperiences/js/images/placeholder.txt b/Samples/AllJoyn/ConsumerExperiences/js/images/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/ConsumerExperiences/js/js/onboardingenumtypes.js b/Samples/AllJoyn/ConsumerExperiences/js/js/onboardingenumtypes.js new file mode 100644 index 0000000000..c2725cda38 --- /dev/null +++ b/Samples/AllJoyn/ConsumerExperiences/js/js/onboardingenumtypes.js @@ -0,0 +1,85 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + + "use strict"; + + var AuthenticationType = { + Wpa2Auto: -3, + WpaAuto: -2, + Any: -1, + Open: 0, + Wep: 1, + WpaTkip: 2, + WpaCcmp: 3, + Wpa2Tkip: 4, + Wpa2Ccmp: 5, + Wps: 6, + properties: { + 0: { name: "Wpa2Auto" }, + 1: { name: "WpaAuto" }, + 2: { name: "Any" }, + 3: { name: "Open" }, + 4: { name: "Wep" }, + 5: { name: "WpaTkip" }, + 6: { name: "WpaCcmp" }, + 7: { name: "Wpa2Tkip" }, + 8: { name: "Wpa2Ccmp" }, + 9: { name: "Wps" }, + } + }; + + // To de-serialize the authentication type enumeration value, + // this offset will need to be added to the properties identifier. + // This is required because the identifiers cannot be negative numbers. + var authenticationIndexOffset = 3; + + var ConfigureWiFiResultStatus = { + NotConcurrent: 1, + Concurrent: 2, + properties: { + 1: { name: "NotConcurrent" }, + 2: { name: "Concurrent" }, + } + } + + var ConnectionResultCode = { + Validated: 0, + Unreachable: 1, + UnsupportedProtocol: 2, + Unauthorized: 3, + ErrorMessage: 4, + properties: { + 0: { name: "Validated" }, + 1: { name: "Unreachable" }, + 2: { name: "UnsupportedProtocol" }, + 3: { name: "Unauthorized" }, + 4: { name: "ErrorMessage" }, + } + } + + var ConfigurationState = { + NotConfigured: 0, + NotValidated: 1, + Validating: 2, + Validated: 3, + Error: 4, + Retry: 5, + properties: { + 0: { name: "NotConfigured" }, + 1: { name: "NotValidated" }, + 2: { name: "Validating" }, + 3: { name: "Validated" }, + 4: { name: "Error" }, + 5: { name: "Retry" }, + } + } + + WinJS.Namespace.define("OnboardingEnumTypes", { + AuthenticationType: AuthenticationType, + ConfigureWiFiResultStatus: ConfigureWiFiResultStatus, + ConnectionResultCode: ConnectionResultCode, + ConfigurationState: ConfigurationState, + authenticationIndexOffset: authenticationIndexOffset + }); +})(); \ No newline at end of file diff --git a/Samples/AllJoyn/ConsumerExperiences/js/js/sample-configuration.js b/Samples/AllJoyn/ConsumerExperiences/js/js/sample-configuration.js new file mode 100644 index 0000000000..d750ef4126 --- /dev/null +++ b/Samples/AllJoyn/ConsumerExperiences/js/js/sample-configuration.js @@ -0,0 +1,17 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var sampleTitle = "AllJoyn Consumer Experiences"; + + var scenarios = [ + { url: "/html/scenario1.html", title: "Secure Consumer" }, + { url: "/html/scenario2.html", title: "Onboarding Consumer" } + ]; + + WinJS.Namespace.define("SdkSample", { + sampleTitle: sampleTitle, + scenarios: new WinJS.Binding.List(scenarios) + }); +})(); \ No newline at end of file diff --git a/Samples/AllJoyn/ConsumerExperiences/js/js/scenario1.js b/Samples/AllJoyn/ConsumerExperiences/js/js/scenario1.js new file mode 100644 index 0000000000..6b32354c39 --- /dev/null +++ b/Samples/AllJoyn/ConsumerExperiences/js/js/scenario1.js @@ -0,0 +1,265 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var allJoyn = Windows.Devices.AllJoyn; + var secureInterface = com.microsoft.Samples.SecureInterface; + var notifications = Windows.UI.Notifications; + + var page = WinJS.UI.Pages.define("/html/scenario1.html", { + ready: function (element, options) { + scenarioInit(); + }, + unload: function (element, options) { + scenarioCleanup(); + } + }); + + var busAttachment = null; + var watcher = null; + var consumer = null; + var isAuthenticated = false; + var isCredentialsRequested = false; + var callSetProperty = true; + + function scenarioInit() { + authenticationOptions.style.display = "none"; + consumerOptions.style.display = "none"; + connectButton.onclick = connectButtonClickHandler; + concatenateButton.onclick = concatenateButtonClickHandler; + upperCaseSwitch.onchange = upperCaseSwitchChangeHandler; + } + + function scenarioCleanup() { + disposeConsumer(); + disposeWatcher(); + + if (busAttachment != null) { + busAttachment.onstatechanged = null; + busAttachment.onauthenticationcomplete = null; + busAttachment.oncredentialsrequested = null; + busAttachment.disconnect(); + busAttachment = null; + } + } + + function connectButtonClickHandler() { + scenarioCleanup(); + + busAttachment = new allJoyn.AllJoynBusAttachment(); + busAttachment.onstatechanged = stateChangedHandler; + busAttachment.authenticationMechanisms.clear(); + busAttachment.authenticationMechanisms.append(allJoyn.AllJoynAuthenticationMechanism.ecdhePsk); + busAttachment.onauthenticationcomplete = authenticationCompleteHandler; + busAttachment.oncredentialsrequested = credentialsRequestedHandler; + + // Initialize a watcher object to listen for about interfaces. + watcher = new secureInterface.SecureInterfaceWatcher(busAttachment); + + // Subscribing to the added event that will be raised whenever a producer for this service is found. + watcher.onadded = watcherAddedHandler; + + reportStatus("Searching..."); + + // Start watching for producers advertising this service. + watcher.start(); + } + + function stateChangedHandler(args) { + if (args.detail[0].state === allJoyn.AllJoynBusAttachmentState.disconnected) { + reportStatus("AllJoyn bus attachment has disconnected with AllJoyn error: 0x" + args.detail[0].status.toString(16)); + consumerOptions.style.display = "block"; + } + } + + function authenticationCompleteHandler(args) { + if (args.detail[0].succeeded) { + reportStatus("Authentication was successful."); + } else { + reportError("Authentication failed."); + } + + isAuthenticated = args.detail[0].succeeded; + keyInputText.value = ""; + authenticationOptions.style.display = "none"; + authenticateButton.onclick = null; + } + + function credentialsRequestedHandler(args) { + var credentialsDeferral = args.detail[0].getDeferral(); + isCredentialsRequested = true; + + if (args.detail[0].credentials.authenticationMechanism == allJoyn.AllJoynAuthenticationMechanism.ecdhePsk) { + // Wait for the user to provide key and click authenticate. + reportStatus("Please enter the key."); + + authenticateButton.onclick = function () { + if (isNullOrWhitespace(keyInputText.value)) { + reportError("Please enter a key."); + } else { + reportStatus("Authenticating..."); + + // Ignore hyphens in the entered key. + args.detail[0].credentials.passwordCredential.password = keyInputText.value.replace(/-/g, ''); + credentialsDeferral.complete(); + } + }; + authenticationOptions.style.display = "block"; + } else { + reportError("Unexpected authentication mechanism."); + credentialsDeferral.complete(); + } + } + + function watcherAddedHandler(args) { + // Optional - Get the About data of the producer. + allJoyn.AllJoynAboutDataView.getDataBySessionPortAsync(args.detail[0].uniqueName, busAttachment, args.detail[0].sessionPort) + .then(function (aboutData) { + if (aboutData != null) { + // Check to see if device name is populated in the about data, since device name is not a mandatory field. + if (aboutData.deviceName != null) { + reportStatus("Found " + aboutData.appName + " on " + aboutData.deviceName + " from manufacturer: " + aboutData.manufacturer + ". Connecting..."); + } else { + reportStatus("Found " + aboutData.appName + " from manufacturer: " + aboutData.manufacturer + ". Connecting..."); + } + } else { + reportError("Unable to get About data."); + } + }) + .then(function () { + // Attempt to join the session when a producer is discovered. + secureInterface.SecureInterfaceConsumer.joinSessionAsync(args, watcher) + .then(function (joinSessionResult) { + if (joinSessionResult.status === allJoyn.AllJoynStatus.ok) { + disposeConsumer(); + consumer = joinSessionResult.consumer; + consumer.onisuppercaseenabledchanged = isUpperCaseEnabledChangedHandler; + consumer.signals.ontextsentreceived = textSentReceivedHandler; + consumer.onsessionlost = sessionLostHandler; + + // At the time of connection, the request credentials callback not being invoked is an + // indication that the consumer and producer are already authenticated from a previous session. + if (!isCredentialsRequested) { + reportStatus("Connected and already authenticated from previous session."); + isUpperCaseEnabledChangedHandler(); + } else { + if (isAuthenticated) { + reportStatus("Connected with authentication."); + isUpperCaseEnabledChangedHandler(); + } else { + reportError("Connected but authentication failed."); + } + } + consumerOptions.style.display = "block"; + } else { + reportError("Attempt to connect failed with AllJoyn error: 0x" + joinSessionResult.status.toString(16)); + } + }); + }); + } + + function isUpperCaseEnabledChangedHandler() { + consumer.getIsUpperCaseEnabledAsync() + .then(function (getIsUpperCaseEnabledResult) { + if (getIsUpperCaseEnabledResult.status === allJoyn.AllJoynStatus.ok) { + if (upperCaseSwitch.winControl.checked !== getIsUpperCaseEnabledResult.isUpperCaseEnabled) { + callSetProperty = false; + upperCaseSwitch.winControl.checked = getIsUpperCaseEnabledResult.isUpperCaseEnabled; + } + } else { + reportError("Get property failed with AllJoyn error: 0x" + getIsUpperCaseEnabledResult.status.toString(16)); + } + }); + } + + function textSentReceivedHandler(args) { + // Show UI Toast. + var toastTemplate = notifications.ToastTemplateType.toastText02; + var toastXml = notifications.ToastNotificationManager.getTemplateContent(toastTemplate); + + // Populate UI Toast. + var toastTextElements = toastXml.getElementsByTagName("text"); + toastTextElements[0].appendChild(toastXml.createTextNode("Signal Received - " + args.detail[0].message)); + + // Create and Send UI Toast. + var toast = new notifications.ToastNotification(toastXml); + notifications.ToastNotificationManager.createToastNotifier().show(toast); + + reportStatus("Signal Received - " + args.detail[0].message); + } + + function sessionLostHandler(args) { + reportStatus("AllJoyn session with the producer lost due to AllJoynSessionLostReason = " + args.detail[0].reason.toString()); + consumerOptions.style.display = "none"; + disposeConsumer(); + } + + function concatenateButtonClickHandler() { + if ((isNullOrWhitespace(inputText1.value)) || (isNullOrWhitespace(inputText2.value))) { + reportError("Input strings cannot be empty."); + } else { + // Call the Concatenate method with the input strings arguments. + consumer.concatenateAsync(inputText1.value, inputText2.value) + .then(function (catResult) { + if (catResult.status === allJoyn.AllJoynStatus.ok) { + reportStatus("Concatenation output : " + catResult.outStr); + } else { + reportError("AllJoyn Error : 0x" + catResult.status.toString(16)); + } + }); + } + } + + function upperCaseSwitchChangeHandler(args) { + if (callSetProperty) { + consumer.setIsUpperCaseEnabledAsync(args.target.winControl.checked) + .then(function (setIsUpperCaseEnabledResult) { + if (setIsUpperCaseEnabledResult.status === allJoyn.AllJoynStatus.ok) { + reportStatus("\"IsUpperCaseEnabled\" property successfully set."); + } else { + reportError("Set property failed with AllJoyn error: 0x" + setIsUpperCaseEnabledResult.status.toString(16)); + callSetProperty = false; + upperCaseSwitch.winControl.checked = !args.target.winControl.checked; + } + }); + } else { + callSetProperty = true; + } + } + + function disposeConsumer() { + if (consumer != null) { + consumer.onisuppercaseenabledchanged = null; + consumer.signals.ontextsentreceived = null; + consumer.onsessionlost = null; + consumer.close(); + consumer = null; + } + } + + function disposeWatcher() { + if (watcher != null) { + watcher.onadded = null; + watcher.stop(); + watcher.close(); + watcher = null; + } + } + + function reportStatus(message) { + WinJS.log && WinJS.log(message, "sample", "status"); + } + + function reportError(message) { + WinJS.log && WinJS.log(message, "sample", "error"); + } + + function isNullOrWhitespace(str) { + if ((typeof str === 'undefined') || (str == null) || (!/\S/.test(str))) { + return true; + } else { + return false; + } + } +})(); diff --git a/Samples/AllJoyn/ConsumerExperiences/js/js/scenario2.js b/Samples/AllJoyn/ConsumerExperiences/js/js/scenario2.js new file mode 100644 index 0000000000..57008136c6 --- /dev/null +++ b/Samples/AllJoyn/ConsumerExperiences/js/js/scenario2.js @@ -0,0 +1,496 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var allJoyn = Windows.Devices.AllJoyn; + var onboarding = org.alljoyn.Onboarding; + var wifi = Windows.Devices.WiFi; + + var page = WinJS.UI.Pages.define("/html/scenario2.html", { + ready: function (element, options) { + scenarioInit(); + }, + unload: function (element, options) { + scenarioCleanup(); + } + }); + + var onboardeeScanResult, onboarderScanResult; + var isCredentialRequested, isAuthenticated; + var showOnboardeeSsidList, showOnboarderSsidList; + var wifiAdapter, wifiAdapterList; + var savedProfileName; + var busAttachment = null; + var watcher = null; + var consumer = null; + + function scenarioInit() { + resetScenario(); + Radio1.onclick = onboardeeChoicesClickHandler; + Radio2.onclick = onboardeeChoicesClickHandler; + scanButton.onclick = scanButtonClickHandler; + adapterSelect.onchange = adapterSelectChangeHandler; + softAPNetworkSelect.onchange = softAPNetworkSelectChangeHandler; + connectButton.onclick = connectButtonClickHandler; + onboardeeNetworkSelect.onchange = onboardeeNetworkSelectChangeHandler; + manualSsidCheckbox.onclick = manualSsidCheckboxClickHandler; + onboardButton.onclick = onboardButtonClickHandler; + + for (var index in OnboardingEnumTypes.AuthenticationType.properties) { + var option = document.createElement("option"); + option.text = OnboardingEnumTypes.AuthenticationType.properties[index].name; + authenticationSelect.add(option); + } + } + + function scenarioCleanup() { + disposeConsumer(); + disposeWatcher(); + + if (busAttachment != null) { + busAttachment.oncredentialsrequested = null; + busAttachment.onauthenticationcomplete = null; + busAttachment.onstatechanged = null; + busAttachment.disconnect(); + busAttachment = null; + } + } + + function onboardeeChoicesClickHandler() { + resetScenario(); + scenarioCleanup(); + scanOptions.style.display = "block"; + } + + function scanButtonClickHandler() { + if (Radio1.checked) { + scanForOnboardingInterfaces(); + } else if (Radio2.checked) { + scanForWiFiAdapters(); + } + } + + function scanForOnboardingInterfaces() { + scenarioCleanup(); + + busAttachment = new allJoyn.AllJoynBusAttachment(); + busAttachment.onstatechanged = stateChangedHandler; + busAttachment.authenticationMechanisms.clear(); + busAttachment.authenticationMechanisms.append(allJoyn.AllJoynAuthenticationMechanism.ecdhePsk); + busAttachment.onauthenticationcomplete = authenticationCompleteHandler; + busAttachment.oncredentialsrequested = credentialsRequestedHandler; + watcher = new onboarding.OnboardingWatcher(busAttachment); + watcher.onadded = watcherAddedHandler; + reportStatus("Searching for onboarding interface..."); + watcher.start(); + } + + function stateChangedHandler(args) { + if (args.detail[0].state === allJoyn.AllJoynBusAttachmentState.disconnected) { + reportStatus("AllJoyn bus attachment has disconnected with AllJoyn error: 0x" + args.detail[0].status.toString(16)); + resetScenario(); + } + } + + function authenticationCompleteHandler(args) { + if (args.detail[0].succeeded) { + reportStatus("Authentication was successful."); + } else { + reportError("Authentication failed."); + } + + isAuthenticated = args.detail[0].succeeded; + keyInputText.value = ""; + authenticateOptions.style.display = "none"; + authenticateButton.onclick = null; + } + + function credentialsRequestedHandler(args) { + var credentialsDeferral = args.detail[0].getDeferral(); + isCredentialRequested = true; + + if (args.detail[0].credentials.authenticationMechanism == allJoyn.AllJoynAuthenticationMechanism.ecdhePsk) { + reportStatus("Please enter the key."); + authenticateButton.onclick = function () { + if (isNullOrWhitespace(keyInputText.value)) { + reportError("Please enter a key."); + } else { + reportStatus("Authenticating..."); + args.detail[0].credentials.passwordCredential.password = keyInputText.value.replace(/-/g, ''); + credentialsDeferral.complete(); + } + }; + authenticateOptions.style.display = "block"; + } else { + reportError("Unexpected authentication mechanism."); + credentialsDeferral.complete(); + } + } + + function watcherAddedHandler(args) { + reportStatus("Joining session..."); + onboarding.OnboardingConsumer.joinSessionAsync(args, watcher) + .then(function (joinSessionResult) { + if (joinSessionResult.status === allJoyn.AllJoynStatus.ok) { + disposeConsumer(); + consumer = joinSessionResult.consumer; + consumer.onsessionlost = sessionLostHandler; + + if (!isCredentialRequested || isAuthenticated) { + getOnboardeeNetworkList(); + } + } else { + reportError("Attempt to join session failed with AllJoyn error: 0x" + joinSessionResult.status.toString(16)); + } + }); + } + + function sessionLostHandler(args) { + reportStatus("AllJoyn session with the producer lost due to AllJoynSessionLostReason = " + args.detail[0].reason.toString()); + disposeConsumer(); + resetScenario(); + } + + function getOnboardeeNetworkList() { + reportStatus("Requesting network list from the onboardee..."); + consumer.getScanInfoAsync() + .then(function (getScanResult) { + if (getScanResult.status === allJoyn.AllJoynStatus.ok) { + if (getScanResult.scanList.size > 0) { + onboardeeScanResult = getScanResult.scanList; + for (var i = 0; i < getScanResult.scanList.size; i++) { + var option = document.createElement("option"); + option.text = getScanResult.scanList[i].value1; + onboardeeNetworkSelect.add(option); + } + displayOnboardeeSsidList(); + reportStatus(getScanResult.scanList.size.toString() + " network(s) returned. Scan age: " + getScanResult.age.toString() + " minutes."); + } else { + // No networks returned by the onboardee. Provide the user option to configure onboardee with networks visible from onboarder. + reportStatus("Please select a network or enter one manually."); + displayOnboarderSsidList(); + } + } else { + // Unable to get scan information from the onboardee. Provide the user option to configure onboardee with networks visible from onboarder. + reportStatus("Please select a network or enter one manually."); + displayOnboarderSsidList(); + } + configurationOptions.style.display = "block"; + }); + } + + function scanForWiFiAdapters() { + if (wifiAdapter == null) { + reportStatus("Requesting WiFi access..."); + wifi.WiFiAdapter.requestAccessAsync() + .then(function (accessStatus) { + if (accessStatus != wifi.WiFiAccessStatus.allowed) { + reportError("WiFi access denied."); + } else { + wifi.WiFiAdapter.findAllAdaptersAsync() + .then(function (adapterList) { + wifiAdapterList = adapterList; + if (adapterList.size > 0) { + for (var i = 0; i < adapterList.size; i++) { + var option = document.createElement("option"); + option.text = "Adapter " + (i + 1).toString(); + adapterSelect.add(option); + } + adapterSelect.style.display = "inline"; + reportStatus("Please select a WiFi adapter."); + } else { + reportError("No WiFi adapters detected on this machine."); + } + }, function (error) { + reportError(error.message); + }); + } + }, function (error) { + reportError(error.message); + }); + } + } + + function adapterSelectChangeHandler() { + if (adapterSelect.selectedIndex > 0) { + wifiAdapter = wifiAdapterList[adapterSelect.selectedIndex - 1]; + } + if (wifiAdapter != null) { + networkStatusChangedHandler(); + Windows.Networking.Connectivity.NetworkInformation.onnetworkstatuschanged = networkStatusChangedHandler; + reportStatus("Scanning for available WiFi networks..."); + wifiAdapter.scanAsync() + .then(function () { + onboarderScanResult = wifiAdapter.networkReport.availableNetworks; + if (onboarderScanResult.size > 0) { + for (var i = 0; i < onboarderScanResult.size; i++) { + var option = document.createElement("option"); + option.text = onboarderScanResult[i].ssid; + softAPNetworkSelect.add(option); + } + onboarderNetworkSelect.innerHTML = softAPNetworkSelect.innerHTML; + connectOptions.style.display = "block"; + reportStatus("Scan complete. Please select a network to connect."); + } else { + reportError("Scan complete. No WiFi networks found."); + } + }, function (error) { + reportError(error.message); + }); + } + } + + function networkStatusChangedHandler() { + if (wifiAdapter != null) { + wifiAdapter.networkAdapter.getConnectedProfileAsync() + .then(function (connectedProfile) { + if ((connectedProfile != null) && (connectedProfile.profileName !== savedProfileName)) { + savedProfileName = connectedProfile.profileName; + } else if ((connectedProfile == null) && (savedProfileName != null)) { + reportStatus("WiFi adapter disconnected from: " + savedProfileName); + savedProfileName = null; + } + }, function (error) { + reportError(error.message); + }); + } + } + + function softAPNetworkSelectChangeHandler() { + if (softAPNetworkSelect.selectedIndex > 0) { + if (onboarderScanResult[softAPNetworkSelect.selectedIndex - 1].securitySettings.networkAuthenticationType === + Windows.Networking.Connectivity.NetworkAuthenticationType.open80211) { + softAPPasswordInput.style.display = "none"; + } else { + softAPPasswordInput.style.display = "inline"; + } + } else { + softAPPasswordInput.style.display = "none"; + } + clearPasswords(); + } + + function connectButtonClickHandler() { + if (wifiAdapter != null) { + if (softAPNetworkSelect.selectedIndex > 0) { + reportStatus("Attempting to connect to " + softAPNetworkSelect[softAPNetworkSelect.selectedIndex].text + "..."); + var result = null; + if (onboarderScanResult[softAPNetworkSelect.selectedIndex - 1].securitySettings.networkAuthenticationType === + Windows.Networking.Connectivity.NetworkAuthenticationType.open80211) { + wifiAdapter.connectAsync(onboarderScanResult[softAPNetworkSelect.selectedIndex - 1], wifi.WiFiReconnectionKind.manual) + .then(function (connectionResult) { + validateConnectionResult(connectionResult); + }, function (error) { + reportError(error.message); + }); + } else { + if (isNullOrWhitespace(softAPPasswordInput.value)) { + reportError("No password entered."); + } else { + var credential = new Windows.Security.Credentials.PasswordCredential(); + credential.password = softAPPasswordInput.value; + wifiAdapter.connectAsync(onboarderScanResult[softAPNetworkSelect.selectedIndex - 1], wifi.WiFiReconnectionKind.manual, credential) + .then(function (connectionResult) { + validateConnectionResult(connectionResult); + }, function (error) { + reportError(error.message); + }); + } + clearPasswords(); + } + } else { + reportError("Network not selected. Please select a network."); + } + } + } + + function validateConnectionResult(result) { + if (result != null) { + if (result.connectionStatus === wifi.WiFiConnectionStatus.success) { + reportStatus("Successfully connected to " + onboarderScanResult[softAPNetworkSelect.selectedIndex - 1].ssid); + scanForOnboardingInterfaces(); + } else { + reportError("Failed to connect to " + onboarderScanResult[softAPNetworkSelect.selectedIndex - 1].ssid + " with error: " + + result.connectionStatus.toString()); + } + } + } + + function onboardeeNetworkSelectChangeHandler() { + if (onboardeeNetworkSelect.selectedIndex > 0) { + authenticationSelect.selectedIndex = onboardeeScanResult[onboardeeNetworkSelect.selectedIndex - 1].value2 + + OnboardingEnumTypes.authenticationIndexOffset + 1; + } + } + + function manualSsidCheckboxClickHandler() { + if (manualSsidCheckbox.checked) { + onboardeeNetworkSelect.style.display = "none"; + onboarderNetworkSelect.style.display = "none"; + ssidInput.style.display = "inline"; + } else { + if (showOnboardeeSsidList) { + onboardeeNetworkSelect.style.display = "inline"; + } else { + onboarderNetworkSelect.style.display = "inline"; + } + ssidInput.style.display = "none"; + } + } + + function onboardButtonClickHandler() { + var configureSsid = null; + if (manualSsidCheckbox.checked) { + configureSsid = ssidInput.value; + } else { + if (showOnboardeeSsidList) { + if (onboardeeNetworkSelect.selectedIndex > 0) { + configureSsid = onboardeeScanResult[onboardeeNetworkSelect.selectedIndex - 1].value1; + } + } else { + if (onboarderNetworkSelect.selectedIndex > 0) { + configureSsid = onboarderScanResult[onboarderNetworkSelect.selectedIndex - 1].ssid; + } + } + } + + if (isNullOrWhitespace(configureSsid)) { + reportError("No SSID selected. Please select a network or manually enter SSID."); + } else { + if (authenticationSelect.selectedIndex > 0) { + attemptOnboarding(configureSsid, configurationPasswordInput.value, + OnboardingEnumTypes.AuthenticationType[authenticationSelect[authenticationSelect.selectedIndex].text]); + } else { + reportError("No authentication type selected."); + } + } + } + + function attemptOnboarding(ssid, password, authenticationType) { + reportStatus("Attempting to configure onboardee..."); + + // WiFi password must be converted to hex representation of the UTF-8 string. + consumer.configureWiFiAsync(ssid, convertUtf8ToHex(password), authenticationType) + .then(function (configureWifiResult) { + if (configureWifiResult.status === allJoyn.AllJoynStatus.ok) { + reportStatus("Onboardee sucessfully configured."); + if (configureWifiResult.status2 === OnboardingEnumTypes.ConfigureWiFiResultStatus.Concurrent) { + // The Onboardee has indicated that it will attempt to connect to the desired AP concurrently, while the SoftAP is enabled. In this case, + // the Onboarder application must wait for the ConnectionResult signal to arrive over the AllJoyn session established over the SoftAP link. + // If the Onboardee does not connect to the desired AP concurrently, then there is no guaranteed way for the Onboarder application to find + // out if the connection attempt was successful or not. In the NotConcurrent connection attempt, if the Onboardee fails to connect to + // the desired AP, the Onboarder application will have to again start over with scanning and connecting to the Onboardee SoftAP. + // For more information please visit https://allseenalliance.org/developers/learn/base-services/onboarding/interface + consumer.signals.onconnectionresultreceived = connectionResultReceivedHandler; + } + attemptConnection(); + } else { + reportError("Attempt to configure WiFi failed with AllJoyn error: 0x" + configureWifiResult.status.toString(16)); + } + }); + clearPasswords(); + } + + function connectionResultReceivedHandler(args) { + if (args.detail[0].arg.value1 === OnboardingEnumTypes.ConnectionResultCode.Validated) { + reportStatus("Onboarding successful."); + } else { + reportError("Connection attempt failed with result code: " + OnboardingEnumTypes.ConnectionResultCode.properties[args.detail[0].arg.value1] + + " and message: " + args.detail[0].arg.value2 + "."); + } + } + + function attemptConnection() { + consumer.connectAsync() + .then(function () { + reportStatus("Connect request sent."); + }); + } + + function displayOnboardeeSsidList() { + if (manualSsidCheckbox.checked) { + showOnboardeeSsidList = true; + showOnboarderSsidList = false; + } else { + onboardeeNetworkSelect.style.display = "inline"; + onboarderNetworkSelect.style.display = "none"; + } + } + + function displayOnboarderSsidList() { + if (manualSsidCheckbox.checked) { + showOnboardeeSsidList = false; + showOnboarderSsidList = true; + } else { + onboardeeNetworkSelect.style.display = "none"; + onboarderNetworkSelect.style.display = "inline"; + } + } + + function clearPasswords() { + softAPPasswordInput.value = ""; + configurationPasswordInput.value = ""; + } + + function convertUtf8ToHex(str) { + var result = ""; + var hex; + + for (var i = 0; i < str.length; i++) { + hex = str.charCodeAt(i).toString(16); + result += hex; + } + + return result; + } + + function disposeConsumer() { + if (consumer != null) { + consumer.onsessionlost = null; + consumer.close(); + consumer = null; + } + } + + function disposeWatcher() { + if (watcher != null) { + watcher.onadded = null; + watcher.stop(); + watcher.close(); + watcher = null; + } + } + + function resetScenario() { + scanOptions.style.display = "none"; + adapterSelect.style.display = "none"; + connectOptions.style.display = "none"; + softAPPasswordInput.style.display = "none"; + authenticateOptions.style.display = "none"; + configurationOptions.style.display = "none"; + ssidInput.style.display = "none"; + manualSsidCheckbox.checked = false; + isCredentialRequested = false; + isAuthenticated = false; + showOnboardeeSsidList = true; + showOnboarderSsidList = false; + wifiAdapter = null + } + + function reportStatus(message) { + WinJS.log && WinJS.log(message, "sample", "status"); + } + + function reportError(message) { + WinJS.log && WinJS.log(message, "sample", "error"); + } + + function isNullOrWhitespace(str) { + if ((typeof str === 'undefined') || (str == null) || (!/\S/.test(str))) { + return true; + } else { + return false; + } + } +})(); diff --git a/Samples/AllJoyn/ConsumerExperiences/js/package.appxmanifest b/Samples/AllJoyn/ConsumerExperiences/js/package.appxmanifest new file mode 100644 index 0000000000..13233aabef --- /dev/null +++ b/Samples/AllJoyn/ConsumerExperiences/js/package.appxmanifest @@ -0,0 +1,54 @@ + + + + + + + + + AllJoyn Consumer Experiences JS Sample + Microsoft Corporation + images\storelogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/AllJoyn/ConsumerExperiences/js/sample-utils/placeholder.txt b/Samples/AllJoyn/ConsumerExperiences/js/sample-utils/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/ProducerExperiences/cs/Scenario1ViewModel.cs b/Samples/AllJoyn/ProducerExperiences/cs/Scenario1ViewModel.cs index 3dcaaa10c1..1ff2a77caa 100644 --- a/Samples/AllJoyn/ProducerExperiences/cs/Scenario1ViewModel.cs +++ b/Samples/AllJoyn/ProducerExperiences/cs/Scenario1ViewModel.cs @@ -178,6 +178,8 @@ private void Start() // Optional - Populate About data for the producer. m_busAttachment.AboutData.DefaultManufacturer = "Contoso"; m_busAttachment.AboutData.SupportUrl = new Uri("http://www.contoso.com/support"); + m_busAttachment.AboutData.ModelNumber = "ContosoTestModel"; + m_busAttachment.AboutData.DefaultDescription = "A secure AllJoyn sample"; // Generate the one-time pre-shared key. Key = CryptographicHelpers.GenerateHighEntropyKey(DesiredKeyLength); @@ -200,7 +202,7 @@ private void SendTextSignal() if (!string.IsNullOrWhiteSpace(SignalText)) { m_producer.Signals.TextSent(SignalText); - UpdateStatusAsync("Signal Sent.", NotifyType.StatusMessage); + UpdateStatusAsync("Signal sent.", NotifyType.StatusMessage); } else { diff --git a/Samples/AllJoyn/ProducerExperiences/cs/Scenario2.xaml b/Samples/AllJoyn/ProducerExperiences/cs/Scenario2.xaml index 670d949aca..9c163a1b58 100644 --- a/Samples/AllJoyn/ProducerExperiences/cs/Scenario2.xaml +++ b/Samples/AllJoyn/ProducerExperiences/cs/Scenario2.xaml @@ -29,8 +29,8 @@ - The Onboarding Producer accepts a connection form the Onboarding Consumer. Once connected, - the Producer will pass back a list of available networks, then accept an SSID and password + The Onboarding producer accepts a connection form the Onboarding consumer. Once connected, + the producer will pass back a list of available networks, then accept an SSID and password for connection purposes as described in the Onboarding Service Framework XML. diff --git a/Samples/AllJoyn/ProducerExperiences/cs/Scenario2ViewModel.cs b/Samples/AllJoyn/ProducerExperiences/cs/Scenario2ViewModel.cs index 2b4ec7c1bc..b1fe8a0968 100644 --- a/Samples/AllJoyn/ProducerExperiences/cs/Scenario2ViewModel.cs +++ b/Samples/AllJoyn/ProducerExperiences/cs/Scenario2ViewModel.cs @@ -334,7 +334,7 @@ private async void OnboardingService_ConnectRequestRecieved(object sender, Event } else { - if (AppData.OnboardingConfigurePassphrase.Equals(ConvertUtf8ToHex(AppData.SampleNetworkPassword))) + if (AppData.OnboardingConfigurePassphrase.Equals(ConvertUtf8ToHex(AppData.SampleNetworkPassword), StringComparison.OrdinalIgnoreCase)) { returnArg.Value1 = (short)ConnectionResultCode.Validated; returnArg.Value2 = "Connected successfully"; @@ -343,7 +343,7 @@ private async void OnboardingService_ConnectRequestRecieved(object sender, Event else { returnArg.Value1 = (short)ConnectionResultCode.Unauthorized; - returnArg.Value2 = "Invalid Password"; + returnArg.Value2 = "Invalid password"; AppData.OnboardingConfigurationState = (short)ConfigurationState.Error; } } @@ -351,7 +351,7 @@ private async void OnboardingService_ConnectRequestRecieved(object sender, Event else { returnArg.Value1 = (short)ConnectionResultCode.UnsupportedProtocol; - returnArg.Value2 = "Unsupported Authentication mechanism"; + returnArg.Value2 = "Unsupported authentication mechanism"; AppData.OnboardingConfigurationState = (short)ConfigurationState.Error; } } diff --git a/Samples/AllJoyn/ProducerExperiences/js/AllJoynProducerExperiences.jsproj b/Samples/AllJoyn/ProducerExperiences/js/AllJoynProducerExperiences.jsproj new file mode 100644 index 0000000000..785371455c --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/AllJoynProducerExperiences.jsproj @@ -0,0 +1,141 @@ + + + + + Debug + ARM + + + Debug + x64 + + + Debug + x86 + + + Release + ARM + + + Release + x64 + + + Release + x86 + + + + c2adb9af-edb3-4e57-8056-9d0531d4a6b2 + + + + 14.0 + + + + + UAP + 10.0.10240.0 + 10.0.10240.0 + $(VersionNumberMajor).$(VersionNumberMinor) + en-US + + + + Designer + + + + + + + + + + + + default.html + + + images\microsoft-sdk.png + + + images\smallTile-sdk.png + + + images\splash-sdk.png + + + images\storeLogo-sdk.png + + + images\tile-sdk.png + + + images\windows-sdk.png + + + js\default.js + + + css\default.css + + + Microsoft.WinJS.4.0\css\ui-dark.css + + + Microsoft.WinJS.4.0\css\ui-light.css + + + Microsoft.WinJS.4.0\js\en-US\ui.strings.js + + + Microsoft.WinJS.4.0\js\WinJS.intellisense-setup.js + + + Microsoft.WinJS.4.0\js\WinJS.intellisense.js + + + Microsoft.WinJS.4.0\fonts\Symbols.ttf + + + Microsoft.WinJS.4.0\js\base.js + + + Microsoft.WinJS.4.0\js\ui.js + + + sample-utils\footer.html + + + sample-utils\header.html + + + sample-utils\sample-utils.js + + + sample-utils\scenario-select.css + + + sample-utils\scenario-select.html + + + + + + + + + \ No newline at end of file diff --git a/Samples/AllJoyn/ProducerExperiences/js/AllJoynProducerExperiences.sln b/Samples/AllJoyn/ProducerExperiences/js/AllJoynProducerExperiences.sln new file mode 100644 index 0000000000..172ce68423 --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/AllJoynProducerExperiences.sln @@ -0,0 +1,68 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "AllJoynProducerExperiences", "AllJoynProducerExperiences.jsproj", "{C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scenario1WinRTComponent", "..\..\Common\Scenario1WinRTComponent\Scenario1WinRTComponent.vcxproj", "{0A9E8245-5676-4B45-B34B-756927D85B3C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scenario2WinRTComponent", "..\..\Common\Scenario2WinRTComponent\Scenario2WinRTComponent.vcxproj", "{F70F17CA-13C9-4386-80CF-BAC562425C16}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.ActiveCfg = Debug|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.Build.0 = Debug|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.Deploy.0 = Debug|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.ActiveCfg = Debug|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.Build.0 = Debug|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.Deploy.0 = Debug|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.ActiveCfg = Debug|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.Build.0 = Debug|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.Deploy.0 = Debug|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.ActiveCfg = Release|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.Build.0 = Release|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.Deploy.0 = Release|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.ActiveCfg = Release|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.Build.0 = Release|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.Deploy.0 = Release|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.ActiveCfg = Release|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.Build.0 = Release|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.Deploy.0 = Release|x86 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|ARM.ActiveCfg = Debug|ARM + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|ARM.Build.0 = Debug|ARM + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|x64.ActiveCfg = Debug|x64 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|x64.Build.0 = Debug|x64 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|x86.ActiveCfg = Debug|Win32 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Debug|x86.Build.0 = Debug|Win32 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|ARM.ActiveCfg = Release|ARM + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|ARM.Build.0 = Release|ARM + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|x64.ActiveCfg = Release|x64 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|x64.Build.0 = Release|x64 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|x86.ActiveCfg = Release|Win32 + {0A9E8245-5676-4B45-B34B-756927D85B3C}.Release|x86.Build.0 = Release|Win32 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|ARM.ActiveCfg = Debug|ARM + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|ARM.Build.0 = Debug|ARM + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|x64.ActiveCfg = Debug|x64 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|x64.Build.0 = Debug|x64 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|x86.ActiveCfg = Debug|Win32 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Debug|x86.Build.0 = Debug|Win32 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|ARM.ActiveCfg = Release|ARM + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|ARM.Build.0 = Release|ARM + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|x64.ActiveCfg = Release|x64 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|x64.Build.0 = Release|x64 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|x86.ActiveCfg = Release|Win32 + {F70F17CA-13C9-4386-80CF-BAC562425C16}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/AllJoyn/ProducerExperiences/js/Microsoft.WinJS.4.0/css/placeholder.txt b/Samples/AllJoyn/ProducerExperiences/js/Microsoft.WinJS.4.0/css/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/ProducerExperiences/js/Microsoft.WinJS.4.0/fonts/placeholder b/Samples/AllJoyn/ProducerExperiences/js/Microsoft.WinJS.4.0/fonts/placeholder new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/ProducerExperiences/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt b/Samples/AllJoyn/ProducerExperiences/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/ProducerExperiences/js/css/scenario.css b/Samples/AllJoyn/ProducerExperiences/js/css/scenario.css new file mode 100644 index 0000000000..a151609aef --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/css/scenario.css @@ -0,0 +1,9 @@ +/* +Copyright (c) Microsoft Corporation. All rights reserved +*/ + +/* styles */ + +.selectableText{ +-ms-user-select: text; +} \ No newline at end of file diff --git a/Samples/AllJoyn/ProducerExperiences/js/html/scenario1.html b/Samples/AllJoyn/ProducerExperiences/js/html/scenario1.html new file mode 100644 index 0000000000..941f5752b9 --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/html/scenario1.html @@ -0,0 +1,39 @@ + + + + + + + + + + + + +
+
+

Description:

+
+

+ Will create a service that will join the AllJoyn bus and request the name 'com.microsoft.Samples.SecureInterface'. + It will create a single method called 'Concatenate' that will concatenate two strings together and return the resulting string to the consumer. +

+
+
+
+
+
+
Key:
+
Hyphen separated
+
+
+ + +
+
+
+
+ + diff --git a/Samples/AllJoyn/ProducerExperiences/js/html/scenario2.html b/Samples/AllJoyn/ProducerExperiences/js/html/scenario2.html new file mode 100644 index 0000000000..7e756262f7 --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/html/scenario2.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + +
+
+

Description:

+
+

+ The Onboarding producer accepts a connection from the Onboarding consumer. Once connected, the producer will pass back a list of + available networks, then accept an SSID and password for connection purposes as described in the Onboarding Service Framework XML. +

+
+
+
+
+
+
Key:
+
Hyphen separated
+
Sample Networks:
+
Password:
+
Auth Type:
+
+
+
+ + diff --git a/Samples/AllJoyn/ProducerExperiences/js/images/placeholder.txt b/Samples/AllJoyn/ProducerExperiences/js/images/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/ProducerExperiences/js/js/appdata.js b/Samples/AllJoyn/ProducerExperiences/js/js/appdata.js new file mode 100644 index 0000000000..29971bdc79 --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/js/appdata.js @@ -0,0 +1,163 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + + "use strict"; + + var localSettings = Windows.Storage.ApplicationData.current.localSettings; + var onboarding = org.alljoyn.Onboarding; + + var isUpperCaseEnabledPropertyKey = "IsUpperCaseEnabled"; + var onboardingConfigureSsidKey = "OnboardingConfigureSsid"; + var onboardingConfigurePassphraseKey = "OnboardingConfigurePassphrase"; + var onboardingConfigureAuthenticationTypeKey = "OnboardingConfigureAuthenticationType"; + var onboardingConfigurationStateKey = "OnboardingConfigurationState"; + var onboardingLastErrorCodeKey = "OnboardingLastErrorCode"; + var onboardingLastErrorMessageKey = "OnboardingLastErrorMessage"; + + var secureInterfaceProperties = {}; + + Object.defineProperty(secureInterfaceProperties, 'isUpperCaseEnabled', { + get: function () { + if (!localSettings.values.hasKey(isUpperCaseEnabledPropertyKey)) { + localSettings.values[isUpperCaseEnabledPropertyKey] = false; + } + return localSettings.values[isUpperCaseEnabledPropertyKey]; + }, + set: function (value) { + localSettings.values[isUpperCaseEnabledPropertyKey] = value; + } + }); + + var onboardingConfiguration = {}; + + Object.defineProperty(onboardingConfiguration, 'ssid', { + get: function () { + if (!localSettings.values.hasKey(onboardingConfigureSsidKey)) { + return null; + } else { + return localSettings.values[onboardingConfigureSsidKey]; + } + }, + set: function (value) { + localSettings.values[onboardingConfigureSsidKey] = value; + } + }); + + Object.defineProperty(onboardingConfiguration, 'passphrase', { + get: function () { + if (!localSettings.values.hasKey(onboardingConfigurePassphraseKey)) { + return null; + } else { + return localSettings.values[onboardingConfigurePassphraseKey]; + } + }, + set: function (value) { + localSettings.values[onboardingConfigurePassphraseKey] = value; + } + }); + + Object.defineProperty(onboardingConfiguration, 'authenticationType', { + get: function () { + if (!localSettings.values.hasKey(onboardingConfigureAuthenticationTypeKey)) { + return OnboardingEnumTypes.AuthenticationType.Any; + } else { + return localSettings.values[onboardingConfigureAuthenticationTypeKey]; + } + }, + set: function (value) { + localSettings.values[onboardingConfigureAuthenticationTypeKey] = value; + } + }); + + var onboardingProperties = {}; + + Object.defineProperty(onboardingProperties, 'configurationState', { + get: function () { + if (!localSettings.values.hasKey(onboardingConfigurationStateKey)) { + localSettings.values[onboardingConfigurationStateKey] = OnboardingEnumTypes.ConfigurationState.NotConfigured; + } + return localSettings.values[onboardingConfigurationStateKey]; + }, + set: function (value) { + localSettings.values[onboardingConfigurationStateKey] = value; + } + }); + + Object.defineProperty(onboardingProperties, 'lastErrorCode', { + get: function () { + if (!localSettings.values.hasKey(onboardingLastErrorCodeKey)) { + return OnboardingEnumTypes.ConnectionResultCode.ErrorMessage; + } else { + return localSettings.values[onboardingLastErrorCodeKey]; + } + }, + set: function (value) { + localSettings.values[onboardingLastErrorCodeKey] = value; + } + }); + + Object.defineProperty(onboardingProperties, 'lastErrorMessage', { + get: function () { + if (!localSettings.values.hasKey(onboardingLastErrorMessageKey)) { + return "No Last Error available"; + } else { + return localSettings.values[onboardingLastErrorMessageKey]; + } + }, + set: function (value) { + localSettings.values[onboardingLastErrorMessageKey] = value; + } + }); + + var getSampleNetworkScanList = function () { + var network1 = new onboarding.OnboardingScanListItem(); + network1.value1 = "SampleNetwork1"; + network1.value2 = OnboardingEnumTypes.AuthenticationType.Open; + + var network2 = new onboarding.OnboardingScanListItem(); + network2.value1 = "SampleNetwork2"; + network2.value2 = OnboardingEnumTypes.AuthenticationType.Wep; + + var network3 = new onboarding.OnboardingScanListItem(); + network3.value1 = "SampleNetwork3"; + network3.value2 = OnboardingEnumTypes.AuthenticationType.WpaTkip; + + var network4 = new onboarding.OnboardingScanListItem(); + network4.value1 = "SampleNetwork4"; + network4.value2 = OnboardingEnumTypes.AuthenticationType.WpaCcmp; + + var network5 = new onboarding.OnboardingScanListItem(); + network5.value1 = "SampleNetwork5"; + network5.value2 = OnboardingEnumTypes.AuthenticationType.Wpa2Tkip; + + var network6 = new onboarding.OnboardingScanListItem(); + network6.value1 = "SampleNetwork6"; + network6.value2 = OnboardingEnumTypes.AuthenticationType.Wpa2Ccmp; + + var network7 = new onboarding.OnboardingScanListItem(); + network7.value1 = "SampleNetwork7"; + network7.value2 = OnboardingEnumTypes.AuthenticationType.Wps; + + var networkScanList = []; + networkScanList.push(network1); + networkScanList.push(network2); + networkScanList.push(network3); + networkScanList.push(network4); + networkScanList.push(network5); + networkScanList.push(network6); + networkScanList.push(network7); + + return networkScanList; + } + + var sampleNetworkPassword = "SamplePassword"; + + WinJS.Namespace.define("AppData", { + secureInterfaceProperties: secureInterfaceProperties, + onboardingConfiguration: onboardingConfiguration, + onboardingProperties: onboardingProperties, + getSampleNetworkScanList: getSampleNetworkScanList, + sampleNetworkPassword: sampleNetworkPassword + }); +})(); \ No newline at end of file diff --git a/Samples/AllJoyn/ProducerExperiences/js/js/cryptographichelpers.js b/Samples/AllJoyn/ProducerExperiences/js/js/cryptographichelpers.js new file mode 100644 index 0000000000..0f7f96ca57 --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/js/cryptographichelpers.js @@ -0,0 +1,75 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + + "use strict"; + + var cryptoBuffer = Windows.Security.Cryptography.CryptographicBuffer; + + var generateHighEntropyKey = function (desiredKeyLength) { + if (desiredKeyLength <= 0) { + throw ("Argument Exception: The desired key length must be a positive integer."); + } else { + var maxAttempts = 100; + var attemptCount = 0; + var randomBuffer; + var str; + var generatedKey = new String(); + + // Base64 uses 6 bits to encode a single character. Number of bits required = length * 6. + var numberOfRandomBytesRequired = Math.round((desiredKeyLength * 6.0) / 8.0); + + while ((generatedKey.length !== desiredKeyLength) && (attemptCount < maxAttempts)) { + randomBuffer = cryptoBuffer.generateRandom(numberOfRandomBytesRequired); + str = cryptoBuffer.encodeToBase64String(randomBuffer); + + for (var i = 0; i < str.length; i++) { + var c = str.charAt(i); + if (/^[a-zA-Z0-9]+$/i.test(c)) { + generatedKey += c; + if (generatedKey.length === desiredKeyLength) { + break; + } + } + } + attemptCount++; + } + + if (generatedKey.length === desiredKeyLength) { + return generatedKey; + } else { + throw ("Exception: Unable to generate a high entropy key."); + } + } + } + + var insertHyphens = function (key, insertHyphenAfterPosition) { + if (!key || 0 === key.length) { + throw ("Argument Exception: Input key must be a valid string."); + } else if (insertHyphenAfterPosition <= 0) { + throw ("Argument Exception: Desired hyphen position must be a positive number."); + } else if (insertHyphenAfterPosition > key.length) { + throw ("Argument Exception: Desired hyphen position cannot be greater than key length."); + } else { + var count = 0; + var resultString = new String(); + + for (var i = 0; i < key.length; i++) { + if (count === insertHyphenAfterPosition) { + resultString += "-"; + count = 0; + } + + resultString += key.charAt(i); + count++; + } + + return resultString; + } + } + + WinJS.Namespace.define("CryptographicHelpers", { + generateHighEntropyKey: generateHighEntropyKey, + insertHyphens: insertHyphens + }); +})(); \ No newline at end of file diff --git a/Samples/AllJoyn/ProducerExperiences/js/js/onboardingenumtypes.js b/Samples/AllJoyn/ProducerExperiences/js/js/onboardingenumtypes.js new file mode 100644 index 0000000000..c2725cda38 --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/js/onboardingenumtypes.js @@ -0,0 +1,85 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + + "use strict"; + + var AuthenticationType = { + Wpa2Auto: -3, + WpaAuto: -2, + Any: -1, + Open: 0, + Wep: 1, + WpaTkip: 2, + WpaCcmp: 3, + Wpa2Tkip: 4, + Wpa2Ccmp: 5, + Wps: 6, + properties: { + 0: { name: "Wpa2Auto" }, + 1: { name: "WpaAuto" }, + 2: { name: "Any" }, + 3: { name: "Open" }, + 4: { name: "Wep" }, + 5: { name: "WpaTkip" }, + 6: { name: "WpaCcmp" }, + 7: { name: "Wpa2Tkip" }, + 8: { name: "Wpa2Ccmp" }, + 9: { name: "Wps" }, + } + }; + + // To de-serialize the authentication type enumeration value, + // this offset will need to be added to the properties identifier. + // This is required because the identifiers cannot be negative numbers. + var authenticationIndexOffset = 3; + + var ConfigureWiFiResultStatus = { + NotConcurrent: 1, + Concurrent: 2, + properties: { + 1: { name: "NotConcurrent" }, + 2: { name: "Concurrent" }, + } + } + + var ConnectionResultCode = { + Validated: 0, + Unreachable: 1, + UnsupportedProtocol: 2, + Unauthorized: 3, + ErrorMessage: 4, + properties: { + 0: { name: "Validated" }, + 1: { name: "Unreachable" }, + 2: { name: "UnsupportedProtocol" }, + 3: { name: "Unauthorized" }, + 4: { name: "ErrorMessage" }, + } + } + + var ConfigurationState = { + NotConfigured: 0, + NotValidated: 1, + Validating: 2, + Validated: 3, + Error: 4, + Retry: 5, + properties: { + 0: { name: "NotConfigured" }, + 1: { name: "NotValidated" }, + 2: { name: "Validating" }, + 3: { name: "Validated" }, + 4: { name: "Error" }, + 5: { name: "Retry" }, + } + } + + WinJS.Namespace.define("OnboardingEnumTypes", { + AuthenticationType: AuthenticationType, + ConfigureWiFiResultStatus: ConfigureWiFiResultStatus, + ConnectionResultCode: ConnectionResultCode, + ConfigurationState: ConfigurationState, + authenticationIndexOffset: authenticationIndexOffset + }); +})(); \ No newline at end of file diff --git a/Samples/AllJoyn/ProducerExperiences/js/js/sample-configuration.js b/Samples/AllJoyn/ProducerExperiences/js/js/sample-configuration.js new file mode 100644 index 0000000000..b1c47a6372 --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/js/sample-configuration.js @@ -0,0 +1,17 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var sampleTitle = "AllJoyn Producer Experiences"; + + var scenarios = [ + { url: "/html/scenario1.html", title: "Secure Producer" }, + { url: "/html/scenario2.html", title: "Onboarding Producer" } + ]; + + WinJS.Namespace.define("SdkSample", { + sampleTitle: sampleTitle, + scenarios: new WinJS.Binding.List(scenarios) + }); +})(); \ No newline at end of file diff --git a/Samples/AllJoyn/ProducerExperiences/js/js/scenario1.js b/Samples/AllJoyn/ProducerExperiences/js/js/scenario1.js new file mode 100644 index 0000000000..2cc07b05b2 --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/js/scenario1.js @@ -0,0 +1,170 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var allJoyn = Windows.Devices.AllJoyn; + var secureInterface = com.microsoft.Samples.SecureInterface; + + var page = WinJS.UI.Pages.define("/html/scenario1.html", { + ready: function (element, options) { + scenarioInit(); + }, + unload: function (element, options) { + scenarioCleanup(); + } + }); + + var isBusAttachmentConnected = false; + var desiredKeyLength = 24; + var insertHyphenAfterPosition = 4; + var key, producer, busAttachment; + + function scenarioInit() { + producerOptions.style.display = "none"; + launchButton.onclick = launchButtonClickHandler; + hyphenCheckbox.onclick = hyphenCheckboxClickHandler; + upperCaseSwitch.winControl.checked = AppData.secureInterfaceProperties.isUpperCaseEnabled; + upperCaseSwitch.onchange = upperCaseSwitchChangeHandler; + sendSignalButton.onclick = sendSignalButtonClickHandler; + } + + function scenarioCleanup() { + if (producer != null) { + producer.service.onconcatenatecalled = null; + producer.service.ongetisuppercaseenabledrequested = null; + producer.service.onsetisuppercaseenabledrequested = null; + producer.stop(); + } + if (busAttachment != null) { + busAttachment.onstatechanged = null; + busAttachment.onauthenticationcomplete = null; + busAttachment.oncredentialsrequested = null; + busAttachment.disconnect(); + isBusAttachmentConnected = false; + } + } + + function launchButtonClickHandler() { + if (isBusAttachmentConnected) { + reportStatus("Already launched."); + } else { + reportStatus("Launching..."); + + busAttachment = new allJoyn.AllJoynBusAttachment(); + busAttachment.onstatechanged = stateChangedHandler; + busAttachment.authenticationMechanisms.clear(); + busAttachment.authenticationMechanisms.append(allJoyn.AllJoynAuthenticationMechanism.ecdhePsk); + busAttachment.onauthenticationcomplete = authenticationCompleteHandler; + busAttachment.oncredentialsrequested = credentialsRequestedHandler; + + // Optional - Populate About data for the producer. + busAttachment.aboutData.defaultManufacturer = "Contoso"; + busAttachment.aboutData.supportUrl = new Windows.Foundation.Uri("http://www.contoso.com/support"); + busAttachment.aboutData.modelNumber = "ContosoTestModel"; + busAttachment.aboutData.defaultDescription = "A secure AllJoyn sample"; + + // Generate the one-time pre-shared key. + key = CryptographicHelpers.generateHighEntropyKey(desiredKeyLength); + keyDisplay.textContent = key; + + // Initialize the producer object generated by the AllJoynCodeGenerator tool. + producer = new secureInterface.SecureInterfaceProducer(busAttachment); + + // Instantiate SecureInterfaceService which will handle the concatenation method calls. + producer.service = new secureInterface.SecureInterfaceServiceEventAdapter(); + producer.service.onconcatenatecalled = concatenateCalledHandler; + producer.service.ongetisuppercaseenabledrequested = getIsUpperCaseEnabledRequestedHandler; + producer.service.onsetisuppercaseenabledrequested = setIsUpperCaseEnabledRequestedHandler; + + // Start advertising the service. + producer.start(); + } + } + + function hyphenCheckboxClickHandler() { + if (hyphenCheckbox.checked) { + keyDisplay.textContent = CryptographicHelpers.insertHyphens(key, insertHyphenAfterPosition); + } else { + keyDisplay.textContent = key; + } + } + + function upperCaseSwitchChangeHandler(args) { + AppData.secureInterfaceProperties.isUpperCaseEnabled = args.target.winControl.checked; + if (producer != null) { + producer.emitIsUpperCaseEnabledChanged(); + } + } + + function sendSignalButtonClickHandler() { + if (producer != null) { + var message = signalText.value; + if ((typeof message === 'undefined') || (message == null) || (!/\S/.test(message))) { + reportError("No text entered.") + } else { + producer.signals.textSent(message); + reportStatus("Signal sent."); + } + } + } + + function stateChangedHandler(args) { + switch (args.detail[0].state) { + case allJoyn.AllJoynBusAttachmentState.disconnected: + reportStatus("Disconnected from the AllJoyn bus attachment with AllJoyn status: 0x" + args.detail[0].status.toString(16)); + isBusAttachmentConnected = false; + producerOptions.style.display = "none"; + break; + case allJoyn.AllJoynBusAttachmentState.connected: + reportStatus("Launched."); + isBusAttachmentConnected = true; + producerOptions.style.display = "block"; + break; + } + } + + function authenticationCompleteHandler(args) { + if (args.detail[0].succeeded) { + reportStatus("Authentication was successful."); + } else { + reportError("Authentication failed."); + } + } + + function credentialsRequestedHandler(args) { + if (args.detail[0].credentials.authenticationMechanism == allJoyn.AllJoynAuthenticationMechanism.ecdhePsk) { + args.detail[0].credentials.passwordCredential.password = key; + } else { + reportError("Unexpected authentication mechanism."); + } + } + + function concatenateCalledHandler(args) { + reportStatus("Concatenation request recieved for \"" + args.detail[0].inStr1 + "\" and \"" + args.detail[0].inStr2 + "\"."); + + if (AppData.secureInterfaceProperties.isUpperCaseEnabled) { + args.detail[0].result = secureInterface.SecureInterfaceConcatenateResult.createSuccessResult(args.detail[0].inStr1.toUpperCase() + args.detail[0].inStr2.toUpperCase()); + } else { + args.detail[0].result = secureInterface.SecureInterfaceConcatenateResult.createSuccessResult(args.detail[0].inStr1 + args.detail[0].inStr2); + } + } + + function getIsUpperCaseEnabledRequestedHandler(args) { + args.detail[0].result = secureInterface.SecureInterfaceGetIsUpperCaseEnabledResult.createSuccessResult(AppData.secureInterfaceProperties.isUpperCaseEnabled); + } + + function setIsUpperCaseEnabledRequestedHandler(args) { + AppData.secureInterfaceProperties.isUpperCaseEnabled = args.detail[0].value; + upperCaseSwitch.winControl.checked = args.detail[0].value; + args.detail[0].result = secureInterface.SecureInterfaceSetIsUpperCaseEnabledResult.createSuccessResult(); + } + + function reportStatus(message) { + WinJS.log && WinJS.log(message, "sample", "status"); + } + + function reportError(message) { + WinJS.log && WinJS.log(message, "sample", "error"); + } +})(); diff --git a/Samples/AllJoyn/ProducerExperiences/js/js/scenario2.js b/Samples/AllJoyn/ProducerExperiences/js/js/scenario2.js new file mode 100644 index 0000000000..482bc78fb2 --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/js/scenario2.js @@ -0,0 +1,282 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var allJoyn = Windows.Devices.AllJoyn; + var onboarding = org.alljoyn.Onboarding; + + var page = WinJS.UI.Pages.define("/html/scenario2.html", { + ready: function (element, options) { + scenarioInit(); + }, + unload: function (element, options) { + scenarioCleanup(); + } + }); + + var isBusAttachmentConnected = false; + var desiredKeyLength = 24; + var insertHyphenAfterPosition = 4; + var key, producer, busAttachment; + + function scenarioInit() { + producerOptions.style.display = "none"; + launchButton.onclick = launchButtonClickHandler; + hyphenCheckbox.onclick = hyphenCheckboxClickHandler; + + var networkscanList = AppData.getSampleNetworkScanList(); + for (var i = 0; i < networkscanList.length; i++) { + var option = document.createElement("option"); + option.text = networkscanList[i].value1; + sampleNetworkSelect.add(option); + } + sampleNetworkSelect.onchange = sampleNetworkSelectChangeHandler; + sampleNetworkSelectChangeHandler(); + } + + function scenarioCleanup() { + if (producer != null) { + producer.service.onconfigurewificalled = null; + producer.service.onconnectcalled = null; + producer.service.onoffboardcalled = null; + producer.service.ongetscaninfocalled = null; + producer.service.ongetversionrequested = null; + producer.service.ongetstaterequested = null; + producer.service.ongetlasterrorrequested = null; + producer.stop(); + } + if (busAttachment != null) { + busAttachment.onstatechanged = null; + busAttachment.onauthenticationcomplete = null; + busAttachment.oncredentialsrequested = null; + busAttachment.disconnect(); + isBusAttachmentConnected = false; + } + } + + function launchButtonClickHandler() { + if (isBusAttachmentConnected) { + reportStatus("Already launched."); + } else { + reportStatus("Launching..."); + + busAttachment = new allJoyn.AllJoynBusAttachment(); + busAttachment.onstatechanged = stateChangedHandler; + busAttachment.authenticationMechanisms.clear(); + busAttachment.authenticationMechanisms.append(allJoyn.AllJoynAuthenticationMechanism.ecdhePsk); + busAttachment.onauthenticationcomplete = authenticationCompleteHandler; + busAttachment.oncredentialsrequested = credentialsRequestedHandler; + + // Generate the one-time pre-shared key. + key = CryptographicHelpers.generateHighEntropyKey(desiredKeyLength); + keyDisplay.textContent = key; + + // Initialize the producer object generated by the AllJoynCodeGenerator tool. + producer = new onboarding.OnboardingProducer(busAttachment); + + // Instantiate OnboardingService which will handle the onboarding method calls. + producer.service = new onboarding.OnboardingServiceEventAdapter(); + producer.service.onconfigurewificalled = configureWiFiCalledHandler; + producer.service.onconnectcalled = connectCalledHandler; + producer.service.onoffboardcalled = offboardCalledHandler; + producer.service.ongetscaninfocalled = getScanInfoCalledHandler; + producer.service.ongetversionrequested = getVersionRequestedHandler; + producer.service.ongetstaterequested = getStateRequestedHandler; + producer.service.ongetlasterrorrequested = getLastErrorRequestedHandler; + + // Start advertising the service. + producer.start(); + } + } + + function hyphenCheckboxClickHandler() { + if (hyphenCheckbox.checked) { + keyDisplay.textContent = CryptographicHelpers.insertHyphens(key, insertHyphenAfterPosition); + } else { + keyDisplay.textContent = key; + } + } + + function sampleNetworkSelectChangeHandler() { + var networkscanList = AppData.getSampleNetworkScanList(); + + if (networkscanList[sampleNetworkSelect.selectedIndex].value2 === OnboardingEnumTypes.AuthenticationType.Open) { + passwordDisplay.textContent = ""; + } else { + passwordDisplay.textContent = AppData.sampleNetworkPassword; + } + + authTypeDisplay.textContent = OnboardingEnumTypes.AuthenticationType.properties[networkscanList[sampleNetworkSelect.selectedIndex].value2 + OnboardingEnumTypes.authenticationIndexOffset].name; + } + + function stateChangedHandler(args) { + switch (args.detail[0].state) { + case allJoyn.AllJoynBusAttachmentState.disconnected: + reportStatus("Disconnected from the AllJoyn bus attachment with AllJoyn status: 0x" + args.detail[0].status.toString(16)); + isBusAttachmentConnected = false; + producerOptions.style.display = "none"; + break; + case allJoyn.AllJoynBusAttachmentState.connected: + reportStatus("Launched."); + isBusAttachmentConnected = true; + producerOptions.style.display = "block"; + break; + } + } + + function authenticationCompleteHandler(args) { + if (args.detail[0].succeeded) { + reportStatus("Authentication was successful."); + } else { + reportError("Authentication failed."); + } + } + + function credentialsRequestedHandler(args) { + if (args.detail[0].credentials.authenticationMechanism == allJoyn.AllJoynAuthenticationMechanism.ecdhePsk) { + args.detail[0].credentials.passwordCredential.password = key; + } else { + reportError("Unexpected authentication mechanism."); + } + } + + function configureWiFiCalledHandler(args) { + reportStatus("Configure WiFi request received."); + AppData.onboardingConfiguration.ssid = args.detail[0].ssid; + AppData.onboardingConfiguration.passphrase = args.detail[0].passphrase; + AppData.onboardingConfiguration.authenticationType = args.detail[0].authType; + AppData.onboardingProperties.configurationState = OnboardingEnumTypes.ConfigurationState.NotValidated; + args.detail[0].result = onboarding.OnboardingConfigureWiFiResult.createSuccessResult(OnboardingEnumTypes.ConfigureWiFiResultStatus.Concurrent); + } + + function connectCalledHandler(args) { + reportStatus("Connect Request received. Attempting to connect..."); + AppData.onboardingProperties.configurationState = OnboardingEnumTypes.ConfigurationState.Validating; + + // 5 second delay to simulate connection attempt time. + setTimeout(function () { + var returnArg = new onboarding.Onboarding(); + + var ssid = AppData.onboardingConfiguration.ssid; + if ((typeof ssid === 'undefined') || (ssid == null) || (!/\S/.test(ssid))) { + returnArg.value1 = OnboardingEnumTypes.ConnectionResultCode.ErrorMessage; + returnArg.value2 = "Invalid SSID"; + AppData.onboardingProperties.configurationState = OnboardingEnumTypes.ConfigurationState.Error; + } else { + var foundSsid = false; + var supportedProtocol = false; + + var networkscanList = AppData.getSampleNetworkScanList(); + for (var i = 0; i < networkscanList.length; i++) { + if (networkscanList[i].value1 === ssid) { + foundSsid = true; + if (AppData.onboardingConfiguration.authenticationType === OnboardingEnumTypes.AuthenticationType.Any) { + supportedProtocol = true; + } else if (AppData.onboardingConfiguration.authenticationType === OnboardingEnumTypes.AuthenticationType.WpaAuto) { + if ((networkscanList[i].value2 === OnboardingEnumTypes.AuthenticationType.WpaTkip) || (networkscanList[i].value2 === OnboardingEnumTypes.AuthenticationType.WpaCcmp)) { + supportedProtocol = true; + } + } else if (AppData.onboardingConfiguration.authenticationType === OnboardingEnumTypes.AuthenticationType.Wpa2Auto) { + if ((networkscanList[i].value2 === OnboardingEnumTypes.AuthenticationType.Wpa2Tkip) || (networkscanList[i].value2 === OnboardingEnumTypes.AuthenticationType.Wpa2Ccmp)) { + supportedProtocol = true; + } + } else { + if (networkscanList[i].value2 === AppData.onboardingConfiguration.authenticationType) { + supportedProtocol = true; + } + } + break; + } + } + + if (foundSsid) { + if (supportedProtocol) { + if (AppData.onboardingConfiguration.authenticationType === OnboardingEnumTypes.AuthenticationType.Open) { + returnArg.value1 = OnboardingEnumTypes.ConnectionResultCode.Validated; + returnArg.value2 = "Connected successfully"; + AppData.onboardingProperties.configurationState = OnboardingEnumTypes.ConfigurationState.Validated; + } else { + if (AppData.onboardingConfiguration.passphrase.toLowerCase() === convertUtf8ToHex(AppData.sampleNetworkPassword)) { + returnArg.value1 = OnboardingEnumTypes.ConnectionResultCode.Validated; + returnArg.value2 = "Connected successfully"; + AppData.onboardingProperties.configurationState = OnboardingEnumTypes.ConfigurationState.Validated; + } else { + returnArg.value1 = OnboardingEnumTypes.ConnectionResultCode.Unauthorized; + returnArg.value2 = "Invalid password"; + AppData.onboardingProperties.configurationState = OnboardingEnumTypes.ConfigurationState.Error; + } + } + } else { + returnArg.value1 = OnboardingEnumTypes.ConnectionResultCode.UnsupportedProtocol; + returnArg.value2 = "Unsupported authentication mechanism"; + AppData.onboardingProperties.configurationState = OnboardingEnumTypes.ConfigurationState.Error; + } + } else { + returnArg.value1 = OnboardingEnumTypes.ConnectionResultCode.Unreachable; + returnArg.value2 = "Configured SSID unreachable"; + AppData.onboardingProperties.configurationState = OnboardingEnumTypes.ConfigurationState.Error; + } + } + + producer.signals.connectionResult(returnArg); + AppData.onboardingProperties.lastErrorCode = returnArg.value1; + AppData.onboardingProperties.lastErrorMessage = returnArg.value2; + + if (returnArg.value1 === OnboardingEnumTypes.ConnectionResultCode.Validated) { + reportStatus("Onboarding successful. Connected to " + ssid); + } else { + reportError("Onboarding Failed. Attempt to connect failed with result code: " + OnboardingEnumTypes.ConnectionResultCode.properties[returnArg.value1].name + " and message: " + returnArg.value2 + "."); + } + }, 5000); + + args.detail[0].result = onboarding.OnboardingConnectResult.createSuccessResult(); + } + + function offboardCalledHandler(args) { + AppData.onboardingConfiguration.ssid = null; + AppData.onboardingConfiguration.passphrase = null; + AppData.onboardingConfiguration.authenticationType = OnboardingEnumTypes.AuthenticationType.Any; + AppData.onboardingProperties.configurationState = OnboardingEnumTypes.ConfigurationState.NotConfigured; + args.detail[0].result = onboarding.OnboardingOffboardResult.createSuccessResult(); + } + + function getScanInfoCalledHandler(args) { + args.detail[0].result = onboarding.OnboardingGetScanInfoResult.createSuccessResult(1, AppData.getSampleNetworkScanList()); + } + + function getVersionRequestedHandler(args) { + args.detail[0].result = onboarding.OnboardingGetVersionResult.createSuccessResult(1); + } + + function getStateRequestedHandler(args) { + args.detail[0].result = onboarding.OnboardingGetStateResult.createSuccessResult(AppData.onboardingProperties.configurationState); + } + + function getLastErrorRequestedHandler(args) { + var lastError = new onboarding.OnboardingLastError(); + lastError.value1 = AppData.onboardingProperties.lastErrorCode; + lastError.value2 = AppData.onboardingProperties.lastErrorMessage; + args.detail[0].result = onboarding.OnboardingGetLastErrorResult.createSuccessResult(lastError); + } + + function convertUtf8ToHex(str) { + var result = ""; + var hex; + + for (var i = 0; i < str.length; i++) { + hex = str.charCodeAt(i).toString(16); + result += hex; + } + + return result; + } + + function reportStatus(message) { + WinJS.log && WinJS.log(message, "sample", "status"); + } + + function reportError(message) { + WinJS.log && WinJS.log(message, "sample", "error"); + } +})(); diff --git a/Samples/AllJoyn/ProducerExperiences/js/package.appxmanifest b/Samples/AllJoyn/ProducerExperiences/js/package.appxmanifest new file mode 100644 index 0000000000..71c279d57b --- /dev/null +++ b/Samples/AllJoyn/ProducerExperiences/js/package.appxmanifest @@ -0,0 +1,31 @@ + + + + + + AllJoyn Producer Experiences JS Sample + Microsoft Corporation + images\storelogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/AllJoyn/ProducerExperiences/js/sample-utils/placeholder.txt b/Samples/AllJoyn/ProducerExperiences/js/sample-utils/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/AllJoyn/shared/AllJoynBusObjectManager.cpp b/Samples/AllJoyn/shared/AllJoynBusObjectManager.cpp index 56e559eb92..276e214bff 100644 --- a/Samples/AllJoyn/shared/AllJoynBusObjectManager.cpp +++ b/Samples/AllJoyn/shared/AllJoynBusObjectManager.cpp @@ -148,12 +148,11 @@ QStatus AllJoynBusObjectManager::CreateBusObject(_In_ const PCSTR objectPath, _O nullptr, nullptr }; - alljoyn_busobject newBusObject = alljoyn_busobject_create(objectPath, false, &callbacks, nullptr); - if (newBusObject == nullptr) + *busObject = alljoyn_busobject_create(objectPath, false, &callbacks, nullptr); + if (*busObject == nullptr) { - return ER_FAIL; + return ER_OUT_OF_MEMORY; } - *busObject = newBusObject; return ER_OK; } diff --git a/Samples/AllJoyn/shared/AllJoynHelpers.cpp b/Samples/AllJoyn/shared/AllJoynHelpers.cpp index 8949285ec3..771404bca0 100644 --- a/Samples/AllJoyn/shared/AllJoynHelpers.cpp +++ b/Samples/AllJoyn/shared/AllJoynHelpers.cpp @@ -160,14 +160,4 @@ bool AllJoynHelpers::CanSecure(_In_ Windows::Foundation::Collections::IVector callback) -{ - // Obtain a reference to the application's CoreDispatcher which allows - // us to run code on its UI thread, then run the provided callback. - CoreDispatcher^ uiDispatcher = Windows::ApplicationModel::Core::CoreApplication::MainView->CoreWindow->Dispatcher; - create_task([=]() { - return uiDispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler(callback)); - }).wait(); } \ No newline at end of file diff --git a/Samples/AllJoyn/shared/AllJoynHelpers.h b/Samples/AllJoyn/shared/AllJoynHelpers.h index 354c506117..170e22504b 100644 --- a/Samples/AllJoyn/shared/AllJoynHelpers.h +++ b/Samples/AllJoyn/shared/AllJoynHelpers.h @@ -69,10 +69,6 @@ class AllJoynHelpers // Determine whether the supplied set of AuthenticationMechanisms is sufficient for securing an AllJoyn connection. static bool CanSecure(_In_ Windows::Foundation::Collections::IVector^ authenticationMechanisms); - // Execute the specified callback on the application's UI thread. The main purpose of this helper is to - // safely marshal typed event arguments to JavaScript applications. - static void DispatchEvent(std::function callback); - // Callback for alljoyn_about_announced_ptr. // This callback expects the context to be of type T, which must implement the OnAnnounce function. template diff --git a/Samples/AllJoyn/shared/TypeConversionHelpers.cpp b/Samples/AllJoyn/shared/TypeConversionHelpers.cpp index 9368a2c977..0f3328824d 100644 --- a/Samples/AllJoyn/shared/TypeConversionHelpers.cpp +++ b/Samples/AllJoyn/shared/TypeConversionHelpers.cpp @@ -31,7 +31,7 @@ //----------------------------------------------------------------------------- #include "pch.h" -_Check_return_ int32 TypeConversionHelpers::AppendNextCompleteType(_In_ PCSTR signature, _Out_ std::vector* typeSignature) +_Check_return_ int32 TypeConversionHelpers::AppendNextCompleteType(_In_ PCSTR signature, _Inout_ std::vector* typeSignature) { if (signature[0] == '\0') { @@ -76,7 +76,7 @@ _Check_return_ int32 TypeConversionHelpers::AppendNextCompleteType(_In_ PCSTR si } } -_Check_return_ int32 TypeConversionHelpers::GetDictionaryTypeSignatures(_In_ PCSTR signature, _Out_ std::vector* keySignature, _Out_ std::vector* valueSignature) +_Check_return_ int32 TypeConversionHelpers::GetDictionaryTypeSignatures(_In_ PCSTR signature, _Inout_ std::vector* keySignature, _Inout_ std::vector* valueSignature) { if ((strlen(signature) < 3) || (signature[0] != 'a') || (signature[1] != '{')) { diff --git a/Samples/AllJoyn/shared/TypeConversionHelpers.h b/Samples/AllJoyn/shared/TypeConversionHelpers.h index 04a1392b1c..bd44a36b16 100644 --- a/Samples/AllJoyn/shared/TypeConversionHelpers.h +++ b/Samples/AllJoyn/shared/TypeConversionHelpers.h @@ -37,8 +37,9 @@ ref class TypeConversionHelpers // Get the array of primitive values stored in the given alljoyn_msgarg. The values in the array will be returned as // a Windows::Foundation::Collections::IVector. template - static _Check_return_ int32 GetPrimitiveArrayMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Windows::Foundation::Collections::IVector^* value) + static _Check_return_ int32 GetPrimitiveArrayMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Windows::Foundation::Collections::IVector^* value) { + *value = nullptr; size_t elementCount = 0; T* arrayContents = nullptr; RETURN_IF_QSTATUS_ERROR(alljoyn_msgarg_get(argument, signature, &elementCount, &arrayContents)); @@ -58,7 +59,7 @@ ref class TypeConversionHelpers // Get the array of primitive values stored in the given alljoyn_msgarg. The values in the array will be returned as // a Windows::Foundation::Collections::IVectorView. template - static _Check_return_ int32 GetPrimitiveArrayMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Windows::Foundation::Collections::IVectorView^* value) + static _Check_return_ int32 GetPrimitiveArrayMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Windows::Foundation::Collections::IVectorView^* value) { Windows::Foundation::Collections::IVector^ result; int32 status = GetPrimitiveArrayMessageArg(argument, signature, &result); @@ -78,10 +79,10 @@ ref class TypeConversionHelpers // Examples: // If signature is "ii", it will append "i", because that string describes the integer type // If signature is "a(is)si" it will append "a(is)", because that string fully describes an array of structures. - static _Check_return_ int32 AppendNextCompleteType(_In_ PCSTR signature, _Out_ std::vector* typeSignature); + static _Check_return_ int32 AppendNextCompleteType(_In_ PCSTR signature, _Inout_ std::vector* typeSignature); // Get the key and value types from the type AllJoyn type signature for a dictionary. - static _Check_return_ int32 GetDictionaryTypeSignatures(_In_ PCSTR signature, _Out_ std::vector* keySignature, _Out_ std::vector* valueSignature); + static _Check_return_ int32 GetDictionaryTypeSignatures(_In_ PCSTR signature, _Inout_ std::vector* keySignature, _Inout_ std::vector* valueSignature); // Get the value of an alljoyn_msgarg whose value matches WinRT type T. // @@ -107,11 +108,15 @@ ref class TypeConversionHelpers return alljoyn_msgarg_set(argument, signature, value); } - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Platform::String^* value) + static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Platform::String^* value) { - PSTR allJoynValue; + *value = nullptr; + PSTR allJoynValue = nullptr; QStatus status = alljoyn_msgarg_get(argument, signature, &allJoynValue); - *value = AllJoynHelpers::MultibyteToPlatformString(allJoynValue); + if ((ER_OK == status) && (nullptr != allJoynValue)) + { + *value = AllJoynHelpers::MultibyteToPlatformString(allJoynValue); + } return static_cast(status); } @@ -122,7 +127,7 @@ ref class TypeConversionHelpers } template - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Windows::Foundation::Collections::IVector^* value) + static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Windows::Foundation::Collections::IVector^* value) { *value = ref new Platform::Collections::Vector(); if (signature[0] != 'a') @@ -177,7 +182,7 @@ ref class TypeConversionHelpers } template - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Windows::Foundation::Collections::IVectorView^* value) + static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Windows::Foundation::Collections::IVectorView^* value) { Windows::Foundation::Collections::IVector^ result; int32 status = GetAllJoynMessageArg(argument, signature, &result); @@ -209,7 +214,7 @@ ref class TypeConversionHelpers return alljoyn_msgarg_set_and_stabilize(argument, signature, value->Size, allJoynArgument.data()); } - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Windows::Foundation::Collections::IVector^* value) + static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Windows::Foundation::Collections::IVector^* value) { *value = ref new Platform::Collections::Vector(); size_t elementCount = 0; @@ -229,7 +234,7 @@ ref class TypeConversionHelpers return S_OK; } - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Windows::Foundation::Collections::IVectorView^* value) + static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Windows::Foundation::Collections::IVectorView^* value) { Windows::Foundation::Collections::IVector^ result; int32 status = GetAllJoynMessageArg(argument, signature, &result); @@ -243,14 +248,14 @@ ref class TypeConversionHelpers } template - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Windows::Foundation::Collections::IMap^* value) + static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Windows::Foundation::Collections::IMap^* value) { + *value = ref new Platform::Collections::Map(); + std::vector keyType; std::vector valueType; RETURN_IF_QSTATUS_ERROR(GetDictionaryTypeSignatures(signature, &keyType, &valueType)); - *value = ref new Platform::Collections::Map(); - size_t elementCount = 0; alljoyn_msgarg dictionaryContents = nullptr; RETURN_IF_QSTATUS_ERROR(alljoyn_msgarg_get(argument, signature, &elementCount, &dictionaryContents)); @@ -274,14 +279,14 @@ ref class TypeConversionHelpers } template - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Windows::Foundation::Collections::IMap^* value) + static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Windows::Foundation::Collections::IMap^* value) { + *value = ref new Platform::Collections::Map(); + std::vector keyType; std::vector valueType; RETURN_IF_QSTATUS_ERROR(GetDictionaryTypeSignatures(signature, &keyType, &valueType)); - *value = ref new Platform::Collections::Map(); - size_t elementCount = 0; alljoyn_msgarg dictionaryContents = nullptr; RETURN_IF_QSTATUS_ERROR(alljoyn_msgarg_get(argument, signature, &elementCount, &dictionaryContents)); @@ -332,7 +337,7 @@ ref class TypeConversionHelpers } template - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Windows::Foundation::Collections::IMapView^* value) + static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Windows::Foundation::Collections::IMapView^* value) { Windows::Foundation::Collections::IMap^ result; int32 status = GetAllJoynMessageArg(argument, signature, &result); @@ -364,8 +369,9 @@ ref class TypeConversionHelpers return static_cast(status); } - static _Check_return_ int32 GetVariantStructureArg(_In_ alljoyn_msgarg argument, _Out_ Platform::Object^* value) + static _Check_return_ int32 GetVariantStructureArg(_In_ alljoyn_msgarg argument, _Outptr_result_maybenull_ Platform::Object^* value) { + *value = nullptr; size_t memberCount = alljoyn_msgarg_getnummembers(argument); auto result = ref new PROJECT_NAMESPACE::AllJoynMessageArgStructure(); @@ -391,8 +397,10 @@ ref class TypeConversionHelpers } template - static _Check_return_ int32 GetVariantArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _In_ Platform::Object^* value) + static _Check_return_ int32 GetVariantArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Platform::Object^* value) { + *value = nullptr; + T innerValue; RETURN_IF_QSTATUS_ERROR(GetAllJoynMessageArg(argument, signature, &innerValue)); *value = innerValue; @@ -517,8 +525,10 @@ ref class TypeConversionHelpers return ER_BUS_BAD_VALUE_TYPE; } - static _Check_return_ int32 GetMapFromVariant(_In_ alljoyn_msgarg argument, _In_ char mapSignature, _Out_ Platform::Object^* value) + static _Check_return_ int32 GetMapFromVariant(_In_ alljoyn_msgarg argument, _In_ char mapSignature, _Outptr_result_maybenull_ Platform::Object^* value) { + *value = nullptr; + switch (mapSignature) { case 'y': @@ -566,8 +576,9 @@ ref class TypeConversionHelpers } } - static _Check_return_ int32 GetValueFromVariant(_In_ alljoyn_msgarg argument, _Out_ Platform::Object^* value) + static _Check_return_ int32 GetValueFromVariant(_In_ alljoyn_msgarg argument, _Outptr_result_maybenull_ Platform::Object^* value) { + *value = nullptr; char variantSignature[c_MaximumSignatureLength]; alljoyn_msgarg_signature(argument, variantSignature, c_MaximumSignatureLength); @@ -618,10 +629,11 @@ ref class TypeConversionHelpers return ER_BUS_BAD_SIGNATURE; } - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ Platform::Object^* value) + static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Outptr_result_maybenull_ Platform::Object^* value) { UNREFERENCED_PARAMETER(signature); + *value = nullptr; alljoyn_msgarg variantArg; RETURN_IF_QSTATUS_ERROR(alljoyn_msgarg_get(argument, "v", &variantArg)); return GetValueFromVariant(variantArg, value); diff --git a/Samples/Altimeter/js/Package.appxmanifest b/Samples/Altimeter/js/Package.appxmanifest index 31858ba545..3c174ee34e 100644 --- a/Samples/Altimeter/js/Package.appxmanifest +++ b/Samples/Altimeter/js/Package.appxmanifest @@ -6,7 +6,7 @@ IgnorableNamespaces="uap mp"> diff --git a/Samples/Altimeter/vb/Package.appxmanifest b/Samples/Altimeter/vb/Package.appxmanifest index f26fd5b589..9da5e5d0be 100644 --- a/Samples/Altimeter/vb/Package.appxmanifest +++ b/Samples/Altimeter/vb/Package.appxmanifest @@ -12,7 +12,7 @@ Version="1.0.0.0" /> - + Altimeter VB Sample diff --git a/Samples/AnimationLibrary/js/Package.appxmanifest b/Samples/AnimationLibrary/js/Package.appxmanifest index dc363b2f82..355fa79c7e 100644 --- a/Samples/AnimationLibrary/js/Package.appxmanifest +++ b/Samples/AnimationLibrary/js/Package.appxmanifest @@ -6,7 +6,7 @@ IgnorableNamespaces="uap mp"> diff --git a/Samples/AnimationMetrics/js/Package.appxmanifest b/Samples/AnimationMetrics/js/Package.appxmanifest index 494a646841..03ecfad867 100644 --- a/Samples/AnimationMetrics/js/Package.appxmanifest +++ b/Samples/AnimationMetrics/js/Package.appxmanifest @@ -6,7 +6,7 @@ IgnorableNamespaces="uap mp"> diff --git a/Samples/AnimationMetrics/vb/Package.appxmanifest b/Samples/AnimationMetrics/vb/Package.appxmanifest index bf4429b4bf..4f3b93b0ae 100644 --- a/Samples/AnimationMetrics/vb/Package.appxmanifest +++ b/Samples/AnimationMetrics/vb/Package.appxmanifest @@ -12,7 +12,7 @@ Version="1.0.0.0" /> - + Animation Metrics VB Sample diff --git a/Samples/AppServices/vb/AppServicesClient/Package.appxmanifest b/Samples/AppServices/vb/AppServicesClient/Package.appxmanifest index 4dae51c6ef..68ed868182 100644 --- a/Samples/AppServices/vb/AppServicesClient/Package.appxmanifest +++ b/Samples/AppServices/vb/AppServicesClient/Package.appxmanifest @@ -12,7 +12,7 @@ Version="1.0.0.0" /> - + AppServicesClient VB Sample diff --git a/Samples/AppServices/vb/AppServicesProvider/Package.appxmanifest b/Samples/AppServices/vb/AppServicesProvider/Package.appxmanifest index a39b911418..d42629c8df 100644 --- a/Samples/AppServices/vb/AppServicesProvider/Package.appxmanifest +++ b/Samples/AppServices/vb/AppServicesProvider/Package.appxmanifest @@ -12,7 +12,7 @@ Version="1.0.0.0" /> - + AppServicesProvider VB Sample diff --git a/Samples/ApplicationData/vb/Package.appxmanifest b/Samples/ApplicationData/vb/Package.appxmanifest index 3425dc7de6..3331ce13aa 100644 --- a/Samples/ApplicationData/vb/Package.appxmanifest +++ b/Samples/ApplicationData/vb/Package.appxmanifest @@ -1,7 +1,7 @@ - + ApplicationData VB Sample Microsoft Corporation diff --git a/Samples/ApplicationResources/cpp/App.xaml b/Samples/ApplicationResources/cpp/App.xaml deleted file mode 100644 index 63e80b839c..0000000000 --- a/Samples/ApplicationResources/cpp/App.xaml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Samples/ApplicationResources/cpp/App.xaml.cpp b/Samples/ApplicationResources/cpp/App.xaml.cpp deleted file mode 100644 index e8b98e77d7..0000000000 --- a/Samples/ApplicationResources/cpp/App.xaml.cpp +++ /dev/null @@ -1,127 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#include "pch.h" -#include "MainPage.xaml.h" - -using namespace SDKTemplate; - -using namespace Platform; -using namespace Windows::ApplicationModel; -using namespace Windows::ApplicationModel::Activation; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Interop; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Navigation; - -// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=402347&clcid=0x409 - -/// -/// Initializes the singleton application object. This is the first line of authored code -/// executed, and as such is the logical equivalent of main() or WinMain(). -/// -App::App() -{ - InitializeComponent(); - Suspending += ref new Windows::UI::Xaml::SuspendingEventHandler(this, &SDKTemplate::App::OnSuspending); -} - -/// -/// Invoked when the application is launched normally by the end user. Other entry points -/// will be used such as when the application is launched to open a specific file. -/// -/// Details about the launch request and process. -void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) -{ -#if _DEBUG - // Show graphics profiling information while debugging. - if (IsDebuggerPresent()) - { - // Display the current frame rate counters - DebugSettings->EnableFrameRateCounter = false; - } -#endif - - auto rootFrame = dynamic_cast(Window::Current->Content); - - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (rootFrame == nullptr) - { - // Create a Frame to act as the navigation context and associate it with - // a SuspensionManager key - rootFrame = ref new Frame(); - - // Set the default language - rootFrame->Language = Windows::Globalization::ApplicationLanguages::Languages->GetAt(0); - - rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed); - - if (e->PreviousExecutionState == ApplicationExecutionState::Terminated) - { - // TODO: Restore the saved session state only when appropriate, scheduling the - // final launch steps after the restore is complete - } - - if (rootFrame->Content == nullptr) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments); - } - // Place the frame in the current Window - Window::Current->Content = rootFrame; - // Ensure the current window is active - Window::Current->Activate(); - } - else - { - if (rootFrame->Content == nullptr) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments); - } - // Ensure the current window is active - Window::Current->Activate(); - } -} - -/// -/// Invoked when application execution is being suspended. Application state is saved -/// without knowing whether the application will be terminated or resumed with the contents -/// of memory still intact. -/// -/// The source of the suspend request. -/// Details about the suspend request. -void App::OnSuspending(Object^ /* sender */, SuspendingEventArgs^ /* e */) -{ - //TODO: Save application state and stop any background activity -} - - -/// -/// Invoked when Navigation to a certain page fails -/// -/// The Frame which failed navigation -/// Details about the navigation failure -void App::OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e) -{ - throw ref new FailureException("Failed to load Page " + e->SourcePageType.Name); -} diff --git a/Samples/ApplicationResources/cpp/App.xaml.h b/Samples/ApplicationResources/cpp/App.xaml.h deleted file mode 100644 index e7bd715aa8..0000000000 --- a/Samples/ApplicationResources/cpp/App.xaml.h +++ /dev/null @@ -1,33 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#pragma once - -#include "App.g.h" - -namespace SDKTemplate -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - ref class App sealed - { - protected: - virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override; - - internal: - App(); - - private: - void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); - void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e); - }; -} diff --git a/Samples/ApplicationResources/cpp/ApplicationResources.vcxproj b/Samples/ApplicationResources/cpp/ApplicationResources.vcxproj index d3ebcd2cdd..b18a5595b0 100644 --- a/Samples/ApplicationResources/cpp/ApplicationResources.vcxproj +++ b/Samples/ApplicationResources/cpp/ApplicationResources.vcxproj @@ -138,65 +138,65 @@ - - App.xaml + + ..\..\..\SharedContent\xaml\App.xaml - - MainPage.xaml + + ..\..\..\SharedContent\cpp\MainPage.xaml - scenario1.xaml + ..\shared\xaml\scenario1.xaml - scenario10.xaml + ..\shared\xaml\scenario10.xaml - scenario11.xaml + ..\shared\xaml\scenario11.xaml - scenario12.xaml + ..\shared\xaml\scenario12.xaml - scenario13.xaml + ..\shared\xaml\scenario13.xaml - scenario2.xaml + ..\shared\xaml\scenario2.xaml - scenario3.xaml + ..\shared\xaml\scenario3.xaml - scenario4.xaml + ..\shared\xaml\scenario4.xaml - scenario5.xaml + ..\shared\xaml\scenario5.xaml - scenario7.xaml + ..\shared\xaml\scenario7.xaml - scenario8.xaml + ..\shared\xaml\scenario8.xaml - + Designer - + Designer - - - - - - - - - - - + + + + + + + + + + + Styles\Styles.xaml @@ -207,11 +207,11 @@ - - App.xaml + + ..\..\..\SharedContent\xaml\App.xaml - - MainPage.xaml + + ..\..\..\SharedContent\cpp\MainPage.xaml Create @@ -223,37 +223,37 @@ - scenario1.xaml + ..\shared\xaml\scenario1.xaml - scenario10.xaml + ..\shared\xaml\scenario10.xaml - scenario11.xaml + ..\shared\xaml\scenario11.xaml - scenario12.xaml + ..\shared\xaml\scenario12.xaml - scenario13.xaml + ..\shared\xaml\scenario13.xaml - scenario2.xaml + ..\shared\xaml\scenario2.xaml - scenario3.xaml + ..\shared\xaml\scenario3.xaml - scenario4.xaml + ..\shared\xaml\scenario4.xaml - scenario5.xaml + ..\shared\xaml\scenario5.xaml - scenario7.xaml + ..\shared\xaml\scenario7.xaml - scenario8.xaml + ..\shared\xaml\scenario8.xaml diff --git a/Samples/ApplicationResources/cpp/ApplicationResources.vcxproj.filters b/Samples/ApplicationResources/cpp/ApplicationResources.vcxproj.filters index f649731e3a..98771b72ba 100644 --- a/Samples/ApplicationResources/cpp/ApplicationResources.vcxproj.filters +++ b/Samples/ApplicationResources/cpp/ApplicationResources.vcxproj.filters @@ -37,11 +37,11 @@ - + - - + + @@ -58,8 +58,8 @@ - - + + @@ -77,21 +77,21 @@ - + Styles - - - - - - - - - - - + + + + + + + + + + + diff --git a/Samples/ApplicationResources/cpp/MainPage.xaml b/Samples/ApplicationResources/cpp/MainPage.xaml deleted file mode 100644 index dd2159c70c..0000000000 --- a/Samples/ApplicationResources/cpp/MainPage.xaml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Samples/ApplicationResources/cpp/MainPage.xaml.cpp b/Samples/ApplicationResources/cpp/MainPage.xaml.cpp deleted file mode 100644 index 3fd41b2195..0000000000 --- a/Samples/ApplicationResources/cpp/MainPage.xaml.cpp +++ /dev/null @@ -1,137 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#include "pch.h" -#include "MainPage.xaml.h" - -using namespace SDKTemplate; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Navigation; -using namespace Windows::UI::Xaml::Interop; - -// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 - -MainPage^ MainPage::Current = nullptr; - -MainPage::MainPage() -{ - InitializeComponent(); - SampleTitle->Text = FEATURE_NAME; - - // This is a static public property that allows downstream pages to get a handle to the MainPage instance - // in order to call methods that are in this class. - MainPage::Current = this; -} - -void MainPage::OnNavigatedTo(NavigationEventArgs^ e) -{ - // Populate the ListBox with the scenarios as defined in SampleConfiguration.cpp. - auto itemCollection = ref new Platform::Collections::Vector(); - int i = 1; - for (auto const& s : MainPage::Current->scenarios) - { - // Create a textBlock to hold the content and apply the ListItemTextStyle from Styles.xaml - TextBlock^ textBlock = ref new TextBlock(); - ListBoxItem^ item = ref new ListBoxItem(); - auto style = App::Current->Resources->Lookup("ListItemTextStyle"); - - textBlock->Text = (i++).ToString() + ") " + s.Title; - textBlock->Style = safe_cast(style); - - item->Name = s.ClassName; - item->Content = textBlock; - itemCollection->Append(item); - } - - // Set the newly created itemCollection as the ListBox ItemSource. - ScenarioControl->ItemsSource = itemCollection; - int startingScenarioIndex; - - if (Window::Current->Bounds.Width < 640) - { - startingScenarioIndex = -1; - } - else - { - startingScenarioIndex = 0; - } - - ScenarioControl->SelectedIndex = startingScenarioIndex; - ScenarioControl->ScrollIntoView(ScenarioControl->SelectedItem); -} - - -void MainPage::ScenarioControl_SelectionChanged(Object^ sender, SelectionChangedEventArgs^ e) -{ - ListBox^ scenarioListBox = safe_cast(sender); //as ListBox; - ListBoxItem^ item = dynamic_cast(scenarioListBox->SelectedItem); - if (item != nullptr) - { - // Clear the status block when changing scenarios - NotifyUser("", NotifyType::StatusMessage); - - // Navigate to the selected scenario. - TypeName scenarioType = { item->Name, TypeKind::Custom }; - ScenarioFrame->Navigate(scenarioType, this); - - if (Window::Current->Bounds.Width < 640) - { - Splitter->IsPaneOpen = false; - } - } -} - -void MainPage::NotifyUser(String^ strMessage, NotifyType type) -{ - switch (type) - { - case NotifyType::StatusMessage: - StatusBorder->Background = ref new SolidColorBrush(Windows::UI::Colors::Green); - break; - case NotifyType::ErrorMessage: - StatusBorder->Background = ref new SolidColorBrush(Windows::UI::Colors::Red); - break; - default: - break; - } - StatusBlock->Text = strMessage; - - // Collapse the StatusBlock if it has no text to conserve real estate. - if (StatusBlock->Text != "") - { - StatusBorder->Visibility = Windows::UI::Xaml::Visibility::Visible; - StatusPanel->Visibility = Windows::UI::Xaml::Visibility::Visible; - } - else - { - StatusBorder->Visibility = Windows::UI::Xaml::Visibility::Collapsed; - StatusPanel->Visibility = Windows::UI::Xaml::Visibility::Collapsed; - } -} - -void MainPage::Footer_Click(Object^ sender, RoutedEventArgs^ e) -{ - auto uri = ref new Uri((String^)((HyperlinkButton^)sender)->Tag); - Windows::System::Launcher::LaunchUriAsync(uri); -} - -void MainPage::Button_Click(Object^ sender, RoutedEventArgs^ e) -{ - Splitter->IsPaneOpen = !Splitter->IsPaneOpen; -} diff --git a/Samples/ApplicationResources/cpp/MainPage.xaml.h b/Samples/ApplicationResources/cpp/MainPage.xaml.h deleted file mode 100644 index 84866e56fd..0000000000 --- a/Samples/ApplicationResources/cpp/MainPage.xaml.h +++ /dev/null @@ -1,45 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#pragma once - -#include "MainPage.g.h" -#include "SampleConfiguration.h" - -namespace SDKTemplate -{ - public enum class NotifyType - { - StatusMessage, - ErrorMessage - }; - - /// - /// An empty page that can be used on its own or navigated to within a Frame. - /// - public ref class MainPage sealed - { - public: - MainPage(); - - protected: - virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override; - - private: - void ScenarioControl_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e); - void Footer_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); - void Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); - - internal: - static MainPage^ Current; - void NotifyUser(Platform::String^ strMessage, NotifyType type); - }; -} diff --git a/Samples/ApplicationResources/cpp/Package.appxmanifest b/Samples/ApplicationResources/cpp/Package.appxmanifest index 284eab8ba1..8a644e7b1b 100644 --- a/Samples/ApplicationResources/cpp/Package.appxmanifest +++ b/Samples/ApplicationResources/cpp/Package.appxmanifest @@ -1,6 +1,6 @@  - + ms-resource:displayNameCPP diff --git a/Samples/ApplicationResources/cpp/scenario10.xaml b/Samples/ApplicationResources/cpp/scenario10.xaml deleted file mode 100644 index 528a1fc961..0000000000 --- a/Samples/ApplicationResources/cpp/scenario10.xaml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - Resources can depend on many different dimensions, including scale, language and - contrast. The resource management system does appropriate fallback behavior to retrieve - the most appropriate resource for the current context. The resource qualifiers are - evaluated in a priority based system (e.g., language is more important than scale). - Application developers are encouraged to mark resources as appropriately as possible. - Only resources that are appropriate for all contexts should be left without any - qualifiers. Default resources are qualified resources that are chosen if no resource - matches the context. The default language can be set by manually editing the .csproj file in a text editor. - - - This sample shows a list of string resources and the ordered set of resource candidates - for different languages, scales, etc. Various contexts can be simulated with the - drop-down below to see which resources are matched in various situations. Each candidate - has additional metadata that can used to determine why it was chosen. - - - To view a resource that has been loaded inline in a different combination of qualifiers, choose the qualifier value below and click Show Message. - - - - - - English (United Kingdom) - English (United States) - French (France) - French (Canada) - German (Germany) - - - - - - - - - - - - - - - - - - - - - - World - Americas - Asia - Northern America - Latin America and the Caribbean - United States of America - - - - -