diff --git a/SparkleLib/Git/SparkleFetcherGit.cs b/SparkleLib/Git/SparkleFetcherGit.cs index 5b0e0098..f542e8b2 100755 --- a/SparkleLib/Git/SparkleFetcherGit.cs +++ b/SparkleLib/Git/SparkleFetcherGit.cs @@ -86,7 +86,8 @@ namespace SparkleLib { this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath, "clone " + "--progress " + // Redirects progress stats to standarderror - "\"" + base.remote_url + "\" " + "\"" + base.target_folder + "\""); + "\"" + base.remote_url + "\" " + + "\"" + SparkleHelpers.NormalizeSeparatorsToOS(base.target_folder) + "\""); this.git.StartInfo.RedirectStandardError = true; this.git.Start (); diff --git a/SparkleLib/SparkleConfig.cs b/SparkleLib/SparkleConfig.cs index f9f57548..df43b97d 100755 --- a/SparkleLib/SparkleConfig.cs +++ b/SparkleLib/SparkleConfig.cs @@ -173,8 +173,14 @@ namespace SparkleLib { string ssh_config_path = Path.Combine (path, ".ssh"); string ssh_config_file_path = SparkleHelpers.CombineMore (path, ".ssh", "config"); - string ssh_config = "IdentityFile " + - Path.Combine (SparkleConfig.ConfigPath, "sparkleshare." + User.Email + ".key"); + + string ssh_key_path = SparkleHelpers.NormalizeSeparatorsToOS( + Path.Combine(SparkleConfig.ConfigPath, "sparkleshare." + User.Email + ".key")); + if (SparkleHelpers.IsWindows && ssh_key_path.IndexOf(' ') >= 0) + { + ssh_key_path = "\"" + ssh_key_path + "\""; + } + string ssh_config = "IdentityFile " + ssh_key_path; if (!Directory.Exists (ssh_config_path)) Directory.CreateDirectory (ssh_config_path); diff --git a/SparkleLib/SparkleHelpers.cs b/SparkleLib/SparkleHelpers.cs index b2b1a459..0cc856d1 100755 --- a/SparkleLib/SparkleHelpers.cs +++ b/SparkleLib/SparkleHelpers.cs @@ -93,6 +93,29 @@ namespace SparkleLib { { return target.Replace (source + Path.DirectorySeparatorChar, ""); } + + public static bool IsWindows + { + get + { + PlatformID platform = Environment.OSVersion.Platform; + return (platform == PlatformID.Win32NT + || platform == PlatformID.Win32S + || platform == PlatformID.Win32Windows); + } + } + + public static string NormalizeSeparatorsToOS(string path) + { + if (IsWindows) + { + return path.Replace('\\', '/'); + } + else + { + return path; + } + } } } diff --git a/SparkleLib/windows/SparkleLib.csproj b/SparkleLib/windows/SparkleLib.csproj index 0aec68a9..0bf9c160 100644 --- a/SparkleLib/windows/SparkleLib.csproj +++ b/SparkleLib/windows/SparkleLib.csproj @@ -3,7 +3,7 @@ Debug AnyCPU - 9.0.21022 + 9.0.30729 2.0 {2C914413-B31C-4362-93C7-1AE34F09112A} Library @@ -75,9 +75,6 @@ SparkleConfig.cs - - SparklePath.cs - SparkleRepoBase.cs @@ -97,7 +94,6 @@ - diff --git a/SparkleLib/windows/getversion.tt b/SparkleLib/windows/getversion.tt index d558b475..7aa89216 100644 --- a/SparkleLib/windows/getversion.tt +++ b/SparkleLib/windows/getversion.tt @@ -19,7 +19,7 @@ process.StartInfo.RedirectStandardOutput = true; process.StartInfo.CreateNoWindow = true; process.StartInfo.FileName = "git"; - process.StartInfo.Arguments = "describe --tags --dirty=-d --always"; + process.StartInfo.Arguments = "describe --tags"; process.StartInfo.WorkingDirectory = Path.GetDirectoryName(Host.TemplateFile); process.Start(); diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 16676e18..7162c52b 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -27,7 +27,9 @@ using System.Text.RegularExpressions; using System.Threading; using System.Xml; +#if __MonoCS__ using Mono.Unix; +#endif using SparkleLib; namespace SparkleShare { @@ -90,7 +92,7 @@ namespace SparkleShare { // Short alias for the translations public static string _ (string s) { - return Catalog.GetString (s); + return Program._(s); } @@ -1081,12 +1083,16 @@ namespace SparkleShare { } - public void Quit () + public virtual void Quit () { foreach (SparkleRepoBase repo in Repositories) repo.Dispose (); +#if __MonoCS__ Environment.Exit (0); +#else + System.Windows.Forms.Application.Exit(); +#endif } diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 96ec23f2..abe44ed1 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -23,9 +23,13 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading; +#if __MonoCS__ using Gtk; using Mono.Unix; using Mono.Unix.Native; +#else +using System.Windows.Forms; +#endif using SparkleLib; namespace SparkleShare { @@ -44,17 +48,19 @@ namespace SparkleShare { // Short alias for the translations public static string _(string s) { - return Catalog.GetString (s); + return Program._ (s); } public SparkleUI () { // Initialize the application +#if __MonoCS__ Application.Init (); // Use translations Catalog.Init (Defines.GETTEXT_PACKAGE, Defines.LOCALE_DIR); +#endif StatusIcon = new SparkleStatusIcon (); Bubbles = new SparkleBubbles (); @@ -73,6 +79,7 @@ namespace SparkleShare { public void Run () { Application.Run (); + StatusIcon.Dispose (); } } } diff --git a/SparkleShare/Windows/SparkleController.cs b/SparkleShare/Windows/SparkleController.cs index 5d54d868..c42a4d29 100644 --- a/SparkleShare/Windows/SparkleController.cs +++ b/SparkleShare/Windows/SparkleController.cs @@ -62,8 +62,9 @@ namespace SparkleShare { Application.SetCompatibleTextRenderingDefault (false); // Add msysgit to path, as we cannot asume it is added to the path - // Asume it is installed in @"C:\msysgit\bin" for now - string MSysGit=@"C:\msysgit"; + // Asume it is installed in @"\msysgit\bin" + string ExecutableDir = Path.GetDirectoryName(Application.ExecutablePath); + string MSysGit = Path.Combine(ExecutableDir, "msysgit"); string newPath = MSysGit + @"\bin" + ";" + MSysGit + @"\mingw\bin" + ";" @@ -110,7 +111,7 @@ namespace SparkleShare { } } - public override string GetAvatar (string email, int size) + /*public override string GetAvatar (string email, int size) { if (string.IsNullOrEmpty (email)) { return "application://sparkleshare/avatar-default-32.png"; @@ -119,7 +120,7 @@ namespace SparkleShare { SparklePaths.SparkleLocalIconPath, size + "x" + size, "status", "avatar-" + email); return avatar_file_path; - } + }*/ // Creates a .desktop entry in autostart folder to @@ -146,18 +147,27 @@ namespace SparkleShare { // Creates the SparkleShare folder in the user's home folder public override bool CreateSparkleShareFolder () { - if (!Directory.Exists (SparklePaths.SparklePath)) { - - Directory.CreateDirectory (SparklePaths.SparklePath); - SparkleHelpers.DebugInfo ("Config", "Created '" + SparklePaths.SparklePath + "'"); + if (!Directory.Exists(SparkleConfig.DefaultConfig.FoldersPath)) + { + Directory.CreateDirectory(SparkleConfig.DefaultConfig.FoldersPath); + Directory.CreateDirectory(SparkleConfig.DefaultConfig.TmpPath); + SparkleHelpers.DebugInfo("Config", "Created '" + SparkleConfig.DefaultConfig.FoldersPath + "'"); return true; - } return false; } + public override void OpenFile(string url) + { + Process process = new Process(); + process.StartInfo.Arguments = "\"" + url + "\""; + process.StartInfo.FileName = "start"; + + process.Start(); + } + public override void OpenSparkleShareFolder (string subfolder) { Process process = new Process(); diff --git a/SparkleShare/Windows/SparkleEventLog.cs b/SparkleShare/Windows/SparkleEventLog.cs index cc267676..5de70192 100644 --- a/SparkleShare/Windows/SparkleEventLog.cs +++ b/SparkleShare/Windows/SparkleEventLog.cs @@ -136,7 +136,7 @@ namespace SparkleShare { HTML = HTML.Replace ("", "application://sparkleshare/document-moved-12.png"); - HTML = HTML.Replace ("href='" + SparklePaths.SparklePath, "href='application://file/" + SparklePaths.SparklePath); + HTML = HTML.Replace("href='" + SparkleConfig.DefaultConfig.FoldersPath, "href='application://file/" + SparkleConfig.DefaultConfig.FoldersPath); HTML = HTML.Replace ("file://application://sparkleshare/", "application://sparkleshare/"); HTML = HTML.Replace ("file://", "application://file/"); } @@ -180,7 +180,7 @@ namespace SparkleShare { Filename = Uri.UnescapeDataString (Filename); Filename = Filename.Replace ("/", "\\"); - if (Filename.StartsWith (SparklePaths.SparklePath)) + if (Filename.StartsWith(SparkleConfig.DefaultConfig.FoldersPath)) System.Diagnostics.Process.Start (Filename); } } diff --git a/SparkleShare/Windows/SparkleSetup.Designer.cs b/SparkleShare/Windows/SparkleSetup.Designer.cs index 99a427ae..e0b10d10 100644 --- a/SparkleShare/Windows/SparkleSetup.Designer.cs +++ b/SparkleShare/Windows/SparkleSetup.Designer.cs @@ -227,7 +227,7 @@ namespace SparkleShare { // label5 // this.label5.AutoSize = true; - this.label5.Font = new System.Drawing.Font ("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Font = new System.Drawing.Font ("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.Location = new System.Drawing.Point (197, 267); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size (114, 20); @@ -237,7 +237,7 @@ namespace SparkleShare { // label14 // this.label14.AutoSize = true; - this.label14.Font = new System.Drawing.Font ("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label14.Font = new System.Drawing.Font ("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label14.Location = new System.Drawing.Point (8, 267); this.label14.Name = "label14"; this.label14.Size = new System.Drawing.Size (75, 20); diff --git a/SparkleShare/Windows/SparkleSetup.cs b/SparkleShare/Windows/SparkleSetup.cs index db81ff29..1bf011fe 100644 --- a/SparkleShare/Windows/SparkleSetup.cs +++ b/SparkleShare/Windows/SparkleSetup.cs @@ -49,7 +49,7 @@ namespace SparkleShare { pictureBox.Image = Icons.side_splash; this.Icon = Icons.sparkleshare; - Controller.ChangePageEvent += delegate (PageType type) { + Controller.ChangePageEvent += delegate (PageType type, string [] warnings) { tabControl.SafeInvoke ((Action)delegate { switch (type) { case PageType.Add: @@ -206,12 +206,19 @@ namespace SparkleShare { // Enables or disables the 'Next' button depending on the // entries filled in by the user if (!String.IsNullOrEmpty (NameEntry.Text) && - Program.Controller.IsValidEmail (EmailEntry.Text)) { + this.IsValidEmail (EmailEntry.Text)) { buttonNext.Enabled = true; } else { buttonNext.Enabled = false; } } + + // Checks to see if an email address is valid + public bool IsValidEmail(string email) + { + Regex regex = new Regex(@"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", RegexOptions.IgnoreCase); + return regex.IsMatch(email); + } } } diff --git a/SparkleShare/Windows/SparkleShare.csproj b/SparkleShare/Windows/SparkleShare.csproj index a48328d9..a4effb6a 100644 --- a/SparkleShare/Windows/SparkleShare.csproj +++ b/SparkleShare/Windows/SparkleShare.csproj @@ -3,7 +3,7 @@ Debug AnyCPU - 9.0.21022 + 9.0.30729 {728483AA-E34B-4441-BF2C-C8BC2901E4E0} Exe SparkleShare @@ -54,7 +54,9 @@ - + + ..\..\bin\CefSharp.dll + False ..\..\tools\gettext-cs-utils\Gettext.CsUtils\Core\Gettext.Cs\bin\Release\Gettext.Cs.dll @@ -85,6 +87,9 @@ SparkleExtensions.cs + + SparkleInvite.cs + SparklePlugin.cs diff --git a/SparkleShare/Windows/SparkleShare.wxs b/SparkleShare/Windows/SparkleShare.wxs index d9f5719a..dc00effc 100644 --- a/SparkleShare/Windows/SparkleShare.wxs +++ b/SparkleShare/Windows/SparkleShare.wxs @@ -1,64 +1,78 @@ - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - MSYSGIT_CAB_EXISTS - - - - - + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/SparkleShare/Windows/SparkleStatusIcon.cs b/SparkleShare/Windows/SparkleStatusIcon.cs index fc5fdae6..8b4bb690 100644 --- a/SparkleShare/Windows/SparkleStatusIcon.cs +++ b/SparkleShare/Windows/SparkleStatusIcon.cs @@ -56,14 +56,14 @@ namespace SparkleShare { CreateMenu (); SetNormalState (); - Program.Controller.FolderSizeChanged += delegate { + /*Program.Controller.FolderSizeChanged += delegate { status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate { if (!Animation.Enabled) SetNormalState (); UpdateMenu (); }); - }; + };*/ Program.Controller.FolderListChanged += delegate { status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate { @@ -315,7 +315,7 @@ namespace SparkleShare { this.status_icon.Icon = Icon.FromHandle (Icons.sparkleshare_syncing_error_24.GetHicon ()); }); } else { - StateText = _("Up to date") + " (" + Program.Controller.FolderSize + ")"; + StateText = _("Up to date") + " (" + FolderSize + ")"; status_icon.ContextMenuStrip.SafeInvoke ((Action)delegate { this.status_icon.Icon = Icon.FromHandle (AnimationFrames [0].GetHicon ()); }); @@ -333,6 +333,19 @@ namespace SparkleShare { Animation.Start (); } + public string FolderSize + { + get + { + double size = 0; + + foreach (SparkleRepoBase repo in Program.Controller.Repositories) + size += repo.Size + repo.HistorySize; + + return Program.Controller.FormatSize(size); + } + } + #region IDisposable Members public void Dispose () diff --git a/SparkleShare/Windows/build.cmd b/SparkleShare/Windows/build.cmd index 2f4ab8ea..7831694b 100644 --- a/SparkleShare/Windows/build.cmd +++ b/SparkleShare/Windows/build.cmd @@ -16,15 +16,13 @@ set wixBinDir=%WIX%\bin if "%1"=="installer" ( if exist "%wixBinDir%" ( - "%wixBinDir%\heat.exe" dir "%git_install_root%." -cg msysGitComponentGroup -gg -scom -sreg -sfrag -srd -dr MSYSGIT_DIR -t addmedia.xlst -var wix.msysgitpath -o msysgit.wxs - "%wixBinDir%\candle" "%~dp0\SparkleShare.wxs" - "%wixBinDir%\candle" "msysgit.wxs - "%wixBinDir%\light" -ext WixUIExtension Sparkleshare.wixobj msysgit.wixobj -dmsysgitpath=%git_install_root% -o SparkleShare.msi + "%wixBinDir%\heat.exe" dir "%~dp0\..\..\bin\msysgit" -cg msysGitComponentGroup -gg -scom -sreg -sfrag -srd -dr MSYSGIT_DIR -var wix.msysgitpath -o msysgit.wxs + "%wixBinDir%\candle" "%~dp0\SparkleShare.wxs" -ext WixUIExtension -ext WixUtilExtension + "%wixBinDir%\candle" "%~dp0\msysgit.wxs" -ext WixUIExtension -ext WixUtilExtension + "%wixBinDir%\light" -ext WixUIExtension -ext WixUtilExtension Sparkleshare.wixobj msysgit.wixobj -droot="%~dp0\..\.." -dmsysgitpath="%~dp0\..\..\bin\msysgit" -o SparkleShare.msi echo SparkleShare.msi created. - ) else ( echo Not building installer ^(could not find wix, Windows Installer XML toolset^) - echo wix is available at http://wix.sourceforge.net/ + echo wix is available at http://wix.sourceforge.net/ ) - ) else echo Not building installer, as it was not requested. ^(Issue "build.cmd installer" to build installer ^)