Skip to content
This repository has been archived by the owner on May 20, 2022. It is now read-only.

Commit

Permalink
* Updated to new Newtonsoft JSON (5.0.2 -> 5.0.5)
Browse files Browse the repository at this point in the history
* It is now possible to supply a "setup.json" file to provide default settings during setup
* Updated version to 0.4.0
  • Loading branch information
RobThree committed May 10, 2013
1 parent 58baf12 commit fea1548
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 15 deletions.
5 changes: 1 addition & 4 deletions Fop2ClientLib/Fop2ClientLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.5.0.2\lib\net35\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.5.0.5\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -64,9 +64,6 @@
<Compile Include="Fop2Client\MessageEventArgs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
4 changes: 0 additions & 4 deletions Fop2ClientLib/packages.config

This file was deleted.

5 changes: 5 additions & 0 deletions Fop2DD/Fop2DD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<Reference Include="GlobalHotKey">
<HintPath>..\packages\GlobalHotKey.1.1.0\lib\GlobalHotKey.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.5.0.5\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Remoting" />
Expand Down Expand Up @@ -150,6 +154,7 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="setup.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Fop2ClientLib\Fop2ClientLib.csproj">
Expand Down
29 changes: 28 additions & 1 deletion Fop2DD/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Fop2DD.Core;
using Newtonsoft.Json;
using System;
using System.Reflection;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;

Expand All @@ -22,6 +25,11 @@ static void Main(string[] args)
bool creatednew = false;
var mux = new Mutex(true, "mux_" + Application.ProductName.ToLowerInvariant(), out creatednew);

//When a json file was passed and we can find the file try to import it as default settings
var importsettingsfile = args.Where(a => a.EndsWith(".json", StringComparison.OrdinalIgnoreCase) && File.Exists(a)).FirstOrDefault();
if (importsettingsfile != null)
ImportSettings(importsettingsfile);

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
using (_core = new DDCore())
Expand All @@ -42,5 +50,24 @@ private static void SingleInstanceCallback(object sender, InstanceCallbackEventA
if (args == null || _core == null) return;
_core.DialFromCommandlineArgs(args.CommandLineArgs);
}

private static void ImportSettings(string path)
{
try
{
var f = JsonConvert.DeserializeObject<Properties.Settings>(File.OpenText(path).ReadToEnd());
foreach (var x in f.Properties.OfType<SettingsProperty>())
{
var pi = Properties.Settings.Default.GetType().GetProperty(x.Name);
var v = f.GetType().GetProperty(x.Name).GetValue(f, null);
pi.SetValue(Properties.Settings.Default, v, null);
}
Properties.Settings.Default.Save();
}
catch (Exception ex)
{
throw new Exception(string.Format("Error importing settings '{0}'", path), ex);
}
}
}
}
4 changes: 2 additions & 2 deletions Fop2DD/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.2.0")]
[assembly: AssemblyFileVersion("0.3.2.0")]
[assembly: AssemblyVersion("0.4.0.0")]
[assembly: AssemblyFileVersion("0.4.0.0")]
1 change: 1 addition & 0 deletions Fop2DD/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="GlobalHotKey" version="1.1.0" targetFramework="net35" />
<package id="Newtonsoft.Json" version="5.0.5" targetFramework="net40-Client" />
</packages>
8 changes: 4 additions & 4 deletions Fop2DD/setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
[Setup]
AppPublisher=KeenSystems
AppPublisherURL=http://www.keensystems.eu
AppVersion=0.3.2.0
AppVersion=0.4.0.0
AppName=Fop2DD
AppVerName=Fop2DD 0.3.2
AppVerName=Fop2DD 0.4.0
AppCopyright=Copyright (C) 2013 KeenSystems
VersionInfoVersion=0.3.2.0
VersionInfoVersion=0.4.0.0
DefaultDirName={pf}\KeenSystems\Fop2DD
DefaultGroupName=KeenSystems\Fop2DD
UninstallDisplayIcon={app}\Fop2DD.exe
Expand Down Expand Up @@ -87,4 +87,4 @@ Root: HKCR; Subkey: "tel\DefaultIcon"; ValueType:
Root: HKCR; Subkey: "tel\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\Fop2DD.exe"" ""%1"""; Flags: uninsdeletevalue; Tasks: TelHandler;

[Run]
Filename: "{app}\Fop2DD.exe"; Flags: postinstall nowait;
Filename: "{app}\Fop2DD.exe"; Parameters: "{src}\setup.json"; Flags: postinstall nowait;
18 changes: 18 additions & 0 deletions Fop2DD/setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Sample setup config file */
{
Host: "127.0.0.1",
Port: 4444,
PingInterval: 20,
Username: "101",
PBXContext: "mycontext",
Password: "mysecret",
FOP2Url: "http://192.168.1.10/fop2/?context=%CONTEXT%&exten=%USER%&pass=%PASS%",
GrabMinLength: 6,
ConnectTimeout: 10,
GlobalDialHotkey: "Control + F8",
DialCmd_File: "https://www.google.com/search?q=%PHONENUMBER%",
DialCmd_Args: "",
DialCmd_WorkDir: "",
DialCmd_MinLength: 6,
FOP2UserPortal: "https://192.168.1.10:10000/session_login.cgi?user=%CONTEXT%-%USER%&pass=%PASS%"
}

0 comments on commit fea1548

Please sign in to comment.