Add FriendFace library
This commit is contained in:
parent
ba4889351a
commit
32f1e03e25
104
FriendFace/FriendFace.cs
Normal file
104
FriendFace/FriendFace.cs
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
// FriendFace creates an icon theme of buddy icons from the web
|
||||||
|
// Copyright (C) 2010 Hylke Bons
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FriendFace
|
||||||
|
{
|
||||||
|
|
||||||
|
public class FaceCollection : IconTheme
|
||||||
|
{
|
||||||
|
|
||||||
|
private string Path;
|
||||||
|
|
||||||
|
public bool UseTwitter;
|
||||||
|
public bool UseGravatar;
|
||||||
|
public bool UseIdentica;
|
||||||
|
public bool UseSystem;
|
||||||
|
public bool UseFlickr;
|
||||||
|
|
||||||
|
public bool UseAllServices;
|
||||||
|
|
||||||
|
private string IconThemePath;
|
||||||
|
|
||||||
|
public FaceCollection ()
|
||||||
|
{
|
||||||
|
|
||||||
|
Path = "";
|
||||||
|
|
||||||
|
UseTwitter = false;
|
||||||
|
UseGravatar = false;
|
||||||
|
UseIdentica = false;
|
||||||
|
UseSystem = false;
|
||||||
|
UseFlickr = false;
|
||||||
|
UseAllServices = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public FaceCollection (string path)
|
||||||
|
{
|
||||||
|
|
||||||
|
UnixUserInfo unix_user_info = new UnixUserInfo (UnixEnvironment.UserName);
|
||||||
|
string home_path = unix_user_info.HomeDirectory;
|
||||||
|
|
||||||
|
string IconThemePath = CombineMore (home_path, ".icons");
|
||||||
|
SetThemePath (IconThemePath);
|
||||||
|
|
||||||
|
if (!Directory.Exists (theme_path))
|
||||||
|
Directory.CreateDirectory (theme_path);
|
||||||
|
|
||||||
|
Directory.CreateDirectory (CombineMore (ThemePath));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetThemePath (string path)
|
||||||
|
{
|
||||||
|
string IconThemePath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetThemePath ()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Gdk.Pixbuf GetFace (string identifier)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AddFace (string identifier)
|
||||||
|
{
|
||||||
|
// avatar-twitter-hbons
|
||||||
|
// 16, 24, 32, 48
|
||||||
|
Gdk.Pixbuf gravatar_icon;
|
||||||
|
if (UseGravatar)
|
||||||
|
gravatar_icon = new GravatarIcon (identifier);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Refresh ()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
1
FriendFace/FriendFace.csproj
Normal file
1
FriendFace/FriendFace.csproj
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3BA434AF-494F-4F5D-9D21-B7BD24FD67AF}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>FriendFace</RootNamespace>
<AssemblyName>FriendFace</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</ItemGroup>
<ItemGroup>
<Compile Include="FriendFace.cs" />
<Compile Include="Gravatar.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="3.5" xmlns="" />
</MonoDevelop>
</ProjectExtensions>
</Project>
|
79
FriendFace/Gravatar.cs
Normal file
79
FriendFace/Gravatar.cs
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
// FriendFace creates an icon theme of buddy icons from the web
|
||||||
|
// Copyright (C) 2010 Hylke Bons
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library 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
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.using Gtk;
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FriendFace {
|
||||||
|
|
||||||
|
public class Gravatar : Gdk.Pixbuf {
|
||||||
|
|
||||||
|
public Gravatar (string identifier)
|
||||||
|
{
|
||||||
|
|
||||||
|
UnixUserInfo unix_user_info = new UnixUserInfo (UnixEnvironment.UserName);
|
||||||
|
string home_path = unix_user_info.HomeDirectory;
|
||||||
|
|
||||||
|
string theme_path = CombineMore (home_path, ".icons", "friendface", "48x48", "status");
|
||||||
|
string file_name = "avatar-gravatar-" + identifier;
|
||||||
|
string file_path = CombineMore (theme_path, file_name);
|
||||||
|
|
||||||
|
if (!Directory.Exists (theme_path))
|
||||||
|
Directory.CreateDirectory (theme_path);
|
||||||
|
|
||||||
|
WebClient WebClient = new WebClient ();
|
||||||
|
Uri icon_uri = new Uri ("http://www.gravatar.com/avatar/" + MD5 (identifier) + ".jpg?s=48&d=404");
|
||||||
|
|
||||||
|
if (File.Exists (file_path))
|
||||||
|
File.Delete (file_path);
|
||||||
|
|
||||||
|
WebClient.DownloadFileAsync (icon_uri, file_path);
|
||||||
|
|
||||||
|
WebClient.DownloadFileCompleted += delegate {
|
||||||
|
|
||||||
|
FileInfo file_info = new FileInfo (file_path);
|
||||||
|
|
||||||
|
if (file_info.Length < 256)
|
||||||
|
File.Delete (file_path);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Creates an MD5 hash of input
|
||||||
|
public static string MD5 (string s)
|
||||||
|
{
|
||||||
|
MD5 md5 = new MD5CryptoServiceProvider ();
|
||||||
|
Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);
|
||||||
|
Byte[] encoded_bytes = md5.ComputeHash (bytes);
|
||||||
|
return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Makes it possible to combine more than
|
||||||
|
// two paths at once
|
||||||
|
public static string CombineMore (params string [] parts)
|
||||||
|
{
|
||||||
|
string new_path = "";
|
||||||
|
foreach (string part in parts)
|
||||||
|
new_path = Path.Combine (new_path, part);
|
||||||
|
return new_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
|
@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotifySharp", "NotifySharp\
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSSH", "SharpSSH\SharpSSH.csproj", "{BB50B7E2-4622-4D8B-B7FF-5E5D8F02D91F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSSH", "SharpSSH\SharpSSH.csproj", "{BB50B7E2-4622-4D8B-B7FF-5E5D8F02D91F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FriendFace", "FriendFace\FriendFace.csproj", "{3BA434AF-494F-4F5D-9D21-B7BD24FD67AF}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -17,6 +19,10 @@ Global
|
||||||
{005CCA8E-DFBF-464A-B6DA-452C62D4589C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{005CCA8E-DFBF-464A-B6DA-452C62D4589C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{005CCA8E-DFBF-464A-B6DA-452C62D4589C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{005CCA8E-DFBF-464A-B6DA-452C62D4589C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{005CCA8E-DFBF-464A-B6DA-452C62D4589C}.Release|Any CPU.Build.0 = Release|Any CPU
|
{005CCA8E-DFBF-464A-B6DA-452C62D4589C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3BA434AF-494F-4F5D-9D21-B7BD24FD67AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3BA434AF-494F-4F5D-9D21-B7BD24FD67AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3BA434AF-494F-4F5D-9D21-B7BD24FD67AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3BA434AF-494F-4F5D-9D21-B7BD24FD67AF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{728483AA-E34B-4441-BF2C-C8BC2901E4E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
|
|
@ -23,11 +23,11 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleIntro : Window
|
public class SparkleIntro : Window {
|
||||||
{
|
|
||||||
|
|
||||||
// Short alias for the translations
|
// Short alias for the translations
|
||||||
public static string _ (string s)
|
public static string _ (string s)
|
||||||
|
@ -38,6 +38,12 @@ namespace SparkleShare {
|
||||||
public SparkleIntro () : base ("")
|
public SparkleIntro () : base ("")
|
||||||
{
|
{
|
||||||
|
|
||||||
|
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
|
||||||
|
{
|
||||||
|
File.WriteAllText ("PublicKeyOnly.xml", rsa.ToXmlString (false));
|
||||||
|
File.WriteAllText ("PublicPrivate.xml", rsa.ToXmlString (true));
|
||||||
|
}
|
||||||
|
|
||||||
BorderWidth = 0;
|
BorderWidth = 0;
|
||||||
SetSizeRequest (640, 400);
|
SetSizeRequest (640, 400);
|
||||||
Resizable = false;
|
Resizable = false;
|
||||||
|
@ -45,8 +51,16 @@ namespace SparkleShare {
|
||||||
|
|
||||||
WindowPosition = WindowPosition.Center;
|
WindowPosition = WindowPosition.Center;
|
||||||
|
|
||||||
|
ShowStepOne ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowStepOne ()
|
||||||
|
{
|
||||||
|
|
||||||
HBox layout_horizontal = new HBox (false, 6);
|
HBox layout_horizontal = new HBox (false, 6);
|
||||||
|
|
||||||
|
// TODO: Fix the path
|
||||||
Image side_splash = new Image ("/home/hbons/github/SparkleShare/data/side-splash.png");
|
Image side_splash = new Image ("/home/hbons/github/SparkleShare/data/side-splash.png");
|
||||||
|
|
||||||
layout_horizontal.PackStart (side_splash, false, false, 0);
|
layout_horizontal.PackStart (side_splash, false, false, 0);
|
||||||
|
@ -143,11 +157,11 @@ namespace SparkleShare {
|
||||||
layout_horizontal.PackStart (wrapper, true, true, 0);
|
layout_horizontal.PackStart (wrapper, true, true, 0);
|
||||||
|
|
||||||
Add (layout_horizontal);
|
Add (layout_horizontal);
|
||||||
|
|
||||||
ShowAll ();
|
ShowAll ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ShowStepTwo ()
|
public void ShowStepTwo ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -165,7 +179,7 @@ namespace SparkleShare {
|
||||||
layout_vertical.BorderWidth = 30;
|
layout_vertical.BorderWidth = 30;
|
||||||
|
|
||||||
Label introduction;
|
Label introduction;
|
||||||
introduction = new Label ("<span size='x-large'><b>SparkleShare ready to go!</b></span>");
|
introduction = new Label ("<span size='x-large'><b>SparkleShare is ready to go!</b></span>");
|
||||||
|
|
||||||
introduction.UseMarkup = true;
|
introduction.UseMarkup = true;
|
||||||
introduction.Xalign = 0;
|
introduction.Xalign = 0;
|
||||||
|
@ -173,7 +187,7 @@ namespace SparkleShare {
|
||||||
Label information;
|
Label information;
|
||||||
information = new Label ("You can now start accepting invitations from others. " +
|
information = new Label ("You can now start accepting invitations from others. " +
|
||||||
"Just click on invitations you get by email and " +
|
"Just click on invitations you get by email and " +
|
||||||
"we'll take care of the rest.");
|
"we will take care of the rest.");
|
||||||
|
|
||||||
information.UseMarkup = true;
|
information.UseMarkup = true;
|
||||||
information.Wrap = true;
|
information.Wrap = true;
|
||||||
|
@ -207,6 +221,7 @@ namespace SparkleShare {
|
||||||
layout_horizontal.Add (wrapper);
|
layout_horizontal.Add (wrapper);
|
||||||
|
|
||||||
Add (layout_horizontal);
|
Add (layout_horizontal);
|
||||||
|
|
||||||
ShowAll ();
|
ShowAll ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,10 @@
|
||||||
<Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
|
<Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="Mono.Posix" />
|
<Reference Include="Mono.Posix" />
|
||||||
|
<Reference Include="DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\SharpSSH\lib\DiffieHellman.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="SparkleBubble.cs" />
|
<Compile Include="SparkleBubble.cs" />
|
||||||
|
|
|
@ -26,8 +26,7 @@ using System.Timers;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleWindow : Window
|
public class SparkleWindow : Window {
|
||||||
{
|
|
||||||
|
|
||||||
// Short alias for the translations
|
// Short alias for the translations
|
||||||
public static string _ (string s)
|
public static string _ (string s)
|
||||||
|
@ -137,7 +136,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
DateTime date_time = UnixTimestampToDateTime (unix_timestamp);
|
DateTime date_time = UnixTimestampToDateTime (unix_timestamp);
|
||||||
|
|
||||||
message = message.Replace ("/", " → ");
|
message = message.Replace ("/", " ‣ ");
|
||||||
message = message.Replace ("\n", " ");
|
message = message.Replace ("\n", " ");
|
||||||
|
|
||||||
ChangeSet change_set = new ChangeSet (user_name, user_email, message, date_time);
|
ChangeSet change_set = new ChangeSet (user_name, user_email, message, date_time);
|
||||||
|
|
Loading…
Reference in a new issue