Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
updates auth flows for rhino plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
didimitrie committed Aug 13, 2019
1 parent d928878 commit 1751283
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
10 changes: 6 additions & 4 deletions SpeckleRhinoPlugin/SpeckleWinR6/SpeckleWinR6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,16 @@
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="SpeckleNewtonsoft">
<HintPath>..\..\SpeckleCore\SpeckleNewtonsoft.dll</HintPath>
<Aliases>SpeckleNewtonsoft</Aliases>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\src\Interop.cs">
Expand Down Expand Up @@ -130,6 +129,9 @@
<PackageReference Include="SpeckleCore">
<Version>1.5.2.343</Version>
</PackageReference>
<PackageReference Include="SpecklePopup">
<Version>1.6.8</Version>
</PackageReference>
<PackageReference Include="sqlite-net-pcl">
<Version>1.5.231</Version>
</PackageReference>
Expand Down
33 changes: 25 additions & 8 deletions SpeckleRhinoPlugin/src/Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
using Rhino;
using System.Dynamic;
using Rhino.DocObjects;
using System.Windows;
using System.Windows.Forms;
using Newtonsoft.Json;
using SpecklePopup;

namespace SpeckleRhino
{
Expand Down Expand Up @@ -253,10 +255,25 @@ public void InstantiateFileClients( )

#region Account Management

public void ShowAccountPopup( )
{
RhinoApp.InvokeOnUiThread( new Action( ( ) =>
//Window.Dispatcher.Invoke( ( ) =>
{
var signInWindow = new SpecklePopup.SignInWindow( true );

var helper = new System.Windows.Interop.WindowInteropHelper( signInWindow );
helper.Owner = RhinoApp.MainWindowHandle();

signInWindow.ShowDialog();
NotifySpeckleFrame( "refresh-accounts", "", "" );
} ) );
}

// called by the web ui
public string GetUserAccounts( )
{
return JsonConvert.SerializeObject( UserAccounts, Interop.camelCaseSettings );
return JsonConvert.SerializeObject( SpeckleCore.LocalContext.GetAllAccounts(), Interop.camelCaseSettings );
}

private void ReadUserAccounts( )
Expand Down Expand Up @@ -324,15 +341,15 @@ public string GetAllClients( )
if ( client is RhinoSender )
{
var rhSender = client as RhinoSender;
NotifySpeckleFrame( "client-add", rhSender.StreamId, JsonConvert.SerializeObject( new { stream = rhSender.Client.Stream, client = rhSender.Client }, camelCaseSettings ) );
NotifySpeckleFrame( "client-add", rhSender.StreamId, JsonConvert.SerializeObject( new { stream = rhSender.Client.Stream, client = rhSender.Client }, camelCaseSettings ) );
continue;
}

var rhReceiver = client as RhinoReceiver;
NotifySpeckleFrame( "client-add", rhReceiver.StreamId, JsonConvert.SerializeObject( new { stream = rhReceiver.Client.Stream, client = rhReceiver.Client }, camelCaseSettings ) );
NotifySpeckleFrame( "client-add", rhReceiver.StreamId, JsonConvert.SerializeObject( new { stream = rhReceiver.Client.Stream, client = rhReceiver.Client }, camelCaseSettings ) );
}

return JsonConvert.SerializeObject( UserClients, camelCaseSettings );
return JsonConvert.SerializeObject( UserClients, camelCaseSettings );
}

#endregion
Expand Down Expand Up @@ -418,7 +435,7 @@ public void setObjectHover( string clientId, string layerId, bool status )

public void AddRemoveObjects( string clientId, string _guids, bool remove )
{
string[ ] guids = JsonConvert.DeserializeObject<string[ ]>( _guids );
string[ ] guids = JsonConvert.DeserializeObject<string[ ]>( _guids );

var myClient = UserClients.FirstOrDefault( c => c.GetClientId() == clientId );
if ( myClient != null )
Expand Down Expand Up @@ -482,13 +499,13 @@ public string getLayersAndObjectsInfo( bool ignoreSelection = false )
{
SelectedObjects = RhinoDoc.ActiveDoc.Objects.GetSelectedObjects( false, false ).ToList();
if ( SelectedObjects.Count == 0 || SelectedObjects[ 0 ] == null )
return JsonConvert.SerializeObject( layerInfoList, camelCaseSettings );
return JsonConvert.SerializeObject( layerInfoList, camelCaseSettings );
}
else
{
SelectedObjects = RhinoDoc.ActiveDoc.Objects.ToList();
if ( SelectedObjects.Count == 0 || SelectedObjects[ 0 ] == null )
return JsonConvert.SerializeObject( layerInfoList, camelCaseSettings );
return JsonConvert.SerializeObject( layerInfoList, camelCaseSettings );

foreach ( Rhino.DocObjects.Layer ll in RhinoDoc.ActiveDoc.Layers )
{
Expand Down Expand Up @@ -530,7 +547,7 @@ public string getLayersAndObjectsInfo( bool ignoreSelection = false )
}
}

return Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes( JsonConvert.SerializeObject( layerInfoList, camelCaseSettings ) ) );
return Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes( JsonConvert.SerializeObject( layerInfoList, camelCaseSettings ) ) );
}
#endregion
}
Expand Down

0 comments on commit 1751283

Please sign in to comment.