Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLIBZ-2618: SQLite PCL replace #166

Merged
merged 3 commits into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "sqlite-net"]
path = sqlite-net
url = https://github.com/heyzooi/sqlite-net.git
vinaygahlawat marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 0 additions & 2 deletions Kinvey-Xamarin-Android/Client/AndroidClientBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using SQLite.Net.Platform.XamarinAndroid;

namespace Kinvey
{
Expand All @@ -9,7 +8,6 @@ public AndroidClientBuilder(string appKey, string appSecret) :
base(appKey, appSecret, Constants.DevicePlatform.Android)
{
this.setFilePath(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal));
this.setOfflinePlatform(new SQLitePlatformAndroid());
vinaygahlawat marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
31 changes: 13 additions & 18 deletions Kinvey-Xamarin-Android/Kinvey-Xamarin-Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<AssemblyName>Kinvey-Xamarin-Android</AssemblyName>
<TargetFrameworkVersion>v7.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v5.1</TargetFrameworkVersion>
<AndroidTlsProvider></AndroidTlsProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down Expand Up @@ -42,28 +42,19 @@
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
<Reference Include="Xamarin.GooglePlayServices.Basement">
<HintPath>..\packages\Xamarin.GooglePlayServices.Basement.27.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Basement.dll</HintPath>
</Reference>
<Reference Include="Xamarin.GooglePlayServices.Base">
<HintPath>..\packages\Xamarin.GooglePlayServices.Base.27.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Base.dll</HintPath>
</Reference>
<Reference Include="Xamarin.GooglePlayServices.Gcm">
<HintPath>..\packages\Xamarin.GooglePlayServices.Gcm.27.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Gcm.dll</HintPath>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http" />
<Reference Include="Xamarin.Android.Support.v4">
<HintPath>..\packages\Xamarin.Android.Support.v4.23.1.1.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll</HintPath>
<HintPath>..\packages\Xamarin.Android.Support.v4.22.2.0.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net">
<HintPath>..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net.Platform.XamarinAndroid">
<HintPath>..\packages\SQLite.Net-PCL.3.1.1\lib\MonoAndroid\SQLite.Net.Platform.XamarinAndroid.dll</HintPath>
<Reference Include="Xamarin.GooglePlayServices.Base">
<HintPath>..\packages\Xamarin.GooglePlayServices.Base.25.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Base.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll</HintPath>
<Reference Include="Xamarin.GooglePlayServices.Gcm">
<HintPath>..\packages\Xamarin.GooglePlayServices.Gcm.25.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Gcm.dll</HintPath>
vinaygahlawat marked this conversation as resolved.
Show resolved Hide resolved
</Reference>
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<Compile Include="Push\KinveyGCMService.cs" />
Expand Down Expand Up @@ -93,5 +84,9 @@
<Project>{6644D98D-026B-48E9-95A3-61C4D98D82E7}</Project>
<Name>Kinvey.Core</Name>
</ProjectReference>
<ProjectReference Include="..\sqlite-net\nuget\SQLite-net-std\SQLite-net-std.csproj">
<Project>{32711A14-971C-4A96-90B3-00A2D1E28E0D}</Project>
<Name>SQLite-net-std</Name>
</ProjectReference>
</ItemGroup>
</Project>
9 changes: 3 additions & 6 deletions Kinvey-Xamarin-Android/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
<packages>
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="MonoAndroid50" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="monoandroid70" />
<package id="SQLite.Net.Core-PCL" version="3.1.1" targetFramework="monoandroid70" />
<package id="SQLite.Net-PCL" version="3.1.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v4" version="23.1.1.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Base" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Basement" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Gcm" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v4" version="22.2.0.0" targetFramework="monoandroid51" />
<package id="Xamarin.GooglePlayServices.Base" version="25.0.0.0" targetFramework="monoandroid51" />
<package id="Xamarin.GooglePlayServices.Gcm" version="25.0.0.0" targetFramework="monoandroid51" />
vinaygahlawat marked this conversation as resolved.
Show resolved Hide resolved
</packages>
2 changes: 0 additions & 2 deletions Kinvey-Xamarin-iOS/Client/IOSClientBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Foundation;
using SQLite.Net.Platform.XamarinIOS;

namespace Kinvey
{
Expand All @@ -9,7 +8,6 @@ public IOSClientBuilder(string appKey, string appSecret) :
base(appKey, appSecret, Constants.DevicePlatform.iOS)
{
this.setFilePath(NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0].ToString());
this.setOfflinePlatform(new SQLitePlatformIOS());
vinaygahlawat marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
6 changes: 0 additions & 6 deletions Kinvey-Xamarin-iOS/Kinvey-Xamarin-iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
<Reference Include="SQLite.Net">
<HintPath>..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net.Platform.XamarinIOS.Unified">
<HintPath>..\packages\SQLite.Net-PCL.3.1.1\lib\Xamarin.iOS10\SQLite.Net.Platform.XamarinIOS.Unified.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll</HintPath>
</Reference>
Expand Down
2 changes: 0 additions & 2 deletions Kinvey-Xamarin-iOS/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="xamarinios10" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="xamarinios10" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="xamarinios10" />
<package id="SQLite.Net.Core-PCL" version="3.1.1" targetFramework="xamarinios10" />
<package id="SQLite.Net-PCL" version="3.1.1" targetFramework="xamarinios10" />
<package id="System.AppContext" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Collections" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="xamarinios10" />
Expand Down
2 changes: 1 addition & 1 deletion Kinvey.Core/Auth/SQLCredential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Unauthorized reproduction, transmission or distribution of this file and its
// contents is a violation of applicable laws.

using SQLite.Net.Attributes;
using SQLite;

/// <summary>
/// SQL credential.
Expand Down
7 changes: 3 additions & 4 deletions Kinvey.Core/Auth/SQLiteCredentialStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
// contents is a violation of applicable laws.

using System.IO;
using SQLite.Net.Interop;
using SQLite.Net;
using SQLite;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
Expand All @@ -35,12 +34,12 @@ public class SQLiteCredentialStore : ICredentialStore
/// </summary>
/// <param name="platform">Platform.</param>
/// <param name="filepath">Filepath.</param>
public SQLiteCredentialStore (ISQLitePlatform platform, string filepath)
public SQLiteCredentialStore (string filepath)
{
string dbPath = Path.Combine (filepath, "kinvey_tokens.sqlite");
if (_dbConnection == null)
{
_dbConnection = new SQLiteConnection (platform, dbPath);
_dbConnection = new SQLiteConnection (dbPath);
_dbConnection.CreateTable<SQLCredential>();
}
}
Expand Down
24 changes: 4 additions & 20 deletions Kinvey.Core/Client/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

using System;
using System.Collections.Generic;
using SQLite.Net.Interop;
using SQLite;
using System.Threading.Tasks;
using KinveyUtils;
using Newtonsoft.Json;
Expand Down Expand Up @@ -133,12 +133,6 @@ internal PingRequest(AbstractClient client, Dictionary<string, string> urlProper
/// <value>The file path.</value>
private string filePath {get; set;}

/// <summary>
///a reference to the sqlite implementation -- going to be platform dependent
/// </summary>
/// <value>The offline platform.</value>
private ISQLitePlatform offlinePlatform {get; set;}

private ICacheManager CacheManager {get; set; }

/// <summary>
Expand Down Expand Up @@ -173,16 +167,16 @@ public Builder(string appKey, string appSecret, Constants.DevicePlatform deviceP
/// </summary>
public virtual Client Build()
{
if (this.filePath != null && offlinePlatform != null)
if (this.filePath != null)
{
if (this.Store == null)
{
this.Store = new SQLiteCredentialStore (offlinePlatform, filePath);
this.Store = new SQLiteCredentialStore (filePath);
}

if (this.CacheManager == null)
{
this.CacheManager = new SQLiteCacheManager (offlinePlatform, filePath);
this.CacheManager = new SQLiteCacheManager (filePath);
}
}

Expand Down Expand Up @@ -265,16 +259,6 @@ public Builder setFilePath(string path){
this.filePath = path;
return this;
}

/// <summary>
/// Set the sqlite implementation to use for offline.
/// </summary>
/// <returns>The offline platform.</returns>
/// <param name="platform">Platform.</param>
public Builder setOfflinePlatform(ISQLitePlatform platform){
this.offlinePlatform = platform;
return this;
}

/// <summary>
/// Sets the logger action -- the ClientLogger class uses this to write to logs.
Expand Down
10 changes: 4 additions & 6 deletions Kinvey.Core/Kinvey.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@
<Reference Include="Remotion.Linq">
<HintPath>..\packages\Remotion.Linq.2.0.1\lib\portable-net45+win+wpa81+wp80\Remotion.Linq.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net.Async">
<HintPath>..\packages\SQLite.Net.Async-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.Async.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net">
<HintPath>..\packages\SQLite.Net-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
</Reference>
Expand All @@ -191,5 +185,9 @@
<Project>{444456B1-5B55-48D6-9637-00ADCA92B7C9}</Project>
<Name>Kinvey-Utils</Name>
</ProjectReference>
<ProjectReference Include="..\sqlite-net\nuget\SQLite-net\SQLite-net.csproj">
<Project>{7F946494-8EE0-432B-8A87-98961143D5C1}</Project>
<Name>SQLite-net</Name>
</ProjectReference>
</ItemGroup>
</Project>
36 changes: 19 additions & 17 deletions Kinvey.Core/Model/AccessControlList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// contents is a violation of applicable laws.

using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using SQLite.Net;

namespace Kinvey
{
Expand All @@ -24,7 +24,8 @@ namespace Kinvey
/// the collection level.
/// </summary>
[JsonObject]
public class AccessControlList : ISerializable<string>
[DataContract]
public class AccessControlList
{
/// <summary>
/// the field name within every JSON object.
Expand All @@ -36,35 +37,40 @@ public class AccessControlList : ISerializable<string>
/// </summary>
/// <value>The creator</value>
[JsonProperty("creator")]
[DataMember(Name = "creator")]
public string Creator { get; set; }

/// <summary>
/// Gets or sets whether this entity is globally readable.
/// </summary>
/// <value><c>true</c> if globally readable; otherwise, <c>false</c>.</value>
[JsonProperty("gr")]
public bool GloballyReadable { get; set; }
[DataMember(Name = "gr")]
public bool GloballyReadable { get; set; }

/// <summary>
/// Gets or sets whether this entity is globally writeable.
/// </summary>
/// <value><c>true</c> if globally writeable; otherwise, <c>false</c>.</value>
[JsonProperty("gw")]
public bool GloballyWriteable { get; set; }
[DataMember(Name = "gw")]
public bool GloballyWriteable { get; set; }

/// <summary>
/// Gets or sets a list of user IDs that are specifically allowed to read this entity.
/// </summary>
/// <value>The list of user IDs allowed to read this entity.</value>
[JsonProperty("r")]
public List<string> Readers { get; set; }
[DataMember(Name = "r")]
public List<string> Readers { get; set; }

/// <summary>
/// Gets or sets a list of user IDs that are specifically allowed to modify this entity.
/// </summary>
/// <value>The list of user IDs allowed to modify this entity.</value>
[JsonProperty("w")]
public List<string> Writers { get; set; }
[DataMember(Name = "w")]
public List<string> Writers { get; set; }

/// <summary>
/// Gets or sets the ACL group that contains lists of user groups which are authorized on the
Expand All @@ -74,28 +80,32 @@ public class AccessControlList : ISerializable<string>
/// </summary>
/// <value>The group object which contains the list of user groups allowed to read and/or modify the entity.</value>
[JsonProperty("groups")]
public ACLGroups Groups { get; set; }
[DataMember(Name = "groups")]
public ACLGroups Groups { get; set; }

/// <summary>
/// Class that holds the list of user groups that can read the entity and the list of user groups
/// that can modify the entity.
/// </summary>
[JsonObject]
[DataContract]
public class ACLGroups
{
/// <summary>
/// Gets or sets the list of user groups that can read the entity.
/// </summary>
/// <value>The list of user groups with read access to the entity.</value>
[JsonProperty("r")]
public List<string> Readers { get; set; }
[DataMember(Name = "r")]
public List<string> Readers { get; set; }

/// <summary>
/// Gets or sets the list of user groups that can modify the entity.
/// </summary>
/// <value>The list of user groups with write access to the entity.</value>
[JsonProperty("w")]
public List<string> Writers { get; set; }
[DataMember(Name = "w")]
public List<string> Writers { get; set; }

public ACLGroups()
{
Expand All @@ -113,13 +123,5 @@ public AccessControlList()

Groups = new ACLGroups();
}

/// <summary>
/// Implementation of ISerializeable interface, used to serialize this <see cref="AccessControlList"/> instance.
/// </summary>
public string Serialize()
{
return JsonConvert.SerializeObject(this);
}
}
}
Loading