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 ()
{
if (this.git != null) {

View file

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

View file

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

View file

@ -31,10 +31,6 @@
<ItemGroup>
<Reference Include="System" />
<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>
<Compile Include="SparkleRepoBase.cs" />

View file

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

View file

@ -52,6 +52,9 @@ namespace SparkleShare {
private NSTextField PathLabel;
private NSTextField PathHelpLabel;
private NSTextField AddProjectTextField;
private NSTextField WarningTextField;
private NSImage WarningImage;
private NSImageView WarningImageView;
private NSTableView TableView;
private NSScrollView ScrollView;
private NSTableColumn IconColumn;
@ -61,7 +64,7 @@ namespace SparkleShare {
public SparkleSetup () : base ()
{
Controller.ChangePageEvent += delegate (PageType type) {
Controller.ChangePageEvent += delegate (PageType type, string [] warnings) {
InvokeOnMainThread (delegate {
Reset ();
@ -452,6 +455,28 @@ namespace SparkleShare {
"" + Controller.SyncingFolder + " in " +
"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 () {
Title = "Finish"
};

View file

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

View file

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

View file

@ -60,22 +60,22 @@ namespace SparkleShare {
if (change_set.Added.Count > 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) {
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) {
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) {
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 +
@ -84,11 +84,11 @@ namespace SparkleShare {
change_set.MovedFrom.Count) - 1;
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);
} else if (changes_count < 0) {
message += _("did something magical");
message += "did something magical";
}
return message;

View file

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

View file

@ -461,7 +461,31 @@ namespace SparkleShare {
Close ();
};
Add (null);
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);
}
AddButton (open_folder_button);
AddButton (finish_button);

View file

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

View file

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