diff --git a/README.md b/README.md index f833841027..107e6a5cad 100644 --- a/README.md +++ b/README.md @@ -268,75 +268,72 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github. -### Devices and sensors +### Devices, sensors, and power - - - - - + - + - + - + - + - + - + - + - + - + + + + + - - -
Accelerometer Activity detection sensorAllJoyn consumer experiences
AllJoyn producer experiences AltimeterBackground sensors
Background sensors Barcode scanner Barcode scanner providerBarometer
Barometer Bluetooth advertisement Bluetooth Low EnergyCash drawer
Cash drawer Compass Custom HID deviceCustom sensors
Custom sensors Custom serial device Custom USB deviceDevice enumeration and pairing
Device enumeration and pairing General Purpose Input/Output (GPIO) GyrometerInclinometer
Inclinometer Inter-Integrated Circuit (I2C) Lamp arrayLamp device
Lamp device Light sensor Line displayMagnetometer
Magnetometer Magnetic stripe reader Near field communication (NFC)NFC enterprise provisioner
NFC enterprise provisioner Orientation sensor PedometerPOS printer
POS printerPower grid forecast Presence sensor
Proximity sensor Radial controllerRelative inclinometer
Relative inclinometer Serial Arduino Serial Peripheral Interface (SPI)
Simple orientation sensor
@@ -450,14 +447,15 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github. Lock screen personalization Microsoft Passport and Windows Hello - Smart cards + Personal Data Encryption + Smart cards User information UserCertificateStore - UserConsentVerifier + UserConsentVerifier Web account management WebAuthenticationBroker diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/AllJoynHelpers.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/AllJoynHelpers.h deleted file mode 100644 index 360af60c5d..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/AllJoynHelpers.h +++ /dev/null @@ -1,277 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -// The amount of time to wait (ms) for a response after sending a message before timing out. -const int c_MessageTimeoutInMilliseconds = 10000; - -// The maximum length of an AllJoyn type signature allowed by the AllJoyn Core library. -const int c_MaximumSignatureLength = 255; - -#define RETURN_IF_QSTATUS_ERROR(status) \ -{ \ -int32 alljoynStatus = static_cast(status); \ -if (Windows::Devices::AllJoyn::AllJoynStatus::Ok != alljoynStatus) \ -{ \ - return status; \ -} \ -} - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -public interface class ISignalEmitter -{ - property Windows::Devices::AllJoyn::AllJoynBusObject^ BusObject - { - Windows::Devices::AllJoyn::AllJoynBusObject^ get(); - } - - property Windows::Devices::AllJoyn::AllJoynSession^ Session - { - Windows::Devices::AllJoyn::AllJoynSession^ get(); - } -}; - -} } } } - -class AllJoynHelpers -{ -public: - // The Windows::Devices::AllJoyn::AllJoynBusAttachment class wraps the alljoyn_busattachment type. This - // function gets the underlying alljoyn_busattachment. - static alljoyn_busattachment GetInternalBusAttachment(_In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment); - - // The Windows::Devices::AllJoyn::AllJoynBusObject class wraps the alljoyn_busobject type. This - // function gets the underlying alljoyn_busobject. - static alljoyn_busobject AllJoynHelpers::GetInternalBusObject(_In_ Windows::Devices::AllJoyn::AllJoynBusObject^ busObject); - - // Create the alljoyn_interfacedescriptions described in introspectionXml and add them to the busAttachment. - static QStatus CreateInterfaces(_Inout_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment, _In_ PCSTR introspectionXml); - - // Convert a UTF8 string to a wide character Platform::String. - static Platform::String^ MultibyteToPlatformString(_In_ PCSTR); - - // Convert a wide character Platform::String to a UTF8 string. - static std::vector PlatformToMultibyteString(_In_ Platform::String^ str); - - // Get the service object path from an objectDescriptionArg. The objectDescriptionArg should - // come from an Announce signal. - static Platform::String^ GetObjectPath(_In_ alljoyn_aboutobjectdescription objectDescription, _In_ PCSTR interfaceName); - - // Determine whether the supplied set of AuthenticationMechanisms is sufficient for securing an AllJoyn connection. - static bool CanSecure(_In_ Windows::Foundation::Collections::IVector^ authenticationMechanisms); - - // Callback for alljoyn_proxybusobject_listener_propertieschanged_ptr. - // This callback expects the context to be of type T, which must implement the OnPropertyChanged function. - template - static void AJ_CALL PropertyChangedHandler(_In_ alljoyn_proxybusobject obj, _In_ PCSTR interfaceName, _In_ const alljoyn_msgarg changed, _In_ const alljoyn_msgarg invalidated, _In_ void* context) - { - T^ caller = static_cast(context)->Resolve(); - caller->OnPropertyChanged(obj, interfaceName, changed, invalidated); - } - - // Callback for alljoyn_busobject_prop_get_ptr. - template - static QStatus AJ_CALL PropertyGetHandler(_In_ const void* context, _In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg value) - { - T^ caller = static_cast(context)->Resolve(); - return caller->OnPropertyGet(interfaceName, propertyName, value); - } - - // Callback for alljoyn_busobject_prop_set_ptr. - template - static QStatus AJ_CALL PropertySetHandler(_In_ const void* context, _In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg value) - { - T^ caller = static_cast(context)->Resolve(); - return caller->OnPropertySet(interfaceName, propertyName, value); - } - - // Callback for alljoyn_sessionlistener_sessionlost_ptr. - template - static void AJ_CALL SessionLostHandler(_In_ const void* context, _In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason) - { - T^ caller = static_cast(context)->Resolve(); - caller->OnSessionLost(sessionId, reason); - } - - // Callback for alljoyn_sessionlistener_sessionmemberadded_ptr. - template - static void AJ_CALL SessionMemberAddedHandler(_In_ const void* context, _In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName) - { - T^ caller = static_cast(context)->Resolve(); - caller->OnSessionMemberAdded(sessionId, uniqueName); - } - - // Callback for alljoyn_sessionlistener_sessionmemberremoved_ptr. - template - static void AJ_CALL SessionMemberRemovedHandler(_In_ const void* context, _In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName) - { - T^ caller = static_cast(context)->Resolve(); - caller->OnSessionMemberRemoved(sessionId, uniqueName); - } - - // Create an AllJoyn bus object. - template - static QStatus CreateBusObject(_Inout_ Platform::WeakReference* target) - { - alljoyn_busobject_callbacks callbacks = - { - PropertyGetHandler, - PropertySetHandler, - nullptr, - nullptr, - }; - - T^ caller = target->Resolve(); - - auto serviceObjectPath = PlatformToMultibyteString(caller->ServiceObjectPath); - alljoyn_busobject busObject = alljoyn_busobject_create(serviceObjectPath.data(), false, &callbacks, target); - if (busObject == nullptr) - { - return ER_FAIL; - } - - caller->BusObject = busObject; - - return ER_OK; - } - - // Callback for alljoyn_sessionportlistener_acceptsessionjoiner_ptr. - // This callback expects the context to be of type T, which must implement the OnAcceptSessionJoiner function. - template - static QCC_BOOL AJ_CALL AcceptSessionJoinerHandler( - _In_ const void* context, - _In_ alljoyn_sessionport sessionPort, - _In_ PCSTR joiner, - _In_ const alljoyn_sessionopts opts) - { - T^ caller = static_cast(context)->Resolve(); - return caller->OnAcceptSessionJoiner(sessionPort, joiner, opts); - } - - // Callback for alljoyn_sessionportlistener_sessionjoined_ptr. - // This callback expects the context to be of type T, which must implement the OnSessionJoined function. - template - static void AJ_CALL SessionJoinedHandler( - _In_ const void* context, - _In_ alljoyn_sessionport sessionPort, - _In_ alljoyn_sessionid id, - _In_ PCSTR joiner) - { - T^ caller = static_cast(context)->Resolve(); - caller->OnSessionJoined(sessionPort, id, joiner); - } - - // Create the session for an AllJoyn producer. - template - static QStatus CreateProducerSession(_Inout_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment, _Inout_ Platform::WeakReference* target) - { - alljoyn_sessionopts opts = alljoyn_sessionopts_create(ALLJOYN_TRAFFIC_TYPE_MESSAGES, true, ALLJOYN_PROXIMITY_ANY, ALLJOYN_TRANSPORT_ANY); - - alljoyn_sessionportlistener_callbacks callbacks = - { - AcceptSessionJoinerHandler, - SessionJoinedHandler - }; - - T^ producer = target->Resolve(); - producer->SessionPortListener = alljoyn_sessionportlistener_create(&callbacks, target); - - alljoyn_sessionport sessionPort = 42; - alljoyn_busattachment_unbindsessionport(AllJoynHelpers::GetInternalBusAttachment(busAttachment), sessionPort); - RETURN_IF_QSTATUS_ERROR(alljoyn_busattachment_bindsessionport(AllJoynHelpers::GetInternalBusAttachment(busAttachment), &sessionPort, opts, producer->SessionPortListener)); - producer->SessionPort = sessionPort; - - alljoyn_sessionopts_destroy(opts); - - return ER_OK; - } -}; - -// Passed to property get callbacks to allow them to report when the async operation is completed. -template -class PropertyGetContext -{ -public: - void SetEvent() - { - m_event.set(); - } - - void Wait() - { - m_event.wait(); - } - - QStatus GetStatus() - { - return m_status; - } - - void SetStatus(QStatus value) - { - m_status = value; - } - - T GetValue() - { - return m_value; - } - - void SetValue(T value) - { - m_value = value; - } - -private: - Concurrency::event m_event; - QStatus m_status; - T m_value; -}; - -// Passed to property set callbacks to allow them to report when the async operation is completed. -class PropertySetContext -{ -public: - void SetEvent() - { - m_event.set(); - } - - void Wait() - { - m_event.wait(); - } - - QStatus GetStatus() - { - return m_status; - } - - void SetStatus(QStatus value) - { - m_status = value; - } - -private: - Concurrency::event m_event; - QStatus m_status; -}; diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h deleted file mode 100644 index 14b2c214bb..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h +++ /dev/null @@ -1,46 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -public interface class ISecureInterfaceService -{ -public: - // "Concatenate two input strings and returns the concatenated string as output" - // Implement this function to handle calls to the Concatenate method. - Windows::Foundation::IAsyncOperation^ ConcatenateAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info , _In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2); - - // "Determine if the output of the Concatenate method is returned as upper case string or not" - // Implement this function to handle requests for the value of the IsUpperCaseEnabled property. - // - // Currently, info will always be null, because no information is available about the requestor. - Windows::Foundation::IAsyncOperation^ GetIsUpperCaseEnabledAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - // "Determine if the output of the Concatenate method is returned as upper case string or not" - // Implement this function to handle requests to set the IsUpperCaseEnabled property. - // - // Currently, info will always be null, because no information is available about the requestor. - Windows::Foundation::IAsyncOperation^ SetIsUpperCaseEnabledAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info, bool value); - -}; - -} } } } diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1IntrospectionXml.xml b/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1IntrospectionXml.xml deleted file mode 100644 index 366ad9383e..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1IntrospectionXml.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - A secure AllJoyn sample - - - Concatenate two input strings and returns the concatenated string as output - - - - - - Determine if the output of the Concatenate method is returned as upper case string or not - - - - This signal is emitted when producer sends a text message to consumer - - - - diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj b/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj deleted file mode 100644 index be19353746..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj +++ /dev/null @@ -1,262 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), LICENSE))\SharedContent - - - {cd05b6af-4bcf-55b1-b08c-45a3343a3664} - WindowsRuntimeComponent - Scenario1WinRTComponent - com.microsoft.Samples.SecureInterface - en-US - 14.0 - true - Windows Store - 10.0.22621.0 - 10.0.22621.0 - 10.0 - true - - - - DynamicLibrary - true - - - DynamicLibrary - true - - - DynamicLibrary - true - - - DynamicLibrary - false - true - true - - - DynamicLibrary - false - true - true - - - DynamicLibrary - false - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - $(VC_IncludePath);$(UniversalCRT_IncludePath);$(WindowsSDK_IncludePath);..\..\shared - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj.filters b/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj.filters deleted file mode 100644 index c0e053639e..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj.filters +++ /dev/null @@ -1,37 +0,0 @@ - - - - - aa05969e-0ba6-407c-9c26-91ed00b63b8b - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp deleted file mode 100644 index f65069e25c..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp +++ /dev/null @@ -1,429 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace concurrency; -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Devices::AllJoyn; -using namespace com::microsoft::Samples::SecureInterface; - -std::map SecureInterfaceConsumer::SourceInterfaces; -PCSTR SecureInterfaceConsumer::m_interfaceName = "com.microsoft.Samples.SecureInterface"; - -SecureInterfaceConsumer::SecureInterfaceConsumer(AllJoynBusAttachment^ busAttachment) - : m_busAttachment(busAttachment), - m_proxyBusObject(nullptr), - m_busObject(nullptr) -{ - m_weak = new WeakReference(this); - m_signals = ref new SecureInterfaceSignals(); - m_nativeBusAttachment = AllJoynHelpers::GetInternalBusAttachment(m_busAttachment); - - GUID result; - HRESULT hr = CoCreateGuid(&result); - - if (FAILED(hr)) - { - throw ref new Exception(hr); - } - - // The consumer needs a bus object to share signals, and its object path must be unique in - // case multiple consumers are created using the same bus attachment. - Guid gd(result); - ServiceObjectPath = gd.ToString(); -} - -SecureInterfaceConsumer::~SecureInterfaceConsumer() -{ - if (nullptr != ProxyBusObject) - { - alljoyn_proxybusobject_destroy(ProxyBusObject); - } - delete m_weak; -} - -QStatus SecureInterfaceConsumer::AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler) -{ - alljoyn_interfacedescription_member member; - if (!alljoyn_interfacedescription_getmember(interfaceDescription, methodName, &member)) - { - return ER_BUS_INTERFACE_NO_SUCH_MEMBER; - } - - return alljoyn_busattachment_registersignalhandler(busAttachment, handler, member, NULL); -} - -IAsyncOperation^ SecureInterfaceConsumer::FromIdAsync(_In_ Platform::String^ deviceId) -{ - return SecureInterfaceConsumer::FromIdAsync(deviceId, AllJoynBusAttachment::GetDefault()); -} - -IAsyncOperation^ SecureInterfaceConsumer::FromIdAsync(_In_ Platform::String^ deviceId, _In_ AllJoynBusAttachment^ busAttachment) -{ - return create_async([deviceId, busAttachment]() -> SecureInterfaceConsumer^ - { - SecureInterfaceConsumer^ result; - create_task(AllJoynServiceInfo::FromIdAsync(deviceId)).then([busAttachment, &result](AllJoynServiceInfo^ serviceInfo) - { - if (serviceInfo != nullptr) - { - int32 status = AllJoynStatus::Ok; - if (busAttachment->State == AllJoynBusAttachmentState::Disconnected) - { - event connectedEvent; - auto token = busAttachment->StateChanged += ref new TypedEventHandler([&connectedEvent](AllJoynBusAttachment^, AllJoynBusAttachmentStateChangedEventArgs^ arg) - { - if (arg->State == AllJoynBusAttachmentState::Connected) - { - connectedEvent.set(); - } - }); - - status = AllJoynHelpers::CreateInterfaces(busAttachment, c_SecureInterfaceIntrospectionXml); - if (status == AllJoynStatus::Ok) - { - busAttachment->Connect(); - connectedEvent.wait(); - } - busAttachment->StateChanged -= token; - } - - if (status == AllJoynStatus::Ok) - { - auto consumer = ref new SecureInterfaceConsumer(busAttachment); - status = consumer->Initialize(serviceInfo); - if (status == AllJoynStatus::Ok) - { - result = consumer; - } - } - } - }).wait(); - - return result; - }); -} - -IAsyncOperation^ SecureInterfaceConsumer::ConcatenateAsync(_In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2) -{ - return create_async([this, interfaceMemberInStr1, interfaceMemberInStr2]() -> SecureInterfaceConcatenateResult^ - { - auto result = ref new SecureInterfaceConcatenateResult(); - - alljoyn_message message = alljoyn_message_create(m_nativeBusAttachment); - size_t argCount = 2; - alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount); - - 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, - m_interfaceName, - "Concatenate", - inputs, - argCount, - message, - c_MessageTimeoutInMilliseconds, - 0); - } - result->Status = static_cast(status); - if (ER_OK == status) - { - result->Status = AllJoynStatus::Ok; - Platform::String^ argument0; - status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &argument0)); - result->OutStr = argument0; - - if (ER_OK != status) - { - result->Status = static_cast(status); - } - } - else if (ER_BUS_REPLY_IS_ERROR_MESSAGE == status) - { - alljoyn_msgarg errorArg = alljoyn_message_getarg(message, 1); - if (nullptr != errorArg) - { - uint16 errorStatus; - status = alljoyn_msgarg_get_uint16(errorArg, &errorStatus); - if (ER_OK == status) - { - status = static_cast(errorStatus); - } - } - result->Status = static_cast(status); - } - - alljoyn_message_destroy(message); - alljoyn_msgarg_destroy(inputs); - - return result; - }); -} - -IAsyncOperation^ SecureInterfaceConsumer::SetIsUpperCaseEnabledAsync(_In_ bool value) -{ - return create_async([this, value]() -> SecureInterfaceSetIsUpperCaseEnabledResult^ - { - PropertySetContext setContext; - - alljoyn_msgarg inputArgument = alljoyn_msgarg_create(); - QStatus status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(inputArgument, "b", value)); - if (ER_OK == status) - { - status = alljoyn_proxybusobject_setpropertyasync( - ProxyBusObject, - m_interfaceName, - "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); - - setContext.Wait(); - } - if (ER_OK == status) - { - return SecureInterfaceSetIsUpperCaseEnabledResult::CreateSuccessResult(); - } - return SecureInterfaceSetIsUpperCaseEnabledResult::CreateFailureResult(static_cast(status)); - }); -} - -IAsyncOperation^ SecureInterfaceConsumer::GetIsUpperCaseEnabledAsync() -{ - return create_async([this]() -> SecureInterfaceGetIsUpperCaseEnabledResult^ - { - PropertyGetContext getContext; - - alljoyn_proxybusobject_getpropertyasync( - ProxyBusObject, - m_interfaceName, - "IsUpperCaseEnabled", - [](QStatus status, alljoyn_proxybusobject obj, const alljoyn_msgarg value, void* context) - { - UNREFERENCED_PARAMETER(obj); - auto propertyContext = static_cast*>(context); - - if (ER_OK == status) - { - bool argument; - status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(value, "b", &argument)); - - propertyContext->SetValue(argument); - } - propertyContext->SetStatus(status); - propertyContext->SetEvent(); - }, - c_MessageTimeoutInMilliseconds, - &getContext); - - getContext.Wait(); - - auto result = ref new SecureInterfaceGetIsUpperCaseEnabledResult(); - result->Status = getContext.GetStatus(); - result->IsUpperCaseEnabled = getContext.GetValue(); - return result; - }); -} - -void SecureInterfaceConsumer::OnPropertyChanged(_In_ alljoyn_proxybusobject obj, _In_ PCSTR interfaceName, _In_ const alljoyn_msgarg changed, _In_ const alljoyn_msgarg invalidated) -{ - UNREFERENCED_PARAMETER(obj); - UNREFERENCED_PARAMETER(interfaceName); - UNREFERENCED_PARAMETER(invalidated); - - alljoyn_msgarg changedProperties; - size_t changedPropertyCount; - if (ER_OK != alljoyn_msgarg_get(changed, "a{sv}", &changedPropertyCount, &changedProperties)) - { - return; - } - - for (size_t i = 0; i < changedPropertyCount; i++) - { - char* propertyName; - alljoyn_msgarg propertyValue; - if (ER_OK != alljoyn_msgarg_get(alljoyn_msgarg_array_element(changedProperties, i), "{sv}", &propertyName, &propertyValue)) - { - return; - } - - - if (strcmp("IsUpperCaseEnabled", propertyName) == 0) - { - bool argument; - (void)TypeConversionHelpers::GetAllJoynMessageArg(propertyValue, "b", &argument); - IsUpperCaseEnabledChanged(this, (Platform::Object^)argument); - } - } -} - -void SecureInterfaceConsumer::CallTextSentSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message) -{ - auto source = SourceInterfaces.find(member->iface); - if (source == SourceInterfaces.end()) - { - return; - } - - auto consumer = source->second->Resolve(); - if (consumer->Signals != nullptr) - { - auto callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - auto eventArgs = ref new SecureInterfaceTextSentReceivedEventArgs(); - eventArgs->MessageInfo = callInfo; - - Platform::String^ argument0; - (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &argument0); - - eventArgs->Message = argument0; - - consumer->Signals->CallTextSentReceived(consumer->Signals, eventArgs); - } -} - -int32 SecureInterfaceConsumer::Initialize(_In_ AllJoynServiceInfo^ serviceInfo) -{ - std::vector sessionNameUtf8 = AllJoynHelpers::PlatformToMultibyteString(serviceInfo->UniqueName); - - ServiceObjectPath = serviceInfo->ObjectPath; - std::vector objectPath = AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath); - - RETURN_IF_QSTATUS_ERROR(AllJoynHelpers::CreateInterfaces(m_busAttachment, c_SecureInterfaceIntrospectionXml)); - - m_session = create_task(AllJoynSession::GetFromServiceInfoAsync(serviceInfo, m_busAttachment)).get(); - if (nullptr == m_session) - { - return AllJoynStatus::Fail; - } - else if (m_session->Status != AllJoynStatus::Ok) - { - return m_session->Status; - } - - if (objectPath.empty()) - { - return AllJoynStatus::Fail; - } - - ProxyBusObject = alljoyn_proxybusobject_create(m_nativeBusAttachment, &sessionNameUtf8[0], &objectPath[0], m_session->Id); - if (nullptr == ProxyBusObject) - { - return AllJoynStatus::Fail; - } - - PCSTR propertyNames[] = { "IsUpperCaseEnabled" }; - - RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_registerpropertieschangedlistener( - ProxyBusObject, - m_interfaceName, - propertyNames, - _countof(propertyNames), - AllJoynHelpers::PropertyChangedHandler, - m_weak)); - - - alljoyn_interfacedescription description = alljoyn_busattachment_getinterface(m_nativeBusAttachment, m_interfaceName); - if (nullptr == description) - { - return AllJoynStatus::Fail; - } - - m_busObject = ref new Windows::Devices::AllJoyn::AllJoynBusObject(ServiceObjectPath, m_busAttachment); - m_nativeBusObject = AllJoynHelpers::GetInternalBusObject(m_busObject); - - QStatus status = alljoyn_busobject_addinterface(m_nativeBusObject, description); - if ((status != ER_OK) && (status != ER_BUS_IFACE_ALREADY_EXISTS)) - { - return status; - } - - - 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); - - // If the current set of AuthenticationMechanisms supports authentication, - // determine whether to secure the connection. - if (AllJoynHelpers::CanSecure(m_busAttachment->AuthenticationMechanisms)) - { - // Secure the connection if the org.alljoyn.Bus.Secure XML annotation - // is specified, or if None is not present in AuthenticationMechanisms. - if (!authenticationMechanismsContainsNone || interfaceIsSecure) - { - RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_secureconnection(ProxyBusObject, QCC_FALSE)); - m_busObject->Start(); - } - else - { - m_busObject->Start(); - } - } - else - { - // If the current set of AuthenticationMechanisms does not support authentication - // but the interface requires security, report an error. - if (interfaceIsSecure) - { - return static_cast(ER_BUS_NO_AUTHENTICATION_MECHANISM); - } - else - { - m_busObject->Start(); - } - } - - RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_addinterface(ProxyBusObject, description)); - - m_signals->Initialize(this); - - return AllJoynStatus::Ok; -} diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h deleted file mode 100644 index 50cb866700..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h +++ /dev/null @@ -1,170 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -public interface class ISecureInterfaceConsumer -{ - event Windows::Foundation::TypedEventHandler^ IsUpperCaseEnabledChanged; -}; - -public ref class SecureInterfaceConsumer sealed : [Windows::Foundation::Metadata::Default] ISecureInterfaceConsumer, ISignalEmitter -{ -public: - SecureInterfaceConsumer(Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment); - virtual ~SecureInterfaceConsumer(); - - // Create a consumer from a device Id asynchronously. - // - // This is usually called to create a consumer after the unique name of a producer has been reported - // in the Added callback on the DeviceWatcher. - static Windows::Foundation::IAsyncOperation^ FromIdAsync(_In_ Platform::String^ deviceId); - - // Create a consumer from a device Id asynchronously with the provided bus attachment. - // - // This is usually called to create a consumer after the unique name of a producer has been reported - // in the Added callback on the DeviceWatcher. - static Windows::Foundation::IAsyncOperation^ FromIdAsync(_In_ Platform::String^ deviceId, _In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment); - - int32 SecureInterfaceConsumer::Initialize(_In_ Windows::Devices::AllJoyn::AllJoynServiceInfo^ serviceInfo); - - // "Concatenate two input strings and returns the concatenated string as output" - // 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 - { - 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); - } - } - - // "Determine if the output of the Concatenate method is returned as upper case string or not" - // Get the value of the IsUpperCaseEnabled property. - Windows::Foundation::IAsyncOperation^ GetIsUpperCaseEnabledAsync(); - - // "Determine if the output of the Concatenate method is returned as upper case string or not" - // Set the value of the IsUpperCaseEnabled property. - Windows::Foundation::IAsyncOperation^ SetIsUpperCaseEnabledAsync(_In_ bool value); - - // Used to send signals or register functions to handle received signals. - property SecureInterfaceSignals^ Signals - { - SecureInterfaceSignals^ get() { return m_signals; } - } - - // Used to get the name of the interface this consumer implements. - static property Platform::String^ InterfaceName - { - Platform::String^ get() { return AllJoynHelpers::MultibyteToPlatformString(m_interfaceName); } - } - - virtual property Windows::Devices::AllJoyn::AllJoynBusObject^ BusObject - { - Windows::Devices::AllJoyn::AllJoynBusObject^ get() { return m_busObject; } - } - - virtual property Windows::Devices::AllJoyn::AllJoynSession^ Session - { - Windows::Devices::AllJoyn::AllJoynSession^ get() { return m_session; } - } - -internal: - // Consumers do not support property get. - QStatus OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg val) - { - UNREFERENCED_PARAMETER(interfaceName); UNREFERENCED_PARAMETER(propertyName); UNREFERENCED_PARAMETER(val); - return ER_NOT_IMPLEMENTED; - } - - // Consumers do not support property set. - QStatus OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg val) - { - UNREFERENCED_PARAMETER(interfaceName); UNREFERENCED_PARAMETER(propertyName); UNREFERENCED_PARAMETER(val); - return ER_NOT_IMPLEMENTED; - } - - void OnPropertyChanged(_In_ alljoyn_proxybusobject obj, _In_ PCSTR interfaceName, _In_ const alljoyn_msgarg changed, _In_ const alljoyn_msgarg invalidated); - - property Platform::String^ ServiceObjectPath - { - Platform::String^ get() { return m_ServiceObjectPath; } - void set(Platform::String^ value) { m_ServiceObjectPath = value; } - } - - property alljoyn_proxybusobject ProxyBusObject - { - alljoyn_proxybusobject get() { return m_proxyBusObject; } - void set(alljoyn_proxybusobject value) { m_proxyBusObject = value; } - } - -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; - - // Register a callback function to handle incoming signals. - QStatus AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler); - - // "This signal is emitted when producer sends a text message to consumer" - static void CallTextSentSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message); - - Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment; - Windows::Devices::AllJoyn::AllJoynBusObject^ m_busObject; - Windows::Devices::AllJoyn::AllJoynSession^ m_session; - SecureInterfaceSignals^ m_signals; - Platform::String^ m_ServiceObjectPath; - - alljoyn_proxybusobject m_proxyBusObject; - alljoyn_sessionlistener m_sessionListener; - alljoyn_busobject m_nativeBusObject; - alljoyn_busattachment m_nativeBusAttachment; - - // Used to pass a pointer to this class to callbacks - Platform::WeakReference* m_weak; - - // This map is required because we need a way to pass the consumer to the signal - // handlers, but the current AllJoyn C API does not allow passing a context to these - // callbacks. - static std::map SourceInterfaces; - - // The name of the interface this consumer implements. - static PCSTR m_interfaceName; -}; - -} } } } diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceEventArgs.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceEventArgs.h deleted file mode 100644 index 5711a7a189..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceEventArgs.h +++ /dev/null @@ -1,50 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -// Signals -// "This signal is emitted when producer sends a text message to consumer" -public ref class SecureInterfaceTextSentReceivedEventArgs sealed -{ -public: - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - void set(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ value) { m_messageInfo = value; } - } - - property Platform::String^ Message - { - Platform::String^ get() { return m_interfaceMemberMessage; } - internal: - void set(_In_ Platform::String^ value) { m_interfaceMemberMessage = value; } - } - -private: - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - - Platform::String^ m_interfaceMemberMessage; -}; - - -} } } } diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.cpp deleted file mode 100644 index 5d17129347..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.cpp +++ /dev/null @@ -1,67 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Devices::AllJoyn; -using namespace Windows::Foundation; -using namespace com::microsoft::Samples::SecureInterface; - -void SecureInterfaceLegacySignals::Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId) -{ - m_busObject = busObject; - m_sessionId = sessionId; - - auto interfaceDefinition = alljoyn_busattachment_getinterface(alljoyn_busobject_getbusattachment(busObject), "com.microsoft.Samples.SecureInterface"); - alljoyn_interfacedescription_getmember(interfaceDefinition, "TextSent", &m_memberTextSent); -} - -void SecureInterfaceLegacySignals::TextSent(_In_ Platform::String^ interfaceMemberMessage) -{ - if (nullptr == m_busObject) - { - return; - } - - size_t argCount = 1; - alljoyn_msgarg arguments = alljoyn_msgarg_array_create(argCount); - (void)TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "s", interfaceMemberMessage); - - alljoyn_busobject_signal( - m_busObject, - NULL, // Generated code only supports broadcast signals. - m_sessionId, - m_memberTextSent, - arguments, - argCount, - 0, // A signal with a TTL of 0 will be sent to every member of the session, regardless of how long it takes to deliver the message - ALLJOYN_MESSAGE_FLAG_GLOBAL_BROADCAST, // Broadcast to everyone in the session. - NULL); // The generated code does not need the generated signal message - - alljoyn_msgarg_destroy(arguments); -} - -void SecureInterfaceLegacySignals::CallTextSentReceived(_In_ SecureInterfaceLegacySignals^ sender, _In_ SecureInterfaceTextSentReceivedEventArgs^ args) -{ - TextSentReceived(sender, args); -} - diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.h deleted file mode 100644 index 3a8f7aafcf..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.h +++ /dev/null @@ -1,74 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -ref class SecureInterfaceLegacySignals; - -public interface class ISecureInterfaceLegacySignals -{ - event Windows::Foundation::TypedEventHandler^ TextSentReceived; -}; - -public ref class SecureInterfaceLegacySignals sealed : [Windows::Foundation::Metadata::Default] ISecureInterfaceLegacySignals -{ -public: - // "This signal is emitted when producer sends a text message to consumer" - // Calling this method will send the TextSent signal to every member of the session. - 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 - { - 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(SecureInterfaceLegacySignals^ sender, SecureInterfaceTextSentReceivedEventArgs^ args) - { - _TextSentReceived(sender, args); - } - } - -internal: - void Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId); - void CallTextSentReceived(_In_ SecureInterfaceLegacySignals^ sender, _In_ SecureInterfaceTextSentReceivedEventArgs^ args); - -private: - alljoyn_busobject m_busObject; - alljoyn_sessionid m_sessionId; - - virtual event Windows::Foundation::EventHandler^ _TextSentReceived; - - alljoyn_interfacedescription_member m_memberTextSent; -}; - -} } } } \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h deleted file mode 100644 index 5634f79b49..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h +++ /dev/null @@ -1,163 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -using namespace concurrency; - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -ref class SecureInterfaceConsumer; - -public ref class SecureInterfaceConcatenateResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - property Platform::String^ OutStr - { - Platform::String^ get() { return m_interfaceMemberOutStr; } - internal: - void set(_In_ Platform::String^ value) { m_interfaceMemberOutStr = value; } - } - - static SecureInterfaceConcatenateResult^ CreateSuccessResult(_In_ Platform::String^ interfaceMemberOutStr) - { - 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; - } - - static SecureInterfaceConcatenateResult^ CreateFailureResult(_In_ int32 status) - { - auto result = ref new SecureInterfaceConcatenateResult(); - result->Status = status; - return result; - } -internal: - Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); - -private: - int32 m_status; - Platform::String^ m_interfaceMemberOutStr; -}; - -public ref class SecureInterfaceJoinSessionResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - property SecureInterfaceConsumer^ Consumer - { - SecureInterfaceConsumer^ get() { return m_consumer; } - internal: - void set(_In_ SecureInterfaceConsumer^ value) { m_consumer = value; } - }; - -private: - int32 m_status; - SecureInterfaceConsumer^ m_consumer; -}; - -public ref class SecureInterfaceGetIsUpperCaseEnabledResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - // "Determine if the output of the Concatenate method is returned as upper case string or not" - property bool IsUpperCaseEnabled - { - bool get() { return m_value; } - internal: - void set(_In_ bool value) { m_value = value; } - } - - static SecureInterfaceGetIsUpperCaseEnabledResult^ CreateSuccessResult(_In_ bool value) - { - 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; - } - - static SecureInterfaceGetIsUpperCaseEnabledResult^ CreateFailureResult(_In_ int32 status) - { - auto result = ref new SecureInterfaceGetIsUpperCaseEnabledResult(); - result->Status = status; - return result; - } -internal: - Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); - -private: - int32 m_status; - bool m_value; -}; - -public ref class SecureInterfaceSetIsUpperCaseEnabledResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - static SecureInterfaceSetIsUpperCaseEnabledResult^ CreateSuccessResult() - { - auto result = ref new SecureInterfaceSetIsUpperCaseEnabledResult(); - result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; - result->m_creationContext = Concurrency::task_continuation_context::use_current(); - return result; - } - - static SecureInterfaceSetIsUpperCaseEnabledResult^ CreateFailureResult(_In_ int32 status) - { - auto result = ref new SecureInterfaceSetIsUpperCaseEnabledResult(); - 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 deleted file mode 100644 index 2a6078ee6a..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.cpp +++ /dev/null @@ -1,447 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace concurrency; -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Devices::AllJoyn; -using namespace com::microsoft::Samples::SecureInterface; - -std::map SecureInterfaceProducer::SourceObjects; -std::map SecureInterfaceProducer::SourceInterfaces; - -SecureInterfaceProducer::SecureInterfaceProducer(AllJoynBusAttachment^ busAttachment) - : m_busAttachment(busAttachment), - m_sessionListener(nullptr), - m_busObject(nullptr), - m_sessionPort(0), - m_sessionId(0) -{ - m_weak = new WeakReference(this); - ServiceObjectPath = ref new String(L"/Service"); - m_signals = ref new SecureInterfaceLegacySignals(); - m_busAttachmentStateChangedToken.Value = 0; -} - -SecureInterfaceProducer::~SecureInterfaceProducer() -{ - UnregisterFromBus(); - delete m_weak; -} - -void SecureInterfaceProducer::UnregisterFromBus() -{ - if ((nullptr != m_busAttachment) && (0 != m_busAttachmentStateChangedToken.Value)) - { - m_busAttachment->StateChanged -= m_busAttachmentStateChangedToken; - m_busAttachmentStateChangedToken.Value = 0; - } - if ((nullptr != m_busAttachment) && (nullptr != SessionPortListener)) - { - alljoyn_busattachment_unbindsessionport(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_sessionPort); - alljoyn_sessionportlistener_destroy(SessionPortListener); - SessionPortListener = nullptr; - } - if ((nullptr != m_busAttachment) && (nullptr != BusObject)) - { - alljoyn_busattachment_unregisterbusobject(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject); - alljoyn_busobject_destroy(BusObject); - BusObject = nullptr; - } - if ((nullptr != m_busAttachment) && (nullptr != SessionListener)) - { - alljoyn_busattachment_leavesession(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_sessionId); - alljoyn_busattachment_setsessionlistener(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_sessionId, nullptr); - alljoyn_sessionlistener_destroy(SessionListener); - SessionListener = nullptr; - } -} - -bool SecureInterfaceProducer::OnAcceptSessionJoiner(_In_ alljoyn_sessionport sessionPort, _In_ PCSTR joiner, _In_ const alljoyn_sessionopts opts) -{ - UNREFERENCED_PARAMETER(sessionPort); UNREFERENCED_PARAMETER(joiner); UNREFERENCED_PARAMETER(opts); - - return true; -} - -void SecureInterfaceProducer::OnSessionJoined(_In_ alljoyn_sessionport sessionPort, _In_ alljoyn_sessionid id, _In_ PCSTR joiner) -{ - UNREFERENCED_PARAMETER(joiner); - - // We initialize the Signals object after the session has been joined, because it needs - // the session id. - m_signals->Initialize(BusObject, id); - m_sessionPort = sessionPort; - m_sessionId = id; - - alljoyn_sessionlistener_callbacks callbacks = - { - AllJoynHelpers::SessionLostHandler, - AllJoynHelpers::SessionMemberAddedHandler, - AllJoynHelpers::SessionMemberRemovedHandler - }; - - SessionListener = alljoyn_sessionlistener_create(&callbacks, m_weak); - alljoyn_busattachment_setsessionlistener(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), id, SessionListener); -} - -void SecureInterfaceProducer::OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason) -{ - if (sessionId == m_sessionId) - { - AllJoynSessionLostEventArgs^ args = ref new AllJoynSessionLostEventArgs(static_cast(reason)); - SessionLost(this, args); - } -} - -void SecureInterfaceProducer::OnSessionMemberAdded(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName) -{ - if (sessionId == m_sessionId) - { - auto args = ref new AllJoynSessionMemberAddedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName)); - SessionMemberAdded(this, args); - } -} - -void SecureInterfaceProducer::OnSessionMemberRemoved(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName) -{ - if (sessionId == m_sessionId) - { - auto args = ref new AllJoynSessionMemberRemovedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName)); - SessionMemberRemoved(this, args); - } -} - -void SecureInterfaceProducer::BusAttachmentStateChanged(_In_ AllJoynBusAttachment^ sender, _In_ AllJoynBusAttachmentStateChangedEventArgs^ args) -{ - if (args->State == AllJoynBusAttachmentState::Connected) - { - QStatus result = AllJoynHelpers::CreateProducerSession(m_busAttachment, m_weak); - if (ER_OK != result) - { - StopInternal(result); - return; - } - } - else if (args->State == AllJoynBusAttachmentState::Disconnected) - { - StopInternal(ER_BUS_STOPPING); - } -} - -void SecureInterfaceProducer::CallConcatenateHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message) -{ - auto source = SourceObjects.find(busObject); - if (source == SourceObjects.end()) - { - return; - } - - SecureInterfaceProducer^ producer = source->second->Resolve(); - if (producer->Service != nullptr) - { - AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - - Platform::String^ inputArg0; - (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &inputArg0); - Platform::String^ inputArg1; - (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 1), "s", &inputArg1); - - SecureInterfaceConcatenateResult^ result = create_task(producer->Service->ConcatenateAsync(callInfo, inputArg0, inputArg1)).get(); - create_task([](){}).then([=] - { - int32 status; - - if (nullptr == result) - { - alljoyn_busobject_methodreply_status(busObject, message, ER_BUS_NO_LISTENER); - return; - } - - status = result->Status; - if (AllJoynStatus::Ok != status) - { - alljoyn_busobject_methodreply_status(busObject, message, static_cast(status)); - return; - } - - size_t argCount = 1; - alljoyn_msgarg outputs = alljoyn_msgarg_array_create(argCount); - - status = TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(outputs, 0), "s", result->OutStr); - if (AllJoynStatus::Ok != status) - { - alljoyn_busobject_methodreply_status(busObject, message, static_cast(status)); - alljoyn_msgarg_destroy(outputs); - return; - } - - alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount); - alljoyn_msgarg_destroy(outputs); - }, result->m_creationContext).wait(); - } -} - -void SecureInterfaceProducer::CallTextSentSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message) -{ - auto source = SourceInterfaces.find(member->iface); - if (source == SourceInterfaces.end()) - { - return; - } - - auto producer = source->second->Resolve(); - if (producer->Signals != nullptr) - { - auto callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - auto eventArgs = ref new SecureInterfaceTextSentReceivedEventArgs(); - eventArgs->MessageInfo = callInfo; - - Platform::String^ argument0; - (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &argument0); - eventArgs->Message = argument0; - - producer->Signals->CallTextSentReceived(producer->Signals, eventArgs); - } -} - -QStatus SecureInterfaceProducer::AddMethodHandler(_In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_methodhandler_ptr handler) -{ - alljoyn_interfacedescription_member member; - if (!alljoyn_interfacedescription_getmember(interfaceDescription, methodName, &member)) - { - return ER_BUS_INTERFACE_NO_SUCH_MEMBER; - } - - return alljoyn_busobject_addmethodhandler( - m_busObject, - member, - handler, - m_weak); -} - -QStatus SecureInterfaceProducer::AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler) -{ - alljoyn_interfacedescription_member member; - if (!alljoyn_interfacedescription_getmember(interfaceDescription, methodName, &member)) - { - return ER_BUS_INTERFACE_NO_SUCH_MEMBER; - } - - return alljoyn_busattachment_registersignalhandler(busAttachment, handler, member, NULL); -} - -QStatus SecureInterfaceProducer::OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg value) -{ - UNREFERENCED_PARAMETER(interfaceName); - - if (0 == strcmp(propertyName, "IsUpperCaseEnabled")) - { - auto task = create_task(Service->GetIsUpperCaseEnabledAsync(nullptr)); - auto result = task.get(); - - 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; -} - -QStatus SecureInterfaceProducer::OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg value) -{ - UNREFERENCED_PARAMETER(interfaceName); - - if (0 == strcmp(propertyName, "IsUpperCaseEnabled")) - { - bool argument; - 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; -} - -void SecureInterfaceProducer::EmitIsUpperCaseEnabledChanged() -{ - create_task([&] - { - alljoyn_msgarg value = alljoyn_msgarg_create(); - OnPropertyGet("com.microsoft.Samples.SecureInterface", "IsUpperCaseEnabled", value); - - alljoyn_busobject_emitpropertychanged( - m_busObject, - "com.microsoft.Samples.SecureInterface", - "IsUpperCaseEnabled", - value, - m_sessionId); - - alljoyn_msgarg_destroy(value); - }); -} - -void SecureInterfaceProducer::Start() -{ - if (nullptr == m_busAttachment) - { - StopInternal(ER_FAIL); - return; - } - - QStatus result = AllJoynHelpers::CreateInterfaces(m_busAttachment, c_SecureInterfaceIntrospectionXml); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - result = AllJoynHelpers::CreateBusObject(m_weak); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - alljoyn_interfacedescription interfaceDescription = alljoyn_busattachment_getinterface(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), "com.microsoft.Samples.SecureInterface"); - if (interfaceDescription == nullptr) - { - StopInternal(ER_FAIL); - return; - } - alljoyn_busobject_addinterface_announced(BusObject, interfaceDescription); - - result = AddMethodHandler( - interfaceDescription, - "Concatenate", - [](alljoyn_busobject busObject, const alljoyn_interfacedescription_member* member, alljoyn_message message) { UNREFERENCED_PARAMETER(member); CallConcatenateHandler(busObject, message); }); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - result = AddSignalHandler( - AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), - interfaceDescription, - "TextSent", - [](const alljoyn_interfacedescription_member* member, PCSTR srcPath, alljoyn_message message) { UNREFERENCED_PARAMETER(srcPath); CallTextSentSignalHandler(member, message); }); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - SourceObjects[m_busObject] = m_weak; - SourceInterfaces[interfaceDescription] = m_weak; - - unsigned int noneMechanismIndex = 0; - bool authenticationMechanismsContainsNone = m_busAttachment->AuthenticationMechanisms->IndexOf(AllJoynAuthenticationMechanism::None, &noneMechanismIndex); - QCC_BOOL interfaceIsSecure = alljoyn_interfacedescription_issecure(interfaceDescription); - - // If the current set of AuthenticationMechanisms supports authentication, - // determine whether a secure BusObject is required. - if (AllJoynHelpers::CanSecure(m_busAttachment->AuthenticationMechanisms)) - { - // Register the BusObject as "secure" if the org.alljoyn.Bus.Secure XML annotation - // is specified, or if None is not present in AuthenticationMechanisms. - if (!authenticationMechanismsContainsNone || interfaceIsSecure) - { - result = alljoyn_busattachment_registerbusobject_secure(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject); - } - else - { - result = alljoyn_busattachment_registerbusobject(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject); - } - } - else - { - // If the current set of AuthenticationMechanisms does not support authentication - // but the interface requires security, report an error. - if (interfaceIsSecure) - { - result = ER_BUS_NO_AUTHENTICATION_MECHANISM; - } - else - { - result = alljoyn_busattachment_registerbusobject(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject); - } - } - - if (result != ER_OK) - { - StopInternal(result); - return; - } - - m_busAttachmentStateChangedToken = m_busAttachment->StateChanged += ref new TypedEventHandler(this, &SecureInterfaceProducer::BusAttachmentStateChanged); - m_busAttachment->Connect(); -} - -void SecureInterfaceProducer::Stop() -{ - StopInternal(AllJoynStatus::Ok); -} - -void SecureInterfaceProducer::StopInternal(int32 status) -{ - UnregisterFromBus(); - Stopped(this, ref new AllJoynProducerStoppedEventArgs(status)); -} - -int32 SecureInterfaceProducer::RemoveMemberFromSession(_In_ String^ uniqueName) -{ - return alljoyn_busattachment_removesessionmember( - AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), - m_sessionId, - AllJoynHelpers::PlatformToMultibyteString(uniqueName).data()); -} - -PCSTR com::microsoft::Samples::SecureInterface::c_SecureInterfaceIntrospectionXml = "" -" A secure AllJoyn sample" -" " -" " -" Concatenate two input strings and returns the concatenated string as output" -" " -" " -" " -" " -" " -" Determine if the output of the Concatenate method is returned as upper case string or not" -" " -" " -" " -" This signal is emitted when producer sends a text message to consumer" -" " -" " -"" -; \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h deleted file mode 100644 index bc79c29320..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h +++ /dev/null @@ -1,246 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -extern PCSTR c_SecureInterfaceIntrospectionXml; - -ref class SecureInterfaceProducer; - -public interface class ISecureInterfaceProducer -{ - event Windows::Foundation::TypedEventHandler^ Stopped; - event Windows::Foundation::TypedEventHandler^ SessionLost; - event Windows::Foundation::TypedEventHandler^ SessionMemberAdded; - event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved; -}; - -public ref class SecureInterfaceProducer sealed : [Windows::Foundation::Metadata::Default] ISecureInterfaceProducer -{ -public: - SecureInterfaceProducer(Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment); - virtual ~SecureInterfaceProducer(); - - // The implementation of ISecureInterfaceService that will handle method calls and property requests. - property ISecureInterfaceService^ Service - { - ISecureInterfaceService^ get() { return m_serviceInterface; } - void set(ISecureInterfaceService^ value) { m_serviceInterface = value; } - } - - // Used to send signals or register functions to handle received signals. - property SecureInterfaceLegacySignals^ Signals - { - SecureInterfaceLegacySignals^ get() { return m_signals; } - } - - // This event will fire whenever this producer is 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 - { - 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 - { - 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 - { - 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(); - - // Start advertising the service. - void Start(); - - // Stop advertising the service. - void Stop(); - - // Remove a member that has joined this session. - int32 RemoveMemberFromSession(_In_ Platform::String^ uniqueName); - -internal: - bool OnAcceptSessionJoiner(_In_ alljoyn_sessionport sessionPort, _In_ PCSTR joiner, _In_ const alljoyn_sessionopts opts); - void OnSessionJoined(_In_ alljoyn_sessionport sessionPort, _In_ alljoyn_sessionid id, _In_ PCSTR joiner); - QStatus OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg val); - QStatus OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg val); - void OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason); - void OnSessionMemberAdded(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName); - void OnSessionMemberRemoved(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName); - - property Platform::String^ ServiceObjectPath - { - Platform::String^ get() { return m_ServiceObjectPath; } - void set(Platform::String^ value) { m_ServiceObjectPath = value; } - } - - property alljoyn_busobject BusObject - { - alljoyn_busobject get() { return m_busObject; } - void set(alljoyn_busobject value) { m_busObject = value; } - } - - property alljoyn_sessionportlistener SessionPortListener - { - alljoyn_sessionportlistener get() { return m_sessionPortListener; } - void set(alljoyn_sessionportlistener value) { m_sessionPortListener = value; } - } - - property alljoyn_sessionlistener SessionListener - { - alljoyn_sessionlistener get() { return m_sessionListener; } - void set(alljoyn_sessionlistener value) { m_sessionListener = value; } - } - - property alljoyn_sessionport SessionPort - { - alljoyn_sessionport get() { return m_sessionPort; } - internal: - void set(alljoyn_sessionport value) { m_sessionPort = value; } - } - - property alljoyn_sessionid SessionId - { - alljoyn_sessionid get() { return m_sessionId; } - } - - // Stop advertising the service and pass status to anyone listening for the Stopped event. - void StopInternal(int32 status); - - 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; - - // "Concatenate two input strings and returns the concatenated string as output" - static void CallConcatenateHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message); - // "This signal is emitted when producer sends a text message to consumer" - static void CallTextSentSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message); - - // Register a callback function to handle methods. - QStatus AddMethodHandler(_In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_methodhandler_ptr handler); - // Register a callback function to handle incoming signals. - QStatus AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler); - - void UnregisterFromBus(); - - Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment; - Windows::Foundation::EventRegistrationToken m_busAttachmentStateChangedToken; - SecureInterfaceLegacySignals^ m_signals; - ISecureInterfaceService^ m_serviceInterface; - Platform::String^ m_ServiceObjectPath; - - alljoyn_busobject m_busObject; - alljoyn_sessionportlistener m_sessionPortListener; - alljoyn_sessionlistener m_sessionListener; - alljoyn_sessionport m_sessionPort; - alljoyn_sessionid m_sessionId; - - // Used to pass a pointer to this class to callbacks - Platform::WeakReference* m_weak; - - // These maps are required because we need a way to pass the producer to the method - // and signal handlers, but the current AllJoyn C API does not allow passing a context to these - // callbacks. - static std::map SourceObjects; - static std::map SourceInterfaces; -}; - -} } } } \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp deleted file mode 100644 index 39df1b9014..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp +++ /dev/null @@ -1,58 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Devices::AllJoyn; -using namespace com::microsoft::Samples::SecureInterface; - -// Note: Unlike an Interface implementation, which provides a single handler for each member, the event -// model allows for 0 or more listeners to be registered. The EventAdapter implementation deals with this -// difference by implementing a last-writer-wins policy. The lack of any return value (i.e., 0 listeners) -// is handled by returning a null result. - -// Methods -IAsyncOperation^ SecureInterfaceServiceEventAdapter::ConcatenateAsync(_In_ AllJoynMessageInfo^ info, _In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2) -{ - auto args = ref new SecureInterfaceConcatenateCalledEventArgs(info, interfaceMemberInStr1, interfaceMemberInStr2); - ConcatenateCalled(this, args); - return SecureInterfaceConcatenateCalledEventArgs::GetResultAsync(args); -} - -// Property Reads -IAsyncOperation^ SecureInterfaceServiceEventAdapter::GetIsUpperCaseEnabledAsync(_In_ AllJoynMessageInfo^ info) -{ - auto args = ref new SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs(info); - GetIsUpperCaseEnabledRequested(this, args); - return SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::GetResultAsync(args); -} - -// Property Writes -IAsyncOperation^ SecureInterfaceServiceEventAdapter::SetIsUpperCaseEnabledAsync(_In_ AllJoynMessageInfo^ info, _In_ bool value) -{ - auto args = ref new SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs(info, value); - SetIsUpperCaseEnabledRequested(this, args); - return SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::GetResultAsync(args); -} - diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h deleted file mode 100644 index 1824eb9bff..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h +++ /dev/null @@ -1,110 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -// This class, and the associated EventArgs classes, exist for the benefit of JavaScript developers who -// do not have the ability to implement ISecureInterfaceService. Instead, SecureInterfaceServiceEventAdapter -// provides the Interface implementation and exposes a set of compatible events to the developer. -public ref class SecureInterfaceServiceEventAdapter sealed : [Windows::Foundation::Metadata::Default] ISecureInterfaceService -{ -public: - // Method Invocation Events - 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 - { - 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 - { - 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); - - 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 deleted file mode 100644 index 19021f61df..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.cpp +++ /dev/null @@ -1,266 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace concurrency; -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Devices::AllJoyn; -using namespace com::microsoft::Samples::SecureInterface; -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -// Methods -SecureInterfaceConcatenateCalledEventArgs::SecureInterfaceConcatenateCalledEventArgs( - _In_ AllJoynMessageInfo^ info, - _In_ Platform::String^ interfaceMemberInStr1, - _In_ Platform::String^ interfaceMemberInStr2) - : m_raised(false), - m_completionsRequired(0), - m_messageInfo(info), - m_interfaceMemberInStr1(interfaceMemberInStr1), - m_interfaceMemberInStr2(interfaceMemberInStr2) -{ - m_result = SecureInterfaceConcatenateResult::CreateFailureResult(ER_NOT_IMPLEMENTED); -} - -Deferral^ SecureInterfaceConcatenateCalledEventArgs::GetDeferral() -{ - std::lock_guard lockGuard(m_lock); - if (m_raised) - { - // Cannot ask for a deferral after the event handler has returned. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - - m_completionsRequired++; - auto handler = ref new DeferralCompletedHandler(this, &SecureInterfaceConcatenateCalledEventArgs::Complete); - return ref new Deferral(handler); -} - -void SecureInterfaceConcatenateCalledEventArgs::InvokeAllFinished() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - m_raised = true; - invokeNeeded = (m_completionsRequired == 0); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void SecureInterfaceConcatenateCalledEventArgs::Complete() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - if (m_completionsRequired == 0) - { - // This should never happen since Complete() should only be called by Windows.Foundation.Deferral - // which will only invoke our completion handler once. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - m_completionsRequired--; - invokeNeeded = (m_raised && (m_completionsRequired == 0)); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void SecureInterfaceConcatenateCalledEventArgs::InvokeCompleteHandler() -{ - if (m_result->Status == ER_NOT_IMPLEMENTED) - { - throw Exception::CreateException(E_NOTIMPL, "No handlers are registered for ConcatenateCalled."); - } - else - { - m_tce.set(m_result); - } -} - -// Readable Properties -SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs( - _In_ AllJoynMessageInfo^ info) - : m_raised(false), - m_completionsRequired(0), - m_messageInfo(info) -{ - m_result = SecureInterfaceGetIsUpperCaseEnabledResult::CreateFailureResult(ER_NOT_IMPLEMENTED); -} - -Deferral^ SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::GetDeferral() -{ - std::lock_guard lockGuard(m_lock); - if (m_raised) - { - // Cannot ask for a deferral after the event handler has returned. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - - m_completionsRequired++; - auto handler = ref new DeferralCompletedHandler(this, &SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::Complete); - return ref new Deferral(handler); -} - -void SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::InvokeAllFinished() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - m_raised = true; - invokeNeeded = (m_completionsRequired == 0); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::Complete() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - if (m_completionsRequired == 0) - { - // This should never happen since Complete() should only be called by Windows.Foundation.Deferral - // which will only invoke our completion handler once. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - m_completionsRequired--; - invokeNeeded = (m_raised && (m_completionsRequired == 0)); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::InvokeCompleteHandler() -{ - if (m_result->Status == ER_NOT_IMPLEMENTED) - { - throw Exception::CreateException(E_NOTIMPL, "No handlers are registered for GetIsUpperCaseEnabledRequested."); - } - else - { - m_tce.set(m_result); - } -} - -// Writable Properties -SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs( - _In_ AllJoynMessageInfo^ info, - _In_ bool value) - : m_raised(false), - m_completionsRequired(0), - m_messageInfo(info), - m_value(value) -{ - m_result = SecureInterfaceSetIsUpperCaseEnabledResult::CreateFailureResult(ER_NOT_IMPLEMENTED); -} - -Deferral^ SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::GetDeferral() -{ - std::lock_guard lockGuard(m_lock); - if (m_raised) - { - // Cannot ask for a deferral after the event handler has returned. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - - m_completionsRequired++; - auto handler = ref new DeferralCompletedHandler(this, &SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::Complete); - return ref new Deferral(handler); -} - -void SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::InvokeAllFinished() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - m_raised = true; - invokeNeeded = (m_completionsRequired == 0); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::Complete() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - if (m_completionsRequired == 0) - { - // This should never happen since Complete() should only be called by Windows.Foundation.Deferral - // which will only invoke our completion handler once. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - m_completionsRequired--; - invokeNeeded = (m_raised && (m_completionsRequired == 0)); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::InvokeCompleteHandler() -{ - if (m_result->Status == ER_NOT_IMPLEMENTED) - { - throw Exception::CreateException(E_NOTIMPL, "No handlers are registered for SetIsUpperCaseEnabledRequested."); - } - else - { - m_tce.set(m_result); - } -} - -} } } } diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.h deleted file mode 100644 index 68e0f0f19e..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.h +++ /dev/null @@ -1,169 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -// Methods -public ref class SecureInterfaceConcatenateCalledEventArgs sealed -{ -public: - SecureInterfaceConcatenateCalledEventArgs(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info, _In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2); - - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - } - - property SecureInterfaceConcatenateResult^ Result - { - SecureInterfaceConcatenateResult^ get() { return m_result; } - void set(_In_ SecureInterfaceConcatenateResult^ value) { m_result = value; } - } - - property Platform::String^ InStr1 - { - Platform::String^ get() { return m_interfaceMemberInStr1; } - } - - property Platform::String^ InStr2 - { - Platform::String^ get() { return m_interfaceMemberInStr2; } - } - - Windows::Foundation::Deferral^ GetDeferral(); - - static Windows::Foundation::IAsyncOperation^ GetResultAsync(SecureInterfaceConcatenateCalledEventArgs^ args) - { - args->InvokeAllFinished(); - auto t = concurrency::create_task(args->m_tce); - return concurrency::create_async([t]() -> concurrency::task - { - return t; - }); - } - -private: - void Complete(); - void InvokeAllFinished(); - void InvokeCompleteHandler(); - - bool m_raised; - int m_completionsRequired; - concurrency::task_completion_event m_tce; - std::mutex m_lock; - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - SecureInterfaceConcatenateResult^ m_result; - Platform::String^ m_interfaceMemberInStr1; - Platform::String^ m_interfaceMemberInStr2; -}; - -// Readable Properties -public ref class SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs sealed -{ -public: - SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - } - - property SecureInterfaceGetIsUpperCaseEnabledResult^ Result - { - SecureInterfaceGetIsUpperCaseEnabledResult^ get() { return m_result; } - void set(_In_ SecureInterfaceGetIsUpperCaseEnabledResult^ value) { m_result = value; } - } - - Windows::Foundation::Deferral^ GetDeferral(); - - static Windows::Foundation::IAsyncOperation^ GetResultAsync(SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs^ args) - { - args->InvokeAllFinished(); - auto t = concurrency::create_task(args->m_tce); - return concurrency::create_async([t]() -> concurrency::task - { - return t; - }); - } - -private: - void Complete(); - void InvokeAllFinished(); - void InvokeCompleteHandler(); - - bool m_raised; - int m_completionsRequired; - concurrency::task_completion_event m_tce; - std::mutex m_lock; - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - SecureInterfaceGetIsUpperCaseEnabledResult^ m_result; -}; - -// Writable Properties -public ref class SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs sealed -{ -public: - SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info, _In_ bool value); - - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - } - - property bool Value - { - bool get() { return m_value; } - } - - property SecureInterfaceSetIsUpperCaseEnabledResult^ Result - { - SecureInterfaceSetIsUpperCaseEnabledResult^ get() { return m_result; } - void set(_In_ SecureInterfaceSetIsUpperCaseEnabledResult^ value) { m_result = value; } - } - - static Windows::Foundation::IAsyncOperation^ GetResultAsync(SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs^ args) - { - args->InvokeAllFinished(); - auto t = concurrency::create_task(args->m_tce); - return concurrency::create_async([t]() -> concurrency::task - { - return t; - }); - } - - Windows::Foundation::Deferral^ GetDeferral(); - -private: - void Complete(); - void InvokeAllFinished(); - void InvokeCompleteHandler(); - - bool m_raised; - int m_completionsRequired; - concurrency::task_completion_event m_tce; - std::mutex m_lock; - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - bool m_value; - SecureInterfaceSetIsUpperCaseEnabledResult^ m_result; -}; - -} } } } diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp deleted file mode 100644 index 7663d85e25..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp +++ /dev/null @@ -1,66 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Devices::AllJoyn; -using namespace Windows::Foundation; -using namespace com::microsoft::Samples::SecureInterface; - -void SecureInterfaceSignals::Initialize(_In_ ISignalEmitter^ emitter) -{ - m_emitter = emitter; - alljoyn_busattachment nativeBusAttachment = AllJoynHelpers::GetInternalBusAttachment(m_emitter->BusObject->BusAttachment); - auto interfaceDefinition = alljoyn_busattachment_getinterface(nativeBusAttachment, "com.microsoft.Samples.SecureInterface"); - alljoyn_interfacedescription_getmember(interfaceDefinition, "TextSent", &m_memberTextSent); -} - -void SecureInterfaceSignals::TextSent(_In_ Platform::String^ interfaceMemberMessage) -{ - if (nullptr == AllJoynHelpers::GetInternalBusObject(m_emitter->BusObject)) - { - return; - } - - size_t argCount = 1; - alljoyn_msgarg arguments = alljoyn_msgarg_array_create(argCount); - (void)TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "s", interfaceMemberMessage); - - alljoyn_busobject_signal( - AllJoynHelpers::GetInternalBusObject(m_emitter->BusObject), - NULL, // Generated code only supports broadcast signals. - m_emitter->Session->Id, - m_memberTextSent, - arguments, - argCount, - 0, // A signal with a TTL of 0 will be sent to every member of the session, regardless of how long it takes to deliver the message - ALLJOYN_MESSAGE_FLAG_GLOBAL_BROADCAST, // Broadcast to everyone in the session. - NULL); // The generated code does not need the generated signal message - - alljoyn_msgarg_destroy(arguments); -} - -void SecureInterfaceSignals::CallTextSentReceived(_In_ SecureInterfaceSignals^ sender, _In_ SecureInterfaceTextSentReceivedEventArgs^ args) -{ - TextSentReceived(sender, args); -} - diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h deleted file mode 100644 index d3fd1adb00..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h +++ /dev/null @@ -1,73 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -ref class SecureInterfaceSignals; - -public interface class ISecureInterfaceSignals -{ - event Windows::Foundation::TypedEventHandler^ TextSentReceived; -}; - -public ref class SecureInterfaceSignals sealed : [Windows::Foundation::Metadata::Default] ISecureInterfaceSignals -{ -public: - // "This signal is emitted when producer sends a text message to consumer" - // Calling this method will send the TextSent signal to every member of the session. - 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 - { - 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_ ISignalEmitter^ emitter); - void CallTextSentReceived(_In_ SecureInterfaceSignals^ sender, _In_ SecureInterfaceTextSentReceivedEventArgs^ args); - -private: - ISignalEmitter^ m_emitter; - - virtual event Windows::Foundation::EventHandler^ _TextSentReceived; - - alljoyn_interfacedescription_member m_memberTextSent; -}; - -} } } } diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceStructures.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceStructures.h deleted file mode 100644 index c4473060c8..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceStructures.h +++ /dev/null @@ -1,108 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace com { namespace microsoft { namespace Samples { namespace SecureInterface { - -public ref class AllJoynMessageArgStructure sealed : Windows::Foundation::Collections::IVector -{ -public: - AllJoynMessageArgStructure() - { - m_vector = ref new Platform::Collections::Vector(); - } - - virtual Windows::Foundation::Collections::IIterator^ First() - { - return m_vector->First(); - } - - virtual Platform::Object^ GetAt(unsigned int index) - { - return m_vector->GetAt(index); - } - - virtual property unsigned int Size { - virtual unsigned int get() - { - return m_vector->Size; - } - } - - virtual bool IndexOf(Platform::Object^ value, unsigned int * index) - { - return m_vector->IndexOf(value, index); - } - - virtual unsigned int GetMany(unsigned int startIndex, Platform::WriteOnlyArray^ items) - { - return m_vector->GetMany(startIndex, items); - } - - virtual Windows::Foundation::Collections::IVectorView^ GetView() - { - return m_vector->GetView(); - } - - virtual void SetAt(unsigned int index, Platform::Object^ value) - { - return m_vector->SetAt(index, value); - } - - virtual void InsertAt(unsigned int index, Platform::Object^ value) - { - return m_vector->InsertAt(index, value); - } - - virtual void Append(Platform::Object^ value) - { - return m_vector->Append(value); - } - - virtual void RemoveAt(unsigned int index) - { - return m_vector->RemoveAt(index); - } - - virtual void RemoveAtEnd() - { - return m_vector->RemoveAtEnd(); - } - - virtual void Clear() - { - return m_vector->Clear(); - } - - virtual void ReplaceAll(const Platform::Array^ items) - { - return m_vector->ReplaceAll(items); - } - -private: - Platform::Collections::Vector^ m_vector; -}; -} } } } - -partial ref class TypeConversionHelpers -{ -internal: -}; diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/pch.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/pch.cpp deleted file mode 100644 index 4c5275e663..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/pch.cpp +++ /dev/null @@ -1,21 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/pch.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/pch.h deleted file mode 100644 index 74ad51f3b1..0000000000 --- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/pch.h +++ /dev/null @@ -1,52 +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. -// -//********************************************************* - -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "AllJoynHelpers.h" -#include "AllJoynBusObjectManager.h" - -#define PROJECT_NAMESPACE com::microsoft::Samples::SecureInterface - -#include "SecureInterfaceStructures.h" -#include "TypeConversionHelpers.h" -#include "SecureInterfaceMethodResults.h" -#include "SecureInterfaceEventArgs.h" -#include "ISecureInterfaceService.h" -#include "SecureInterfaceSignals.h" -#include "SecureInterfaceLegacySignals.h" -#include "SecureInterfaceProducer.h" -#include "SecureInterfaceConsumer.h" -#include "SecureInterfaceServiceEventArgs.h" -#include "SecureInterfaceServiceEventAdapter.h" \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/AllJoynHelpers.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/AllJoynHelpers.h deleted file mode 100644 index 1987e10a79..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/AllJoynHelpers.h +++ /dev/null @@ -1,277 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -// The amount of time to wait (ms) for a response after sending a message before timing out. -const int c_MessageTimeoutInMilliseconds = 10000; - -// The maximum length of an AllJoyn type signature allowed by the AllJoyn Core library. -const int c_MaximumSignatureLength = 255; - -#define RETURN_IF_QSTATUS_ERROR(status) \ -{ \ -int32 alljoynStatus = static_cast(status); \ -if (Windows::Devices::AllJoyn::AllJoynStatus::Ok != alljoynStatus) \ -{ \ - return status; \ -} \ -} - -namespace org { namespace alljoyn { namespace Onboarding { - -public interface class ISignalEmitter -{ - property Windows::Devices::AllJoyn::AllJoynBusObject^ BusObject - { - Windows::Devices::AllJoyn::AllJoynBusObject^ get(); - } - - property Windows::Devices::AllJoyn::AllJoynSession^ Session - { - Windows::Devices::AllJoyn::AllJoynSession^ get(); - } -}; - -} } } - -class AllJoynHelpers -{ -public: - // The Windows::Devices::AllJoyn::AllJoynBusAttachment class wraps the alljoyn_busattachment type. This - // function gets the underlying alljoyn_busattachment. - static alljoyn_busattachment GetInternalBusAttachment(_In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment); - - // The Windows::Devices::AllJoyn::AllJoynBusObject class wraps the alljoyn_busobject type. This - // function gets the underlying alljoyn_busobject. - static alljoyn_busobject AllJoynHelpers::GetInternalBusObject(_In_ Windows::Devices::AllJoyn::AllJoynBusObject^ busObject); - - // Create the alljoyn_interfacedescriptions described in introspectionXml and add them to the busAttachment. - static QStatus CreateInterfaces(_Inout_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment, _In_ PCSTR introspectionXml); - - // Convert a UTF8 string to a wide character Platform::String. - static Platform::String^ MultibyteToPlatformString(_In_ PCSTR); - - // Convert a wide character Platform::String to a UTF8 string. - static std::vector PlatformToMultibyteString(_In_ Platform::String^ str); - - // Get the service object path from an objectDescriptionArg. The objectDescriptionArg should - // come from an Announce signal. - static Platform::String^ GetObjectPath(_In_ alljoyn_aboutobjectdescription objectDescription, _In_ PCSTR interfaceName); - - // Determine whether the supplied set of AuthenticationMechanisms is sufficient for securing an AllJoyn connection. - static bool CanSecure(_In_ Windows::Foundation::Collections::IVector^ authenticationMechanisms); - - // Callback for alljoyn_proxybusobject_listener_propertieschanged_ptr. - // This callback expects the context to be of type T, which must implement the OnPropertyChanged function. - template - static void AJ_CALL PropertyChangedHandler(_In_ alljoyn_proxybusobject obj, _In_ PCSTR interfaceName, _In_ const alljoyn_msgarg changed, _In_ const alljoyn_msgarg invalidated, _In_ void* context) - { - T^ caller = static_cast(context)->Resolve(); - caller->OnPropertyChanged(obj, interfaceName, changed, invalidated); - } - - // Callback for alljoyn_busobject_prop_get_ptr. - template - static QStatus AJ_CALL PropertyGetHandler(_In_ const void* context, _In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg value) - { - T^ caller = static_cast(context)->Resolve(); - return caller->OnPropertyGet(interfaceName, propertyName, value); - } - - // Callback for alljoyn_busobject_prop_set_ptr. - template - static QStatus AJ_CALL PropertySetHandler(_In_ const void* context, _In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg value) - { - T^ caller = static_cast(context)->Resolve(); - return caller->OnPropertySet(interfaceName, propertyName, value); - } - - // Callback for alljoyn_sessionlistener_sessionlost_ptr. - template - static void AJ_CALL SessionLostHandler(_In_ const void* context, _In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason) - { - T^ caller = static_cast(context)->Resolve(); - caller->OnSessionLost(sessionId, reason); - } - - // Callback for alljoyn_sessionlistener_sessionmemberadded_ptr. - template - static void AJ_CALL SessionMemberAddedHandler(_In_ const void* context, _In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName) - { - T^ caller = static_cast(context)->Resolve(); - caller->OnSessionMemberAdded(sessionId, uniqueName); - } - - // Callback for alljoyn_sessionlistener_sessionmemberremoved_ptr. - template - static void AJ_CALL SessionMemberRemovedHandler(_In_ const void* context, _In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName) - { - T^ caller = static_cast(context)->Resolve(); - caller->OnSessionMemberRemoved(sessionId, uniqueName); - } - - // Create an AllJoyn bus object. - template - static QStatus CreateBusObject(_Inout_ Platform::WeakReference* target) - { - alljoyn_busobject_callbacks callbacks = - { - PropertyGetHandler, - PropertySetHandler, - nullptr, - nullptr, - }; - - T^ caller = target->Resolve(); - - auto serviceObjectPath = PlatformToMultibyteString(caller->ServiceObjectPath); - alljoyn_busobject busObject = alljoyn_busobject_create(serviceObjectPath.data(), false, &callbacks, target); - if (busObject == nullptr) - { - return ER_FAIL; - } - - caller->BusObject = busObject; - - return ER_OK; - } - - // Callback for alljoyn_sessionportlistener_acceptsessionjoiner_ptr. - // This callback expects the context to be of type T, which must implement the OnAcceptSessionJoiner function. - template - static QCC_BOOL AJ_CALL AcceptSessionJoinerHandler( - _In_ const void* context, - _In_ alljoyn_sessionport sessionPort, - _In_ PCSTR joiner, - _In_ const alljoyn_sessionopts opts) - { - T^ caller = static_cast(context)->Resolve(); - return caller->OnAcceptSessionJoiner(sessionPort, joiner, opts); - } - - // Callback for alljoyn_sessionportlistener_sessionjoined_ptr. - // This callback expects the context to be of type T, which must implement the OnSessionJoined function. - template - static void AJ_CALL SessionJoinedHandler( - _In_ const void* context, - _In_ alljoyn_sessionport sessionPort, - _In_ alljoyn_sessionid id, - _In_ PCSTR joiner) - { - T^ caller = static_cast(context)->Resolve(); - caller->OnSessionJoined(sessionPort, id, joiner); - } - - // Create the session for an AllJoyn producer. - template - static QStatus CreateProducerSession(_Inout_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment, _Inout_ Platform::WeakReference* target) - { - alljoyn_sessionopts opts = alljoyn_sessionopts_create(ALLJOYN_TRAFFIC_TYPE_MESSAGES, true, ALLJOYN_PROXIMITY_ANY, ALLJOYN_TRANSPORT_ANY); - - alljoyn_sessionportlistener_callbacks callbacks = - { - AcceptSessionJoinerHandler, - SessionJoinedHandler - }; - - T^ producer = target->Resolve(); - producer->SessionPortListener = alljoyn_sessionportlistener_create(&callbacks, target); - - alljoyn_sessionport sessionPort = 42; - alljoyn_busattachment_unbindsessionport(AllJoynHelpers::GetInternalBusAttachment(busAttachment), sessionPort); - RETURN_IF_QSTATUS_ERROR(alljoyn_busattachment_bindsessionport(AllJoynHelpers::GetInternalBusAttachment(busAttachment), &sessionPort, opts, producer->SessionPortListener)); - producer->SessionPort = sessionPort; - - alljoyn_sessionopts_destroy(opts); - - return ER_OK; - } -}; - -// Passed to property get callbacks to allow them to report when the async operation is completed. -template -class PropertyGetContext -{ -public: - void SetEvent() - { - m_event.set(); - } - - void Wait() - { - m_event.wait(); - } - - QStatus GetStatus() - { - return m_status; - } - - void SetStatus(QStatus value) - { - m_status = value; - } - - T GetValue() - { - return m_value; - } - - void SetValue(T value) - { - m_value = value; - } - -private: - Concurrency::event m_event; - QStatus m_status; - T m_value; -}; - -// Passed to property set callbacks to allow them to report when the async operation is completed. -class PropertySetContext -{ -public: - void SetEvent() - { - m_event.set(); - } - - void Wait() - { - m_event.wait(); - } - - QStatus GetStatus() - { - return m_status; - } - - void SetStatus(QStatus value) - { - m_status = value; - } - -private: - Concurrency::event m_event; - QStatus m_status; -}; diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h deleted file mode 100644 index 65ba47eb2c..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h +++ /dev/null @@ -1,64 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace org { namespace alljoyn { namespace Onboarding { - -public interface class IOnboardingService -{ -public: - // "Sends the personal AP information to the onboardee" - // Implement this function to handle calls to the ConfigureWiFi method. - Windows::Foundation::IAsyncOperation^ ConfigureWiFiAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info , _In_ Platform::String^ interfaceMemberSSID, _In_ Platform::String^ interfaceMemberPassphrase, _In_ int16 interfaceMemberAuthType); - - // "Tells the onboardee to connect to the personal AP" - // Implement this function to handle calls to the Connect method. - Windows::Foundation::IAsyncOperation^ ConnectAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info ); - - // "Tells the onboardee to disconnect from the personal AP" - // Implement this function to handle calls to the Offboard method. - Windows::Foundation::IAsyncOperation^ OffboardAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info ); - - // "Scans all the Wi-Fi access points in the onboardee's proximity" - // Implement this function to handle calls to the GetScanInfo method. - Windows::Foundation::IAsyncOperation^ GetScanInfoAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info ); - - // "Interface version number" - // Implement this function to handle requests for the value of the Version property. - // - // Currently, info will always be null, because no information is available about the requestor. - Windows::Foundation::IAsyncOperation^ GetVersionAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - // "The configuration state" - // Implement this function to handle requests for the value of the State property. - // - // Currently, info will always be null, because no information is available about the requestor. - Windows::Foundation::IAsyncOperation^ GetStateAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - // "The last error code and error message" - // Implement this function to handle requests for the value of the LastError property. - // - // Currently, info will always be null, because no information is available about the requestor. - Windows::Foundation::IAsyncOperation^ GetLastErrorAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - -}; - -} } } diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp deleted file mode 100644 index 783f0f682b..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp +++ /dev/null @@ -1,563 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace concurrency; -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Devices::AllJoyn; -using namespace org::alljoyn::Onboarding; - -std::map OnboardingConsumer::SourceInterfaces; -PCSTR OnboardingConsumer::m_interfaceName = "org.alljoyn.Onboarding"; - -OnboardingConsumer::OnboardingConsumer(AllJoynBusAttachment^ busAttachment) - : m_busAttachment(busAttachment), - m_proxyBusObject(nullptr), - m_busObject(nullptr) -{ - m_weak = new WeakReference(this); - m_signals = ref new OnboardingSignals(); - m_nativeBusAttachment = AllJoynHelpers::GetInternalBusAttachment(m_busAttachment); - - GUID result; - HRESULT hr = CoCreateGuid(&result); - - if (FAILED(hr)) - { - throw ref new Exception(hr); - } - - // The consumer needs a bus object to share signals, and its object path must be unique in - // case multiple consumers are created using the same bus attachment. - Guid gd(result); - ServiceObjectPath = gd.ToString(); -} - -OnboardingConsumer::~OnboardingConsumer() -{ - if (nullptr != ProxyBusObject) - { - alljoyn_proxybusobject_destroy(ProxyBusObject); - } - delete m_weak; -} - -QStatus OnboardingConsumer::AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler) -{ - alljoyn_interfacedescription_member member; - if (!alljoyn_interfacedescription_getmember(interfaceDescription, methodName, &member)) - { - return ER_BUS_INTERFACE_NO_SUCH_MEMBER; - } - - return alljoyn_busattachment_registersignalhandler(busAttachment, handler, member, NULL); -} - -IAsyncOperation^ OnboardingConsumer::FromIdAsync(_In_ Platform::String^ deviceId) -{ - return OnboardingConsumer::FromIdAsync(deviceId, AllJoynBusAttachment::GetDefault()); -} - -IAsyncOperation^ OnboardingConsumer::FromIdAsync(_In_ Platform::String^ deviceId, _In_ AllJoynBusAttachment^ busAttachment) -{ - return create_async([deviceId, busAttachment]() -> OnboardingConsumer^ - { - OnboardingConsumer^ result; - create_task(AllJoynServiceInfo::FromIdAsync(deviceId)).then([busAttachment, &result](AllJoynServiceInfo^ serviceInfo) - { - if (serviceInfo != nullptr) - { - int32 status = AllJoynStatus::Ok; - if (busAttachment->State == AllJoynBusAttachmentState::Disconnected) - { - event connectedEvent; - auto token = busAttachment->StateChanged += ref new TypedEventHandler([&connectedEvent](AllJoynBusAttachment^, AllJoynBusAttachmentStateChangedEventArgs^ arg) - { - if (arg->State == AllJoynBusAttachmentState::Connected) - { - connectedEvent.set(); - } - }); - - status = AllJoynHelpers::CreateInterfaces(busAttachment, c_OnboardingIntrospectionXml); - if (status == AllJoynStatus::Ok) - { - busAttachment->Connect(); - connectedEvent.wait(); - } - busAttachment->StateChanged -= token; - } - - if (status == AllJoynStatus::Ok) - { - auto consumer = ref new OnboardingConsumer(busAttachment); - status = consumer->Initialize(serviceInfo); - if (status == AllJoynStatus::Ok) - { - result = consumer; - } - } - } - }).wait(); - - return result; - }); -} - -IAsyncOperation^ OnboardingConsumer::ConfigureWiFiAsync(_In_ Platform::String^ interfaceMemberSSID, _In_ Platform::String^ interfaceMemberPassphrase, _In_ int16 interfaceMemberAuthType) -{ - return create_async([this, interfaceMemberSSID, interfaceMemberPassphrase, interfaceMemberAuthType]() -> OnboardingConfigureWiFiResult^ - { - auto result = ref new OnboardingConfigureWiFiResult(); - - alljoyn_message message = alljoyn_message_create(m_nativeBusAttachment); - size_t argCount = 3; - alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount); - - 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, - m_interfaceName, - "ConfigureWiFi", - inputs, - argCount, - message, - c_MessageTimeoutInMilliseconds, - 0); - } - result->Status = static_cast(status); - if (ER_OK == status) - { - result->Status = AllJoynStatus::Ok; - int16 argument0; - status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "n", &argument0)); - result->Status2 = argument0; - - if (ER_OK != status) - { - result->Status = static_cast(status); - } - } - else if (ER_BUS_REPLY_IS_ERROR_MESSAGE == status) - { - alljoyn_msgarg errorArg = alljoyn_message_getarg(message, 1); - if (nullptr != errorArg) - { - uint16 errorStatus; - status = alljoyn_msgarg_get_uint16(errorArg, &errorStatus); - if (ER_OK == status) - { - status = static_cast(errorStatus); - } - } - result->Status = static_cast(status); - } - - alljoyn_message_destroy(message); - alljoyn_msgarg_destroy(inputs); - - return result; - }); -} -IAsyncOperation^ OnboardingConsumer::ConnectAsync() -{ - return create_async([this]() -> OnboardingConnectResult^ - { - auto result = ref new OnboardingConnectResult(); - - alljoyn_message message = alljoyn_message_create(m_nativeBusAttachment); - size_t argCount = 0; - alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount); - - QStatus status = ER_OK; - if (ER_OK == status) - { - status = alljoyn_proxybusobject_methodcall( - ProxyBusObject, - m_interfaceName, - "Connect", - inputs, - argCount, - message, - c_MessageTimeoutInMilliseconds, - 0); - } - result->Status = static_cast(status); - - alljoyn_message_destroy(message); - alljoyn_msgarg_destroy(inputs); - - return result; - }); -} -IAsyncOperation^ OnboardingConsumer::OffboardAsync() -{ - return create_async([this]() -> OnboardingOffboardResult^ - { - auto result = ref new OnboardingOffboardResult(); - - alljoyn_message message = alljoyn_message_create(m_nativeBusAttachment); - size_t argCount = 0; - alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount); - - QStatus status = ER_OK; - if (ER_OK == status) - { - status = alljoyn_proxybusobject_methodcall( - ProxyBusObject, - m_interfaceName, - "Offboard", - inputs, - argCount, - message, - c_MessageTimeoutInMilliseconds, - 0); - } - result->Status = static_cast(status); - - alljoyn_message_destroy(message); - alljoyn_msgarg_destroy(inputs); - - return result; - }); -} -IAsyncOperation^ OnboardingConsumer::GetScanInfoAsync() -{ - return create_async([this]() -> OnboardingGetScanInfoResult^ - { - auto result = ref new OnboardingGetScanInfoResult(); - - alljoyn_message message = alljoyn_message_create(m_nativeBusAttachment); - size_t argCount = 0; - alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount); - - QStatus status = ER_OK; - if (ER_OK == status) - { - status = alljoyn_proxybusobject_methodcall( - ProxyBusObject, - m_interfaceName, - "GetScanInfo", - inputs, - argCount, - message, - c_MessageTimeoutInMilliseconds, - 0); - } - result->Status = static_cast(status); - if (ER_OK == status) - { - result->Status = AllJoynStatus::Ok; - uint16 argument0; - status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "q", &argument0)); - result->Age = argument0; - - if (ER_OK != status) - { - result->Status = static_cast(status); - } - Windows::Foundation::Collections::IVector^ argument1; - status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 1), "a(sn)", &argument1)); - result->ScanList = argument1; - - if (ER_OK != status) - { - result->Status = static_cast(status); - } - } - else if (ER_BUS_REPLY_IS_ERROR_MESSAGE == status) - { - alljoyn_msgarg errorArg = alljoyn_message_getarg(message, 1); - if (nullptr != errorArg) - { - uint16 errorStatus; - status = alljoyn_msgarg_get_uint16(errorArg, &errorStatus); - if (ER_OK == status) - { - status = static_cast(errorStatus); - } - } - result->Status = static_cast(status); - } - - alljoyn_message_destroy(message); - alljoyn_msgarg_destroy(inputs); - - return result; - }); -} - -IAsyncOperation^ OnboardingConsumer::GetVersionAsync() -{ - return create_async([this]() -> OnboardingGetVersionResult^ - { - PropertyGetContext getContext; - - alljoyn_proxybusobject_getpropertyasync( - ProxyBusObject, - m_interfaceName, - "Version", - [](QStatus status, alljoyn_proxybusobject obj, const alljoyn_msgarg value, void* context) - { - UNREFERENCED_PARAMETER(obj); - auto propertyContext = static_cast*>(context); - - if (ER_OK == status) - { - uint16 argument; - status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(value, "q", &argument)); - - propertyContext->SetValue(argument); - } - propertyContext->SetStatus(status); - propertyContext->SetEvent(); - }, - c_MessageTimeoutInMilliseconds, - &getContext); - - getContext.Wait(); - - auto result = ref new OnboardingGetVersionResult(); - result->Status = getContext.GetStatus(); - result->Version = getContext.GetValue(); - return result; - }); -} - -IAsyncOperation^ OnboardingConsumer::GetStateAsync() -{ - return create_async([this]() -> OnboardingGetStateResult^ - { - PropertyGetContext getContext; - - alljoyn_proxybusobject_getpropertyasync( - ProxyBusObject, - m_interfaceName, - "State", - [](QStatus status, alljoyn_proxybusobject obj, const alljoyn_msgarg value, void* context) - { - UNREFERENCED_PARAMETER(obj); - auto propertyContext = static_cast*>(context); - - if (ER_OK == status) - { - int16 argument; - status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(value, "n", &argument)); - - propertyContext->SetValue(argument); - } - propertyContext->SetStatus(status); - propertyContext->SetEvent(); - }, - c_MessageTimeoutInMilliseconds, - &getContext); - - getContext.Wait(); - - auto result = ref new OnboardingGetStateResult(); - result->Status = getContext.GetStatus(); - result->State = getContext.GetValue(); - return result; - }); -} - -IAsyncOperation^ OnboardingConsumer::GetLastErrorAsync() -{ - return create_async([this]() -> OnboardingGetLastErrorResult^ - { - PropertyGetContext getContext; - - alljoyn_proxybusobject_getpropertyasync( - ProxyBusObject, - m_interfaceName, - "LastError", - [](QStatus status, alljoyn_proxybusobject obj, const alljoyn_msgarg value, void* context) - { - UNREFERENCED_PARAMETER(obj); - auto propertyContext = static_cast*>(context); - - if (ER_OK == status) - { - OnboardingLastError^ argument; - status = static_cast(TypeConversionHelpers::GetAllJoynMessageArg(value, "(ns)", &argument)); - - propertyContext->SetValue(argument); - } - propertyContext->SetStatus(status); - propertyContext->SetEvent(); - }, - c_MessageTimeoutInMilliseconds, - &getContext); - - getContext.Wait(); - - auto result = ref new OnboardingGetLastErrorResult(); - result->Status = getContext.GetStatus(); - result->LastError = getContext.GetValue(); - return result; - }); -} - -void OnboardingConsumer::OnPropertyChanged(_In_ alljoyn_proxybusobject obj, _In_ PCSTR interfaceName, _In_ const alljoyn_msgarg changed, _In_ const alljoyn_msgarg invalidated) -{ - UNREFERENCED_PARAMETER(obj); - UNREFERENCED_PARAMETER(interfaceName); - UNREFERENCED_PARAMETER(changed); - UNREFERENCED_PARAMETER(invalidated); -} - -void OnboardingConsumer::CallConnectionResultSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message) -{ - auto source = SourceInterfaces.find(member->iface); - if (source == SourceInterfaces.end()) - { - return; - } - - auto consumer = source->second->Resolve(); - if (consumer->Signals != nullptr) - { - auto callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - auto eventArgs = ref new OnboardingConnectionResultReceivedEventArgs(); - eventArgs->MessageInfo = callInfo; - - Onboarding^ argument0; - (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "(ns)", &argument0); - - eventArgs->Arg = argument0; - - consumer->Signals->CallConnectionResultReceived(consumer->Signals, eventArgs); - } -} - -int32 OnboardingConsumer::Initialize(_In_ AllJoynServiceInfo^ serviceInfo) -{ - std::vector sessionNameUtf8 = AllJoynHelpers::PlatformToMultibyteString(serviceInfo->UniqueName); - - ServiceObjectPath = serviceInfo->ObjectPath; - std::vector objectPath = AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath); - - RETURN_IF_QSTATUS_ERROR(AllJoynHelpers::CreateInterfaces(m_busAttachment, c_OnboardingIntrospectionXml)); - - m_session = create_task(AllJoynSession::GetFromServiceInfoAsync(serviceInfo, m_busAttachment)).get(); - if (nullptr == m_session) - { - return AllJoynStatus::Fail; - } - else if (m_session->Status != AllJoynStatus::Ok) - { - return m_session->Status; - } - - if (objectPath.empty()) - { - return AllJoynStatus::Fail; - } - - ProxyBusObject = alljoyn_proxybusobject_create(m_nativeBusAttachment, &sessionNameUtf8[0], &objectPath[0], m_session->Id); - if (nullptr == ProxyBusObject) - { - return AllJoynStatus::Fail; - } - - - alljoyn_interfacedescription description = alljoyn_busattachment_getinterface(m_nativeBusAttachment, m_interfaceName); - if (nullptr == description) - { - return AllJoynStatus::Fail; - } - - m_busObject = ref new Windows::Devices::AllJoyn::AllJoynBusObject(ServiceObjectPath, m_busAttachment); - m_nativeBusObject = AllJoynHelpers::GetInternalBusObject(m_busObject); - - QStatus status = alljoyn_busobject_addinterface(m_nativeBusObject, description); - if ((status != ER_OK) && (status != ER_BUS_IFACE_ALREADY_EXISTS)) - { - return status; - } - - - 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); - - // If the current set of AuthenticationMechanisms supports authentication, - // determine whether to secure the connection. - if (AllJoynHelpers::CanSecure(m_busAttachment->AuthenticationMechanisms)) - { - // Secure the connection if the org.alljoyn.Bus.Secure XML annotation - // is specified, or if None is not present in AuthenticationMechanisms. - if (!authenticationMechanismsContainsNone || interfaceIsSecure) - { - RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_secureconnection(ProxyBusObject, QCC_FALSE)); - m_busObject->Start(); - } - else - { - m_busObject->Start(); - } - } - else - { - // If the current set of AuthenticationMechanisms does not support authentication - // but the interface requires security, report an error. - if (interfaceIsSecure) - { - return static_cast(ER_BUS_NO_AUTHENTICATION_MECHANISM); - } - else - { - m_busObject->Start(); - } - } - - RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_addinterface(ProxyBusObject, description)); - - m_signals->Initialize(this); - - return AllJoynStatus::Ok; -} diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h deleted file mode 100644 index f185881069..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h +++ /dev/null @@ -1,160 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace org { namespace alljoyn { namespace Onboarding { - -public interface class IOnboardingConsumer -{ -}; - -public ref class OnboardingConsumer sealed : [Windows::Foundation::Metadata::Default] IOnboardingConsumer, ISignalEmitter -{ -public: - OnboardingConsumer(Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment); - virtual ~OnboardingConsumer(); - - // Create a consumer from a device Id asynchronously. - // - // This is usually called to create a consumer after the unique name of a producer has been reported - // in the Added callback on the DeviceWatcher. - static Windows::Foundation::IAsyncOperation^ FromIdAsync(_In_ Platform::String^ deviceId); - - // Create a consumer from a device Id asynchronously with the provided bus attachment. - // - // This is usually called to create a consumer after the unique name of a producer has been reported - // in the Added callback on the DeviceWatcher. - static Windows::Foundation::IAsyncOperation^ FromIdAsync(_In_ Platform::String^ deviceId, _In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment); - - int32 OnboardingConsumer::Initialize(_In_ Windows::Devices::AllJoyn::AllJoynServiceInfo^ serviceInfo); - - // "Sends the personal AP information to the onboardee" - // Call the ConfigureWiFi method - Windows::Foundation::IAsyncOperation^ ConfigureWiFiAsync(_In_ Platform::String^ interfaceMemberSSID, _In_ Platform::String^ interfaceMemberPassphrase, _In_ int16 interfaceMemberAuthType); - // "Tells the onboardee to connect to the personal AP" - // Call the Connect method - Windows::Foundation::IAsyncOperation^ ConnectAsync(); - // "Tells the onboardee to disconnect from the personal AP" - // Call the Offboard method - Windows::Foundation::IAsyncOperation^ OffboardAsync(); - // "Scans all the Wi-Fi access points in the onboardee's proximity" - // Call the GetScanInfo method - Windows::Foundation::IAsyncOperation^ GetScanInfoAsync(); - - // "Interface version number" - // Get the value of the Version property. - Windows::Foundation::IAsyncOperation^ GetVersionAsync(); - - // "The configuration state" - // Get the value of the State property. - Windows::Foundation::IAsyncOperation^ GetStateAsync(); - - // "The last error code and error message" - // Get the value of the LastError property. - Windows::Foundation::IAsyncOperation^ GetLastErrorAsync(); - - - // Used to send signals or register functions to handle received signals. - property OnboardingSignals^ Signals - { - OnboardingSignals^ get() { return m_signals; } - } - - // Used to get the name of the interface this consumer implements. - static property Platform::String^ InterfaceName - { - Platform::String^ get() { return AllJoynHelpers::MultibyteToPlatformString(m_interfaceName); } - } - - virtual property Windows::Devices::AllJoyn::AllJoynBusObject^ BusObject - { - Windows::Devices::AllJoyn::AllJoynBusObject^ get() { return m_busObject; } - } - - virtual property Windows::Devices::AllJoyn::AllJoynSession^ Session - { - Windows::Devices::AllJoyn::AllJoynSession^ get() { return m_session; } - } - -internal: - // Consumers do not support property get. - QStatus OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg val) - { - UNREFERENCED_PARAMETER(interfaceName); UNREFERENCED_PARAMETER(propertyName); UNREFERENCED_PARAMETER(val); - return ER_NOT_IMPLEMENTED; - } - - // Consumers do not support property set. - QStatus OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg val) - { - UNREFERENCED_PARAMETER(interfaceName); UNREFERENCED_PARAMETER(propertyName); UNREFERENCED_PARAMETER(val); - return ER_NOT_IMPLEMENTED; - } - - void OnPropertyChanged(_In_ alljoyn_proxybusobject obj, _In_ PCSTR interfaceName, _In_ const alljoyn_msgarg changed, _In_ const alljoyn_msgarg invalidated); - - property Platform::String^ ServiceObjectPath - { - Platform::String^ get() { return m_ServiceObjectPath; } - void set(Platform::String^ value) { m_ServiceObjectPath = value; } - } - - property alljoyn_proxybusobject ProxyBusObject - { - alljoyn_proxybusobject get() { return m_proxyBusObject; } - void set(alljoyn_proxybusobject value) { m_proxyBusObject = value; } - } - -private: - virtual event Windows::Foundation::EventHandler^ _SessionLost; - virtual event Windows::Foundation::EventHandler^ _SessionMemberAdded; - virtual event Windows::Foundation::EventHandler^ _SessionMemberRemoved; - - // Register a callback function to handle incoming signals. - QStatus AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler); - - // "This signal is emitted when the connection attempt against the personal AP is completed" - static void CallConnectionResultSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message); - - Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment; - Windows::Devices::AllJoyn::AllJoynBusObject^ m_busObject; - Windows::Devices::AllJoyn::AllJoynSession^ m_session; - OnboardingSignals^ m_signals; - Platform::String^ m_ServiceObjectPath; - - alljoyn_proxybusobject m_proxyBusObject; - alljoyn_sessionlistener m_sessionListener; - alljoyn_busobject m_nativeBusObject; - alljoyn_busattachment m_nativeBusAttachment; - - // Used to pass a pointer to this class to callbacks - Platform::WeakReference* m_weak; - - // This map is required because we need a way to pass the consumer to the signal - // handlers, but the current AllJoyn C API does not allow passing a context to these - // callbacks. - static std::map SourceInterfaces; - - // The name of the interface this consumer implements. - static PCSTR m_interfaceName; -}; - -} } } diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingEventArgs.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingEventArgs.h deleted file mode 100644 index ff8beb311c..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingEventArgs.h +++ /dev/null @@ -1,50 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace org { namespace alljoyn { namespace Onboarding { - -// Signals -// "This signal is emitted when the connection attempt against the personal AP is completed" -public ref class OnboardingConnectionResultReceivedEventArgs sealed -{ -public: - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - void set(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ value) { m_messageInfo = value; } - } - - property Onboarding^ Arg - { - Onboarding^ get() { return m_interfaceMemberArg; } - internal: - void set(_In_ Onboarding^ value) { m_interfaceMemberArg = value; } - } - -private: - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - - Onboarding^ m_interfaceMemberArg; -}; - - -} } } diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.cpp deleted file mode 100644 index 3943ad7944..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.cpp +++ /dev/null @@ -1,67 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Devices::AllJoyn; -using namespace Windows::Foundation; -using namespace org::alljoyn::Onboarding; - -void OnboardingLegacySignals::Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId) -{ - m_busObject = busObject; - m_sessionId = sessionId; - - auto interfaceDefinition = alljoyn_busattachment_getinterface(alljoyn_busobject_getbusattachment(busObject), "org.alljoyn.Onboarding"); - alljoyn_interfacedescription_getmember(interfaceDefinition, "ConnectionResult", &m_memberConnectionResult); -} - -void OnboardingLegacySignals::ConnectionResult(_In_ Onboarding^ interfaceMemberArg) -{ - if (nullptr == m_busObject) - { - return; - } - - size_t argCount = 1; - alljoyn_msgarg arguments = alljoyn_msgarg_array_create(argCount); - (void)TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "(ns)", interfaceMemberArg); - - alljoyn_busobject_signal( - m_busObject, - NULL, // Generated code only supports broadcast signals. - m_sessionId, - m_memberConnectionResult, - arguments, - argCount, - 0, // A signal with a TTL of 0 will be sent to every member of the session, regardless of how long it takes to deliver the message - ALLJOYN_MESSAGE_FLAG_GLOBAL_BROADCAST, // Broadcast to everyone in the session. - NULL); // The generated code does not need the generated signal message - - alljoyn_msgarg_destroy(arguments); -} - -void OnboardingLegacySignals::CallConnectionResultReceived(_In_ OnboardingLegacySignals^ sender, _In_ OnboardingConnectionResultReceivedEventArgs^ args) -{ - ConnectionResultReceived(sender, args); -} - diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.h deleted file mode 100644 index 3e3aac566d..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.h +++ /dev/null @@ -1,74 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace org { namespace alljoyn { namespace Onboarding { - -ref class OnboardingLegacySignals; - -public interface class IOnboardingLegacySignals -{ - event Windows::Foundation::TypedEventHandler^ ConnectionResultReceived; -}; - -public ref class OnboardingLegacySignals sealed : [Windows::Foundation::Metadata::Default] IOnboardingLegacySignals -{ -public: - // "This signal is emitted when the connection attempt against the personal AP is completed" - // Calling this method will send the ConnectionResult signal to every member of the session. - 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 - { - 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(OnboardingLegacySignals^ sender, OnboardingConnectionResultReceivedEventArgs^ args) - { - _ConnectionResultReceived(sender, args); - } - } - -internal: - void Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId); - void CallConnectionResultReceived(_In_ OnboardingLegacySignals^ sender, _In_ OnboardingConnectionResultReceivedEventArgs^ args); - -private: - alljoyn_busobject m_busObject; - alljoyn_sessionid m_sessionId; - - virtual event Windows::Foundation::EventHandler^ _ConnectionResultReceived; - - alljoyn_interfacedescription_member m_memberConnectionResult; -}; - -} } } \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h deleted file mode 100644 index eabd9c7507..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h +++ /dev/null @@ -1,326 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -using namespace concurrency; - -namespace org { namespace alljoyn { namespace Onboarding { - -ref class OnboardingConsumer; - -public ref class OnboardingConfigureWiFiResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - property int16 Status2 - { - int16 get() { return m_interfaceMemberStatus2; } - internal: - void set(_In_ int16 value) { m_interfaceMemberStatus2 = value; } - } - - static OnboardingConfigureWiFiResult^ CreateSuccessResult(_In_ int16 interfaceMemberStatus2) - { - 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; - } - - static OnboardingConfigureWiFiResult^ CreateFailureResult(_In_ int32 status) - { - auto result = ref new OnboardingConfigureWiFiResult(); - result->Status = status; - return result; - } -internal: - Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); - -private: - int32 m_status; - int16 m_interfaceMemberStatus2; -}; - -public ref class OnboardingConnectResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - - static OnboardingConnectResult^ CreateSuccessResult() - { - auto result = ref new OnboardingConnectResult(); - result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; - result->m_creationContext = Concurrency::task_continuation_context::use_current(); - return result; - } - - static OnboardingConnectResult^ CreateFailureResult(_In_ int32 status) - { - auto result = ref new OnboardingConnectResult(); - result->Status = status; - return result; - } -internal: - Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); - -private: - int32 m_status; -}; - -public ref class OnboardingOffboardResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - - static OnboardingOffboardResult^ CreateSuccessResult() - { - auto result = ref new OnboardingOffboardResult(); - result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; - result->m_creationContext = Concurrency::task_continuation_context::use_current(); - return result; - } - - static OnboardingOffboardResult^ CreateFailureResult(_In_ int32 status) - { - auto result = ref new OnboardingOffboardResult(); - result->Status = status; - return result; - } -internal: - Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); - -private: - int32 m_status; -}; - -public ref class OnboardingGetScanInfoResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - property uint16 Age - { - uint16 get() { return m_interfaceMemberAge; } - internal: - void set(_In_ uint16 value) { m_interfaceMemberAge = value; } - } - property Windows::Foundation::Collections::IVector^ ScanList - { - Windows::Foundation::Collections::IVector^ get() { return m_interfaceMemberScanList; } - internal: - void set(_In_ Windows::Foundation::Collections::IVector^ value) { m_interfaceMemberScanList = value; } - } - - static OnboardingGetScanInfoResult^ CreateSuccessResult(_In_ uint16 interfaceMemberAge, _In_ Windows::Foundation::Collections::IVector^ interfaceMemberScanList) - { - auto result = ref new OnboardingGetScanInfoResult(); - result->Status = Windows::Devices::AllJoyn::AllJoynStatus::Ok; - result->Age = interfaceMemberAge; - result->ScanList = interfaceMemberScanList; - result->m_creationContext = Concurrency::task_continuation_context::use_current(); - return result; - } - - static OnboardingGetScanInfoResult^ CreateFailureResult(_In_ int32 status) - { - auto result = ref new OnboardingGetScanInfoResult(); - result->Status = status; - return result; - } -internal: - Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); - -private: - int32 m_status; - uint16 m_interfaceMemberAge; - Windows::Foundation::Collections::IVector^ m_interfaceMemberScanList; -}; - -public ref class OnboardingJoinSessionResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - property OnboardingConsumer^ Consumer - { - OnboardingConsumer^ get() { return m_consumer; } - internal: - void set(_In_ OnboardingConsumer^ value) { m_consumer = value; } - }; - -private: - int32 m_status; - OnboardingConsumer^ m_consumer; -}; - -public ref class OnboardingGetVersionResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - // "Interface version number" - property uint16 Version - { - uint16 get() { return m_value; } - internal: - void set(_In_ uint16 value) { m_value = value; } - } - - static OnboardingGetVersionResult^ CreateSuccessResult(_In_ uint16 value) - { - 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; - } - - static OnboardingGetVersionResult^ CreateFailureResult(_In_ int32 status) - { - auto result = ref new OnboardingGetVersionResult(); - result->Status = status; - return result; - } -internal: - Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); - -private: - int32 m_status; - uint16 m_value; -}; - -public ref class OnboardingGetStateResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - // "The configuration state" - property int16 State - { - int16 get() { return m_value; } - internal: - void set(_In_ int16 value) { m_value = value; } - } - - static OnboardingGetStateResult^ CreateSuccessResult(_In_ int16 value) - { - 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; - } - - static OnboardingGetStateResult^ CreateFailureResult(_In_ int32 status) - { - auto result = ref new OnboardingGetStateResult(); - result->Status = status; - return result; - } -internal: - Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); - -private: - int32 m_status; - int16 m_value; -}; - -public ref class OnboardingGetLastErrorResult sealed -{ -public: - property int32 Status - { - int32 get() { return m_status; } - internal: - void set(_In_ int32 value) { m_status = value; } - } - - // "The last error code and error message" - property OnboardingLastError^ LastError - { - OnboardingLastError^ get() { return m_value; } - internal: - void set(_In_ OnboardingLastError^ value) { m_value = value; } - } - - static OnboardingGetLastErrorResult^ CreateSuccessResult(_In_ OnboardingLastError^ value) - { - 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; - } - - static OnboardingGetLastErrorResult^ CreateFailureResult(_In_ int32 status) - { - auto result = ref new OnboardingGetLastErrorResult(); - result->Status = status; - return result; - } -internal: - Concurrency::task_continuation_context m_creationContext = Concurrency::task_continuation_context::use_default(); - -private: - int32 m_status; - OnboardingLastError^ m_value; -}; - -} } } diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp deleted file mode 100644 index 904d310aeb..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp +++ /dev/null @@ -1,638 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace concurrency; -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Devices::AllJoyn; -using namespace org::alljoyn::Onboarding; - -std::map OnboardingProducer::SourceObjects; -std::map OnboardingProducer::SourceInterfaces; - -OnboardingProducer::OnboardingProducer(AllJoynBusAttachment^ busAttachment) - : m_busAttachment(busAttachment), - m_sessionListener(nullptr), - m_busObject(nullptr), - m_sessionPort(0), - m_sessionId(0) -{ - m_weak = new WeakReference(this); - ServiceObjectPath = ref new String(L"/Service"); - m_signals = ref new OnboardingLegacySignals(); - m_busAttachmentStateChangedToken.Value = 0; -} - -OnboardingProducer::~OnboardingProducer() -{ - UnregisterFromBus(); - delete m_weak; -} - -void OnboardingProducer::UnregisterFromBus() -{ - if ((nullptr != m_busAttachment) && (0 != m_busAttachmentStateChangedToken.Value)) - { - m_busAttachment->StateChanged -= m_busAttachmentStateChangedToken; - m_busAttachmentStateChangedToken.Value = 0; - } - if ((nullptr != m_busAttachment) && (nullptr != SessionPortListener)) - { - alljoyn_busattachment_unbindsessionport(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_sessionPort); - alljoyn_sessionportlistener_destroy(SessionPortListener); - SessionPortListener = nullptr; - } - if ((nullptr != m_busAttachment) && (nullptr != BusObject)) - { - alljoyn_busattachment_unregisterbusobject(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject); - alljoyn_busobject_destroy(BusObject); - BusObject = nullptr; - } - if ((nullptr != m_busAttachment) && (nullptr != SessionListener)) - { - alljoyn_busattachment_leavesession(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_sessionId); - alljoyn_busattachment_setsessionlistener(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_sessionId, nullptr); - alljoyn_sessionlistener_destroy(SessionListener); - SessionListener = nullptr; - } -} - -bool OnboardingProducer::OnAcceptSessionJoiner(_In_ alljoyn_sessionport sessionPort, _In_ PCSTR joiner, _In_ const alljoyn_sessionopts opts) -{ - UNREFERENCED_PARAMETER(sessionPort); UNREFERENCED_PARAMETER(joiner); UNREFERENCED_PARAMETER(opts); - - return true; -} - -void OnboardingProducer::OnSessionJoined(_In_ alljoyn_sessionport sessionPort, _In_ alljoyn_sessionid id, _In_ PCSTR joiner) -{ - UNREFERENCED_PARAMETER(joiner); - - // We initialize the Signals object after the session has been joined, because it needs - // the session id. - m_signals->Initialize(BusObject, id); - m_sessionPort = sessionPort; - m_sessionId = id; - - alljoyn_sessionlistener_callbacks callbacks = - { - AllJoynHelpers::SessionLostHandler, - AllJoynHelpers::SessionMemberAddedHandler, - AllJoynHelpers::SessionMemberRemovedHandler - }; - - SessionListener = alljoyn_sessionlistener_create(&callbacks, m_weak); - alljoyn_busattachment_setsessionlistener(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), id, SessionListener); -} - -void OnboardingProducer::OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason) -{ - if (sessionId == m_sessionId) - { - AllJoynSessionLostEventArgs^ args = ref new AllJoynSessionLostEventArgs(static_cast(reason)); - SessionLost(this, args); - } -} - -void OnboardingProducer::OnSessionMemberAdded(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName) -{ - if (sessionId == m_sessionId) - { - auto args = ref new AllJoynSessionMemberAddedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName)); - SessionMemberAdded(this, args); - } -} - -void OnboardingProducer::OnSessionMemberRemoved(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName) -{ - if (sessionId == m_sessionId) - { - auto args = ref new AllJoynSessionMemberRemovedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName)); - SessionMemberRemoved(this, args); - } -} - -void OnboardingProducer::BusAttachmentStateChanged(_In_ AllJoynBusAttachment^ sender, _In_ AllJoynBusAttachmentStateChangedEventArgs^ args) -{ - if (args->State == AllJoynBusAttachmentState::Connected) - { - QStatus result = AllJoynHelpers::CreateProducerSession(m_busAttachment, m_weak); - if (ER_OK != result) - { - StopInternal(result); - return; - } - } - else if (args->State == AllJoynBusAttachmentState::Disconnected) - { - StopInternal(ER_BUS_STOPPING); - } -} - -void OnboardingProducer::CallConfigureWiFiHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message) -{ - auto source = SourceObjects.find(busObject); - if (source == SourceObjects.end()) - { - return; - } - - OnboardingProducer^ producer = source->second->Resolve(); - if (producer->Service != nullptr) - { - AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - - Platform::String^ inputArg0; - (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "s", &inputArg0); - Platform::String^ inputArg1; - (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 1), "s", &inputArg1); - int16 inputArg2; - (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 2), "n", &inputArg2); - - OnboardingConfigureWiFiResult^ result = create_task(producer->Service->ConfigureWiFiAsync(callInfo, inputArg0, inputArg1, inputArg2)).get(); - create_task([](){}).then([=] - { - int32 status; - - if (nullptr == result) - { - alljoyn_busobject_methodreply_status(busObject, message, ER_BUS_NO_LISTENER); - return; - } - - status = result->Status; - if (AllJoynStatus::Ok != status) - { - alljoyn_busobject_methodreply_status(busObject, message, static_cast(status)); - return; - } - - size_t argCount = 1; - alljoyn_msgarg outputs = alljoyn_msgarg_array_create(argCount); - - status = TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(outputs, 0), "n", result->Status2); - if (AllJoynStatus::Ok != status) - { - alljoyn_busobject_methodreply_status(busObject, message, static_cast(status)); - alljoyn_msgarg_destroy(outputs); - return; - } - - alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount); - alljoyn_msgarg_destroy(outputs); - }, result->m_creationContext).wait(); - } -} - -void OnboardingProducer::CallConnectHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message) -{ - auto source = SourceObjects.find(busObject); - if (source == SourceObjects.end()) - { - return; - } - - OnboardingProducer^ producer = source->second->Resolve(); - if (producer->Service != nullptr) - { - AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - - - OnboardingConnectResult^ result = create_task(producer->Service->ConnectAsync(callInfo)).get(); - create_task([](){}).then([=] - { - int32 status; - - if (nullptr == result) - { - alljoyn_busobject_methodreply_status(busObject, message, ER_BUS_NO_LISTENER); - return; - } - - status = result->Status; - if (AllJoynStatus::Ok != status) - { - alljoyn_busobject_methodreply_status(busObject, message, static_cast(status)); - return; - } - - size_t argCount = 0; - alljoyn_msgarg outputs = alljoyn_msgarg_array_create(argCount); - - alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount); - alljoyn_msgarg_destroy(outputs); - }, result->m_creationContext).wait(); - } -} - -void OnboardingProducer::CallOffboardHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message) -{ - auto source = SourceObjects.find(busObject); - if (source == SourceObjects.end()) - { - return; - } - - OnboardingProducer^ producer = source->second->Resolve(); - if (producer->Service != nullptr) - { - AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - - - OnboardingOffboardResult^ result = create_task(producer->Service->OffboardAsync(callInfo)).get(); - create_task([](){}).then([=] - { - int32 status; - - if (nullptr == result) - { - alljoyn_busobject_methodreply_status(busObject, message, ER_BUS_NO_LISTENER); - return; - } - - status = result->Status; - if (AllJoynStatus::Ok != status) - { - alljoyn_busobject_methodreply_status(busObject, message, static_cast(status)); - return; - } - - size_t argCount = 0; - alljoyn_msgarg outputs = alljoyn_msgarg_array_create(argCount); - - alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount); - alljoyn_msgarg_destroy(outputs); - }, result->m_creationContext).wait(); - } -} - -void OnboardingProducer::CallGetScanInfoHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message) -{ - auto source = SourceObjects.find(busObject); - if (source == SourceObjects.end()) - { - return; - } - - OnboardingProducer^ producer = source->second->Resolve(); - if (producer->Service != nullptr) - { - AllJoynMessageInfo^ callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - - - OnboardingGetScanInfoResult^ result = create_task(producer->Service->GetScanInfoAsync(callInfo)).get(); - create_task([](){}).then([=] - { - int32 status; - - if (nullptr == result) - { - alljoyn_busobject_methodreply_status(busObject, message, ER_BUS_NO_LISTENER); - return; - } - - status = result->Status; - if (AllJoynStatus::Ok != status) - { - alljoyn_busobject_methodreply_status(busObject, message, static_cast(status)); - return; - } - - size_t argCount = 2; - alljoyn_msgarg outputs = alljoyn_msgarg_array_create(argCount); - - status = TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(outputs, 0), "q", result->Age); - if (AllJoynStatus::Ok != status) - { - alljoyn_busobject_methodreply_status(busObject, message, static_cast(status)); - alljoyn_msgarg_destroy(outputs); - return; - } - - status = TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(outputs, 1), "a(sn)", result->ScanList); - if (AllJoynStatus::Ok != status) - { - alljoyn_busobject_methodreply_status(busObject, message, static_cast(status)); - alljoyn_msgarg_destroy(outputs); - return; - } - - alljoyn_busobject_methodreply_args(busObject, message, outputs, argCount); - alljoyn_msgarg_destroy(outputs); - }, result->m_creationContext).wait(); - } -} - -void OnboardingProducer::CallConnectionResultSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message) -{ - auto source = SourceInterfaces.find(member->iface); - if (source == SourceInterfaces.end()) - { - return; - } - - auto producer = source->second->Resolve(); - if (producer->Signals != nullptr) - { - auto callInfo = ref new AllJoynMessageInfo(AllJoynHelpers::MultibyteToPlatformString(alljoyn_message_getsender(message))); - auto eventArgs = ref new OnboardingConnectionResultReceivedEventArgs(); - eventArgs->MessageInfo = callInfo; - - Onboarding^ argument0; - (void)TypeConversionHelpers::GetAllJoynMessageArg(alljoyn_message_getarg(message, 0), "(ns)", &argument0); - eventArgs->Arg = argument0; - - producer->Signals->CallConnectionResultReceived(producer->Signals, eventArgs); - } -} - -QStatus OnboardingProducer::AddMethodHandler(_In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_methodhandler_ptr handler) -{ - alljoyn_interfacedescription_member member; - if (!alljoyn_interfacedescription_getmember(interfaceDescription, methodName, &member)) - { - return ER_BUS_INTERFACE_NO_SUCH_MEMBER; - } - - return alljoyn_busobject_addmethodhandler( - m_busObject, - member, - handler, - m_weak); -} - -QStatus OnboardingProducer::AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler) -{ - alljoyn_interfacedescription_member member; - if (!alljoyn_interfacedescription_getmember(interfaceDescription, methodName, &member)) - { - return ER_BUS_INTERFACE_NO_SUCH_MEMBER; - } - - return alljoyn_busattachment_registersignalhandler(busAttachment, handler, member, NULL); -} - -QStatus OnboardingProducer::OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg value) -{ - UNREFERENCED_PARAMETER(interfaceName); - - if (0 == strcmp(propertyName, "Version")) - { - auto task = create_task(Service->GetVersionAsync(nullptr)); - auto result = task.get(); - - 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(); - - 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(); - - 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; -} - -QStatus OnboardingProducer::OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg value) -{ - UNREFERENCED_PARAMETER(interfaceName); - - return ER_BUS_NO_SUCH_PROPERTY; -} - -void OnboardingProducer::Start() -{ - if (nullptr == m_busAttachment) - { - StopInternal(ER_FAIL); - return; - } - - QStatus result = AllJoynHelpers::CreateInterfaces(m_busAttachment, c_OnboardingIntrospectionXml); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - result = AllJoynHelpers::CreateBusObject(m_weak); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - alljoyn_interfacedescription interfaceDescription = alljoyn_busattachment_getinterface(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), "org.alljoyn.Onboarding"); - if (interfaceDescription == nullptr) - { - StopInternal(ER_FAIL); - return; - } - alljoyn_busobject_addinterface_announced(BusObject, interfaceDescription); - - result = AddMethodHandler( - interfaceDescription, - "ConfigureWiFi", - [](alljoyn_busobject busObject, const alljoyn_interfacedescription_member* member, alljoyn_message message) { UNREFERENCED_PARAMETER(member); CallConfigureWiFiHandler(busObject, message); }); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - result = AddMethodHandler( - interfaceDescription, - "Connect", - [](alljoyn_busobject busObject, const alljoyn_interfacedescription_member* member, alljoyn_message message) { UNREFERENCED_PARAMETER(member); CallConnectHandler(busObject, message); }); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - result = AddMethodHandler( - interfaceDescription, - "Offboard", - [](alljoyn_busobject busObject, const alljoyn_interfacedescription_member* member, alljoyn_message message) { UNREFERENCED_PARAMETER(member); CallOffboardHandler(busObject, message); }); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - result = AddMethodHandler( - interfaceDescription, - "GetScanInfo", - [](alljoyn_busobject busObject, const alljoyn_interfacedescription_member* member, alljoyn_message message) { UNREFERENCED_PARAMETER(member); CallGetScanInfoHandler(busObject, message); }); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - result = AddSignalHandler( - AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), - interfaceDescription, - "ConnectionResult", - [](const alljoyn_interfacedescription_member* member, PCSTR srcPath, alljoyn_message message) { UNREFERENCED_PARAMETER(srcPath); CallConnectionResultSignalHandler(member, message); }); - if (result != ER_OK) - { - StopInternal(result); - return; - } - - SourceObjects[m_busObject] = m_weak; - SourceInterfaces[interfaceDescription] = m_weak; - - unsigned int noneMechanismIndex = 0; - bool authenticationMechanismsContainsNone = m_busAttachment->AuthenticationMechanisms->IndexOf(AllJoynAuthenticationMechanism::None, &noneMechanismIndex); - QCC_BOOL interfaceIsSecure = alljoyn_interfacedescription_issecure(interfaceDescription); - - // If the current set of AuthenticationMechanisms supports authentication, - // determine whether a secure BusObject is required. - if (AllJoynHelpers::CanSecure(m_busAttachment->AuthenticationMechanisms)) - { - // Register the BusObject as "secure" if the org.alljoyn.Bus.Secure XML annotation - // is specified, or if None is not present in AuthenticationMechanisms. - if (!authenticationMechanismsContainsNone || interfaceIsSecure) - { - result = alljoyn_busattachment_registerbusobject_secure(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject); - } - else - { - result = alljoyn_busattachment_registerbusobject(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject); - } - } - else - { - // If the current set of AuthenticationMechanisms does not support authentication - // but the interface requires security, report an error. - if (interfaceIsSecure) - { - result = ER_BUS_NO_AUTHENTICATION_MECHANISM; - } - else - { - result = alljoyn_busattachment_registerbusobject(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), BusObject); - } - } - - if (result != ER_OK) - { - StopInternal(result); - return; - } - - m_busAttachmentStateChangedToken = m_busAttachment->StateChanged += ref new TypedEventHandler(this, &OnboardingProducer::BusAttachmentStateChanged); - m_busAttachment->Connect(); -} - -void OnboardingProducer::Stop() -{ - StopInternal(AllJoynStatus::Ok); -} - -void OnboardingProducer::StopInternal(int32 status) -{ - UnregisterFromBus(); - Stopped(this, ref new AllJoynProducerStoppedEventArgs(status)); -} - -int32 OnboardingProducer::RemoveMemberFromSession(_In_ String^ uniqueName) -{ - return alljoyn_busattachment_removesessionmember( - AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), - m_sessionId, - AllJoynHelpers::PlatformToMultibyteString(uniqueName).data()); -} - -PCSTR org::alljoyn::Onboarding::c_OnboardingIntrospectionXml = "" -" A secure onboarding interface" -" " -" " -" Interface version number" -" " -" " -" " -" The configuration state" -" " -" " -" " -" The last error code and error message" -" " -" " -" " -" Sends the personal AP information to the onboardee" -" " -" " -" " -" " -" " -" " -" Tells the onboardee to connect to the personal AP" -" " -" " -" " -" Tells the onboardee to disconnect from the personal AP" -" " -" " -" " -" Scans all the Wi-Fi access points in the onboardee's proximity" -" " -" " -" " -" " -" This signal is emitted when the connection attempt against the personal AP is completed" -" " -" " -"" -; \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h deleted file mode 100644 index 497043ca94..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h +++ /dev/null @@ -1,249 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace org { namespace alljoyn { namespace Onboarding { - -extern PCSTR c_OnboardingIntrospectionXml; - -ref class OnboardingProducer; - -public interface class IOnboardingProducer -{ - event Windows::Foundation::TypedEventHandler^ Stopped; - event Windows::Foundation::TypedEventHandler^ SessionLost; - event Windows::Foundation::TypedEventHandler^ SessionMemberAdded; - event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved; -}; - -public ref class OnboardingProducer sealed : [Windows::Foundation::Metadata::Default] IOnboardingProducer -{ -public: - OnboardingProducer(Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment); - virtual ~OnboardingProducer(); - - // The implementation of IOnboardingService that will handle method calls and property requests. - property IOnboardingService^ Service - { - IOnboardingService^ get() { return m_serviceInterface; } - void set(IOnboardingService^ value) { m_serviceInterface = value; } - } - - // Used to send signals or register functions to handle received signals. - property OnboardingLegacySignals^ Signals - { - OnboardingLegacySignals^ get() { return m_signals; } - } - - // This event will fire whenever this producer is 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 - { - 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 - { - 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 - { - 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(); - - // Stop advertising the service. - void Stop(); - - // Remove a member that has joined this session. - int32 RemoveMemberFromSession(_In_ Platform::String^ uniqueName); - -internal: - bool OnAcceptSessionJoiner(_In_ alljoyn_sessionport sessionPort, _In_ PCSTR joiner, _In_ const alljoyn_sessionopts opts); - void OnSessionJoined(_In_ alljoyn_sessionport sessionPort, _In_ alljoyn_sessionid id, _In_ PCSTR joiner); - QStatus OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg val); - QStatus OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg val); - void OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason); - void OnSessionMemberAdded(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName); - void OnSessionMemberRemoved(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName); - - property Platform::String^ ServiceObjectPath - { - Platform::String^ get() { return m_ServiceObjectPath; } - void set(Platform::String^ value) { m_ServiceObjectPath = value; } - } - - property alljoyn_busobject BusObject - { - alljoyn_busobject get() { return m_busObject; } - void set(alljoyn_busobject value) { m_busObject = value; } - } - - property alljoyn_sessionportlistener SessionPortListener - { - alljoyn_sessionportlistener get() { return m_sessionPortListener; } - void set(alljoyn_sessionportlistener value) { m_sessionPortListener = value; } - } - - property alljoyn_sessionlistener SessionListener - { - alljoyn_sessionlistener get() { return m_sessionListener; } - void set(alljoyn_sessionlistener value) { m_sessionListener = value; } - } - - property alljoyn_sessionport SessionPort - { - alljoyn_sessionport get() { return m_sessionPort; } - internal: - void set(alljoyn_sessionport value) { m_sessionPort = value; } - } - - property alljoyn_sessionid SessionId - { - alljoyn_sessionid get() { return m_sessionId; } - } - - // Stop advertising the service and pass status to anyone listening for the Stopped event. - void StopInternal(int32 status); - - 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; - - // "Sends the personal AP information to the onboardee" - static void CallConfigureWiFiHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message); - // "Tells the onboardee to connect to the personal AP" - static void CallConnectHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message); - // "Tells the onboardee to disconnect from the personal AP" - static void CallOffboardHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message); - // "Scans all the Wi-Fi access points in the onboardee's proximity" - static void CallGetScanInfoHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message); - // "This signal is emitted when the connection attempt against the personal AP is completed" - static void CallConnectionResultSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message); - - // Register a callback function to handle methods. - QStatus AddMethodHandler(_In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_methodhandler_ptr handler); - // Register a callback function to handle incoming signals. - QStatus AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler); - - void UnregisterFromBus(); - - Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment; - Windows::Foundation::EventRegistrationToken m_busAttachmentStateChangedToken; - OnboardingLegacySignals^ m_signals; - IOnboardingService^ m_serviceInterface; - Platform::String^ m_ServiceObjectPath; - - alljoyn_busobject m_busObject; - alljoyn_sessionportlistener m_sessionPortListener; - alljoyn_sessionlistener m_sessionListener; - alljoyn_sessionport m_sessionPort; - alljoyn_sessionid m_sessionId; - - // Used to pass a pointer to this class to callbacks - Platform::WeakReference* m_weak; - - // These maps are required because we need a way to pass the producer to the method - // and signal handlers, but the current AllJoyn C API does not allow passing a context to these - // callbacks. - static std::map SourceObjects; - static std::map SourceInterfaces; -}; - -} } } \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp deleted file mode 100644 index 1a86b78f0c..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp +++ /dev/null @@ -1,86 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Devices::AllJoyn; -using namespace org::alljoyn::Onboarding; - -// Note: Unlike an Interface implementation, which provides a single handler for each member, the event -// model allows for 0 or more listeners to be registered. The EventAdapter implementation deals with this -// difference by implementing a last-writer-wins policy. The lack of any return value (i.e., 0 listeners) -// is handled by returning a null result. - -// Methods -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); - ConfigureWiFiCalled(this, args); - return OnboardingConfigureWiFiCalledEventArgs::GetResultAsync(args); -} - -IAsyncOperation^ OnboardingServiceEventAdapter::ConnectAsync(_In_ AllJoynMessageInfo^ info) -{ - auto args = ref new OnboardingConnectCalledEventArgs(info); - ConnectCalled(this, args); - return OnboardingConnectCalledEventArgs::GetResultAsync(args); -} - -IAsyncOperation^ OnboardingServiceEventAdapter::OffboardAsync(_In_ AllJoynMessageInfo^ info) -{ - auto args = ref new OnboardingOffboardCalledEventArgs(info); - OffboardCalled(this, args); - return OnboardingOffboardCalledEventArgs::GetResultAsync(args); -} - -IAsyncOperation^ OnboardingServiceEventAdapter::GetScanInfoAsync(_In_ AllJoynMessageInfo^ info) -{ - auto args = ref new OnboardingGetScanInfoCalledEventArgs(info); - GetScanInfoCalled(this, args); - return OnboardingGetScanInfoCalledEventArgs::GetResultAsync(args); -} - -// Property Reads -IAsyncOperation^ OnboardingServiceEventAdapter::GetVersionAsync(_In_ AllJoynMessageInfo^ info) -{ - auto args = ref new OnboardingGetVersionRequestedEventArgs(info); - GetVersionRequested(this, args); - return OnboardingGetVersionRequestedEventArgs::GetResultAsync(args); -} - -IAsyncOperation^ OnboardingServiceEventAdapter::GetStateAsync(_In_ AllJoynMessageInfo^ info) -{ - auto args = ref new OnboardingGetStateRequestedEventArgs(info); - GetStateRequested(this, args); - return OnboardingGetStateRequestedEventArgs::GetResultAsync(args); -} - -IAsyncOperation^ OnboardingServiceEventAdapter::GetLastErrorAsync(_In_ AllJoynMessageInfo^ info) -{ - auto args = ref new OnboardingGetLastErrorRequestedEventArgs(info); - GetLastErrorRequested(this, args); - return OnboardingGetLastErrorRequestedEventArgs::GetResultAsync(args); -} - -// Property Writes diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h deleted file mode 100644 index c6a5f2a4d8..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h +++ /dev/null @@ -1,202 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace org { namespace alljoyn { namespace Onboarding { - -// This class, and the associated EventArgs classes, exist for the benefit of JavaScript developers who -// do not have the ability to implement IOnboardingService. Instead, OnboardingServiceEventAdapter -// provides the Interface implementation and exposes a set of compatible events to the developer. -public ref class OnboardingServiceEventAdapter sealed : [Windows::Foundation::Metadata::Default] IOnboardingService -{ -public: - // Method Invocation Events - 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 - { - 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); - virtual Windows::Foundation::IAsyncOperation^ OffboardAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - virtual Windows::Foundation::IAsyncOperation^ GetScanInfoAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - virtual Windows::Foundation::IAsyncOperation^ GetVersionAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - 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 deleted file mode 100644 index fde0ade6cb..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.cpp +++ /dev/null @@ -1,566 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace concurrency; -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Devices::AllJoyn; -using namespace org::alljoyn::Onboarding; -namespace org { namespace alljoyn { namespace Onboarding { - -// Methods -OnboardingConfigureWiFiCalledEventArgs::OnboardingConfigureWiFiCalledEventArgs( - _In_ AllJoynMessageInfo^ info, - _In_ Platform::String^ interfaceMemberSSID, - _In_ Platform::String^ interfaceMemberPassphrase, - _In_ int16 interfaceMemberAuthType) - : m_raised(false), - m_completionsRequired(0), - m_messageInfo(info), - m_interfaceMemberSSID(interfaceMemberSSID), - m_interfaceMemberPassphrase(interfaceMemberPassphrase), - m_interfaceMemberAuthType(interfaceMemberAuthType) -{ - m_result = OnboardingConfigureWiFiResult::CreateFailureResult(ER_NOT_IMPLEMENTED); -} - -Deferral^ OnboardingConfigureWiFiCalledEventArgs::GetDeferral() -{ - std::lock_guard lockGuard(m_lock); - if (m_raised) - { - // Cannot ask for a deferral after the event handler has returned. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - - m_completionsRequired++; - auto handler = ref new DeferralCompletedHandler(this, &OnboardingConfigureWiFiCalledEventArgs::Complete); - return ref new Deferral(handler); -} - -void OnboardingConfigureWiFiCalledEventArgs::InvokeAllFinished() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - m_raised = true; - invokeNeeded = (m_completionsRequired == 0); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingConfigureWiFiCalledEventArgs::Complete() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - if (m_completionsRequired == 0) - { - // This should never happen since Complete() should only be called by Windows.Foundation.Deferral - // which will only invoke our completion handler once. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - m_completionsRequired--; - invokeNeeded = (m_raised && (m_completionsRequired == 0)); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingConfigureWiFiCalledEventArgs::InvokeCompleteHandler() -{ - if (m_result->Status == ER_NOT_IMPLEMENTED) - { - throw Exception::CreateException(E_NOTIMPL, "No handlers are registered for ConfigureWiFiCalled."); - } - else - { - m_tce.set(m_result); - } -} - -OnboardingConnectCalledEventArgs::OnboardingConnectCalledEventArgs( - _In_ AllJoynMessageInfo^ info) - : m_raised(false), - m_completionsRequired(0), - m_messageInfo(info) -{ - m_result = OnboardingConnectResult::CreateFailureResult(ER_NOT_IMPLEMENTED); -} - -Deferral^ OnboardingConnectCalledEventArgs::GetDeferral() -{ - std::lock_guard lockGuard(m_lock); - if (m_raised) - { - // Cannot ask for a deferral after the event handler has returned. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - - m_completionsRequired++; - auto handler = ref new DeferralCompletedHandler(this, &OnboardingConnectCalledEventArgs::Complete); - return ref new Deferral(handler); -} - -void OnboardingConnectCalledEventArgs::InvokeAllFinished() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - m_raised = true; - invokeNeeded = (m_completionsRequired == 0); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingConnectCalledEventArgs::Complete() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - if (m_completionsRequired == 0) - { - // This should never happen since Complete() should only be called by Windows.Foundation.Deferral - // which will only invoke our completion handler once. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - m_completionsRequired--; - invokeNeeded = (m_raised && (m_completionsRequired == 0)); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingConnectCalledEventArgs::InvokeCompleteHandler() -{ - if (m_result->Status == ER_NOT_IMPLEMENTED) - { - throw Exception::CreateException(E_NOTIMPL, "No handlers are registered for ConnectCalled."); - } - else - { - m_tce.set(m_result); - } -} - -OnboardingOffboardCalledEventArgs::OnboardingOffboardCalledEventArgs( - _In_ AllJoynMessageInfo^ info) - : m_raised(false), - m_completionsRequired(0), - m_messageInfo(info) -{ - m_result = OnboardingOffboardResult::CreateFailureResult(ER_NOT_IMPLEMENTED); -} - -Deferral^ OnboardingOffboardCalledEventArgs::GetDeferral() -{ - std::lock_guard lockGuard(m_lock); - if (m_raised) - { - // Cannot ask for a deferral after the event handler has returned. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - - m_completionsRequired++; - auto handler = ref new DeferralCompletedHandler(this, &OnboardingOffboardCalledEventArgs::Complete); - return ref new Deferral(handler); -} - -void OnboardingOffboardCalledEventArgs::InvokeAllFinished() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - m_raised = true; - invokeNeeded = (m_completionsRequired == 0); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingOffboardCalledEventArgs::Complete() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - if (m_completionsRequired == 0) - { - // This should never happen since Complete() should only be called by Windows.Foundation.Deferral - // which will only invoke our completion handler once. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - m_completionsRequired--; - invokeNeeded = (m_raised && (m_completionsRequired == 0)); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingOffboardCalledEventArgs::InvokeCompleteHandler() -{ - if (m_result->Status == ER_NOT_IMPLEMENTED) - { - throw Exception::CreateException(E_NOTIMPL, "No handlers are registered for OffboardCalled."); - } - else - { - m_tce.set(m_result); - } -} - -OnboardingGetScanInfoCalledEventArgs::OnboardingGetScanInfoCalledEventArgs( - _In_ AllJoynMessageInfo^ info) - : m_raised(false), - m_completionsRequired(0), - m_messageInfo(info) -{ - m_result = OnboardingGetScanInfoResult::CreateFailureResult(ER_NOT_IMPLEMENTED); -} - -Deferral^ OnboardingGetScanInfoCalledEventArgs::GetDeferral() -{ - std::lock_guard lockGuard(m_lock); - if (m_raised) - { - // Cannot ask for a deferral after the event handler has returned. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - - m_completionsRequired++; - auto handler = ref new DeferralCompletedHandler(this, &OnboardingGetScanInfoCalledEventArgs::Complete); - return ref new Deferral(handler); -} - -void OnboardingGetScanInfoCalledEventArgs::InvokeAllFinished() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - m_raised = true; - invokeNeeded = (m_completionsRequired == 0); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingGetScanInfoCalledEventArgs::Complete() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - if (m_completionsRequired == 0) - { - // This should never happen since Complete() should only be called by Windows.Foundation.Deferral - // which will only invoke our completion handler once. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - m_completionsRequired--; - invokeNeeded = (m_raised && (m_completionsRequired == 0)); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingGetScanInfoCalledEventArgs::InvokeCompleteHandler() -{ - if (m_result->Status == ER_NOT_IMPLEMENTED) - { - throw Exception::CreateException(E_NOTIMPL, "No handlers are registered for GetScanInfoCalled."); - } - else - { - m_tce.set(m_result); - } -} - -// Readable Properties -OnboardingGetVersionRequestedEventArgs::OnboardingGetVersionRequestedEventArgs( - _In_ AllJoynMessageInfo^ info) - : m_raised(false), - m_completionsRequired(0), - m_messageInfo(info) -{ - m_result = OnboardingGetVersionResult::CreateFailureResult(ER_NOT_IMPLEMENTED); -} - -Deferral^ OnboardingGetVersionRequestedEventArgs::GetDeferral() -{ - std::lock_guard lockGuard(m_lock); - if (m_raised) - { - // Cannot ask for a deferral after the event handler has returned. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - - m_completionsRequired++; - auto handler = ref new DeferralCompletedHandler(this, &OnboardingGetVersionRequestedEventArgs::Complete); - return ref new Deferral(handler); -} - -void OnboardingGetVersionRequestedEventArgs::InvokeAllFinished() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - m_raised = true; - invokeNeeded = (m_completionsRequired == 0); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingGetVersionRequestedEventArgs::Complete() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - if (m_completionsRequired == 0) - { - // This should never happen since Complete() should only be called by Windows.Foundation.Deferral - // which will only invoke our completion handler once. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - m_completionsRequired--; - invokeNeeded = (m_raised && (m_completionsRequired == 0)); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingGetVersionRequestedEventArgs::InvokeCompleteHandler() -{ - if (m_result->Status == ER_NOT_IMPLEMENTED) - { - throw Exception::CreateException(E_NOTIMPL, "No handlers are registered for GetVersionRequested."); - } - else - { - m_tce.set(m_result); - } -} - -OnboardingGetStateRequestedEventArgs::OnboardingGetStateRequestedEventArgs( - _In_ AllJoynMessageInfo^ info) - : m_raised(false), - m_completionsRequired(0), - m_messageInfo(info) -{ - m_result = OnboardingGetStateResult::CreateFailureResult(ER_NOT_IMPLEMENTED); -} - -Deferral^ OnboardingGetStateRequestedEventArgs::GetDeferral() -{ - std::lock_guard lockGuard(m_lock); - if (m_raised) - { - // Cannot ask for a deferral after the event handler has returned. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - - m_completionsRequired++; - auto handler = ref new DeferralCompletedHandler(this, &OnboardingGetStateRequestedEventArgs::Complete); - return ref new Deferral(handler); -} - -void OnboardingGetStateRequestedEventArgs::InvokeAllFinished() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - m_raised = true; - invokeNeeded = (m_completionsRequired == 0); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingGetStateRequestedEventArgs::Complete() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - if (m_completionsRequired == 0) - { - // This should never happen since Complete() should only be called by Windows.Foundation.Deferral - // which will only invoke our completion handler once. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - m_completionsRequired--; - invokeNeeded = (m_raised && (m_completionsRequired == 0)); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingGetStateRequestedEventArgs::InvokeCompleteHandler() -{ - if (m_result->Status == ER_NOT_IMPLEMENTED) - { - throw Exception::CreateException(E_NOTIMPL, "No handlers are registered for GetStateRequested."); - } - else - { - m_tce.set(m_result); - } -} - -OnboardingGetLastErrorRequestedEventArgs::OnboardingGetLastErrorRequestedEventArgs( - _In_ AllJoynMessageInfo^ info) - : m_raised(false), - m_completionsRequired(0), - m_messageInfo(info) -{ - m_result = OnboardingGetLastErrorResult::CreateFailureResult(ER_NOT_IMPLEMENTED); -} - -Deferral^ OnboardingGetLastErrorRequestedEventArgs::GetDeferral() -{ - std::lock_guard lockGuard(m_lock); - if (m_raised) - { - // Cannot ask for a deferral after the event handler has returned. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - - m_completionsRequired++; - auto handler = ref new DeferralCompletedHandler(this, &OnboardingGetLastErrorRequestedEventArgs::Complete); - return ref new Deferral(handler); -} - -void OnboardingGetLastErrorRequestedEventArgs::InvokeAllFinished() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - m_raised = true; - invokeNeeded = (m_completionsRequired == 0); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingGetLastErrorRequestedEventArgs::Complete() -{ - bool invokeNeeded; - - // We need to hold a lock while modifying private state, but release it before invoking a completion handler. - { - std::lock_guard lockGuard(m_lock); - if (m_completionsRequired == 0) - { - // This should never happen since Complete() should only be called by Windows.Foundation.Deferral - // which will only invoke our completion handler once. - throw Exception::CreateException(E_ILLEGAL_METHOD_CALL); - } - m_completionsRequired--; - invokeNeeded = (m_raised && (m_completionsRequired == 0)); - } - - if (invokeNeeded) - { - InvokeCompleteHandler(); - } -} - -void OnboardingGetLastErrorRequestedEventArgs::InvokeCompleteHandler() -{ - if (m_result->Status == ER_NOT_IMPLEMENTED) - { - throw Exception::CreateException(E_NOTIMPL, "No handlers are registered for GetLastErrorRequested."); - } - else - { - m_tce.set(m_result); - } -} - -// Writable Properties -} } } diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.h deleted file mode 100644 index d09643578e..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.h +++ /dev/null @@ -1,333 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace org { namespace alljoyn { namespace Onboarding { - -// Methods -public ref class OnboardingConfigureWiFiCalledEventArgs sealed -{ -public: - OnboardingConfigureWiFiCalledEventArgs(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info, _In_ Platform::String^ interfaceMemberSSID, _In_ Platform::String^ interfaceMemberPassphrase, _In_ int16 interfaceMemberAuthType); - - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - } - - property OnboardingConfigureWiFiResult^ Result - { - OnboardingConfigureWiFiResult^ get() { return m_result; } - void set(_In_ OnboardingConfigureWiFiResult^ value) { m_result = value; } - } - - property Platform::String^ SSID - { - Platform::String^ get() { return m_interfaceMemberSSID; } - } - - property Platform::String^ Passphrase - { - Platform::String^ get() { return m_interfaceMemberPassphrase; } - } - - property int16 AuthType - { - int16 get() { return m_interfaceMemberAuthType; } - } - - Windows::Foundation::Deferral^ GetDeferral(); - - static Windows::Foundation::IAsyncOperation^ GetResultAsync(OnboardingConfigureWiFiCalledEventArgs^ args) - { - args->InvokeAllFinished(); - auto t = concurrency::create_task(args->m_tce); - return concurrency::create_async([t]() -> concurrency::task - { - return t; - }); - } - -private: - void Complete(); - void InvokeAllFinished(); - void InvokeCompleteHandler(); - - bool m_raised; - int m_completionsRequired; - concurrency::task_completion_event m_tce; - std::mutex m_lock; - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - OnboardingConfigureWiFiResult^ m_result; - Platform::String^ m_interfaceMemberSSID; - Platform::String^ m_interfaceMemberPassphrase; - int16 m_interfaceMemberAuthType; -}; - -public ref class OnboardingConnectCalledEventArgs sealed -{ -public: - OnboardingConnectCalledEventArgs(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - } - - property OnboardingConnectResult^ Result - { - OnboardingConnectResult^ get() { return m_result; } - void set(_In_ OnboardingConnectResult^ value) { m_result = value; } - } - - Windows::Foundation::Deferral^ GetDeferral(); - - static Windows::Foundation::IAsyncOperation^ GetResultAsync(OnboardingConnectCalledEventArgs^ args) - { - args->InvokeAllFinished(); - auto t = concurrency::create_task(args->m_tce); - return concurrency::create_async([t]() -> concurrency::task - { - return t; - }); - } - -private: - void Complete(); - void InvokeAllFinished(); - void InvokeCompleteHandler(); - - bool m_raised; - int m_completionsRequired; - concurrency::task_completion_event m_tce; - std::mutex m_lock; - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - OnboardingConnectResult^ m_result; -}; - -public ref class OnboardingOffboardCalledEventArgs sealed -{ -public: - OnboardingOffboardCalledEventArgs(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - } - - property OnboardingOffboardResult^ Result - { - OnboardingOffboardResult^ get() { return m_result; } - void set(_In_ OnboardingOffboardResult^ value) { m_result = value; } - } - - Windows::Foundation::Deferral^ GetDeferral(); - - static Windows::Foundation::IAsyncOperation^ GetResultAsync(OnboardingOffboardCalledEventArgs^ args) - { - args->InvokeAllFinished(); - auto t = concurrency::create_task(args->m_tce); - return concurrency::create_async([t]() -> concurrency::task - { - return t; - }); - } - -private: - void Complete(); - void InvokeAllFinished(); - void InvokeCompleteHandler(); - - bool m_raised; - int m_completionsRequired; - concurrency::task_completion_event m_tce; - std::mutex m_lock; - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - OnboardingOffboardResult^ m_result; -}; - -public ref class OnboardingGetScanInfoCalledEventArgs sealed -{ -public: - OnboardingGetScanInfoCalledEventArgs(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - } - - property OnboardingGetScanInfoResult^ Result - { - OnboardingGetScanInfoResult^ get() { return m_result; } - void set(_In_ OnboardingGetScanInfoResult^ value) { m_result = value; } - } - - Windows::Foundation::Deferral^ GetDeferral(); - - static Windows::Foundation::IAsyncOperation^ GetResultAsync(OnboardingGetScanInfoCalledEventArgs^ args) - { - args->InvokeAllFinished(); - auto t = concurrency::create_task(args->m_tce); - return concurrency::create_async([t]() -> concurrency::task - { - return t; - }); - } - -private: - void Complete(); - void InvokeAllFinished(); - void InvokeCompleteHandler(); - - bool m_raised; - int m_completionsRequired; - concurrency::task_completion_event m_tce; - std::mutex m_lock; - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - OnboardingGetScanInfoResult^ m_result; -}; - -// Readable Properties -public ref class OnboardingGetVersionRequestedEventArgs sealed -{ -public: - OnboardingGetVersionRequestedEventArgs(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - } - - property OnboardingGetVersionResult^ Result - { - OnboardingGetVersionResult^ get() { return m_result; } - void set(_In_ OnboardingGetVersionResult^ value) { m_result = value; } - } - - Windows::Foundation::Deferral^ GetDeferral(); - - static Windows::Foundation::IAsyncOperation^ GetResultAsync(OnboardingGetVersionRequestedEventArgs^ args) - { - args->InvokeAllFinished(); - auto t = concurrency::create_task(args->m_tce); - return concurrency::create_async([t]() -> concurrency::task - { - return t; - }); - } - -private: - void Complete(); - void InvokeAllFinished(); - void InvokeCompleteHandler(); - - bool m_raised; - int m_completionsRequired; - concurrency::task_completion_event m_tce; - std::mutex m_lock; - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - OnboardingGetVersionResult^ m_result; -}; - -public ref class OnboardingGetStateRequestedEventArgs sealed -{ -public: - OnboardingGetStateRequestedEventArgs(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - } - - property OnboardingGetStateResult^ Result - { - OnboardingGetStateResult^ get() { return m_result; } - void set(_In_ OnboardingGetStateResult^ value) { m_result = value; } - } - - Windows::Foundation::Deferral^ GetDeferral(); - - static Windows::Foundation::IAsyncOperation^ GetResultAsync(OnboardingGetStateRequestedEventArgs^ args) - { - args->InvokeAllFinished(); - auto t = concurrency::create_task(args->m_tce); - return concurrency::create_async([t]() -> concurrency::task - { - return t; - }); - } - -private: - void Complete(); - void InvokeAllFinished(); - void InvokeCompleteHandler(); - - bool m_raised; - int m_completionsRequired; - concurrency::task_completion_event m_tce; - std::mutex m_lock; - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - OnboardingGetStateResult^ m_result; -}; - -public ref class OnboardingGetLastErrorRequestedEventArgs sealed -{ -public: - OnboardingGetLastErrorRequestedEventArgs(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info); - - property Windows::Devices::AllJoyn::AllJoynMessageInfo^ MessageInfo - { - Windows::Devices::AllJoyn::AllJoynMessageInfo^ get() { return m_messageInfo; } - } - - property OnboardingGetLastErrorResult^ Result - { - OnboardingGetLastErrorResult^ get() { return m_result; } - void set(_In_ OnboardingGetLastErrorResult^ value) { m_result = value; } - } - - Windows::Foundation::Deferral^ GetDeferral(); - - static Windows::Foundation::IAsyncOperation^ GetResultAsync(OnboardingGetLastErrorRequestedEventArgs^ args) - { - args->InvokeAllFinished(); - auto t = concurrency::create_task(args->m_tce); - return concurrency::create_async([t]() -> concurrency::task - { - return t; - }); - } - -private: - void Complete(); - void InvokeAllFinished(); - void InvokeCompleteHandler(); - - bool m_raised; - int m_completionsRequired; - concurrency::task_completion_event m_tce; - std::mutex m_lock; - Windows::Devices::AllJoyn::AllJoynMessageInfo^ m_messageInfo; - OnboardingGetLastErrorResult^ m_result; -}; - -// Writable Properties -} } } diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp deleted file mode 100644 index 5baf4b55f6..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp +++ /dev/null @@ -1,66 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" - -using namespace Microsoft::WRL; -using namespace Platform; -using namespace Windows::Devices::AllJoyn; -using namespace Windows::Foundation; -using namespace org::alljoyn::Onboarding; - -void OnboardingSignals::Initialize(_In_ ISignalEmitter^ emitter) -{ - m_emitter = emitter; - alljoyn_busattachment nativeBusAttachment = AllJoynHelpers::GetInternalBusAttachment(m_emitter->BusObject->BusAttachment); - auto interfaceDefinition = alljoyn_busattachment_getinterface(nativeBusAttachment, "org.alljoyn.Onboarding"); - alljoyn_interfacedescription_getmember(interfaceDefinition, "ConnectionResult", &m_memberConnectionResult); -} - -void OnboardingSignals::ConnectionResult(_In_ Onboarding^ interfaceMemberArg) -{ - if (nullptr == AllJoynHelpers::GetInternalBusObject(m_emitter->BusObject)) - { - return; - } - - size_t argCount = 1; - alljoyn_msgarg arguments = alljoyn_msgarg_array_create(argCount); - (void)TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "(ns)", interfaceMemberArg); - - alljoyn_busobject_signal( - AllJoynHelpers::GetInternalBusObject(m_emitter->BusObject), - NULL, // Generated code only supports broadcast signals. - m_emitter->Session->Id, - m_memberConnectionResult, - arguments, - argCount, - 0, // A signal with a TTL of 0 will be sent to every member of the session, regardless of how long it takes to deliver the message - ALLJOYN_MESSAGE_FLAG_GLOBAL_BROADCAST, // Broadcast to everyone in the session. - NULL); // The generated code does not need the generated signal message - - alljoyn_msgarg_destroy(arguments); -} - -void OnboardingSignals::CallConnectionResultReceived(_In_ OnboardingSignals^ sender, _In_ OnboardingConnectionResultReceivedEventArgs^ args) -{ - ConnectionResultReceived(sender, args); -} - diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h deleted file mode 100644 index c6a6adb804..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h +++ /dev/null @@ -1,73 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace org { namespace alljoyn { namespace Onboarding { - -ref class OnboardingSignals; - -public interface class IOnboardingSignals -{ - event Windows::Foundation::TypedEventHandler^ ConnectionResultReceived; -}; - -public ref class OnboardingSignals sealed : [Windows::Foundation::Metadata::Default] IOnboardingSignals -{ -public: - // "This signal is emitted when the connection attempt against the personal AP is completed" - // Calling this method will send the ConnectionResult signal to every member of the session. - 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 - { - 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_ ISignalEmitter^ emitter); - void CallConnectionResultReceived(_In_ OnboardingSignals^ sender, _In_ OnboardingConnectionResultReceivedEventArgs^ args); - -private: - ISignalEmitter^ m_emitter; - - virtual event Windows::Foundation::EventHandler^ _ConnectionResultReceived; - - alljoyn_interfacedescription_member m_memberConnectionResult; -}; - -} } } diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingStructures.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingStructures.h deleted file mode 100644 index b094a61dc1..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingStructures.h +++ /dev/null @@ -1,279 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -namespace org { namespace alljoyn { namespace Onboarding { - -public ref class OnboardingScanListItem sealed -{ -public: - property Platform::String^ Value1 - { - Platform::String^ get() { return m_value1; } - void set(Platform::String^ value) { m_value1 = value; } - } - - property int16 Value2 - { - int16 get() { return m_value2; } - void set(int16 value) { m_value2 = value; } - } - -private: - Platform::String^ m_value1; - int16 m_value2; -}; - -public ref class Onboarding sealed -{ -public: - property int16 Value1 - { - int16 get() { return m_value1; } - void set(int16 value) { m_value1 = value; } - } - - property Platform::String^ Value2 - { - Platform::String^ get() { return m_value2; } - void set(Platform::String^ value) { m_value2 = value; } - } - -private: - int16 m_value1; - Platform::String^ m_value2; -}; - -public ref class OnboardingLastError sealed -{ -public: - property int16 Value1 - { - int16 get() { return m_value1; } - void set(int16 value) { m_value1 = value; } - } - - property Platform::String^ Value2 - { - Platform::String^ get() { return m_value2; } - void set(Platform::String^ value) { m_value2 = value; } - } - -private: - int16 m_value1; - Platform::String^ m_value2; -}; - -public ref class AllJoynMessageArgStructure sealed : Windows::Foundation::Collections::IVector -{ -public: - AllJoynMessageArgStructure() - { - m_vector = ref new Platform::Collections::Vector(); - } - - virtual Windows::Foundation::Collections::IIterator^ First() - { - return m_vector->First(); - } - - virtual Platform::Object^ GetAt(unsigned int index) - { - return m_vector->GetAt(index); - } - - virtual property unsigned int Size { - virtual unsigned int get() - { - return m_vector->Size; - } - } - - virtual bool IndexOf(Platform::Object^ value, unsigned int * index) - { - return m_vector->IndexOf(value, index); - } - - virtual unsigned int GetMany(unsigned int startIndex, Platform::WriteOnlyArray^ items) - { - return m_vector->GetMany(startIndex, items); - } - - virtual Windows::Foundation::Collections::IVectorView^ GetView() - { - return m_vector->GetView(); - } - - virtual void SetAt(unsigned int index, Platform::Object^ value) - { - return m_vector->SetAt(index, value); - } - - virtual void InsertAt(unsigned int index, Platform::Object^ value) - { - return m_vector->InsertAt(index, value); - } - - virtual void Append(Platform::Object^ value) - { - return m_vector->Append(value); - } - - virtual void RemoveAt(unsigned int index) - { - return m_vector->RemoveAt(index); - } - - virtual void RemoveAtEnd() - { - return m_vector->RemoveAtEnd(); - } - - virtual void Clear() - { - return m_vector->Clear(); - } - - virtual void ReplaceAll(const Platform::Array^ items) - { - return m_vector->ReplaceAll(items); - } - -private: - Platform::Collections::Vector^ m_vector; -}; -} } } - -partial ref class TypeConversionHelpers -{ -internal: - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ org::alljoyn::Onboarding::OnboardingScanListItem^* value) - { - UNREFERENCED_PARAMETER(signature); - - (*value) = ref new org::alljoyn::Onboarding::OnboardingScanListItem(); - - alljoyn_msgarg argument1; - alljoyn_msgarg argument2; - RETURN_IF_QSTATUS_ERROR(alljoyn_msgarg_get(argument, "(**)", &argument1, &argument2)); - - Platform::String^ value1; - RETURN_IF_QSTATUS_ERROR(GetAllJoynMessageArg(argument1, "s", &value1)); - (*value)->Value1 = value1; - int16 value2; - RETURN_IF_QSTATUS_ERROR(GetAllJoynMessageArg(argument2, "n", &value2)); - (*value)->Value2 = value2; - - return ER_OK; - } - - static _Check_return_ int32 SetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _In_ org::alljoyn::Onboarding::OnboardingScanListItem^ value) - { - UNREFERENCED_PARAMETER(signature); - - auto argument1 = alljoyn_msgarg_create(); - RETURN_IF_QSTATUS_ERROR(SetAllJoynMessageArg(argument1, "s", value->Value1)); - auto argument2 = alljoyn_msgarg_create(); - RETURN_IF_QSTATUS_ERROR(SetAllJoynMessageArg(argument2, "n", value->Value2)); - - RETURN_IF_QSTATUS_ERROR(alljoyn_msgarg_set(argument, "(**)", argument1, argument2)); - alljoyn_msgarg_stabilize(argument); - alljoyn_msgarg_destroy(argument1); - alljoyn_msgarg_destroy(argument2); - - return ER_OK; - } - - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ org::alljoyn::Onboarding::Onboarding^* value) - { - UNREFERENCED_PARAMETER(signature); - - (*value) = ref new org::alljoyn::Onboarding::Onboarding(); - - alljoyn_msgarg argument1; - alljoyn_msgarg argument2; - RETURN_IF_QSTATUS_ERROR(alljoyn_msgarg_get(argument, "(**)", &argument1, &argument2)); - - int16 value1; - RETURN_IF_QSTATUS_ERROR(GetAllJoynMessageArg(argument1, "n", &value1)); - (*value)->Value1 = value1; - Platform::String^ value2; - RETURN_IF_QSTATUS_ERROR(GetAllJoynMessageArg(argument2, "s", &value2)); - (*value)->Value2 = value2; - - return ER_OK; - } - - static _Check_return_ int32 SetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _In_ org::alljoyn::Onboarding::Onboarding^ value) - { - UNREFERENCED_PARAMETER(signature); - - auto argument1 = alljoyn_msgarg_create(); - RETURN_IF_QSTATUS_ERROR(SetAllJoynMessageArg(argument1, "n", value->Value1)); - auto argument2 = alljoyn_msgarg_create(); - RETURN_IF_QSTATUS_ERROR(SetAllJoynMessageArg(argument2, "s", value->Value2)); - - RETURN_IF_QSTATUS_ERROR(alljoyn_msgarg_set(argument, "(**)", argument1, argument2)); - alljoyn_msgarg_stabilize(argument); - alljoyn_msgarg_destroy(argument1); - alljoyn_msgarg_destroy(argument2); - - return ER_OK; - } - - static _Check_return_ int32 GetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _Out_ org::alljoyn::Onboarding::OnboardingLastError^* value) - { - UNREFERENCED_PARAMETER(signature); - - (*value) = ref new org::alljoyn::Onboarding::OnboardingLastError(); - - alljoyn_msgarg argument1; - alljoyn_msgarg argument2; - RETURN_IF_QSTATUS_ERROR(alljoyn_msgarg_get(argument, "(**)", &argument1, &argument2)); - - int16 value1; - RETURN_IF_QSTATUS_ERROR(GetAllJoynMessageArg(argument1, "n", &value1)); - (*value)->Value1 = value1; - Platform::String^ value2; - RETURN_IF_QSTATUS_ERROR(GetAllJoynMessageArg(argument2, "s", &value2)); - (*value)->Value2 = value2; - - return ER_OK; - } - - static _Check_return_ int32 SetAllJoynMessageArg(_In_ alljoyn_msgarg argument, _In_ PCSTR signature, _In_ org::alljoyn::Onboarding::OnboardingLastError^ value) - { - UNREFERENCED_PARAMETER(signature); - - auto argument1 = alljoyn_msgarg_create(); - RETURN_IF_QSTATUS_ERROR(SetAllJoynMessageArg(argument1, "n", value->Value1)); - auto argument2 = alljoyn_msgarg_create(); - RETURN_IF_QSTATUS_ERROR(SetAllJoynMessageArg(argument2, "s", value->Value2)); - - RETURN_IF_QSTATUS_ERROR(alljoyn_msgarg_set(argument, "(**)", argument1, argument2)); - alljoyn_msgarg_stabilize(argument); - alljoyn_msgarg_destroy(argument1); - alljoyn_msgarg_destroy(argument2); - - return ER_OK; - } - -}; diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2IntrospectionXml.xml b/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2IntrospectionXml.xml deleted file mode 100644 index 71c3a1dbd3..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2IntrospectionXml.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - A secure onboarding interface - - - Interface version number - - - - The configuration state - - - - The last error code and error message - - - - Sends the personal AP information to the onboardee - - - - - - - Tells the onboardee to connect to the personal AP - - - - Tells the onboardee to disconnect from the personal AP - - - - Scans all the Wi-Fi access points in the onboardee's proximity - - - - - This signal is emitted when the connection attempt against the personal AP is completed - - - - \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj b/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj deleted file mode 100644 index a1b9499091..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj +++ /dev/null @@ -1,262 +0,0 @@ - - - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - Win32 - - - Release - x64 - - - - $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), LICENSE))\SharedContent - - - {2f094e07-9106-553d-a1c2-89c64d3697ca} - WindowsRuntimeComponent - Scenario2WinRTComponent - org.alljoyn.Onboarding - en-US - 14.0 - true - Windows Store - 10.0.22621.0 - 10.0.22621.0 - 10.0 - true - - - - DynamicLibrary - true - - - DynamicLibrary - true - - - DynamicLibrary - true - - - DynamicLibrary - false - true - true - - - DynamicLibrary - false - true - true - - - DynamicLibrary - false - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - $(VC_IncludePath);$(UniversalCRT_IncludePath);$(WindowsSDK_IncludePath);..\..\shared - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - Use - _WINRT_DLL;QCC_OS_GROUP_WINDOWS;%(PreprocessorDefinitions) - pch.h - $(IntDir)pch.pch - $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) - /bigobj /Zm250 - 28204 - - - Console - false - WindowsApp.lib;msajapi.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj.filters b/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj.filters deleted file mode 100644 index bc561c71cb..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj.filters +++ /dev/null @@ -1,37 +0,0 @@ - - - - - b4947898-b9a0-45e2-804b-eda2a7e89237 - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/pch.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/pch.cpp deleted file mode 100644 index 4c5275e663..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/pch.cpp +++ /dev/null @@ -1,21 +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. -// -//********************************************************* -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#include "pch.h" diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/pch.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/pch.h deleted file mode 100644 index 754d9b45ce..0000000000 --- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/pch.h +++ /dev/null @@ -1,52 +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. -// -//********************************************************* - -//----------------------------------------------------------------------------- -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246 -// -//----------------------------------------------------------------------------- -#pragma once - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "AllJoynHelpers.h" -#include "AllJoynBusObjectManager.h" - -#define PROJECT_NAMESPACE org::alljoyn::Onboarding - -#include "OnboardingStructures.h" -#include "TypeConversionHelpers.h" -#include "OnboardingMethodResults.h" -#include "OnboardingEventArgs.h" -#include "IOnboardingService.h" -#include "OnboardingSignals.h" -#include "OnboardingLegacySignals.h" -#include "OnboardingProducer.h" -#include "OnboardingConsumer.h" -#include "OnboardingServiceEventArgs.h" -#include "OnboardingServiceEventAdapter.h" \ No newline at end of file diff --git a/Samples/AllJoyn/ConsumerExperiences/README.md b/Samples/AllJoyn/ConsumerExperiences/README.md deleted file mode 100644 index c3f7e5c538..0000000000 --- a/Samples/AllJoyn/ConsumerExperiences/README.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -page_type: sample -languages: -- csharp -products: -- windows -- windows-uwp -urlFragment: AllJoynConsumerExperiences -extendedZipContent: -- path: SharedContent - target: SharedContent -- path: LICENSE - target: LICENSE -- path: Samples/AllJoyn/Common - target: Common -- path: Samples/AllJoyn/shared - target: shared -description: "Creates an AllJoyn Windows Universal app using Code Generation with Introspection XML and Windows.Devices.AllJoyn." ---- - - - -# AllJoyn consumer experiences sample - -Shows how to create an AllJoyn Windows Universal app using Code Generation with Introspection XML and Windows.Devices.AllJoyn. - -> **Note:** This sample is part of a large collection of UWP feature samples. -> You can download this sample as a standalone ZIP file -> [from docs.microsoft.com](https://docs.microsoft.com/samples/microsoft/windows-universal-samples/alljoynconsumerexperiences/), -> or you can download the entire collection as a single -> [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/master.zip), but be -> sure to unzip everything to access shared dependencies. For more info on working with the ZIP file, -> the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq). -> For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center. - -Specifically, this sample covers: - -**Scenario 1** -- Creating and launching a Secure AllJoyn Consumer. -- Implementing method call, property and signal from generated code. - -**Scenario 2** -- Discovering and connecting to an Onboardee's SoftAP. -- Implementing method calls to get an Onboardee's network scan, configuring an Onboardee with WiFi credentials etc. - -**Note** The Universal Windows samples require Visual Studio to build and Windows 10 to execute. - -To obtain information about Windows 10 development, go to the [Windows Dev Center](http://go.microsoft.com/fwlink/?LinkID=532421) - -To obtain information about Microsoft Visual Studio and the tools for developing Windows apps, go to [Visual Studio](http://go.microsoft.com/fwlink/?LinkID=532422) - -## Related topics - -### Samples - -* [AllJoyn Producer Experiences](http://go.microsoft.com/fwlink/p/?LinkId=534025) -* [AllJoyn Consumer Experiences](http://go.microsoft.com/fwlink/p/?LinkID=534021) -* [AllJoyn Consumer Experiences](/archived/AllJoyn/ConsumerExperiences/) for JavaScript (archived) - -The AllSeen Alliance has samples in [Windows SDK](https://allseenalliance.org/developers/download) - -### Reference - -[MSDN Reference](https://msdn.microsoft.com/library/windows/apps/windows.devices.alljoyn.aspx) -[AllJoyn Reference](https://allseenalliance.org/developers/develop/api-reference) -[Troubleshooting AllJoyn blog](http://channel9.msdn.com/Blogs/Internet-of-Things-Blog/Troubleshooting-AllJoyn-with-Windows-10-Insider-Preview-Builds) - -## System requirements - -* Windows 10 - -## Build the sample - -1. Start Microsoft Visual Studio and select **File** \> **Open** \> **Project/Solution**. -2. Go to the directory to which you unzipped the sample. Then go to the subdirectory containing the sample in the C# language. Double-click the Visual Studio Solution (.sln) file. -3. Set the active solution configuration and platform to the desired values under **Build** \> **Configuration Manager**. -4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**. - -## Run the sample - -The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it. - -### Deploying the sample - -- Select Build > Deploy Solution. - -### Deploying and running the sample - -- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging. \ No newline at end of file diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/AllJoynConsumerExperiences.sln b/Samples/AllJoyn/ConsumerExperiences/cs/AllJoynConsumerExperiences.sln deleted file mode 100644 index 7e96ef4d7f..0000000000 --- a/Samples/AllJoyn/ConsumerExperiences/cs/AllJoynConsumerExperiences.sln +++ /dev/null @@ -1,68 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AllJoynConsumerExperiences", "AllJoynConsumerExperiences.csproj", "{B90C803E-A5CA-58AF-B6B0-4897295C9131}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scenario1WinRTComponent", "..\..\Common\Scenario1WinRTComponent\Scenario1WinRTComponent.vcxproj", "{4CABAFE4-BA62-587C-87FC-595DA36017C9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scenario2WinRTComponent", "..\..\Common\Scenario2WinRTComponent\Scenario2WinRTComponent.vcxproj", "{07A51DCA-D988-59D5-AAD5-46CF209F1368}" -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 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Debug|ARM.ActiveCfg = Debug|ARM - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Debug|ARM.Build.0 = Debug|ARM - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Debug|ARM.Deploy.0 = Debug|ARM - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Debug|x64.ActiveCfg = Debug|x64 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Debug|x64.Build.0 = Debug|x64 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Debug|x64.Deploy.0 = Debug|x64 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Debug|x86.ActiveCfg = Debug|x86 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Debug|x86.Build.0 = Debug|x86 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Debug|x86.Deploy.0 = Debug|x86 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Release|ARM.ActiveCfg = Release|ARM - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Release|ARM.Build.0 = Release|ARM - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Release|ARM.Deploy.0 = Release|ARM - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Release|x64.ActiveCfg = Release|x64 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Release|x64.Build.0 = Release|x64 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Release|x64.Deploy.0 = Release|x64 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Release|x86.ActiveCfg = Release|x86 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Release|x86.Build.0 = Release|x86 - {B90C803E-A5CA-58AF-B6B0-4897295C9131}.Release|x86.Deploy.0 = Release|x86 - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Debug|ARM.ActiveCfg = Debug|ARM - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Debug|ARM.Build.0 = Debug|ARM - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Debug|x64.ActiveCfg = Debug|x64 - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Debug|x64.Build.0 = Debug|x64 - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Debug|x86.ActiveCfg = Debug|Win32 - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Debug|x86.Build.0 = Debug|Win32 - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Release|ARM.ActiveCfg = Release|ARM - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Release|ARM.Build.0 = Release|ARM - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Release|x64.ActiveCfg = Release|x64 - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Release|x64.Build.0 = Release|x64 - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Release|x86.ActiveCfg = Release|Win32 - {4CABAFE4-BA62-587C-87FC-595DA36017C9}.Release|x86.Build.0 = Release|Win32 - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Debug|ARM.ActiveCfg = Debug|ARM - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Debug|ARM.Build.0 = Debug|ARM - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Debug|x64.ActiveCfg = Debug|x64 - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Debug|x64.Build.0 = Debug|x64 - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Debug|x86.ActiveCfg = Debug|Win32 - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Debug|x86.Build.0 = Debug|Win32 - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Release|ARM.ActiveCfg = Release|ARM - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Release|ARM.Build.0 = Release|ARM - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Release|x64.ActiveCfg = Release|x64 - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Release|x64.Build.0 = Release|x64 - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Release|x86.ActiveCfg = Release|Win32 - {07A51DCA-D988-59D5-AAD5-46CF209F1368}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/OnboardingEnumTypes.cs b/Samples/AllJoyn/ConsumerExperiences/cs/OnboardingEnumTypes.cs deleted file mode 100644 index 364af134c7..0000000000 --- a/Samples/AllJoyn/ConsumerExperiences/cs/OnboardingEnumTypes.cs +++ /dev/null @@ -1,70 +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. -// -//********************************************************* - -using System; -using Windows.UI.Xaml.Data; - -namespace AllJoynConsumerExperiences -{ - // All the Enums below as per the Onboarding interface spec - // For more info: https://allseenalliance.org/developers/learn/base-services/onboarding/interface - - enum OnboardingAuthenticationType - { - Wpa2Auto = -3, - WpaAuto = -2, - Any = -1, - Open = 0, - Wep = 1, - WpaTkip = 2, - WpaCcmp = 3, - Wpa2Tkip = 4, - Wpa2Ccmp = 5, - Wps = 6, - } - - enum ConfigureWiFiResultStatus - { - NotConcurrent = 1, - Concurrent = 2, - } - - enum ConnectionResultCode - { - Validated = 0, - Unreachable, - UnsupportedProtocol, - Unauthorized, - ErrorMessage, - } - - public class AuthTypeToStringConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - return value.ToString(); - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - OnboardingAuthenticationType returnValue; - - if (Enum.TryParse(value.ToString(), true, out returnValue)) - { - return returnValue; - } - else - { - return OnboardingAuthenticationType.Any; - } - } - } -} diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/Package.appxmanifest b/Samples/AllJoyn/ConsumerExperiences/cs/Package.appxmanifest deleted file mode 100644 index c3fc45e648..0000000000 --- a/Samples/AllJoyn/ConsumerExperiences/cs/Package.appxmanifest +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - AllJoyn Consumer Experiences C# Sample - Microsoft Corporation - Assets\StoreLogo-sdk.png - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/RelayCommand.cs b/Samples/AllJoyn/ConsumerExperiences/cs/RelayCommand.cs deleted file mode 100644 index 5301fd7e49..0000000000 --- a/Samples/AllJoyn/ConsumerExperiences/cs/RelayCommand.cs +++ /dev/null @@ -1,56 +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. -// -//********************************************************* - -using System; -using System.Windows.Input; - -namespace AllJoynConsumerExperiences -{ - /// - /// Helpful class to execute the command logic (as defined by ViewModel's exposed ICommand properties) via delegates. - /// - public class RelayCommand : ICommand - { - readonly Action execute; - readonly Predicate canExecute; - - public RelayCommand(Action execute) - : this(execute, null) - { - } - - public event EventHandler CanExecuteChanged - { - add { } - remove { } - } - - public RelayCommand(Action execute, Predicate canExecute) - { - if (execute == null) - { - throw new ArgumentNullException("execute"); - } - this.execute = execute; - this.canExecute = canExecute; - } - - public bool CanExecute(object parameter) - { - return canExecute == null ? true : canExecute(parameter); - } - - public void Execute(object parameter) - { - execute(parameter); - } - } -} diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1.xaml b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1.xaml deleted file mode 100644 index c3cdb2ed74..0000000000 --- a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1.xaml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The SecureInterface consumer will use About to find a SecureInterface producer and then make a call to the "Concatenate" method. - - - - - -