Merge pull request #1750 from Klemele/windows-merge

Windows merge
This commit is contained in:
Hylke Bons 2017-04-15 07:23:44 +01:00 committed by GitHub
commit c696b3c412
33 changed files with 1107 additions and 1769 deletions

View file

@ -167,7 +167,7 @@ namespace SparkleShare {
public abstract void SetFolderIcon (); public abstract void SetFolderIcon ();
// Creates the SparkleShare folder in the user's home folder // Creates the SparkleShare folder in the user's home folder
public abstract bool CreateSparkleShareFolder (); public abstract void CreateSparkleShareFolder ();
// Opens the SparkleShare folder or an (optional) subfolder // Opens the SparkleShare folder or an (optional) subfolder
public abstract void OpenFolder (string path); public abstract void OpenFolder (string path);
@ -206,9 +206,6 @@ namespace SparkleShare {
Config = new Configuration (config_path, "projects.xml"); Config = new Configuration (config_path, "projects.xml");
Configuration.DefaultConfiguration = Config; Configuration.DefaultConfiguration = Config;
UserAuthenticationInfo = new SSHAuthenticationInfo ();
SSHAuthenticationInfo.DefaultAuthenticationInfo = UserAuthenticationInfo;
FoldersPath = Config.FoldersPath; FoldersPath = Config.FoldersPath;
} }
@ -227,6 +224,9 @@ namespace SparkleShare {
// TODO: ToString() with nice os version names (Mac OS X Yosemite, Fedora 24, Ubuntu 16.04, etc.) // TODO: ToString() with nice os version names (Mac OS X Yosemite, Fedora 24, Ubuntu 16.04, etc.)
Logger.LogInfo ("Environment", InstallationInfo.OperatingSystem + " (" + Environment.OSVersion + ")"); Logger.LogInfo ("Environment", InstallationInfo.OperatingSystem + " (" + Environment.OSVersion + ")");
UserAuthenticationInfo = new SSHAuthenticationInfo ();
SSHAuthenticationInfo.DefaultAuthenticationInfo = UserAuthenticationInfo;
Preset.PresetsPath = PresetsPath; Preset.PresetsPath = PresetsPath;
InstallProtocolHandler (); InstallProtocolHandler ();

View file

@ -33,15 +33,12 @@ namespace SparkleShare {
} }
public override bool CreateSparkleShareFolder () public override void CreateSparkleShareFolder ()
{ {
if (Directory.Exists (Configuration.DefaultConfiguration.FoldersPath)) if (!Directory.Exists (Configuration.DefaultConfiguration.FoldersPath)) {
return false; Directory.CreateDirectory (Configuration.DefaultConfiguration.FoldersPath);
Syscall.chmod (Configuration.DefaultConfiguration.FoldersPath, (FilePermissions) 448); // 448 -> 700
Directory.CreateDirectory (Configuration.DefaultConfiguration.FoldersPath); }
Syscall.chmod (Configuration.DefaultConfiguration.FoldersPath, (FilePermissions) 448); // 448 -> 700
return false;
} }

View file

@ -61,16 +61,12 @@ namespace SparkleShare {
} }
public override bool CreateSparkleShareFolder () public override void CreateSparkleShareFolder ()
{ {
if (!Directory.Exists (SparkleShare.Controller.FoldersPath)) { if (!Directory.Exists (SparkleShare.Controller.FoldersPath)) {
Directory.CreateDirectory (SparkleShare.Controller.FoldersPath); Directory.CreateDirectory (SparkleShare.Controller.FoldersPath);
Syscall.chmod (SparkleShare.Controller.FoldersPath, (FilePermissions) 448); // 448 -> 700 Syscall.chmod (SparkleShare.Controller.FoldersPath, (FilePermissions) 448); // 448 -> 700
return true;
} }
return false;
} }

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

View file

@ -1,372 +0,0 @@
// SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons (hylkebons@gmail.com)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see (http://www.gnu.org/licenses/).
using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Win32;
using Shapes = System.Windows.Shapes;
using SparkleLib;
namespace SparkleShare {
public class SparkleEventLog : Window {
public SparkleEventLogController Controller = new SparkleEventLogController ();
private Canvas canvas;
private Label size_label_value;
private Label history_label_value;
private ComboBox combo_box;
private WebBrowser web_browser;
private SparkleSpinner spinner;
public SparkleEventLog ()
{
Title = "Recent Changes";
Height = 640;
Width = 480;
ResizeMode = ResizeMode.NoResize; // TODO
Background = new SolidColorBrush (Color.FromRgb (240, 240, 240));
AllowsTransparency = false;
Icon = SparkleUIHelpers.GetImageSource ("sparkleshare-app", "ico");
int x = (int) (SystemParameters.PrimaryScreenWidth * 0.61);
int y = (int) (SystemParameters.PrimaryScreenHeight * 0.5 - (Height * 0.5));
WindowStartupLocation = WindowStartupLocation.Manual;
Left = x;
Top = y;
WriteOutImages ();
Label size_label = new Label () {
Content = "Size:",
FontWeight = FontWeights.Bold
};
this.size_label_value = new Label () {
Content = Controller.Size
};
size_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
Rect size_label_rect = new Rect (size_label.DesiredSize);
Label history_label = new Label () {
Content = "History:",
FontWeight = FontWeights.Bold
};
this.history_label_value = new Label () {
Content = Controller.HistorySize,
};
history_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
Rect history_label_rect = new Rect (history_label.DesiredSize);
Shapes.Rectangle line = new Shapes.Rectangle () {
Width = Width,
Height = 1,
Fill = new SolidColorBrush (Color.FromRgb (223, 223, 223))
};
Shapes.Rectangle background = new Shapes.Rectangle () {
Width = Width,
Height = Height,
Fill = new SolidColorBrush (Color.FromRgb (250, 250, 250))
};
this.web_browser = new WebBrowser () {
Width = Width - 6,
Height = Height - 64
};
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();
spinner = new SparkleSpinner (22);
// Disable annoying IE clicking sound
CoInternetSetFeatureEnabled (21, 0x00000002, true);
this.canvas = new Canvas ();
Content = this.canvas;
this.canvas.Children.Add (size_label);
Canvas.SetLeft (size_label, 24);
Canvas.SetTop (size_label, 4);
this.canvas.Children.Add (this.size_label_value);
Canvas.SetLeft (this.size_label_value, 22 + size_label_rect.Width);
Canvas.SetTop (this.size_label_value, 4);
this.canvas.Children.Add (history_label);
Canvas.SetLeft (history_label, 130);
Canvas.SetTop (history_label, 4);
this.canvas.Children.Add (this.history_label_value);
Canvas.SetLeft (this.history_label_value, 130 + history_label_rect.Width);
Canvas.SetTop (this.history_label_value, 4);
this.canvas.Children.Add (background);
Canvas.SetLeft (background, 0);
Canvas.SetTop (background, 36);
this.canvas.Children.Add (spinner);
Canvas.SetLeft (spinner, (Width / 2) - 15);
Canvas.SetTop (spinner, (Height / 2) - 22);
this.canvas.Children.Add (line);
Canvas.SetLeft (line, 0);
Canvas.SetTop (line, 35);
Closing += Close;
Controller.ShowWindowEvent += delegate {
Dispatcher.BeginInvoke ((Action) delegate {
Show ();
Activate ();
BringIntoView ();
});
};
Controller.HideWindowEvent += delegate {
Dispatcher.BeginInvoke ((Action) delegate {
Hide ();
if (this.canvas.Children.Contains (this.web_browser))
this.canvas.Children.Remove (this.web_browser);
});
};
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
Dispatcher.BeginInvoke ((Action) delegate {
this.size_label_value.Content = size;
this.size_label_value.UpdateLayout ();
this.history_label_value.Content = history_size;
this.history_label_value.UpdateLayout ();
});
};
Controller.UpdateChooserEvent += delegate (string [] folders) {
Dispatcher.BeginInvoke ((Action) delegate {
UpdateChooser (folders);
});
};
Controller.UpdateChooserEnablementEvent += delegate (bool enabled) {
Dispatcher.BeginInvoke ((Action) delegate {
this.combo_box.IsEnabled = enabled;
});
};
Controller.UpdateContentEvent += delegate (string html) {
Dispatcher.BeginInvoke ((Action) delegate {
UpdateContent (html);
});
};
Controller.ContentLoadingEvent += delegate {
Dispatcher.BeginInvoke ((Action) delegate {
this.spinner.Start ();
if (this.canvas.Children.Contains (this.web_browser))
this.canvas.Children.Remove (this.web_browser);
});
};
Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) {
Dispatcher.BeginInvoke ((Action) delegate {
SaveFileDialog dialog = new SaveFileDialog () {
FileName = file_name,
InitialDirectory = target_folder_path,
Title = "Restore from History",
DefaultExt = "." + Path.GetExtension (file_name),
Filter = "All Files|*.*"
};
Nullable<bool> result = dialog.ShowDialog (this);
if (result == true)
Controller.SaveDialogCompleted (dialog.FileName);
else
Controller.SaveDialogCancelled ();
});
};
}
public void UpdateChooser (string [] folders)
{
if (folders == null)
folders = Controller.Folders;
if (this.combo_box != null)
this.canvas.Children.Remove (this.combo_box);
this.combo_box = new ComboBox () {
Width = 160
};
ComboBoxItem item = new ComboBoxItem () {
Content = "Summary"
};
this.combo_box.Items.Add (item);
this.combo_box.Items.Add (new Separator ());
this.combo_box.SelectedItem = combo_box.Items [0];
int row = 2;
foreach (string folder in folders) {
this.combo_box.Items.Add (
new ComboBoxItem () { Content = folder }
);
if (folder.Equals (Controller.SelectedFolder))
this.combo_box.SelectedItem = combo_box.Items [row];
row++;
}
this.combo_box.SelectionChanged += delegate {
Dispatcher.BeginInvoke ((Action) delegate {
int index = this.combo_box.SelectedIndex;
if (index == 0)
Controller.SelectedFolder = null;
else
Controller.SelectedFolder = (string)
(this.combo_box.Items [index] as ComboBoxItem).Content;
});
};
this.canvas.Children.Add (combo_box);
Canvas.SetLeft (this.combo_box, Width - 24 - this.combo_box.Width);
Canvas.SetTop (this.combo_box, 6);
}
public void UpdateContent (string html)
{
string pixmaps_path = Path.Combine (SparkleLib.SparkleConfig.DefaultConfig.TmpPath, "Images".SHA1 ());
pixmaps_path = pixmaps_path.Replace ("\\", "/");
html = html.Replace ("<a href=", "<a class='windows' href=");
html = html.Replace ("<!-- $body-font-family -->", "'Segoe UI', sans-serif");
html = html.Replace ("<!-- $day-entry-header-font-size -->", "13px");
html = html.Replace ("<!-- $body-font-size -->", "12px");
html = html.Replace ("<!-- $secondary-font-color -->", "#bbb");
html = html.Replace ("<!-- $small-color -->", "#ddd");
html = html.Replace ("<!-- $small-font-size -->", "90%");
html = html.Replace ("<!-- $day-entry-header-background-color -->", "#f5f5f5");
html = html.Replace ("<!-- $a-color -->", "#0085cf");
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
html = html.Replace ("<!-- $pixmaps-path -->", pixmaps_path);
html = html.Replace ("<!-- $document-added-background-image -->", pixmaps_path + "/document-added-12.png");
html = html.Replace ("<!-- $document-edited-background-image -->", pixmaps_path + "/document-edited-12.png");
html = html.Replace ("<!-- $document-deleted-background-image -->", pixmaps_path + "/document-deleted-12.png");
html = html.Replace ("<!-- $document-moved-background-image -->", pixmaps_path + "/document-moved-12.png");
this.spinner.Stop ();
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();
this.web_browser.NavigateToString (html);
if (!this.canvas.Children.Contains (this.web_browser)) {
this.canvas.Children.Add (this.web_browser);
Canvas.SetLeft (this.web_browser, 0);
Canvas.SetTop (this.web_browser, 36);
}
}
private void WriteOutImages ()
{
string tmp_path = SparkleLib.SparkleConfig.DefaultConfig.TmpPath;
string pixmaps_path = Path.Combine (tmp_path, "Images".SHA1 ());
if (!Directory.Exists (pixmaps_path)) {
Directory.CreateDirectory (pixmaps_path);
File.SetAttributes (tmp_path,
File.GetAttributes (tmp_path) | FileAttributes.Hidden);
}
BitmapSource image = SparkleUIHelpers.GetImageSource ("user-icon-default");
string file_path = Path.Combine (pixmaps_path, "user-icon-default.png");
using (FileStream stream = new FileStream (file_path, FileMode.Create))
{
BitmapEncoder encoder = new PngBitmapEncoder ();
encoder.Frames.Add (BitmapFrame.Create (image));
encoder.Save (stream);
}
string [] actions = new string [] {"added", "deleted", "edited", "moved"};
foreach (string action in actions) {
image = SparkleUIHelpers.GetImageSource ("document-" + action + "-12");
file_path = Path.Combine (pixmaps_path, "document-" + action + "-12.png");
using (FileStream stream = new FileStream (file_path, FileMode.Create))
{
BitmapEncoder encoder = new PngBitmapEncoder ();
encoder.Frames.Add (BitmapFrame.Create (image));
encoder.Save (stream);
}
}
}
private void Close (object sender, CancelEventArgs args)
{
Controller.WindowClosed ();
args.Cancel = true;
}
[DllImport ("urlmon.dll")]
[PreserveSig]
[return:MarshalAs (UnmanagedType.Error)]
static extern int CoInternetSetFeatureEnabled (int feature,
[MarshalAs (UnmanagedType.U4)] int flags, bool enable);
}
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[ComVisible(true)]
public class SparkleScriptingObject {
public void LinkClicked (string url)
{
SparkleShare.UI.EventLog.Controller.LinkClicked (url);
}
}
}

View file

@ -1,38 +0,0 @@
<Window x:Class="SparkleShare.SparkleEventLogWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:sparkleShare="clr-namespace:SparkleShare"
mc:Ignorable="d"
Height="640" SizeToContent="WidthAndHeight" Title="Recent Changes" MinHeight="640" MinWidth="490">
<Grid x:Name="grid_Base" Background="White">
<Border VerticalAlignment="Top" Height="35" Background="#FFF0F0F0" BorderBrush="#FFDFDFDF" BorderThickness="0,0,0,1">
<Grid>
<Label Content="Size: ?" Height="28" Name="label_Size" HorizontalAlignment="Left" Margin="20,0,0,0" FontWeight="Bold" />
<Label Content="History: ?" Height="28" Name="label_History" HorizontalAlignment="Left" Margin="100,0,0,0" FontWeight="Bold" />
<ComboBox HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,6,0" MinWidth="120" x:Name="combobox" />
</Grid>
</Border>
<Grid Margin="0, 35, 0, 0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<sparkleShare:SparkleSpinner x:Name="spinner" />
<WebBrowser x:Name="webbrowser" Height="{Binding ElementName=sizingControlHeight, Path=ActualHeight}" Width="{Binding ElementName=sizingControlWidth, Path=ActualWidth}" />
<!-- WPF always resizes from child to parent. Unfortunately the webbrowser takes all space it gets.
To correct this "feature" we use a dummy control in a different column to bind the height to.
See: http://stackoverflow.com/questions/7300975/prevent-parent-from-being-resized-by-child -->
<Rectangle Name="sizingControlHeight" Grid.Column="1" Visibility="Hidden" />
<Rectangle Name="sizingControlWidth" Grid.Column="0" Grid.Row="1" Visibility="Hidden" />
</Grid>
</Grid>
</Window>

View file

@ -1,262 +0,0 @@
// SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Win32;
namespace SparkleShare
{
public partial class SparkleEventLogWindow : Window
{
public SparkleEventLogController Controller = new SparkleEventLogController ();
[DllImport("urlmon.dll")]
[PreserveSig]
[return: MarshalAs(UnmanagedType.Error)]
static extern int CoInternetSetFeatureEnabled (int feature, [MarshalAs(UnmanagedType.U4)] int flags, bool enable);
public SparkleEventLogWindow ()
{
InitializeComponent ();
Background = new SolidColorBrush (Color.FromRgb(240, 240, 240));
AllowsTransparency = false;
Icon = SparkleUIHelpers.GetImageSource ("sparkleshare-app", "ico");
WindowStartupLocation = WindowStartupLocation.CenterScreen;
WriteOutImages ();
this.label_Size.Content = "Size: " + Controller.Size;
this.label_History.Content = "History: " + Controller.HistorySize;
this.webbrowser.ObjectForScripting = new SparkleScriptingObject ();
// Disable annoying IE clicking sound
CoInternetSetFeatureEnabled (21, 0x00000002, true);
Closing += this.OnClosing;
Controller.ShowWindowEvent += delegate {
Dispatcher.BeginInvoke ((Action) (() => {
Show ();
Activate ();
BringIntoView ();
}));
};
Controller.HideWindowEvent += delegate {
Dispatcher.BeginInvoke ((Action) (() => {
Hide ();
this.spinner.Visibility = Visibility.Visible;
this.webbrowser.Visibility = Visibility.Collapsed;
}));
};
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
Dispatcher.BeginInvoke ((Action) (() => {
this.label_Size.Content = "Size: " + size;
this.label_History.Content = "History: " + history_size;
}));
};
Controller.UpdateChooserEvent += delegate (string [] folders) {
Dispatcher.BeginInvoke ((Action) (() =>
UpdateChooser (folders))
);
};
Controller.UpdateChooserEnablementEvent += delegate (bool enabled) {
Dispatcher.BeginInvoke ((Action) (() =>
this.combobox.IsEnabled = enabled
));
};
Controller.UpdateContentEvent += delegate (string html) {
Dispatcher.BeginInvoke ((Action) (() => {
UpdateContent (html);
this.spinner.Visibility = Visibility.Collapsed;
this.webbrowser.Visibility = Visibility.Visible;
}));
};
Controller.ContentLoadingEvent += () => this.Dispatcher.BeginInvoke (
(Action)(() => {
this.spinner.Visibility = Visibility.Visible;
this.spinner.Start ();
this.webbrowser.Visibility = Visibility.Collapsed;
}));
Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) {
Dispatcher.BeginInvoke ((Action) (() => {
SaveFileDialog dialog = new SaveFileDialog () {
FileName = file_name,
InitialDirectory = target_folder_path,
Title = "Restore from History",
DefaultExt = "." + Path.GetExtension (file_name),
Filter = "All Files|*.*"
};
bool? result = dialog.ShowDialog (this);
if (result == true)
Controller.SaveDialogCompleted (dialog.FileName);
else
Controller.SaveDialogCancelled ();
}));
};
}
private void OnClosing (object sender, CancelEventArgs cancel_event_args)
{
Controller.WindowClosed ();
cancel_event_args.Cancel = true;
}
private void UpdateContent (string html)
{
string pixmaps_path = Path.Combine (Sparkles.SparkleConfig.DefaultConfig.TmpPath, "Images");
pixmaps_path = pixmaps_path.Replace ("\\", "/");
html = html.Replace ("<a href=", "<a class='windows' href=");
html = html.Replace ("<!-- $body-font-family -->", "Segoe UI");
html = html.Replace ("<!-- $day-entry-header-font-size -->", "13px");
html = html.Replace ("<!-- $body-font-size -->", "12px");
html = html.Replace ("<!-- $secondary-font-color -->", "#bbb");
html = html.Replace ("<!-- $small-color -->", "#ddd");
html = html.Replace ("<!-- $small-font-size -->", "90%");
html = html.Replace ("<!-- $day-entry-header-background-color -->", "#f5f5f5");
html = html.Replace ("<!-- $a-color -->", "#0085cf");
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
html = html.Replace ("<!-- $pixmaps-path -->", pixmaps_path);
html = html.Replace ("<!-- $document-added-background-image -->", pixmaps_path + "/document-added-12.png");
html = html.Replace ("<!-- $document-edited-background-image -->", pixmaps_path + "/document-edited-12.png");
html = html.Replace ("<!-- $document-deleted-background-image -->", pixmaps_path + "/document-deleted-12.png");
html = html.Replace ("<!-- $document-moved-background-image -->", pixmaps_path + "/document-moved-12.png");
this.spinner.Stop ();
this.webbrowser.ObjectForScripting = new SparkleScriptingObject ();
this.webbrowser.NavigateToString (html);
}
public void UpdateChooser (string [] folders)
{
if (folders == null) {
folders = Controller.Folders;
}
this.combobox.Items.Clear ();
this.combobox.Items.Add (new ComboBoxItem () { Content = "Summary" });
this.combobox.Items.Add (new Separator ());
this.combobox.SelectedItem = combobox.Items [0];
int row = 2;
foreach (string folder in folders) {
this.combobox.Items.Add (new ComboBoxItem () { Content = folder } );
if (folder.Equals (Controller.SelectedFolder))
this.combobox.SelectedItem = this.combobox.Items [row];
row++;
}
this.combobox.SelectionChanged += delegate {
Dispatcher.BeginInvoke ((Action) delegate {
int index = this.combobox.SelectedIndex;
if (index == 0)
Controller.SelectedFolder = null;
else
Controller.SelectedFolder = (string) ((ComboBoxItem) this.combobox.Items [index]).Content;
});
};
}
private void WriteOutImages ()
{
string tmp_path = Sparkles.SparkleConfig.DefaultConfig.TmpPath;
string pixmaps_path = Path.Combine (tmp_path, "Images");
if (!Directory.Exists (pixmaps_path))
{
Directory.CreateDirectory (pixmaps_path);
File.SetAttributes (tmp_path, File.GetAttributes (tmp_path) | FileAttributes.Hidden);
}
BitmapSource image = SparkleUIHelpers.GetImageSource ("user-icon-default");
string file_path = Path.Combine (pixmaps_path, "user-icon-default.png");
using (FileStream stream = new FileStream (file_path, FileMode.Create))
{
BitmapEncoder encoder = new PngBitmapEncoder ();
encoder.Frames.Add (BitmapFrame.Create (image));
encoder.Save (stream);
}
string[] actions = new string [] { "added", "deleted", "edited", "moved" };
foreach (string action in actions)
{
image = SparkleUIHelpers.GetImageSource ("document-" + action + "-12");
file_path = Path.Combine (pixmaps_path, "document-" + action + "-12.png");
using (FileStream stream = new FileStream (file_path, FileMode.Create))
{
BitmapEncoder encoder = new PngBitmapEncoder ();
encoder.Frames.Add (BitmapFrame.Create(image));
encoder.Save (stream);
}
}
}
}
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[ComVisible(true)]
public class SparkleScriptingObject
{
public void LinkClicked(string url)
{
SparkleShare.UI.EventLog.Controller.LinkClicked(url);
}
}
}

View file

@ -1,71 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7F0DB8D0-E278-4955-8204-FC391B99F7C1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SparkleLib.Git</RootNamespace>
<AssemblyName>SparkleLib.Git</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\SparkleLib\Git\SparkleFetcherGit.cs">
<Link>SparkleFetcherGit.cs</Link>
</Compile>
<Compile Include="..\..\..\..\SparkleLib\Git\SparkleGit.cs">
<Link>SparkleGit.cs</Link>
<SubType>Component</SubType>
</Compile>
<Compile Include="..\..\..\..\SparkleLib\Git\SparkleRepoGit.cs">
<Link>SparkleRepoGit.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SparkleLib.csproj">
<Project>{748f6316-37b4-46fd-a011-af073bc7c02d}</Project>
<Name>SparkleLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -1,97 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{748F6316-37B4-46FD-A011-AF073BC7C02D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SparkleLib</RootNamespace>
<AssemblyName>SparkleLib</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\SparkleLib\Defines.cs">
<Link>Defines.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleBackend.cs">
<Link>SparkleBackend.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleConfig.cs">
<Link>SparkleConfig.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleExtensions.cs">
<Link>SparkleExtensions.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleFetcherBase.cs">
<Link>SparkleFetcherBase.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleFetcherSSH.cs">
<Link>SparkleFetcherSSH.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleListenerBase.cs">
<Link>SparkleListenerBase.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleListenerFactory.cs">
<Link>SparkleListenerFactory.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleListenerTcp.cs">
<Link>SparkleListenerTcp.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleLogger.cs">
<Link>SparkleLogger.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleRepoBase.cs">
<Link>SparkleRepoBase.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleUser.cs">
<Link>SparkleUser.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleWatcher.cs">
<Link>SparkleWatcher.cs</Link>
</Compile>
<Compile Include="..\..\..\SparkleLib\SparkleWrappers.cs">
<Link>SparkleWrappers.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -6,9 +6,9 @@
<ProductVersion>8.0.30703</ProductVersion> <ProductVersion>8.0.30703</ProductVersion>
<ProjectGuid>{728483AA-E34B-4441-BF2C-C8BC2901E4E0}</ProjectGuid> <ProjectGuid>{728483AA-E34B-4441-BF2C-C8BC2901E4E0}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AssemblyName>SparkleShare</AssemblyName> <AssemblyName>SparkleShare.Windows</AssemblyName>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<RootNamespace>SparkleShare</RootNamespace> <RootNamespace>SparkleShare.Windows</RootNamespace>
<FileUpgradeFlags> <FileUpgradeFlags>
</FileUpgradeFlags> </FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion> <OldToolsVersion>3.5</OldToolsVersion>
@ -44,6 +44,7 @@
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>..\..\bin\</OutputPath> <OutputPath>..\..\bin\</OutputPath>
@ -53,6 +54,26 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Windows-Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWindows|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMac|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMac|AnyCPU' ">
<OutputPath>..\..\bin\</OutputPath> <OutputPath>..\..\bin\</OutputPath>
@ -80,53 +101,30 @@
<Reference Include="System.Xaml" /> <Reference Include="System.Xaml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\SparkleBubblesController.cs"> <Compile Include="..\Common\AboutController.cs" />
<Link>SparkleBubblesController.cs</Link> <Compile Include="..\Common\Avatars.cs" />
<Compile Include="..\Common\BaseController.cs" />
<Compile Include="..\Common\BubblesController.cs" />
<Compile Include="..\Common\EventLogController.cs" />
<Compile Include="..\Common\NoteController.cs" />
<Compile Include="..\Common\SetupController.cs" />
<Compile Include="..\Common\SparkleShare.cs" />
<Compile Include="..\Common\StatusIconController.cs" />
<Compile Include="UserInterface\About.cs" />
<Compile Include="UserInterface\Bubbles.cs" />
<Compile Include="UserInterface\EventLog.cs" />
<Compile Include="UserInterface\Controller.cs" />
<Compile Include="UserInterface\Note.xaml.cs">
<DependentUpon>Note.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="..\SparkleControllerBase.cs"> <Compile Include="UserInterface\NotifyIcon.cs" />
<Link>SparkleControllerBase.cs</Link> <Compile Include="UserInterface\Setup.cs" />
</Compile> <Compile Include="UserInterface\SetupWindow.cs" />
<Compile Include="..\SparkleExtensions.cs"> <Compile Include="UserInterface\Shortcut.cs" />
<Link>SparkleExtensions.cs</Link> <Compile Include="UserInterface\Spinner.cs" />
</Compile> <Compile Include="UserInterface\StatusIcon.cs" />
<Compile Include="..\SparkleInvite.cs"> <Compile Include="UserInterface\UserInterface.cs" />
<Link>SparkleInvite.cs</Link> <Compile Include="UserInterface\UserInterfaceHelpers.cs" />
</Compile>
<Compile Include="..\SparkleNoteController.cs">
<Link>SparkleNoteController.cs</Link>
</Compile>
<Compile Include="..\SparklePlugin.cs">
<Link>SparklePlugin.cs</Link>
</Compile>
<Compile Include="..\SparkleStatusIconController.cs">
<Link>SparkleStatusIconController.cs</Link>
</Compile>
<Compile Include="..\SparkleSetupController.cs" />
<Compile Include="SparkleEventLogWindow.xaml.cs">
<DependentUpon>SparkleEventLogWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SparkleNote.xaml.cs">
<DependentUpon>SparkleNote.xaml</DependentUpon>
</Compile>
<Compile Include="SparkleShortcut.cs" />
<Compile Include="SparkleUI.cs" />
<Compile Include="..\SparkleAboutController.cs" />
<Compile Include="..\SparkleAvatars.cs" />
<Compile Include="SparkleBubbles.cs" />
<Compile Include="SparkleAbout.cs" />
<Compile Include="SparkleController.cs" />
<Compile Include="SparkleSetup.cs" />
<Compile Include="SparkleStatusIcon.cs" />
<Compile Include="SparkleUIHelpers.cs" />
<Compile Include="..\SparkleEventLogController.cs">
<Link>SparkleEventLogController.cs</Link>
</Compile>
<Compile Include="SparkleSetupWindow.cs" />
<Compile Include="..\Program.cs">
<Link>Program.cs</Link>
</Compile>
<Compile Include="SparkleNotifyIcon.cs" />
<Compile Include="SparkleSpinner.cs" />
</ItemGroup> </ItemGroup>
<ProjectExtensions> <ProjectExtensions>
<VisualStudio /> <VisualStudio />
@ -155,9 +153,11 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="..\Common\Images\about.png"> <EmbeddedResource Include="..\Common\Images\about.png">
<Link>Images\about.png</Link> <Link>Images\about.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\Common\Images\side-splash.png"> <EmbeddedResource Include="..\Common\Images\side-splash.png">
<Link>Images\side-splash.png</Link> <Link>Images\side-splash.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\Common\HTML\day-entry.html"> <EmbeddedResource Include="..\Common\HTML\day-entry.html">
<Link>HTML\day-entry.html</Link> <Link>HTML\day-entry.html</Link>
@ -174,31 +174,47 @@
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\Common\Images\user-icon-default.png"> <EmbeddedResource Include="..\Common\Images\user-icon-default.png">
<Link>Images\user-icon-default.png</Link> <Link>Images\user-icon-default.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\Linux\Images\icons\document-added-12.png"> <EmbeddedResource Include="..\Linux\Images\icons\hicolor\document-added-12.png">
<Link>Images\document-added-12.png</Link> <Link>Images\document-added-12.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\Linux\Images\icons\document-deleted-12.png"> <EmbeddedResource Include="..\Linux\Images\icons\hicolor\document-deleted-12.png">
<Link>Images\document-deleted-12.png</Link> <Link>Images\document-deleted-12.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\Linux\Images\icons\document-edited-12.png"> <EmbeddedResource Include="..\Linux\Images\icons\hicolor\document-edited-12.png">
<Link>Images\document-edited-12.png</Link> <Link>Images\document-edited-12.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\Linux\Images\icons\document-moved-12.png"> <EmbeddedResource Include="..\Linux\Images\icons\hicolor\document-moved-12.png">
<Link>Images\document-moved-12.png</Link> <Link>Images\document-moved-12.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\Linux\Images\icons\process-working-22.png"> <EmbeddedResource Include="..\Linux\Images\icons\hicolor\process-working-22.png">
<Link>Images\process-working-22.png</Link> <Link>Images\process-working-22.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Images\process-syncing-down.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Images\process-syncing-idle.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Images\process-syncing-up.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Images\process-syncing.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Images\process-syncing-down.png" />
<EmbeddedResource Include="Images\process-syncing-idle.png" />
<EmbeddedResource Include="Images\process-syncing-up.png" />
<EmbeddedResource Include="Images\process-syncing.png" />
<EmbeddedResource Include="..\Common\Images\tutorial-slide-1.png"> <EmbeddedResource Include="..\Common\Images\tutorial-slide-1.png">
<Link>Images\tutorial-slide-1.png</Link> <Link>Images\tutorial-slide-1.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\Common\Images\tutorial-slide-2.png"> <EmbeddedResource Include="..\Common\Images\tutorial-slide-2.png">
<Link>Images\tutorial-slide-2.png</Link> <Link>Images\tutorial-slide-2.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -206,10 +222,6 @@
<Link>Presets\github.png</Link> <Link>Presets\github.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="..\Common\Presets\gitorious.png">
<Link>Presets\gitorious.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Common\Presets\own-server.png"> <None Include="..\Common\Presets\own-server.png">
<Link>Presets\own-server.png</Link> <Link>Presets\own-server.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
@ -218,20 +230,13 @@
<Link>Presets\bitbucket.png</Link> <Link>Presets\bitbucket.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="..\Common\Presets\ssnet.png">
<Link>Presets\ssnet.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Common\Presets\planio.png"> <None Include="..\Common\Presets\planio.png">
<Link>Presets\planio.png</Link> <Link>Presets\planio.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="app.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\Common\Presets\ssnet.xml">
<Link>Presets\ssnet.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Common\Presets\bitbucket.xml"> <None Include="..\Common\Presets\bitbucket.xml">
<Link>Presets\bitbucket.xml</Link> <Link>Presets\bitbucket.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
@ -240,10 +245,6 @@
<Link>Presets\github.xml</Link> <Link>Presets\github.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="..\Common\Presets\gitorious.xml">
<Link>Presets\gitorious.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\Common\Presets\own-server.xml"> <None Include="..\Common\Presets\own-server.xml">
<Link>Presets\own-server.xml</Link> <Link>Presets\own-server.xml</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
@ -254,26 +255,35 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Images\folder.png" /> <EmbeddedResource Include="Images\folder.png">
<EmbeddedResource Include="Images\process-syncing-error.png" /> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
<EmbeddedResource Include="Images\sparkleshare-app.ico" /> </EmbeddedResource>
<EmbeddedResource Include="Images\sparkleshare-folder.png" /> <EmbeddedResource Include="Images\process-syncing-error.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Images\sparkleshare-app.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Images\sparkleshare-folder.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Images\tutorial-slide-3.png" /> <EmbeddedResource Include="Images\tutorial-slide-3.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="..\Common\Images\text-balloon.png"> <Resource Include="..\Common\Images\text-balloon.png">
<Link>Images\text-balloon.png</Link> <Link>Images\text-balloon.png</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource> </Resource>
<Content Include="Images\sparkleshare-folder.ico" /> <Content Include="Images\sparkleshare-folder.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="SparkleEventLogWindow.xaml"> <Page Include="UserInterface\Note.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SparkleNote.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
@ -288,4 +298,4 @@
<Name>Sparkles.Git</Name> <Name>Sparkles.Git</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -17,30 +17,27 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xaml;
namespace SparkleShare { namespace SparkleShare {
public class SparkleAbout : Window { public class About : Window {
public SparkleAboutController Controller = new SparkleAboutController (); public AboutController Controller = new AboutController ();
private Label updates; private Label updates;
public SparkleAbout () public About ()
{ {
Title = "About SparkleShare"; Title = "About SparkleShare";
ResizeMode = ResizeMode.NoResize; ResizeMode = ResizeMode.NoResize;
Height = 288; Height = 288;
Width = 720; Width = 720;
Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); Icon = UserInterfaceHelpers.GetImageSource("sparkleshare-app", "ico");
WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowStartupLocation = WindowStartupLocation.CenterScreen;
Closing += Close; Closing += Close;
@ -77,7 +74,7 @@ namespace SparkleShare {
Height = 260 Height = 260
}; };
image.Source = SparkleUIHelpers.GetImageSource ("about"); image.Source = UserInterfaceHelpers.GetImageSource ("about");
Label version = new Label () { Label version = new Label () {

View file

@ -15,16 +15,14 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace SparkleShare { namespace SparkleShare {
public class SparkleBubbles { public class Bubbles {
public SparkleBubblesController Controller = new SparkleBubblesController (); public BubblesController Controller = new BubblesController ();
public SparkleBubbles () public Bubbles ()
{ {
Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) { Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
if (!SparkleShare.Controller.NotificationsEnabled) if (!SparkleShare.Controller.NotificationsEnabled)

View file

@ -16,26 +16,22 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows; using System.Windows;
using Forms = System.Windows.Forms; using Forms = System.Windows.Forms;
using Microsoft.Win32;
using Sparkles; using Sparkles;
using Sparkles.Git;
namespace SparkleShare { namespace SparkleShare {
public class SparkleController : SparkleControllerBase { public class Controller : BaseController {
public SparkleController () public Controller ()
{ {
} }
@ -43,7 +39,7 @@ namespace SparkleShare {
public override string PresetsPath public override string PresetsPath
{ {
get { get {
return Path.Combine (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location), "plugins"); return Path.Combine (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location), "Presets");
} }
} }
@ -55,15 +51,11 @@ namespace SparkleShare {
string executable_path = Path.GetDirectoryName (Forms.Application.ExecutablePath); string executable_path = Path.GetDirectoryName (Forms.Application.ExecutablePath);
string msysgit_path = Path.Combine (executable_path, "msysgit"); string msysgit_path = Path.Combine (executable_path, "msysgit");
string new_PATH = msysgit_path + @"\bin" + ";" +
msysgit_path + @"\mingw\bin" + ";" +
msysgit_path + @"\cmd" + ";" +
Environment.ExpandEnvironmentVariables ("%PATH%");
Environment.SetEnvironmentVariable ("PATH", new_PATH);
Environment.SetEnvironmentVariable ("HOME", Environment.GetFolderPath (Environment.SpecialFolder.UserProfile)); Environment.SetEnvironmentVariable ("HOME", Environment.GetFolderPath (Environment.SpecialFolder.UserProfile));
Sparkles.Git.SparkleGit.SSHPath = Path.Combine (msysgit_path, "bin", "ssh.exe"); SSHCommand.SSHPath = Path.Combine (msysgit_path, "usr", "bin");
SSHFetcher.SSHKeyScan = Path.Combine (msysgit_path, "usr", "bin", "ssh-keyscan.exe");
GitCommand.GitPath = Path.Combine (msysgit_path, "bin", "git.exe");
base.Initialize (); base.Initialize ();
} }
@ -71,22 +63,54 @@ namespace SparkleShare {
public override string EventLogHTML { public override string EventLogHTML {
get { get {
string html = SparkleUIHelpers.GetHTML ("event-log.html"); string html = UserInterfaceHelpers.GetHTML ("event-log.html");
return html.Replace ("<!-- $jquery -->", SparkleUIHelpers.GetHTML ("jquery.js")); return html.Replace ("<!-- $jquery -->", UserInterfaceHelpers.GetHTML ("jquery.js"));
} }
} }
public override string DayEntryHTML { public override string DayEntryHTML {
get { get {
return SparkleUIHelpers.GetHTML ("day-entry.html"); return UserInterfaceHelpers.GetHTML ("day-entry.html");
} }
} }
public override string EventEntryHTML { public override string EventEntryHTML {
get { get {
return SparkleUIHelpers.GetHTML ("event-entry.html"); return UserInterfaceHelpers.GetHTML ("event-entry.html");
}
}
public override void SetFolderIcon ()
{
string app_path = Path.GetDirectoryName (Forms.Application.ExecutablePath);
string icon_file_path = Path.Combine (app_path, "Images", "sparkleshare-folder.ico");
if (!File.Exists (icon_file_path))
{
string ini_file_path = Path.Combine (FoldersPath, "desktop.ini");
string n = Environment.NewLine;
string ini_file = "[.ShellClassInfo]" + n +
"IconFile=" + icon_file_path + n +
"IconIndex=0" + n +
"InfoTip=SparkleShare";
try
{
File.Create (ini_file_path).Close ();
File.WriteAllText (ini_file_path, ini_file);
File.SetAttributes (ini_file_path,
File.GetAttributes (ini_file_path) | FileAttributes.Hidden | FileAttributes.System);
}
catch (IOException e)
{
Logger.LogInfo ("Config", "Failed setting icon for '" + FoldersPath + "': " + e.Message);
}
} }
} }
@ -112,7 +136,7 @@ namespace SparkleShare {
} }
public override void AddToBookmarks () public void AddToBookmarks ()
{ {
string user_profile_path = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile); string user_profile_path = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
string shortcut_path = Path.Combine (user_profile_path, "Links", "SparkleShare.lnk"); string shortcut_path = Path.Combine (user_profile_path, "Links", "SparkleShare.lnk");
@ -125,43 +149,15 @@ namespace SparkleShare {
} }
public override bool CreateSparkleShareFolder () public override void CreateSparkleShareFolder ()
{ {
if (Directory.Exists (FoldersPath)) if (!Directory.Exists (FoldersPath))
return false; {
Directory.CreateDirectory (FoldersPath);
Directory.CreateDirectory (FoldersPath); File.SetAttributes (FoldersPath, File.GetAttributes(FoldersPath) | FileAttributes.System);
Logger.LogInfo ("Config", "Created '" + FoldersPath + "'");
File.SetAttributes (FoldersPath, File.GetAttributes (FoldersPath) | FileAttributes.System);
SparkleLogger.LogInfo ("Config", "Created '" + FoldersPath + "'");
string app_path = Path.GetDirectoryName (Forms.Application.ExecutablePath);
string icon_file_path = Path.Combine (app_path, "Images", "sparkleshare-folder.ico");
if (!File.Exists (icon_file_path)) {
string ini_file_path = Path.Combine (FoldersPath, "desktop.ini");
string n = Environment.NewLine;
string ini_file = "[.ShellClassInfo]" + n +
"IconFile=" + icon_file_path + n +
"IconIndex=0" + n +
"InfoTip=SparkleShare";
try {
File.Create (ini_file_path).Close ();
File.WriteAllText (ini_file_path, ini_file);
File.SetAttributes (ini_file_path,
File.GetAttributes (ini_file_path) | FileAttributes.Hidden | FileAttributes.System);
} catch (IOException e) {
SparkleLogger.LogInfo ("Config", "Failed setting icon for '" + FoldersPath + "': " + e.Message);
}
return true;
} }
return false;
} }
@ -189,7 +185,7 @@ namespace SparkleShare {
Clipboard.SetData (DataFormats.Text, text); Clipboard.SetData (DataFormats.Text, text);
} catch (COMException e) { } catch (COMException e) {
SparkleLogger.LogInfo ("Controller", "Copy to clipboard failed", e); Logger.LogInfo ("Controller", "Copy to clipboard failed", e);
} }
} }

View file

@ -0,0 +1,347 @@
// SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.ComponentModel;
using System.IO;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Win32;
using System.Windows.Data;
namespace SparkleShare
{
public class EventLog : Window {
public EventLogController Controller = new EventLogController ();
private Label label_Size;
private Label label_History;
private WebBrowser webbrowser;
private Spinner spinner;
private ComboBox combobox;
private Grid grid_Base;
[DllImport("urlmon.dll")]
[PreserveSig]
[return: MarshalAs(UnmanagedType.Error)]
static extern int CoInternetSetFeatureEnabled(int feature, [MarshalAs(UnmanagedType.U4)] int flags, bool enable);
public EventLog()
{
CreateEventLog();
Background = new SolidColorBrush(Color.FromRgb(240, 240, 240));
AllowsTransparency = false;
Icon = UserInterfaceHelpers.GetImageSource("sparkleshare-app", "ico");
WindowStartupLocation = WindowStartupLocation.CenterScreen;
WriteOutImages();
this.label_Size.Content = "Size: " + Controller.Size;
this.label_History.Content = "History: " + Controller.HistorySize;
this.webbrowser.ObjectForScripting = new SparkleScriptingObject();
// Disable annoying IE clicking sound
CoInternetSetFeatureEnabled(21, 0x00000002, true);
Closing += this.OnClosing;
Controller.ShowWindowEvent += delegate {
Dispatcher.BeginInvoke((Action)(() => {
Show();
Activate();
BringIntoView();
}));
};
Controller.HideWindowEvent += delegate {
Dispatcher.BeginInvoke((Action)(() => {
Hide();
this.spinner.Visibility = Visibility.Visible;
this.webbrowser.Visibility = Visibility.Collapsed;
}));
};
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
Dispatcher.BeginInvoke((Action)(() => {
this.label_Size.Content = "Size: " + size;
this.label_History.Content = "History: " + history_size;
}));
};
Controller.UpdateChooserEvent += delegate (string[] folders) {
Dispatcher.BeginInvoke((Action)(() =>
UpdateChooser(folders))
);
};
Controller.UpdateChooserEnablementEvent += delegate (bool enabled) {
Dispatcher.BeginInvoke((Action)(() =>
this.combobox.IsEnabled = enabled
));
};
Controller.UpdateContentEvent += delegate (string html) {
Dispatcher.BeginInvoke((Action)(() => {
UpdateContent(html);
this.spinner.Visibility = Visibility.Collapsed;
this.webbrowser.Visibility = Visibility.Visible;
}));
};
Controller.ContentLoadingEvent += () => this.Dispatcher.BeginInvoke(
(Action)(() => {
this.spinner.Visibility = Visibility.Visible;
this.spinner.Start();
this.webbrowser.Visibility = Visibility.Collapsed;
}));
Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) {
Dispatcher.BeginInvoke((Action)(() => {
SaveFileDialog dialog = new SaveFileDialog()
{
FileName = file_name,
InitialDirectory = target_folder_path,
Title = "Restore from History",
DefaultExt = "." + System.IO.Path.GetExtension(file_name),
Filter = "All Files|*.*"
};
bool? result = dialog.ShowDialog(this);
if (result == true)
Controller.SaveDialogCompleted(dialog.FileName);
else
Controller.SaveDialogCancelled();
}));
};
}
private void CreateEventLog () {
grid_Base = new Grid { Background = Brushes.White };
label_Size = new Label {
Content = "Size: ?",
Height = 28,
HorizontalAlignment = HorizontalAlignment.Left,
Margin = new Thickness(20, 0, 0, 0),
FontWeight = FontWeights.Bold
};
label_History = new Label {
Content = "History: ?",
Height = 28,
HorizontalAlignment = HorizontalAlignment.Left,
Margin = new Thickness(100, 0, 0, 0),
FontWeight = FontWeights.Bold
};
combobox = new ComboBox {
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(0, 0, 6, 0),
MinWidth = 120
};
spinner = new Spinner { Name = "spinner" };
webbrowser = new WebBrowser { Name = "webbrowser" };
Border border = new Border {
VerticalAlignment = VerticalAlignment.Top,
Height = 35,
Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)),
BorderBrush = new SolidColorBrush(Color.FromArgb(255, 223, 223, 223)),
BorderThickness = new Thickness(0, 0, 0, 1)
};
Grid borderGrid = new Grid();
borderGrid.Children.Add(this.label_Size);
borderGrid.Children.Add(this.label_History);
borderGrid.Children.Add(this.combobox);
border.Child = borderGrid;
Grid browserGrid = new Grid { Margin = new Thickness(0, 35, 0, 0) };
browserGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
browserGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
browserGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
browserGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
browserGrid.Children.Add(this.spinner);
browserGrid.Children.Add(this.webbrowser);
Rectangle sizingControlHeight = new Rectangle {
Name = "sizingControlHeight",
Visibility = Visibility.Hidden
};
Grid.SetColumn(sizingControlHeight, 1);
Rectangle sizingControlWidth = new Rectangle {
Name = "sizingControlHeight",
Visibility = Visibility.Hidden
};
Grid.SetColumn(sizingControlWidth, 0);
Grid.SetRow(sizingControlWidth, 0);
browserGrid.Children.Add(sizingControlHeight);
browserGrid.Children.Add(sizingControlWidth);
webbrowser.SetBinding(HeightProperty, new Binding("ActualHeightProperty") { ElementName = sizingControlHeight.Name });
webbrowser.SetBinding(WidthProperty, new Binding("ActualWidthProperty") { ElementName = sizingControlWidth.Name });
grid_Base.Children.Add(border);
}
private void OnClosing(object sender, CancelEventArgs cancel_event_args)
{
Controller.WindowClosed();
cancel_event_args.Cancel = true;
}
private void UpdateContent(string html)
{
string pixmaps_path = System.IO.Path.Combine(Sparkles.Configuration.DefaultConfiguration.TmpPath, "Images");
pixmaps_path = pixmaps_path.Replace("\\", "/");
html = html.Replace("<a href=", "<a class='windows' href=");
html = html.Replace("<!-- $body-font-family -->", "Segoe UI");
html = html.Replace("<!-- $day-entry-header-font-size -->", "13px");
html = html.Replace("<!-- $body-font-size -->", "12px");
html = html.Replace("<!-- $secondary-font-color -->", "#bbb");
html = html.Replace("<!-- $small-color -->", "#ddd");
html = html.Replace("<!-- $small-font-size -->", "90%");
html = html.Replace("<!-- $day-entry-header-background-color -->", "#f5f5f5");
html = html.Replace("<!-- $a-color -->", "#0085cf");
html = html.Replace("<!-- $a-hover-color -->", "#009ff8");
html = html.Replace("<!-- $pixmaps-path -->", pixmaps_path);
html = html.Replace("<!-- $document-added-background-image -->", pixmaps_path + "/document-added-12.png");
html = html.Replace("<!-- $document-edited-background-image -->", pixmaps_path + "/document-edited-12.png");
html = html.Replace("<!-- $document-deleted-background-image -->", pixmaps_path + "/document-deleted-12.png");
html = html.Replace("<!-- $document-moved-background-image -->", pixmaps_path + "/document-moved-12.png");
this.spinner.Stop();
this.webbrowser.ObjectForScripting = new SparkleScriptingObject();
this.webbrowser.NavigateToString(html);
}
public void UpdateChooser(string[] folders)
{
if (folders == null)
{
folders = Controller.Folders;
}
this.combobox.Items.Clear();
this.combobox.Items.Add(new ComboBoxItem() { Content = "Summary" });
this.combobox.Items.Add(new Separator());
this.combobox.SelectedItem = combobox.Items[0];
int row = 2;
foreach (string folder in folders)
{
this.combobox.Items.Add(new ComboBoxItem() { Content = folder });
if (folder.Equals(Controller.SelectedFolder))
this.combobox.SelectedItem = this.combobox.Items[row];
row++;
}
this.combobox.SelectionChanged += delegate {
Dispatcher.BeginInvoke((Action)delegate {
int index = this.combobox.SelectedIndex;
if (index == 0)
Controller.SelectedFolder = null;
else
Controller.SelectedFolder = (string)((ComboBoxItem)this.combobox.Items[index]).Content;
});
};
}
private void WriteOutImages()
{
string tmp_path = Sparkles.Configuration.DefaultConfiguration.TmpPath;
string pixmaps_path = System.IO.Path.Combine(tmp_path, "Images");
if (!Directory.Exists(pixmaps_path))
{
Directory.CreateDirectory(pixmaps_path);
File.SetAttributes(tmp_path, File.GetAttributes(tmp_path) | FileAttributes.Hidden);
}
BitmapSource image = UserInterfaceHelpers.GetImageSource("user-icon-default");
string file_path = System.IO.Path.Combine(pixmaps_path, "user-icon-default.png");
using (FileStream stream = new FileStream(file_path, FileMode.Create))
{
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(image));
encoder.Save(stream);
}
string[] actions = new string[] { "added", "deleted", "edited", "moved" };
foreach (string action in actions)
{
image = UserInterfaceHelpers.GetImageSource("document-" + action + "-12");
file_path = System.IO.Path.Combine(pixmaps_path, "document-" + action + "-12.png");
using (FileStream stream = new FileStream(file_path, FileMode.Create))
{
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(image));
encoder.Save(stream);
}
}
}
}
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[ComVisible(true)]
public class SparkleScriptingObject
{
public void LinkClicked(string url)
{
SparkleShare.UI.EventLog.Controller.LinkClicked(url);
}
}
}

View file

@ -1,4 +1,4 @@
<Window x:Class="SparkleShare.SparkleNote" <Window x:Class="SparkleShare.Note"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -26,7 +26,7 @@
</StackPanel> </StackPanel>
<TextBox x:Name="balloon_text_field" Grid.Row="1" Grid.ColumnSpan="2" Width="438" Height="72" BorderBrush="{x:Null}" BorderThickness="0" Padding="8,12,8,8" TextWrapping="Wrap" AcceptsReturn="True" Text="Anything to add?" > <TextBox x:Name="balloon_text_field" Grid.Row="1" Grid.ColumnSpan="2" Width="438" Height="72" BorderBrush="{x:Null}" BorderThickness="0" Padding="8,12,8,8" TextWrapping="Wrap" AcceptsReturn="True" Text="Anything to add?" >
<TextBox.Background> <TextBox.Background>
<ImageBrush ImageSource="pack://application:,,,/SparkleShare;component/Images/text-balloon.png" Stretch="Uniform"></ImageBrush> <ImageBrush ImageSource="pack://application:,,,/SparkleShare.Windows;component/Images/text-balloon.png" Stretch="Uniform"></ImageBrush>
</TextBox.Background> </TextBox.Background>
</TextBox> </TextBox>
<StackPanel Grid.Column="1" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Orientation="Horizontal"> <StackPanel Grid.Column="1" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Orientation="Horizontal">

View file

@ -26,19 +26,19 @@ using Sparkles;
namespace SparkleShare { namespace SparkleShare {
public partial class SparkleNote : Window { public partial class Note : Window {
public SparkleNoteController Controller = new SparkleNoteController (); public NoteController Controller = new NoteController ();
private readonly string default_text = "Anything to add?"; private readonly string default_text = "Anything to add?";
public SparkleNote() public Note ()
{ {
InitializeComponent(); InitializeComponent();
Background = new SolidColorBrush(Color.FromRgb(240, 240, 240)); Background = new SolidColorBrush(Color.FromRgb(240, 240, 240));
AllowsTransparency = false; AllowsTransparency = false;
Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); Icon = UserInterfaceHelpers.GetImageSource("sparkleshare-app", "ico");
WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowStartupLocation = WindowStartupLocation.CenterScreen;
Closing += this.OnClosing; Closing += this.OnClosing;
@ -85,10 +85,10 @@ namespace SparkleShare {
private void CreateNote() private void CreateNote()
{ {
ImageSource avatar = SparkleUIHelpers.GetImageSource("user-icon-default"); ImageSource avatar = UserInterfaceHelpers.GetImageSource("user-icon-default");
if (File.Exists (Controller.AvatarFilePath)) { if (File.Exists (Controller.AvatarFilePath)) {
avatar = SparkleUIHelpers.GetImage (Controller.AvatarFilePath); avatar = UserInterfaceHelpers.GetImage (Controller.AvatarFilePath);
} }
this.user_image.ImageSource = avatar; this.user_image.ImageSource = avatar;

View file

@ -1,188 +1,188 @@
// SparkleShare, a collaboration and sharing tool. // SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com> // Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Markup; using System.Windows.Markup;
using Drawing = System.Drawing; using Drawing = System.Drawing;
using Forms = System.Windows.Forms; using Forms = System.Windows.Forms;
namespace SparkleShare { namespace SparkleShare {
[ContentProperty("Text")] [ContentProperty("Text")]
[DefaultEvent("MouseDoubleClick")] [DefaultEvent("MouseDoubleClick")]
public class SparkleNotifyIcon : UIElement, IAddChild { public class NotifyIcon : UIElement, IAddChild {
[DllImport("user32.dll", EntryPoint = "DestroyIcon")] [DllImport("user32.dll", EntryPoint = "DestroyIcon")]
static extern bool DestroyIcon(IntPtr h_icon); static extern bool DestroyIcon(IntPtr h_icon);
public Drawing.Bitmap Icon { public Drawing.Bitmap Icon {
set { set {
NotifyIcon.Icon = GetIconFromBitmap(value); Notification.Icon = GetIconFromBitmap(value);
} }
} }
public string Text { public string Text {
get { get {
return (string) GetValue(TextProperty); return (string) GetValue(TextProperty);
} }
set { set {
var text = value; var text = value;
if(!string.IsNullOrEmpty(HeaderText)) if(!string.IsNullOrEmpty(HeaderText))
text = HeaderText + "\n" + text; text = HeaderText + "\n" + text;
SetValue(TextProperty, text); SetValue(TextProperty, text);
} }
} }
public ContextMenu ContextMenu { public ContextMenu ContextMenu {
get; get;
set; set;
} }
public string HeaderText { public string HeaderText {
get; get;
set; set;
} }
private Forms.NotifyIcon NotifyIcon { private Forms.NotifyIcon Notification {
get; get;
set; set;
} }
public readonly RoutedEvent MouseClickEvent = EventManager.RegisterRoutedEvent( public readonly RoutedEvent MouseClickEvent = EventManager.RegisterRoutedEvent(
"MouseClick", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(SparkleNotifyIcon)); "MouseClick", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(NotifyIcon));
public readonly RoutedEvent MouseDoubleClickEvent = EventManager.RegisterRoutedEvent( public readonly RoutedEvent MouseDoubleClickEvent = EventManager.RegisterRoutedEvent(
"MouseDoubleClick", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(SparkleNotifyIcon)); "MouseDoubleClick", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(NotifyIcon));
public readonly DependencyProperty TextProperty = DependencyProperty.Register( public readonly DependencyProperty TextProperty = DependencyProperty.Register(
"Text", typeof(string), typeof(SparkleNotifyIcon), new PropertyMetadata(OnTextChanged)); "Text", typeof(string), typeof(NotifyIcon), new PropertyMetadata(OnTextChanged));
public SparkleNotifyIcon() { public NotifyIcon() {
VisibilityProperty.OverrideMetadata(typeof(SparkleNotifyIcon), new PropertyMetadata(OnVisibilityChanged)); VisibilityProperty.OverrideMetadata(typeof(NotifyIcon), new PropertyMetadata(OnVisibilityChanged));
NotifyIcon = new Forms.NotifyIcon { Notification = new Forms.NotifyIcon {
Text = Text, Text = Text,
Visible = true, Visible = true,
ContextMenu = new Forms.ContextMenu() ContextMenu = new Forms.ContextMenu()
}; };
NotifyIcon.MouseDown += OnMouseDown; Notification.MouseDown += OnMouseDown;
NotifyIcon.MouseUp += OnMouseUp; Notification.MouseUp += OnMouseUp;
NotifyIcon.MouseClick += OnMouseClick; Notification.MouseClick += OnMouseClick;
NotifyIcon.MouseDoubleClick += OnMouseDoubleClick; Notification.MouseDoubleClick += OnMouseDoubleClick;
} }
public void ShowBalloonTip(string title, string subtext, string image_path) { public void ShowBalloonTip(string title, string subtext, string image_path) {
// TODO: // TODO:
// - Use the image pointed to by image_path // - Use the image pointed to by image_path
// - Find a way to use the prettier (Win7?) balloons // - Find a way to use the prettier (Win7?) balloons
NotifyIcon.ShowBalloonTip(5 * 1000, title, subtext, Forms.ToolTipIcon.Info); Notification.ShowBalloonTip(5 * 1000, title, subtext, Forms.ToolTipIcon.Info);
} }
public void Dispose() { public void Dispose() {
NotifyIcon.Dispose(); Notification.Dispose();
} }
void IAddChild.AddChild(object value) { void IAddChild.AddChild(object value) {
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
void IAddChild.AddText(string text) { void IAddChild.AddText(string text) {
if(text == null) if(text == null)
throw new ArgumentNullException(); throw new ArgumentNullException();
Text = text; Text = text;
} }
private static MouseButtonEventArgs CreateMouseButtonEventArgs(RoutedEvent handler, Forms.MouseButtons button) { private static MouseButtonEventArgs CreateMouseButtonEventArgs(RoutedEvent handler, Forms.MouseButtons button) {
MouseButton mouse_button; MouseButton mouse_button;
if(button == Forms.MouseButtons.Left) { if(button == Forms.MouseButtons.Left) {
mouse_button = MouseButton.Left; mouse_button = MouseButton.Left;
} else if(button == Forms.MouseButtons.Right) { } else if(button == Forms.MouseButtons.Right) {
mouse_button = MouseButton.Right; mouse_button = MouseButton.Right;
} else if(button == Forms.MouseButtons.Middle) { } else if(button == Forms.MouseButtons.Middle) {
mouse_button = MouseButton.Middle; mouse_button = MouseButton.Middle;
} else if(button == Forms.MouseButtons.XButton1) { } else if(button == Forms.MouseButtons.XButton1) {
mouse_button = MouseButton.XButton1; mouse_button = MouseButton.XButton1;
} else if(button == Forms.MouseButtons.XButton2) { } else if(button == Forms.MouseButtons.XButton2) {
mouse_button = MouseButton.XButton2; mouse_button = MouseButton.XButton2;
} else { } else {
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
return new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice, 0, mouse_button) { return new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice, 0, mouse_button) {
RoutedEvent = handler RoutedEvent = handler
}; };
} }
private void OnVisibilityChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) { private void OnVisibilityChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) {
SparkleNotifyIcon control = (SparkleNotifyIcon) target; NotifyIcon control = (NotifyIcon) target;
control.NotifyIcon.Visible = (control.Visibility == Visibility.Visible); control.Notification.Visible = (control.Visibility == Visibility.Visible);
} }
private void OnMouseDown(object sender, Forms.MouseEventArgs args) { private void OnMouseDown(object sender, Forms.MouseEventArgs args) {
RaiseEvent(CreateMouseButtonEventArgs(MouseDownEvent, args.Button)); RaiseEvent(CreateMouseButtonEventArgs(MouseDownEvent, args.Button));
} }
private void OnMouseClick(object sender, Forms.MouseEventArgs args) { private void OnMouseClick(object sender, Forms.MouseEventArgs args) {
RaiseEvent(CreateMouseButtonEventArgs(MouseClickEvent, args.Button)); RaiseEvent(CreateMouseButtonEventArgs(MouseClickEvent, args.Button));
} }
private void OnMouseDoubleClick(object sender, Forms.MouseEventArgs args) { private void OnMouseDoubleClick(object sender, Forms.MouseEventArgs args) {
RaiseEvent(CreateMouseButtonEventArgs(MouseDoubleClickEvent, args.Button)); RaiseEvent(CreateMouseButtonEventArgs(MouseDoubleClickEvent, args.Button));
} }
private void OnMouseUp(object sender, Forms.MouseEventArgs args) { private void OnMouseUp(object sender, Forms.MouseEventArgs args) {
if(args.Button == Forms.MouseButtons.Right) { if(args.Button == Forms.MouseButtons.Right) {
ContextMenu.IsOpen = true; ContextMenu.IsOpen = true;
ContextMenu.StaysOpen = false; ContextMenu.StaysOpen = false;
} }
RaiseEvent(CreateMouseButtonEventArgs(MouseUpEvent, args.Button)); RaiseEvent(CreateMouseButtonEventArgs(MouseUpEvent, args.Button));
} }
private static void OnTextChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) { private static void OnTextChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) {
SparkleNotifyIcon control = (SparkleNotifyIcon) target; NotifyIcon control = (NotifyIcon) target;
control.NotifyIcon.Text = control.Text; control.Notification.Text = control.Text;
} }
private static Drawing.Icon GetIconFromBitmap(Drawing.Bitmap bitmap) { private static Drawing.Icon GetIconFromBitmap(Drawing.Bitmap bitmap) {
IntPtr unmanaged_icon = bitmap.GetHicon(); IntPtr unmanaged_icon = bitmap.GetHicon();
Drawing.Icon icon = (Drawing.Icon) Drawing.Icon.FromHandle(unmanaged_icon).Clone(); Drawing.Icon icon = (Drawing.Icon) Drawing.Icon.FromHandle(unmanaged_icon).Clone();
DestroyIcon(unmanaged_icon); DestroyIcon(unmanaged_icon);
return icon; return icon;
} }
} }
} }

View file

@ -15,33 +15,27 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using Sparkles;
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Media;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Markup; using System.Windows.Markup;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shell; using System.Windows.Shell;
using Drawing = System.Drawing; using Drawing = System.Drawing;
using Imaging = System.Windows.Interop.Imaging; using Imaging = System.Windows.Interop.Imaging;
using WPF = System.Windows.Controls;
namespace SparkleShare { namespace SparkleShare {
public class SparkleSetup : SparkleSetupWindow { public class Setup : SetupWindow {
public SparkleSetupController Controller = new SparkleSetupController (); public SetupController Controller = new SetupController ();
public SparkleSetup () public Setup ()
{ {
Controller.ShowWindowEvent += delegate { Controller.ShowWindowEvent += delegate {
Dispatcher.BeginInvoke ((Action) delegate { Dispatcher.BeginInvoke ((Action) delegate {
@ -268,7 +262,7 @@ namespace SparkleShare {
header_style.Setters.Add (new Setter (GridViewColumnHeader.VisibilityProperty, Visibility.Collapsed)); header_style.Setters.Add (new Setter (GridViewColumnHeader.VisibilityProperty, Visibility.Collapsed));
grid_view.ColumnHeaderContainerStyle = header_style; grid_view.ColumnHeaderContainerStyle = header_style;
foreach (SparklePreset plugin in Controller.Presets) { foreach (Preset plugin in Controller.Presets) {
// FIXME: images are blurry // FIXME: images are blurry
BitmapFrame image = BitmapFrame.Create ( BitmapFrame image = BitmapFrame.Create (
new Uri (plugin.ImagePath) new Uri (plugin.ImagePath)
@ -814,167 +808,6 @@ namespace SparkleShare {
break; break;
} }
case PageType.Tutorial: {
switch (Controller.TutorialPageNumber) {
case 1: {
Header = "Whats happening next?";
Description = "SparkleShare creates a special folder on your computer " +
"that will keep track of your projects.";
WPF.Image slide_image = new WPF.Image () {
Width = 324,
Height = 200
};
slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-1");
Button skip_tutorial_button = new Button () {
Content = "Skip tutorial"
};
Button continue_button = new Button () {
Content = "Continue"
};
ContentCanvas.Children.Add (slide_image);
Canvas.SetLeft (slide_image, 228);
Canvas.SetTop (slide_image, 130);
Buttons.Add (skip_tutorial_button);
Buttons.Add (continue_button);
skip_tutorial_button.Click += delegate {
Controller.TutorialSkipped ();
};
continue_button.Click += delegate {
Controller.TutorialPageCompleted ();
};
break;
}
case 2: {
Header = "Sharing files with others";
Description = "All files added to your project folders are synced automatically with " +
"the host and your team members.";
Button continue_button = new Button () {
Content = "Continue"
};
WPF.Image slide_image = new WPF.Image () {
Width = 324,
Height = 200
};
slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-2");
ContentCanvas.Children.Add (slide_image);
Canvas.SetLeft (slide_image, 228);
Canvas.SetTop (slide_image, 130);
Buttons.Add (continue_button);
continue_button.Click += delegate {
Controller.TutorialPageCompleted ();
};
break;
}
case 3: {
Header = "The status icon helps you";
Description = "It shows the syncing progress, provides easy access to " +
"your projects, and lets you view recent changes.";
Button continue_button = new Button () {
Content = "Continue"
};
WPF.Image slide_image = new WPF.Image () {
Width = 324,
Height = 200
};
slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-3");
ContentCanvas.Children.Add (slide_image);
Canvas.SetLeft (slide_image, 228);
Canvas.SetTop (slide_image, 130);
Buttons.Add (continue_button);
continue_button.Click += delegate {
Controller.TutorialPageCompleted ();
};
break;
}
case 4: {
Header = "Heres your unique Client ID";
Description = "Youll need it whenever you want to link this computer to a host. " +
"You can also find it in the status icon menu.";
TextBox link_code_text_box = new TextBox () {
Text = SparkleShare.Controller.CurrentUser.PublicKey,
Width = 250,
MaxLines = 1,
TextWrapping = TextWrapping.NoWrap,
IsEnabled = false
};
Button copy_button = new Button () {
Content = "Copy",
Width = 60
};
Button finish_button = new Button () {
Content = "Finish"
};
CheckBox check_box = new CheckBox () {
Content = "Add SparkleShare to startup items",
IsChecked = true
};
ContentCanvas.Children.Add (link_code_text_box);
Canvas.SetLeft (link_code_text_box, 235);
Canvas.SetTop (link_code_text_box, 190);
ContentCanvas.Children.Add (copy_button);
Canvas.SetLeft (copy_button, 490);
Canvas.SetTop (copy_button, 190);
ContentCanvas.Children.Add (check_box);
Canvas.SetLeft (check_box, 185);
Canvas.SetBottom (check_box, 12);
Buttons.Add (finish_button);
check_box.Click += delegate { Controller.StartupItemChanged (check_box.IsChecked.Value); };
finish_button.Click += delegate { Controller.TutorialPageCompleted (); };
copy_button.Click += delegate { Controller.CopyToClipboardClicked(); };
break;
}
}
break;
}
} }
ShowAll (); ShowAll ();

View file

@ -1,193 +1,193 @@
// SparkleShare, a collaboration and sharing tool. // SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons (hylkebons@gmail.com) // Copyright (C) 2010 Hylke Bons (hylkebons@gmail.com)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see (http://www.gnu.org/licenses/). // along with this program. If not, see (http://www.gnu.org/licenses/).
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Forms.Integration; using System.Windows.Forms.Integration;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Shapes; using System.Windows.Shapes;
using System.Windows.Shell; using System.Windows.Shell;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Interop; using System.Windows.Interop;
namespace SparkleShare { namespace SparkleShare {
public class SparkleSetupWindow : Window { public class SetupWindow : Window {
public Canvas ContentCanvas = new Canvas (); public Canvas ContentCanvas = new Canvas ();
public List <Button> Buttons = new List <Button> (); public List <Button> Buttons = new List <Button> ();
public string Header; public string Header;
public string Description; public string Description;
private Image side_splash; private Image side_splash;
private Rectangle bar; private Rectangle bar;
private Rectangle line; private Rectangle line;
public SparkleSetupWindow () public SetupWindow ()
{ {
Title = "SparkleShare Setup"; Title = "SparkleShare Setup";
Width = 640; Width = 640;
Height = 440; Height = 440;
ResizeMode = ResizeMode.NoResize; ResizeMode = ResizeMode.NoResize;
Background = new SolidColorBrush (Colors.WhiteSmoke); Background = new SolidColorBrush (Colors.WhiteSmoke);
Icon = SparkleUIHelpers.GetImageSource ("sparkleshare-app", "ico"); Icon = UserInterfaceHelpers.GetImageSource ("sparkleshare-app", "ico");
TaskbarItemInfo = new TaskbarItemInfo () { TaskbarItemInfo = new TaskbarItemInfo () {
Description = "SparkleShare" Description = "SparkleShare"
}; };
WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowStartupLocation = WindowStartupLocation.CenterScreen;
Content = ContentCanvas; Content = ContentCanvas;
// Remove the close button // Remove the close button
Closing += Close; Closing += Close;
SourceInitialized += delegate { SourceInitialized += delegate {
const int gwl_style = -16; const int gwl_style = -16;
const int ws_sysmenu = 0x00080000; const int ws_sysmenu = 0x00080000;
WindowInteropHelper helper = new WindowInteropHelper (this); WindowInteropHelper helper = new WindowInteropHelper (this);
int style = GetWindowLong (helper.Handle, gwl_style); int style = GetWindowLong (helper.Handle, gwl_style);
SetWindowLong (helper.Handle, gwl_style, style & ~ws_sysmenu); SetWindowLong (helper.Handle, gwl_style, style & ~ws_sysmenu);
}; };
this.bar = new Rectangle () { this.bar = new Rectangle () {
Width = Width, Width = Width,
Height = 40, Height = 40,
Fill = new SolidColorBrush (Color.FromRgb (240, 240, 240)) Fill = new SolidColorBrush (Color.FromRgb (240, 240, 240))
}; };
this.line = new Rectangle () { this.line = new Rectangle () {
Width = Width, Width = Width,
Height = 1, Height = 1,
Fill = new SolidColorBrush (Color.FromRgb (223, 223, 223)) Fill = new SolidColorBrush (Color.FromRgb (223, 223, 223))
}; };
this.side_splash = new Image () { this.side_splash = new Image () {
Width = 150, Width = 150,
Height = 482 Height = 482
}; };
this.side_splash.Source = SparkleUIHelpers.GetImageSource ("side-splash"); this.side_splash.Source = UserInterfaceHelpers.GetImageSource ("side-splash");
ContentCanvas.Children.Add (this.bar); ContentCanvas.Children.Add (this.bar);
Canvas.SetRight (bar, 0); Canvas.SetRight (bar, 0);
Canvas.SetBottom (bar, 0); Canvas.SetBottom (bar, 0);
ContentCanvas.Children.Add (this.line); ContentCanvas.Children.Add (this.line);
Canvas.SetRight (this.line, 0); Canvas.SetRight (this.line, 0);
Canvas.SetBottom (this.line, 40); Canvas.SetBottom (this.line, 40);
ContentCanvas.Children.Add (this.side_splash); ContentCanvas.Children.Add (this.side_splash);
Canvas.SetLeft (this.side_splash, 0); Canvas.SetLeft (this.side_splash, 0);
Canvas.SetBottom (this.side_splash, 0); Canvas.SetBottom (this.side_splash, 0);
} }
public void Reset () public void Reset ()
{ {
ContentCanvas.Children.Remove (this.bar); ContentCanvas.Children.Remove (this.bar);
ContentCanvas.Children.Remove (this.line); ContentCanvas.Children.Remove (this.line);
ContentCanvas.Children.Remove (this.side_splash); ContentCanvas.Children.Remove (this.side_splash);
ContentCanvas = new Canvas (); ContentCanvas = new Canvas ();
Content = ContentCanvas; Content = ContentCanvas;
ContentCanvas.Children.Add (this.bar); ContentCanvas.Children.Add (this.bar);
ContentCanvas.Children.Add (this.line); ContentCanvas.Children.Add (this.line);
ContentCanvas.Children.Add (this.side_splash); ContentCanvas.Children.Add (this.side_splash);
Buttons = new List <Button> (); Buttons = new List <Button> ();
Header = ""; Header = "";
Description = ""; Description = "";
} }
public void ShowAll () public void ShowAll ()
{ {
Label header_label = new Label () { Label header_label = new Label () {
Content = Header, Content = Header,
Foreground = new SolidColorBrush (Color.FromRgb (0, 51, 153)), Foreground = new SolidColorBrush (Color.FromRgb (0, 51, 153)),
FontSize = 16 FontSize = 16
}; };
TextBlock description_label = new TextBlock () { TextBlock description_label = new TextBlock () {
Text = Description, Text = Description,
TextWrapping = TextWrapping.Wrap, TextWrapping = TextWrapping.Wrap,
Width = 375 Width = 375
}; };
ContentCanvas.Children.Add (header_label); ContentCanvas.Children.Add (header_label);
Canvas.SetLeft (header_label, 180); Canvas.SetLeft (header_label, 180);
Canvas.SetTop (header_label, 18); Canvas.SetTop (header_label, 18);
ContentCanvas.Children.Add (description_label); ContentCanvas.Children.Add (description_label);
Canvas.SetLeft (description_label, 185); Canvas.SetLeft (description_label, 185);
Canvas.SetTop (description_label, 60); Canvas.SetTop (description_label, 60);
if (Buttons.Count > 0) { if (Buttons.Count > 0) {
Buttons [0].IsDefault = true; Buttons [0].IsDefault = true;
Buttons.Reverse (); Buttons.Reverse ();
int right = 9; int right = 9;
foreach (Button button in Buttons) { foreach (Button button in Buttons) {
button.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity)); button.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
Rect rect = new Rect (button.DesiredSize); Rect rect = new Rect (button.DesiredSize);
button.Width = rect.Width + 26; button.Width = rect.Width + 26;
if (button.Width < 75) if (button.Width < 75)
button.Width = 75; button.Width = 75;
ContentCanvas.Children.Add (button); ContentCanvas.Children.Add (button);
Canvas.SetRight (button, right); Canvas.SetRight (button, right);
Canvas.SetBottom (button, 9); Canvas.SetBottom (button, 9);
right += (int) button.Width + 9; right += (int) button.Width + 9;
if ((button.Content as string).Equals ("Continue")) { if ((button.Content as string).Equals ("Continue")) {
Buttons [Buttons.Count - 1].IsDefault = false; Buttons [Buttons.Count - 1].IsDefault = false;
button.IsDefault = true; button.IsDefault = true;
} }
} }
} }
ElementHost.EnableModelessKeyboardInterop (this); ElementHost.EnableModelessKeyboardInterop (this);
} }
private void Close (object sender, CancelEventArgs args) private void Close (object sender, CancelEventArgs args)
{ {
args.Cancel = true; args.Cancel = true;
} }
[DllImport("user32.dll")] [DllImport("user32.dll")]
private extern static int SetWindowLong (IntPtr hwnd, int index, int value); private extern static int SetWindowLong (IntPtr hwnd, int index, int value);
[DllImport("user32.dll")] [DllImport("user32.dll")]
private extern static int GetWindowLong (IntPtr hwnd, int index); private extern static int GetWindowLong (IntPtr hwnd, int index);
} }
} }

View file

@ -16,11 +16,8 @@
using System; using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Windows.Forms;
namespace SparkleShare { namespace SparkleShare {

View file

@ -1,91 +1,91 @@
// SparkleShare, a collaboration and sharing tool. // SparkleShare, a collaboration and sharing tool.
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com> // Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using System; using System;
using System.Timers; using System.Timers;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.ComponentModel; using System.ComponentModel;
namespace SparkleShare { namespace SparkleShare {
public class SparkleSpinner : Image { public class Spinner : Image {
private Timer timer; private Timer timer;
public SparkleSpinner () public Spinner ()
: this (22) { : this (22) {
} }
public SparkleSpinner (int size) : base () { public Spinner (int size) : base () {
if (DesignerProperties.GetIsInDesignMode(this)) { if (DesignerProperties.GetIsInDesignMode(this)) {
return; return;
} }
Width = size; Width = size;
Height = size; Height = size;
int current_frame = 0; int current_frame = 0;
BitmapSource spinner_gallery = SparkleUIHelpers.GetImageSource ("process-working-22"); BitmapSource spinner_gallery = UserInterfaceHelpers.GetImageSource ("process-working-22");
int frames_in_width = spinner_gallery.PixelWidth / size; int frames_in_width = spinner_gallery.PixelWidth / size;
int frames_in_height = spinner_gallery.PixelHeight / size; int frames_in_height = spinner_gallery.PixelHeight / size;
int frame_count = (frames_in_width * frames_in_height) - 1; int frame_count = (frames_in_width * frames_in_height) - 1;
Image [] frames = new Image [frame_count]; Image [] frames = new Image [frame_count];
int i = 0; int i = 0;
for (int y = 0; y < frames_in_height; y++) { for (int y = 0; y < frames_in_height; y++) {
for (int x = 0; x < frames_in_width; x++) { for (int x = 0; x < frames_in_width; x++) {
if (!(y == 0 && x == 0)) { if (!(y == 0 && x == 0)) {
CroppedBitmap crop = new CroppedBitmap (spinner_gallery, CroppedBitmap crop = new CroppedBitmap (spinner_gallery,
new Int32Rect (size * x, size * y, size, size)); new Int32Rect (size * x, size * y, size, size));
frames [i] = new Image (); frames [i] = new Image ();
frames [i].Source = crop; frames [i].Source = crop;
i++; i++;
} }
} }
} }
this.timer = new Timer () { this.timer = new Timer () {
Interval = 400 / frame_count Interval = 400 / frame_count
}; };
this.timer.Elapsed += delegate { this.timer.Elapsed += delegate {
Dispatcher.BeginInvoke ((Action) delegate { Dispatcher.BeginInvoke ((Action) delegate {
if (current_frame < frame_count - 1) if (current_frame < frame_count - 1)
current_frame++; current_frame++;
else else
current_frame = 0; current_frame = 0;
Source = frames [current_frame].Source; Source = frames [current_frame].Source;
}); });
}; };
} }
public void Start () public void Start ()
{ {
this.timer.Start (); this.timer.Start ();
} }
public void Stop () public void Stop ()
{ {
this.timer.Stop (); this.timer.Stop ();
} }
} }
} }

View file

@ -26,15 +26,15 @@ using Drawing = System.Drawing;
namespace SparkleShare { namespace SparkleShare {
public class SparkleStatusIcon : Control { public class StatusIcon : Control {
public SparkleStatusIconController Controller = new SparkleStatusIconController(); public StatusIconController Controller = new StatusIconController();
private readonly Drawing.Bitmap syncing_idle_image = SparkleUIHelpers.GetBitmap("process-syncing-idle"); private readonly Drawing.Bitmap syncing_idle_image = UserInterfaceHelpers.GetBitmap("process-syncing-idle");
private readonly Drawing.Bitmap syncing_up_image = SparkleUIHelpers.GetBitmap("process-syncing-up"); private readonly Drawing.Bitmap syncing_up_image = UserInterfaceHelpers.GetBitmap("process-syncing-up");
private readonly Drawing.Bitmap syncing_down_image = SparkleUIHelpers.GetBitmap("process-syncing-down"); private readonly Drawing.Bitmap syncing_down_image = UserInterfaceHelpers.GetBitmap("process-syncing-down");
private readonly Drawing.Bitmap syncing_image = SparkleUIHelpers.GetBitmap("process-syncing"); private readonly Drawing.Bitmap syncing_image = UserInterfaceHelpers.GetBitmap("process-syncing");
private readonly Drawing.Bitmap syncing_error_image = SparkleUIHelpers.GetBitmap("process-syncing-error"); private readonly Drawing.Bitmap syncing_error_image = UserInterfaceHelpers.GetBitmap("process-syncing-error");
private ContextMenu context_menu; private ContextMenu context_menu;
@ -43,10 +43,10 @@ namespace SparkleShare {
private SparkleMenuItem exit_item; private SparkleMenuItem exit_item;
private SparkleMenuItem[] state_menu_items; private SparkleMenuItem[] state_menu_items;
private readonly SparkleNotifyIcon notify_icon = new SparkleNotifyIcon(); private readonly NotifyIcon notify_icon = new NotifyIcon();
public SparkleStatusIcon() { public StatusIcon() {
this.notify_icon.HeaderText = "SparkleShare"; this.notify_icon.HeaderText = "SparkleShare";
this.notify_icon.Icon = this.syncing_idle_image; this.notify_icon.Icon = this.syncing_idle_image;
@ -117,7 +117,7 @@ namespace SparkleShare {
}; };
Image folder_image = new Image { Image folder_image = new Image {
Source = SparkleUIHelpers.GetImageSource("sparkleshare-folder"), Source = UserInterfaceHelpers.GetImageSource("sparkleshare-folder"),
Width = 16, Width = 16,
Height = 16 Height = 16
}; };
@ -142,7 +142,7 @@ namespace SparkleShare {
if(Controller.LinkCodeItemEnabled) { if(Controller.LinkCodeItemEnabled) {
SparkleMenuItem code_item = new SparkleMenuItem { SparkleMenuItem code_item = new SparkleMenuItem {
Header = SparkleShare.Controller.CurrentUser.PublicKey.Substring(0, 20) + "..." Header = SparkleShare.Controller.UserAuthenticationInfo.PublicKey.Substring(0, 20) + "..."
}; };
SparkleMenuItem copy_item = new SparkleMenuItem { SparkleMenuItem copy_item = new SparkleMenuItem {
@ -215,7 +215,7 @@ namespace SparkleShare {
SparkleMenuItem subfolder_item = new SparkleMenuItem { SparkleMenuItem subfolder_item = new SparkleMenuItem {
Header = project.Name.Replace("_", "__"), Header = project.Name.Replace("_", "__"),
Icon = new Image { Icon = new Image {
Source = SparkleUIHelpers.GetImageSource("folder"), Source = UserInterfaceHelpers.GetImageSource("folder"),
Width = 16, Width = 16,
Height = 16 Height = 16
} }
@ -233,7 +233,7 @@ namespace SparkleShare {
Header = "Open folder", Header = "Open folder",
Icon = new Image Icon = new Image
{ {
Source = SparkleUIHelpers.GetImageSource("folder"), Source = UserInterfaceHelpers.GetImageSource("folder"),
Width = 16, Width = 16,
Height = 16 Height = 16
} }

View file

@ -23,39 +23,39 @@ using Sparkles;
namespace SparkleShare { namespace SparkleShare {
public class SparkleUI { public class UserInterface {
public SparkleSetup Setup; public Setup Setup;
public SparkleEventLogWindow EventLog; public EventLog EventLog;
public SparkleBubbles Bubbles; public Bubbles Bubbles;
public SparkleStatusIcon StatusIcon; public StatusIcon StatusIcon;
public SparkleAbout About; public About About;
public SparkleNote Note; public Note Note;
static SparkleUI () static UserInterface ()
{ {
Application.ThreadException += OnUnhandledException; Application.ThreadException += OnUnhandledException;
Application.SetUnhandledExceptionMode (UnhandledExceptionMode.CatchException); Application.SetUnhandledExceptionMode (UnhandledExceptionMode.CatchException);
} }
public SparkleUI () public UserInterface ()
{ {
// FIXME: The second time windows are shown, the windows // FIXME: The second time windows are shown, the windows
// don't have the smooth ease in animation, but appear abruptly. // don't have the smooth ease in animation, but appear abruptly.
// The ease out animation always seems to work // The ease out animation always seems to work
Setup = new SparkleSetup (); Setup = new Setup ();
EventLog = new SparkleEventLogWindow(); EventLog = new EventLog();
About = new SparkleAbout (); About = new About ();
Bubbles = new SparkleBubbles (); Bubbles = new Bubbles ();
StatusIcon = new SparkleStatusIcon (); StatusIcon = new StatusIcon ();
Note = new SparkleNote (); Note = new Note ();
SparkleShare.Controller.UIHasLoaded (); SparkleShare.Controller.UIHasLoaded ();
} }
public void Run () public void Run (string [] args)
{ {
Application.Run (); Application.Run ();
StatusIcon.Dispose (); StatusIcon.Dispose ();
@ -64,7 +64,7 @@ namespace SparkleShare {
private static void OnUnhandledException (object sender, ThreadExceptionEventArgs exception_args) private static void OnUnhandledException (object sender, ThreadExceptionEventArgs exception_args)
{ {
try { try {
SparkleLogger.WriteCrashReport (exception_args.Exception); Logger.WriteCrashReport (exception_args.Exception);
} finally { } finally {
Environment.Exit (-1); Environment.Exit (-1);
} }

View file

@ -18,8 +18,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
@ -27,7 +25,7 @@ using Drawing = System.Drawing;
namespace SparkleShare { namespace SparkleShare {
public static class SparkleUIHelpers { public static class UserInterfaceHelpers {
public static string ToHex (this Drawing.Color color) public static string ToHex (this Drawing.Color color)
{ {
@ -44,7 +42,7 @@ namespace SparkleShare {
public static BitmapFrame GetImageSource (string name, string type) public static BitmapFrame GetImageSource (string name, string type)
{ {
Assembly assembly = Assembly.GetExecutingAssembly(); Assembly assembly = Assembly.GetExecutingAssembly();
Stream image_stream = assembly.GetManifestResourceStream("SparkleShare.Images." + name + "." + type); Stream image_stream = assembly.GetManifestResourceStream("SparkleShare.Windows.Images." + name + "." + type);
return BitmapFrame.Create(image_stream); return BitmapFrame.Create(image_stream);
} }
@ -62,7 +60,7 @@ namespace SparkleShare {
public static Drawing.Bitmap GetBitmap (string name) public static Drawing.Bitmap GetBitmap (string name)
{ {
Assembly assembly = Assembly.GetExecutingAssembly (); Assembly assembly = Assembly.GetExecutingAssembly ();
Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Images." + name + ".png"); Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Windows.Images." + name + ".png");
return (Drawing.Bitmap) Drawing.Bitmap.FromStream (image_stream); return (Drawing.Bitmap) Drawing.Bitmap.FromStream (image_stream);
} }
@ -71,7 +69,7 @@ namespace SparkleShare {
{ {
Assembly assembly = Assembly.GetExecutingAssembly (); Assembly assembly = Assembly.GetExecutingAssembly ();
StreamReader html_reader = new StreamReader ( StreamReader html_reader = new StreamReader (
assembly.GetManifestResourceStream ("SparkleShare.HTML." + name)); assembly.GetManifestResourceStream ("SparkleShare.Windows.HTML." + name));
return html_reader.ReadToEnd (); return html_reader.ReadToEnd ();
} }

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

View file

@ -21,7 +21,6 @@ namespace Sparkles.Git {
public class GitCommand : Command { public class GitCommand : Command {
public static string SSHPath = "ssh";
public static string ExecPath; public static string ExecPath;
@ -82,10 +81,10 @@ namespace Sparkles.Git {
{ {
StartInfo.WorkingDirectory = working_dir; StartInfo.WorkingDirectory = working_dir;
string GIT_SSH_COMMAND = SSHPath; string GIT_SSH_COMMAND = SSHCommand.SSHCommandPath;
if (auth_info != null) if (auth_info != null)
GIT_SSH_COMMAND = FormatGitSSHCommand (auth_info); GIT_SSH_COMMAND = SSHCommand.FormatGitSSHCommand (auth_info);
if (ExecPath != null) if (ExecPath != null)
SetEnvironmentVariable ("GIT_EXEC_PATH", ExecPath); SetEnvironmentVariable ("GIT_EXEC_PATH", ExecPath);
@ -209,16 +208,5 @@ namespace Sparkles.Git {
return error; return error;
} }
public static string FormatGitSSHCommand (SSHAuthenticationInfo auth_info)
{
return SSHPath + " " +
"-i " + auth_info.PrivateKeyFilePath.Replace (" ", "\\ ") + " " +
"-o UserKnownHostsFile=" + auth_info.KnownHostsFilePath.Replace (" ", "\\ ") + " " +
"-o IdentitiesOnly=yes" + " " + // Don't fall back to other keys on the system
"-o PasswordAuthentication=no" + " " + // Don't hang on possible password prompts
"-F /dev/null"; // Ignore the system's SSH config file
}
} }
} }

View file

@ -16,9 +16,7 @@
using System; using System;
using System.Globalization;
using System.IO; using System.IO;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
namespace Sparkles.Git { namespace Sparkles.Git {
@ -418,15 +416,15 @@ namespace Sparkles.Git {
{ {
var git_config_required = new GitCommand (TargetFolder, "config filter.lfs.required true"); var git_config_required = new GitCommand (TargetFolder, "config filter.lfs.required true");
string GIT_SSH_COMMAND = GitCommand.FormatGitSSHCommand (auth_info); string GIT_SSH_COMMAND = SSHCommand.FormatGitSSHCommand (auth_info);
string smudge_command; string smudge_command;
string clean_command; string clean_command;
if (InstallationInfo.OperatingSystem == OS.Mac) { if (InstallationInfo.OperatingSystem == OS.Mac || InstallationInfo.OperatingSystem == OS.Windows) {
smudge_command = "env GIT_SSH_COMMAND='" + GIT_SSH_COMMAND + "' " + smudge_command = "env GIT_SSH_COMMAND='" + GIT_SSH_COMMAND + "' " +
Path.Combine (Configuration.DefaultConfiguration.BinPath, "git-lfs") + " smudge %f"; Path.Combine (Configuration.DefaultConfiguration.BinPath, "git-lfs").Replace ("\\", "/") + " smudge %f";
clean_command = Path.Combine (Configuration.DefaultConfiguration.BinPath, "git-lfs") + " clean %f"; clean_command = Path.Combine (Configuration.DefaultConfiguration.BinPath, "git-lfs").Replace ("\\", "/") + " clean %f";
} else { } else {
smudge_command = "env GIT_SSH_COMMAND='" + GIT_SSH_COMMAND + "' git-lfs smudge %f"; smudge_command = "env GIT_SSH_COMMAND='" + GIT_SSH_COMMAND + "' git-lfs smudge %f";

View file

@ -78,6 +78,9 @@ namespace Sparkles.Git {
git_config = new GitCommand (LocalPath, "config remote.origin.url \"" + RemoteUrl + "\""); git_config = new GitCommand (LocalPath, "config remote.origin.url \"" + RemoteUrl + "\"");
git_config.StartAndWaitForExit (); git_config.StartAndWaitForExit ();
git_config = new GitCommand (LocalPath, "config core.sshCommand " + SSHCommand.FormatGitSSHCommand (auth_info));
git_config.StartAndWaitForExit();
} }
@ -204,16 +207,16 @@ namespace Sparkles.Git {
string pre_push_hook_content; string pre_push_hook_content;
// The pre-push hook may have been changed by Git LFS, overwrite it to use our own configuration // The pre-push hook may have been changed by Git LFS, overwrite it to use our own configuration
if (InstallationInfo.OperatingSystem == OS.Mac) { if (InstallationInfo.OperatingSystem == OS.Mac || InstallationInfo.OperatingSystem == OS.Windows) {
pre_push_hook_content = pre_push_hook_content =
"#!/bin/sh" + Environment.NewLine + "#!/bin/sh" + Environment.NewLine +
"env GIT_SSH_COMMAND='" + GitCommand.FormatGitSSHCommand (auth_info) + "' " + "env GIT_SSH_COMMAND='" + SSHCommand.FormatGitSSHCommand (auth_info) + "' " +
Path.Combine (Configuration.DefaultConfiguration.BinPath, "git-lfs") + " pre-push \"$@\""; Path.Combine (Configuration.DefaultConfiguration.BinPath, "git-lfs").Replace ("\\", "/") + " pre-push \"$@\"";
} else { } else {
pre_push_hook_content = pre_push_hook_content =
"#!/bin/sh" + Environment.NewLine + "#!/bin/sh" + Environment.NewLine +
"env GIT_SSH_COMMAND='" + GitCommand.FormatGitSSHCommand (auth_info) + "' " + "env GIT_SSH_COMMAND='" + SSHCommand.FormatGitSSHCommand (auth_info) + "' " +
"git-lfs pre-push \"$@\""; "git-lfs pre-push \"$@\"";
} }

View file

@ -101,7 +101,7 @@ namespace Sparkles {
"-C \"" + computer_name + " (SparkleShare)\" " + // Key comment "-C \"" + computer_name + " (SparkleShare)\" " + // Key comment
"-f \"" + key_file_name + "\""; "-f \"" + key_file_name + "\"";
var ssh_keygen = new Command ("ssh-keygen", arguments); var ssh_keygen = new SSHCommand ("ssh-keygen", arguments);
ssh_keygen.StartInfo.WorkingDirectory = Path; ssh_keygen.StartInfo.WorkingDirectory = Path;
ssh_keygen.StartAndWaitForExit (); ssh_keygen.StartAndWaitForExit ();

35
Sparkles/SSHCommand.cs Normal file
View file

@ -0,0 +1,35 @@
using System.IO;
namespace Sparkles {
public class SSHCommand : Command
{
public static string SSHPath = "";
public static string SSHCommandPath {
get {
return Path.Combine(SSHPath, "ssh").Replace("\\", "/");
}
}
public SSHCommand(string command, string args) : this (command, args, null) {
}
public SSHCommand(string command, string args, SSHAuthenticationInfo auth_info) : base (Path.Combine(SSHPath, command), args) {
string GIT_SSH_COMMAND = SSHPath;
if (auth_info != null)
GIT_SSH_COMMAND = FormatGitSSHCommand(auth_info);
SetEnvironmentVariable("GIT_SSH_COMMAND", GIT_SSH_COMMAND);
}
public static string FormatGitSSHCommand(SSHAuthenticationInfo auth_info)
{
return SSHCommandPath + " " +
"-i " + auth_info.PrivateKeyFilePath.Replace("\\" , "/").Replace(" ", "\\ ") + " " +
"-o UserKnownHostsFile=" + auth_info.KnownHostsFilePath.Replace("\\", "/").Replace(" ", "\\ ") + " " +
"-o IdentitiesOnly=yes" + " " + // Don't fall back to other keys on the system
"-o PasswordAuthentication=no" + " " + // Don't hang on possible password prompts
"-F /dev/null"; // Ignore the system's SSH config file
}
}
}

View file

@ -23,6 +23,8 @@ namespace Sparkles {
public abstract class SSHFetcher : BaseFetcher { public abstract class SSHFetcher : BaseFetcher {
public static string SSHKeyScan = "ssh-keyscan";
protected SSHFetcher (SparkleFetcherInfo info) : base (info) protected SSHFetcher (SparkleFetcherInfo info) : base (info)
{ {
} }
@ -90,7 +92,7 @@ namespace Sparkles {
string FetchHostKey () string FetchHostKey ()
{ {
Logger.LogInfo ("Auth", string.Format ("Fetching host key for {0}", RemoteUrl.Host)); Logger.LogInfo ("Auth", string.Format ("Fetching host key for {0}", RemoteUrl.Host));
var ssh_keyscan = new Command ("ssh-keyscan", string.Format ("-t rsa -p 22 {0}", RemoteUrl.Host)); var ssh_keyscan = new Command (SSHKeyScan, string.Format ("-t rsa -p 22 {0}", RemoteUrl.Host));
if (RemoteUrl.Port > 0) if (RemoteUrl.Port > 0)
ssh_keyscan.StartInfo.Arguments = string.Format ("-t rsa -p {0} {1}", RemoteUrl.Port, RemoteUrl.Host); ssh_keyscan.StartInfo.Arguments = string.Format ("-t rsa -p {0} {1}", RemoteUrl.Port, RemoteUrl.Host);

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -48,53 +48,27 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AuthenticationInfo.cs" />
<Compile Include="BaseFetcher.cs" />
<Compile Include="BaseListener.cs" />
<Compile Include="BaseRepository.cs" />
<Compile Include="ChangeSet.cs" />
<Compile Include="Configuration.cs" /> <Compile Include="Configuration.cs" />
<Compile Include="Extensions.cs" /> <Compile Include="Extensions.cs" />
<Compile Include="ListenerFactory.cs" />
<Compile Include="Logger.cs" /> <Compile Include="Logger.cs" />
<Compile Include="InstallationInfo.Directory.cs" /> <Compile Include="InstallationInfo.Directory.cs" />
<Compile Include="Command.cs" /> <Compile Include="Command.cs" />
<Compile Include="SSHFetcher.cs"> <Compile Include="SSHCommand.cs" />
<Link>Fetcher\SSHFetcher.cs</Link> <Compile Include="SSHFetcher.cs" />
</Compile> <Compile Include="SSHAuthenticationInfo.cs" />
<Compile Include="BaseFetcher.cs"> <Compile Include="TcpListener.cs" />
<Link>Fetcher\BaseFetcher.cs</Link> <Compile Include="User.cs" />
</Compile>
<Compile Include="TcpListener.cs">
<Link>Listener\TcpListener.cs</Link>
</Compile>
<Compile Include="BaseListener.cs">
<Link>Listener\BaseListener.cs</Link>
</Compile>
<Compile Include="ListenerFactory.cs">
<Link>Listener\ListenerFactory.cs</Link>
</Compile>
<Compile Include="SSHAuthenticationInfo.cs">
<Link>AuthenticationInfo\SSHAuthenticationInfo.cs</Link>
</Compile>
<Compile Include="AuthenticationInfo.cs">
<Link>AuthenticationInfo\AuthenticationInfo.cs</Link>
</Compile>
<Compile Include="BaseRepository.cs">
<Link>Repository\BaseRepository.cs</Link>
</Compile>
<Compile Include="ChangeSet.cs">
<Link>Repository\ChangeSet.cs</Link>
</Compile>
<Compile Include="User.cs">
<Link>Repository\User.cs</Link>
</Compile>
<Compile Include="Watcher.cs">
<Link>Repository\Watcher.cs</Link>
</Compile>
<Compile Include="InstallationInfo.cs" /> <Compile Include="InstallationInfo.cs" />
<Compile Include="Preset.cs" /> <Compile Include="Preset.cs" />
<Compile Include="Invite.cs" /> <Compile Include="Invite.cs" />
<Compile Include="Watcher.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="Fetcher\" />
<Folder Include="Listener\" />
<Folder Include="AuthenticationInfo\" />
<Folder Include="Repository\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> </Project>