controller: use User object
This commit is contained in:
parent
06029e56b3
commit
8bad2b6f01
|
@ -510,8 +510,8 @@ namespace SparkleShare {
|
||||||
int midnight = (int) (DateTime.Today.AddDays (1) - new DateTime (1970, 1, 1)).TotalSeconds;
|
int midnight = (int) (DateTime.Today.AddDays (1) - new DateTime (1970, 1, 1)).TotalSeconds;
|
||||||
|
|
||||||
string html = event_log_html.Replace ("<!-- $event-log-content -->", event_log)
|
string html = event_log_html.Replace ("<!-- $event-log-content -->", event_log)
|
||||||
.Replace ("<!-- $username -->", UserName)
|
.Replace ("<!-- $username -->", CurrentUser.Name)
|
||||||
.Replace ("<!-- $user-avatar-url -->", "file://" + GetAvatar (UserEmail, 48))
|
.Replace ("<!-- $user-avatar-url -->", "file://" + GetAvatar (CurrentUser.Email, 48))
|
||||||
.Replace ("<!-- $midnight -->", midnight.ToString ());
|
.Replace ("<!-- $midnight -->", midnight.ToString ());
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
|
@ -722,7 +722,7 @@ namespace SparkleShare {
|
||||||
public void ImportPrivateKey ()
|
public void ImportPrivateKey ()
|
||||||
{
|
{
|
||||||
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
||||||
string key_file_name = "sparkleshare." + UserEmail + ".key";
|
string key_file_name = "sparkleshare." + CurrentUser.Email + ".key";
|
||||||
string key_file_path = Path.Combine (keys_path, key_file_name);
|
string key_file_path = Path.Combine (keys_path, key_file_name);
|
||||||
|
|
||||||
if (!File.Exists (key_file_path)) {
|
if (!File.Exists (key_file_path)) {
|
||||||
|
@ -752,33 +752,19 @@ namespace SparkleShare {
|
||||||
// key in the user's SparkleShare folder
|
// key in the user's SparkleShare folder
|
||||||
if (!File.Exists (pubkey_file_path))
|
if (!File.Exists (pubkey_file_path))
|
||||||
File.Copy (pubkey_file_path,
|
File.Copy (pubkey_file_path,
|
||||||
Path.Combine (SparklePath, UserName + "'s key.txt"),
|
Path.Combine (SparklePath, CurrentUser.Name + "'s key.txt"),
|
||||||
true); // Overwriting is allowed
|
true); // Overwriting is allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Looks up the user's name from the global configuration
|
// Looks up the user's name from the global configuration
|
||||||
public string UserName
|
public SparkleUser CurrentUser {
|
||||||
{
|
|
||||||
get {
|
get {
|
||||||
return SparkleConfig.DefaultConfig.User.Name;
|
return SparkleConfig.DefaultConfig.User;
|
||||||
}
|
}
|
||||||
|
|
||||||
set {
|
set {
|
||||||
SparkleConfig.DefaultConfig.User = new SparkleUser (value, UserEmail);
|
SparkleConfig.DefaultConfig.User = value;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Looks up the user's email from the global configuration
|
|
||||||
public string UserEmail
|
|
||||||
{
|
|
||||||
get {
|
|
||||||
return SparkleConfig.DefaultConfig.User.Email;
|
|
||||||
}
|
|
||||||
|
|
||||||
set {
|
|
||||||
SparkleConfig.DefaultConfig.User = new SparkleUser (UserName, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -787,7 +773,7 @@ namespace SparkleShare {
|
||||||
public void GenerateKeyPair ()
|
public void GenerateKeyPair ()
|
||||||
{
|
{
|
||||||
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
||||||
string key_file_name = "sparkleshare." + UserEmail + ".key";
|
string key_file_name = "sparkleshare." + CurrentUser.Email + ".key";
|
||||||
string key_file_path = Path.Combine (keys_path, key_file_name);
|
string key_file_path = Path.Combine (keys_path, key_file_name);
|
||||||
|
|
||||||
if (File.Exists (key_file_path)) {
|
if (File.Exists (key_file_path)) {
|
||||||
|
@ -824,7 +810,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
// Create an easily accessible copy of the public
|
// Create an easily accessible copy of the public
|
||||||
// key in the user's SparkleShare folder
|
// key in the user's SparkleShare folder
|
||||||
File.Copy (key_file_path + ".pub", Path.Combine (SparklePath, UserName + "'s key.txt"), true);
|
File.Copy (key_file_path + ".pub", Path.Combine (SparklePath, CurrentUser.Name + "'s key.txt"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -87,16 +87,16 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public string GuessedUserName {
|
public string GuessedUserName {
|
||||||
get {
|
get {
|
||||||
return Program.Controller.UserName;
|
return Program.Controller.CurrentUser.Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GuessedUserEmail {
|
public string GuessedUserEmail {
|
||||||
get {
|
get {
|
||||||
if (Program.Controller.UserEmail.Equals ("Unknown"))
|
if (Program.Controller.CurrentUser.Email.Equals ("Unknown"))
|
||||||
return "";
|
return "";
|
||||||
else
|
else
|
||||||
return Program.Controller.UserEmail;
|
return Program.Controller.CurrentUser.Email;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,8 +219,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void SetupPageCompleted (string full_name, string email)
|
public void SetupPageCompleted (string full_name, string email)
|
||||||
{
|
{
|
||||||
Program.Controller.UserName = full_name;
|
Program.Controller.CurrentUser = new SparkleUser (full_name, email);
|
||||||
Program.Controller.UserEmail = email;
|
|
||||||
|
|
||||||
new Thread (
|
new Thread (
|
||||||
new ThreadStart (delegate {
|
new ThreadStart (delegate {
|
||||||
|
|
Loading…
Reference in a new issue