diff --git a/ClientServerLib/ClientServerLib/CDiscover.cs b/ClientServerLib/ClientServerLib/CDiscover.cs
index ba327e2d..9dd5aa3d 100644
--- a/ClientServerLib/ClientServerLib/CDiscover.cs
+++ b/ClientServerLib/ClientServerLib/CDiscover.cs
@@ -1,4 +1,21 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -10,116 +27,115 @@ using System.Timers;
namespace ServerLib
{
- public delegate void OnServerDiscovered(string IPAddress, string Hostname);
+ public delegate void OnServerDiscovered(string IPAddress, string Hostname);
- public class CDiscover
- {
- public static readonly string sTimeout = "Timeout";
- public static readonly string sFinished = "Finished";
+ public class CDiscover
+ {
+ public static readonly string sTimeout = "Timeout";
+ public static readonly string sFinished = "Finished";
- private string _Keyword;
- private string _BroadcastAddress;
- private int _Port;
+ private string _Keyword;
+ private string _BroadcastAddress;
+ private int _Port;
- private Thread _DiscoverThread;
- private bool _DiscoverRunning;
- private OnServerDiscovered _OnDiscovered;
+ private Thread _DiscoverThread;
+ private bool _DiscoverRunning;
+ private OnServerDiscovered _OnDiscovered;
+ private System.Timers.Timer _BroadcastTimer;
- private System.Timers.Timer _BroadcastTimer;
+ public CDiscover(int Port, string Keyword, string BroadcastAddress = "255.255.255.255")
+ {
+ _BroadcastAddress = BroadcastAddress;
+ _Port = Port;
+ _Keyword = Keyword;
- public CDiscover(int Port, string Keyword, string BroadcastAddress = "255.255.255.255")
- {
- _BroadcastAddress = BroadcastAddress;
- _Port = Port;
- _Keyword = Keyword;
+ _DiscoverRunning = false;
+ _BroadcastTimer = new System.Timers.Timer();
+ _BroadcastTimer.Elapsed += OnBroadcastEvent;
+ _BroadcastTimer.Interval = 2500;
+ }
- _DiscoverRunning = false;
- _BroadcastTimer = new System.Timers.Timer();
- _BroadcastTimer.Elapsed += new ElapsedEventHandler(OnBroadcastEvent);
- _BroadcastTimer.Interval = 2500;
- }
+ public void StartBroadcasting()
+ {
+ _BroadcastTimer.Start();
+ }
- public void StartBroadcasting()
- {
- _BroadcastTimer.Start();
- }
+ public void Stop()
+ {
+ _BroadcastTimer.Stop();
+ _DiscoverRunning = false;
+ }
- public void Stop()
- {
- _BroadcastTimer.Stop();
- _DiscoverRunning = false;
- }
+ public void Discover(OnServerDiscovered OnDiscovered, int Timeout = 5000)
+ {
+ if (_DiscoverRunning)
+ return;
- public void Discover(OnServerDiscovered OnDiscovered, int Timeout = 5000)
- {
- if (_DiscoverRunning)
- return;
+ _DiscoverRunning = true;
+ _DiscoverThread = new Thread(() => _Discover(Timeout));
+ _OnDiscovered = OnDiscovered;
+ _DiscoverThread.Start();
+ }
- _DiscoverRunning = true;
- _DiscoverThread = new Thread(() => _Discover(Timeout));
- _OnDiscovered = OnDiscovered;
- _DiscoverThread.Start();
- }
+ private void OnBroadcastEvent(object source, ElapsedEventArgs e)
+ {
+ Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
+ s.EnableBroadcast = true;
+ IPAddress broadcast = IPAddress.Parse(_BroadcastAddress);
+ byte[] sendbuf = Encoding.UTF8.GetBytes(_Keyword);
+ IPEndPoint ep = new IPEndPoint(broadcast, _Port);
- private void OnBroadcastEvent(object source, ElapsedEventArgs e)
- {
- Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
- s.EnableBroadcast = true;
- IPAddress broadcast = IPAddress.Parse(_BroadcastAddress);
- byte[] sendbuf = Encoding.UTF8.GetBytes(_Keyword);
- IPEndPoint ep = new IPEndPoint(broadcast, _Port);
+ s.SendTo(sendbuf, ep);
+ s.Close();
+ }
- s.SendTo(sendbuf, ep);
- s.Close();
- }
+ private void _Discover(int Timeout)
+ {
+ UdpClient listener = null;
+ Stopwatch timer = new Stopwatch();
- private void _Discover(int Timeout)
- {
- UdpClient listener = null;
- Stopwatch timer = new Stopwatch();
+ List knownServer = new List();
+ bool foundSomething = false;
+ timer.Start();
+ while (_DiscoverRunning && timer.ElapsedMilliseconds < Timeout * 2)
+ {
+ try
+ {
+ listener = new UdpClient(_Port);
+ IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, _Port);
+ listener.Client.ReceiveTimeout = Timeout;
- List knownServer = new List();
- bool foundSomething = false;
- timer.Start();
- while (_DiscoverRunning && timer.ElapsedMilliseconds < Timeout * 2)
- {
- try
- {
- listener = new UdpClient(_Port);
- IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, _Port);
- listener.Client.ReceiveTimeout = Timeout;
+ byte[] bytes = listener.Receive(ref groupEP);
+ string message = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
- byte[] bytes = listener.Receive(ref groupEP);
- string message = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
+ foundSomething = true;
+ if (!knownServer.Contains(groupEP.Address.ToString()))
+ {
+ knownServer.Add(groupEP.Address.ToString());
+ if (_OnDiscovered != null)
+ {
+ IPHostEntry e = Dns.GetHostEntry(groupEP.Address);
+ string hostname = e.HostName;
- foundSomething = true;
- if (!knownServer.Contains(groupEP.Address.ToString()))
- {
- knownServer.Add(groupEP.Address.ToString());
- if (_OnDiscovered != null)
- {
- IPHostEntry e = Dns.GetHostEntry(groupEP.Address);
- string hostname = e.HostName;
+ _OnDiscovered(groupEP.Address.ToString(), hostname);
+ }
+ }
- _OnDiscovered(groupEP.Address.ToString(), hostname);
- }
- }
+ listener.Close();
+ }
+ catch (Exception)
+ {
+ if (listener != null)
+ listener.Close();
+ }
+ }
+ _DiscoverRunning = false;
- listener.Close();
- }
- catch (Exception)
- {
- if (listener != null)
- listener.Close();
- }
- }
- _DiscoverRunning = false;
-
- if (!foundSomething)
- _OnDiscovered(sTimeout, String.Empty);
- else
- _OnDiscovered(sFinished, String.Empty);
- }
- }
-}
+ if (!foundSomething)
+ _OnDiscovered(sTimeout, String.Empty);
+ else
+ _OnDiscovered(sFinished, String.Empty);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ClientServerLib/ClientServerLib/CServer.cs b/ClientServerLib/ClientServerLib/CServer.cs
index 9310ce16..ab704a95 100644
--- a/ClientServerLib/ClientServerLib/CServer.cs
+++ b/ClientServerLib/ClientServerLib/CServer.cs
@@ -1,4 +1,21 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Diagnostics;
diff --git a/ClientServerLib/ClientServerLib/CWebservice.cs b/ClientServerLib/ClientServerLib/CWebservice.cs
index 2d1ef759..97a8962c 100644
--- a/ClientServerLib/ClientServerLib/CWebservice.cs
+++ b/ClientServerLib/ClientServerLib/CWebservice.cs
@@ -1,4 +1,21 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Web;
diff --git a/ClientServerLib/ClientServerLib/DataStructs.cs b/ClientServerLib/ClientServerLib/DataStructs.cs
index cf52fd80..4d4bbed7 100644
--- a/ClientServerLib/ClientServerLib/DataStructs.cs
+++ b/ClientServerLib/ClientServerLib/DataStructs.cs
@@ -1,4 +1,21 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Linq;
using System.Runtime.Serialization;
using System.Drawing;
@@ -10,64 +27,49 @@ namespace ServerLib
{
public delegate bool SendKeyEventDelegate(string key);
-
#region profile
-
public delegate SProfileData GetProfileDataDelegate(int profileId, bool isReadonly);
+
public delegate bool SendProfileDataDelegate(SProfileData profile);
+
public delegate SProfileData[] GetProfileListDelegate();
[DataContract]
public struct SProfileData
{
- [DataMember]
- public CBase64Image Avatar;
- [DataMember]
- public string PlayerName;
- [DataMember]
- public int Type;
- [DataMember]
- public int Difficulty;
- [DataMember]
- public int ProfileId;
- [DataMember]
- public bool IsEditable;
- [DataMember]
- public string Password;
+ [DataMember] public CBase64Image Avatar;
+ [DataMember] public string PlayerName;
+ [DataMember] public int Type;
+ [DataMember] public int Difficulty;
+ [DataMember] public int ProfileId;
+ [DataMember] public bool IsEditable;
+ [DataMember] public string Password;
}
-
#endregion
#region photo
-
public delegate bool SendPhotoDelegate(SPhotoData photo);
[DataContract]
public struct SPhotoData
{
- [DataMember]
- public CBase64Image Photo;
+ [DataMember] public CBase64Image Photo;
//Add infomation about the user who took this image??
}
-
#endregion
#region website
-
public delegate byte[] GetSiteFileDelegate(string filename);
public delegate CBase64Image GetDelayedImageDelegate(string hashedFilename);
-
#endregion
[DataContract]
public class CBase64Image
{
- [DataMember]
- private string base64Data = "";
+ [DataMember] private string base64Data = "";
- [DataMember]
- private string imageId = "";
+ [DataMember] private string imageId = "";
public CBase64Image(Image img, ImageFormat format)
{
@@ -97,28 +99,21 @@ namespace ServerLib
Match match = Regex.Match(base64Data, "(?<=data:image/)[a-zA-Z]+(?=;base64)");
return match.Success ? match.Groups[0].Value : "";
}
-
-
}
#region songs
-
public delegate SSongInfo GetSongDelegate(int songId);
public delegate SSongInfo[] GetAllSongsDelegate();
public delegate int GetCurrentSongIdDelegate();
-
-
+
[DataContract]
public struct SSongInfo
{
- [DataMember]
- public string Title;
- [DataMember]
- public string Artist;
- [DataMember]
- public CBase64Image Cover;
+ [DataMember] public string Title;
+ [DataMember] public string Artist;
+ [DataMember] public CBase64Image Cover;
[DataMember]
public string Genre { get; set; }
[DataMember]
@@ -130,7 +125,6 @@ namespace ServerLib
[DataMember]
public int SongId { get; set; }
}
-
#endregion
#region playlists
@@ -155,33 +149,23 @@ namespace ServerLib
[DataContract]
public struct SPlaylistSongInfo
{
- [DataMember]
- public SSongInfo Song;
- [DataMember]
- public int PlaylistId;
- [DataMember]
- public int PlaylistPosition;
- [DataMember]
- public int GameMode;
+ [DataMember] public SSongInfo Song;
+ [DataMember] public int PlaylistId;
+ [DataMember] public int PlaylistPosition;
+ [DataMember] public int GameMode;
}
-
+
[DataContract]
public struct SPlaylistInfo
{
- [DataMember]
- public int PlaylistId;
- [DataMember]
- public string PlaylistName;
- [DataMember]
- public int SongCount;
- [DataMember]
- public string LastChanged;
+ [DataMember] public int PlaylistId;
+ [DataMember] public string PlaylistName;
+ [DataMember] public int SongCount;
+ [DataMember] public string LastChanged;
}
-
#endregion
#region user management
-
public delegate void SetPasswordDelegate(int profileId, string newPassword);
public delegate bool ValidatePasswordDelegate(int profileId, string password);
@@ -191,6 +175,5 @@ namespace ServerLib
public delegate void SetUserRoleDelegate(int profileId, int userRole);
public delegate int GetUserIdFromUsernameDelegate(string username);
-
#endregion
-}
+}
\ No newline at end of file
diff --git a/ClientServerLib/ClientServerLib/ICWebservice.cs b/ClientServerLib/ClientServerLib/ICWebservice.cs
index 3e79d8ce..38f1d5d0 100644
--- a/ClientServerLib/ClientServerLib/ICWebservice.cs
+++ b/ClientServerLib/ClientServerLib/ICWebservice.cs
@@ -1,4 +1,21 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Web;
@@ -8,207 +25,195 @@ namespace ServerLib
[ServiceContract]
public interface ICWebservice
{
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/sendKeyEvent?key={key}")]
+
void SendKeyEvent(string key);
#region profile
-
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getOwnProfileId")]
+
int GetOwnProfileId();
- [OperationContract]
- [WebInvoke(Method = "POST",
+ [OperationContract, WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/sendProfile")]
+
void SendProfile(SProfileData profile);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getProfile?profileId={profileId}")]
+
SProfileData GetProfile(int profileId);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getProfileList")]
+
SProfileData[] GetProfileList();
-
#endregion
#region photo
-
- [OperationContract]
- [WebInvoke(Method = "POST",
+ [OperationContract, WebInvoke(Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/sendPhoto")]
+
void SendPhoto(SPhotoData photo);
-
#endregion
#region website
-
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/login?username={username}&password={password}")]
+
Guid Login(string username, string password);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "")]
+
Stream Index();
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/js/{filename}")]
+
Stream GetJsFile(String filename);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/css/{filename}")]
+
Stream GetCssFile(String filename);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/css/images/{filename}")]
+
Stream GetCssImageFile(String filename);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/img/{filename}")]
+
Stream GetImgFile(String filename);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/locales/{filename}")]
+
Stream GetLocaleFile(String filename);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/delayedImage?id={id}")]
+
CBase64Image GetDelayedImage(String id);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/isServerOnline")]
+
bool IsServerOnline();
-
#endregion
#region songs
-
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getSong?songId={songId}")]
+
SSongInfo GetSong(int songId);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getCurrentSongId")]
+
int GetCurrentSongId();
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getAllSongs")]
+
SSongInfo[] GetAllSongs();
-
#endregion
#region playlist
-
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getPlaylists")]
+
SPlaylistInfo[] GetPlaylists();
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getPlaylist?id={playlistId}")]
+
SPlaylistInfo GetPlaylist(int playlistId);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/addSongToPlaylist?songId={songId}&playlistId={playlistId}&duplicates={allowDuplicates}")]
+
void AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/removeSongFromPlaylist?position={position}&playlistId={playlistId}&songId={songId}")]
+
void RemoveSongFromPlaylist(int position, int playlistId, int songId);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/moveSongInPlaylist?newPosition={newPosition}&playlistId={playlistId}&songId={songId}")]
+
void MoveSongInPlaylist(int newPosition, int playlistId, int songId);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/playlistContainsSong?songId={songId}&playlistId={playlistId}")]
+
bool PlaylistContainsSong(int songId, int playlistId);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getPlaylistSongs?playlistId={playlistId}")]
+
SPlaylistSongInfo[] GetPlaylistSongs(int playlistId);
[OperationContract, WebInvoke(Method = "GET",
- ResponseFormat = WebMessageFormat.Json,
- UriTemplate = "/removePlaylist?playlistId={playlistId}")]
+ ResponseFormat = WebMessageFormat.Json,
+ UriTemplate = "/removePlaylist?playlistId={playlistId}")]
void RemovePlaylist(int playlistId);
[OperationContract, WebInvoke(Method = "GET",
- ResponseFormat = WebMessageFormat.Json,
- UriTemplate = "/addPlaylist?playlistName={playlistName}")]
+ ResponseFormat = WebMessageFormat.Json,
+ UriTemplate = "/addPlaylist?playlistName={playlistName}")]
int AddPlaylist(string playlistName);
-
#endregion
#region user management
-
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/getUserRole?profileId={profileId}")]
+
int GetUserRole(int profileId);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/setUserRole?profileId={profileId}&userRole={userRole}")]
+
void SetUserRole(int profileId, int userRole);
- [OperationContract]
- [WebInvoke(Method = "GET",
+ [OperationContract, WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/hasUserRight?right={right}")]
+
bool HasUserRight(int right);
-
#endregion
}
}
\ No newline at end of file
diff --git a/ClientServerLib/ClientServerLib/Properties/AssemblyInfo.cs b/ClientServerLib/ClientServerLib/Properties/AssemblyInfo.cs
index 64cd33c7..fe3863d2 100644
--- a/ClientServerLib/ClientServerLib/Properties/AssemblyInfo.cs
+++ b/ClientServerLib/ClientServerLib/Properties/AssemblyInfo.cs
@@ -1,10 +1,28 @@
-using System.Reflection;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
+
[assembly: AssemblyTitle("ClientServerLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
@@ -17,9 +35,11 @@ using System.Runtime.InteropServices;
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+
[assembly: Guid("53f89645-1948-420f-b64a-7dc705ca8820")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
@@ -32,5 +52,6 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
+
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
diff --git a/ClientServerLib/ClientServerLib/Session.cs b/ClientServerLib/ClientServerLib/Session.cs
index b482fe53..ad0f612f 100644
--- a/ClientServerLib/ClientServerLib/Session.cs
+++ b/ClientServerLib/ClientServerLib/Session.cs
@@ -1,22 +1,39 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
namespace ServerLib
{
- internal class CSession
+ class CSession
{
- readonly Guid _ID;
+ private readonly Guid _ID;
public Guid Id
{
get { return _ID; }
}
- readonly int _ProfileId;
+ private readonly int _ProfileId;
public int ProfileId
{
get { return _ProfileId; }
}
- readonly EUserRoles _Roles;
+ private readonly EUserRoles _Roles;
internal EUserRoles Roles
{
get { return _Roles; }
@@ -24,9 +41,9 @@ namespace ServerLib
public CSession(Guid id, int profileId, EUserRoles roles)
{
- this._ID = id;
- this._ProfileId = profileId;
- this._Roles = roles;
+ _ID = id;
+ _ProfileId = profileId;
+ _Roles = roles;
}
}
-}
+}
\ No newline at end of file
diff --git a/ClientServerLib/ClientServerLib/SessionControl.cs b/ClientServerLib/ClientServerLib/SessionControl.cs
index eee8fc2a..80bd2e66 100644
--- a/ClientServerLib/ClientServerLib/SessionControl.cs
+++ b/ClientServerLib/ClientServerLib/SessionControl.cs
@@ -1,19 +1,34 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Collections.Generic;
using System.Linq;
namespace ServerLib
{
- internal static class CSessionControl
+ static class CSessionControl
{
private static readonly Dictionary _ActiveSessions = new Dictionary();
public static Guid OpenSession(string userName, string password)
{
if (!_ValidateUserAndPassword(userName, password))
- {
return Guid.Empty;
- }
Guid newId = Guid.NewGuid();
int id = _GetProfileIdFormUsername(userName);
@@ -42,27 +57,23 @@ namespace ServerLib
internal static void InvalidateSessions(int profileId)
{
- foreach (var s in (from kv in _ActiveSessions
- where kv.Value.ProfileId == profileId
- select kv).ToList())
- {
+ foreach (KeyValuePair s in (from kv in _ActiveSessions
+ where kv.Value.ProfileId == profileId
+ select kv).ToList())
_ActiveSessions.Remove(s.Key);
- }
}
internal static bool RequestRight(Guid sessionId, EUserRights requestedRight)
{
return ((CUserRoleControl.GetUserRightsFromUserRole(_ActiveSessions[sessionId].Roles)
- .HasFlag(requestedRight)));
+ .HasFlag(requestedRight)));
}
internal static int GetUserIdFromSession(Guid sessionId)
{
if (!_ActiveSessions.ContainsKey(sessionId))
- {
return -1;
- }
return _ActiveSessions[sessionId].ProfileId;
}
}
-}
+}
\ No newline at end of file
diff --git a/ClientServerLib/ClientServerLib/UserRights.cs b/ClientServerLib/ClientServerLib/UserRights.cs
index d5d71fbe..56b42d81 100644
--- a/ClientServerLib/ClientServerLib/UserRights.cs
+++ b/ClientServerLib/ClientServerLib/UserRights.cs
@@ -1,9 +1,26 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
namespace ServerLib
{
[Flags]
- internal enum EUserRights
+ enum EUserRights
{
None = 0,
EditAllProfiles = 1,
@@ -16,4 +33,4 @@ namespace ServerLib
DeletePlaylists = 128,
RemoveSongsFromPlaylists = 256
}
-}
+}
\ No newline at end of file
diff --git a/ClientServerLib/ClientServerLib/UserRoleControl.cs b/ClientServerLib/ClientServerLib/UserRoleControl.cs
index 8bff242a..a66212d3 100644
--- a/ClientServerLib/ClientServerLib/UserRoleControl.cs
+++ b/ClientServerLib/ClientServerLib/UserRoleControl.cs
@@ -1,46 +1,77 @@
-using System.Collections.Generic;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System.Collections.Generic;
using System.Linq;
namespace ServerLib
{
- internal static class CUserRoleControl
+ static class CUserRoleControl
{
- private static readonly Dictionary _RoleRightsMapping = new Dictionary {
- {EUserRoles.TR_USERROLE_ADMIN,
- (EUserRights.EditAllProfiles|
- EUserRights.UploadPhotos|
- EUserRights.ViewOtherProfiles|
- EUserRights.UseKeyboard|
- EUserRights.AddSongToPlaylist|
- EUserRights.ReorderPlaylists|
- EUserRights.CreatePlaylists|
- EUserRights.DeletePlaylists|
- EUserRights.RemoveSongsFromPlaylists)},
- {EUserRoles.TR_USERROLE_GUEST,
- EUserRights.None},
- {EUserRoles.TR_USERROLE_NORMAL,
- (EUserRights.UploadPhotos|
- EUserRights.ViewOtherProfiles)},
- {EUserRoles.TR_USERROLE_KEYBOARDUSER,
- EUserRights.UseKeyboard},
- {EUserRoles.TR_USERROLE_ADDSONGSUSER,
- EUserRights.AddSongToPlaylist},
- {EUserRoles.TR_USERROLE_PLAYLISTEDITOR,
- (EUserRights.AddSongToPlaylist|
- EUserRights.ReorderPlaylists|
- EUserRights.CreatePlaylists|
- EUserRights.DeletePlaylists|
- EUserRights.RemoveSongsFromPlaylists)},
- {EUserRoles.TR_USERROLE_PROFILEEDITOR,
- EUserRights.EditAllProfiles}
- };
-
+ private static readonly Dictionary _RoleRightsMapping = new Dictionary
+ {
+ {
+ EUserRoles.TR_USERROLE_ADMIN,
+ (EUserRights.EditAllProfiles |
+ EUserRights.UploadPhotos |
+ EUserRights.ViewOtherProfiles |
+ EUserRights.UseKeyboard |
+ EUserRights.AddSongToPlaylist |
+ EUserRights.ReorderPlaylists |
+ EUserRights.CreatePlaylists |
+ EUserRights.DeletePlaylists |
+ EUserRights.RemoveSongsFromPlaylists)
+ },
+ {
+ EUserRoles.TR_USERROLE_GUEST,
+ EUserRights.None
+ },
+ {
+ EUserRoles.TR_USERROLE_NORMAL,
+ (EUserRights.UploadPhotos |
+ EUserRights.ViewOtherProfiles)
+ },
+ {
+ EUserRoles.TR_USERROLE_KEYBOARDUSER,
+ EUserRights.UseKeyboard
+ },
+ {
+ EUserRoles.TR_USERROLE_ADDSONGSUSER,
+ EUserRights.AddSongToPlaylist
+ },
+ {
+ EUserRoles.TR_USERROLE_PLAYLISTEDITOR,
+ (EUserRights.AddSongToPlaylist |
+ EUserRights.ReorderPlaylists |
+ EUserRights.CreatePlaylists |
+ EUserRights.DeletePlaylists |
+ EUserRights.RemoveSongsFromPlaylists)
+ },
+ {
+ EUserRoles.TR_USERROLE_PROFILEEDITOR,
+ EUserRights.EditAllProfiles
+ }
+ };
internal static EUserRights GetUserRightsFromUserRole(EUserRoles userRole)
{
return _RoleRightsMapping.Where(role => userRole.HasFlag(role.Key))
- .Select(role => role.Value)
- .Aggregate(EUserRights.None, (current, r) => current | r);
+ .Select(role => role.Value)
+ .Aggregate(EUserRights.None, (current, r) => current | r);
}
}
-}
+}
\ No newline at end of file
diff --git a/ClientServerLib/ClientServerLib/UserRoles.cs b/ClientServerLib/ClientServerLib/UserRoles.cs
index bcdb0988..860b9d7f 100644
--- a/ClientServerLib/ClientServerLib/UserRoles.cs
+++ b/ClientServerLib/ClientServerLib/UserRoles.cs
@@ -1,9 +1,26 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
namespace ServerLib
{
[Flags]
- internal enum EUserRoles
+ enum EUserRoles
{
TR_USERROLE_GUEST = 0,
TR_USERROLE_NORMAL = 1,
@@ -13,4 +30,4 @@ namespace ServerLib
TR_USERROLE_PLAYLISTEDITOR = 16,
TR_USERROLE_PROFILEEDITOR = 32
}
-}
+}
\ No newline at end of file
diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs
index 449deba3..46d00571 100644
--- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs
+++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs
@@ -60,7 +60,7 @@ namespace VocaluxeLib.PartyModes.Challenge
while (_Data.ScreenNames.ProfileIDs.Count > _NumPlayer)
_Data.ScreenNames.ProfileIDs.RemoveAt(_Data.ScreenNames.ProfileIDs.Count - 1);
- List[] ids = new List[] { _Data.ScreenNames.ProfileIDs };
+ List[] ids = new List[] {_Data.ScreenNames.ProfileIDs};
SetPartyModeProfiles(ids);
}
catch (Exception e)
@@ -77,7 +77,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public override void Back()
{
SPartyNameOptions options = GetData();
- if(options.TeamList.Length == 1)
+ if (options.TeamList.Length == 1)
_Data.ScreenNames.ProfileIDs = options.TeamList[0];
_Data.ScreenNames.FadeBack = true;
_PartyMode.DataFromScreen(ThemeName, _Data);
diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs
index 73da860e..3858de80 100644
--- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs
+++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyNames.cs
@@ -61,7 +61,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
while (_Data.ScreenNames.ProfileIDs.Count > _NumPlayer)
_Data.ScreenNames.ProfileIDs.RemoveAt(_Data.ScreenNames.ProfileIDs.Count - 1);
- List[] ids = new List[] { _Data.ScreenNames.ProfileIDs };
+ List[] ids = new List[] {_Data.ScreenNames.ProfileIDs};
SetPartyModeProfiles(ids);
}
catch (Exception e)
@@ -70,7 +70,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
}
}
-
public override void Back()
{
SPartyNameOptions options = GetData();
diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs
index ec039ba7..00f99acc 100644
--- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs
+++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeNames.cs
@@ -77,11 +77,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
}
}
-
public override void OnShow()
{
base.OnShow();
- SetPartyModeData(2, _NumPlayerTeam1 + _NumPlayerTeam2, new int[] { _NumPlayerTeam1, _NumPlayerTeam2 });
+ SetPartyModeData(2, _NumPlayerTeam1 + _NumPlayerTeam2, new int[] {_NumPlayerTeam1, _NumPlayerTeam2});
List[] ids = new List[] {_Data.ScreenNames.ProfileIDsTeam1, _Data.ScreenNames.ProfileIDsTeam2};
SetPartyModeProfiles(ids);
}
@@ -89,7 +88,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public override void Back()
{
SPartyNameOptions options = GetData();
- if(options.TeamList.Length == 2)
+ if (options.TeamList.Length == 2)
{
_Data.ScreenNames.ProfileIDsTeam1 = options.TeamList[0];
_Data.ScreenNames.ProfileIDsTeam2 = options.TeamList[1];
diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs
index 5f23e8c9..c5024d1e 100644
--- a/Vocaluxe/Base/CConfig.cs
+++ b/Vocaluxe/Base/CConfig.cs
@@ -34,7 +34,7 @@ namespace Vocaluxe.Base
static class CConfig
{
///
- /// Uniform settings for writing XML files. ALWAYS use this!
+ /// Uniform settings for writing XML files. ALWAYS use this!
///
public static readonly XmlWriterSettings XMLSettings = new XmlWriterSettings
{
diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs
index 356c9192..4953a767 100644
--- a/Vocaluxe/Base/CGame.cs
+++ b/Vocaluxe/Base/CGame.cs
@@ -276,7 +276,8 @@ namespace Vocaluxe.Base
{
int tone = notes[note].Tone;
int tonePlayer = CSound.RecordGetTone(p);
- if (DEBUG_HIT) tonePlayer = tone;
+ if (DEBUG_HIT)
+ tonePlayer = tone;
while (tonePlayer - tone > 6)
tonePlayer -= 12;
diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs
index 99a43471..60356193 100644
--- a/Vocaluxe/Base/CGraphics.cs
+++ b/Vocaluxe/Base/CGraphics.cs
@@ -79,7 +79,7 @@ namespace Vocaluxe.Base
_Screens.Add(new CScreenHighscore());
_Screens.Add(new CScreenOptionsGame());
_Screens.Add(new CScreenOptionsSound());
- _Screens.Add(new CScreenOptionsRecord());
+ _Screens.Add(new CScreenOptionsRecord());
_Screens.Add(new CScreenOptionsVideo());
_Screens.Add(new CScreenOptionsVideoAdjustments());
_Screens.Add(new CScreenOptionsLyrics());
@@ -375,7 +375,8 @@ namespace Vocaluxe.Base
if (!eventsAvailable)
keyEvent = inputKeyEvent;
- if (keyEvent.Key == Keys.Left || keyEvent.Key == Keys.Right || keyEvent.Key == Keys.Up || keyEvent.Key == Keys.Down || keyEvent.Key == Keys.NumPad0 || keyEvent.Key == Keys.D0 )
+ if (keyEvent.Key == Keys.Left || keyEvent.Key == Keys.Right || keyEvent.Key == Keys.Up || keyEvent.Key == Keys.Down || keyEvent.Key == Keys.NumPad0 ||
+ keyEvent.Key == Keys.D0)
{
CSettings.MouseInactive();
_Cursor.FadeOut();
diff --git a/Vocaluxe/Base/CPlaylists.cs b/Vocaluxe/Base/CPlaylists.cs
index 9f0793c1..e73dbd2b 100644
--- a/Vocaluxe/Base/CPlaylists.cs
+++ b/Vocaluxe/Base/CPlaylists.cs
@@ -1,18 +1,18 @@
#region license
-// This file is part of Vocaluxe.
+// This file is part of Vocaluxe.
//
-// Vocaluxe 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.
+// Vocaluxe 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.
//
-// Vocaluxe 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.
+// Vocaluxe 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 Vocaluxe. If not, see .
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
#endregion
using System;
@@ -125,7 +125,7 @@ namespace Vocaluxe.Base
public static int NewPlaylist()
{
- CPlaylistFile pl = new CPlaylistFile { PlaylistName = "New Playlist", Id = _Playlists.Count };
+ CPlaylistFile pl = new CPlaylistFile {PlaylistName = "New Playlist", Id = _Playlists.Count};
_Playlists.Add(pl);
return _Playlists.Count - 1;
}
diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs
index a57412a9..b4f4ae50 100644
--- a/Vocaluxe/Base/CProfiles.cs
+++ b/Vocaluxe/Base/CProfiles.cs
@@ -1,18 +1,18 @@
#region license
-// This file is part of Vocaluxe.
+// This file is part of Vocaluxe.
//
-// Vocaluxe 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.
+// Vocaluxe 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.
//
-// Vocaluxe 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.
+// Vocaluxe 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 Vocaluxe. If not, see .
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
#endregion
using System;
@@ -202,7 +202,7 @@ namespace Vocaluxe.Base
public static void LoadProfiles()
{
- var change = new SChange { Action = EAction.LoadProfiles };
+ var change = new SChange {Action = EAction.LoadProfiles};
lock (_QueueMutex)
{
@@ -212,7 +212,7 @@ namespace Vocaluxe.Base
public static void LoadAvatars()
{
- var change = new SChange { Action = EAction.LoadAvatars };
+ var change = new SChange {Action = EAction.LoadAvatars};
lock (_QueueMutex)
{
@@ -225,7 +225,7 @@ namespace Vocaluxe.Base
if (newProfile == null)
return;
- var change = new SChange { Action = EAction.AddProfile, Profile = newProfile };
+ var change = new SChange {Action = EAction.AddProfile, Profile = newProfile};
lock (_QueueMutex)
{
@@ -238,7 +238,7 @@ namespace Vocaluxe.Base
if (editProfile == null)
return;
- var change = new SChange { Action = EAction.EditProfile, Profile = editProfile };
+ var change = new SChange {Action = EAction.EditProfile, Profile = editProfile};
lock (_QueueMutex)
{
@@ -251,7 +251,7 @@ namespace Vocaluxe.Base
if (!IsProfileIDValid(profileID))
return;
- var change = new SChange { Action = EAction.DeleteProfile, ProfileID = profileID };
+ var change = new SChange {Action = EAction.DeleteProfile, ProfileID = profileID};
lock (_QueueMutex)
{
@@ -264,7 +264,7 @@ namespace Vocaluxe.Base
if (newAvatar == null)
return;
- var change = new SChange { Action = EAction.AddAvatar, Avatar = newAvatar };
+ var change = new SChange {Action = EAction.AddAvatar, Avatar = newAvatar};
lock (_QueueMutex)
{
@@ -277,7 +277,7 @@ namespace Vocaluxe.Base
if (editAvatar == null)
return;
- var change = new SChange { Action = EAction.EditAvatar, Avatar = editAvatar };
+ var change = new SChange {Action = EAction.EditAvatar, Avatar = editAvatar};
lock (_QueueMutex)
{
@@ -298,9 +298,7 @@ namespace Vocaluxe.Base
public static CProfile GetProfile(int profileID)
{
if (!IsProfileIDValid(profileID))
- {
return null;
- }
return _Profiles[profileID];
}
diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs
index bfd0aa35..e70a0d0c 100644
--- a/Vocaluxe/Base/CSettings.cs
+++ b/Vocaluxe/Base/CSettings.cs
@@ -1,18 +1,18 @@
#region license
-// This file is part of Vocaluxe.
+// This file is part of Vocaluxe.
//
-// Vocaluxe 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.
+// Vocaluxe 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.
//
-// Vocaluxe 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.
+// Vocaluxe 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 Vocaluxe. If not, see .
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
#endregion
using System;
diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs
index 9477224e..7aa205c9 100644
--- a/Vocaluxe/Base/CSongs.cs
+++ b/Vocaluxe/Base/CSongs.cs
@@ -226,13 +226,13 @@ namespace Vocaluxe.Base
totalCounts += song.NumPlayedSession;
int averageCount = totalCounts / NumSongsVisible;
- foreach(CSong song in VisibleSongs)
+ foreach (CSong song in VisibleSongs)
{
if (song.NumPlayedSession <= averageCount)
_SongsForRandom.Add(song);
}
-
- if(_SongsForRandom.Count == 0)
+
+ if (_SongsForRandom.Count == 0)
_SongsForRandom.AddRange(VisibleSongs);
}
@@ -295,7 +295,7 @@ namespace Vocaluxe.Base
}
///
- /// Gets category with given index or null for invalid index
+ /// Gets category with given index or null for invalid index
///
///
/// category with given index or null for invalid index
@@ -308,7 +308,7 @@ namespace Vocaluxe.Base
}
///
- /// Gets visible song with given index or null for invalid index or song not visible
+ /// Gets visible song with given index or null for invalid index or song not visible
///
///
/// visible song with given index or null for invalid index or song not visible
diff --git a/Vocaluxe/Base/Server/CCommands.cs b/Vocaluxe/Base/Server/CCommands.cs
index 6e6f0e66..be2b0bae 100644
--- a/Vocaluxe/Base/Server/CCommands.cs
+++ b/Vocaluxe/Base/Server/CCommands.cs
@@ -97,7 +97,7 @@ namespace Vocaluxe.Base.Server
stream.Write(cmd, 0, cmd.Length);
byte[] data;
- string json = JsonConvert.SerializeObject(obj);
+ string json = JsonConvert.SerializeObject(obj);
data = _Encoder.GetBytes(json);
stream.Write(data, 0, data.Length);
return stream.ToArray();
@@ -115,16 +115,16 @@ namespace Vocaluxe.Base.Server
var data = new byte[message.Length - 4];
Array.Copy(message, 4, data, 0, data.Length);
- try
- {
+ try
+ {
obj = JsonConvert.DeserializeObject(_Encoder.GetString(data));
- return true;
- }
- catch
- {
- return false;
+ return true;
+ }
+ catch
+ {
+ return false;
}
}
#endregion Serializing
}
-}
+}
\ No newline at end of file
diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs
index 13072356..03ede100 100644
--- a/Vocaluxe/Base/Server/CVocaluxeServer.cs
+++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs
@@ -1,18 +1,18 @@
#region license
-// This file is part of Vocaluxe.
+// This file is part of Vocaluxe.
//
-// Vocaluxe 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.
+// Vocaluxe 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.
//
-// Vocaluxe 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.
+// Vocaluxe 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 Vocaluxe. If not, see .
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
#endregion
using System;
@@ -137,7 +137,7 @@ namespace Vocaluxe.Base.Server
result = true;
break;
default:
- foreach (char c in key.ToCharArray())
+ foreach (char c in key)
{
bool shift = true;
char keyChar;
@@ -147,17 +147,13 @@ namespace Vocaluxe.Base.Server
shift = false;
}
else
- {
keyChar = c;
- }
if ((keyChar >= 0x30 && keyChar <= 0x39) || (keyChar >= 0x41 && keyChar <= 0x5A))
{
Keys keys = (Keys)keyChar;
if (shift)
- {
keys |= Keys.Shift;
- }
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, keys));
result = true;
}
@@ -167,18 +163,14 @@ namespace Vocaluxe.Base.Server
}
return result;
-
}
#region profile
-
private static SProfileData _GetProfileData(int profileId, bool isReadonly)
{
CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null)
- {
return new SProfileData();
- }
return _CreateProfileData(profile, isReadonly);
}
@@ -190,31 +182,28 @@ namespace Vocaluxe.Base.Server
if (existingProfile != null)
{
newProfile = new CProfile
- {
- ID = existingProfile.ID,
- FileName = existingProfile.FileName,
- Active = existingProfile.Active,
- AvatarFileName = existingProfile.AvatarFileName,
- Avatar = existingProfile.Avatar,
- Difficulty = existingProfile.Difficulty,
- UserRole = existingProfile.UserRole,
- PlayerName = existingProfile.PlayerName
- };
+ {
+ ID = existingProfile.ID,
+ FileName = existingProfile.FileName,
+ Active = existingProfile.Active,
+ AvatarFileName = existingProfile.AvatarFileName,
+ Avatar = existingProfile.Avatar,
+ Difficulty = existingProfile.Difficulty,
+ UserRole = existingProfile.UserRole,
+ PlayerName = existingProfile.PlayerName
+ };
}
else
{
newProfile = new CProfile
- {
- Active = EOffOn.TR_CONFIG_ON,
- UserRole = EUserRole.TR_USERROLE_NORMAL
- };
+ {
+ Active = EOffOn.TR_CONFIG_ON,
+ UserRole = EUserRole.TR_USERROLE_NORMAL
+ };
}
if (profile.Avatar != null)
- {
newProfile.Avatar = _AddAvatar(profile.Avatar);
-
- }
else if (newProfile.Avatar == null || newProfile.Avatar.ID == -1)
{
newProfile.Avatar = CProfiles.GetAvatars().First();
@@ -226,22 +215,16 @@ namespace Vocaluxe.Base.Server
}
if (!string.IsNullOrEmpty(profile.PlayerName))
- {
newProfile.PlayerName = profile.PlayerName;
- }
else if (!string.IsNullOrEmpty(newProfile.PlayerName))
- {
newProfile.PlayerName = "DummyName";
- }
if (profile.Difficulty >= 0 && profile.Difficulty <= 2)
- {
newProfile.Difficulty = (EGameDifficulty)profile.Difficulty;
- }
if (profile.Type >= 0 && profile.Type <= 1)
{
- var option = profile.Type == 0 ? EUserRole.TR_USERROLE_GUEST : EUserRole.TR_USERROLE_NORMAL;
+ EUserRole option = profile.Type == 0 ? EUserRole.TR_USERROLE_GUEST : EUserRole.TR_USERROLE_NORMAL;
//Only allow the change of TR_USERROLE_GUEST and TR_USERROLE_NORMAL
const EUserRole mask = EUserRole.TR_USERROLE_NORMAL;
newProfile.UserRole = (newProfile.UserRole & mask) | option;
@@ -274,9 +257,7 @@ namespace Vocaluxe.Base.Server
CProfiles.SaveProfiles();
}
else
- {
CProfiles.AddProfile(newProfile);
- }
return true;
}
@@ -293,22 +274,20 @@ namespace Vocaluxe.Base.Server
private static SProfileData _CreateProfileData(CProfile profile, bool isReadonly)
{
SProfileData profileData = new SProfileData
- {
- IsEditable = !isReadonly,
- ProfileId = profile.ID,
- PlayerName = profile.PlayerName,
- //Is TR_USERROLE_GUEST or TR_USERROLE_NORMAL?
- Type = (profile.UserRole.HasFlag(EUserRole.TR_USERROLE_NORMAL)?1:0),
- Difficulty = (int)profile.Difficulty
- };
-
+ {
+ IsEditable = !isReadonly,
+ ProfileId = profile.ID,
+ PlayerName = profile.PlayerName,
+ //Is TR_USERROLE_GUEST or TR_USERROLE_NORMAL?
+ Type = (profile.UserRole.HasFlag(EUserRole.TR_USERROLE_NORMAL) ? 1 : 0),
+ Difficulty = (int)profile.Difficulty
+ };
+
CAvatar avatar = profile.Avatar;
if (avatar != null)
{
if (File.Exists(avatar.FileName))
- {
profileData.Avatar = new CBase64Image(_CreateDelayedImage(avatar.FileName));
- }
}
return profileData;
}
@@ -332,19 +311,15 @@ namespace Vocaluxe.Base.Server
return null;
}
}
-
#endregion
#region photo
-
private static List photosOfThisRound = new List();
private static bool _SendPhoto(SPhotoData photoData)
{
if (photoData.Photo == null)
- {
return false;
- }
string name = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
string filePath = _SaveImage(photoData.Photo, name, CSettings.FolderPhotos);
@@ -359,15 +334,13 @@ namespace Vocaluxe.Base.Server
internal static string[] getPhotosOfThisRound()
{
- var result = photosOfThisRound.ToArray();
+ string[] result = photosOfThisRound.ToArray();
photosOfThisRound.Clear();
return result;
}
-
#endregion
#region website
-
private static readonly Dictionary _DelayedImagePath = new Dictionary();
private static byte[] _GetSiteFile(string filename)
@@ -376,9 +349,7 @@ namespace Vocaluxe.Base.Server
path = path.Replace("..", "");
if (!File.Exists(path))
- {
return null;
- }
/*string content = File.ReadAllText(path);
@@ -395,25 +366,19 @@ namespace Vocaluxe.Base.Server
byte[] by = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(filename));
var sb = new StringBuilder();
foreach (byte b in by)
- {
sb.Append(b.ToString("x2"));
- }
string hashedFilename = sb.ToString();
if (!_DelayedImagePath.ContainsKey(hashedFilename))
- {
_DelayedImagePath.Add(hashedFilename, filename);
- }
return hashedFilename;
}
private static CBase64Image _GetDelayedImage(string hashedFilename)
{
if (!_DelayedImagePath.ContainsKey(hashedFilename))
- {
throw new FileNotFoundException("Image not found");
- }
string fileName = _DelayedImagePath[hashedFilename];
@@ -424,11 +389,9 @@ namespace Vocaluxe.Base.Server
}
throw new FileNotFoundException("Image not found");
}
-
#endregion
#region songs
-
private static SSongInfo _GetSong(int songId)
{
CSong song = CSongs.GetSong(songId);
@@ -437,7 +400,7 @@ namespace Vocaluxe.Base.Server
private static SSongInfo[] _GetAllSongs()
{
- var songs = CSongs.Songs;
+ List songs = CSongs.Songs;
return (from s in songs
select _GetSongInfo(s, false)).ToArray();
}
@@ -446,9 +409,7 @@ namespace Vocaluxe.Base.Server
{
CSong song = CGame.GetSong();
if (song == null)
- {
return -1;
- }
return song.ID;
}
@@ -465,17 +426,13 @@ namespace Vocaluxe.Base.Server
result.IsDuet = song.IsDuet;
result.SongId = song.ID;
if (includeCover)
- {
result.Cover = new CBase64Image(_CreateDelayedImage(song.Folder + "\\" + song.CoverFileName));
- }
}
return result;
}
-
#endregion
#region playlist
-
private static SPlaylistInfo[] _GetPlaylists()
{
return (from p in CPlaylists.Playlists
@@ -485,18 +442,14 @@ namespace Vocaluxe.Base.Server
private static SPlaylistInfo _GetPlaylist(int playlistId)
{
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
- {
throw new ArgumentException("invalid playlistId");
- }
return _GetPlaylistInfo(CPlaylists.Playlists[playlistId]);
}
private static void _AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates)
{
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
- {
throw new ArgumentException("invalid playlistId");
- }
if (allowDuplicates || !_PlaylistContainsSong(songId, playlistId))
{
@@ -504,26 +457,18 @@ namespace Vocaluxe.Base.Server
CPlaylists.SavePlaylist(playlistId);
}
else
- {
throw new ArgumentException("song exists in this playlist");
- }
}
private static void _RemoveSongFromPlaylist(int position, int playlistId, int songId)
{
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
- {
throw new ArgumentException("invalid playlistId");
- }
if (!_PlaylistContainsSong(songId, playlistId))
- {
throw new ArgumentException("invalid songId");
- }
if (position < 0 || CPlaylists.Playlists[playlistId].Songs.Count <= position
|| CPlaylists.Playlists[playlistId].Songs[position].SongID != songId)
- {
throw new ArgumentException("invalid position");
- }
CPlaylists.Playlists[playlistId].DeleteSong(position);
CPlaylists.SavePlaylist(playlistId);
}
@@ -531,18 +476,12 @@ namespace Vocaluxe.Base.Server
private static void _MoveSongInPlaylist(int newPosition, int playlistId, int songId)
{
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
- {
throw new ArgumentException("invalid playlistId");
- }
if (!_PlaylistContainsSong(songId, playlistId))
- {
throw new ArgumentException("invalid songId");
- }
if (CPlaylists.Playlists[playlistId].Songs.Count < newPosition)
- {
throw new ArgumentException("invalid newPosition");
- }
int oldPosition = CPlaylists.Playlists[playlistId].Songs.FindIndex(s => s.SongID == songId);
CPlaylists.MovePlaylistSong(playlistId, oldPosition, newPosition);
@@ -552,18 +491,14 @@ namespace Vocaluxe.Base.Server
private static bool _PlaylistContainsSong(int songId, int playlistId)
{
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
- {
throw new ArgumentException("invalid playlistId");
- }
return CPlaylists.Playlists[playlistId].Songs.Any(s => s.SongID == songId);
}
private static SPlaylistSongInfo[] _GetPlaylistSongs(int playlistId)
{
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
- {
throw new ArgumentException("invalid playlistId");
- }
return _GetPlaylistSongInfos(CPlaylists.Playlists[playlistId]);
}
@@ -585,29 +520,25 @@ namespace Vocaluxe.Base.Server
{
SPlaylistSongInfo[] result = new SPlaylistSongInfo[playlist.Songs.Count];
for (int i = 0; i < playlist.Songs.Count; i++)
- {
result[i] = _GetPlaylistSongInfo(playlist.Songs[i], playlist.Id, i);
- }
return result;
}
private static SPlaylistInfo _GetPlaylistInfo(CPlaylistFile playlist)
{
return new SPlaylistInfo
- {
- PlaylistId = playlist.Id,
- PlaylistName = playlist.PlaylistName,
- SongCount = playlist.Songs.Count,
- LastChanged = DateTime.Now.ToLongDateString()
- };
+ {
+ PlaylistId = playlist.Id,
+ PlaylistName = playlist.PlaylistName,
+ SongCount = playlist.Songs.Count,
+ LastChanged = DateTime.Now.ToLongDateString()
+ };
}
private static void _RemovePlaylist(int playlistId)
{
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
- {
throw new ArgumentException("invalid playlistId");
- }
CPlaylists.DeletePlaylist(playlistId);
}
@@ -619,25 +550,19 @@ namespace Vocaluxe.Base.Server
return newPlaylistId;
}
-
#endregion
#region user management
-
private static bool _ValidatePassword(int profileId, string password)
{
CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null)
- {
throw new ArgumentException("Invalid profileId");
- }
if (profile.PasswordHash == null)
{
if (string.IsNullOrEmpty(password))
- {
return true; //Allow emty passwords
- }
return false;
}
@@ -649,16 +574,12 @@ namespace Vocaluxe.Base.Server
{
CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null)
- {
throw new ArgumentException("Invalid profileId");
- }
if (profile.PasswordHash == null)
{
if (hashedPassword == null)
- {
return true; //Allow emty passwords
- }
return false;
}
@@ -670,14 +591,10 @@ namespace Vocaluxe.Base.Server
{
CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null)
- {
throw new ArgumentException("Invalid profileId");
- }
if (profile.PasswordHash == null)
- {
throw new ArgumentException("Emty password");
- }
return profile.PasswordSalt;
}
@@ -686,9 +603,7 @@ namespace Vocaluxe.Base.Server
{
CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null)
- {
throw new ArgumentException("Invalid profileId");
- }
//Hide TR_USERROLE_GUEST and TR_USERROLE_NORMAL
//const EUserRole mask = (EUserRole.TR_USERROLE_GUEST | EUserRole.TR_USERROLE_NORMAL);
@@ -700,9 +615,7 @@ namespace Vocaluxe.Base.Server
{
CProfile profile = CProfiles.GetProfile(profileId);
if (profile == null)
- {
throw new ArgumentException("Invalid profileId");
- }
var option = (EUserRole)userRole;
@@ -719,13 +632,11 @@ namespace Vocaluxe.Base.Server
private static int _GetUserIdFromUsername(string username)
{
- var playerIds = (from p in CProfiles.GetProfiles()
- where String.Equals(p.PlayerName, username, StringComparison.OrdinalIgnoreCase)
- select p.ID);
+ IEnumerable playerIds = (from p in CProfiles.GetProfiles()
+ where String.Equals(p.PlayerName, username, StringComparison.OrdinalIgnoreCase)
+ select p.ID);
if (!playerIds.Any())
- {
throw new ArgumentException("Invalid playername");
- }
return playerIds.First();
}
@@ -741,7 +652,6 @@ namespace Vocaluxe.Base.Server
return hashAlgo.ComputeHash(data);
}
-
#endregion
private static string _SaveImage(CBase64Image imageDate, string name, string folder)
@@ -750,24 +660,18 @@ namespace Vocaluxe.Base.Server
string extension = imageDate.GetImageType();
if (!Directory.Exists(folder))
- {
Directory.CreateDirectory(folder);
- }
string filename = Path.Combine(folder, name);
if (File.Exists(filename + "." + extension))
{
int i = 0;
while (File.Exists(filename + "_" + i + "." + extension))
- {
i++;
- }
filename = filename + "_" + i + "." + extension;
}
else
- {
filename = filename + "." + extension;
- }
avatarImage.Save(filename);
return filename;
diff --git a/Vocaluxe/CProgrammHelper.cs b/Vocaluxe/CProgrammHelper.cs
index de0a61a9..12cf6753 100644
--- a/Vocaluxe/CProgrammHelper.cs
+++ b/Vocaluxe/CProgrammHelper.cs
@@ -1,4 +1,21 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -11,7 +28,7 @@ using Vocaluxe.Base;
namespace Vocaluxe
{
///
- /// Some helper functions for the programm
+ /// Some helper functions for the programm
///
static class CProgrammHelper
{
@@ -37,7 +54,7 @@ namespace Vocaluxe
}
///
- /// Checks if a given program is installed by checking the Uninstall registry key.
+ /// Checks if a given program is installed by checking the Uninstall registry key.
///
/// Name of the programm. Got to equal the displayname in the key or one needs to be the start of the other one. NOT case sensitive.
///
diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs
index cf8048ef..11b11c21 100644
--- a/Vocaluxe/Lib/Draw/CDirect3D.cs
+++ b/Vocaluxe/Lib/Draw/CDirect3D.cs
@@ -65,10 +65,10 @@ namespace Vocaluxe.Lib.Draw
private int _Y;
private int _X;
- private int _BorderLeft = 0;
- private int _BorderRight = 0;
- private int _BorderTop = 0;
- private int _BorderBottom = 0;
+ private int _BorderLeft;
+ private int _BorderRight;
+ private int _BorderTop;
+ private int _BorderBottom;
private CTexture _BlankTexture;
@@ -416,7 +416,7 @@ namespace Vocaluxe.Lib.Draw
if (_Device.SetStreamSource(0, _VertexBuffer, 0, Marshal.SizeOf(typeof(STexturedColoredVertex))).IsFailure)
CLog.LogError("Failed to set stream source");
_Device.VertexDeclaration = STexturedColoredVertex.GetDeclaration(_Device);
-
+
if (_Device.SetRenderState(RenderState.CullMode, Cull.None).IsFailure)
CLog.LogError("Failed to set cull mode");
if (_Device.SetRenderState(RenderState.AlphaBlendEnable, true).IsFailure)
diff --git a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs
index 58d2f575..954cc6a7 100644
--- a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs
+++ b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs
@@ -1,18 +1,18 @@
#region license
-// This file is part of Vocaluxe.
+// This file is part of Vocaluxe.
//
-// Vocaluxe 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.
+// Vocaluxe 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.
//
-// Vocaluxe 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.
+// Vocaluxe 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 Vocaluxe. If not, see .
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
#endregion
using System;
diff --git a/Vocaluxe/Lib/Sound/CGstreamerAudio.cs b/Vocaluxe/Lib/Sound/CGstreamerAudio.cs
index d9aeea6e..e29937de 100644
--- a/Vocaluxe/Lib/Sound/CGstreamerAudio.cs
+++ b/Vocaluxe/Lib/Sound/CGstreamerAudio.cs
@@ -160,7 +160,6 @@ namespace Vocaluxe.Lib.Sound
CGstreamerAudioWrapper.Update();
}
-
public void FadeAndStop(int stream, float targetVolume, float seconds)
{
throw new NotImplementedException();
diff --git a/Vocaluxe/Lib/Sound/CGstreamerSharpAudio.cs b/Vocaluxe/Lib/Sound/CGstreamerSharpAudio.cs
index 3d5ace6e..b8270b32 100644
--- a/Vocaluxe/Lib/Sound/CGstreamerSharpAudio.cs
+++ b/Vocaluxe/Lib/Sound/CGstreamerSharpAudio.cs
@@ -1,11 +1,28 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Collections.Generic;
using Gst;
using GLib;
using System.Runtime.InteropServices;
using System.Diagnostics;
using Vocaluxe.Base;
-using Thread = System.Threading.Thread;
+using Thread = System.Threading.Thread;
namespace Vocaluxe.Lib.Sound
{
@@ -29,16 +46,14 @@ namespace Vocaluxe.Lib.Sound
Application.Init();
Registry reg = Registry.Get();
reg.ScanPath(path);
-
+
return Application.IsInitialized;
}
public void SetGlobalVolume(float volume)
{
foreach (CGstreamerSharpAudioStream stream in _Streams.Values)
- {
stream.Volume = volume;
- }
}
public int GetStreamCount()
@@ -49,9 +64,7 @@ namespace Vocaluxe.Lib.Sound
public void CloseAll()
{
foreach (CGstreamerSharpAudioStream stream in _Streams.Values)
- {
stream.Close();
- }
}
public int Load(string media)
@@ -61,7 +74,7 @@ namespace Vocaluxe.Lib.Sound
public int Load(string media, bool prescan)
{
- var stream = new CGstreamerSharpAudioStream (media, prescan);
+ var stream = new CGstreamerSharpAudioStream(media, prescan);
_Streams[_IDCount] = stream;
return _IDCount++;
}
@@ -188,16 +201,14 @@ namespace Vocaluxe.Lib.Sound
public void Update()
{
var streamsToDelete = new List();
- foreach (KeyValuePair stream in _Streams)
+ foreach (KeyValuePair stream in _Streams)
{
if (stream.Value.Closed)
streamsToDelete.Add(stream.Key);
stream.Value.Update();
}
foreach (int key in streamsToDelete)
- {
_Streams.Remove(key);
- }
}
private class CGstreamerSharpAudioStream
@@ -221,10 +232,11 @@ namespace Vocaluxe.Lib.Sound
private volatile float _Duration = -1f;
private volatile float _Position;
private volatile bool _QueryingDuration;
+
public CGstreamerSharpAudioStream(string media, bool prescan)
{
- var convert = ElementFactory.Make("audioconvert", "convert");
- var audiosink = ElementFactory.Make("directsoundsink", "audiosink");
+ Element convert = ElementFactory.Make("audioconvert", "convert");
+ Element audiosink = ElementFactory.Make("directsoundsink", "audiosink");
var audioSinkBin = new Bin("Audiosink");
if (convert == null || audiosink == null)
@@ -257,8 +269,8 @@ namespace Vocaluxe.Lib.Sound
// if it takes more than 500ms, duration queries will be performed asynchronously
if (prescan)
{
- var msg = _Element.Bus.TimedPopFiltered(0xffffffffffffffff, MessageType.AsyncDone);
- if(msg.Handle != IntPtr.Zero)
+ Message msg = _Element.Bus.TimedPopFiltered(0xffffffffffffffff, MessageType.AsyncDone);
+ if (msg.Handle != IntPtr.Zero)
_UpdateDuration();
}
}
@@ -274,7 +286,7 @@ namespace Vocaluxe.Lib.Sound
Position = 0;
else
Finished = true;
- Close();
+ Close();
break;
case MessageType.Error:
GException error;
@@ -289,18 +301,15 @@ namespace Vocaluxe.Lib.Sound
msg.Unref();
}
-
public void Close()
{
if (!Closed)
{
-
Closed = true;
Finished = true;
var t = new Thread(_TerminateStream);
t.Start();
}
-
}
private void _TerminateStream()
@@ -354,10 +363,7 @@ namespace Vocaluxe.Lib.Sound
public float Volume
{
- get
- {
- return _Element != null ? (float)(double)_Element["volume"] : 0;
- }
+ get { return _Element != null ? (float)(double)_Element["volume"] : 0; }
set
{
_Volume = value;
@@ -368,10 +374,7 @@ namespace Vocaluxe.Lib.Sound
public float MaxVolume
{
- get
- {
- return _MaxVolume;
- }
+ get { return _MaxVolume; }
set
{
_MaxVolume = value;
@@ -412,10 +415,7 @@ namespace Vocaluxe.Lib.Sound
public bool Paused
{
- get
- {
- return _Element == null || _Element.TargetState == State.Paused;
- }
+ get { return _Element == null || _Element.TargetState == State.Paused; }
set
{
if (value && _Element != null)
@@ -425,13 +425,10 @@ namespace Vocaluxe.Lib.Sound
public bool Playing
{
- get
- {
- return _Element != null && (_Element.TargetState == State.Playing && !Finished);
- }
+ get { return _Element != null && (_Element.TargetState == State.Playing && !Finished); }
set
{
- if(value && _Element != null)
+ if (value && _Element != null)
_Element.SetState(State.Playing);
}
}
@@ -439,9 +436,7 @@ namespace Vocaluxe.Lib.Sound
public void Update()
{
while (_Element != null && _Element.Bus != null && _Element.Bus.HavePending())
- {
_OnMessage(_Element.Bus.Pop());
- }
if (_Fading)
{
@@ -481,4 +476,4 @@ namespace Vocaluxe.Lib.Sound
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Vocaluxe/Lib/Sound/COpenALPlay.cs b/Vocaluxe/Lib/Sound/COpenALPlay.cs
index 131a7ff7..caecc663 100644
--- a/Vocaluxe/Lib/Sound/COpenALPlay.cs
+++ b/Vocaluxe/Lib/Sound/COpenALPlay.cs
@@ -346,7 +346,6 @@ namespace Vocaluxe.Lib.Sound
_Context = null;
}
-
public void FadeAndStop(int stream, float targetVolume, float seconds)
{
throw new NotImplementedException();
diff --git a/Vocaluxe/Lib/Video/Acinerella/CDecoder.cs b/Vocaluxe/Lib/Video/Acinerella/CDecoder.cs
index e922e565..9591eaaa 100644
--- a/Vocaluxe/Lib/Video/Acinerella/CDecoder.cs
+++ b/Vocaluxe/Lib/Video/Acinerella/CDecoder.cs
@@ -446,4 +446,4 @@ namespace Vocaluxe.Lib.Video.Acinerella
}
#endregion Threading
}
-}
+}
\ No newline at end of file
diff --git a/Vocaluxe/Lib/Video/IVideoDecoder.cs b/Vocaluxe/Lib/Video/IVideoDecoder.cs
index 72d12ecd..b1da1feb 100644
--- a/Vocaluxe/Lib/Video/IVideoDecoder.cs
+++ b/Vocaluxe/Lib/Video/IVideoDecoder.cs
@@ -22,57 +22,61 @@ namespace Vocaluxe.Lib.Video
interface IVideoDecoder
{
///
- /// Initializes videodecoder. Got to be called before usage
+ /// Initializes videodecoder. Got to be called before usage
///
/// True on success, false if something went wrong.
bool Init();
///
- /// Close all video streams
+ /// Close all video streams
///
void CloseAll();
///
- /// Loads the file with the given file path.
+ /// Loads the file with the given file path.
///
/// Absolute file path of the video file
/// StreamID >=0 on success or -1 on failure
int Load(string videoFileName);
///
- /// Closes the stream with the given ID
+ /// Closes the stream with the given ID
///
/// ID of the stream
/// true if stream was closed, false if stream doesn't exist or already closed
bool Close(int streamID);
///
- /// Gets the number of streams currently active
+ /// Gets the number of streams currently active
///
///
int GetNumStreams();
///
- /// Gets the length of the video in s
+ /// Gets the length of the video in s
///
/// Id of the stream
/// Length of the video in s
float GetLength(int streamID);
///
- /// Gets a frame of the video and sets the current video time
+ /// Gets a frame of the video and sets the current video time
///
/// Id of the stream
- /// Reference to already initialized video texture (from previous calls). If null, one will be created.
- /// Returns the current video frame which might be outdated if time != current (internal) video position or unchanged (even null) if none is available.
- /// The position in s of the video you want to get a frame of. If != current (internal) video position, it will seek to get to right position.
- /// Note:Will be ignored for looped playback!
+ ///
+ /// Reference to already initialized video texture (from previous calls). If null, one will be created.
+ /// Returns the current video frame which might be outdated if time != current (internal) video position or unchanged (even null) if none is available.
+ ///
+ ///
+ /// The position in s of the video you want to get a frame of. If != current (internal) video position, it will seek to get to right position.
+ /// Note:Will be ignored for looped playback!
+ ///
/// The actual position in s of the returned frame. Should be ~ time+VideoGap
/// True if frame is valid, false: frame and videoTime might be unchanged or invalid
bool GetFrame(int streamID, ref CTexture frame, float time, out float videoTime);
///
- /// Seeks to given position
+ /// Seeks to given position
///
/// Id of the stream
/// Position to seek to
@@ -81,33 +85,33 @@ namespace Vocaluxe.Lib.Video
bool Skip(int streamID, float start, float gap);
///
- /// Set if the video should be looped
+ /// Set if the video should be looped
///
/// Id of the stream
/// True if it should be looped
void SetLoop(int streamID, bool loop);
///
- /// Pauses the video (no new frames will be decoded)
+ /// Pauses the video (no new frames will be decoded)
///
/// Id of the stream
void Pause(int streamID);
///
- /// Resumes a paused video
+ /// Resumes a paused video
///
/// Id of the stream
void Resume(int streamID);
///
- /// Check if the given video is finished
+ /// Check if the given video is finished
///
/// Id of the stream
/// True if all frames are shown
bool Finished(int streamID);
///
- /// Do a step of the decoder in unthreaded decoders. Should be called once every frame.
+ /// Do a step of the decoder in unthreaded decoders. Should be called once every frame.
///
void Update();
}
diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs
index f85b67d9..5d254c13 100644
--- a/Vocaluxe/Program.cs
+++ b/Vocaluxe/Program.cs
@@ -326,9 +326,9 @@ namespace Vocaluxe
Process currentProcess = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName);
- foreach (var process in processes.Where(t => t.Id != currentProcess.Id))
+ foreach (Process process in processes.Where(t => t.Id != currentProcess.Id))
{
- var wnd = process.MainWindowHandle;
+ IntPtr wnd = process.MainWindowHandle;
if (wnd != IntPtr.Zero)
SetForegroundWindow(wnd);
}
diff --git a/Vocaluxe/Screens/CPopupScreenServerQR.cs b/Vocaluxe/Screens/CPopupScreenServerQR.cs
index fbf4a8e8..94ad9f74 100644
--- a/Vocaluxe/Screens/CPopupScreenServerQR.cs
+++ b/Vocaluxe/Screens/CPopupScreenServerQR.cs
@@ -52,8 +52,8 @@ namespace Vocaluxe.Screens
{
base.Init();
- _ThemeStatics = new string[] { _StaticQRServer, _StaticQRAndroid, _StaticQRSymbian, _StaticQRWebOS, _StaticQRWindowsPhone };
- _ThemeTexts = new string[] { _TextServerAddress, _TextServerNotRunning };
+ _ThemeStatics = new string[] {_StaticQRServer, _StaticQRAndroid, _StaticQRSymbian, _StaticQRWebOS, _StaticQRWindowsPhone};
+ _ThemeTexts = new string[] {_TextServerAddress, _TextServerNotRunning};
}
public override void LoadTheme(string xmlPath)
@@ -127,4 +127,4 @@ namespace Vocaluxe.Screens
_QRWindowsPhoneLink = CDraw.AddTexture(qrcode.GetGraphic(20));
}
}
-}
+}
\ No newline at end of file
diff --git a/Vocaluxe/Screens/CScreenOptionsVideo.cs b/Vocaluxe/Screens/CScreenOptionsVideo.cs
index 4e7d9a61..d1b446c8 100644
--- a/Vocaluxe/Screens/CScreenOptionsVideo.cs
+++ b/Vocaluxe/Screens/CScreenOptionsVideo.cs
@@ -146,7 +146,7 @@ namespace Vocaluxe.Screens
_SaveConfig();
if (_Buttons[_ButtonExit].Selected)
CGraphics.FadeTo(EScreens.ScreenOptions);
- if(_Buttons[_ButtonScreenAdjustments].Selected)
+ if (_Buttons[_ButtonScreenAdjustments].Selected)
CGraphics.FadeTo(EScreens.ScreenOptionsVideoAdjustments);
}
return true;
diff --git a/Vocaluxe/Screens/CScreenOptionsVideoAdjustments.cs b/Vocaluxe/Screens/CScreenOptionsVideoAdjustments.cs
index ff70fa43..774ef686 100644
--- a/Vocaluxe/Screens/CScreenOptionsVideoAdjustments.cs
+++ b/Vocaluxe/Screens/CScreenOptionsVideoAdjustments.cs
@@ -38,14 +38,14 @@ namespace Vocaluxe.Screens
{
base.Init();
- _ThemeButtons = new string[] { _ButtonExit };
+ _ThemeButtons = new string[] {_ButtonExit};
}
public override bool HandleInput(SKeyEvent keyEvent)
{
base.HandleInput(keyEvent);
- if (keyEvent.KeyPressed) { }
+ if (keyEvent.KeyPressed) {}
else
{
switch (keyEvent.Key)
@@ -102,4 +102,4 @@ namespace Vocaluxe.Screens
CConfig.SaveConfig();
}
}
-}
+}
\ No newline at end of file
diff --git a/Vocaluxe/Screens/CScreenProfiles.cs b/Vocaluxe/Screens/CScreenProfiles.cs
index 7e567a38..d3b06914 100644
--- a/Vocaluxe/Screens/CScreenProfiles.cs
+++ b/Vocaluxe/Screens/CScreenProfiles.cs
@@ -179,7 +179,7 @@ namespace Vocaluxe.Screens
else if (_SelectSlides[_SelectSlideUserRole].Selected)
{
CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex,
- (EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
+ (EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
}
else if (_SelectSlides[_SelectSlideActive].Selected)
{
@@ -228,7 +228,7 @@ namespace Vocaluxe.Screens
else if (_SelectSlides[_SelectSlideUserRole].Selected)
{
CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex,
- (EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
+ (EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
}
else if (_SelectSlides[_SelectSlideActive].Selected)
{
diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs
index b9a363aa..4eb21fbd 100644
--- a/Vocaluxe/Screens/CScreenSing.cs
+++ b/Vocaluxe/Screens/CScreenSing.cs
@@ -565,7 +565,7 @@ namespace Vocaluxe.Screens
}
CDraw.RemoveTexture(ref _Background);
- if(_SlideShow != null)
+ if (_SlideShow != null)
_SlideShow.RemoveSlideShowTextures();
_Lyrics[_LyricMain].Clear();
@@ -637,7 +637,7 @@ namespace Vocaluxe.Screens
if (song.BackgroundFileNames.Count > 1)
{
_SlideShow = GetNewBackground();
- foreach(string bgFile in song.BackgroundFileNames)
+ foreach (string bgFile in song.BackgroundFileNames)
_SlideShow.AddSlideShowTexture(Path.Combine(song.Folder, bgFile));
_Background = null;
}
@@ -887,7 +887,7 @@ namespace Vocaluxe.Screens
_Buttons[_ButtonContinue].Visible = false;
_Buttons[_ButtonSkip].Visible = false;
CSound.Play(_CurrentStream);
- if(_Webcam)
+ if (_Webcam)
CWebcam.Start();
}
}
@@ -1309,7 +1309,7 @@ namespace Vocaluxe.Screens
float currentTime = _CurrentTime - song.Start;
if (_Length < 0 && totalTime > 0)
- _PrepareTimeLine();
+ _PrepareTimeLine();
if (totalTime <= 0f)
return;
diff --git a/VocaluxeLib/CHelper.cs b/VocaluxeLib/CHelper.cs
index a0ad24d8..6d0bc3ae 100644
--- a/VocaluxeLib/CHelper.cs
+++ b/VocaluxeLib/CHelper.cs
@@ -161,7 +161,7 @@ namespace VocaluxeLib
return files;
}
- public static bool TryParse(string value, out T result, bool ignoreCase=false)
+ public static bool TryParse(string value, out T result, bool ignoreCase = false)
where T : struct
{
result = default(T);
diff --git a/VocaluxeLib/Extensions.cs b/VocaluxeLib/Extensions.cs
index d6c78529..8def331c 100644
--- a/VocaluxeLib/Extensions.cs
+++ b/VocaluxeLib/Extensions.cs
@@ -1,4 +1,21 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@@ -9,7 +26,7 @@ namespace VocaluxeLib
public static class Extensions
{
///
- /// Resizes the given list to the given size. Removes elements or adds default values
+ /// Resizes the given list to the given size. Removes elements or adds default values
///
///
///
@@ -25,7 +42,7 @@ namespace VocaluxeLib
}
///
- /// Makes the list at least the given size adding the given default values.
+ /// Makes the list at least the given size adding the given default values.
///
///
///
@@ -39,7 +56,7 @@ namespace VocaluxeLib
}
///
- /// Makes the list at least the given size adding a new instance of T
+ /// Makes the list at least the given size adding a new instance of T
///
///
///
@@ -51,7 +68,7 @@ namespace VocaluxeLib
}
///
- /// Gets all set bits starting from lowest (Bit 0)
+ /// Gets all set bits starting from lowest (Bit 0)
///
///
///
@@ -100,7 +117,7 @@ namespace VocaluxeLib
}
///
- /// Converts value to a string in fixed point notation using invariant formating (english style decimal point)
+ /// Converts value to a string in fixed point notation using invariant formating (english style decimal point)
///
/// Value to be converted
/// String representation of value
diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs
index 3c3725ad..682597b4 100644
--- a/VocaluxeLib/IBasic.cs
+++ b/VocaluxeLib/IBasic.cs
@@ -57,7 +57,7 @@ namespace VocaluxeLib
int GetMaxNumMics();
///
- /// Get the uniform settings for writing XML files. ALWAYS use this!
+ /// Get the uniform settings for writing XML files. ALWAYS use this!
///
XmlWriterSettings GetXMLSettings();
}
diff --git a/VocaluxeLib/Menu/CBackground.cs b/VocaluxeLib/Menu/CBackground.cs
index fe0943cf..b63de885 100644
--- a/VocaluxeLib/Menu/CBackground.cs
+++ b/VocaluxeLib/Menu/CBackground.cs
@@ -138,9 +138,7 @@ namespace VocaluxeLib.Menu
writer.WriteComment(": Texture name for slide-show");
for (int i = 0; i < _Theme.SlideShowTextures.Count; i++)
- {
writer.WriteElementString("SlideShow" + (i + 1), _Theme.SlideShowTextures[i]);
- }
writer.WriteComment(": Background color for type \"Color\" from ColorScheme (high priority)");
writer.WriteComment("or , , , (lower priority)");
@@ -193,9 +191,7 @@ namespace VocaluxeLib.Menu
if (_Theme.Type == EBackgroundTypes.SlideShow && _Theme.SlideShowTextures.Count > 0)
- {
ok = _DrawSlideShow();
- }
if (!String.IsNullOrEmpty(_Theme.TextureName) &&
(_Theme.Type == EBackgroundTypes.Texture ||
@@ -209,7 +205,10 @@ namespace VocaluxeLib.Menu
return true;
}
- public void UnloadTextures() { _SlideShowTextures.Clear(); }
+ public void UnloadTextures()
+ {
+ _SlideShowTextures.Clear();
+ }
public void LoadTextures()
{
@@ -226,7 +225,7 @@ namespace VocaluxeLib.Menu
if (!String.IsNullOrEmpty(image))
{
CTexture texture = CBase.Drawing.AddTexture(image);
- if(texture != null)
+ if (texture != null)
_SlideShowTextures.Add(texture);
}
}
@@ -273,7 +272,7 @@ namespace VocaluxeLib.Menu
private bool _DrawSlideShow()
{
- if (_SlideShowTextures.Count > 0)
+ if (_SlideShowTextures.Count > 0)
{
if (!_SlideShowTimer.IsRunning)
{
@@ -314,10 +313,10 @@ namespace VocaluxeLib.Menu
{
float alpha = (_SlideShowTimer.ElapsedMilliseconds - CBase.Settings.GetSlideShowImageTime()) / CBase.Settings.GetSlideShowFadeTime();
CHelper.SetRect(bounds, out rect, texture.OrigAspect, EAspect.Crop);
- CBase.Drawing.DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, (CBase.Settings.GetZFar() / 4) - 1), new SColorF(1,1,1, alpha));
+ CBase.Drawing.DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, (CBase.Settings.GetZFar() / 4) - 1), new SColorF(1, 1, 1, alpha));
}
}
-
+
return true;
}
return false;
diff --git a/VocaluxeLib/Menu/CLyric.cs b/VocaluxeLib/Menu/CLyric.cs
index 4c6366a8..f4315702 100644
--- a/VocaluxeLib/Menu/CLyric.cs
+++ b/VocaluxeLib/Menu/CLyric.cs
@@ -38,7 +38,7 @@ namespace VocaluxeLib.Menu
private bool _ThemeLoaded;
///
- /// Holds a reference to Songline. DO NOT MODIFY
+ /// Holds a reference to Songline. DO NOT MODIFY
///
private CSongLine _Line;
private CText _Text;
diff --git a/VocaluxeLib/Menu/CMenuPartyNameSelection.cs b/VocaluxeLib/Menu/CMenuPartyNameSelection.cs
index 95a7f972..1b8686a4 100644
--- a/VocaluxeLib/Menu/CMenuPartyNameSelection.cs
+++ b/VocaluxeLib/Menu/CMenuPartyNameSelection.cs
@@ -30,6 +30,7 @@ namespace VocaluxeLib.Menu
public int[] NumPlayerTeams;
public List[] TeamList;
}
+
public abstract class CMenuPartyNameSelection : CMenuParty
{
private bool _Teams;
@@ -40,7 +41,7 @@ namespace VocaluxeLib.Menu
protected bool _AllowChangeTeamNum = true;
protected bool _ChangePlayerNumDynamic = true;
protected bool _ChangeTeamNumDynamic = true;
- private int _CurrentTeam = 0;
+ private int _CurrentTeam;
private bool _AvatarsChanged;
private bool _ProfilesChanged;
@@ -70,9 +71,9 @@ namespace VocaluxeLib.Menu
public override void Init()
{
base.Init();
- _ThemeButtons = new string[] { _ButtonBack, _ButtonNext, _ButtonRandom, _ButtonIncreaseTeams, _ButtonDecreaseTeams, _ButtonIncreasePlayer, _ButtonDecreasePlayer };
- _ThemeSelectSlides = new string[] { _SelectSlideTeams, _SelectSlidePlayer };
- _ThemeNameSelections = new string[] { _NameSelection };
+ _ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonRandom, _ButtonIncreaseTeams, _ButtonDecreaseTeams, _ButtonIncreasePlayer, _ButtonDecreasePlayer};
+ _ThemeSelectSlides = new string[] {_SelectSlideTeams, _SelectSlidePlayer};
+ _ThemeNameSelections = new string[] {_NameSelection};
_ChooseAvatarStatic = GetNewStatic();
_ChooseAvatarStatic.Visible = false;
@@ -83,11 +84,11 @@ namespace VocaluxeLib.Menu
public void SetPartyModeData(int numPlayer)
{
- SetPartyModeData(1, numPlayer, new int[] { numPlayer });
+ SetPartyModeData(1, numPlayer, new int[] {numPlayer});
_CurrentTeam = 0;
}
- public void SetPartyModeData(int numTeams, int numPlayer, int[] numPlayerTeams)
+ public void SetPartyModeData(int numTeams, int numPlayer, int[] numPlayerTeams)
{
_NumTeams = numTeams;
_NumPlayer = numPlayer;
@@ -141,13 +142,14 @@ namespace VocaluxeLib.Menu
_AddPlayer(_CurrentTeam, _SelectedProfileID);
}
//Started selecting with 'P'
- if (_SelectingFast) {
+ if (_SelectingFast)
+ {
if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
resetSelection = true;
else if (_TeamList[_CurrentTeam].Count == _PartyMode.GetMaxPlayerPerTeam())
resetSelection = true;
}
- else if(!_SelectingFast)
+ else if (!_SelectingFast)
resetSelection = true;
break;
@@ -292,14 +294,15 @@ namespace VocaluxeLib.Menu
else if (_SelectSlides[_SelectSlidePlayer].Selected)
IncreasePlayerNum(_CurrentTeam);
break;
-
}
if (numPressed > 0)
{
if (_ChangeTeamNumDynamic && numPressed < _PartyMode.GetMaxTeams() && numPressed > _SelectSlides[_SelectSlideTeams].NumValues)
+ {
while (numPressed < _PartyMode.GetMaxTeams())
IncreaseTeamNum();
+ }
if (numPressed <= _SelectSlides[_SelectSlideTeams].NumValues)
_SelectSlides[_SelectSlideTeams].SetSelectionByValueIndex(numPressed - 1);
}
@@ -353,7 +356,7 @@ namespace VocaluxeLib.Menu
_OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y;
}
- // LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar
+ // LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar
else if (_SelectedProfileID >= 0 && !_SelectingFast)
{
//Check if mouse is in drop-area
@@ -439,7 +442,7 @@ namespace VocaluxeLib.Menu
else if (mouseEvent.RB)
{
bool exit = true;
- if (_SelectSlides[_SelectSlidePlayer].Selected && _TeamList[_CurrentTeam].Count > 0 )
+ if (_SelectSlides[_SelectSlidePlayer].Selected && _TeamList[_CurrentTeam].Count > 0)
{
int currentSelection = _SelectSlides[_SelectSlidePlayer].Selection;
int id = _TeamList[_CurrentTeam][currentSelection];
@@ -447,7 +450,7 @@ namespace VocaluxeLib.Menu
_UpdatePlayerSlide();
exit = false;
}
-
+
if (exit)
Back();
}
@@ -568,9 +571,7 @@ namespace VocaluxeLib.Menu
return;
if (_NumTeams - 1 >= _PartyMode.GetMinTeams())
- {
_NumTeams--;
- }
_UpdateButtonState();
}
@@ -601,9 +602,8 @@ namespace VocaluxeLib.Menu
}
_UpdateButtonState();
}
-
- #region private methods
+ #region private methods
private void _OnProfileChanged(EProfileChangedFlags flags)
{
if (EProfileChangedFlags.Avatar == (EProfileChangedFlags.Avatar & flags))
@@ -650,9 +650,7 @@ namespace VocaluxeLib.Menu
_SelectSlides[_SelectSlidePlayer].AddValue(name, avatar);
}
for (int i = _TeamList[_CurrentTeam].Count; i < _NumPlayerTeams[_CurrentTeam]; i++)
- {
_SelectSlides[_SelectSlidePlayer].AddValue("", _NameSelections[_NameSelection].TextureEmptyTile);
- }
if (selection >= _TeamList[_CurrentTeam].Count)
selection = _TeamList[_CurrentTeam].Count - 1;
_SelectSlides[_SelectSlidePlayer].SetSelectionByValueIndex(selection);
@@ -664,13 +662,12 @@ namespace VocaluxeLib.Menu
_SelectSlides[_SelectSlideTeams].Clear();
for (int i = 1; i <= _NumTeams; i++)
_SelectSlides[_SelectSlideTeams].AddValue("Team " + i);
-
}
private void _UpdateButtonVisibility()
{
- _Buttons[_ButtonIncreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.GetMinTeams() != _PartyMode.GetMaxTeams();
- _Buttons[_ButtonDecreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.GetMinTeams() != _PartyMode.GetMaxTeams();
+ _Buttons[_ButtonIncreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.GetMinTeams() != _PartyMode.GetMaxTeams();
+ _Buttons[_ButtonDecreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.GetMinTeams() != _PartyMode.GetMaxTeams();
_Buttons[_ButtonIncreasePlayer].Visible = _AllowChangePlayerNum;
_Buttons[_ButtonDecreasePlayer].Visible = _AllowChangePlayerNum;
}
@@ -711,9 +708,7 @@ namespace VocaluxeLib.Menu
List ids = new List();
ids.AddRange(_TeamList[t]);
for (int p = 0; p < ids.Count; p++)
- {
_RemovePlayer(t, ids[p]);
- }
}
}
@@ -745,7 +740,6 @@ namespace VocaluxeLib.Menu
}
}
}
-
- #endregion
+ #endregion
}
-}
+}
\ No newline at end of file
diff --git a/VocaluxeLib/Menu/CNameSelection.cs b/VocaluxeLib/Menu/CNameSelection.cs
index 9e08262b..301c2d04 100644
--- a/VocaluxeLib/Menu/CNameSelection.cs
+++ b/VocaluxeLib/Menu/CNameSelection.cs
@@ -376,7 +376,7 @@ namespace VocaluxeLib.Menu
_Player = player;
_PlayerSelector.Color = CBase.Theme.GetPlayerColor(player);
}
- //Normal activation
+ //Normal activation
else if (active)
{
Selection = 0;
@@ -385,7 +385,7 @@ namespace VocaluxeLib.Menu
_PlayerSelector.Color = CBase.Theme.GetPlayerColor(player);
_PlayerSelector.Visible = true;
}
- //Deactivate
+ //Deactivate
else
{
Selection = -1;
@@ -415,7 +415,8 @@ namespace VocaluxeLib.Menu
{
_Tiles[i].Avatar.Texture = CBase.Profiles.GetAvatar(_VisibleProfiles[i + offset * _Tiles.Count]);
_Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1);
- _Tiles[i].Name.Text = CBase.Profiles.GetPlayerName(_VisibleProfiles[i + offset * _Tiles.Count]); ;
+ _Tiles[i].Name.Text = CBase.Profiles.GetPlayerName(_VisibleProfiles[i + offset * _Tiles.Count]);
+ ;
_Tiles[i].ProfileID = _VisibleProfiles[i + offset * _Tiles.Count];
}
else
@@ -462,7 +463,7 @@ namespace VocaluxeLib.Menu
return new CStatic(_PartyModeID);
}
- public void UnloadTextures() { }
+ public void UnloadTextures() {}
public void LoadTextures()
{
@@ -486,12 +487,14 @@ namespace VocaluxeLib.Menu
public void UseProfile(int id)
{
- if(id > -1)
+ if (id > -1)
+ {
if (!_UsedProfiles.Contains(id) && CBase.Profiles.IsProfileIDValid(id) && !CBase.Profiles.IsGuest(id))
{
_UsedProfiles.Add(id);
UpdateList();
}
+ }
}
public void RemoveUsedProfile(int id)
@@ -513,7 +516,7 @@ namespace VocaluxeLib.Menu
if (_VisibleProfiles.Count == _UsedProfiles.Count)
return id;
- while(id == -1)
+ while (id == -1)
{
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
if (_UsedProfiles.Contains(_VisibleProfiles[rand]))
@@ -532,7 +535,7 @@ namespace VocaluxeLib.Menu
for (int j = 0; j < _NumW; j++)
{
var rect = new SRectF(Rect.X + j * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, Rect.Z);
- var tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, ColorEmptyTile, rect) { Aspect = EAspect.Crop };
+ var tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, ColorEmptyTile, rect) {Aspect = EAspect.Crop};
var tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.NameSpace, rect.Z, _Theme.NameHeight, rect.W, EAlignment.Center, _Theme.NameStyle,
_Theme.NameFont, _Theme.NameColor, "");
_Tiles.Add(new CTile(tileStatic, tileText, -1));
diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs
index 68ee6513..2beb4e95 100644
--- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs
+++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs
@@ -71,10 +71,7 @@ namespace VocaluxeLib.Menu.SongMenu
base._PreviewIdInternal = value;
_UpdatePreview();
}
- get
- {
- return base._PreviewIdInternal;
- }
+ get { return base._PreviewIdInternal; }
}
public override int GetActualSelection()
@@ -375,7 +372,7 @@ namespace VocaluxeLib.Menu.SongMenu
}
if (!keyEvent.Handled)
- {
+ {
_ActualSelection = _Locked;
if (_PreviewId != _Locked)
_PreviewId = _Locked;
diff --git a/VocaluxeLib/Profile/CAvatar.cs b/VocaluxeLib/Profile/CAvatar.cs
index 35aff61e..716884c6 100644
--- a/VocaluxeLib/Profile/CAvatar.cs
+++ b/VocaluxeLib/Profile/CAvatar.cs
@@ -1,18 +1,18 @@
#region license
-// This file is part of Vocaluxe.
+// This file is part of Vocaluxe.
//
-// Vocaluxe 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.
+// Vocaluxe 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.
//
-// Vocaluxe 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.
+// Vocaluxe 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 Vocaluxe. If not, see .
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
#endregion
using VocaluxeLib.Draw;
diff --git a/VocaluxeLib/Profile/CProfile.cs b/VocaluxeLib/Profile/CProfile.cs
index 4e27614c..7d4e2b54 100644
--- a/VocaluxeLib/Profile/CProfile.cs
+++ b/VocaluxeLib/Profile/CProfile.cs
@@ -121,7 +121,7 @@ namespace VocaluxeLib.Profile
string filename = string.Empty;
// ReSharper disable LoopCanBeConvertedToQuery
foreach (char chr in PlayerName)
- // ReSharper restore LoopCanBeConvertedToQuery
+ // ReSharper restore LoopCanBeConvertedToQuery
{
if (char.IsLetter(chr))
filename += chr.ToString();
@@ -166,13 +166,9 @@ namespace VocaluxeLib.Profile
writer.WriteElementString("UserRole", Enum.GetName(typeof(EUserRole), UserRole));
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), Active));
if (PasswordHash != null)
- {
writer.WriteElementString("PasswordHash", Convert.ToBase64String(PasswordHash));
- }
if (PasswordSalt != null)
- {
writer.WriteElementString("PasswordSalt", Convert.ToBase64String(PasswordSalt));
- }
writer.WriteEndElement();
writer.WriteEndElement(); //end of root
diff --git a/VocaluxeLib/Songs/CBaseNote.cs b/VocaluxeLib/Songs/CBaseNote.cs
index 45043aa7..271283c3 100644
--- a/VocaluxeLib/Songs/CBaseNote.cs
+++ b/VocaluxeLib/Songs/CBaseNote.cs
@@ -49,7 +49,7 @@ namespace VocaluxeLib.Songs
public int StartBeat { get; set; }
///
- /// Last beat of this note. First valid beat for a note after that is at EndBeat+1
+ /// Last beat of this note. First valid beat for a note after that is at EndBeat+1
///
public int EndBeat
{
diff --git a/VocaluxeLib/Songs/CLineBase.cs b/VocaluxeLib/Songs/CLineBase.cs
index 53826d83..16023f42 100644
--- a/VocaluxeLib/Songs/CLineBase.cs
+++ b/VocaluxeLib/Songs/CLineBase.cs
@@ -80,7 +80,7 @@ namespace VocaluxeLib.Songs
#region Methods
///
- /// Find last note with StartBeat
+ /// Find last note with StartBeat
///
///
/// Note index of last note with StartBeat or -1 if all notes start after beat
diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs
index 53d2dde8..e711cd94 100644
--- a/VocaluxeLib/Songs/CSong.cs
+++ b/VocaluxeLib/Songs/CSong.cs
@@ -134,21 +134,21 @@ namespace VocaluxeLib.Songs
public readonly List UnknownTags = new List();
///
- /// Start of the song in s (s in txt)
+ /// Start of the song in s (s in txt)
///
public float Start;
///
- /// End of the song in s (ms in txt)
+ /// End of the song in s (ms in txt)
///
public float Finish;
public float BPM = 1f;
///
- /// Gap of the mp3 in s (ms in txt)
+ /// Gap of the mp3 in s (ms in txt)
///
public float Gap;
///
- /// Gap of the video in s (s in txt)
+ /// Gap of the video in s (s in txt)
///
public float VideoGap;
@@ -194,7 +194,7 @@ namespace VocaluxeLib.Songs
}
///
- /// Returns true if the requested game mode is available
+ /// Returns true if the requested game mode is available
///
///
/// true if the requested game mode is available
diff --git a/VocaluxeLib/Songs/CSongLoader.cs b/VocaluxeLib/Songs/CSongLoader.cs
index 26e1dea1..98ba075c 100644
--- a/VocaluxeLib/Songs/CSongLoader.cs
+++ b/VocaluxeLib/Songs/CSongLoader.cs
@@ -1,4 +1,21 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.IO;
using System.Linq;
using System.Text;
@@ -6,12 +23,12 @@ using System.Text;
namespace VocaluxeLib.Songs
{
///
- /// Part of CSong that is required for note loading
+ /// Part of CSong that is required for note loading
///
public partial class CSong
{
///
- /// Factor the bpm given in the txt is multiplied with
+ /// Factor the bpm given in the txt is multiplied with
///
private const int _BPMFactor = 4;
@@ -54,7 +71,7 @@ namespace VocaluxeLib.Songs
}
///
- /// Logs a given message with file name and line#
+ /// Logs a given message with file name and line#
///
/// Message
/// True prepends "Error: "; False prepends "Warning: "
@@ -470,9 +487,9 @@ namespace VocaluxeLib.Songs
private const int _MaxOverlapNoteCt = 3;
///
- /// Read notes. First try to read notes normally (assume standard)
- /// If there are more than _MaxZeroNoteCt with length < 1, try to read notes adding 1 to length
- /// Then if there are more than _MaxOverlapNoteCt fallback to first version ignoring notes with length < 1
+ /// Read notes. First try to read notes normally (assume standard)
+ /// If there are more than _MaxZeroNoteCt with length < 1, try to read notes adding 1 to length
+ /// Then if there are more than _MaxOverlapNoteCt fallback to first version ignoring notes with length < 1
///
///
///
diff --git a/VocaluxeLib/Songs/CSongWriter.cs b/VocaluxeLib/Songs/CSongWriter.cs
index 9d7328b7..1e3221d8 100644
--- a/VocaluxeLib/Songs/CSongWriter.cs
+++ b/VocaluxeLib/Songs/CSongWriter.cs
@@ -1,4 +1,21 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Collections.Generic;
using System.IO;
diff --git a/VocaluxeLib/Songs/CVoice.cs b/VocaluxeLib/Songs/CVoice.cs
index 47433e95..27aaeae0 100644
--- a/VocaluxeLib/Songs/CVoice.cs
+++ b/VocaluxeLib/Songs/CVoice.cs
@@ -69,7 +69,7 @@ namespace VocaluxeLib.Songs
#region Methods
///
- /// Find last line with StartBeat
+ /// Find last line with StartBeat
///
///
///
@@ -128,7 +128,7 @@ namespace VocaluxeLib.Songs
{
CSongLine prevLine = _Lines[insPos];
//We already have a line break here
- if (prevLine.StartBeat == startBeat && (prevLine.NoteCount==0 || prevLine.FirstNoteBeat == startBeat))
+ if (prevLine.StartBeat == startBeat && (prevLine.NoteCount == 0 || prevLine.FirstNoteBeat == startBeat))
return false;
//Maybe we have to split the previous line
while (prevLine.NoteCount > 0 && prevLine.LastNote.StartBeat >= startBeat)
diff --git a/WebserverInitalConfig/CConfigHttpApi.cs b/WebserverInitalConfig/CConfigHttpApi.cs
index 40bc79d0..4bbd3ed9 100644
--- a/WebserverInitalConfig/CConfigHttpApi.cs
+++ b/WebserverInitalConfig/CConfigHttpApi.cs
@@ -1,4 +1,21 @@
-using Security.Cryptography;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using Security.Cryptography;
using Security.Cryptography.X509Certificates;
using System;
using System.Linq;
@@ -11,7 +28,7 @@ namespace WebserverInitalConfig
{
public static class CConfigHttpApi
{
-// ReSharper disable InconsistentNaming
+ // ReSharper disable InconsistentNaming
private const String CLSID_NetFwMgr = "{304CE942-6E39-40D8-943A-B913C40C9CD4}";
private const String CLSID_NetAuthApp = "{EC9846B3-2762-4A6B-A214-6ACB603462D2}";
private const String CLSID_NetOpenPort = "{0CA545C6-37AD-4A6C-BF92-9F7610067EF5}";
@@ -21,46 +38,39 @@ namespace WebserverInitalConfig
HttpApi.ReserveURL(networkString, "D:(A;;GX;;;S-1-1-0)");
}
-
public static void BindCert(string ip, int port, X509Certificate2 cert)
{
IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(ip), port);
if (HttpApi.QuerySslCertificateInfo(endpoint) != null)
- {
HttpApi.DeleteCertificateBinding(endpoint);
- }
HttpApi.BindCertificate(endpoint, cert.GetCertHash(), StoreName.My, new Guid("{7baf41f1-48b7-42cb-b145-f815499cb48f}"));
}
-
public static void AddCertToStore(X509Certificate2 cert)
{
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadWrite);
X509Certificate2Collection oldCerts = store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName,
- cert.SubjectName.Name, false);
+ cert.SubjectName.Name, false);
- foreach (var oldCert in oldCerts)
- {
+ foreach (X509Certificate2 oldCert in oldCerts)
store.Remove(oldCert);
- }
store.Add(cert);
store.Close();
}
-
public static X509Certificate2 GetSelfSignedCert(string subjectName)
{
var keyParam = new CngKeyCreationParameters
- {
- ExportPolicy = CngExportPolicies.AllowExport,
- KeyCreationOptions = CngKeyCreationOptions.MachineKey | CngKeyCreationOptions.OverwriteExistingKey,
- KeyUsage = CngKeyUsages.AllUsages,
- Provider = CngProvider.MicrosoftSoftwareKeyStorageProvider,
- };
+ {
+ ExportPolicy = CngExportPolicies.AllowExport,
+ KeyCreationOptions = CngKeyCreationOptions.MachineKey | CngKeyCreationOptions.OverwriteExistingKey,
+ KeyUsage = CngKeyUsages.AllUsages,
+ Provider = CngProvider.MicrosoftSoftwareKeyStorageProvider,
+ };
keyParam.Parameters.Add(new CngProperty("Length", BitConverter.GetBytes(2048), CngPropertyOptions.None));
@@ -69,7 +79,7 @@ namespace WebserverInitalConfig
X509CertificateCreationParameters param = new X509CertificateCreationParameters(new X500DistinguishedName(subjectName))
{
SubjectName = new X500DistinguishedName(subjectName),
- EndTime = DateTime.Today.AddYears(20)//,SignatureAlgorithm = X509CertificateSignatureAlgorithm.RsaSha512
+ EndTime = DateTime.Today.AddYears(20) //,SignatureAlgorithm = X509CertificateSignatureAlgorithm.RsaSha512
};
OidCollection oc = new OidCollection {new Oid("1.3.6.1.5.5.7.3.1")};
@@ -117,7 +127,7 @@ namespace WebserverInitalConfig
openPort.Enabled = true;
openPort.Port = port;
openPort.Protocol = protocol;
- openPort.Name = "Vocaluxe("+port+")";
+ openPort.Name = "Vocaluxe(" + port + ")";
openPort.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_ALL;
openPorts.Add(openPort);
@@ -134,6 +144,7 @@ namespace WebserverInitalConfig
_AddFirewallRuleForProfile(manage.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_STANDARD), exePath, port, isTCP);
_AddFirewallRuleForProfile(manage.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_CURRENT), exePath, port, isTCP);
}
+
/*public static X509Certificate2 getCert(string subject)
{
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
@@ -157,4 +168,4 @@ namespace WebserverInitalConfig
return new X509Certificate2(x509.Sign(rsa));
}*/
}
-}
+}
\ No newline at end of file
diff --git a/WebserverInitalConfig/HttpApi.cs b/WebserverInitalConfig/HttpApi.cs
index 29f1994a..c248f8b6 100644
--- a/WebserverInitalConfig/HttpApi.cs
+++ b/WebserverInitalConfig/HttpApi.cs
@@ -1,4 +1,21 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
@@ -11,28 +28,19 @@ using System.Threading.Tasks;
namespace WebserverInitalConfig
{
- internal static class HttpApi
+ static class HttpApi
{
private static readonly HTTPAPI_VERSION HttpApiVersion = new HTTPAPI_VERSION(1, 0);
#region DllImport
-
[DllImport("httpapi.dll", SetLastError = true)]
- static extern uint HttpInitialize(
+ private static extern uint HttpInitialize(
HTTPAPI_VERSION version,
uint flags,
IntPtr pReserved);
[DllImport("httpapi.dll", SetLastError = true)]
- static extern uint HttpSetServiceConfiguration(
- IntPtr serviceIntPtr,
- HTTP_SERVICE_CONFIG_ID configId,
- IntPtr pConfigInformation,
- int configInformationLength,
- IntPtr pOverlapped);
-
- [DllImport("httpapi.dll", SetLastError = true)]
- static extern uint HttpDeleteServiceConfiguration(
+ private static extern uint HttpSetServiceConfiguration(
IntPtr serviceIntPtr,
HTTP_SERVICE_CONFIG_ID configId,
IntPtr pConfigInformation,
@@ -40,26 +48,31 @@ namespace WebserverInitalConfig
IntPtr pOverlapped);
[DllImport("httpapi.dll", SetLastError = true)]
- static extern uint HttpTerminate(
+ private static extern uint HttpDeleteServiceConfiguration(
+ IntPtr serviceIntPtr,
+ HTTP_SERVICE_CONFIG_ID configId,
+ IntPtr pConfigInformation,
+ int configInformationLength,
+ IntPtr pOverlapped);
+
+ [DllImport("httpapi.dll", SetLastError = true)]
+ private static extern uint HttpTerminate(
uint Flags,
IntPtr pReserved);
[DllImport("httpapi.dll", SetLastError = true)]
- static extern uint HttpQueryServiceConfiguration(
- IntPtr serviceIntPtr,
- HTTP_SERVICE_CONFIG_ID configId,
- IntPtr pInputConfigInfo,
- int inputConfigInfoLength,
- IntPtr pOutputConfigInfo,
- int outputConfigInfoLength,
- [Optional]
- out int pReturnLength,
- IntPtr pOverlapped);
+ private static extern uint HttpQueryServiceConfiguration(
+ IntPtr serviceIntPtr,
+ HTTP_SERVICE_CONFIG_ID configId,
+ IntPtr pInputConfigInfo,
+ int inputConfigInfoLength,
+ IntPtr pOutputConfigInfo,
+ int outputConfigInfoLength,
+ [Optional] out int pReturnLength,
+ IntPtr pOverlapped);
-
- enum HTTP_SERVICE_CONFIG_ID
+ private enum HTTP_SERVICE_CONFIG_ID
{
-
HttpServiceConfigIPListenList = 0,
HttpServiceConfigSSLCertInfo,
HttpServiceConfigUrlAclInfo,
@@ -67,14 +80,14 @@ namespace WebserverInitalConfig
}
[StructLayout(LayoutKind.Sequential)]
- struct HTTP_SERVICE_CONFIG_SSL_SET
+ private struct HTTP_SERVICE_CONFIG_SSL_SET
{
public HTTP_SERVICE_CONFIG_SSL_KEY KeyDesc;
public HTTP_SERVICE_CONFIG_SSL_PARAM ParamDesc;
}
[StructLayout(LayoutKind.Sequential)]
- struct HTTP_SERVICE_CONFIG_SSL_KEY
+ private struct HTTP_SERVICE_CONFIG_SSL_KEY
{
public IntPtr pIpPort;
@@ -85,25 +98,22 @@ namespace WebserverInitalConfig
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- struct HTTP_SERVICE_CONFIG_SSL_PARAM
+ private struct HTTP_SERVICE_CONFIG_SSL_PARAM
{
public int SslHashLength;
public IntPtr pSslHash;
public Guid AppId;
- [MarshalAs(UnmanagedType.LPWStr)]
- public string pSslCertStoreName;
+ [MarshalAs(UnmanagedType.LPWStr)] public string pSslCertStoreName;
public uint DefaultCertCheckMode;
public int DefaultRevocationFreshnessTime;
public int DefaultRevocationUrlRetrievalTimeout;
- [MarshalAs(UnmanagedType.LPWStr)]
- public string pDefaultSslCtlIdentifier;
- [MarshalAs(UnmanagedType.LPWStr)]
- public string pDefaultSslCtlStoreName;
+ [MarshalAs(UnmanagedType.LPWStr)] public string pDefaultSslCtlIdentifier;
+ [MarshalAs(UnmanagedType.LPWStr)] public string pDefaultSslCtlStoreName;
public uint DefaultFlags;
}
[StructLayout(LayoutKind.Sequential, Pack = 2)]
- struct HTTPAPI_VERSION
+ private struct HTTPAPI_VERSION
{
public ushort HttpApiMajorVersion;
public ushort HttpApiMinorVersion;
@@ -116,14 +126,14 @@ namespace WebserverInitalConfig
}
[StructLayout(LayoutKind.Sequential)]
- struct HTTP_SERVICE_CONFIG_SSL_QUERY
+ private struct HTTP_SERVICE_CONFIG_SSL_QUERY
{
public HTTP_SERVICE_CONFIG_QUERY_TYPE QueryDesc;
public HTTP_SERVICE_CONFIG_SSL_KEY KeyDesc;
public uint dwToken;
}
- enum HTTP_SERVICE_CONFIG_QUERY_TYPE
+ private enum HTTP_SERVICE_CONFIG_QUERY_TYPE
{
HttpServiceConfigQueryExact = 0,
HttpServiceConfigQueryNext,
@@ -131,7 +141,7 @@ namespace WebserverInitalConfig
}
[StructLayout(LayoutKind.Sequential)]
- struct HTTP_SERVICE_CONFIG_URLACL_SET
+ private struct HTTP_SERVICE_CONFIG_URLACL_SET
{
public HTTP_SERVICE_CONFIG_URLACL_KEY KeyDesc;
public HTTP_SERVICE_CONFIG_URLACL_PARAM ParamDesc;
@@ -140,8 +150,7 @@ namespace WebserverInitalConfig
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HTTP_SERVICE_CONFIG_URLACL_KEY
{
- [MarshalAs(UnmanagedType.LPWStr)]
- public string pUrlPrefix;
+ [MarshalAs(UnmanagedType.LPWStr)] public string pUrlPrefix;
public HTTP_SERVICE_CONFIG_URLACL_KEY(string urlPrefix)
{
@@ -150,21 +159,18 @@ namespace WebserverInitalConfig
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- struct HTTP_SERVICE_CONFIG_URLACL_PARAM
+ private struct HTTP_SERVICE_CONFIG_URLACL_PARAM
{
- [MarshalAs(UnmanagedType.LPWStr)]
- public string pStringSecurityDescriptor;
+ [MarshalAs(UnmanagedType.LPWStr)] public string pStringSecurityDescriptor;
public HTTP_SERVICE_CONFIG_URLACL_PARAM(string securityDescriptor)
{
pStringSecurityDescriptor = securityDescriptor;
}
}
-
#endregion
#region Constants
-
public const uint HTTP_INITIALIZE_CONFIG = 0x00000002;
public const uint HTTP_SERVICE_CONFIG_SSL_FLAG_NEGOTIATE_CLIENT_CERT = 0x00000002;
public const uint HTTP_SERVICE_CONFIG_SSL_FLAG_NO_RAW_FILTER = 0x00000004;
@@ -173,11 +179,9 @@ namespace WebserverInitalConfig
private const uint ERROR_ALREADY_EXISTS = 183;
private const uint ERROR_FILE_NOT_FOUND = 2;
private const int ERROR_NO_MORE_ITEMS = 259;
-
#endregion
#region Public methods
-
public class SslCertificateInfo
{
public byte[] Hash { get; set; }
@@ -192,162 +196,158 @@ namespace WebserverInitalConfig
uint retVal;
CallHttpApi(delegate
- {
- GCHandle sockAddrHandle = CreateSockaddrStructure(ipPort);
- IntPtr pIpPort = sockAddrHandle.AddrOfPinnedObject();
- HTTP_SERVICE_CONFIG_SSL_KEY sslKey = new HTTP_SERVICE_CONFIG_SSL_KEY(pIpPort);
-
- HTTP_SERVICE_CONFIG_SSL_QUERY inputConfigInfoQuery =
- new HTTP_SERVICE_CONFIG_SSL_QUERY
- {
- QueryDesc = HTTP_SERVICE_CONFIG_QUERY_TYPE.HttpServiceConfigQueryExact,
- KeyDesc = sslKey
- };
-
- IntPtr pInputConfigInfo =
- Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_QUERY)));
- Marshal.StructureToPtr(inputConfigInfoQuery, pInputConfigInfo, false);
-
- IntPtr pOutputConfigInfo = IntPtr.Zero;
- int returnLength = 0;
-
- try
{
- HTTP_SERVICE_CONFIG_ID queryType = HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo;
- int inputConfigInfoSize = Marshal.SizeOf(inputConfigInfoQuery);
- retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
- queryType,
- pInputConfigInfo,
- inputConfigInfoSize,
- pOutputConfigInfo,
- returnLength,
- out returnLength,
- IntPtr.Zero);
- if (retVal == ERROR_FILE_NOT_FOUND)
- return;
+ GCHandle sockAddrHandle = CreateSockaddrStructure(ipPort);
+ IntPtr pIpPort = sockAddrHandle.AddrOfPinnedObject();
+ HTTP_SERVICE_CONFIG_SSL_KEY sslKey = new HTTP_SERVICE_CONFIG_SSL_KEY(pIpPort);
- if (ERROR_INSUFFICIENT_BUFFER == retVal) // ERROR_INSUFFICIENT_BUFFER = 122
+ HTTP_SERVICE_CONFIG_SSL_QUERY inputConfigInfoQuery =
+ new HTTP_SERVICE_CONFIG_SSL_QUERY
+ {
+ QueryDesc = HTTP_SERVICE_CONFIG_QUERY_TYPE.HttpServiceConfigQueryExact,
+ KeyDesc = sslKey
+ };
+
+ IntPtr pInputConfigInfo =
+ Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_QUERY)));
+ Marshal.StructureToPtr(inputConfigInfoQuery, pInputConfigInfo, false);
+
+ IntPtr pOutputConfigInfo = IntPtr.Zero;
+ int returnLength = 0;
+
+ try
{
- pOutputConfigInfo = Marshal.AllocCoTaskMem(returnLength);
+ HTTP_SERVICE_CONFIG_ID queryType = HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo;
+ int inputConfigInfoSize = Marshal.SizeOf(inputConfigInfoQuery);
+ retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
+ queryType,
+ pInputConfigInfo,
+ inputConfigInfoSize,
+ pOutputConfigInfo,
+ returnLength,
+ out returnLength,
+ IntPtr.Zero);
+ if (retVal == ERROR_FILE_NOT_FOUND)
+ return;
- try
+ if (ERROR_INSUFFICIENT_BUFFER == retVal) // ERROR_INSUFFICIENT_BUFFER = 122
{
- retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
- queryType,
- pInputConfigInfo,
- inputConfigInfoSize,
- pOutputConfigInfo,
- returnLength,
- out returnLength,
- IntPtr.Zero);
+ pOutputConfigInfo = Marshal.AllocCoTaskMem(returnLength);
+
+ try
+ {
+ retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
+ queryType,
+ pInputConfigInfo,
+ inputConfigInfoSize,
+ pOutputConfigInfo,
+ returnLength,
+ out returnLength,
+ IntPtr.Zero);
+ ThrowWin32ExceptionIfError(retVal);
+
+ var outputConfigInfo =
+ (HTTP_SERVICE_CONFIG_SSL_SET)
+ Marshal.PtrToStructure(pOutputConfigInfo, typeof(HTTP_SERVICE_CONFIG_SSL_SET));
+
+ byte[] hash = new byte[outputConfigInfo.ParamDesc.SslHashLength];
+ Marshal.Copy(outputConfigInfo.ParamDesc.pSslHash, hash, 0, hash.Length);
+
+ Guid appId = outputConfigInfo.ParamDesc.AppId;
+ string storeName = outputConfigInfo.ParamDesc.pSslCertStoreName;
+
+ result = new SslCertificateInfo {AppId = appId, Hash = hash, StoreName = storeName, IpPort = ipPort};
+ }
+ finally
+ {
+ Marshal.FreeCoTaskMem(pOutputConfigInfo);
+ }
+ }
+ else
ThrowWin32ExceptionIfError(retVal);
-
- var outputConfigInfo =
- (HTTP_SERVICE_CONFIG_SSL_SET)
- Marshal.PtrToStructure(pOutputConfigInfo, typeof(HTTP_SERVICE_CONFIG_SSL_SET));
-
- byte[] hash = new byte[outputConfigInfo.ParamDesc.SslHashLength];
- Marshal.Copy(outputConfigInfo.ParamDesc.pSslHash, hash, 0, hash.Length);
-
- Guid appId = outputConfigInfo.ParamDesc.AppId;
- string storeName = outputConfigInfo.ParamDesc.pSslCertStoreName;
-
- result = new SslCertificateInfo { AppId = appId, Hash = hash, StoreName = storeName, IpPort = ipPort };
- }
- finally
- {
- Marshal.FreeCoTaskMem(pOutputConfigInfo);
- }
}
- else
+ finally
{
- ThrowWin32ExceptionIfError(retVal);
+ Marshal.FreeCoTaskMem(pInputConfigInfo);
+ if (sockAddrHandle.IsAllocated)
+ sockAddrHandle.Free();
}
-
- }
- finally
- {
- Marshal.FreeCoTaskMem(pInputConfigInfo);
- if (sockAddrHandle.IsAllocated)
- sockAddrHandle.Free();
- }
-
- });
+ });
return result;
}
public static void BindCertificate(IPEndPoint ipPort, byte[] hash, StoreName storeName, Guid appId)
{
- if (ipPort == null) throw new ArgumentNullException("ipPort");
- if (hash == null) throw new ArgumentNullException("hash");
+ if (ipPort == null)
+ throw new ArgumentNullException("ipPort");
+ if (hash == null)
+ throw new ArgumentNullException("hash");
CallHttpApi(
delegate
- {
- HTTP_SERVICE_CONFIG_SSL_SET configSslSet = new HTTP_SERVICE_CONFIG_SSL_SET();
-
- GCHandle sockAddrHandle = CreateSockaddrStructure(ipPort);
- IntPtr pIpPort = sockAddrHandle.AddrOfPinnedObject();
- HTTP_SERVICE_CONFIG_SSL_KEY httpServiceConfigSslKey =
- new HTTP_SERVICE_CONFIG_SSL_KEY(pIpPort);
- HTTP_SERVICE_CONFIG_SSL_PARAM configSslParam = new HTTP_SERVICE_CONFIG_SSL_PARAM();
-
-
- GCHandle handleHash = GCHandle.Alloc(hash, GCHandleType.Pinned);
- configSslParam.AppId = appId;
- configSslParam.DefaultCertCheckMode = 0;
- configSslParam.DefaultFlags = 0; //HTTP_SERVICE_CONFIG_SSL_FLAG_NEGOTIATE_CLIENT_CERT;
- configSslParam.DefaultRevocationFreshnessTime = 0;
- configSslParam.DefaultRevocationUrlRetrievalTimeout = 0;
- configSslParam.pSslCertStoreName = storeName.ToString();
- configSslParam.pSslHash = handleHash.AddrOfPinnedObject();
- configSslParam.SslHashLength = hash.Length;
- configSslSet.ParamDesc = configSslParam;
- configSslSet.KeyDesc = httpServiceConfigSslKey;
-
- IntPtr pInputConfigInfo =
- Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_SET)));
- Marshal.StructureToPtr(configSslSet, pInputConfigInfo, false);
-
- try
{
- uint retVal = HttpSetServiceConfiguration(IntPtr.Zero,
- HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo,
- pInputConfigInfo,
- Marshal.SizeOf(configSslSet),
- IntPtr.Zero);
+ HTTP_SERVICE_CONFIG_SSL_SET configSslSet = new HTTP_SERVICE_CONFIG_SSL_SET();
- if (ERROR_ALREADY_EXISTS != retVal)
- {
- ThrowWin32ExceptionIfError(retVal);
- }
- else
- {
- retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
- HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo,
- pInputConfigInfo,
- Marshal.SizeOf(configSslSet),
- IntPtr.Zero);
- ThrowWin32ExceptionIfError(retVal);
+ GCHandle sockAddrHandle = CreateSockaddrStructure(ipPort);
+ IntPtr pIpPort = sockAddrHandle.AddrOfPinnedObject();
+ HTTP_SERVICE_CONFIG_SSL_KEY httpServiceConfigSslKey =
+ new HTTP_SERVICE_CONFIG_SSL_KEY(pIpPort);
+ HTTP_SERVICE_CONFIG_SSL_PARAM configSslParam = new HTTP_SERVICE_CONFIG_SSL_PARAM();
- retVal = HttpSetServiceConfiguration(IntPtr.Zero,
- HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo,
- pInputConfigInfo,
- Marshal.SizeOf(configSslSet),
- IntPtr.Zero);
- ThrowWin32ExceptionIfError(retVal);
+
+ GCHandle handleHash = GCHandle.Alloc(hash, GCHandleType.Pinned);
+ configSslParam.AppId = appId;
+ configSslParam.DefaultCertCheckMode = 0;
+ configSslParam.DefaultFlags = 0; //HTTP_SERVICE_CONFIG_SSL_FLAG_NEGOTIATE_CLIENT_CERT;
+ configSslParam.DefaultRevocationFreshnessTime = 0;
+ configSslParam.DefaultRevocationUrlRetrievalTimeout = 0;
+ configSslParam.pSslCertStoreName = storeName.ToString();
+ configSslParam.pSslHash = handleHash.AddrOfPinnedObject();
+ configSslParam.SslHashLength = hash.Length;
+ configSslSet.ParamDesc = configSslParam;
+ configSslSet.KeyDesc = httpServiceConfigSslKey;
+
+ IntPtr pInputConfigInfo =
+ Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_SET)));
+ Marshal.StructureToPtr(configSslSet, pInputConfigInfo, false);
+
+ try
+ {
+ uint retVal = HttpSetServiceConfiguration(IntPtr.Zero,
+ HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo,
+ pInputConfigInfo,
+ Marshal.SizeOf(configSslSet),
+ IntPtr.Zero);
+
+ if (ERROR_ALREADY_EXISTS != retVal)
+ ThrowWin32ExceptionIfError(retVal);
+ else
+ {
+ retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
+ HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo,
+ pInputConfigInfo,
+ Marshal.SizeOf(configSslSet),
+ IntPtr.Zero);
+ ThrowWin32ExceptionIfError(retVal);
+
+ retVal = HttpSetServiceConfiguration(IntPtr.Zero,
+ HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo,
+ pInputConfigInfo,
+ Marshal.SizeOf(configSslSet),
+ IntPtr.Zero);
+ ThrowWin32ExceptionIfError(retVal);
+ }
}
- }
- finally
- {
- Marshal.FreeCoTaskMem(pInputConfigInfo);
- if (handleHash.IsAllocated)
- handleHash.Free();
- if (sockAddrHandle.IsAllocated)
- sockAddrHandle.Free();
- }
- });
+ finally
+ {
+ Marshal.FreeCoTaskMem(pInputConfigInfo);
+ if (handleHash.IsAllocated)
+ handleHash.Free();
+ if (sockAddrHandle.IsAllocated)
+ sockAddrHandle.Free();
+ }
+ });
}
public static void DeleteCertificateBinding(params IPEndPoint[] ipPorts)
@@ -356,41 +356,41 @@ namespace WebserverInitalConfig
return;
CallHttpApi(
- delegate
- {
- foreach (var ipPort in ipPorts)
- {
- HTTP_SERVICE_CONFIG_SSL_SET configSslSet =
- new HTTP_SERVICE_CONFIG_SSL_SET();
-
- GCHandle sockAddrHandle = CreateSockaddrStructure(ipPort);
- IntPtr pIpPort = sockAddrHandle.AddrOfPinnedObject();
- HTTP_SERVICE_CONFIG_SSL_KEY httpServiceConfigSslKey =
- new HTTP_SERVICE_CONFIG_SSL_KEY(pIpPort);
- configSslSet.KeyDesc = httpServiceConfigSslKey;
-
- IntPtr pInputConfigInfo =
- Marshal.AllocCoTaskMem(
- Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_SET)));
- Marshal.StructureToPtr(configSslSet, pInputConfigInfo, false);
-
- try
+ delegate
{
- uint retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
- HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo,
- pInputConfigInfo,
- Marshal.SizeOf(configSslSet),
- IntPtr.Zero);
- ThrowWin32ExceptionIfError(retVal);
- }
- finally
- {
- Marshal.FreeCoTaskMem(pInputConfigInfo);
- if (sockAddrHandle.IsAllocated)
- sockAddrHandle.Free();
- }
- }
- });
+ foreach (IPEndPoint ipPort in ipPorts)
+ {
+ HTTP_SERVICE_CONFIG_SSL_SET configSslSet =
+ new HTTP_SERVICE_CONFIG_SSL_SET();
+
+ GCHandle sockAddrHandle = CreateSockaddrStructure(ipPort);
+ IntPtr pIpPort = sockAddrHandle.AddrOfPinnedObject();
+ HTTP_SERVICE_CONFIG_SSL_KEY httpServiceConfigSslKey =
+ new HTTP_SERVICE_CONFIG_SSL_KEY(pIpPort);
+ configSslSet.KeyDesc = httpServiceConfigSslKey;
+
+ IntPtr pInputConfigInfo =
+ Marshal.AllocCoTaskMem(
+ Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_SET)));
+ Marshal.StructureToPtr(configSslSet, pInputConfigInfo, false);
+
+ try
+ {
+ uint retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
+ HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo,
+ pInputConfigInfo,
+ Marshal.SizeOf(configSslSet),
+ IntPtr.Zero);
+ ThrowWin32ExceptionIfError(retVal);
+ }
+ finally
+ {
+ Marshal.FreeCoTaskMem(pInputConfigInfo);
+ if (sockAddrHandle.IsAllocated)
+ sockAddrHandle.Free();
+ }
+ }
+ });
}
public static SslCertificateInfo[] QuerySslCertificateInfo()
@@ -399,193 +399,186 @@ namespace WebserverInitalConfig
CallHttpApi(
delegate
- {
- uint token = 0;
-
- uint retVal;
- do
{
- HTTP_SERVICE_CONFIG_SSL_QUERY inputConfigInfoQuery =
- new HTTP_SERVICE_CONFIG_SSL_QUERY
- {
- QueryDesc = HTTP_SERVICE_CONFIG_QUERY_TYPE.HttpServiceConfigQueryNext,
- dwToken = token,
- };
+ uint token = 0;
- IntPtr pInputConfigInfo =
- Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_QUERY)));
- Marshal.StructureToPtr(inputConfigInfoQuery, pInputConfigInfo, false);
-
- IntPtr pOutputConfigInfo = IntPtr.Zero;
- int returnLength = 0;
-
- const HTTP_SERVICE_CONFIG_ID queryType = HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo;
-
- try
+ uint retVal;
+ do
{
- int inputConfigInfoSize = Marshal.SizeOf(inputConfigInfoQuery);
- retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
- queryType,
- pInputConfigInfo,
- inputConfigInfoSize,
- pOutputConfigInfo,
- returnLength,
- out returnLength,
- IntPtr.Zero);
- if (ERROR_NO_MORE_ITEMS == retVal)
- break;
- if (ERROR_INSUFFICIENT_BUFFER == retVal) // ERROR_INSUFFICIENT_BUFFER = 122
- {
- pOutputConfigInfo = Marshal.AllocCoTaskMem(returnLength);
-
- try
- {
- retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
- queryType,
- pInputConfigInfo,
- inputConfigInfoSize,
- pOutputConfigInfo,
- returnLength,
- out returnLength,
- IntPtr.Zero);
- ThrowWin32ExceptionIfError(retVal);
-
- var outputConfigInfo = (HTTP_SERVICE_CONFIG_SSL_SET)Marshal.PtrToStructure(
- pOutputConfigInfo, typeof(HTTP_SERVICE_CONFIG_SSL_SET));
-
- byte[] hash = new byte[outputConfigInfo.ParamDesc.SslHashLength];
- Marshal.Copy(outputConfigInfo.ParamDesc.pSslHash, hash, 0, hash.Length);
-
- Guid appId = outputConfigInfo.ParamDesc.AppId;
- string storeName = outputConfigInfo.ParamDesc.pSslCertStoreName;
- IPEndPoint ipPort = ReadSockaddrStructure(outputConfigInfo.KeyDesc.pIpPort);
-
- var resultItem = new SslCertificateInfo
+ HTTP_SERVICE_CONFIG_SSL_QUERY inputConfigInfoQuery =
+ new HTTP_SERVICE_CONFIG_SSL_QUERY
{
- AppId = appId,
- Hash = hash,
- StoreName = storeName,
- IpPort = ipPort
+ QueryDesc = HTTP_SERVICE_CONFIG_QUERY_TYPE.HttpServiceConfigQueryNext,
+ dwToken = token,
};
- result.Add(resultItem);
- token++;
- }
- finally
- {
- Marshal.FreeCoTaskMem(pOutputConfigInfo);
- }
- }
- else
+
+ IntPtr pInputConfigInfo =
+ Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_QUERY)));
+ Marshal.StructureToPtr(inputConfigInfoQuery, pInputConfigInfo, false);
+
+ IntPtr pOutputConfigInfo = IntPtr.Zero;
+ int returnLength = 0;
+
+ const HTTP_SERVICE_CONFIG_ID queryType = HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo;
+
+ try
{
- ThrowWin32ExceptionIfError(retVal);
+ int inputConfigInfoSize = Marshal.SizeOf(inputConfigInfoQuery);
+ retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
+ queryType,
+ pInputConfigInfo,
+ inputConfigInfoSize,
+ pOutputConfigInfo,
+ returnLength,
+ out returnLength,
+ IntPtr.Zero);
+ if (ERROR_NO_MORE_ITEMS == retVal)
+ break;
+ if (ERROR_INSUFFICIENT_BUFFER == retVal) // ERROR_INSUFFICIENT_BUFFER = 122
+ {
+ pOutputConfigInfo = Marshal.AllocCoTaskMem(returnLength);
+
+ try
+ {
+ retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
+ queryType,
+ pInputConfigInfo,
+ inputConfigInfoSize,
+ pOutputConfigInfo,
+ returnLength,
+ out returnLength,
+ IntPtr.Zero);
+ ThrowWin32ExceptionIfError(retVal);
+
+ var outputConfigInfo = (HTTP_SERVICE_CONFIG_SSL_SET)Marshal.PtrToStructure(
+ pOutputConfigInfo, typeof(HTTP_SERVICE_CONFIG_SSL_SET));
+
+ byte[] hash = new byte[outputConfigInfo.ParamDesc.SslHashLength];
+ Marshal.Copy(outputConfigInfo.ParamDesc.pSslHash, hash, 0, hash.Length);
+
+ Guid appId = outputConfigInfo.ParamDesc.AppId;
+ string storeName = outputConfigInfo.ParamDesc.pSslCertStoreName;
+ IPEndPoint ipPort = ReadSockaddrStructure(outputConfigInfo.KeyDesc.pIpPort);
+
+ var resultItem = new SslCertificateInfo
+ {
+ AppId = appId,
+ Hash = hash,
+ StoreName = storeName,
+ IpPort = ipPort
+ };
+ result.Add(resultItem);
+ token++;
+ }
+ finally
+ {
+ Marshal.FreeCoTaskMem(pOutputConfigInfo);
+ }
+ }
+ else
+ ThrowWin32ExceptionIfError(retVal);
}
- }
- finally
- {
- Marshal.FreeCoTaskMem(pInputConfigInfo);
- }
-
- } while (NOERROR == retVal);
-
- });
+ finally
+ {
+ Marshal.FreeCoTaskMem(pInputConfigInfo);
+ }
+ } while (NOERROR == retVal);
+ });
return result.ToArray();
}
public static void ReserveURL(string networkURL, string securityDescriptor)
{
- if (String.IsNullOrEmpty(networkURL)) throw new ArgumentNullException("networkURL");
- if (String.IsNullOrEmpty(securityDescriptor)) throw new ArgumentNullException("securityDescriptor");
+ if (String.IsNullOrEmpty(networkURL))
+ throw new ArgumentNullException("networkURL");
+ if (String.IsNullOrEmpty(securityDescriptor))
+ throw new ArgumentNullException("securityDescriptor");
CallHttpApi(
delegate
- {
- uint retVal = (uint)NOERROR; // NOERROR = 0
-
- HTTP_SERVICE_CONFIG_URLACL_KEY keyDesc = new HTTP_SERVICE_CONFIG_URLACL_KEY(networkURL);
- HTTP_SERVICE_CONFIG_URLACL_PARAM paramDesc = new HTTP_SERVICE_CONFIG_URLACL_PARAM(securityDescriptor);
-
- HTTP_SERVICE_CONFIG_URLACL_SET inputConfigInfoSet = new HTTP_SERVICE_CONFIG_URLACL_SET();
- inputConfigInfoSet.KeyDesc = keyDesc;
- inputConfigInfoSet.ParamDesc = paramDesc;
-
- IntPtr pInputConfigInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));
- Marshal.StructureToPtr(inputConfigInfoSet, pInputConfigInfo, false);
- try
{
- retVal = HttpApi.HttpSetServiceConfiguration(IntPtr.Zero,
- HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
- pInputConfigInfo,
- Marshal.SizeOf(inputConfigInfoSet),
- IntPtr.Zero);
+ uint retVal = (uint)NOERROR; // NOERROR = 0
- if ((uint)ERROR_ALREADY_EXISTS == retVal) // ERROR_ALREADY_EXISTS = 183
+ HTTP_SERVICE_CONFIG_URLACL_KEY keyDesc = new HTTP_SERVICE_CONFIG_URLACL_KEY(networkURL);
+ HTTP_SERVICE_CONFIG_URLACL_PARAM paramDesc = new HTTP_SERVICE_CONFIG_URLACL_PARAM(securityDescriptor);
+
+ HTTP_SERVICE_CONFIG_URLACL_SET inputConfigInfoSet = new HTTP_SERVICE_CONFIG_URLACL_SET();
+ inputConfigInfoSet.KeyDesc = keyDesc;
+ inputConfigInfoSet.ParamDesc = paramDesc;
+
+ IntPtr pInputConfigInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));
+ Marshal.StructureToPtr(inputConfigInfoSet, pInputConfigInfo, false);
+ try
{
- retVal = HttpApi.HttpDeleteServiceConfiguration(IntPtr.Zero,
- HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
- pInputConfigInfo,
- Marshal.SizeOf(inputConfigInfoSet),
- IntPtr.Zero);
+ retVal = HttpSetServiceConfiguration(IntPtr.Zero,
+ HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
+ pInputConfigInfo,
+ Marshal.SizeOf(inputConfigInfoSet),
+ IntPtr.Zero);
- if ((uint)NOERROR == retVal)
+ if (ERROR_ALREADY_EXISTS == retVal) // ERROR_ALREADY_EXISTS = 183
{
- retVal = HttpApi.HttpSetServiceConfiguration(IntPtr.Zero,
- HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
- pInputConfigInfo,
- Marshal.SizeOf(inputConfigInfoSet),
- IntPtr.Zero);
- }
- else if ((uint)ERROR_FILE_NOT_FOUND == retVal) // ERROR_FILE_NOT_FOUND = 2
- {
- string networkURLOld = networkURL.Contains("https") ? networkURL.Replace("https", "http") :
- networkURL.Replace("http", "https");
- HTTP_SERVICE_CONFIG_URLACL_KEY keyDescOld = new HTTP_SERVICE_CONFIG_URLACL_KEY(networkURLOld);
- HTTP_SERVICE_CONFIG_URLACL_PARAM paramDescOld = new HTTP_SERVICE_CONFIG_URLACL_PARAM(securityDescriptor);
+ retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
+ HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
+ pInputConfigInfo,
+ Marshal.SizeOf(inputConfigInfoSet),
+ IntPtr.Zero);
- HTTP_SERVICE_CONFIG_URLACL_SET inputConfigInfoSetOld = new HTTP_SERVICE_CONFIG_URLACL_SET();
- inputConfigInfoSetOld.KeyDesc = keyDescOld;
- inputConfigInfoSetOld.ParamDesc = paramDescOld;
-
- IntPtr pInputConfigInfoOld = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));
- Marshal.StructureToPtr(inputConfigInfoSetOld, pInputConfigInfoOld, false);
-
- retVal = HttpApi.HttpDeleteServiceConfiguration(IntPtr.Zero,
- HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
- pInputConfigInfoOld,
- Marshal.SizeOf(inputConfigInfoSetOld),
- IntPtr.Zero);
-
- if ((uint)NOERROR == retVal)
+ if (NOERROR == retVal)
{
- retVal = HttpApi.HttpSetServiceConfiguration(IntPtr.Zero,
- HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
- pInputConfigInfo,
- Marshal.SizeOf(inputConfigInfoSet),
- IntPtr.Zero);
+ retVal = HttpSetServiceConfiguration(IntPtr.Zero,
+ HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
+ pInputConfigInfo,
+ Marshal.SizeOf(inputConfigInfoSet),
+ IntPtr.Zero);
+ }
+ else if (ERROR_FILE_NOT_FOUND == retVal) // ERROR_FILE_NOT_FOUND = 2
+ {
+ string networkURLOld = networkURL.Contains("https") ? networkURL.Replace("https", "http") :
+ networkURL.Replace("http", "https");
+ HTTP_SERVICE_CONFIG_URLACL_KEY keyDescOld = new HTTP_SERVICE_CONFIG_URLACL_KEY(networkURLOld);
+ HTTP_SERVICE_CONFIG_URLACL_PARAM paramDescOld = new HTTP_SERVICE_CONFIG_URLACL_PARAM(securityDescriptor);
+
+ HTTP_SERVICE_CONFIG_URLACL_SET inputConfigInfoSetOld = new HTTP_SERVICE_CONFIG_URLACL_SET();
+ inputConfigInfoSetOld.KeyDesc = keyDescOld;
+ inputConfigInfoSetOld.ParamDesc = paramDescOld;
+
+ IntPtr pInputConfigInfoOld = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));
+ Marshal.StructureToPtr(inputConfigInfoSetOld, pInputConfigInfoOld, false);
+
+ retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
+ HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
+ pInputConfigInfoOld,
+ Marshal.SizeOf(inputConfigInfoSetOld),
+ IntPtr.Zero);
+
+ if (NOERROR == retVal)
+ {
+ retVal = HttpSetServiceConfiguration(IntPtr.Zero,
+ HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
+ pInputConfigInfo,
+ Marshal.SizeOf(inputConfigInfoSet),
+ IntPtr.Zero);
+ }
}
}
- }
- }
- finally
- {
- Marshal.FreeCoTaskMem(pInputConfigInfo);
- HttpApi.HttpTerminate(HttpApi.HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
- }
- if ((uint)NOERROR != retVal)
- {
- ThrowWin32ExceptionIfError(retVal);
- }
- });
+ }
+ finally
+ {
+ Marshal.FreeCoTaskMem(pInputConfigInfo);
+ HttpTerminate(HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
+ }
+ if (NOERROR != retVal)
+ ThrowWin32ExceptionIfError(retVal);
+ });
}
-
#endregion
private static void ThrowWin32ExceptionIfError(uint retVal)
{
if (NOERROR != retVal)
- {
throw new Win32Exception(Convert.ToInt32(retVal));
- }
}
private static void CallHttpApi(Action body)
@@ -604,7 +597,7 @@ namespace WebserverInitalConfig
}
///
- /// Creates an unmanaged sockaddr structure to pass to a WinAPI function.
+ /// Creates an unmanaged sockaddr structure to pass to a WinAPI function.
///
/// IP address and port number
/// a handle for the structure. Use the AddrOfPinnedObject Method to get a stable pointer to the object.
@@ -617,14 +610,12 @@ namespace WebserverInitalConfig
byte[] sockAddrStructureBytes = new byte[socketAddress.Size];
GCHandle sockAddrHandle = GCHandle.Alloc(sockAddrStructureBytes, GCHandleType.Pinned);
for (int i = 0; i < socketAddress.Size; ++i)
- {
sockAddrStructureBytes[i] = socketAddress[i];
- }
return sockAddrHandle;
}
///
- /// Reads the unmanaged sockaddr structure returned by a WinAPI function
+ /// Reads the unmanaged sockaddr structure returned by a WinAPI function
///
/// pointer to the unmanaged sockaddr structure
/// IP address and port number
@@ -659,9 +650,7 @@ namespace WebserverInitalConfig
// create SocketAddress from bytes
var socketAddress = new SocketAddress(AddressFamily.Unspecified, sockAddrSructureSize);
for (int i = 0; i < sockAddrSructureSize; i++)
- {
socketAddress[i] = sockAddrSructureBytes[i];
- }
// create IPEndPoint from SocketAddress
IPEndPoint result = (IPEndPoint)ipEndPointAny.Create(socketAddress);
@@ -669,4 +658,4 @@ namespace WebserverInitalConfig
return result;
}
}
-}
+}
\ No newline at end of file
diff --git a/WebserverInitalConfig/Program.cs b/WebserverInitalConfig/Program.cs
index 0e9deb54..4b7ce630 100644
--- a/WebserverInitalConfig/Program.cs
+++ b/WebserverInitalConfig/Program.cs
@@ -1,12 +1,30 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.IO;
using System.Net;
+using System.Security.Cryptography.X509Certificates;
namespace WebserverInitalConfig
{
class Program
{
- static void Main(string[] args)
+ private static void Main(string[] args)
{
if (args.Length != 2)
{
@@ -14,22 +32,18 @@ namespace WebserverInitalConfig
Environment.Exit(-1);
}
- CConfigHttpApi.AddFirewallRule(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Vocaluxe.exe"), Int32.Parse(args[0]), true);
+ CConfigHttpApi.AddFirewallRule(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Vocaluxe.exe"), Int32.Parse(args[0]), true);
if (args[1].ToLower() == "true")
{
string hostname = Dns.GetHostName();
- var cert = CConfigHttpApi.GetSelfSignedCert("CN=" + hostname + " C=DE O=Vocaluxe OU=Vocaluxe Server");
+ X509Certificate2 cert = CConfigHttpApi.GetSelfSignedCert("CN=" + hostname + " C=DE O=Vocaluxe OU=Vocaluxe Server");
CConfigHttpApi.AddCertToStore(cert);
CConfigHttpApi.BindCert("0.0.0.0", Int32.Parse(args[0]), cert);
CConfigHttpApi.ReserveUrl("https://+:" + args[0] + "/");
}
else
- {
CConfigHttpApi.ReserveUrl("http://+:" + args[0] + "/");
- }
}
-
-
}
-}
+}
\ No newline at end of file
diff --git a/WebserverInitalConfig/Properties/AssemblyInfo.cs b/WebserverInitalConfig/Properties/AssemblyInfo.cs
index 4b7d7a28..4665bfa0 100644
--- a/WebserverInitalConfig/Properties/AssemblyInfo.cs
+++ b/WebserverInitalConfig/Properties/AssemblyInfo.cs
@@ -1,10 +1,28 @@
-using System.Reflection;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe 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.
+//
+// Vocaluxe 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 Vocaluxe. If not, see .
+#endregion
+
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
+
[assembly: AssemblyTitle("Vocaluxe Server Config")]
[assembly: AssemblyDescription("Configures your computer to run the Vocaluxe Server")]
[assembly: AssemblyConfiguration("")]
@@ -17,9 +35,11 @@ using System.Runtime.InteropServices;
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+
[assembly: Guid("b2df9255-3927-4125-ab3c-23c35794b04d")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
@@ -32,5 +52,6 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
+
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file