setup: Show a warning when the user has a global gitignore. Closes #432

This commit is contained in:
Hylke Bons 2011-11-28 14:40:34 +01:00
parent bdb6057e2e
commit 5030933abf
13 changed files with 124 additions and 52 deletions

View file

@ -137,6 +137,30 @@ namespace SparkleLib {
} }
public override string [] Warnings {
get {
SparkleGit git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath,
"config --global core.excludesfile");
git.Start ();
// Reading the standard output HAS to go before
// WaitForExit, or it will hang forever on output > 4096 bytes
string output = git.StandardOutput.ReadToEnd ().Trim ();
git.WaitForExit ();
if (string.IsNullOrEmpty (output)) {
return null;
} else {
return new string [] {
string.Format ("You seem to have configured a system gitignore file. " +
"This may interfere with SparkleShare.\n({0})", output)
};
}
}
}
public override void Stop () public override void Stop ()
{ {
if (this.git != null) { if (this.git != null) {

View file

@ -19,8 +19,9 @@ using System;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml; using System.Xml;
using System.Security.Principal;
using Mono.Unix; //using Mono.Unix;
namespace SparkleLib { namespace SparkleLib {
@ -98,11 +99,11 @@ namespace SparkleLib {
if (SparkleBackend.Platform == PlatformID.Unix || if (SparkleBackend.Platform == PlatformID.Unix ||
SparkleBackend.Platform == PlatformID.MacOSX) { SparkleBackend.Platform == PlatformID.MacOSX) {
user_name = new UnixUserInfo (UnixEnvironment.UserName).RealName; user_name = Environment.UserName;
if (string.IsNullOrEmpty (user_name)) if (string.IsNullOrEmpty (user_name))
user_name = UnixEnvironment.UserName; user_name = "";
else else
user_name = user_name.TrimEnd (",".ToCharArray()); user_name = user_name.TrimEnd (",".ToCharArray ());
} else { } else {
user_name = Environment.UserName; user_name = Environment.UserName;

View file

@ -18,10 +18,11 @@
using System; using System;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using System.Security.AccessControl;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using Mono.Unix; //using Mono.Unix;
namespace SparkleLib { namespace SparkleLib {
@ -29,7 +30,7 @@ namespace SparkleLib {
public abstract class SparkleFetcherBase { public abstract class SparkleFetcherBase {
public delegate void StartedEventHandler (); public delegate void StartedEventHandler ();
public delegate void FinishedEventHandler (); public delegate void FinishedEventHandler (string [] warnings);
public delegate void FailedEventHandler (); public delegate void FailedEventHandler ();
public delegate void ProgressChangedEventHandler (double percentage); public delegate void ProgressChangedEventHandler (double percentage);
@ -52,7 +53,7 @@ namespace SparkleLib {
public abstract bool Fetch (); public abstract bool Fetch ();
public abstract string [] Warnings { get; }
// Clones the remote repository // Clones the remote repository
public void Start () public void Start ()
@ -83,7 +84,7 @@ namespace SparkleLib {
EnableHostKeyCheckingForHost (host); EnableHostKeyCheckingForHost (host);
if (Finished != null) if (Finished != null)
Finished (); Finished (Warnings);
} else { } else {
SparkleHelpers.DebugInfo ("Fetcher", "Failed"); SparkleHelpers.DebugInfo ("Fetcher", "Failed");
@ -157,9 +158,9 @@ namespace SparkleLib {
File.WriteAllText (ssh_config_file_path, ssh_config); File.WriteAllText (ssh_config_file_path, ssh_config);
} }
UnixFileSystemInfo file_info = new UnixFileInfo (ssh_config_file_path); //UnixFileSystemInfo file_info = new UnixFileInfo (ssh_config_file_path);
file_info.FileAccessPermissions = (FileAccessPermissions.UserRead | //file_info.FileAccessPermissions = (FileAccessPermissions.UserRead |
FileAccessPermissions.UserWrite); // FileAccessPermissions.UserWrite); TODO
SparkleHelpers.DebugInfo ("Fetcher", "Disabled host key checking " + host); SparkleHelpers.DebugInfo ("Fetcher", "Disabled host key checking " + host);
} }
@ -169,8 +170,8 @@ namespace SparkleLib {
{ {
string path = SparkleConfig.DefaultConfig.HomePath; string path = SparkleConfig.DefaultConfig.HomePath;
if (!(SparkleBackend.Platform == PlatformID.Unix || if (SparkleBackend.Platform != PlatformID.Unix &&
SparkleBackend.Platform == PlatformID.MacOSX)) { SparkleBackend.Platform != PlatformID.MacOSX) {
path = Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%"); path = Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%");
} }
@ -208,9 +209,9 @@ namespace SparkleLib {
} else { } else {
File.WriteAllText (ssh_config_file_path, new_ssh_config.Trim ()); File.WriteAllText (ssh_config_file_path, new_ssh_config.Trim ());
UnixFileSystemInfo file_info = new UnixFileInfo (ssh_config_file_path); //UnixFileSystemInfo file_info = new UnixFileInfo (ssh_config_file_path);
file_info.FileAccessPermissions = (FileAccessPermissions.UserRead | //file_info.FileAccessPermissions = (FileAccessPermissions.UserRead |
FileAccessPermissions.UserWrite); // FileAccessPermissions.UserWrite); TODO
} }
} }

View file

@ -31,10 +31,6 @@
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="Mono.Posix" /> <Reference Include="Mono.Posix" />
<Reference Include="Meebey.SmartIrc4net, Version=0.4.5.0, Culture=neutral, PublicKeyToken=7868485fbf407e0f">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\Meebey.SmartIrc4net.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="SparkleRepoBase.cs" /> <Compile Include="SparkleRepoBase.cs" />

View file

@ -75,9 +75,6 @@ namespace SparkleLib {
case "tcp": case "tcp":
listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier)); listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier));
break; break;
case "irc":
listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier));
break;
default: default:
listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier)); listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier));
break; break;

View file

@ -52,6 +52,9 @@ namespace SparkleShare {
private NSTextField PathLabel; private NSTextField PathLabel;
private NSTextField PathHelpLabel; private NSTextField PathHelpLabel;
private NSTextField AddProjectTextField; private NSTextField AddProjectTextField;
private NSTextField WarningTextField;
private NSImage WarningImage;
private NSImageView WarningImageView;
private NSTableView TableView; private NSTableView TableView;
private NSScrollView ScrollView; private NSScrollView ScrollView;
private NSTableColumn IconColumn; private NSTableColumn IconColumn;
@ -61,7 +64,7 @@ namespace SparkleShare {
public SparkleSetup () : base () public SparkleSetup () : base ()
{ {
Controller.ChangePageEvent += delegate (PageType type) { Controller.ChangePageEvent += delegate (PageType type, string [] warnings) {
InvokeOnMainThread (delegate { InvokeOnMainThread (delegate {
Reset (); Reset ();
@ -452,6 +455,28 @@ namespace SparkleShare {
"" + Controller.SyncingFolder + " in " + "" + Controller.SyncingFolder + " in " +
"your SparkleShare folder."; "your SparkleShare folder.";
if (warnings != null) {
WarningImage = NSImage.ImageNamed ("NSCaution");
WarningImage.Size = new SizeF (24, 24);
WarningImageView = new NSImageView () {
Image = WarningImage,
Frame = new RectangleF (190, Frame.Height - 175, 24, 24)
};
WarningTextField = new NSTextField () {
Frame = new RectangleF (230, Frame.Height - 245, 325, 100),
StringValue = warnings [0],
BackgroundColor = NSColor.WindowBackground,
Bordered = false,
Editable = false,
Font = SparkleUI.Font
};
ContentView.AddSubview (WarningImageView);
ContentView.AddSubview (WarningTextField);
}
FinishButton = new NSButton () { FinishButton = new NSButton () {
Title = "Finish" Title = "Finish"
}; };

View file

@ -143,7 +143,7 @@ namespace SparkleShare {
public override void PerformClose (NSObject sender) public override void PerformClose (NSObject sender)
{ {
OrderOut (this); base.OrderOut (this);
NSApplication.SharedApplication.RemoveWindowsItem (this); NSApplication.SharedApplication.RemoveWindowsItem (this);
return; return;
} }

View file

@ -11,7 +11,7 @@
<RootNamespace>SparkleShare</RootNamespace> <RootNamespace>SparkleShare</RootNamespace>
<AssemblyName>SparkleShare</AssemblyName> <AssemblyName>SparkleShare</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<ReleaseVersion>0.4.0</ReleaseVersion> <ReleaseVersion>0.2.5</ReleaseVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -58,12 +58,11 @@
<Reference Include="Mono.Posix"> <Reference Include="Mono.Posix">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
</Reference> </Reference>
</Reference> <Reference Include="System.Net" />
<Reference Include="SparkleLib, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="SparkleLib, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\bin\SparkleLib.dll</HintPath> <HintPath>..\..\bin\SparkleLib.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Net" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AppDelegate.cs"> <Compile Include="AppDelegate.cs">
@ -110,6 +109,9 @@
<Compile Include="..\SparklePlugin.cs"> <Compile Include="..\SparklePlugin.cs">
<Link>SparklePlugin.cs</Link> <Link>SparklePlugin.cs</Link>
</Compile> </Compile>
<Compile Include="..\SparkleOptions.cs">
<Link>SparkleOptions.cs</Link>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="MainMenu.xib" /> <Page Include="MainMenu.xib" />

View file

@ -60,22 +60,22 @@ namespace SparkleShare {
if (change_set.Added.Count > 0) { if (change_set.Added.Count > 0) {
file_name = change_set.Added [0]; file_name = change_set.Added [0];
message = String.Format (_("added {0}"), file_name); message = String.Format ("added {0}", file_name);
} }
if (change_set.MovedFrom.Count > 0) { if (change_set.MovedFrom.Count > 0) {
file_name = change_set.MovedFrom [0]; file_name = change_set.MovedFrom [0];
message = String.Format (_("moved {0}"), file_name); message = String.Format ("moved {0}", file_name);
} }
if (change_set.Edited.Count > 0) { if (change_set.Edited.Count > 0) {
file_name = change_set.Edited [0]; file_name = change_set.Edited [0];
message = String.Format (_("edited {0}"), file_name); message = String.Format ("edited {0}", file_name);
} }
if (change_set.Deleted.Count > 0) { if (change_set.Deleted.Count > 0) {
file_name = change_set.Deleted [0]; file_name = change_set.Deleted [0];
message = String.Format (_("deleted {0}"), file_name); message = String.Format ("deleted {0}", file_name);
} }
int changes_count = (change_set.Added.Count + int changes_count = (change_set.Added.Count +
@ -84,11 +84,11 @@ namespace SparkleShare {
change_set.MovedFrom.Count) - 1; change_set.MovedFrom.Count) - 1;
if (changes_count > 0) { if (changes_count > 0) {
string msg = Catalog.GetPluralString ("and {0} more", "and {0} more", changes_count); string msg = string.Format ("and {0} more", changes_count);
message += " " + String.Format (msg, changes_count); message += " " + String.Format (msg, changes_count);
} else if (changes_count < 0) { } else if (changes_count < 0) {
message += _("did something magical"); message += "did something magical";
} }
return message; return message;

View file

@ -42,7 +42,7 @@ namespace SparkleShare {
public delegate void OnQuitWhileSyncingEventHandler (); public delegate void OnQuitWhileSyncingEventHandler ();
public event FolderFetchedEventHandler FolderFetched; public event FolderFetchedEventHandler FolderFetched;
public delegate void FolderFetchedEventHandler (); public delegate void FolderFetchedEventHandler (string [] warnings);
public event FolderFetchErrorEventHandler FolderFetchError; public event FolderFetchErrorEventHandler FolderFetchError;
public delegate void FolderFetchErrorEventHandler (string remote_url); public delegate void FolderFetchErrorEventHandler (string remote_url);
@ -1013,7 +1013,7 @@ namespace SparkleShare {
if (i > 1) if (i > 1)
target_folder_name += " (" + i + ")"; target_folder_name += " (" + i + ")";
this.fetcher.Finished += delegate { this.fetcher.Finished += delegate (string [] warnings) {
// Needed to do the moving // Needed to do the moving
SparkleHelpers.ClearAttributes (tmp_folder); SparkleHelpers.ClearAttributes (tmp_folder);
@ -1030,7 +1030,7 @@ namespace SparkleShare {
AddRepository (target_folder_path); AddRepository (target_folder_path);
if (FolderFetched != null) if (FolderFetched != null)
FolderFetched (); FolderFetched (warnings);
FolderSize = GetFolderSize (); FolderSize = GetFolderSize ();

View file

@ -461,7 +461,31 @@ namespace SparkleShare {
Close (); Close ();
}; };
if (warnings != null) {
WarningImage = NSImage.ImageNamed ("NSCaution");
WarningImage.Size = new SizeF (24, 24);
WarningImageView = new NSImageView () {
Image = WarningImage,
Frame = new RectangleF (190, Frame.Height - 175, 24, 24)
};
Image warning_image = new Image (SparkleUIHelpers.GetIcon ("dialog-warning", 24));
Label warning_label = new Label (warnings [0]) {
Xalign = 0
};
HBox warning_layout = new HBox (false, 0);
warning_layout.PackStart (warning_image, false, false, 0);
warning_layout.PackStart (warning_label, true, true, 0);
Add (warning_layout);
} else {
Add (null); Add (null);
}
AddButton (open_folder_button); AddButton (open_folder_button);
AddButton (finish_button); AddButton (finish_button);

View file

@ -42,7 +42,7 @@ namespace SparkleShare {
public class SparkleSetupController { public class SparkleSetupController {
public event ChangePageEventHandler ChangePageEvent; public event ChangePageEventHandler ChangePageEvent;
public delegate void ChangePageEventHandler (PageType page); public delegate void ChangePageEventHandler (PageType page, string [] warnings);
public event UpdateProgressBarEventHandler UpdateProgressBarEvent; public event UpdateProgressBarEventHandler UpdateProgressBarEvent;
public delegate void UpdateProgressBarEventHandler (double percentage); public delegate void UpdateProgressBarEventHandler (double percentage);
@ -152,7 +152,7 @@ namespace SparkleShare {
SelectedPlugin = Plugins [0]; SelectedPlugin = Plugins [0];
ChangePageEvent += delegate (PageType page) { ChangePageEvent += delegate (PageType page, string [] warning) {
this.previous_page = page; this.previous_page = page;
}; };
} }
@ -161,7 +161,7 @@ namespace SparkleShare {
public void ShowSetupPage () public void ShowSetupPage ()
{ {
if (ChangePageEvent != null) if (ChangePageEvent != null)
ChangePageEvent (PageType.Setup); ChangePageEvent (PageType.Setup, null);
} }
@ -187,7 +187,7 @@ namespace SparkleShare {
Program.Controller.UpdateState (); Program.Controller.UpdateState ();
if (ChangePageEvent != null) if (ChangePageEvent != null)
ChangePageEvent (PageType.Tutorial); ChangePageEvent (PageType.Tutorial, null);
} }
@ -196,7 +196,7 @@ namespace SparkleShare {
this.tutorial_page_number++; this.tutorial_page_number++;
if (ChangePageEvent != null) if (ChangePageEvent != null)
ChangePageEvent (PageType.Tutorial); ChangePageEvent (PageType.Tutorial, null);
} }
@ -205,14 +205,14 @@ namespace SparkleShare {
this.tutorial_page_number = 4; this.tutorial_page_number = 4;
if (ChangePageEvent != null) if (ChangePageEvent != null)
ChangePageEvent (PageType.Tutorial); ChangePageEvent (PageType.Tutorial, null);
} }
public void ShowAddPage () public void ShowAddPage ()
{ {
if (ChangePageEvent != null) if (ChangePageEvent != null)
ChangePageEvent (PageType.Add); ChangePageEvent (PageType.Add, null);
SelectedPluginChanged (SelectedPluginIndex); SelectedPluginChanged (SelectedPluginIndex);
} }
@ -241,11 +241,13 @@ namespace SparkleShare {
this.previous_path = path; this.previous_path = path;
if (ChangePageEvent != null) if (ChangePageEvent != null)
ChangePageEvent (PageType.Syncing); ChangePageEvent (PageType.Syncing, null);
Program.Controller.FolderFetched += delegate { // TODO: Remove events afterwards
Program.Controller.FolderFetched += delegate (string [] warnings) {
if (ChangePageEvent != null) if (ChangePageEvent != null)
ChangePageEvent (PageType.Finished); ChangePageEvent (PageType.Finished, warnings);
this.previous_address = ""; this.previous_address = "";
this.syncing_folder = ""; this.syncing_folder = "";
@ -257,7 +259,7 @@ namespace SparkleShare {
this.previous_url = remote_url; this.previous_url = remote_url;
if (ChangePageEvent != null) if (ChangePageEvent != null)
ChangePageEvent (PageType.Error); ChangePageEvent (PageType.Error, null);
this.syncing_folder = ""; this.syncing_folder = "";
}; };
@ -274,7 +276,7 @@ namespace SparkleShare {
public void ErrorPageCompleted () public void ErrorPageCompleted ()
{ {
if (ChangePageEvent != null) if (ChangePageEvent != null)
ChangePageEvent (PageType.Add); ChangePageEvent (PageType.Add, null);
} }
@ -283,7 +285,7 @@ namespace SparkleShare {
Program.Controller.StopFetcher (); Program.Controller.StopFetcher ();
if (ChangePageEvent != null) if (ChangePageEvent != null)
ChangePageEvent (PageType.Add); ChangePageEvent (PageType.Add, null);
} }

View file

@ -24,7 +24,7 @@ namespace SparkleShare {
Idle, Idle,
SyncingUp, SyncingUp,
SyncingDown, SyncingDown,
SyncingUpDown, Syncing,
Error Error
} }