commit
aad3c8147f
71 files changed
+1486
-2367
No files matched your search
+5
-1
@@ -58,4 +58,8 @@ Output/Vocaluxe_x64.exe
|
|||||||
/WebserverInitalConfig/bin/Release
|
/WebserverInitalConfig/bin/Release
|
||||||
/Output/Photos
|
/Output/Photos
|
||||||
/Output/Screenshots
|
/Output/Screenshots
|
||||||
/Output/Website
|
/Output/Website
|
||||||
|
/Output/VocaluxeServerConfig.exe
|
||||||
|
/Output/VocaluxeServerConfig.exe.config
|
||||||
|
/PhoneGap/
|
||||||
|
/Output/Profiles
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -10,116 +27,115 @@ using System.Timers;
|
|||||||
|
|
||||||
namespace ServerLib
|
namespace ServerLib
|
||||||
{
|
{
|
||||||
public delegate void OnServerDiscovered(string IPAddress, string Hostname);
|
public delegate void OnServerDiscovered(string IPAddress, string Hostname);
|
||||||
|
|
||||||
public class CDiscover
|
public class CDiscover
|
||||||
{
|
{
|
||||||
public static readonly string sTimeout = "Timeout";
|
public static readonly string sTimeout = "Timeout";
|
||||||
public static readonly string sFinished = "Finished";
|
public static readonly string sFinished = "Finished";
|
||||||
|
|
||||||
private string _Keyword;
|
private string _Keyword;
|
||||||
private string _BroadcastAddress;
|
private string _BroadcastAddress;
|
||||||
private int _Port;
|
private int _Port;
|
||||||
|
|
||||||
private Thread _DiscoverThread;
|
private Thread _DiscoverThread;
|
||||||
private bool _DiscoverRunning;
|
private bool _DiscoverRunning;
|
||||||
private OnServerDiscovered _OnDiscovered;
|
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")
|
_DiscoverRunning = false;
|
||||||
{
|
_BroadcastTimer = new System.Timers.Timer();
|
||||||
_BroadcastAddress = BroadcastAddress;
|
_BroadcastTimer.Elapsed += OnBroadcastEvent;
|
||||||
_Port = Port;
|
_BroadcastTimer.Interval = 2500;
|
||||||
_Keyword = Keyword;
|
}
|
||||||
|
|
||||||
_DiscoverRunning = false;
|
public void StartBroadcasting()
|
||||||
_BroadcastTimer = new System.Timers.Timer();
|
{
|
||||||
_BroadcastTimer.Elapsed += new ElapsedEventHandler(OnBroadcastEvent);
|
_BroadcastTimer.Start();
|
||||||
_BroadcastTimer.Interval = 2500;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void StartBroadcasting()
|
public void Stop()
|
||||||
{
|
{
|
||||||
_BroadcastTimer.Start();
|
_BroadcastTimer.Stop();
|
||||||
}
|
_DiscoverRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Discover(OnServerDiscovered OnDiscovered, int Timeout = 5000)
|
||||||
{
|
{
|
||||||
_BroadcastTimer.Stop();
|
if (_DiscoverRunning)
|
||||||
_DiscoverRunning = false;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
public void Discover(OnServerDiscovered OnDiscovered, int Timeout = 5000)
|
_DiscoverRunning = true;
|
||||||
{
|
_DiscoverThread = new Thread(() => _Discover(Timeout));
|
||||||
if (_DiscoverRunning)
|
_OnDiscovered = OnDiscovered;
|
||||||
return;
|
_DiscoverThread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
_DiscoverRunning = true;
|
private void OnBroadcastEvent(object source, ElapsedEventArgs e)
|
||||||
_DiscoverThread = new Thread(() => _Discover(Timeout));
|
{
|
||||||
_OnDiscovered = OnDiscovered;
|
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||||
_DiscoverThread.Start();
|
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)
|
s.SendTo(sendbuf, ep);
|
||||||
{
|
s.Close();
|
||||||
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);
|
private void _Discover(int Timeout)
|
||||||
s.Close();
|
{
|
||||||
}
|
UdpClient listener = null;
|
||||||
|
Stopwatch timer = new Stopwatch();
|
||||||
|
|
||||||
private void _Discover(int Timeout)
|
List<string> knownServer = new List<string>();
|
||||||
{
|
bool foundSomething = false;
|
||||||
UdpClient listener = null;
|
timer.Start();
|
||||||
Stopwatch timer = new Stopwatch();
|
while (_DiscoverRunning && timer.ElapsedMilliseconds < Timeout * 2)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
listener = new UdpClient(_Port);
|
||||||
|
IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, _Port);
|
||||||
|
listener.Client.ReceiveTimeout = Timeout;
|
||||||
|
|
||||||
List<string> knownServer = new List<string>();
|
byte[] bytes = listener.Receive(ref groupEP);
|
||||||
bool foundSomething = false;
|
string message = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
|
||||||
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);
|
foundSomething = true;
|
||||||
string message = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
|
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;
|
_OnDiscovered(groupEP.Address.ToString(), hostname);
|
||||||
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);
|
listener.Close();
|
||||||
}
|
}
|
||||||
}
|
catch (Exception)
|
||||||
|
{
|
||||||
|
if (listener != null)
|
||||||
|
listener.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_DiscoverRunning = false;
|
||||||
|
|
||||||
listener.Close();
|
if (!foundSomething)
|
||||||
}
|
_OnDiscovered(sTimeout, String.Empty);
|
||||||
catch (Exception)
|
else
|
||||||
{
|
_OnDiscovered(sFinished, String.Empty);
|
||||||
if (listener != null)
|
}
|
||||||
listener.Close();
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_DiscoverRunning = false;
|
|
||||||
|
|
||||||
if (!foundSomething)
|
|
||||||
_OnDiscovered(sTimeout, String.Empty);
|
|
||||||
else
|
|
||||||
_OnDiscovered(sFinished, String.Empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.ServiceModel;
|
using System.ServiceModel;
|
||||||
using System.ServiceModel.Web;
|
using System.ServiceModel.Web;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -10,194 +27,66 @@ namespace ServerLib
|
|||||||
{
|
{
|
||||||
private ServiceHost _Host;
|
private ServiceHost _Host;
|
||||||
private Uri _BaseAddress;
|
private Uri _BaseAddress;
|
||||||
private bool _Encrypted = false;
|
private bool _Encrypted;
|
||||||
|
|
||||||
private static SendKeyEventDelegate _SendKeyEvent;
|
public static SendKeyEventDelegate SendKeyEvent { internal get; set; }
|
||||||
public static SendKeyEventDelegate SendKeyEvent
|
|
||||||
{
|
|
||||||
internal get { return CServer._SendKeyEvent; }
|
|
||||||
set { CServer._SendKeyEvent = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#region profile
|
#region profile
|
||||||
|
public static GetProfileDataDelegate GetProfileData { internal get; set; }
|
||||||
|
|
||||||
private static GetProfileDataDelegate _GetProfileData;
|
public static SendProfileDataDelegate SendProfileData { internal get; set; }
|
||||||
public static GetProfileDataDelegate GetProfileData
|
|
||||||
{
|
|
||||||
internal get { return CServer._GetProfileData; }
|
|
||||||
set { CServer._GetProfileData = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static SendProfileDataDelegate _SendProfileData;
|
|
||||||
public static SendProfileDataDelegate SendProfileData
|
|
||||||
{
|
|
||||||
internal get { return CServer._SendProfileData; }
|
|
||||||
set { CServer._SendProfileData = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GetProfileListDelegate _GetProfileList;
|
|
||||||
public static GetProfileListDelegate GetProfileList
|
|
||||||
{
|
|
||||||
internal get { return CServer._GetProfileList; }
|
|
||||||
set { CServer._GetProfileList = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static GetProfileListDelegate GetProfileList { internal get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region photo
|
#region photo
|
||||||
private static SendPhotoDelegate _SendPhoto;
|
public static SendPhotoDelegate SendPhoto { get; set; }
|
||||||
public static SendPhotoDelegate SendPhoto
|
|
||||||
{
|
|
||||||
get { return CServer._SendPhoto; }
|
|
||||||
set { CServer._SendPhoto = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region website
|
#region website
|
||||||
|
public static GetSiteFileDelegate GetSiteFile { internal get; set; }
|
||||||
|
|
||||||
private static GetSiteFileDelegate _GetSiteFile;
|
public static GetDelayedImageDelegate GetDelayedImage { internal get; set; }
|
||||||
public static GetSiteFileDelegate GetSiteFile
|
|
||||||
{
|
|
||||||
internal get { return CServer._GetSiteFile; }
|
|
||||||
set { CServer._GetSiteFile = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GetDelayedImageDelegate _GetDelayedImage;
|
|
||||||
public static GetDelayedImageDelegate GetDelayedImage
|
|
||||||
{
|
|
||||||
internal get { return CServer._GetDelayedImage; }
|
|
||||||
set { CServer._GetDelayedImage = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region songs
|
#region songs
|
||||||
|
public static GetSongDelegate GetSong { internal get; set; }
|
||||||
|
|
||||||
private static GetSongDelegate _GetSong;
|
public static GetAllSongsDelegate GetAllSongs { internal get; set; }
|
||||||
public static GetSongDelegate GetSong
|
|
||||||
{
|
|
||||||
internal get { return CServer._GetSong; }
|
|
||||||
set { CServer._GetSong = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GetAllSongsDelegate _GetAllSongs;
|
|
||||||
public static GetAllSongsDelegate GetAllSongs
|
|
||||||
{
|
|
||||||
internal get { return CServer._GetAllSongs; }
|
|
||||||
set { CServer._GetAllSongs = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GetCurrentSongIdDelegate _GetCurrentSongId;
|
|
||||||
public static GetCurrentSongIdDelegate GetCurrentSongId
|
|
||||||
{
|
|
||||||
internal get { return CServer._GetCurrentSongId; }
|
|
||||||
set { CServer._GetCurrentSongId = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
public static GetCurrentSongIdDelegate GetCurrentSongId { internal get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region playlist
|
#region playlist
|
||||||
|
public static GetPlaylistsDelegate GetPlaylists { internal get; set; }
|
||||||
|
|
||||||
private static GetPlaylistsDelegate _GetPlaylists;
|
public static GetPlaylistDelegate GetPlaylist { internal get; set; }
|
||||||
public static GetPlaylistsDelegate GetPlaylists
|
|
||||||
{
|
|
||||||
internal get { return _GetPlaylists; }
|
|
||||||
set { _GetPlaylists = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static AddSongToPlaylistDelegate AddSongToPlaylist { internal get; set; }
|
||||||
|
|
||||||
private static GetPlaylistDelegate _GetPlaylist;
|
public static RemoveSongFromPlaylistDelegate RemoveSongFromPlaylist { internal get; set; }
|
||||||
public static GetPlaylistDelegate GetPlaylist
|
|
||||||
{
|
|
||||||
internal get { return _GetPlaylist; }
|
|
||||||
set { _GetPlaylist = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AddSongToPlaylistDelegate _AddSongToPlaylist;
|
public static MoveSongInPlaylistDelegate MoveSongInPlaylist { internal get; set; }
|
||||||
public static AddSongToPlaylistDelegate AddSongToPlaylist
|
|
||||||
{
|
|
||||||
internal get { return _AddSongToPlaylist; }
|
|
||||||
set { _AddSongToPlaylist = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static RemoveSongFromPlaylistDelegate _RemoveSongFromPlaylist;
|
public static PlaylistContainsSongDelegate PlaylistContainsSong { internal get; set; }
|
||||||
public static RemoveSongFromPlaylistDelegate RemoveSongFromPlaylist
|
|
||||||
{
|
|
||||||
internal get { return _RemoveSongFromPlaylist; }
|
|
||||||
set { _RemoveSongFromPlaylist = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MoveSongInPlaylistDelegate _MoveSongInPlaylist;
|
public static GetPlaylistSongsDelegate GetPlaylistSongs { internal get; set; }
|
||||||
public static MoveSongInPlaylistDelegate MoveSongInPlaylist
|
|
||||||
{
|
|
||||||
internal get { return _MoveSongInPlaylist; }
|
|
||||||
set { _MoveSongInPlaylist = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PlaylistContainsSongDelegate _PlaylistContainsSong;
|
public static RemovePlaylistDelegate RemovePlaylist { internal get; set; }
|
||||||
public static PlaylistContainsSongDelegate PlaylistContainsSong
|
|
||||||
{
|
|
||||||
internal get { return _PlaylistContainsSong; }
|
|
||||||
set { _PlaylistContainsSong = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GetPlaylistSongsDelegate _GetPlaylistSongs;
|
|
||||||
public static GetPlaylistSongsDelegate GetPlaylistSongs
|
|
||||||
{
|
|
||||||
internal get { return _GetPlaylistSongs; }
|
|
||||||
set { _GetPlaylistSongs = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static RemovePlaylistDelegate _RemovePlaylist;
|
|
||||||
public static RemovePlaylistDelegate RemovePlaylist
|
|
||||||
{
|
|
||||||
internal get { return _RemovePlaylist; }
|
|
||||||
set { _RemovePlaylist = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AddPlaylistDelegate _AddPlaylist;
|
|
||||||
public static AddPlaylistDelegate AddPlaylist
|
|
||||||
{
|
|
||||||
internal get { return _AddPlaylist; }
|
|
||||||
set { _AddPlaylist = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static AddPlaylistDelegate AddPlaylist { internal get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region user management
|
#region user management
|
||||||
|
public static ValidatePasswordDelegate ValidatePassword { internal get; set; }
|
||||||
|
|
||||||
private static ValidatePasswordDelegate _ValidatePassword;
|
public static GetUserRoleDelegate GetUserRole { internal get; set; }
|
||||||
public static ValidatePasswordDelegate ValidatePassword
|
|
||||||
{
|
|
||||||
internal get { return CServer._ValidatePassword; }
|
|
||||||
set { CServer._ValidatePassword = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GetUserRoleDelegate _GetUserRole;
|
public static SetUserRoleDelegate SetUserRole { internal get; set; }
|
||||||
public static GetUserRoleDelegate GetUserRole
|
|
||||||
{
|
|
||||||
internal get { return CServer._GetUserRole; }
|
|
||||||
set { CServer._GetUserRole = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static SetUserRoleDelegate _SetUserRole;
|
public static GetUserIdFromUsernameDelegate GetUserIdFromUsername { internal get; set; }
|
||||||
public static SetUserRoleDelegate SetUserRole
|
|
||||||
{
|
|
||||||
internal get { return CServer._SetUserRole; }
|
|
||||||
set { CServer._SetUserRole = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GetUserIdFromUsernameDelegate _GetUserIdFromUsername;
|
|
||||||
public static GetUserIdFromUsernameDelegate GetUserIdFromUsername
|
|
||||||
{
|
|
||||||
internal get { return CServer._GetUserIdFromUsername; }
|
|
||||||
set { CServer._GetUserIdFromUsername = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public CServer(int port, bool encrypted)
|
public CServer(int port, bool encrypted)
|
||||||
{
|
{
|
||||||
_Init(port, encrypted);
|
_Init(port, encrypted);
|
||||||
@@ -206,11 +95,11 @@ namespace ServerLib
|
|||||||
public string GetBaseAddress()
|
public string GetBaseAddress()
|
||||||
{
|
{
|
||||||
return _BaseAddress.AbsoluteUri;
|
return _BaseAddress.AbsoluteUri;
|
||||||
|
|
||||||
/*IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
|
/*IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
|
||||||
foreach (IPAddress ip in ips)
|
foreach (IPAddress ip in ips)
|
||||||
{
|
{
|
||||||
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
|
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
||||||
return ip.ToString();
|
return ip.ToString();
|
||||||
}
|
}
|
||||||
return "";*/
|
return "";*/
|
||||||
@@ -222,32 +111,25 @@ namespace ServerLib
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region server control
|
#region server control
|
||||||
|
|
||||||
private void _Init(int port, bool encrypted)
|
private void _Init(int port, bool encrypted)
|
||||||
{
|
{
|
||||||
string hostname = Dns.GetHostName();
|
string hostname = Dns.GetHostName();
|
||||||
if (encrypted)
|
string protocol = (encrypted) ? "https" : "http";
|
||||||
{
|
_BaseAddress = new Uri(protocol + "://" + hostname + ":" + port + "/");
|
||||||
_BaseAddress = new Uri("https://" + hostname + ":" + port + "/");
|
_Encrypted = encrypted;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_BaseAddress = new Uri("http://" + hostname + ":" + port + "/");
|
|
||||||
}
|
|
||||||
this._Encrypted = encrypted;
|
|
||||||
_Host = new WebServiceHost(typeof(CWebservice), _BaseAddress);
|
_Host = new WebServiceHost(typeof(CWebservice), _BaseAddress);
|
||||||
|
|
||||||
WebHttpBinding wb = new WebHttpBinding
|
WebHttpBinding wb = new WebHttpBinding
|
||||||
{
|
{
|
||||||
MaxReceivedMessageSize = 10485760,
|
MaxReceivedMessageSize = 10485760,
|
||||||
MaxBufferSize = 10485760,
|
MaxBufferSize = 10485760,
|
||||||
MaxBufferPoolSize = 10485760,
|
MaxBufferPoolSize = 10485760,
|
||||||
ReaderQuotas = { MaxStringContentLength = 10485760, MaxArrayLength = 10485760, MaxBytesPerRead = 10485760 }
|
ReaderQuotas = {MaxStringContentLength = 10485760, MaxArrayLength = 10485760, MaxBytesPerRead = 10485760}
|
||||||
};
|
};
|
||||||
if (encrypted)
|
if (encrypted)
|
||||||
{
|
{
|
||||||
wb.Security.Mode = WebHttpSecurityMode.Transport;
|
wb.Security.Mode = WebHttpSecurityMode.Transport;
|
||||||
wb.Security.Transport = new HttpTransportSecurity { ClientCredentialType = HttpClientCredentialType.None };
|
wb.Security.Transport = new HttpTransportSecurity {ClientCredentialType = HttpClientCredentialType.None};
|
||||||
}
|
}
|
||||||
_Host.AddServiceEndpoint(typeof(ICWebservice), wb, "");
|
_Host.AddServiceEndpoint(typeof(ICWebservice), wb, "");
|
||||||
}
|
}
|
||||||
@@ -260,7 +142,7 @@ namespace ServerLib
|
|||||||
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
|
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
|
||||||
smb.HttpGetEnabled = true;
|
smb.HttpGetEnabled = true;
|
||||||
host.Description.Behaviors.Add(smb);*/
|
host.Description.Behaviors.Add(smb);*/
|
||||||
|
_RegisterUrlAndCert(_BaseAddress.Port);
|
||||||
_Host.Open();
|
_Host.Open();
|
||||||
}
|
}
|
||||||
catch (CommunicationException e)
|
catch (CommunicationException e)
|
||||||
@@ -274,15 +156,13 @@ namespace ServerLib
|
|||||||
_Init(_BaseAddress.Port, _Encrypted);
|
_Init(_BaseAddress.Port, _Encrypted);
|
||||||
_Host.Open();
|
_Host.Open();
|
||||||
}
|
}
|
||||||
catch (CommunicationException e2)
|
catch (CommunicationException)
|
||||||
{
|
{
|
||||||
_Host.Abort();
|
_Host.Abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_Host.Abort();
|
_Host.Abort();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +172,7 @@ namespace ServerLib
|
|||||||
{
|
{
|
||||||
_Host.Close();
|
_Host.Close();
|
||||||
}
|
}
|
||||||
catch (CommunicationException e)
|
catch (CommunicationException)
|
||||||
{
|
{
|
||||||
_Host.Abort();
|
_Host.Abort();
|
||||||
}
|
}
|
||||||
@@ -303,29 +183,24 @@ namespace ServerLib
|
|||||||
#if WIN
|
#if WIN
|
||||||
|
|
||||||
ProcessStartInfo info = new ProcessStartInfo
|
ProcessStartInfo info = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "VocaluxeServerConfig.exe",
|
FileName = "VocaluxeServerConfig.exe",
|
||||||
Arguments = port.ToString() + " " + (_Encrypted?"true":"false"),
|
Arguments = port + " " + (_Encrypted ? "true" : "false"),
|
||||||
UseShellExecute = true,
|
UseShellExecute = true,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
Verb = "runas"
|
Verb = "runas"
|
||||||
};
|
};
|
||||||
Process p = Process.Start(info);
|
Process p = Process.Start(info);
|
||||||
if (p != null)
|
p.WaitForExit();
|
||||||
{
|
p.Close();
|
||||||
p.WaitForExit();
|
|
||||||
p.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
//Required?
|
//Required?
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.ServiceModel;
|
using System.ServiceModel;
|
||||||
using System.ServiceModel.Web;
|
using System.ServiceModel.Web;
|
||||||
@@ -15,42 +32,33 @@ namespace ServerLib
|
|||||||
string sessionHeader =
|
string sessionHeader =
|
||||||
((HttpRequestMessageProperty)OperationContext.Current.IncomingMessageProperties["httpRequest"]).Headers["session"];
|
((HttpRequestMessageProperty)OperationContext.Current.IncomingMessageProperties["httpRequest"]).Headers["session"];
|
||||||
if (string.IsNullOrEmpty(sessionHeader))
|
if (string.IsNullOrEmpty(sessionHeader))
|
||||||
{
|
|
||||||
return sessionKey;
|
return sessionKey;
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sessionKey = Guid.Parse(sessionHeader);
|
sessionKey = Guid.Parse(sessionHeader);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
return sessionKey;
|
return sessionKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendKeyEvent(string key)
|
public void SendKeyEvent(string key)
|
||||||
{
|
{
|
||||||
if (!_CheckRight(EUserRights.UseKeyboard))
|
if (!_CheckRight(EUserRights.UseKeyboard))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (CServer.SendKeyEvent == null)
|
if (CServer.SendKeyEvent == null)
|
||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
{
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.NotFound;
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not found";
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not found";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
CServer.SendKeyEvent(key);
|
CServer.SendKeyEvent(key);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region profile
|
#region profile
|
||||||
|
|
||||||
public int GetOwnProfileId()
|
public int GetOwnProfileId()
|
||||||
{
|
{
|
||||||
Guid sessionKey = _GetSession();
|
Guid sessionKey = _GetSession();
|
||||||
@@ -58,7 +66,7 @@ namespace ServerLib
|
|||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
{
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -68,7 +76,7 @@ namespace ServerLib
|
|||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
{
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -82,18 +90,16 @@ namespace ServerLib
|
|||||||
|
|
||||||
if (profile.ProfileId != -1) //-1 is the id for a new profile
|
if (profile.ProfileId != -1) //-1 is the id for a new profile
|
||||||
{
|
{
|
||||||
if (CSessionControl.GetUserIdFromSession(sessionKey) != profile.ProfileId
|
if (CSessionControl.GetUserIdFromSession(sessionKey) != profile.ProfileId
|
||||||
&& !(_CheckRight(EUserRights.EditAllProfiles) ))
|
&& !(_CheckRight(EUserRights.EditAllProfiles)))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CServer.SendProfileData == null)
|
if (CServer.SendProfileData == null)
|
||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
{
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.NotFound;
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not found";
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not found";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -108,9 +114,7 @@ namespace ServerLib
|
|||||||
if (_CheckRight(EUserRights.ViewOtherProfiles) || CSessionControl.GetUserIdFromSession(sessionKey) == profileId)
|
if (_CheckRight(EUserRights.ViewOtherProfiles) || CSessionControl.GetUserIdFromSession(sessionKey) == profileId)
|
||||||
{
|
{
|
||||||
if (CServer.GetProfileData == null)
|
if (CServer.GetProfileData == null)
|
||||||
{
|
|
||||||
return new SProfileData();
|
return new SProfileData();
|
||||||
}
|
|
||||||
|
|
||||||
bool isReadonly = (!CSessionControl.RequestRight(sessionKey, EUserRights.EditAllProfiles) &&
|
bool isReadonly = (!CSessionControl.RequestRight(sessionKey, EUserRights.EditAllProfiles) &&
|
||||||
CSessionControl.GetUserIdFromSession(sessionKey) != profileId);
|
CSessionControl.GetUserIdFromSession(sessionKey) != profileId);
|
||||||
@@ -118,36 +122,26 @@ namespace ServerLib
|
|||||||
return CServer.GetProfileData(profileId, isReadonly);
|
return CServer.GetProfileData(profileId, isReadonly);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return new SProfileData();
|
return new SProfileData();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SProfileData[] GetProfileList()
|
public SProfileData[] GetProfileList()
|
||||||
{
|
{
|
||||||
if (CServer.GetProfileList == null)
|
if (CServer.GetProfileList == null)
|
||||||
{
|
return new SProfileData[] {};
|
||||||
return new SProfileData[] { };
|
|
||||||
}
|
|
||||||
return CServer.GetProfileList();
|
return CServer.GetProfileList();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region photo
|
#region photo
|
||||||
|
|
||||||
public void SendPhoto(SPhotoData photo)
|
public void SendPhoto(SPhotoData photo)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.UploadPhotos))
|
if (_CheckRight(EUserRights.UploadPhotos))
|
||||||
{
|
|
||||||
CServer.SendPhoto(photo);
|
CServer.SendPhoto(photo);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region website
|
#region website
|
||||||
|
|
||||||
public Guid Login(string username, string password)
|
public Guid Login(string username, string password)
|
||||||
{
|
{
|
||||||
Guid sessionId = CSessionControl.OpenSession(username, password);
|
Guid sessionId = CSessionControl.OpenSession(username, password);
|
||||||
@@ -155,7 +149,7 @@ namespace ServerLib
|
|||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
{
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Wrong username or password";
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Wrong username or password";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,9 +159,7 @@ namespace ServerLib
|
|||||||
public Stream Index()
|
public Stream Index()
|
||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
|
||||||
WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";
|
WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";
|
||||||
}
|
|
||||||
|
|
||||||
return new MemoryStream(CServer.GetSiteFile("index.html"));
|
return new MemoryStream(CServer.GetSiteFile("index.html"));
|
||||||
}
|
}
|
||||||
@@ -186,14 +178,10 @@ namespace ServerLib
|
|||||||
byte[] data = CServer.GetSiteFile("js/" + filename);
|
byte[] data = CServer.GetSiteFile("js/" + filename);
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
|
||||||
return new MemoryStream(data);
|
return new MemoryStream(data);
|
||||||
}
|
|
||||||
|
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.NotFound;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,13 +199,9 @@ namespace ServerLib
|
|||||||
byte[] data = CServer.GetSiteFile("css/" + filename);
|
byte[] data = CServer.GetSiteFile("css/" + filename);
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
|
||||||
return new MemoryStream(data);
|
return new MemoryStream(data);
|
||||||
}
|
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.NotFound;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,13 +219,9 @@ namespace ServerLib
|
|||||||
byte[] data = CServer.GetSiteFile("css\\images\\" + filename);
|
byte[] data = CServer.GetSiteFile("css\\images\\" + filename);
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
|
||||||
return new MemoryStream(data);
|
return new MemoryStream(data);
|
||||||
}
|
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.NotFound;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,13 +239,9 @@ namespace ServerLib
|
|||||||
byte[] data = CServer.GetSiteFile("img/" + filename);
|
byte[] data = CServer.GetSiteFile("img/" + filename);
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
|
||||||
return new MemoryStream(data);
|
return new MemoryStream(data);
|
||||||
}
|
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.NotFound;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,14 +259,10 @@ namespace ServerLib
|
|||||||
byte[] data = CServer.GetSiteFile("locales/" + filename);
|
byte[] data = CServer.GetSiteFile("locales/" + filename);
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
|
||||||
return new MemoryStream(data);
|
return new MemoryStream(data);
|
||||||
}
|
|
||||||
|
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,11 +275,9 @@ namespace ServerLib
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region songs
|
#region songs
|
||||||
|
|
||||||
public SSongInfo GetSong(int songId)
|
public SSongInfo GetSong(int songId)
|
||||||
{
|
{
|
||||||
return CServer.GetSong(songId);
|
return CServer.GetSong(songId);
|
||||||
@@ -325,7 +295,6 @@ namespace ServerLib
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region playlist
|
#region playlist
|
||||||
|
|
||||||
public SPlaylistInfo[] GetPlaylists()
|
public SPlaylistInfo[] GetPlaylists()
|
||||||
{
|
{
|
||||||
return CServer.GetPlaylists();
|
return CServer.GetPlaylists();
|
||||||
@@ -339,25 +308,19 @@ namespace ServerLib
|
|||||||
public void AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates)
|
public void AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.AddSongToPlaylist))
|
if (_CheckRight(EUserRights.AddSongToPlaylist))
|
||||||
{
|
|
||||||
CServer.AddSongToPlaylist(songId, playlistId, allowDuplicates);
|
CServer.AddSongToPlaylist(songId, playlistId, allowDuplicates);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveSongFromPlaylist(int position, int playlistId, int songId)
|
public void RemoveSongFromPlaylist(int position, int playlistId, int songId)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.RemoveSongsFromPlaylists))
|
if (_CheckRight(EUserRights.RemoveSongsFromPlaylists))
|
||||||
{
|
|
||||||
CServer.RemoveSongFromPlaylist(position, playlistId, songId);
|
CServer.RemoveSongFromPlaylist(position, playlistId, songId);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveSongInPlaylist(int newPosition, int playlistId, int songId)
|
public void MoveSongInPlaylist(int newPosition, int playlistId, int songId)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.ReorderPlaylists))
|
if (_CheckRight(EUserRights.ReorderPlaylists))
|
||||||
{
|
|
||||||
CServer.MoveSongInPlaylist(newPosition, playlistId, songId);
|
CServer.MoveSongInPlaylist(newPosition, playlistId, songId);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool PlaylistContainsSong(int songId, int playlistId)
|
public bool PlaylistContainsSong(int songId, int playlistId)
|
||||||
@@ -373,24 +336,18 @@ namespace ServerLib
|
|||||||
public void RemovePlaylist(int playlistId)
|
public void RemovePlaylist(int playlistId)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.DeletePlaylists))
|
if (_CheckRight(EUserRights.DeletePlaylists))
|
||||||
{
|
|
||||||
CServer.RemovePlaylist(playlistId);
|
CServer.RemovePlaylist(playlistId);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AddPlaylist(string playlistName)
|
public int AddPlaylist(string playlistName)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.CreatePlaylists))
|
if (_CheckRight(EUserRights.CreatePlaylists))
|
||||||
{
|
|
||||||
return CServer.AddPlaylist(playlistName);
|
return CServer.AddPlaylist(playlistName);
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region user management
|
#region user management
|
||||||
|
|
||||||
public int GetUserRole(int profileId)
|
public int GetUserRole(int profileId)
|
||||||
{
|
{
|
||||||
return CServer.GetUserRole(profileId);
|
return CServer.GetUserRole(profileId);
|
||||||
@@ -399,11 +356,9 @@ namespace ServerLib
|
|||||||
public void SetUserRole(int profileId, int userRole)
|
public void SetUserRole(int profileId, int userRole)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.EditAllProfiles))
|
if (_CheckRight(EUserRights.EditAllProfiles))
|
||||||
{
|
|
||||||
CServer.SetUserRole(profileId, userRole);
|
CServer.SetUserRole(profileId, userRole);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasUserRight(int right)
|
public bool HasUserRight(int right)
|
||||||
{
|
{
|
||||||
return _CheckRightWithNoErrorMessage((EUserRights)right);
|
return _CheckRightWithNoErrorMessage((EUserRights)right);
|
||||||
@@ -417,7 +372,7 @@ namespace ServerLib
|
|||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
{
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = "No session";
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -427,7 +382,7 @@ namespace ServerLib
|
|||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
{
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Forbidden;
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not allowed";
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not allowed";
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -440,19 +395,13 @@ namespace ServerLib
|
|||||||
Guid sessionKey = _GetSession();
|
Guid sessionKey = _GetSession();
|
||||||
|
|
||||||
if (sessionKey == Guid.Empty)
|
if (sessionKey == Guid.Empty)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!CSessionControl.RequestRight(sessionKey, requestedRight))
|
if (!CSessionControl.RequestRight(sessionKey, requestedRight))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
@@ -10,64 +27,49 @@ namespace ServerLib
|
|||||||
{
|
{
|
||||||
public delegate bool SendKeyEventDelegate(string key);
|
public delegate bool SendKeyEventDelegate(string key);
|
||||||
|
|
||||||
|
|
||||||
#region profile
|
#region profile
|
||||||
|
|
||||||
public delegate SProfileData GetProfileDataDelegate(int profileId, bool isReadonly);
|
public delegate SProfileData GetProfileDataDelegate(int profileId, bool isReadonly);
|
||||||
|
|
||||||
public delegate bool SendProfileDataDelegate(SProfileData profile);
|
public delegate bool SendProfileDataDelegate(SProfileData profile);
|
||||||
|
|
||||||
public delegate SProfileData[] GetProfileListDelegate();
|
public delegate SProfileData[] GetProfileListDelegate();
|
||||||
|
|
||||||
[DataContract]
|
[DataContract]
|
||||||
public struct SProfileData
|
public struct SProfileData
|
||||||
{
|
{
|
||||||
[DataMember]
|
[DataMember] public CBase64Image Avatar;
|
||||||
public CBase64Image Avatar;
|
[DataMember] public string PlayerName;
|
||||||
[DataMember]
|
[DataMember] public int Type;
|
||||||
public string PlayerName;
|
[DataMember] public int Difficulty;
|
||||||
[DataMember]
|
[DataMember] public int ProfileId;
|
||||||
public int Type;
|
[DataMember] public bool IsEditable;
|
||||||
[DataMember]
|
[DataMember] public string Password;
|
||||||
public int Difficulty;
|
|
||||||
[DataMember]
|
|
||||||
public int ProfileId;
|
|
||||||
[DataMember]
|
|
||||||
public bool IsEditable;
|
|
||||||
[DataMember]
|
|
||||||
public string Password;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region photo
|
#region photo
|
||||||
|
|
||||||
public delegate bool SendPhotoDelegate(SPhotoData photo);
|
public delegate bool SendPhotoDelegate(SPhotoData photo);
|
||||||
|
|
||||||
[DataContract]
|
[DataContract]
|
||||||
public struct SPhotoData
|
public struct SPhotoData
|
||||||
{
|
{
|
||||||
[DataMember]
|
[DataMember] public CBase64Image Photo;
|
||||||
public CBase64Image Photo;
|
|
||||||
//Add infomation about the user who took this image??
|
//Add infomation about the user who took this image??
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region website
|
#region website
|
||||||
|
|
||||||
public delegate byte[] GetSiteFileDelegate(string filename);
|
public delegate byte[] GetSiteFileDelegate(string filename);
|
||||||
|
|
||||||
public delegate CBase64Image GetDelayedImageDelegate(string hashedFilename);
|
public delegate CBase64Image GetDelayedImageDelegate(string hashedFilename);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
[DataContract]
|
[DataContract]
|
||||||
public class CBase64Image
|
public class CBase64Image
|
||||||
{
|
{
|
||||||
[DataMember]
|
[DataMember] private string base64Data = "";
|
||||||
private string base64Data = "";
|
|
||||||
|
|
||||||
[DataMember]
|
[DataMember] private string imageId = "";
|
||||||
private string imageId = "";
|
|
||||||
|
|
||||||
public CBase64Image(Image img, ImageFormat format)
|
public CBase64Image(Image img, ImageFormat format)
|
||||||
{
|
{
|
||||||
@@ -97,28 +99,21 @@ namespace ServerLib
|
|||||||
Match match = Regex.Match(base64Data, "(?<=data:image/)[a-zA-Z]+(?=;base64)");
|
Match match = Regex.Match(base64Data, "(?<=data:image/)[a-zA-Z]+(?=;base64)");
|
||||||
return match.Success ? match.Groups[0].Value : "";
|
return match.Success ? match.Groups[0].Value : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region songs
|
#region songs
|
||||||
|
|
||||||
public delegate SSongInfo GetSongDelegate(int songId);
|
public delegate SSongInfo GetSongDelegate(int songId);
|
||||||
|
|
||||||
public delegate SSongInfo[] GetAllSongsDelegate();
|
public delegate SSongInfo[] GetAllSongsDelegate();
|
||||||
|
|
||||||
public delegate int GetCurrentSongIdDelegate();
|
public delegate int GetCurrentSongIdDelegate();
|
||||||
|
|
||||||
|
|
||||||
[DataContract]
|
[DataContract]
|
||||||
public struct SSongInfo
|
public struct SSongInfo
|
||||||
{
|
{
|
||||||
[DataMember]
|
[DataMember] public string Title;
|
||||||
public string Title;
|
[DataMember] public string Artist;
|
||||||
[DataMember]
|
[DataMember] public CBase64Image Cover;
|
||||||
public string Artist;
|
|
||||||
[DataMember]
|
|
||||||
public CBase64Image Cover;
|
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public string Genre { get; set; }
|
public string Genre { get; set; }
|
||||||
[DataMember]
|
[DataMember]
|
||||||
@@ -130,7 +125,6 @@ namespace ServerLib
|
|||||||
[DataMember]
|
[DataMember]
|
||||||
public int SongId { get; set; }
|
public int SongId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region playlists
|
#region playlists
|
||||||
@@ -155,33 +149,23 @@ namespace ServerLib
|
|||||||
[DataContract]
|
[DataContract]
|
||||||
public struct SPlaylistSongInfo
|
public struct SPlaylistSongInfo
|
||||||
{
|
{
|
||||||
[DataMember]
|
[DataMember] public SSongInfo Song;
|
||||||
public SSongInfo Song;
|
[DataMember] public int PlaylistId;
|
||||||
[DataMember]
|
[DataMember] public int PlaylistPosition;
|
||||||
public int PlaylistId;
|
[DataMember] public int GameMode;
|
||||||
[DataMember]
|
|
||||||
public int PlaylistPosition;
|
|
||||||
[DataMember]
|
|
||||||
public int GameMode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[DataContract]
|
[DataContract]
|
||||||
public struct SPlaylistInfo
|
public struct SPlaylistInfo
|
||||||
{
|
{
|
||||||
[DataMember]
|
[DataMember] public int PlaylistId;
|
||||||
public int PlaylistId;
|
[DataMember] public string PlaylistName;
|
||||||
[DataMember]
|
[DataMember] public int SongCount;
|
||||||
public string PlaylistName;
|
[DataMember] public string LastChanged;
|
||||||
[DataMember]
|
|
||||||
public int SongCount;
|
|
||||||
[DataMember]
|
|
||||||
public string LastChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region user management
|
#region user management
|
||||||
|
|
||||||
public delegate void SetPasswordDelegate(int profileId, string newPassword);
|
public delegate void SetPasswordDelegate(int profileId, string newPassword);
|
||||||
|
|
||||||
public delegate bool ValidatePasswordDelegate(int profileId, string password);
|
public delegate bool ValidatePasswordDelegate(int profileId, string password);
|
||||||
@@ -191,6 +175,5 @@ namespace ServerLib
|
|||||||
public delegate void SetUserRoleDelegate(int profileId, int userRole);
|
public delegate void SetUserRoleDelegate(int profileId, int userRole);
|
||||||
|
|
||||||
public delegate int GetUserIdFromUsernameDelegate(string username);
|
public delegate int GetUserIdFromUsernameDelegate(string username);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.ServiceModel;
|
using System.ServiceModel;
|
||||||
using System.ServiceModel.Web;
|
using System.ServiceModel.Web;
|
||||||
@@ -8,207 +25,195 @@ namespace ServerLib
|
|||||||
[ServiceContract]
|
[ServiceContract]
|
||||||
public interface ICWebservice
|
public interface ICWebservice
|
||||||
{
|
{
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/sendKeyEvent?key={key}")]
|
UriTemplate = "/sendKeyEvent?key={key}")]
|
||||||
|
|
||||||
void SendKeyEvent(string key);
|
void SendKeyEvent(string key);
|
||||||
|
|
||||||
#region profile
|
#region profile
|
||||||
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[OperationContract]
|
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getOwnProfileId")]
|
UriTemplate = "/getOwnProfileId")]
|
||||||
|
|
||||||
int GetOwnProfileId();
|
int GetOwnProfileId();
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "POST",
|
||||||
[WebInvoke(Method = "POST",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/sendProfile")]
|
UriTemplate = "/sendProfile")]
|
||||||
|
|
||||||
void SendProfile(SProfileData profile);
|
void SendProfile(SProfileData profile);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getProfile?profileId={profileId}")]
|
UriTemplate = "/getProfile?profileId={profileId}")]
|
||||||
|
|
||||||
SProfileData GetProfile(int profileId);
|
SProfileData GetProfile(int profileId);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getProfileList")]
|
UriTemplate = "/getProfileList")]
|
||||||
|
|
||||||
SProfileData[] GetProfileList();
|
SProfileData[] GetProfileList();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region photo
|
#region photo
|
||||||
|
[OperationContract, WebInvoke(Method = "POST",
|
||||||
[OperationContract]
|
|
||||||
[WebInvoke(Method = "POST",
|
|
||||||
RequestFormat = WebMessageFormat.Json,
|
RequestFormat = WebMessageFormat.Json,
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/sendPhoto")]
|
UriTemplate = "/sendPhoto")]
|
||||||
|
|
||||||
void SendPhoto(SPhotoData photo);
|
void SendPhoto(SPhotoData photo);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region website
|
#region website
|
||||||
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[OperationContract]
|
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/login?username={username}&password={password}")]
|
UriTemplate = "/login?username={username}&password={password}")]
|
||||||
|
|
||||||
Guid Login(string username, string password);
|
Guid Login(string username, string password);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "")]
|
UriTemplate = "")]
|
||||||
|
|
||||||
Stream Index();
|
Stream Index();
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/js/{filename}")]
|
UriTemplate = "/js/{filename}")]
|
||||||
|
|
||||||
Stream GetJsFile(String filename);
|
Stream GetJsFile(String filename);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/css/{filename}")]
|
UriTemplate = "/css/{filename}")]
|
||||||
|
|
||||||
Stream GetCssFile(String filename);
|
Stream GetCssFile(String filename);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/css/images/{filename}")]
|
UriTemplate = "/css/images/{filename}")]
|
||||||
|
|
||||||
Stream GetCssImageFile(String filename);
|
Stream GetCssImageFile(String filename);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/img/{filename}")]
|
UriTemplate = "/img/{filename}")]
|
||||||
|
|
||||||
Stream GetImgFile(String filename);
|
Stream GetImgFile(String filename);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/locales/{filename}")]
|
UriTemplate = "/locales/{filename}")]
|
||||||
|
|
||||||
Stream GetLocaleFile(String filename);
|
Stream GetLocaleFile(String filename);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/delayedImage?id={id}")]
|
UriTemplate = "/delayedImage?id={id}")]
|
||||||
|
|
||||||
CBase64Image GetDelayedImage(String id);
|
CBase64Image GetDelayedImage(String id);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/isServerOnline")]
|
UriTemplate = "/isServerOnline")]
|
||||||
|
|
||||||
bool IsServerOnline();
|
bool IsServerOnline();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region songs
|
#region songs
|
||||||
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[OperationContract]
|
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getSong?songId={songId}")]
|
UriTemplate = "/getSong?songId={songId}")]
|
||||||
|
|
||||||
SSongInfo GetSong(int songId);
|
SSongInfo GetSong(int songId);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getCurrentSongId")]
|
UriTemplate = "/getCurrentSongId")]
|
||||||
|
|
||||||
int GetCurrentSongId();
|
int GetCurrentSongId();
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getAllSongs")]
|
UriTemplate = "/getAllSongs")]
|
||||||
|
|
||||||
SSongInfo[] GetAllSongs();
|
SSongInfo[] GetAllSongs();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region playlist
|
#region playlist
|
||||||
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[OperationContract]
|
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getPlaylists")]
|
UriTemplate = "/getPlaylists")]
|
||||||
|
|
||||||
SPlaylistInfo[] GetPlaylists();
|
SPlaylistInfo[] GetPlaylists();
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getPlaylist?id={playlistId}")]
|
UriTemplate = "/getPlaylist?id={playlistId}")]
|
||||||
|
|
||||||
SPlaylistInfo GetPlaylist(int playlistId);
|
SPlaylistInfo GetPlaylist(int playlistId);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/addSongToPlaylist?songId={songId}&playlistId={playlistId}&duplicates={allowDuplicates}")]
|
UriTemplate = "/addSongToPlaylist?songId={songId}&playlistId={playlistId}&duplicates={allowDuplicates}")]
|
||||||
|
|
||||||
void AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates);
|
void AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/removeSongFromPlaylist?position={position}&playlistId={playlistId}&songId={songId}")]
|
UriTemplate = "/removeSongFromPlaylist?position={position}&playlistId={playlistId}&songId={songId}")]
|
||||||
|
|
||||||
void RemoveSongFromPlaylist(int position, int playlistId, int songId);
|
void RemoveSongFromPlaylist(int position, int playlistId, int songId);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/moveSongInPlaylist?newPosition={newPosition}&playlistId={playlistId}&songId={songId}")]
|
UriTemplate = "/moveSongInPlaylist?newPosition={newPosition}&playlistId={playlistId}&songId={songId}")]
|
||||||
|
|
||||||
void MoveSongInPlaylist(int newPosition, int playlistId, int songId);
|
void MoveSongInPlaylist(int newPosition, int playlistId, int songId);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/playlistContainsSong?songId={songId}&playlistId={playlistId}")]
|
UriTemplate = "/playlistContainsSong?songId={songId}&playlistId={playlistId}")]
|
||||||
|
|
||||||
bool PlaylistContainsSong(int songId, int playlistId);
|
bool PlaylistContainsSong(int songId, int playlistId);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getPlaylistSongs?playlistId={playlistId}")]
|
UriTemplate = "/getPlaylistSongs?playlistId={playlistId}")]
|
||||||
|
|
||||||
SPlaylistSongInfo[] GetPlaylistSongs(int playlistId);
|
SPlaylistSongInfo[] GetPlaylistSongs(int playlistId);
|
||||||
|
|
||||||
[OperationContract, WebInvoke(Method = "GET",
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/removePlaylist?playlistId={playlistId}")]
|
UriTemplate = "/removePlaylist?playlistId={playlistId}")]
|
||||||
void RemovePlaylist(int playlistId);
|
void RemovePlaylist(int playlistId);
|
||||||
|
|
||||||
[OperationContract, WebInvoke(Method = "GET",
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/addPlaylist?playlistName={playlistName}")]
|
UriTemplate = "/addPlaylist?playlistName={playlistName}")]
|
||||||
int AddPlaylist(string playlistName);
|
int AddPlaylist(string playlistName);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region user management
|
#region user management
|
||||||
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[OperationContract]
|
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/getUserRole?profileId={profileId}")]
|
UriTemplate = "/getUserRole?profileId={profileId}")]
|
||||||
|
|
||||||
int GetUserRole(int profileId);
|
int GetUserRole(int profileId);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/setUserRole?profileId={profileId}&userRole={userRole}")]
|
UriTemplate = "/setUserRole?profileId={profileId}&userRole={userRole}")]
|
||||||
|
|
||||||
void SetUserRole(int profileId, int userRole);
|
void SetUserRole(int profileId, int userRole);
|
||||||
|
|
||||||
[OperationContract]
|
[OperationContract, WebInvoke(Method = "GET",
|
||||||
[WebInvoke(Method = "GET",
|
|
||||||
ResponseFormat = WebMessageFormat.Json,
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
UriTemplate = "/hasUserRight?right={right}")]
|
UriTemplate = "/hasUserRight?right={right}")]
|
||||||
|
|
||||||
bool HasUserRight(int right);
|
bool HasUserRight(int right);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||||
// die mit einer Assembly verknüpft sind.
|
// die mit einer Assembly verknüpft sind.
|
||||||
|
|
||||||
[assembly: AssemblyTitle("ClientServerLib")]
|
[assembly: AssemblyTitle("ClientServerLib")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
@@ -17,9 +35,11 @@ using System.Runtime.InteropServices;
|
|||||||
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
|
// 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
|
// 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.
|
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
|
||||||
|
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
// 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")]
|
[assembly: Guid("53f89645-1948-420f-b64a-7dc705ca8820")]
|
||||||
|
|
||||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
// 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
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace ServerLib
|
namespace ServerLib
|
||||||
{
|
{
|
||||||
internal class CSession
|
class CSession
|
||||||
{
|
{
|
||||||
readonly Guid _ID;
|
private readonly Guid _ID;
|
||||||
public Guid Id
|
public Guid Id
|
||||||
{
|
{
|
||||||
get { return _ID; }
|
get { return _ID; }
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly int _ProfileId;
|
private readonly int _ProfileId;
|
||||||
public int ProfileId
|
public int ProfileId
|
||||||
{
|
{
|
||||||
get { return _ProfileId; }
|
get { return _ProfileId; }
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly EUserRoles _Roles;
|
private readonly EUserRoles _Roles;
|
||||||
internal EUserRoles Roles
|
internal EUserRoles Roles
|
||||||
{
|
{
|
||||||
get { return _Roles; }
|
get { return _Roles; }
|
||||||
@@ -24,9 +41,9 @@ namespace ServerLib
|
|||||||
|
|
||||||
public CSession(Guid id, int profileId, EUserRoles roles)
|
public CSession(Guid id, int profileId, EUserRoles roles)
|
||||||
{
|
{
|
||||||
this._ID = id;
|
_ID = id;
|
||||||
this._ProfileId = profileId;
|
_ProfileId = profileId;
|
||||||
this._Roles = roles;
|
_Roles = roles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace ServerLib
|
namespace ServerLib
|
||||||
{
|
{
|
||||||
internal static class CSessionControl
|
static class CSessionControl
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<Guid, CSession> _ActiveSessions = new Dictionary<Guid, CSession>();
|
private static readonly Dictionary<Guid, CSession> _ActiveSessions = new Dictionary<Guid, CSession>();
|
||||||
|
|
||||||
public static Guid OpenSession(string userName, string password)
|
public static Guid OpenSession(string userName, string password)
|
||||||
{
|
{
|
||||||
if (!_ValidateUserAndPassword(userName, password))
|
if (!_ValidateUserAndPassword(userName, password))
|
||||||
{
|
|
||||||
return Guid.Empty;
|
return Guid.Empty;
|
||||||
}
|
|
||||||
|
|
||||||
Guid newId = Guid.NewGuid();
|
Guid newId = Guid.NewGuid();
|
||||||
int id = _GetProfileIdFormUsername(userName);
|
int id = _GetProfileIdFormUsername(userName);
|
||||||
@@ -42,27 +57,23 @@ namespace ServerLib
|
|||||||
|
|
||||||
internal static void InvalidateSessions(int profileId)
|
internal static void InvalidateSessions(int profileId)
|
||||||
{
|
{
|
||||||
foreach (var s in (from kv in _ActiveSessions
|
foreach (KeyValuePair<Guid, CSession> s in (from kv in _ActiveSessions
|
||||||
where kv.Value.ProfileId == profileId
|
where kv.Value.ProfileId == profileId
|
||||||
select kv).ToList())
|
select kv).ToList())
|
||||||
{
|
|
||||||
_ActiveSessions.Remove(s.Key);
|
_ActiveSessions.Remove(s.Key);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool RequestRight(Guid sessionId, EUserRights requestedRight)
|
internal static bool RequestRight(Guid sessionId, EUserRights requestedRight)
|
||||||
{
|
{
|
||||||
return ((CUserRoleControl.GetUserRightsFromUserRole(_ActiveSessions[sessionId].Roles)
|
return ((CUserRoleControl.GetUserRightsFromUserRole(_ActiveSessions[sessionId].Roles)
|
||||||
.HasFlag(requestedRight)));
|
.HasFlag(requestedRight)));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static int GetUserIdFromSession(Guid sessionId)
|
internal static int GetUserIdFromSession(Guid sessionId)
|
||||||
{
|
{
|
||||||
if (!_ActiveSessions.ContainsKey(sessionId))
|
if (!_ActiveSessions.ContainsKey(sessionId))
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
return _ActiveSessions[sessionId].ProfileId;
|
return _ActiveSessions[sessionId].ProfileId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace ServerLib
|
namespace ServerLib
|
||||||
{
|
{
|
||||||
[Flags]
|
[Flags]
|
||||||
internal enum EUserRights
|
enum EUserRights
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
EditAllProfiles = 1,
|
EditAllProfiles = 1,
|
||||||
@@ -16,4 +33,4 @@ namespace ServerLib
|
|||||||
DeletePlaylists = 128,
|
DeletePlaylists = 128,
|
||||||
RemoveSongsFromPlaylists = 256
|
RemoveSongsFromPlaylists = 256
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace ServerLib
|
namespace ServerLib
|
||||||
{
|
{
|
||||||
internal static class CUserRoleControl
|
static class CUserRoleControl
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<EUserRoles, EUserRights> _RoleRightsMapping = new Dictionary<EUserRoles, EUserRights> {
|
private static readonly Dictionary<EUserRoles, EUserRights> _RoleRightsMapping = new Dictionary<EUserRoles, EUserRights>
|
||||||
{EUserRoles.TR_USERROLE_ADMIN,
|
{
|
||||||
(EUserRights.EditAllProfiles|
|
{
|
||||||
EUserRights.UploadPhotos|
|
EUserRoles.TR_USERROLE_ADMIN,
|
||||||
EUserRights.ViewOtherProfiles|
|
(EUserRights.EditAllProfiles |
|
||||||
EUserRights.UseKeyboard|
|
EUserRights.UploadPhotos |
|
||||||
EUserRights.AddSongToPlaylist|
|
EUserRights.ViewOtherProfiles |
|
||||||
EUserRights.ReorderPlaylists|
|
EUserRights.UseKeyboard |
|
||||||
EUserRights.CreatePlaylists|
|
EUserRights.AddSongToPlaylist |
|
||||||
EUserRights.DeletePlaylists|
|
EUserRights.ReorderPlaylists |
|
||||||
EUserRights.RemoveSongsFromPlaylists)},
|
EUserRights.CreatePlaylists |
|
||||||
{EUserRoles.TR_USERROLE_GUEST,
|
EUserRights.DeletePlaylists |
|
||||||
EUserRights.None},
|
EUserRights.RemoveSongsFromPlaylists)
|
||||||
{EUserRoles.TR_USERROLE_NORMAL,
|
},
|
||||||
(EUserRights.UploadPhotos|
|
{
|
||||||
EUserRights.ViewOtherProfiles)},
|
EUserRoles.TR_USERROLE_GUEST,
|
||||||
{EUserRoles.TR_USERROLE_KEYBOARDUSER,
|
EUserRights.None
|
||||||
EUserRights.UseKeyboard},
|
},
|
||||||
{EUserRoles.TR_USERROLE_ADDSONGSUSER,
|
{
|
||||||
EUserRights.AddSongToPlaylist},
|
EUserRoles.TR_USERROLE_NORMAL,
|
||||||
{EUserRoles.TR_USERROLE_PLAYLISTEDITOR,
|
(EUserRights.UploadPhotos |
|
||||||
(EUserRights.AddSongToPlaylist|
|
EUserRights.ViewOtherProfiles)
|
||||||
EUserRights.ReorderPlaylists|
|
},
|
||||||
EUserRights.CreatePlaylists|
|
{
|
||||||
EUserRights.DeletePlaylists|
|
EUserRoles.TR_USERROLE_KEYBOARDUSER,
|
||||||
EUserRights.RemoveSongsFromPlaylists)},
|
EUserRights.UseKeyboard
|
||||||
{EUserRoles.TR_USERROLE_PROFILEEDITOR,
|
},
|
||||||
EUserRights.EditAllProfiles}
|
{
|
||||||
};
|
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)
|
internal static EUserRights GetUserRightsFromUserRole(EUserRoles userRole)
|
||||||
{
|
{
|
||||||
return _RoleRightsMapping.Where(role => userRole.HasFlag(role.Key))
|
return _RoleRightsMapping.Where(role => userRole.HasFlag(role.Key))
|
||||||
.Select(role => role.Value)
|
.Select(role => role.Value)
|
||||||
.Aggregate(EUserRights.None, (current, r) => current | r);
|
.Aggregate(EUserRights.None, (current, r) => current | r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace ServerLib
|
namespace ServerLib
|
||||||
{
|
{
|
||||||
[Flags]
|
[Flags]
|
||||||
internal enum EUserRoles
|
enum EUserRoles
|
||||||
{
|
{
|
||||||
TR_USERROLE_GUEST = 0,
|
TR_USERROLE_GUEST = 0,
|
||||||
TR_USERROLE_NORMAL = 1,
|
TR_USERROLE_NORMAL = 1,
|
||||||
@@ -13,4 +30,4 @@ namespace ServerLib
|
|||||||
TR_USERROLE_PLAYLISTEDITOR = 16,
|
TR_USERROLE_PLAYLISTEDITOR = 16,
|
||||||
TR_USERROLE_PROFILEEDITOR = 32
|
TR_USERROLE_PROFILEEDITOR = 32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
using Security.Cryptography;
|
|
||||||
using Security.Cryptography.X509Certificates;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Security.Permissions;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ConfigHttpApi
|
|
||||||
{
|
|
||||||
public static class ConfigHttpApi
|
|
||||||
{
|
|
||||||
[PrincipalPermission(SecurityAction.Demand, Role = @"BUILTIN\Administrators")]
|
|
||||||
public static void reserveURL(string networkString)
|
|
||||||
{
|
|
||||||
HttpApi.ReserveURL(networkString, "D:(A;;GX;;;S-1-1-0)");
|
|
||||||
}
|
|
||||||
|
|
||||||
[PrincipalPermission(SecurityAction.Demand, Role = @"BUILTIN\Administrators")]
|
|
||||||
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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
[PrincipalPermission(SecurityAction.Demand, Role = @"BUILTIN\Administrators")]
|
|
||||||
public static void addCertToStore(X509Certificate2 cert)
|
|
||||||
{
|
|
||||||
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
|
|
||||||
store.Open(OpenFlags.ReadWrite);
|
|
||||||
store.Add(cert);
|
|
||||||
store.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
[PrincipalPermission(SecurityAction.Demand, Role = @"BUILTIN\Administrators")]
|
|
||||||
public static X509Certificate2 getSelfSignedCert(string subjectName)
|
|
||||||
{
|
|
||||||
CngKey key = CngKey.Create(CngAlgorithm2.Rsa);
|
|
||||||
X509CertificateCreationParameters param = new X509CertificateCreationParameters(
|
|
||||||
new X500DistinguishedName("CN=Vocaluxe Server"));
|
|
||||||
param.SubjectName = new X500DistinguishedName("CN=localhost");
|
|
||||||
param.EndTime = DateTime.Today.AddYears(20);
|
|
||||||
param.SignatureAlgorithm = X509CertificateSignatureAlgorithm.RsaSha512;
|
|
||||||
OidCollection oc = new OidCollection();
|
|
||||||
oc.Add(new Oid("1.3.6.1.5.5.7.3.1"));
|
|
||||||
X509Extension eku = new X509EnhancedKeyUsageExtension(oc, true);
|
|
||||||
param.Extensions.Add(eku);
|
|
||||||
|
|
||||||
return key.CreateSelfSignedCertificate(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public static X509Certificate2 getCert(string subject)
|
|
||||||
{
|
|
||||||
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
|
|
||||||
|
|
||||||
Mono.Security.Authenticode.PrivateKey key = new Mono.Security.Authenticode.PrivateKey { RSA=RSA.Create()};
|
|
||||||
|
|
||||||
|
|
||||||
Mono.Security.X509.X509CertificateBuilder x509 = new Mono.Security.X509.X509CertificateBuilder();
|
|
||||||
x509.IssuerName = "CN=Vocaluxe Server";
|
|
||||||
x509.NotAfter = DateTime.Today.AddYears(20);
|
|
||||||
x509.NotBefore = DateTime.Today.AddDays(-1);
|
|
||||||
x509.SubjectName = subject;
|
|
||||||
x509.SerialNumber = new byte[] { 1 };
|
|
||||||
x509.Version = 3;
|
|
||||||
x509.SubjectPublicKey = rsa;
|
|
||||||
|
|
||||||
ExtendedKeyUsageExtension eku = new ExtendedKeyUsageExtension();
|
|
||||||
eku.KeyPurpose.Add("1.3.6.1.5.5.7.3.1");
|
|
||||||
x509.Extensions.Add(eku);
|
|
||||||
|
|
||||||
return new X509Certificate2(x509.Sign(rsa));
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{EC28CFA6-35A8-4971-AB07-37A54E010F69}</ProjectGuid>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>ConfigHttpApi</RootNamespace>
|
|
||||||
<AssemblyName>ConfigHttpApi</AssemblyName>
|
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<TargetFrameworkProfile />
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<StartupObject />
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Security">
|
|
||||||
<HintPath>..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 11.0\Libs\clrsecurity_june10\Security.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Security.Cryptography">
|
|
||||||
<HintPath>..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 11.0\Libs\clrsecurity_june10\Security.Cryptography.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="ConfigHttpApi.cs" />
|
|
||||||
<Compile Include="HttpApi.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
|
||||||
<Target Name="BeforeBuild">
|
|
||||||
</Target>
|
|
||||||
<Target Name="AfterBuild">
|
|
||||||
</Target>
|
|
||||||
-->
|
|
||||||
</Project>
|
|
||||||
@@ -1,643 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ConfigHttpApi
|
|
||||||
{
|
|
||||||
internal 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(
|
|
||||||
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(
|
|
||||||
IntPtr serviceIntPtr,
|
|
||||||
HTTP_SERVICE_CONFIG_ID configId,
|
|
||||||
IntPtr pConfigInformation,
|
|
||||||
int configInformationLength,
|
|
||||||
IntPtr pOverlapped);
|
|
||||||
|
|
||||||
[DllImport("httpapi.dll", SetLastError = true)]
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
enum HTTP_SERVICE_CONFIG_ID
|
|
||||||
{
|
|
||||||
|
|
||||||
HttpServiceConfigIPListenList = 0,
|
|
||||||
HttpServiceConfigSSLCertInfo,
|
|
||||||
HttpServiceConfigUrlAclInfo,
|
|
||||||
HttpServiceConfigMax
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
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
|
|
||||||
{
|
|
||||||
public IntPtr pIpPort;
|
|
||||||
|
|
||||||
public HTTP_SERVICE_CONFIG_SSL_KEY(IntPtr pIpPort)
|
|
||||||
{
|
|
||||||
this.pIpPort = pIpPort;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
||||||
struct HTTP_SERVICE_CONFIG_SSL_PARAM
|
|
||||||
{
|
|
||||||
public int SslHashLength;
|
|
||||||
public IntPtr pSslHash;
|
|
||||||
public Guid AppId;
|
|
||||||
[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;
|
|
||||||
public uint DefaultFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
|
||||||
struct HTTPAPI_VERSION
|
|
||||||
{
|
|
||||||
public ushort HttpApiMajorVersion;
|
|
||||||
public ushort HttpApiMinorVersion;
|
|
||||||
|
|
||||||
public HTTPAPI_VERSION(ushort majorVersion, ushort minorVersion)
|
|
||||||
{
|
|
||||||
HttpApiMajorVersion = majorVersion;
|
|
||||||
HttpApiMinorVersion = minorVersion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
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
|
|
||||||
{
|
|
||||||
HttpServiceConfigQueryExact = 0,
|
|
||||||
HttpServiceConfigQueryNext,
|
|
||||||
HttpServiceConfigQueryMax
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
struct HTTP_SERVICE_CONFIG_URLACL_SET
|
|
||||||
{
|
|
||||||
public HTTP_SERVICE_CONFIG_URLACL_KEY KeyDesc;
|
|
||||||
public HTTP_SERVICE_CONFIG_URLACL_PARAM ParamDesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
||||||
public struct HTTP_SERVICE_CONFIG_URLACL_KEY
|
|
||||||
{
|
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
|
||||||
public string pUrlPrefix;
|
|
||||||
|
|
||||||
public HTTP_SERVICE_CONFIG_URLACL_KEY(string urlPrefix)
|
|
||||||
{
|
|
||||||
pUrlPrefix = urlPrefix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
||||||
struct HTTP_SERVICE_CONFIG_URLACL_PARAM
|
|
||||||
{
|
|
||||||
[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;
|
|
||||||
private const uint NOERROR = 0;
|
|
||||||
private const uint ERROR_INSUFFICIENT_BUFFER = 122;
|
|
||||||
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; }
|
|
||||||
public Guid AppId { get; set; }
|
|
||||||
public string StoreName { get; set; }
|
|
||||||
public IPEndPoint IpPort { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SslCertificateInfo QuerySslCertificateInfo(IPEndPoint ipPort)
|
|
||||||
{
|
|
||||||
SslCertificateInfo result = null;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
result = new SslCertificateInfo { AppId = appId, Hash = hash, StoreName = storeName, IpPort = ipPort };
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Marshal.FreeCoTaskMem(pOutputConfigInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ThrowWin32ExceptionIfError(retVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
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");
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DeleteCertificateBinding(params IPEndPoint[] ipPorts)
|
|
||||||
{
|
|
||||||
if (ipPorts == null || ipPorts.Length == 0)
|
|
||||||
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
|
|
||||||
{
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
var result = new List<SslCertificateInfo>();
|
|
||||||
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
if ((uint)ERROR_ALREADY_EXISTS == retVal) // ERROR_ALREADY_EXISTS = 183
|
|
||||||
{
|
|
||||||
retVal = HttpApi.HttpDeleteServiceConfiguration(IntPtr.Zero,
|
|
||||||
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
|
|
||||||
pInputConfigInfo,
|
|
||||||
Marshal.SizeOf(inputConfigInfoSet),
|
|
||||||
IntPtr.Zero);
|
|
||||||
|
|
||||||
if ((uint)NOERROR == retVal)
|
|
||||||
{
|
|
||||||
retVal = HttpApi.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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private static void ThrowWin32ExceptionIfError(uint retVal)
|
|
||||||
{
|
|
||||||
if (NOERROR != retVal)
|
|
||||||
{
|
|
||||||
throw new Win32Exception(Convert.ToInt32(retVal));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CallHttpApi(Action body)
|
|
||||||
{
|
|
||||||
uint retVal = HttpInitialize(HttpApiVersion, HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
|
|
||||||
ThrowWin32ExceptionIfError(retVal);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
body();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
HttpTerminate(HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates an unmanaged sockaddr structure to pass to a WinAPI function.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ipEndPoint">IP address and port number</param>
|
|
||||||
/// <returns>a handle for the structure. Use the AddrOfPinnedObject Method to get a stable pointer to the object. </returns>
|
|
||||||
/// <remarks>When the handle goes out of scope you must explicitly release it by calling the Free method; otherwise, memory leaks may occur. </remarks>
|
|
||||||
private static GCHandle CreateSockaddrStructure(IPEndPoint ipEndPoint)
|
|
||||||
{
|
|
||||||
SocketAddress socketAddress = ipEndPoint.Serialize();
|
|
||||||
|
|
||||||
// use an array of bytes instead of the sockaddr structure
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads the unmanaged sockaddr structure returned by a WinAPI function
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pSockaddrStructure">pointer to the unmanaged sockaddr structure</param>
|
|
||||||
/// <returns>IP address and port number</returns>
|
|
||||||
private static IPEndPoint ReadSockaddrStructure(IntPtr pSockaddrStructure)
|
|
||||||
{
|
|
||||||
short sAddressFamily = Marshal.ReadInt16(pSockaddrStructure);
|
|
||||||
AddressFamily addressFamily = (AddressFamily)sAddressFamily;
|
|
||||||
|
|
||||||
int sockAddrSructureSize;
|
|
||||||
IPEndPoint ipEndPointAny;
|
|
||||||
switch (addressFamily)
|
|
||||||
{
|
|
||||||
case AddressFamily.InterNetwork:
|
|
||||||
// IP v4 address
|
|
||||||
sockAddrSructureSize = 16;
|
|
||||||
ipEndPointAny = new IPEndPoint(IPAddress.Any, 0);
|
|
||||||
break;
|
|
||||||
case AddressFamily.InterNetworkV6:
|
|
||||||
// IP v6 address
|
|
||||||
sockAddrSructureSize = 28;
|
|
||||||
ipEndPointAny = new IPEndPoint(IPAddress.IPv6Any, 0);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException("pSockaddrStructure", "Unknown address family");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// get bytes of the sockadrr structure
|
|
||||||
byte[] sockAddrSructureBytes = new byte[sockAddrSructureSize];
|
|
||||||
Marshal.Copy(pSockaddrStructure, sockAddrSructureBytes, 0, sockAddrSructureSize);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
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("ConfigHttpApi")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("")]
|
|
||||||
[assembly: AssemblyProduct("ConfigHttpApi")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// 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("89f719af-3a0d-4704-be7f-16e5b4e19c02")]
|
|
||||||
|
|
||||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
|
||||||
//
|
|
||||||
// Hauptversion
|
|
||||||
// Nebenversion
|
|
||||||
// Buildnummer
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// 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")]
|
|
||||||
@@ -200,7 +200,7 @@
|
|||||||
<string name="TR_SCREENOTHEME_COVERLOADING">Chování nahrávání obalu</string>
|
<string name="TR_SCREENOTHEME_COVERLOADING">Chování nahrávání obalu</string>
|
||||||
<string name="TR_SCREENOLYRICS_OPTIONS">Nastavení textu písně</string>
|
<string name="TR_SCREENOLYRICS_OPTIONS">Nastavení textu písně</string>
|
||||||
<string name="TR_SCREENOLYRICS_STYLE">Styl</string>
|
<string name="TR_SCREENOLYRICS_STYLE">Styl</string>
|
||||||
<string name="TR_SCREENOLYRICS_POSTION">Poloha textu písně</string>
|
<string name="TR_SCREENOLYRICS_POSITION">Poloha textu písně</string>
|
||||||
<string name="TR_SCREENOVIDEO_OPTIONS">Nastavení obrazu</string>
|
<string name="TR_SCREENOVIDEO_OPTIONS">Nastavení obrazu</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Pozadí obrazu</string>
|
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Pozadí obrazu</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Náhled obrazu</string>
|
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Náhled obrazu</string>
|
||||||
|
|||||||
@@ -194,7 +194,7 @@
|
|||||||
<string name="TR_SCREENOTHEME_COVERLOADING">Gedrag Laden Covers</string>
|
<string name="TR_SCREENOTHEME_COVERLOADING">Gedrag Laden Covers</string>
|
||||||
<string name="TR_SCREENOLYRICS_OPTIONS">Songtekstopties</string>
|
<string name="TR_SCREENOLYRICS_OPTIONS">Songtekstopties</string>
|
||||||
<string name="TR_SCREENOLYRICS_STYLE">Stijl</string>
|
<string name="TR_SCREENOLYRICS_STYLE">Stijl</string>
|
||||||
<string name="TR_SCREENOLYRICS_POSTION">Positie songteksten</string>
|
<string name="TR_SCREENOLYRICS_POSITION">Positie songteksten</string>
|
||||||
<string name="TR_SCREENOVIDEO_OPTIONS">Video-opties</string>
|
<string name="TR_SCREENOVIDEO_OPTIONS">Video-opties</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Videoachtergronden</string>
|
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Videoachtergronden</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Videopreview</string>
|
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Videopreview</string>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
<string name="TR_USERROLE_GUEST">Guest</string>
|
<string name="TR_USERROLE_GUEST">Guest</string>
|
||||||
<string name="TR_USERROLE_NORMAL">Normal User</string>
|
<string name="TR_USERROLE_NORMAL">Normal User</string>
|
||||||
<string name="TR_USERROLE_ADMIN">Administrator</string>
|
<string name="TR_USERROLE_ADMIN">Administrator</string>
|
||||||
|
<string name="TR_USERROLE_KEYBOARDUSER">Keyboard User</string>
|
||||||
<string name="TR_CONFIG_SOFTWARE">Software</string>
|
<string name="TR_CONFIG_SOFTWARE">Software</string>
|
||||||
<string name="TR_CONFIG_OPENGL">OpenGL</string>
|
<string name="TR_CONFIG_OPENGL">OpenGL</string>
|
||||||
<string name="TR_CONFIG_DIRECT3D">Direct3D</string>
|
<string name="TR_CONFIG_DIRECT3D">Direct3D</string>
|
||||||
@@ -199,7 +200,7 @@
|
|||||||
<string name="TR_SCREENOTHEME_COVERLOADING">Cover Loading Behavior</string>
|
<string name="TR_SCREENOTHEME_COVERLOADING">Cover Loading Behavior</string>
|
||||||
<string name="TR_SCREENOLYRICS_OPTIONS">Lyrics Options</string>
|
<string name="TR_SCREENOLYRICS_OPTIONS">Lyrics Options</string>
|
||||||
<string name="TR_SCREENOLYRICS_STYLE">Style</string>
|
<string name="TR_SCREENOLYRICS_STYLE">Style</string>
|
||||||
<string name="TR_SCREENOLYRICS_POSTION">Lyrics position</string>
|
<string name="TR_SCREENOLYRICS_POSITION">Lyrics position</string>
|
||||||
<string name="TR_SCREENOVIDEO_OPTIONS">Video Options</string>
|
<string name="TR_SCREENOVIDEO_OPTIONS">Video Options</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Video Backgrounds</string>
|
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Video Backgrounds</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Video Preview</string>
|
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Video Preview</string>
|
||||||
|
|||||||
@@ -200,7 +200,7 @@
|
|||||||
<string name="TR_SCREENOTHEME_COVERLOADING">Chargement des couvertures</string>
|
<string name="TR_SCREENOTHEME_COVERLOADING">Chargement des couvertures</string>
|
||||||
<string name="TR_SCREENOLYRICS_OPTIONS">Options des paroles</string>
|
<string name="TR_SCREENOLYRICS_OPTIONS">Options des paroles</string>
|
||||||
<string name="TR_SCREENOLYRICS_STYLE">Style</string>
|
<string name="TR_SCREENOLYRICS_STYLE">Style</string>
|
||||||
<string name="TR_SCREENOLYRICS_POSTION">Position des paroles</string>
|
<string name="TR_SCREENOLYRICS_POSITION">Position des paroles</string>
|
||||||
<string name="TR_SCREENOVIDEO_OPTIONS">Options Vidéo</string>
|
<string name="TR_SCREENOVIDEO_OPTIONS">Options Vidéo</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Vidéo en arrière plan</string>
|
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Vidéo en arrière plan</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Prévisualisation des Vidéos</string>
|
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Prévisualisation des Vidéos</string>
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
<string name="TR_USERROLE_GUEST">Gast</string>
|
<string name="TR_USERROLE_GUEST">Gast</string>
|
||||||
<string name="TR_USERROLE_NORMAL">Normaler Benutzer</string>
|
<string name="TR_USERROLE_NORMAL">Normaler Benutzer</string>
|
||||||
<string name="TR_USERROLE_ADMIN">Administrator</string>
|
<string name="TR_USERROLE_ADMIN">Administrator</string>
|
||||||
|
<string name="TR_USERROLE_KEYBOARDUSER">Tastatursteuerer</string>
|
||||||
<string name="TR_CONFIG_SOFTWARE">Software</string>
|
<string name="TR_CONFIG_SOFTWARE">Software</string>
|
||||||
<string name="TR_CONFIG_OPENGL">OpenGL</string>
|
<string name="TR_CONFIG_OPENGL">OpenGL</string>
|
||||||
<string name="TR_CONFIG_DIRECT3D">Direct3D</string>
|
<string name="TR_CONFIG_DIRECT3D">Direct3D</string>
|
||||||
@@ -200,7 +201,7 @@
|
|||||||
<string name="TR_SCREENOTHEME_COVERLOADING">Cover Ladeverhalten</string>
|
<string name="TR_SCREENOTHEME_COVERLOADING">Cover Ladeverhalten</string>
|
||||||
<string name="TR_SCREENOLYRICS_OPTIONS">Songtexteinstellungen</string>
|
<string name="TR_SCREENOLYRICS_OPTIONS">Songtexteinstellungen</string>
|
||||||
<string name="TR_SCREENOLYRICS_STYLE">Stil</string>
|
<string name="TR_SCREENOLYRICS_STYLE">Stil</string>
|
||||||
<string name="TR_SCREENOLYRICS_POSTION">Songtext-Position</string>
|
<string name="TR_SCREENOLYRICS_POSITION">Songtext-Position</string>
|
||||||
<string name="TR_SCREENOVIDEO_OPTIONS">Videoeinstellungen</string>
|
<string name="TR_SCREENOVIDEO_OPTIONS">Videoeinstellungen</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Video-Hintergründe</string>
|
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Video-Hintergründe</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Video-Vorschau</string>
|
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Video-Vorschau</string>
|
||||||
|
|||||||
@@ -200,7 +200,7 @@
|
|||||||
<string name="TR_SCREENOTHEME_COVERLOADING">Beteende För Hur Omslag Laddas</string>
|
<string name="TR_SCREENOTHEME_COVERLOADING">Beteende För Hur Omslag Laddas</string>
|
||||||
<string name="TR_SCREENOLYRICS_OPTIONS">Låttext Alternativ</string>
|
<string name="TR_SCREENOLYRICS_OPTIONS">Låttext Alternativ</string>
|
||||||
<string name="TR_SCREENOLYRICS_STYLE">Utseende</string>
|
<string name="TR_SCREENOLYRICS_STYLE">Utseende</string>
|
||||||
<string name="TR_SCREENOLYRICS_POSTION">Text position</string>
|
<string name="TR_SCREENOLYRICS_POSITION">Text position</string>
|
||||||
<string name="TR_SCREENOVIDEO_OPTIONS">Video Alternativ</string>
|
<string name="TR_SCREENOVIDEO_OPTIONS">Video Alternativ</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Video Bakgrund</string>
|
<string name="TR_SCREENOVIDEO_VIDEOBACKGROUNDS">Video Bakgrund</string>
|
||||||
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Video Förhandsvisning</string>
|
<string name="TR_SCREENOVIDEO_VIDEOPREVIEW">Video Förhandsvisning</string>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
while (_Data.ScreenNames.ProfileIDs.Count > _NumPlayer)
|
while (_Data.ScreenNames.ProfileIDs.Count > _NumPlayer)
|
||||||
_Data.ScreenNames.ProfileIDs.RemoveAt(_Data.ScreenNames.ProfileIDs.Count - 1);
|
_Data.ScreenNames.ProfileIDs.RemoveAt(_Data.ScreenNames.ProfileIDs.Count - 1);
|
||||||
|
|
||||||
List<int>[] ids = new List<int>[] { _Data.ScreenNames.ProfileIDs };
|
List<int>[] ids = new List<int>[] {_Data.ScreenNames.ProfileIDs};
|
||||||
SetPartyModeProfiles(ids);
|
SetPartyModeProfiles(ids);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -77,7 +77,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
public override void Back()
|
public override void Back()
|
||||||
{
|
{
|
||||||
SPartyNameOptions options = GetData();
|
SPartyNameOptions options = GetData();
|
||||||
if(options.TeamList.Length == 1)
|
if (options.TeamList.Length == 1)
|
||||||
_Data.ScreenNames.ProfileIDs = options.TeamList[0];
|
_Data.ScreenNames.ProfileIDs = options.TeamList[0];
|
||||||
_Data.ScreenNames.FadeBack = true;
|
_Data.ScreenNames.FadeBack = true;
|
||||||
_PartyMode.DataFromScreen(ThemeName, _Data);
|
_PartyMode.DataFromScreen(ThemeName, _Data);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
|||||||
while (_Data.ScreenNames.ProfileIDs.Count > _NumPlayer)
|
while (_Data.ScreenNames.ProfileIDs.Count > _NumPlayer)
|
||||||
_Data.ScreenNames.ProfileIDs.RemoveAt(_Data.ScreenNames.ProfileIDs.Count - 1);
|
_Data.ScreenNames.ProfileIDs.RemoveAt(_Data.ScreenNames.ProfileIDs.Count - 1);
|
||||||
|
|
||||||
List<int>[] ids = new List<int>[] { _Data.ScreenNames.ProfileIDs };
|
List<int>[] ids = new List<int>[] {_Data.ScreenNames.ProfileIDs};
|
||||||
SetPartyModeProfiles(ids);
|
SetPartyModeProfiles(ids);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -70,7 +70,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Back()
|
public override void Back()
|
||||||
{
|
{
|
||||||
SPartyNameOptions options = GetData();
|
SPartyNameOptions options = GetData();
|
||||||
|
|||||||
@@ -77,11 +77,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void OnShow()
|
public override void OnShow()
|
||||||
{
|
{
|
||||||
base.OnShow();
|
base.OnShow();
|
||||||
SetPartyModeData(2, _NumPlayerTeam1 + _NumPlayerTeam2, new int[] { _NumPlayerTeam1, _NumPlayerTeam2 });
|
SetPartyModeData(2, _NumPlayerTeam1 + _NumPlayerTeam2, new int[] {_NumPlayerTeam1, _NumPlayerTeam2});
|
||||||
List<int>[] ids = new List<int>[] {_Data.ScreenNames.ProfileIDsTeam1, _Data.ScreenNames.ProfileIDsTeam2};
|
List<int>[] ids = new List<int>[] {_Data.ScreenNames.ProfileIDsTeam1, _Data.ScreenNames.ProfileIDsTeam2};
|
||||||
SetPartyModeProfiles(ids);
|
SetPartyModeProfiles(ids);
|
||||||
}
|
}
|
||||||
@@ -89,7 +88,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
|||||||
public override void Back()
|
public override void Back()
|
||||||
{
|
{
|
||||||
SPartyNameOptions options = GetData();
|
SPartyNameOptions options = GetData();
|
||||||
if(options.TeamList.Length == 2)
|
if (options.TeamList.Length == 2)
|
||||||
{
|
{
|
||||||
_Data.ScreenNames.ProfileIDsTeam1 = options.TeamList[0];
|
_Data.ScreenNames.ProfileIDsTeam1 = options.TeamList[0];
|
||||||
_Data.ScreenNames.ProfileIDsTeam2 = options.TeamList[1];
|
_Data.ScreenNames.ProfileIDsTeam2 = options.TeamList[1];
|
||||||
|
|||||||
+12
-14
@@ -9,7 +9,7 @@
|
|||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SpecifyACultureInStringConversionExplicitly/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SpecifyACultureInStringConversionExplicitly/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEverywhere/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEverywhere/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Cleanup/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="Cleanup"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_EXPLICIT</BehavourStyle><LocalVariableStyle>IMPLICIT_WHEN_INITIALIZER_HAS_TYPE</LocalVariableStyle><ForeachVariableStyle>ALWAYS_EXPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSShortenReferences>True</CSShortenReferences><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMusLine truncated
|
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Cleanup/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="Cleanup"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSUseVar><BehavourStyle>CAN_CHANGE_TO_EXPLICIT</BehavourStyle><LocalVariableStyle>IMPLICIT_WHEN_INITIALIZER_HAS_TYPE</LocalVariableStyle><ForeachVariableStyle>ALWAYS_EXPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSharpFormatDocComments>True</CSharpFormatDocComments><CSShortenReferences>True</CSShortenReferences><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpace>True</SA1006PreprocessorKeywordLine truncated
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Simple_0020Reformat/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="Simple Reformat"><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpace>True</SA1006PreprocessorKeywordsMustNotBePrecededBySpace><SA1021NegativeSignsMustBeSpacedCorrectly>True</SA1021NegativeSignsMustBeSpacedCorrectly><SA1022PositiveSignsMustBeSpacedCorrectly>True</SA1022PositiveSignsMustBeSpacedCorrectly><SA1025CodeMustNotContainMultipleWhitespaceInARow>True</SA1025CodeMustNotContainMultipleWhitespaceInARow></StyleCop.Spacing><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Ordering><AlphabeticalUsingDirectives>Ignore</AlphabeticalUsingDirectives><ExpandUsingDirectiLine truncated
|
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Simple_0020Reformat/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="Simple Reformat"><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><StyleCop.Documentation><SA1600ElementsMustBeDocumented>False</SA1600ElementsMustBeDocumented><SA1604ElementDocumentationMustHaveSummary>False</SA1604ElementDocumentationMustHaveSummary><SA1609PropertyDocumentationMustHaveValueDocumented>False</SA1609PropertyDocumentationMustHaveValueDocumented><SA1611ElementParametersMustBeDocumented>False</SA1611ElementParametersMustBeDocumented><SA1615ElementReturnValueMustBeDocumented>False</SA1615ElementReturnValueMustBeDocumented><SA1617VoidReturnValueMustNotBeDocumented>False</SA1617VoidReturnValueMustNotBeDocumented><SA1618GenericTypeParametersMustBeDocumented>False</SA1618GenericTypeParametersMustBeDocumented><SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes>False</SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes><SA1628DocumentationTextMustBeginWithACapitalLetter>False</SA1628DocumentationTextMustBeginWithACapitalLetter><SA1629DocumentationTextMustEndWithAPeriod>False</SA1629DocumentationTextMustEndWithAPeriod><SA1633SA1641UpdateFileHeader>Ignore</SA1633SA1641UpdateFileHeader><SA1639FileHeaderMustHaveSummary>False</SA1639FileHeaderMustHaveSummary><SA1642ConstructorSummaryDocumentationMustBeginWithStandardText>False</SA1642ConstructorSummaryDocumentationMustBeginWithStandardText><SA1643DestructorSummaryDocumentationMustBeginWithStandardText>False</SA1643DestructorSummaryDocumentationMustBeginWithStandardText><SA1644DocumentationHeadersMustNotContainBlankLines>False</SA1644DocumentationHeadersMustNotContainBlankLines></StyleCop.Documentation><StyleCop.Spacing><SA1001CommasMustBeSpacedCorrectly>False</SA1001CommasMustBeSpacedCorrectly><SA1005SingleLineCommentsMustBeginWithSingleSpace>False</SA1005SingleLineCommentsMustBeginWithSingleSpace><SA1006PreprocessorKeywordsMustNotBePrecededBySpace>True</SA1006PreprocessorKeywordsMustNotBePrecededBySpace><SA1021NegativeSignsMustBeSpacedCorrectly>True</SA1021NegativeSignsMustBeSpacedCorrectly><SA1022PositiveSignsMustBeSpacedCorrectly>True</SA1022PositiveSignsMustBeSpacedCorrectly><SA1025CodeMustNotContainMultipleWhitespaceInARow>True</SA1025CodeMustNotContainMultipleWhitespaceInARow></StyleCop.Spacing><StyleCop.Readability><SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists>True</SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists><SA1106CodeMustNotContainEmptyStatements>True</SA1106CodeMustNotContainEmptyStatements><SA1108BlockStatementsMustNotContainEmbeddedComments>True</SA1108BlockStatementsMustNotContainEmbeddedComments><SA1109BlockStatementsMustNotContainEmbeddedRegions>True</SA1109BlockStatementsMustNotContainEmbeddedRegions><SA1120CommentsMustContainText>False</SA1120CommentsMustContainText><SA1121UseBuiltInTypeAlias>False</SA1121UseBuiltInTypeAlias><SA1122UseStringEmptyForEmptyStrings>False</SA1122UseStringEmptyForEmptyStrings><SA1123DoNotPlaceRegionsWithinElements>False</SA1123DoNotPlaceRegionsWithinElements><SA1124CodeMustNotContainEmptyRegions>True</SA1124CodeMustNotContainEmptyRegions></StyleCop.Readability><StyleCop.Layout><SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine>False</SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine><SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine>True</SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine><SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine>True</SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine><SA1511WhileDoFooterMustNotBePrecededByBlankLine>True</SA1511WhileDoFooterMustNotBePrecededByBlankLine><SA1512SingleLineCommentsMustNotBeFollowedByBlankLine>True</SA1512SingleLineCommentsMustNotBeFollowedByBlankLine><SA1513ClosingCurlyBracketMustBeFollowedByBlankLine>False</SA1513ClosingCurlyBracketMustBeFollowedByBlankLine><SA1514ElementDocumentationHeaderMustBePrecededByBlankLine>False</SA1514ElementDocumentationHeaderMustBePrecededByBlankLine><SA1515SingleLineCommentMustBeProceededByBlankLine>False</SA1515SingleLineCommentMustBeProceededByBlankLine></StyleCop.Layout><StyleCop.Ordering><AlphabeticalUsingDirectives>Ignore</AlphabeticalUsingDirectives><ExpandUsingDirectiLine truncated
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">Cleanup</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">Cleanup</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">Simple Reformat</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">Simple Reformat</s:String>
|
||||||
@@ -41,22 +41,20 @@
|
|||||||
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AllowAlias/@EntryValue">False</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AllowAlias/@EntryValue">False</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">False</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">False</s:Boolean>
|
||||||
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderRegionName/@EntryValue">license</s:String>
|
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderRegionName/@EntryValue">license</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue">/*
|
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue">This file is part of $SOLUTION$.
|
||||||
This file is part of $SOLUTION$.
|
|
||||||

|

|
||||||
$SOLUTION$ is free software: you can redistribute it and/or modify
|
$SOLUTION$ is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||

|

|
||||||
$SOLUTION$ is distributed in the hope that it will be useful,
|
$SOLUTION$ is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||

|

|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with $SOLUTION$. If not, see <http://www.gnu.org/licenses/>.
|
along with $SOLUTION$. If not, see <http://www.gnu.org/licenses/>.</s:String>
|
||||||
*/</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AA/@EntryIndexedValue">AA</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AA/@EntryIndexedValue">AA</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AC/@EntryIndexedValue">AC</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AC/@EntryIndexedValue">AC</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AL/@EntryIndexedValue">AL</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AL/@EntryIndexedValue">AL</s:String>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace Vocaluxe.Base
|
|||||||
static class CConfig
|
static class CConfig
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Uniform settings for writing XML files. ALWAYS use this!
|
/// Uniform settings for writing XML files. ALWAYS use this!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly XmlWriterSettings XMLSettings = new XmlWriterSettings
|
public static readonly XmlWriterSettings XMLSettings = new XmlWriterSettings
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -276,7 +276,8 @@ namespace Vocaluxe.Base
|
|||||||
{
|
{
|
||||||
int tone = notes[note].Tone;
|
int tone = notes[note].Tone;
|
||||||
int tonePlayer = CSound.RecordGetTone(p);
|
int tonePlayer = CSound.RecordGetTone(p);
|
||||||
if (DEBUG_HIT) tonePlayer = tone;
|
if (DEBUG_HIT)
|
||||||
|
tonePlayer = tone;
|
||||||
|
|
||||||
while (tonePlayer - tone > 6)
|
while (tonePlayer - tone > 6)
|
||||||
tonePlayer -= 12;
|
tonePlayer -= 12;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace Vocaluxe.Base
|
|||||||
_Screens.Add(new CScreenHighscore());
|
_Screens.Add(new CScreenHighscore());
|
||||||
_Screens.Add(new CScreenOptionsGame());
|
_Screens.Add(new CScreenOptionsGame());
|
||||||
_Screens.Add(new CScreenOptionsSound());
|
_Screens.Add(new CScreenOptionsSound());
|
||||||
_Screens.Add(new CScreenOptionsRecord());
|
_Screens.Add(new CScreenOptionsRecord());
|
||||||
_Screens.Add(new CScreenOptionsVideo());
|
_Screens.Add(new CScreenOptionsVideo());
|
||||||
_Screens.Add(new CScreenOptionsVideoAdjustments());
|
_Screens.Add(new CScreenOptionsVideoAdjustments());
|
||||||
_Screens.Add(new CScreenOptionsLyrics());
|
_Screens.Add(new CScreenOptionsLyrics());
|
||||||
@@ -375,7 +375,8 @@ namespace Vocaluxe.Base
|
|||||||
if (!eventsAvailable)
|
if (!eventsAvailable)
|
||||||
keyEvent = inputKeyEvent;
|
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();
|
CSettings.MouseInactive();
|
||||||
_Cursor.FadeOut();
|
_Cursor.FadeOut();
|
||||||
|
|||||||
+12
-12
@@ -1,18 +1,18 @@
|
|||||||
#region license
|
#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
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Vocaluxe is distributed in the hope that it will be useful,
|
// Vocaluxe is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -125,7 +125,7 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static int NewPlaylist()
|
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);
|
_Playlists.Add(pl);
|
||||||
return _Playlists.Count - 1;
|
return _Playlists.Count - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-20
@@ -1,18 +1,18 @@
|
|||||||
#region license
|
#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
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Vocaluxe is distributed in the hope that it will be useful,
|
// Vocaluxe is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -202,7 +202,7 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static void LoadProfiles()
|
public static void LoadProfiles()
|
||||||
{
|
{
|
||||||
var change = new SChange { Action = EAction.LoadProfiles };
|
var change = new SChange {Action = EAction.LoadProfiles};
|
||||||
|
|
||||||
lock (_QueueMutex)
|
lock (_QueueMutex)
|
||||||
{
|
{
|
||||||
@@ -212,7 +212,7 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static void LoadAvatars()
|
public static void LoadAvatars()
|
||||||
{
|
{
|
||||||
var change = new SChange { Action = EAction.LoadAvatars };
|
var change = new SChange {Action = EAction.LoadAvatars};
|
||||||
|
|
||||||
lock (_QueueMutex)
|
lock (_QueueMutex)
|
||||||
{
|
{
|
||||||
@@ -225,7 +225,7 @@ namespace Vocaluxe.Base
|
|||||||
if (newProfile == null)
|
if (newProfile == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var change = new SChange { Action = EAction.AddProfile, Profile = newProfile };
|
var change = new SChange {Action = EAction.AddProfile, Profile = newProfile};
|
||||||
|
|
||||||
lock (_QueueMutex)
|
lock (_QueueMutex)
|
||||||
{
|
{
|
||||||
@@ -238,7 +238,7 @@ namespace Vocaluxe.Base
|
|||||||
if (editProfile == null)
|
if (editProfile == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var change = new SChange { Action = EAction.EditProfile, Profile = editProfile };
|
var change = new SChange {Action = EAction.EditProfile, Profile = editProfile};
|
||||||
|
|
||||||
lock (_QueueMutex)
|
lock (_QueueMutex)
|
||||||
{
|
{
|
||||||
@@ -251,7 +251,7 @@ namespace Vocaluxe.Base
|
|||||||
if (!IsProfileIDValid(profileID))
|
if (!IsProfileIDValid(profileID))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var change = new SChange { Action = EAction.DeleteProfile, ProfileID = profileID };
|
var change = new SChange {Action = EAction.DeleteProfile, ProfileID = profileID};
|
||||||
|
|
||||||
lock (_QueueMutex)
|
lock (_QueueMutex)
|
||||||
{
|
{
|
||||||
@@ -264,7 +264,7 @@ namespace Vocaluxe.Base
|
|||||||
if (newAvatar == null)
|
if (newAvatar == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var change = new SChange { Action = EAction.AddAvatar, Avatar = newAvatar };
|
var change = new SChange {Action = EAction.AddAvatar, Avatar = newAvatar};
|
||||||
|
|
||||||
lock (_QueueMutex)
|
lock (_QueueMutex)
|
||||||
{
|
{
|
||||||
@@ -277,7 +277,7 @@ namespace Vocaluxe.Base
|
|||||||
if (editAvatar == null)
|
if (editAvatar == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var change = new SChange { Action = EAction.EditAvatar, Avatar = editAvatar };
|
var change = new SChange {Action = EAction.EditAvatar, Avatar = editAvatar};
|
||||||
|
|
||||||
lock (_QueueMutex)
|
lock (_QueueMutex)
|
||||||
{
|
{
|
||||||
@@ -298,9 +298,7 @@ namespace Vocaluxe.Base
|
|||||||
public static CProfile GetProfile(int profileID)
|
public static CProfile GetProfile(int profileID)
|
||||||
{
|
{
|
||||||
if (!IsProfileIDValid(profileID))
|
if (!IsProfileIDValid(profileID))
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
return _Profiles[profileID];
|
return _Profiles[profileID];
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -1,18 +1,18 @@
|
|||||||
#region license
|
#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
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Vocaluxe is distributed in the hope that it will be useful,
|
// Vocaluxe is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@@ -226,13 +226,13 @@ namespace Vocaluxe.Base
|
|||||||
totalCounts += song.NumPlayedSession;
|
totalCounts += song.NumPlayedSession;
|
||||||
int averageCount = totalCounts / NumSongsVisible;
|
int averageCount = totalCounts / NumSongsVisible;
|
||||||
|
|
||||||
foreach(CSong song in VisibleSongs)
|
foreach (CSong song in VisibleSongs)
|
||||||
{
|
{
|
||||||
if (song.NumPlayedSession <= averageCount)
|
if (song.NumPlayedSession <= averageCount)
|
||||||
_SongsForRandom.Add(song);
|
_SongsForRandom.Add(song);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_SongsForRandom.Count == 0)
|
if (_SongsForRandom.Count == 0)
|
||||||
_SongsForRandom.AddRange(VisibleSongs);
|
_SongsForRandom.AddRange(VisibleSongs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ namespace Vocaluxe.Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets category with given index or null for invalid index
|
/// Gets category with given index or null for invalid index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <returns>category with given index or null for invalid index</returns>
|
/// <returns>category with given index or null for invalid index</returns>
|
||||||
@@ -308,7 +308,7 @@ namespace Vocaluxe.Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <returns>visible song with given index or null for invalid index or song not visible</returns>
|
/// <returns>visible song with given index or null for invalid index or song not visible</returns>
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace Vocaluxe.Base.Server
|
|||||||
stream.Write(cmd, 0, cmd.Length);
|
stream.Write(cmd, 0, cmd.Length);
|
||||||
|
|
||||||
byte[] data;
|
byte[] data;
|
||||||
string json = JsonConvert.SerializeObject(obj);
|
string json = JsonConvert.SerializeObject(obj);
|
||||||
data = _Encoder.GetBytes(json);
|
data = _Encoder.GetBytes(json);
|
||||||
stream.Write(data, 0, data.Length);
|
stream.Write(data, 0, data.Length);
|
||||||
return stream.ToArray();
|
return stream.ToArray();
|
||||||
@@ -115,16 +115,16 @@ namespace Vocaluxe.Base.Server
|
|||||||
|
|
||||||
var data = new byte[message.Length - 4];
|
var data = new byte[message.Length - 4];
|
||||||
Array.Copy(message, 4, data, 0, data.Length);
|
Array.Copy(message, 4, data, 0, data.Length);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
obj = JsonConvert.DeserializeObject<T>(_Encoder.GetString(data));
|
obj = JsonConvert.DeserializeObject<T>(_Encoder.GetString(data));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion Serializing
|
#endregion Serializing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
#region license
|
#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
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Vocaluxe is distributed in the hope that it will be useful,
|
// Vocaluxe is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@@ -137,7 +137,7 @@ namespace Vocaluxe.Base.Server
|
|||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
foreach (char c in key.ToCharArray())
|
foreach (char c in key)
|
||||||
{
|
{
|
||||||
bool shift = true;
|
bool shift = true;
|
||||||
char keyChar;
|
char keyChar;
|
||||||
@@ -147,17 +147,13 @@ namespace Vocaluxe.Base.Server
|
|||||||
shift = false;
|
shift = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
keyChar = c;
|
keyChar = c;
|
||||||
}
|
|
||||||
|
|
||||||
if ((keyChar >= 0x30 && keyChar <= 0x39) || (keyChar >= 0x41 && keyChar <= 0x5A))
|
if ((keyChar >= 0x30 && keyChar <= 0x39) || (keyChar >= 0x41 && keyChar <= 0x5A))
|
||||||
{
|
{
|
||||||
Keys keys = (Keys)keyChar;
|
Keys keys = (Keys)keyChar;
|
||||||
if (shift)
|
if (shift)
|
||||||
{
|
|
||||||
keys |= Keys.Shift;
|
keys |= Keys.Shift;
|
||||||
}
|
|
||||||
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, keys));
|
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, keys));
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
@@ -167,18 +163,14 @@ namespace Vocaluxe.Base.Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region profile
|
#region profile
|
||||||
|
|
||||||
private static SProfileData _GetProfileData(int profileId, bool isReadonly)
|
private static SProfileData _GetProfileData(int profileId, bool isReadonly)
|
||||||
{
|
{
|
||||||
CProfile profile = CProfiles.GetProfile(profileId);
|
CProfile profile = CProfiles.GetProfile(profileId);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
|
||||||
return new SProfileData();
|
return new SProfileData();
|
||||||
}
|
|
||||||
return _CreateProfileData(profile, isReadonly);
|
return _CreateProfileData(profile, isReadonly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,31 +182,28 @@ namespace Vocaluxe.Base.Server
|
|||||||
if (existingProfile != null)
|
if (existingProfile != null)
|
||||||
{
|
{
|
||||||
newProfile = new CProfile
|
newProfile = new CProfile
|
||||||
{
|
{
|
||||||
ID = existingProfile.ID,
|
ID = existingProfile.ID,
|
||||||
FileName = existingProfile.FileName,
|
FileName = existingProfile.FileName,
|
||||||
Active = existingProfile.Active,
|
Active = existingProfile.Active,
|
||||||
AvatarFileName = existingProfile.AvatarFileName,
|
AvatarFileName = existingProfile.AvatarFileName,
|
||||||
Avatar = existingProfile.Avatar,
|
Avatar = existingProfile.Avatar,
|
||||||
Difficulty = existingProfile.Difficulty,
|
Difficulty = existingProfile.Difficulty,
|
||||||
UserRole = existingProfile.UserRole,
|
UserRole = existingProfile.UserRole,
|
||||||
PlayerName = existingProfile.PlayerName
|
PlayerName = existingProfile.PlayerName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newProfile = new CProfile
|
newProfile = new CProfile
|
||||||
{
|
{
|
||||||
Active = EOffOn.TR_CONFIG_ON,
|
Active = EOffOn.TR_CONFIG_ON,
|
||||||
UserRole = EUserRole.TR_USERROLE_NORMAL
|
UserRole = EUserRole.TR_USERROLE_NORMAL
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.Avatar != null)
|
if (profile.Avatar != null)
|
||||||
{
|
|
||||||
newProfile.Avatar = _AddAvatar(profile.Avatar);
|
newProfile.Avatar = _AddAvatar(profile.Avatar);
|
||||||
|
|
||||||
}
|
|
||||||
else if (newProfile.Avatar == null || newProfile.Avatar.ID == -1)
|
else if (newProfile.Avatar == null || newProfile.Avatar.ID == -1)
|
||||||
{
|
{
|
||||||
newProfile.Avatar = CProfiles.GetAvatars().First();
|
newProfile.Avatar = CProfiles.GetAvatars().First();
|
||||||
@@ -226,22 +215,16 @@ namespace Vocaluxe.Base.Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(profile.PlayerName))
|
if (!string.IsNullOrEmpty(profile.PlayerName))
|
||||||
{
|
|
||||||
newProfile.PlayerName = profile.PlayerName;
|
newProfile.PlayerName = profile.PlayerName;
|
||||||
}
|
|
||||||
else if (!string.IsNullOrEmpty(newProfile.PlayerName))
|
else if (!string.IsNullOrEmpty(newProfile.PlayerName))
|
||||||
{
|
|
||||||
newProfile.PlayerName = "DummyName";
|
newProfile.PlayerName = "DummyName";
|
||||||
}
|
|
||||||
|
|
||||||
if (profile.Difficulty >= 0 && profile.Difficulty <= 2)
|
if (profile.Difficulty >= 0 && profile.Difficulty <= 2)
|
||||||
{
|
|
||||||
newProfile.Difficulty = (EGameDifficulty)profile.Difficulty;
|
newProfile.Difficulty = (EGameDifficulty)profile.Difficulty;
|
||||||
}
|
|
||||||
|
|
||||||
if (profile.Type >= 0 && profile.Type <= 1)
|
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
|
//Only allow the change of TR_USERROLE_GUEST and TR_USERROLE_NORMAL
|
||||||
const EUserRole mask = EUserRole.TR_USERROLE_NORMAL;
|
const EUserRole mask = EUserRole.TR_USERROLE_NORMAL;
|
||||||
newProfile.UserRole = (newProfile.UserRole & mask) | option;
|
newProfile.UserRole = (newProfile.UserRole & mask) | option;
|
||||||
@@ -274,9 +257,7 @@ namespace Vocaluxe.Base.Server
|
|||||||
CProfiles.SaveProfiles();
|
CProfiles.SaveProfiles();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
CProfiles.AddProfile(newProfile);
|
CProfiles.AddProfile(newProfile);
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -293,22 +274,20 @@ namespace Vocaluxe.Base.Server
|
|||||||
private static SProfileData _CreateProfileData(CProfile profile, bool isReadonly)
|
private static SProfileData _CreateProfileData(CProfile profile, bool isReadonly)
|
||||||
{
|
{
|
||||||
SProfileData profileData = new SProfileData
|
SProfileData profileData = new SProfileData
|
||||||
{
|
{
|
||||||
IsEditable = !isReadonly,
|
IsEditable = !isReadonly,
|
||||||
ProfileId = profile.ID,
|
ProfileId = profile.ID,
|
||||||
PlayerName = profile.PlayerName,
|
PlayerName = profile.PlayerName,
|
||||||
//Is TR_USERROLE_GUEST or TR_USERROLE_NORMAL?
|
//Is TR_USERROLE_GUEST or TR_USERROLE_NORMAL?
|
||||||
Type = (profile.UserRole.HasFlag(EUserRole.TR_USERROLE_NORMAL)?1:0),
|
Type = (profile.UserRole.HasFlag(EUserRole.TR_USERROLE_NORMAL) ? 1 : 0),
|
||||||
Difficulty = (int)profile.Difficulty
|
Difficulty = (int)profile.Difficulty
|
||||||
};
|
};
|
||||||
|
|
||||||
CAvatar avatar = profile.Avatar;
|
CAvatar avatar = profile.Avatar;
|
||||||
if (avatar != null)
|
if (avatar != null)
|
||||||
{
|
{
|
||||||
if (File.Exists(avatar.FileName))
|
if (File.Exists(avatar.FileName))
|
||||||
{
|
|
||||||
profileData.Avatar = new CBase64Image(_CreateDelayedImage(avatar.FileName));
|
profileData.Avatar = new CBase64Image(_CreateDelayedImage(avatar.FileName));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return profileData;
|
return profileData;
|
||||||
}
|
}
|
||||||
@@ -332,19 +311,15 @@ namespace Vocaluxe.Base.Server
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region photo
|
#region photo
|
||||||
|
|
||||||
private static List<string> photosOfThisRound = new List<string>();
|
private static List<string> photosOfThisRound = new List<string>();
|
||||||
|
|
||||||
private static bool _SendPhoto(SPhotoData photoData)
|
private static bool _SendPhoto(SPhotoData photoData)
|
||||||
{
|
{
|
||||||
if (photoData.Photo == null)
|
if (photoData.Photo == null)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
string name = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
string name = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
||||||
string filePath = _SaveImage(photoData.Photo, name, CSettings.FolderPhotos);
|
string filePath = _SaveImage(photoData.Photo, name, CSettings.FolderPhotos);
|
||||||
@@ -359,15 +334,13 @@ namespace Vocaluxe.Base.Server
|
|||||||
|
|
||||||
internal static string[] getPhotosOfThisRound()
|
internal static string[] getPhotosOfThisRound()
|
||||||
{
|
{
|
||||||
var result = photosOfThisRound.ToArray();
|
string[] result = photosOfThisRound.ToArray();
|
||||||
photosOfThisRound.Clear();
|
photosOfThisRound.Clear();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region website
|
#region website
|
||||||
|
|
||||||
private static readonly Dictionary<string, string> _DelayedImagePath = new Dictionary<string, string>();
|
private static readonly Dictionary<string, string> _DelayedImagePath = new Dictionary<string, string>();
|
||||||
|
|
||||||
private static byte[] _GetSiteFile(string filename)
|
private static byte[] _GetSiteFile(string filename)
|
||||||
@@ -376,9 +349,7 @@ namespace Vocaluxe.Base.Server
|
|||||||
path = path.Replace("..", "");
|
path = path.Replace("..", "");
|
||||||
|
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
/*string content = File.ReadAllText(path);
|
/*string content = File.ReadAllText(path);
|
||||||
|
|
||||||
@@ -395,25 +366,19 @@ namespace Vocaluxe.Base.Server
|
|||||||
byte[] by = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(filename));
|
byte[] by = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(filename));
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
foreach (byte b in by)
|
foreach (byte b in by)
|
||||||
{
|
|
||||||
sb.Append(b.ToString("x2"));
|
sb.Append(b.ToString("x2"));
|
||||||
}
|
|
||||||
|
|
||||||
string hashedFilename = sb.ToString();
|
string hashedFilename = sb.ToString();
|
||||||
|
|
||||||
if (!_DelayedImagePath.ContainsKey(hashedFilename))
|
if (!_DelayedImagePath.ContainsKey(hashedFilename))
|
||||||
{
|
|
||||||
_DelayedImagePath.Add(hashedFilename, filename);
|
_DelayedImagePath.Add(hashedFilename, filename);
|
||||||
}
|
|
||||||
return hashedFilename;
|
return hashedFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CBase64Image _GetDelayedImage(string hashedFilename)
|
private static CBase64Image _GetDelayedImage(string hashedFilename)
|
||||||
{
|
{
|
||||||
if (!_DelayedImagePath.ContainsKey(hashedFilename))
|
if (!_DelayedImagePath.ContainsKey(hashedFilename))
|
||||||
{
|
|
||||||
throw new FileNotFoundException("Image not found");
|
throw new FileNotFoundException("Image not found");
|
||||||
}
|
|
||||||
|
|
||||||
string fileName = _DelayedImagePath[hashedFilename];
|
string fileName = _DelayedImagePath[hashedFilename];
|
||||||
|
|
||||||
@@ -424,11 +389,9 @@ namespace Vocaluxe.Base.Server
|
|||||||
}
|
}
|
||||||
throw new FileNotFoundException("Image not found");
|
throw new FileNotFoundException("Image not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region songs
|
#region songs
|
||||||
|
|
||||||
private static SSongInfo _GetSong(int songId)
|
private static SSongInfo _GetSong(int songId)
|
||||||
{
|
{
|
||||||
CSong song = CSongs.GetSong(songId);
|
CSong song = CSongs.GetSong(songId);
|
||||||
@@ -437,7 +400,7 @@ namespace Vocaluxe.Base.Server
|
|||||||
|
|
||||||
private static SSongInfo[] _GetAllSongs()
|
private static SSongInfo[] _GetAllSongs()
|
||||||
{
|
{
|
||||||
var songs = CSongs.Songs;
|
List<CSong> songs = CSongs.Songs;
|
||||||
return (from s in songs
|
return (from s in songs
|
||||||
select _GetSongInfo(s, false)).ToArray<SSongInfo>();
|
select _GetSongInfo(s, false)).ToArray<SSongInfo>();
|
||||||
}
|
}
|
||||||
@@ -446,9 +409,7 @@ namespace Vocaluxe.Base.Server
|
|||||||
{
|
{
|
||||||
CSong song = CGame.GetSong();
|
CSong song = CGame.GetSong();
|
||||||
if (song == null)
|
if (song == null)
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
return song.ID;
|
return song.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,17 +426,13 @@ namespace Vocaluxe.Base.Server
|
|||||||
result.IsDuet = song.IsDuet;
|
result.IsDuet = song.IsDuet;
|
||||||
result.SongId = song.ID;
|
result.SongId = song.ID;
|
||||||
if (includeCover)
|
if (includeCover)
|
||||||
{
|
|
||||||
result.Cover = new CBase64Image(_CreateDelayedImage(song.Folder + "\\" + song.CoverFileName));
|
result.Cover = new CBase64Image(_CreateDelayedImage(song.Folder + "\\" + song.CoverFileName));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region playlist
|
#region playlist
|
||||||
|
|
||||||
private static SPlaylistInfo[] _GetPlaylists()
|
private static SPlaylistInfo[] _GetPlaylists()
|
||||||
{
|
{
|
||||||
return (from p in CPlaylists.Playlists
|
return (from p in CPlaylists.Playlists
|
||||||
@@ -485,18 +442,14 @@ namespace Vocaluxe.Base.Server
|
|||||||
private static SPlaylistInfo _GetPlaylist(int playlistId)
|
private static SPlaylistInfo _GetPlaylist(int playlistId)
|
||||||
{
|
{
|
||||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid playlistId");
|
throw new ArgumentException("invalid playlistId");
|
||||||
}
|
|
||||||
return _GetPlaylistInfo(CPlaylists.Playlists[playlistId]);
|
return _GetPlaylistInfo(CPlaylists.Playlists[playlistId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void _AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates)
|
private static void _AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates)
|
||||||
{
|
{
|
||||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid playlistId");
|
throw new ArgumentException("invalid playlistId");
|
||||||
}
|
|
||||||
|
|
||||||
if (allowDuplicates || !_PlaylistContainsSong(songId, playlistId))
|
if (allowDuplicates || !_PlaylistContainsSong(songId, playlistId))
|
||||||
{
|
{
|
||||||
@@ -504,26 +457,18 @@ namespace Vocaluxe.Base.Server
|
|||||||
CPlaylists.SavePlaylist(playlistId);
|
CPlaylists.SavePlaylist(playlistId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
throw new ArgumentException("song exists in this playlist");
|
throw new ArgumentException("song exists in this playlist");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void _RemoveSongFromPlaylist(int position, int playlistId, int songId)
|
private static void _RemoveSongFromPlaylist(int position, int playlistId, int songId)
|
||||||
{
|
{
|
||||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid playlistId");
|
throw new ArgumentException("invalid playlistId");
|
||||||
}
|
|
||||||
if (!_PlaylistContainsSong(songId, playlistId))
|
if (!_PlaylistContainsSong(songId, playlistId))
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid songId");
|
throw new ArgumentException("invalid songId");
|
||||||
}
|
|
||||||
if (position < 0 || CPlaylists.Playlists[playlistId].Songs.Count <= position
|
if (position < 0 || CPlaylists.Playlists[playlistId].Songs.Count <= position
|
||||||
|| CPlaylists.Playlists[playlistId].Songs[position].SongID != songId)
|
|| CPlaylists.Playlists[playlistId].Songs[position].SongID != songId)
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid position");
|
throw new ArgumentException("invalid position");
|
||||||
}
|
|
||||||
CPlaylists.Playlists[playlistId].DeleteSong(position);
|
CPlaylists.Playlists[playlistId].DeleteSong(position);
|
||||||
CPlaylists.SavePlaylist(playlistId);
|
CPlaylists.SavePlaylist(playlistId);
|
||||||
}
|
}
|
||||||
@@ -531,18 +476,12 @@ namespace Vocaluxe.Base.Server
|
|||||||
private static void _MoveSongInPlaylist(int newPosition, int playlistId, int songId)
|
private static void _MoveSongInPlaylist(int newPosition, int playlistId, int songId)
|
||||||
{
|
{
|
||||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid playlistId");
|
throw new ArgumentException("invalid playlistId");
|
||||||
}
|
|
||||||
if (!_PlaylistContainsSong(songId, playlistId))
|
if (!_PlaylistContainsSong(songId, playlistId))
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid songId");
|
throw new ArgumentException("invalid songId");
|
||||||
}
|
|
||||||
|
|
||||||
if (CPlaylists.Playlists[playlistId].Songs.Count < newPosition)
|
if (CPlaylists.Playlists[playlistId].Songs.Count < newPosition)
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid newPosition");
|
throw new ArgumentException("invalid newPosition");
|
||||||
}
|
|
||||||
|
|
||||||
int oldPosition = CPlaylists.Playlists[playlistId].Songs.FindIndex(s => s.SongID == songId);
|
int oldPosition = CPlaylists.Playlists[playlistId].Songs.FindIndex(s => s.SongID == songId);
|
||||||
CPlaylists.MovePlaylistSong(playlistId, oldPosition, newPosition);
|
CPlaylists.MovePlaylistSong(playlistId, oldPosition, newPosition);
|
||||||
@@ -552,18 +491,14 @@ namespace Vocaluxe.Base.Server
|
|||||||
private static bool _PlaylistContainsSong(int songId, int playlistId)
|
private static bool _PlaylistContainsSong(int songId, int playlistId)
|
||||||
{
|
{
|
||||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid playlistId");
|
throw new ArgumentException("invalid playlistId");
|
||||||
}
|
|
||||||
return CPlaylists.Playlists[playlistId].Songs.Any(s => s.SongID == songId);
|
return CPlaylists.Playlists[playlistId].Songs.Any(s => s.SongID == songId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SPlaylistSongInfo[] _GetPlaylistSongs(int playlistId)
|
private static SPlaylistSongInfo[] _GetPlaylistSongs(int playlistId)
|
||||||
{
|
{
|
||||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid playlistId");
|
throw new ArgumentException("invalid playlistId");
|
||||||
}
|
|
||||||
|
|
||||||
return _GetPlaylistSongInfos(CPlaylists.Playlists[playlistId]);
|
return _GetPlaylistSongInfos(CPlaylists.Playlists[playlistId]);
|
||||||
}
|
}
|
||||||
@@ -585,29 +520,25 @@ namespace Vocaluxe.Base.Server
|
|||||||
{
|
{
|
||||||
SPlaylistSongInfo[] result = new SPlaylistSongInfo[playlist.Songs.Count];
|
SPlaylistSongInfo[] result = new SPlaylistSongInfo[playlist.Songs.Count];
|
||||||
for (int i = 0; i < playlist.Songs.Count; i++)
|
for (int i = 0; i < playlist.Songs.Count; i++)
|
||||||
{
|
|
||||||
result[i] = _GetPlaylistSongInfo(playlist.Songs[i], playlist.Id, i);
|
result[i] = _GetPlaylistSongInfo(playlist.Songs[i], playlist.Id, i);
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SPlaylistInfo _GetPlaylistInfo(CPlaylistFile playlist)
|
private static SPlaylistInfo _GetPlaylistInfo(CPlaylistFile playlist)
|
||||||
{
|
{
|
||||||
return new SPlaylistInfo
|
return new SPlaylistInfo
|
||||||
{
|
{
|
||||||
PlaylistId = playlist.Id,
|
PlaylistId = playlist.Id,
|
||||||
PlaylistName = playlist.PlaylistName,
|
PlaylistName = playlist.PlaylistName,
|
||||||
SongCount = playlist.Songs.Count,
|
SongCount = playlist.Songs.Count,
|
||||||
LastChanged = DateTime.Now.ToLongDateString()
|
LastChanged = DateTime.Now.ToLongDateString()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void _RemovePlaylist(int playlistId)
|
private static void _RemovePlaylist(int playlistId)
|
||||||
{
|
{
|
||||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||||
{
|
|
||||||
throw new ArgumentException("invalid playlistId");
|
throw new ArgumentException("invalid playlistId");
|
||||||
}
|
|
||||||
CPlaylists.DeletePlaylist(playlistId);
|
CPlaylists.DeletePlaylist(playlistId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,25 +550,19 @@ namespace Vocaluxe.Base.Server
|
|||||||
|
|
||||||
return newPlaylistId;
|
return newPlaylistId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region user management
|
#region user management
|
||||||
|
|
||||||
private static bool _ValidatePassword(int profileId, string password)
|
private static bool _ValidatePassword(int profileId, string password)
|
||||||
{
|
{
|
||||||
CProfile profile = CProfiles.GetProfile(profileId);
|
CProfile profile = CProfiles.GetProfile(profileId);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
|
||||||
throw new ArgumentException("Invalid profileId");
|
throw new ArgumentException("Invalid profileId");
|
||||||
}
|
|
||||||
|
|
||||||
if (profile.PasswordHash == null)
|
if (profile.PasswordHash == null)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(password))
|
if (string.IsNullOrEmpty(password))
|
||||||
{
|
|
||||||
return true; //Allow emty passwords
|
return true; //Allow emty passwords
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,16 +574,12 @@ namespace Vocaluxe.Base.Server
|
|||||||
{
|
{
|
||||||
CProfile profile = CProfiles.GetProfile(profileId);
|
CProfile profile = CProfiles.GetProfile(profileId);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
|
||||||
throw new ArgumentException("Invalid profileId");
|
throw new ArgumentException("Invalid profileId");
|
||||||
}
|
|
||||||
|
|
||||||
if (profile.PasswordHash == null)
|
if (profile.PasswordHash == null)
|
||||||
{
|
{
|
||||||
if (hashedPassword == null)
|
if (hashedPassword == null)
|
||||||
{
|
|
||||||
return true; //Allow emty passwords
|
return true; //Allow emty passwords
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -670,14 +591,10 @@ namespace Vocaluxe.Base.Server
|
|||||||
{
|
{
|
||||||
CProfile profile = CProfiles.GetProfile(profileId);
|
CProfile profile = CProfiles.GetProfile(profileId);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
|
||||||
throw new ArgumentException("Invalid profileId");
|
throw new ArgumentException("Invalid profileId");
|
||||||
}
|
|
||||||
|
|
||||||
if (profile.PasswordHash == null)
|
if (profile.PasswordHash == null)
|
||||||
{
|
|
||||||
throw new ArgumentException("Emty password");
|
throw new ArgumentException("Emty password");
|
||||||
}
|
|
||||||
|
|
||||||
return profile.PasswordSalt;
|
return profile.PasswordSalt;
|
||||||
}
|
}
|
||||||
@@ -686,9 +603,7 @@ namespace Vocaluxe.Base.Server
|
|||||||
{
|
{
|
||||||
CProfile profile = CProfiles.GetProfile(profileId);
|
CProfile profile = CProfiles.GetProfile(profileId);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
|
||||||
throw new ArgumentException("Invalid profileId");
|
throw new ArgumentException("Invalid profileId");
|
||||||
}
|
|
||||||
|
|
||||||
//Hide TR_USERROLE_GUEST and TR_USERROLE_NORMAL
|
//Hide TR_USERROLE_GUEST and TR_USERROLE_NORMAL
|
||||||
//const EUserRole mask = (EUserRole.TR_USERROLE_GUEST | EUserRole.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);
|
CProfile profile = CProfiles.GetProfile(profileId);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
|
||||||
throw new ArgumentException("Invalid profileId");
|
throw new ArgumentException("Invalid profileId");
|
||||||
}
|
|
||||||
|
|
||||||
var option = (EUserRole)userRole;
|
var option = (EUserRole)userRole;
|
||||||
|
|
||||||
@@ -719,13 +632,11 @@ namespace Vocaluxe.Base.Server
|
|||||||
|
|
||||||
private static int _GetUserIdFromUsername(string username)
|
private static int _GetUserIdFromUsername(string username)
|
||||||
{
|
{
|
||||||
var playerIds = (from p in CProfiles.GetProfiles()
|
IEnumerable<int> playerIds = (from p in CProfiles.GetProfiles()
|
||||||
where String.Equals(p.PlayerName, username, StringComparison.OrdinalIgnoreCase)
|
where String.Equals(p.PlayerName, username, StringComparison.OrdinalIgnoreCase)
|
||||||
select p.ID);
|
select p.ID);
|
||||||
if (!playerIds.Any())
|
if (!playerIds.Any())
|
||||||
{
|
|
||||||
throw new ArgumentException("Invalid playername");
|
throw new ArgumentException("Invalid playername");
|
||||||
}
|
|
||||||
|
|
||||||
return playerIds.First();
|
return playerIds.First();
|
||||||
}
|
}
|
||||||
@@ -741,7 +652,6 @@ namespace Vocaluxe.Base.Server
|
|||||||
|
|
||||||
return hashAlgo.ComputeHash(data);
|
return hashAlgo.ComputeHash(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static string _SaveImage(CBase64Image imageDate, string name, string folder)
|
private static string _SaveImage(CBase64Image imageDate, string name, string folder)
|
||||||
@@ -750,24 +660,18 @@ namespace Vocaluxe.Base.Server
|
|||||||
string extension = imageDate.GetImageType();
|
string extension = imageDate.GetImageType();
|
||||||
|
|
||||||
if (!Directory.Exists(folder))
|
if (!Directory.Exists(folder))
|
||||||
{
|
|
||||||
Directory.CreateDirectory(folder);
|
Directory.CreateDirectory(folder);
|
||||||
}
|
|
||||||
|
|
||||||
string filename = Path.Combine(folder, name);
|
string filename = Path.Combine(folder, name);
|
||||||
if (File.Exists(filename + "." + extension))
|
if (File.Exists(filename + "." + extension))
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (File.Exists(filename + "_" + i + "." + extension))
|
while (File.Exists(filename + "_" + i + "." + extension))
|
||||||
{
|
|
||||||
i++;
|
i++;
|
||||||
}
|
|
||||||
filename = filename + "_" + i + "." + extension;
|
filename = filename + "_" + i + "." + extension;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
filename = filename + "." + extension;
|
filename = filename + "." + extension;
|
||||||
}
|
|
||||||
|
|
||||||
avatarImage.Save(filename);
|
avatarImage.Save(filename);
|
||||||
return filename;
|
return filename;
|
||||||
|
|||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -11,7 +28,7 @@ using Vocaluxe.Base;
|
|||||||
namespace Vocaluxe
|
namespace Vocaluxe
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Some helper functions for the programm
|
/// Some helper functions for the programm
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static class CProgrammHelper
|
static class CProgrammHelper
|
||||||
{
|
{
|
||||||
@@ -37,7 +54,7 @@ namespace Vocaluxe
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">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.</param>
|
/// <param name="name">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.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|||||||
@@ -65,10 +65,10 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
private int _Y;
|
private int _Y;
|
||||||
private int _X;
|
private int _X;
|
||||||
|
|
||||||
private int _BorderLeft = 0;
|
private int _BorderLeft;
|
||||||
private int _BorderRight = 0;
|
private int _BorderRight;
|
||||||
private int _BorderTop = 0;
|
private int _BorderTop;
|
||||||
private int _BorderBottom = 0;
|
private int _BorderBottom;
|
||||||
|
|
||||||
private CTexture _BlankTexture;
|
private CTexture _BlankTexture;
|
||||||
|
|
||||||
@@ -416,7 +416,7 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
if (_Device.SetStreamSource(0, _VertexBuffer, 0, Marshal.SizeOf(typeof(STexturedColoredVertex))).IsFailure)
|
if (_Device.SetStreamSource(0, _VertexBuffer, 0, Marshal.SizeOf(typeof(STexturedColoredVertex))).IsFailure)
|
||||||
CLog.LogError("Failed to set stream source");
|
CLog.LogError("Failed to set stream source");
|
||||||
_Device.VertexDeclaration = STexturedColoredVertex.GetDeclaration(_Device);
|
_Device.VertexDeclaration = STexturedColoredVertex.GetDeclaration(_Device);
|
||||||
|
|
||||||
if (_Device.SetRenderState(RenderState.CullMode, Cull.None).IsFailure)
|
if (_Device.SetRenderState(RenderState.CullMode, Cull.None).IsFailure)
|
||||||
CLog.LogError("Failed to set cull mode");
|
CLog.LogError("Failed to set cull mode");
|
||||||
if (_Device.SetRenderState(RenderState.AlphaBlendEnable, true).IsFailure)
|
if (_Device.SetRenderState(RenderState.AlphaBlendEnable, true).IsFailure)
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
#region license
|
#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
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Vocaluxe is distributed in the hope that it will be useful,
|
// Vocaluxe is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
CGstreamerAudioWrapper.Update();
|
CGstreamerAudioWrapper.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void FadeAndStop(int stream, float targetVolume, float seconds)
|
public void FadeAndStop(int stream, float targetVolume, float seconds)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Gst;
|
using Gst;
|
||||||
using GLib;
|
using GLib;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Vocaluxe.Base;
|
using Vocaluxe.Base;
|
||||||
using Thread = System.Threading.Thread;
|
using Thread = System.Threading.Thread;
|
||||||
|
|
||||||
namespace Vocaluxe.Lib.Sound
|
namespace Vocaluxe.Lib.Sound
|
||||||
{
|
{
|
||||||
@@ -29,16 +46,14 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
Application.Init();
|
Application.Init();
|
||||||
Registry reg = Registry.Get();
|
Registry reg = Registry.Get();
|
||||||
reg.ScanPath(path);
|
reg.ScanPath(path);
|
||||||
|
|
||||||
return Application.IsInitialized;
|
return Application.IsInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetGlobalVolume(float volume)
|
public void SetGlobalVolume(float volume)
|
||||||
{
|
{
|
||||||
foreach (CGstreamerSharpAudioStream stream in _Streams.Values)
|
foreach (CGstreamerSharpAudioStream stream in _Streams.Values)
|
||||||
{
|
|
||||||
stream.Volume = volume;
|
stream.Volume = volume;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetStreamCount()
|
public int GetStreamCount()
|
||||||
@@ -49,9 +64,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
public void CloseAll()
|
public void CloseAll()
|
||||||
{
|
{
|
||||||
foreach (CGstreamerSharpAudioStream stream in _Streams.Values)
|
foreach (CGstreamerSharpAudioStream stream in _Streams.Values)
|
||||||
{
|
|
||||||
stream.Close();
|
stream.Close();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Load(string media)
|
public int Load(string media)
|
||||||
@@ -61,7 +74,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
|
|
||||||
public int Load(string media, bool prescan)
|
public int Load(string media, bool prescan)
|
||||||
{
|
{
|
||||||
var stream = new CGstreamerSharpAudioStream (media, prescan);
|
var stream = new CGstreamerSharpAudioStream(media, prescan);
|
||||||
_Streams[_IDCount] = stream;
|
_Streams[_IDCount] = stream;
|
||||||
return _IDCount++;
|
return _IDCount++;
|
||||||
}
|
}
|
||||||
@@ -188,16 +201,14 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
var streamsToDelete = new List<int>();
|
var streamsToDelete = new List<int>();
|
||||||
foreach (KeyValuePair<int,CGstreamerSharpAudioStream> stream in _Streams)
|
foreach (KeyValuePair<int, CGstreamerSharpAudioStream> stream in _Streams)
|
||||||
{
|
{
|
||||||
if (stream.Value.Closed)
|
if (stream.Value.Closed)
|
||||||
streamsToDelete.Add(stream.Key);
|
streamsToDelete.Add(stream.Key);
|
||||||
stream.Value.Update();
|
stream.Value.Update();
|
||||||
}
|
}
|
||||||
foreach (int key in streamsToDelete)
|
foreach (int key in streamsToDelete)
|
||||||
{
|
|
||||||
_Streams.Remove(key);
|
_Streams.Remove(key);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CGstreamerSharpAudioStream
|
private class CGstreamerSharpAudioStream
|
||||||
@@ -221,10 +232,11 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
private volatile float _Duration = -1f;
|
private volatile float _Duration = -1f;
|
||||||
private volatile float _Position;
|
private volatile float _Position;
|
||||||
private volatile bool _QueryingDuration;
|
private volatile bool _QueryingDuration;
|
||||||
|
|
||||||
public CGstreamerSharpAudioStream(string media, bool prescan)
|
public CGstreamerSharpAudioStream(string media, bool prescan)
|
||||||
{
|
{
|
||||||
var convert = ElementFactory.Make("audioconvert", "convert");
|
Element convert = ElementFactory.Make("audioconvert", "convert");
|
||||||
var audiosink = ElementFactory.Make("directsoundsink", "audiosink");
|
Element audiosink = ElementFactory.Make("directsoundsink", "audiosink");
|
||||||
var audioSinkBin = new Bin("Audiosink");
|
var audioSinkBin = new Bin("Audiosink");
|
||||||
|
|
||||||
if (convert == null || audiosink == null)
|
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 it takes more than 500ms, duration queries will be performed asynchronously
|
||||||
if (prescan)
|
if (prescan)
|
||||||
{
|
{
|
||||||
var msg = _Element.Bus.TimedPopFiltered(0xffffffffffffffff, MessageType.AsyncDone);
|
Message msg = _Element.Bus.TimedPopFiltered(0xffffffffffffffff, MessageType.AsyncDone);
|
||||||
if(msg.Handle != IntPtr.Zero)
|
if (msg.Handle != IntPtr.Zero)
|
||||||
_UpdateDuration();
|
_UpdateDuration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -274,7 +286,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
Position = 0;
|
Position = 0;
|
||||||
else
|
else
|
||||||
Finished = true;
|
Finished = true;
|
||||||
Close();
|
Close();
|
||||||
break;
|
break;
|
||||||
case MessageType.Error:
|
case MessageType.Error:
|
||||||
GException error;
|
GException error;
|
||||||
@@ -289,18 +301,15 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
msg.Unref();
|
msg.Unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
if (!Closed)
|
if (!Closed)
|
||||||
{
|
{
|
||||||
|
|
||||||
Closed = true;
|
Closed = true;
|
||||||
Finished = true;
|
Finished = true;
|
||||||
var t = new Thread(_TerminateStream);
|
var t = new Thread(_TerminateStream);
|
||||||
t.Start();
|
t.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _TerminateStream()
|
private void _TerminateStream()
|
||||||
@@ -354,10 +363,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
|
|
||||||
public float Volume
|
public float Volume
|
||||||
{
|
{
|
||||||
get
|
get { return _Element != null ? (float)(double)_Element["volume"] : 0; }
|
||||||
{
|
|
||||||
return _Element != null ? (float)(double)_Element["volume"] : 0;
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_Volume = value;
|
_Volume = value;
|
||||||
@@ -368,10 +374,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
|
|
||||||
public float MaxVolume
|
public float MaxVolume
|
||||||
{
|
{
|
||||||
get
|
get { return _MaxVolume; }
|
||||||
{
|
|
||||||
return _MaxVolume;
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_MaxVolume = value;
|
_MaxVolume = value;
|
||||||
@@ -412,10 +415,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
|
|
||||||
public bool Paused
|
public bool Paused
|
||||||
{
|
{
|
||||||
get
|
get { return _Element == null || _Element.TargetState == State.Paused; }
|
||||||
{
|
|
||||||
return _Element == null || _Element.TargetState == State.Paused;
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value && _Element != null)
|
if (value && _Element != null)
|
||||||
@@ -425,13 +425,10 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
|
|
||||||
public bool Playing
|
public bool Playing
|
||||||
{
|
{
|
||||||
get
|
get { return _Element != null && (_Element.TargetState == State.Playing && !Finished); }
|
||||||
{
|
|
||||||
return _Element != null && (_Element.TargetState == State.Playing && !Finished);
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if(value && _Element != null)
|
if (value && _Element != null)
|
||||||
_Element.SetState(State.Playing);
|
_Element.SetState(State.Playing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -439,9 +436,7 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
while (_Element != null && _Element.Bus != null && _Element.Bus.HavePending())
|
while (_Element != null && _Element.Bus != null && _Element.Bus.HavePending())
|
||||||
{
|
|
||||||
_OnMessage(_Element.Bus.Pop());
|
_OnMessage(_Element.Bus.Pop());
|
||||||
}
|
|
||||||
|
|
||||||
if (_Fading)
|
if (_Fading)
|
||||||
{
|
{
|
||||||
@@ -481,4 +476,4 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -346,7 +346,6 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
_Context = null;
|
_Context = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void FadeAndStop(int stream, float targetVolume, float seconds)
|
public void FadeAndStop(int stream, float targetVolume, float seconds)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
@@ -446,4 +446,4 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
}
|
}
|
||||||
#endregion Threading
|
#endregion Threading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,57 +22,61 @@ namespace Vocaluxe.Lib.Video
|
|||||||
interface IVideoDecoder
|
interface IVideoDecoder
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes videodecoder. Got to be called before usage
|
/// Initializes videodecoder. Got to be called before usage
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>True on success, false if something went wrong.</returns>
|
/// <returns>True on success, false if something went wrong.</returns>
|
||||||
bool Init();
|
bool Init();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Close all video streams
|
/// Close all video streams
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void CloseAll();
|
void CloseAll();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads the file with the given file path.
|
/// Loads the file with the given file path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="videoFileName">Absolute file path of the video file</param>
|
/// <param name="videoFileName">Absolute file path of the video file</param>
|
||||||
/// <returns>StreamID >=0 on success or -1 on failure</returns>
|
/// <returns>StreamID >=0 on success or -1 on failure</returns>
|
||||||
int Load(string videoFileName);
|
int Load(string videoFileName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Closes the stream with the given ID
|
/// Closes the stream with the given ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="streamID">ID of the stream</param>
|
/// <param name="streamID">ID of the stream</param>
|
||||||
/// <returns>true if stream was closed, false if stream doesn't exist or already closed</returns>
|
/// <returns>true if stream was closed, false if stream doesn't exist or already closed</returns>
|
||||||
bool Close(int streamID);
|
bool Close(int streamID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the number of streams currently active
|
/// Gets the number of streams currently active
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
int GetNumStreams();
|
int GetNumStreams();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the length of the video in s
|
/// Gets the length of the video in s
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="streamID">Id of the stream</param>
|
/// <param name="streamID">Id of the stream</param>
|
||||||
/// <returns>Length of the video in s</returns>
|
/// <returns>Length of the video in s</returns>
|
||||||
float GetLength(int streamID);
|
float GetLength(int streamID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a frame of the video and sets the current video time
|
/// Gets a frame of the video and sets the current video time
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="streamID">Id of the stream</param>
|
/// <param name="streamID">Id of the stream</param>
|
||||||
/// <param name="frame">Reference to already initialized video texture (from previous calls). If null, one will be created.<br/>
|
/// <param name="frame">
|
||||||
/// Returns the current video frame which might be outdated if time != current (internal) video position or unchanged (even null) if none is available.</param>
|
/// Reference to already initialized video texture (from previous calls). If null, one will be created.<br />
|
||||||
/// <param name="time">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.<br/>
|
/// Returns the current video frame which might be outdated if time != current (internal) video position or unchanged (even null) if none is available.
|
||||||
/// <b>Note:</b>Will be ignored for looped playback!</param>
|
/// </param>
|
||||||
|
/// <param name="time">
|
||||||
|
/// 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.<br />
|
||||||
|
/// <b>Note:</b>Will be ignored for looped playback!
|
||||||
|
/// </param>
|
||||||
/// <param name="videoTime">The actual position in s of the returned frame. Should be ~ time+VideoGap</param>
|
/// <param name="videoTime">The actual position in s of the returned frame. Should be ~ time+VideoGap</param>
|
||||||
/// <returns>True if frame is valid, false: frame and videoTime might be unchanged or invalid</returns>
|
/// <returns>True if frame is valid, false: frame and videoTime might be unchanged or invalid</returns>
|
||||||
bool GetFrame(int streamID, ref CTexture frame, float time, out float videoTime);
|
bool GetFrame(int streamID, ref CTexture frame, float time, out float videoTime);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Seeks to given position
|
/// Seeks to given position
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="streamID">Id of the stream</param>
|
/// <param name="streamID">Id of the stream</param>
|
||||||
/// <param name="start">Position to seek to</param>
|
/// <param name="start">Position to seek to</param>
|
||||||
@@ -81,33 +85,33 @@ namespace Vocaluxe.Lib.Video
|
|||||||
bool Skip(int streamID, float start, float gap);
|
bool Skip(int streamID, float start, float gap);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set if the video should be looped
|
/// Set if the video should be looped
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="streamID">Id of the stream</param>
|
/// <param name="streamID">Id of the stream</param>
|
||||||
/// <param name="loop">True if it should be looped</param>
|
/// <param name="loop">True if it should be looped</param>
|
||||||
void SetLoop(int streamID, bool loop);
|
void SetLoop(int streamID, bool loop);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Pauses the video (no new frames will be decoded)
|
/// Pauses the video (no new frames will be decoded)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="streamID">Id of the stream</param>
|
/// <param name="streamID">Id of the stream</param>
|
||||||
void Pause(int streamID);
|
void Pause(int streamID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resumes a paused video
|
/// Resumes a paused video
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="streamID">Id of the stream</param>
|
/// <param name="streamID">Id of the stream</param>
|
||||||
void Resume(int streamID);
|
void Resume(int streamID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the given video is finished
|
/// Check if the given video is finished
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="streamID">Id of the stream</param>
|
/// <param name="streamID">Id of the stream</param>
|
||||||
/// <returns>True if all frames are shown</returns>
|
/// <returns>True if all frames are shown</returns>
|
||||||
bool Finished(int streamID);
|
bool Finished(int streamID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Update();
|
void Update();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -326,9 +326,9 @@ namespace Vocaluxe
|
|||||||
Process currentProcess = Process.GetCurrentProcess();
|
Process currentProcess = Process.GetCurrentProcess();
|
||||||
Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName);
|
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)
|
if (wnd != IntPtr.Zero)
|
||||||
SetForegroundWindow(wnd);
|
SetForegroundWindow(wnd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|
||||||
_ThemeStatics = new string[] { _StaticQRServer, _StaticQRAndroid, _StaticQRSymbian, _StaticQRWebOS, _StaticQRWindowsPhone };
|
_ThemeStatics = new string[] {_StaticQRServer, _StaticQRAndroid, _StaticQRSymbian, _StaticQRWebOS, _StaticQRWindowsPhone};
|
||||||
_ThemeTexts = new string[] { _TextServerAddress, _TextServerNotRunning };
|
_ThemeTexts = new string[] {_TextServerAddress, _TextServerNotRunning};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void LoadTheme(string xmlPath)
|
public override void LoadTheme(string xmlPath)
|
||||||
@@ -127,4 +127,4 @@ namespace Vocaluxe.Screens
|
|||||||
_QRWindowsPhoneLink = CDraw.AddTexture(qrcode.GetGraphic(20));
|
_QRWindowsPhoneLink = CDraw.AddTexture(qrcode.GetGraphic(20));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ namespace Vocaluxe.Screens
|
|||||||
_SaveConfig();
|
_SaveConfig();
|
||||||
if (_Buttons[_ButtonExit].Selected)
|
if (_Buttons[_ButtonExit].Selected)
|
||||||
CGraphics.FadeTo(EScreens.ScreenOptions);
|
CGraphics.FadeTo(EScreens.ScreenOptions);
|
||||||
if(_Buttons[_ButtonScreenAdjustments].Selected)
|
if (_Buttons[_ButtonScreenAdjustments].Selected)
|
||||||
CGraphics.FadeTo(EScreens.ScreenOptionsVideoAdjustments);
|
CGraphics.FadeTo(EScreens.ScreenOptionsVideoAdjustments);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -38,14 +38,14 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|
||||||
_ThemeButtons = new string[] { _ButtonExit };
|
_ThemeButtons = new string[] {_ButtonExit};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandleInput(SKeyEvent keyEvent)
|
public override bool HandleInput(SKeyEvent keyEvent)
|
||||||
{
|
{
|
||||||
base.HandleInput(keyEvent);
|
base.HandleInput(keyEvent);
|
||||||
|
|
||||||
if (keyEvent.KeyPressed) { }
|
if (keyEvent.KeyPressed) {}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (keyEvent.Key)
|
switch (keyEvent.Key)
|
||||||
@@ -102,4 +102,4 @@ namespace Vocaluxe.Screens
|
|||||||
CConfig.SaveConfig();
|
CConfig.SaveConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ namespace Vocaluxe.Screens
|
|||||||
else if (_SelectSlides[_SelectSlideUserRole].Selected)
|
else if (_SelectSlides[_SelectSlideUserRole].Selected)
|
||||||
{
|
{
|
||||||
CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex,
|
CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex,
|
||||||
(EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
|
(EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
|
||||||
}
|
}
|
||||||
else if (_SelectSlides[_SelectSlideActive].Selected)
|
else if (_SelectSlides[_SelectSlideActive].Selected)
|
||||||
{
|
{
|
||||||
@@ -228,7 +228,7 @@ namespace Vocaluxe.Screens
|
|||||||
else if (_SelectSlides[_SelectSlideUserRole].Selected)
|
else if (_SelectSlides[_SelectSlideUserRole].Selected)
|
||||||
{
|
{
|
||||||
CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex,
|
CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].ValueIndex,
|
||||||
(EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
|
(EUserRole)_SelectSlides[_SelectSlideUserRole].Selection);
|
||||||
}
|
}
|
||||||
else if (_SelectSlides[_SelectSlideActive].Selected)
|
else if (_SelectSlides[_SelectSlideActive].Selected)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -565,7 +565,7 @@ namespace Vocaluxe.Screens
|
|||||||
}
|
}
|
||||||
CDraw.RemoveTexture(ref _Background);
|
CDraw.RemoveTexture(ref _Background);
|
||||||
|
|
||||||
if(_SlideShow != null)
|
if (_SlideShow != null)
|
||||||
_SlideShow.RemoveSlideShowTextures();
|
_SlideShow.RemoveSlideShowTextures();
|
||||||
|
|
||||||
_Lyrics[_LyricMain].Clear();
|
_Lyrics[_LyricMain].Clear();
|
||||||
@@ -637,7 +637,7 @@ namespace Vocaluxe.Screens
|
|||||||
if (song.BackgroundFileNames.Count > 1)
|
if (song.BackgroundFileNames.Count > 1)
|
||||||
{
|
{
|
||||||
_SlideShow = GetNewBackground();
|
_SlideShow = GetNewBackground();
|
||||||
foreach(string bgFile in song.BackgroundFileNames)
|
foreach (string bgFile in song.BackgroundFileNames)
|
||||||
_SlideShow.AddSlideShowTexture(Path.Combine(song.Folder, bgFile));
|
_SlideShow.AddSlideShowTexture(Path.Combine(song.Folder, bgFile));
|
||||||
_Background = null;
|
_Background = null;
|
||||||
}
|
}
|
||||||
@@ -887,7 +887,7 @@ namespace Vocaluxe.Screens
|
|||||||
_Buttons[_ButtonContinue].Visible = false;
|
_Buttons[_ButtonContinue].Visible = false;
|
||||||
_Buttons[_ButtonSkip].Visible = false;
|
_Buttons[_ButtonSkip].Visible = false;
|
||||||
CSound.Play(_CurrentStream);
|
CSound.Play(_CurrentStream);
|
||||||
if(_Webcam)
|
if (_Webcam)
|
||||||
CWebcam.Start();
|
CWebcam.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1309,7 +1309,7 @@ namespace Vocaluxe.Screens
|
|||||||
float currentTime = _CurrentTime - song.Start;
|
float currentTime = _CurrentTime - song.Start;
|
||||||
|
|
||||||
if (_Length < 0 && totalTime > 0)
|
if (_Length < 0 && totalTime > 0)
|
||||||
_PrepareTimeLine();
|
_PrepareTimeLine();
|
||||||
|
|
||||||
if (totalTime <= 0f)
|
if (totalTime <= 0f)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ namespace VocaluxeLib
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryParse<T>(string value, out T result, bool ignoreCase=false)
|
public static bool TryParse<T>(string value, out T result, bool ignoreCase = false)
|
||||||
where T : struct
|
where T : struct
|
||||||
{
|
{
|
||||||
result = default(T);
|
result = default(T);
|
||||||
|
|||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -9,7 +26,7 @@ namespace VocaluxeLib
|
|||||||
public static class Extensions
|
public static class Extensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="list"></param>
|
/// <param name="list"></param>
|
||||||
@@ -25,7 +42,7 @@ namespace VocaluxeLib
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="list"></param>
|
/// <param name="list"></param>
|
||||||
@@ -39,7 +56,7 @@ namespace VocaluxeLib
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="list"></param>
|
/// <param name="list"></param>
|
||||||
@@ -51,7 +68,7 @@ namespace VocaluxeLib
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all set bits starting from lowest (Bit 0)
|
/// Gets all set bits starting from lowest (Bit 0)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -100,7 +117,7 @@ namespace VocaluxeLib
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">Value to be converted</param>
|
/// <param name="value">Value to be converted</param>
|
||||||
/// <returns>String representation of value</returns>
|
/// <returns>String representation of value</returns>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace VocaluxeLib
|
|||||||
int GetMaxNumMics();
|
int GetMaxNumMics();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the uniform settings for writing XML files. ALWAYS use this!
|
/// Get the uniform settings for writing XML files. ALWAYS use this!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
XmlWriterSettings GetXMLSettings();
|
XmlWriterSettings GetXMLSettings();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,9 +138,7 @@ namespace VocaluxeLib.Menu
|
|||||||
|
|
||||||
writer.WriteComment("<SlideShow%>: Texture name for slide-show");
|
writer.WriteComment("<SlideShow%>: Texture name for slide-show");
|
||||||
for (int i = 0; i < _Theme.SlideShowTextures.Count; i++)
|
for (int i = 0; i < _Theme.SlideShowTextures.Count; i++)
|
||||||
{
|
|
||||||
writer.WriteElementString("SlideShow" + (i + 1), _Theme.SlideShowTextures[i]);
|
writer.WriteElementString("SlideShow" + (i + 1), _Theme.SlideShowTextures[i]);
|
||||||
}
|
|
||||||
|
|
||||||
writer.WriteComment("<Color>: Background color for type \"Color\" from ColorScheme (high priority)");
|
writer.WriteComment("<Color>: Background color for type \"Color\" from ColorScheme (high priority)");
|
||||||
writer.WriteComment("or <R>, <G>, <B>, <A> (lower priority)");
|
writer.WriteComment("or <R>, <G>, <B>, <A> (lower priority)");
|
||||||
@@ -193,9 +191,7 @@ namespace VocaluxeLib.Menu
|
|||||||
|
|
||||||
|
|
||||||
if (_Theme.Type == EBackgroundTypes.SlideShow && _Theme.SlideShowTextures.Count > 0)
|
if (_Theme.Type == EBackgroundTypes.SlideShow && _Theme.SlideShowTextures.Count > 0)
|
||||||
{
|
|
||||||
ok = _DrawSlideShow();
|
ok = _DrawSlideShow();
|
||||||
}
|
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(_Theme.TextureName) &&
|
if (!String.IsNullOrEmpty(_Theme.TextureName) &&
|
||||||
(_Theme.Type == EBackgroundTypes.Texture ||
|
(_Theme.Type == EBackgroundTypes.Texture ||
|
||||||
@@ -209,7 +205,10 @@ namespace VocaluxeLib.Menu
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnloadTextures() { _SlideShowTextures.Clear(); }
|
public void UnloadTextures()
|
||||||
|
{
|
||||||
|
_SlideShowTextures.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public void LoadTextures()
|
public void LoadTextures()
|
||||||
{
|
{
|
||||||
@@ -226,7 +225,7 @@ namespace VocaluxeLib.Menu
|
|||||||
if (!String.IsNullOrEmpty(image))
|
if (!String.IsNullOrEmpty(image))
|
||||||
{
|
{
|
||||||
CTexture texture = CBase.Drawing.AddTexture(image);
|
CTexture texture = CBase.Drawing.AddTexture(image);
|
||||||
if(texture != null)
|
if (texture != null)
|
||||||
_SlideShowTextures.Add(texture);
|
_SlideShowTextures.Add(texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,7 +272,7 @@ namespace VocaluxeLib.Menu
|
|||||||
|
|
||||||
private bool _DrawSlideShow()
|
private bool _DrawSlideShow()
|
||||||
{
|
{
|
||||||
if (_SlideShowTextures.Count > 0)
|
if (_SlideShowTextures.Count > 0)
|
||||||
{
|
{
|
||||||
if (!_SlideShowTimer.IsRunning)
|
if (!_SlideShowTimer.IsRunning)
|
||||||
{
|
{
|
||||||
@@ -314,10 +313,10 @@ namespace VocaluxeLib.Menu
|
|||||||
{
|
{
|
||||||
float alpha = (_SlideShowTimer.ElapsedMilliseconds - CBase.Settings.GetSlideShowImageTime()) / CBase.Settings.GetSlideShowFadeTime();
|
float alpha = (_SlideShowTimer.ElapsedMilliseconds - CBase.Settings.GetSlideShowImageTime()) / CBase.Settings.GetSlideShowFadeTime();
|
||||||
CHelper.SetRect(bounds, out rect, texture.OrigAspect, EAspect.Crop);
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace VocaluxeLib.Menu
|
|||||||
private bool _ThemeLoaded;
|
private bool _ThemeLoaded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds a reference to Songline. DO NOT MODIFY
|
/// Holds a reference to Songline. DO NOT MODIFY
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private CSongLine _Line;
|
private CSongLine _Line;
|
||||||
private CText _Text;
|
private CText _Text;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace VocaluxeLib.Menu
|
|||||||
public int[] NumPlayerTeams;
|
public int[] NumPlayerTeams;
|
||||||
public List<int>[] TeamList;
|
public List<int>[] TeamList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class CMenuPartyNameSelection : CMenuParty
|
public abstract class CMenuPartyNameSelection : CMenuParty
|
||||||
{
|
{
|
||||||
private bool _Teams;
|
private bool _Teams;
|
||||||
@@ -40,7 +41,7 @@ namespace VocaluxeLib.Menu
|
|||||||
protected bool _AllowChangeTeamNum = true;
|
protected bool _AllowChangeTeamNum = true;
|
||||||
protected bool _ChangePlayerNumDynamic = true;
|
protected bool _ChangePlayerNumDynamic = true;
|
||||||
protected bool _ChangeTeamNumDynamic = true;
|
protected bool _ChangeTeamNumDynamic = true;
|
||||||
private int _CurrentTeam = 0;
|
private int _CurrentTeam;
|
||||||
|
|
||||||
private bool _AvatarsChanged;
|
private bool _AvatarsChanged;
|
||||||
private bool _ProfilesChanged;
|
private bool _ProfilesChanged;
|
||||||
@@ -70,9 +71,9 @@ namespace VocaluxeLib.Menu
|
|||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
_ThemeButtons = new string[] { _ButtonBack, _ButtonNext, _ButtonRandom, _ButtonIncreaseTeams, _ButtonDecreaseTeams, _ButtonIncreasePlayer, _ButtonDecreasePlayer };
|
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonRandom, _ButtonIncreaseTeams, _ButtonDecreaseTeams, _ButtonIncreasePlayer, _ButtonDecreasePlayer};
|
||||||
_ThemeSelectSlides = new string[] { _SelectSlideTeams, _SelectSlidePlayer };
|
_ThemeSelectSlides = new string[] {_SelectSlideTeams, _SelectSlidePlayer};
|
||||||
_ThemeNameSelections = new string[] { _NameSelection };
|
_ThemeNameSelections = new string[] {_NameSelection};
|
||||||
|
|
||||||
_ChooseAvatarStatic = GetNewStatic();
|
_ChooseAvatarStatic = GetNewStatic();
|
||||||
_ChooseAvatarStatic.Visible = false;
|
_ChooseAvatarStatic.Visible = false;
|
||||||
@@ -83,11 +84,11 @@ namespace VocaluxeLib.Menu
|
|||||||
|
|
||||||
public void SetPartyModeData(int numPlayer)
|
public void SetPartyModeData(int numPlayer)
|
||||||
{
|
{
|
||||||
SetPartyModeData(1, numPlayer, new int[] { numPlayer });
|
SetPartyModeData(1, numPlayer, new int[] {numPlayer});
|
||||||
_CurrentTeam = 0;
|
_CurrentTeam = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPartyModeData(int numTeams, int numPlayer, int[] numPlayerTeams)
|
public void SetPartyModeData(int numTeams, int numPlayer, int[] numPlayerTeams)
|
||||||
{
|
{
|
||||||
_NumTeams = numTeams;
|
_NumTeams = numTeams;
|
||||||
_NumPlayer = numPlayer;
|
_NumPlayer = numPlayer;
|
||||||
@@ -141,13 +142,14 @@ namespace VocaluxeLib.Menu
|
|||||||
_AddPlayer(_CurrentTeam, _SelectedProfileID);
|
_AddPlayer(_CurrentTeam, _SelectedProfileID);
|
||||||
}
|
}
|
||||||
//Started selecting with 'P'
|
//Started selecting with 'P'
|
||||||
if (_SelectingFast) {
|
if (_SelectingFast)
|
||||||
|
{
|
||||||
if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
|
if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
|
||||||
resetSelection = true;
|
resetSelection = true;
|
||||||
else if (_TeamList[_CurrentTeam].Count == _PartyMode.GetMaxPlayerPerTeam())
|
else if (_TeamList[_CurrentTeam].Count == _PartyMode.GetMaxPlayerPerTeam())
|
||||||
resetSelection = true;
|
resetSelection = true;
|
||||||
}
|
}
|
||||||
else if(!_SelectingFast)
|
else if (!_SelectingFast)
|
||||||
resetSelection = true;
|
resetSelection = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -292,14 +294,15 @@ namespace VocaluxeLib.Menu
|
|||||||
else if (_SelectSlides[_SelectSlidePlayer].Selected)
|
else if (_SelectSlides[_SelectSlidePlayer].Selected)
|
||||||
IncreasePlayerNum(_CurrentTeam);
|
IncreasePlayerNum(_CurrentTeam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numPressed > 0)
|
if (numPressed > 0)
|
||||||
{
|
{
|
||||||
if (_ChangeTeamNumDynamic && numPressed < _PartyMode.GetMaxTeams() && numPressed > _SelectSlides[_SelectSlideTeams].NumValues)
|
if (_ChangeTeamNumDynamic && numPressed < _PartyMode.GetMaxTeams() && numPressed > _SelectSlides[_SelectSlideTeams].NumValues)
|
||||||
|
{
|
||||||
while (numPressed < _PartyMode.GetMaxTeams())
|
while (numPressed < _PartyMode.GetMaxTeams())
|
||||||
IncreaseTeamNum();
|
IncreaseTeamNum();
|
||||||
|
}
|
||||||
if (numPressed <= _SelectSlides[_SelectSlideTeams].NumValues)
|
if (numPressed <= _SelectSlides[_SelectSlideTeams].NumValues)
|
||||||
_SelectSlides[_SelectSlideTeams].SetSelectionByValueIndex(numPressed - 1);
|
_SelectSlides[_SelectSlideTeams].SetSelectionByValueIndex(numPressed - 1);
|
||||||
}
|
}
|
||||||
@@ -353,7 +356,7 @@ namespace VocaluxeLib.Menu
|
|||||||
_OldMouseX = mouseEvent.X;
|
_OldMouseX = mouseEvent.X;
|
||||||
_OldMouseY = mouseEvent.Y;
|
_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)
|
else if (_SelectedProfileID >= 0 && !_SelectingFast)
|
||||||
{
|
{
|
||||||
//Check if mouse is in drop-area
|
//Check if mouse is in drop-area
|
||||||
@@ -439,7 +442,7 @@ namespace VocaluxeLib.Menu
|
|||||||
else if (mouseEvent.RB)
|
else if (mouseEvent.RB)
|
||||||
{
|
{
|
||||||
bool exit = true;
|
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 currentSelection = _SelectSlides[_SelectSlidePlayer].Selection;
|
||||||
int id = _TeamList[_CurrentTeam][currentSelection];
|
int id = _TeamList[_CurrentTeam][currentSelection];
|
||||||
@@ -447,7 +450,7 @@ namespace VocaluxeLib.Menu
|
|||||||
_UpdatePlayerSlide();
|
_UpdatePlayerSlide();
|
||||||
exit = false;
|
exit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exit)
|
if (exit)
|
||||||
Back();
|
Back();
|
||||||
}
|
}
|
||||||
@@ -568,9 +571,7 @@ namespace VocaluxeLib.Menu
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (_NumTeams - 1 >= _PartyMode.GetMinTeams())
|
if (_NumTeams - 1 >= _PartyMode.GetMinTeams())
|
||||||
{
|
|
||||||
_NumTeams--;
|
_NumTeams--;
|
||||||
}
|
|
||||||
_UpdateButtonState();
|
_UpdateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -601,9 +602,8 @@ namespace VocaluxeLib.Menu
|
|||||||
}
|
}
|
||||||
_UpdateButtonState();
|
_UpdateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region private methods
|
|
||||||
|
|
||||||
|
#region private methods
|
||||||
private void _OnProfileChanged(EProfileChangedFlags flags)
|
private void _OnProfileChanged(EProfileChangedFlags flags)
|
||||||
{
|
{
|
||||||
if (EProfileChangedFlags.Avatar == (EProfileChangedFlags.Avatar & flags))
|
if (EProfileChangedFlags.Avatar == (EProfileChangedFlags.Avatar & flags))
|
||||||
@@ -650,9 +650,7 @@ namespace VocaluxeLib.Menu
|
|||||||
_SelectSlides[_SelectSlidePlayer].AddValue(name, avatar);
|
_SelectSlides[_SelectSlidePlayer].AddValue(name, avatar);
|
||||||
}
|
}
|
||||||
for (int i = _TeamList[_CurrentTeam].Count; i < _NumPlayerTeams[_CurrentTeam]; i++)
|
for (int i = _TeamList[_CurrentTeam].Count; i < _NumPlayerTeams[_CurrentTeam]; i++)
|
||||||
{
|
|
||||||
_SelectSlides[_SelectSlidePlayer].AddValue("", _NameSelections[_NameSelection].TextureEmptyTile);
|
_SelectSlides[_SelectSlidePlayer].AddValue("", _NameSelections[_NameSelection].TextureEmptyTile);
|
||||||
}
|
|
||||||
if (selection >= _TeamList[_CurrentTeam].Count)
|
if (selection >= _TeamList[_CurrentTeam].Count)
|
||||||
selection = _TeamList[_CurrentTeam].Count - 1;
|
selection = _TeamList[_CurrentTeam].Count - 1;
|
||||||
_SelectSlides[_SelectSlidePlayer].SetSelectionByValueIndex(selection);
|
_SelectSlides[_SelectSlidePlayer].SetSelectionByValueIndex(selection);
|
||||||
@@ -664,13 +662,12 @@ namespace VocaluxeLib.Menu
|
|||||||
_SelectSlides[_SelectSlideTeams].Clear();
|
_SelectSlides[_SelectSlideTeams].Clear();
|
||||||
for (int i = 1; i <= _NumTeams; i++)
|
for (int i = 1; i <= _NumTeams; i++)
|
||||||
_SelectSlides[_SelectSlideTeams].AddValue("Team " + i);
|
_SelectSlides[_SelectSlideTeams].AddValue("Team " + i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _UpdateButtonVisibility()
|
private void _UpdateButtonVisibility()
|
||||||
{
|
{
|
||||||
_Buttons[_ButtonIncreaseTeams].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[_ButtonDecreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.GetMinTeams() != _PartyMode.GetMaxTeams();
|
||||||
_Buttons[_ButtonIncreasePlayer].Visible = _AllowChangePlayerNum;
|
_Buttons[_ButtonIncreasePlayer].Visible = _AllowChangePlayerNum;
|
||||||
_Buttons[_ButtonDecreasePlayer].Visible = _AllowChangePlayerNum;
|
_Buttons[_ButtonDecreasePlayer].Visible = _AllowChangePlayerNum;
|
||||||
}
|
}
|
||||||
@@ -711,9 +708,7 @@ namespace VocaluxeLib.Menu
|
|||||||
List<int> ids = new List<int>();
|
List<int> ids = new List<int>();
|
||||||
ids.AddRange(_TeamList[t]);
|
ids.AddRange(_TeamList[t]);
|
||||||
for (int p = 0; p < ids.Count; p++)
|
for (int p = 0; p < ids.Count; p++)
|
||||||
{
|
|
||||||
_RemovePlayer(t, ids[p]);
|
_RemovePlayer(t, ids[p]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,7 +740,6 @@ namespace VocaluxeLib.Menu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,7 +376,7 @@ namespace VocaluxeLib.Menu
|
|||||||
_Player = player;
|
_Player = player;
|
||||||
_PlayerSelector.Color = CBase.Theme.GetPlayerColor(player);
|
_PlayerSelector.Color = CBase.Theme.GetPlayerColor(player);
|
||||||
}
|
}
|
||||||
//Normal activation
|
//Normal activation
|
||||||
else if (active)
|
else if (active)
|
||||||
{
|
{
|
||||||
Selection = 0;
|
Selection = 0;
|
||||||
@@ -385,7 +385,7 @@ namespace VocaluxeLib.Menu
|
|||||||
_PlayerSelector.Color = CBase.Theme.GetPlayerColor(player);
|
_PlayerSelector.Color = CBase.Theme.GetPlayerColor(player);
|
||||||
_PlayerSelector.Visible = true;
|
_PlayerSelector.Visible = true;
|
||||||
}
|
}
|
||||||
//Deactivate
|
//Deactivate
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Selection = -1;
|
Selection = -1;
|
||||||
@@ -415,7 +415,8 @@ namespace VocaluxeLib.Menu
|
|||||||
{
|
{
|
||||||
_Tiles[i].Avatar.Texture = CBase.Profiles.GetAvatar(_VisibleProfiles[i + offset * _Tiles.Count]);
|
_Tiles[i].Avatar.Texture = CBase.Profiles.GetAvatar(_VisibleProfiles[i + offset * _Tiles.Count]);
|
||||||
_Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1);
|
_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];
|
_Tiles[i].ProfileID = _VisibleProfiles[i + offset * _Tiles.Count];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -462,7 +463,7 @@ namespace VocaluxeLib.Menu
|
|||||||
return new CStatic(_PartyModeID);
|
return new CStatic(_PartyModeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnloadTextures() { }
|
public void UnloadTextures() {}
|
||||||
|
|
||||||
public void LoadTextures()
|
public void LoadTextures()
|
||||||
{
|
{
|
||||||
@@ -486,12 +487,14 @@ namespace VocaluxeLib.Menu
|
|||||||
|
|
||||||
public void UseProfile(int id)
|
public void UseProfile(int id)
|
||||||
{
|
{
|
||||||
if(id > -1)
|
if (id > -1)
|
||||||
|
{
|
||||||
if (!_UsedProfiles.Contains(id) && CBase.Profiles.IsProfileIDValid(id) && !CBase.Profiles.IsGuest(id))
|
if (!_UsedProfiles.Contains(id) && CBase.Profiles.IsProfileIDValid(id) && !CBase.Profiles.IsGuest(id))
|
||||||
{
|
{
|
||||||
_UsedProfiles.Add(id);
|
_UsedProfiles.Add(id);
|
||||||
UpdateList();
|
UpdateList();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveUsedProfile(int id)
|
public void RemoveUsedProfile(int id)
|
||||||
@@ -513,7 +516,7 @@ namespace VocaluxeLib.Menu
|
|||||||
if (_VisibleProfiles.Count == _UsedProfiles.Count)
|
if (_VisibleProfiles.Count == _UsedProfiles.Count)
|
||||||
return id;
|
return id;
|
||||||
|
|
||||||
while(id == -1)
|
while (id == -1)
|
||||||
{
|
{
|
||||||
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
|
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
|
||||||
if (_UsedProfiles.Contains(_VisibleProfiles[rand]))
|
if (_UsedProfiles.Contains(_VisibleProfiles[rand]))
|
||||||
@@ -532,7 +535,7 @@ namespace VocaluxeLib.Menu
|
|||||||
for (int j = 0; j < _NumW; j++)
|
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 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,
|
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, "");
|
_Theme.NameFont, _Theme.NameColor, "");
|
||||||
_Tiles.Add(new CTile(tileStatic, tileText, -1));
|
_Tiles.Add(new CTile(tileStatic, tileText, -1));
|
||||||
|
|||||||
@@ -71,10 +71,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
base._PreviewIdInternal = value;
|
base._PreviewIdInternal = value;
|
||||||
_UpdatePreview();
|
_UpdatePreview();
|
||||||
}
|
}
|
||||||
get
|
get { return base._PreviewIdInternal; }
|
||||||
{
|
|
||||||
return base._PreviewIdInternal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetActualSelection()
|
public override int GetActualSelection()
|
||||||
@@ -375,7 +372,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!keyEvent.Handled)
|
if (!keyEvent.Handled)
|
||||||
{
|
{
|
||||||
_ActualSelection = _Locked;
|
_ActualSelection = _Locked;
|
||||||
if (_PreviewId != _Locked)
|
if (_PreviewId != _Locked)
|
||||||
_PreviewId = _Locked;
|
_PreviewId = _Locked;
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
#region license
|
#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
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Vocaluxe is distributed in the hope that it will be useful,
|
// Vocaluxe is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using VocaluxeLib.Draw;
|
using VocaluxeLib.Draw;
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ namespace VocaluxeLib.Profile
|
|||||||
string filename = string.Empty;
|
string filename = string.Empty;
|
||||||
// ReSharper disable LoopCanBeConvertedToQuery
|
// ReSharper disable LoopCanBeConvertedToQuery
|
||||||
foreach (char chr in PlayerName)
|
foreach (char chr in PlayerName)
|
||||||
// ReSharper restore LoopCanBeConvertedToQuery
|
// ReSharper restore LoopCanBeConvertedToQuery
|
||||||
{
|
{
|
||||||
if (char.IsLetter(chr))
|
if (char.IsLetter(chr))
|
||||||
filename += chr.ToString();
|
filename += chr.ToString();
|
||||||
@@ -166,13 +166,9 @@ namespace VocaluxeLib.Profile
|
|||||||
writer.WriteElementString("UserRole", Enum.GetName(typeof(EUserRole), UserRole));
|
writer.WriteElementString("UserRole", Enum.GetName(typeof(EUserRole), UserRole));
|
||||||
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), Active));
|
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), Active));
|
||||||
if (PasswordHash != null)
|
if (PasswordHash != null)
|
||||||
{
|
|
||||||
writer.WriteElementString("PasswordHash", Convert.ToBase64String(PasswordHash));
|
writer.WriteElementString("PasswordHash", Convert.ToBase64String(PasswordHash));
|
||||||
}
|
|
||||||
if (PasswordSalt != null)
|
if (PasswordSalt != null)
|
||||||
{
|
|
||||||
writer.WriteElementString("PasswordSalt", Convert.ToBase64String(PasswordSalt));
|
writer.WriteElementString("PasswordSalt", Convert.ToBase64String(PasswordSalt));
|
||||||
}
|
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
|
|
||||||
writer.WriteEndElement(); //end of root
|
writer.WriteEndElement(); //end of root
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace VocaluxeLib.Songs
|
|||||||
public int StartBeat { get; set; }
|
public int StartBeat { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int EndBeat
|
public int EndBeat
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace VocaluxeLib.Songs
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Find last note with StartBeat
|
/// Find last note with StartBeat
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beat"></param>
|
/// <param name="beat"></param>
|
||||||
/// <returns>Note index of last note with StartBeat or -1 if all notes start after beat</returns>
|
/// <returns>Note index of last note with StartBeat or -1 if all notes start after beat</returns>
|
||||||
|
|||||||
@@ -134,21 +134,21 @@ namespace VocaluxeLib.Songs
|
|||||||
public readonly List<String> UnknownTags = new List<string>();
|
public readonly List<String> UnknownTags = new List<string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start of the song in s (s in txt)
|
/// Start of the song in s (s in txt)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Start;
|
public float Start;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// End of the song in s (ms in txt)
|
/// End of the song in s (ms in txt)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Finish;
|
public float Finish;
|
||||||
|
|
||||||
public float BPM = 1f;
|
public float BPM = 1f;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gap of the mp3 in s (ms in txt)
|
/// Gap of the mp3 in s (ms in txt)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Gap;
|
public float Gap;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gap of the video in s (s in txt)
|
/// Gap of the video in s (s in txt)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float VideoGap;
|
public float VideoGap;
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ namespace VocaluxeLib.Songs
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if the requested game mode is available
|
/// Returns true if the requested game mode is available
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gameMode"></param>
|
/// <param name="gameMode"></param>
|
||||||
/// <returns>true if the requested game mode is available</returns>
|
/// <returns>true if the requested game mode is available</returns>
|
||||||
|
|||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -6,12 +23,12 @@ using System.Text;
|
|||||||
namespace VocaluxeLib.Songs
|
namespace VocaluxeLib.Songs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Part of CSong that is required for note loading
|
/// Part of CSong that is required for note loading
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class CSong
|
public partial class CSong
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Factor the bpm given in the txt is multiplied with
|
/// Factor the bpm given in the txt is multiplied with
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const int _BPMFactor = 4;
|
private const int _BPMFactor = 4;
|
||||||
|
|
||||||
@@ -54,7 +71,7 @@ namespace VocaluxeLib.Songs
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logs a given message with file name and line#
|
/// Logs a given message with file name and line#
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="msg">Message</param>
|
/// <param name="msg">Message</param>
|
||||||
/// <param name="error">True prepends "Error: "; False prepends "Warning: "</param>
|
/// <param name="error">True prepends "Error: "; False prepends "Warning: "</param>
|
||||||
@@ -470,9 +487,9 @@ namespace VocaluxeLib.Songs
|
|||||||
private const int _MaxOverlapNoteCt = 3;
|
private const int _MaxOverlapNoteCt = 3;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read notes. First try to read notes normally (assume standard)<br/>
|
/// Read notes. First try to read notes normally (assume standard)<br />
|
||||||
/// If there are more than _MaxZeroNoteCt with length < 1, try to read notes adding 1 to length<br/>
|
/// If there are more than _MaxZeroNoteCt with length < 1, try to read notes adding 1 to length<br />
|
||||||
/// Then if there are more than _MaxOverlapNoteCt fallback to first version ignoring notes with length < 1
|
/// Then if there are more than _MaxOverlapNoteCt fallback to first version ignoring notes with length < 1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="forceReload"></param>
|
/// <param name="forceReload"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace VocaluxeLib.Songs
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Find last line with StartBeat
|
/// Find last line with StartBeat
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beat"></param>
|
/// <param name="beat"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -128,7 +128,7 @@ namespace VocaluxeLib.Songs
|
|||||||
{
|
{
|
||||||
CSongLine prevLine = _Lines[insPos];
|
CSongLine prevLine = _Lines[insPos];
|
||||||
//We already have a line break here
|
//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;
|
return false;
|
||||||
//Maybe we have to split the previous line
|
//Maybe we have to split the previous line
|
||||||
while (prevLine.NoteCount > 0 && prevLine.LastNote.StartBeat >= startBeat)
|
while (prevLine.NoteCount > 0 && prevLine.LastNote.StartBeat >= startBeat)
|
||||||
|
|||||||
@@ -0,0 +1,171 @@
|
|||||||
|
#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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using Security.Cryptography;
|
||||||
|
using Security.Cryptography.X509Certificates;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using NetFwTypeLib;
|
||||||
|
|
||||||
|
namespace WebserverInitalConfig
|
||||||
|
{
|
||||||
|
public static class CConfigHttpApi
|
||||||
|
{
|
||||||
|
// 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}";
|
||||||
|
// ReSharper restore InconsistentNaming
|
||||||
|
public static void ReserveUrl(string networkString)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
|
||||||
|
keyParam.Parameters.Add(new CngProperty("Length", BitConverter.GetBytes(2048), CngPropertyOptions.None));
|
||||||
|
|
||||||
|
CngKey key = CngKey.Create(CngAlgorithm2.Rsa, Guid.NewGuid().ToString(), keyParam);
|
||||||
|
|
||||||
|
X509CertificateCreationParameters param = new X509CertificateCreationParameters(new X500DistinguishedName(subjectName))
|
||||||
|
{
|
||||||
|
SubjectName = new X500DistinguishedName(subjectName),
|
||||||
|
EndTime = DateTime.Today.AddYears(20) //,SignatureAlgorithm = X509CertificateSignatureAlgorithm.RsaSha512
|
||||||
|
};
|
||||||
|
|
||||||
|
OidCollection oc = new OidCollection {new Oid("1.3.6.1.5.5.7.3.1")};
|
||||||
|
X509Extension eku = new X509EnhancedKeyUsageExtension(oc, true);
|
||||||
|
param.Extensions.Add(eku);
|
||||||
|
|
||||||
|
param.TakeOwnershipOfKey = true;
|
||||||
|
|
||||||
|
byte[] rawData = key.CreateSelfSignedCertificate(param).Export(X509ContentType.Pfx, "");
|
||||||
|
var cert = new X509Certificate2(rawData, "", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet)
|
||||||
|
{
|
||||||
|
FriendlyName = "Vocaluxe Server Certificate"
|
||||||
|
};
|
||||||
|
return cert;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void _AddFirewallRuleForProfile(INetFwProfile profile, string exePath, int port, bool isTCP)
|
||||||
|
{
|
||||||
|
bool isFirewallEnabled = profile.FirewallEnabled;
|
||||||
|
|
||||||
|
if (!isFirewallEnabled)
|
||||||
|
return;
|
||||||
|
INetFwAuthorizedApplications applications = profile.AuthorizedApplications;
|
||||||
|
if (!(from INetFwAuthorizedApplication a in applications
|
||||||
|
where a.ProcessImageFileName == exePath
|
||||||
|
select a).Any())
|
||||||
|
{
|
||||||
|
INetFwAuthorizedApplication application = (INetFwAuthorizedApplication)Activator.CreateInstance(
|
||||||
|
Type.GetTypeFromCLSID(new Guid(CLSID_NetAuthApp)));
|
||||||
|
|
||||||
|
application.Name = "Vocaluxe";
|
||||||
|
application.ProcessImageFileName = exePath;
|
||||||
|
application.Enabled = true;
|
||||||
|
application.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_ALL;
|
||||||
|
applications.Add(application);
|
||||||
|
}
|
||||||
|
INetFwOpenPorts openPorts = profile.GloballyOpenPorts;
|
||||||
|
NET_FW_IP_PROTOCOL_ protocol = isTCP ? NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP : NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_UDP;
|
||||||
|
if (!(from INetFwOpenPort p in openPorts
|
||||||
|
where (p.Port == port &&
|
||||||
|
(p.Protocol == protocol))
|
||||||
|
select p).Any())
|
||||||
|
{
|
||||||
|
INetFwOpenPort openPort = (INetFwOpenPort)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(CLSID_NetOpenPort)));
|
||||||
|
openPort.Enabled = true;
|
||||||
|
openPort.Port = port;
|
||||||
|
openPort.Protocol = protocol;
|
||||||
|
openPort.Name = "Vocaluxe(" + port + ")";
|
||||||
|
openPort.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_ALL;
|
||||||
|
|
||||||
|
openPorts.Add(openPort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddFirewallRule(string exePath, int port, bool isTCP)
|
||||||
|
{
|
||||||
|
INetFwMgr manage = (INetFwMgr)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(CLSID_NetFwMgr)));
|
||||||
|
//AddFirewallRuleForProfile(manage.LocalPolicy.CurrentProfile, exePath, port, isTCP);
|
||||||
|
//if (manage.CurrentProfileType != NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_STANDARD)
|
||||||
|
//Add to Home/Work(Private) and current net
|
||||||
|
//TODO: This somewhow adds 2 entries each instead of only one that is activated for Home/Work and public nets
|
||||||
|
_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();
|
||||||
|
|
||||||
|
Mono.Security.Authenticode.PrivateKey key = new Mono.Security.Authenticode.PrivateKey { RSA=RSA.Create()};
|
||||||
|
|
||||||
|
|
||||||
|
Mono.Security.X509.X509CertificateBuilder x509 = new Mono.Security.X509.X509CertificateBuilder();
|
||||||
|
x509.IssuerName = "CN=Vocaluxe Server";
|
||||||
|
x509.NotAfter = DateTime.Today.AddYears(20);
|
||||||
|
x509.NotBefore = DateTime.Today.AddDays(-1);
|
||||||
|
x509.SubjectName = subject;
|
||||||
|
x509.SerialNumber = new byte[] { 1 };
|
||||||
|
x509.Version = 3;
|
||||||
|
x509.SubjectPublicKey = rsa;
|
||||||
|
|
||||||
|
ExtendedKeyUsageExtension eku = new ExtendedKeyUsageExtension();
|
||||||
|
eku.KeyPurpose.Add("1.3.6.1.5.5.7.3.1");
|
||||||
|
x509.Extensions.Add(eku);
|
||||||
|
|
||||||
|
return new X509Certificate2(x509.Sign(rsa));
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
using Security.Cryptography;
|
|
||||||
using Security.Cryptography.X509Certificates;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Security.Permissions;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using NetFwTypeLib;
|
|
||||||
|
|
||||||
namespace WebserverInitalConfig
|
|
||||||
{
|
|
||||||
public static class ConfigHttpApi
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void reserveURL(string networkString)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
foreach (var 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,
|
|
||||||
};
|
|
||||||
|
|
||||||
keyParam.Parameters.Add(new CngProperty("Length", BitConverter.GetBytes(2048), CngPropertyOptions.None));
|
|
||||||
|
|
||||||
CngKey key = CngKey.Create(CngAlgorithm2.Rsa, Guid.NewGuid().ToString(), keyParam);
|
|
||||||
|
|
||||||
X509CertificateCreationParameters param = new X509CertificateCreationParameters(
|
|
||||||
new X500DistinguishedName(subjectName));
|
|
||||||
param.SubjectName = new X500DistinguishedName(subjectName);
|
|
||||||
param.EndTime = DateTime.Today.AddYears(20);
|
|
||||||
//param.SignatureAlgorithm = X509CertificateSignatureAlgorithm.RsaSha512;
|
|
||||||
|
|
||||||
OidCollection oc = new OidCollection();
|
|
||||||
oc.Add(new Oid("1.3.6.1.5.5.7.3.1"));
|
|
||||||
X509Extension eku = new X509EnhancedKeyUsageExtension(oc, true);
|
|
||||||
param.Extensions.Add(eku);
|
|
||||||
|
|
||||||
param.TakeOwnershipOfKey = true;
|
|
||||||
|
|
||||||
byte[] rawData = key.CreateSelfSignedCertificate(param).Export(X509ContentType.Pfx, "");
|
|
||||||
var cert = new X509Certificate2(rawData, "", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
|
|
||||||
cert.FriendlyName = "Vocaluxe Server Certificate";
|
|
||||||
return cert;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addFirewallrule(string exePath, int port, bool isTCP)
|
|
||||||
{
|
|
||||||
INetFwMgr manage = (INetFwMgr)Activator.CreateInstance(
|
|
||||||
Type.GetTypeFromCLSID(new Guid("{304CE942-6E39-40D8-943A-B913C40C9CD4}")));
|
|
||||||
bool isFirewallEnabled = manage.LocalPolicy.CurrentProfile.FirewallEnabled;
|
|
||||||
|
|
||||||
if (isFirewallEnabled)
|
|
||||||
{
|
|
||||||
INetFwAuthorizedApplications applications = manage.LocalPolicy.CurrentProfile.AuthorizedApplications;
|
|
||||||
if ((from INetFwAuthorizedApplication a in applications
|
|
||||||
where a.ProcessImageFileName == exePath
|
|
||||||
select a).Count() == 0)
|
|
||||||
{
|
|
||||||
INetFwAuthorizedApplication application = (INetFwAuthorizedApplication)Activator.CreateInstance(
|
|
||||||
Type.GetTypeFromCLSID(new Guid("{EC9846B3-2762-4A6B-A214-6ACB603462D2}")));
|
|
||||||
|
|
||||||
application.Name = "Vocaluxe";
|
|
||||||
application.ProcessImageFileName = exePath;
|
|
||||||
application.Enabled = true;
|
|
||||||
applications.Add(application);
|
|
||||||
}
|
|
||||||
INetFwOpenPorts openPorts = manage.LocalPolicy.CurrentProfile.GloballyOpenPorts;
|
|
||||||
if ((from INetFwOpenPort p in openPorts
|
|
||||||
where (p.Port == port &&
|
|
||||||
(p.Protocol == (isTCP?NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP : NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_UDP)))
|
|
||||||
select p).Count() == 0)
|
|
||||||
{
|
|
||||||
INetFwOpenPort openPort = (INetFwOpenPort)Activator.CreateInstance(
|
|
||||||
Type.GetTypeFromCLSID(new Guid("{0CA545C6-37AD-4A6C-BF92-9F7610067EF5}")));
|
|
||||||
openPort.Enabled = true;
|
|
||||||
openPort.Port = port;
|
|
||||||
openPort.Protocol = (isTCP ? NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP : NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_UDP);
|
|
||||||
openPort.Name = "Vocaluxe";
|
|
||||||
|
|
||||||
openPorts.Add(openPort);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*public static X509Certificate2 getCert(string subject)
|
|
||||||
{
|
|
||||||
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
|
|
||||||
|
|
||||||
Mono.Security.Authenticode.PrivateKey key = new Mono.Security.Authenticode.PrivateKey { RSA=RSA.Create()};
|
|
||||||
|
|
||||||
|
|
||||||
Mono.Security.X509.X509CertificateBuilder x509 = new Mono.Security.X509.X509CertificateBuilder();
|
|
||||||
x509.IssuerName = "CN=Vocaluxe Server";
|
|
||||||
x509.NotAfter = DateTime.Today.AddYears(20);
|
|
||||||
x509.NotBefore = DateTime.Today.AddDays(-1);
|
|
||||||
x509.SubjectName = subject;
|
|
||||||
x509.SerialNumber = new byte[] { 1 };
|
|
||||||
x509.Version = 3;
|
|
||||||
x509.SubjectPublicKey = rsa;
|
|
||||||
|
|
||||||
ExtendedKeyUsageExtension eku = new ExtendedKeyUsageExtension();
|
|
||||||
eku.KeyPurpose.Add("1.3.6.1.5.5.7.3.1");
|
|
||||||
x509.Extensions.Add(eku);
|
|
||||||
|
|
||||||
return new X509Certificate2(x509.Sign(rsa));
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+368
-379
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -11,28 +28,19 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace WebserverInitalConfig
|
namespace WebserverInitalConfig
|
||||||
{
|
{
|
||||||
internal static class HttpApi
|
static class HttpApi
|
||||||
{
|
{
|
||||||
private static readonly HTTPAPI_VERSION HttpApiVersion = new HTTPAPI_VERSION(1, 0);
|
private static readonly HTTPAPI_VERSION HttpApiVersion = new HTTPAPI_VERSION(1, 0);
|
||||||
|
|
||||||
#region DllImport
|
#region DllImport
|
||||||
|
|
||||||
[DllImport("httpapi.dll", SetLastError = true)]
|
[DllImport("httpapi.dll", SetLastError = true)]
|
||||||
static extern uint HttpInitialize(
|
private static extern uint HttpInitialize(
|
||||||
HTTPAPI_VERSION version,
|
HTTPAPI_VERSION version,
|
||||||
uint flags,
|
uint flags,
|
||||||
IntPtr pReserved);
|
IntPtr pReserved);
|
||||||
|
|
||||||
[DllImport("httpapi.dll", SetLastError = true)]
|
[DllImport("httpapi.dll", SetLastError = true)]
|
||||||
static extern uint HttpSetServiceConfiguration(
|
private 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(
|
|
||||||
IntPtr serviceIntPtr,
|
IntPtr serviceIntPtr,
|
||||||
HTTP_SERVICE_CONFIG_ID configId,
|
HTTP_SERVICE_CONFIG_ID configId,
|
||||||
IntPtr pConfigInformation,
|
IntPtr pConfigInformation,
|
||||||
@@ -40,26 +48,31 @@ namespace WebserverInitalConfig
|
|||||||
IntPtr pOverlapped);
|
IntPtr pOverlapped);
|
||||||
|
|
||||||
[DllImport("httpapi.dll", SetLastError = true)]
|
[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,
|
uint Flags,
|
||||||
IntPtr pReserved);
|
IntPtr pReserved);
|
||||||
|
|
||||||
[DllImport("httpapi.dll", SetLastError = true)]
|
[DllImport("httpapi.dll", SetLastError = true)]
|
||||||
static extern uint HttpQueryServiceConfiguration(
|
private static extern uint HttpQueryServiceConfiguration(
|
||||||
IntPtr serviceIntPtr,
|
IntPtr serviceIntPtr,
|
||||||
HTTP_SERVICE_CONFIG_ID configId,
|
HTTP_SERVICE_CONFIG_ID configId,
|
||||||
IntPtr pInputConfigInfo,
|
IntPtr pInputConfigInfo,
|
||||||
int inputConfigInfoLength,
|
int inputConfigInfoLength,
|
||||||
IntPtr pOutputConfigInfo,
|
IntPtr pOutputConfigInfo,
|
||||||
int outputConfigInfoLength,
|
int outputConfigInfoLength,
|
||||||
[Optional]
|
[Optional] out int pReturnLength,
|
||||||
out int pReturnLength,
|
IntPtr pOverlapped);
|
||||||
IntPtr pOverlapped);
|
|
||||||
|
|
||||||
|
private enum HTTP_SERVICE_CONFIG_ID
|
||||||
enum HTTP_SERVICE_CONFIG_ID
|
|
||||||
{
|
{
|
||||||
|
|
||||||
HttpServiceConfigIPListenList = 0,
|
HttpServiceConfigIPListenList = 0,
|
||||||
HttpServiceConfigSSLCertInfo,
|
HttpServiceConfigSSLCertInfo,
|
||||||
HttpServiceConfigUrlAclInfo,
|
HttpServiceConfigUrlAclInfo,
|
||||||
@@ -67,14 +80,14 @@ namespace WebserverInitalConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[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_KEY KeyDesc;
|
||||||
public HTTP_SERVICE_CONFIG_SSL_PARAM ParamDesc;
|
public HTTP_SERVICE_CONFIG_SSL_PARAM ParamDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct HTTP_SERVICE_CONFIG_SSL_KEY
|
private struct HTTP_SERVICE_CONFIG_SSL_KEY
|
||||||
{
|
{
|
||||||
public IntPtr pIpPort;
|
public IntPtr pIpPort;
|
||||||
|
|
||||||
@@ -85,25 +98,22 @@ namespace WebserverInitalConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
struct HTTP_SERVICE_CONFIG_SSL_PARAM
|
private struct HTTP_SERVICE_CONFIG_SSL_PARAM
|
||||||
{
|
{
|
||||||
public int SslHashLength;
|
public int SslHashLength;
|
||||||
public IntPtr pSslHash;
|
public IntPtr pSslHash;
|
||||||
public Guid AppId;
|
public Guid AppId;
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
[MarshalAs(UnmanagedType.LPWStr)] public string pSslCertStoreName;
|
||||||
public string pSslCertStoreName;
|
|
||||||
public uint DefaultCertCheckMode;
|
public uint DefaultCertCheckMode;
|
||||||
public int DefaultRevocationFreshnessTime;
|
public int DefaultRevocationFreshnessTime;
|
||||||
public int DefaultRevocationUrlRetrievalTimeout;
|
public int DefaultRevocationUrlRetrievalTimeout;
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
[MarshalAs(UnmanagedType.LPWStr)] public string pDefaultSslCtlIdentifier;
|
||||||
public string pDefaultSslCtlIdentifier;
|
[MarshalAs(UnmanagedType.LPWStr)] public string pDefaultSslCtlStoreName;
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
|
||||||
public string pDefaultSslCtlStoreName;
|
|
||||||
public uint DefaultFlags;
|
public uint DefaultFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
||||||
struct HTTPAPI_VERSION
|
private struct HTTPAPI_VERSION
|
||||||
{
|
{
|
||||||
public ushort HttpApiMajorVersion;
|
public ushort HttpApiMajorVersion;
|
||||||
public ushort HttpApiMinorVersion;
|
public ushort HttpApiMinorVersion;
|
||||||
@@ -116,14 +126,14 @@ namespace WebserverInitalConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[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_QUERY_TYPE QueryDesc;
|
||||||
public HTTP_SERVICE_CONFIG_SSL_KEY KeyDesc;
|
public HTTP_SERVICE_CONFIG_SSL_KEY KeyDesc;
|
||||||
public uint dwToken;
|
public uint dwToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum HTTP_SERVICE_CONFIG_QUERY_TYPE
|
private enum HTTP_SERVICE_CONFIG_QUERY_TYPE
|
||||||
{
|
{
|
||||||
HttpServiceConfigQueryExact = 0,
|
HttpServiceConfigQueryExact = 0,
|
||||||
HttpServiceConfigQueryNext,
|
HttpServiceConfigQueryNext,
|
||||||
@@ -131,7 +141,7 @@ namespace WebserverInitalConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[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_KEY KeyDesc;
|
||||||
public HTTP_SERVICE_CONFIG_URLACL_PARAM ParamDesc;
|
public HTTP_SERVICE_CONFIG_URLACL_PARAM ParamDesc;
|
||||||
@@ -140,8 +150,7 @@ namespace WebserverInitalConfig
|
|||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
public struct HTTP_SERVICE_CONFIG_URLACL_KEY
|
public struct HTTP_SERVICE_CONFIG_URLACL_KEY
|
||||||
{
|
{
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
[MarshalAs(UnmanagedType.LPWStr)] public string pUrlPrefix;
|
||||||
public string pUrlPrefix;
|
|
||||||
|
|
||||||
public HTTP_SERVICE_CONFIG_URLACL_KEY(string urlPrefix)
|
public HTTP_SERVICE_CONFIG_URLACL_KEY(string urlPrefix)
|
||||||
{
|
{
|
||||||
@@ -150,21 +159,18 @@ namespace WebserverInitalConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
struct HTTP_SERVICE_CONFIG_URLACL_PARAM
|
private struct HTTP_SERVICE_CONFIG_URLACL_PARAM
|
||||||
{
|
{
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
[MarshalAs(UnmanagedType.LPWStr)] public string pStringSecurityDescriptor;
|
||||||
public string pStringSecurityDescriptor;
|
|
||||||
|
|
||||||
public HTTP_SERVICE_CONFIG_URLACL_PARAM(string securityDescriptor)
|
public HTTP_SERVICE_CONFIG_URLACL_PARAM(string securityDescriptor)
|
||||||
{
|
{
|
||||||
pStringSecurityDescriptor = securityDescriptor;
|
pStringSecurityDescriptor = securityDescriptor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constants
|
#region Constants
|
||||||
|
|
||||||
public const uint HTTP_INITIALIZE_CONFIG = 0x00000002;
|
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_NEGOTIATE_CLIENT_CERT = 0x00000002;
|
||||||
public const uint HTTP_SERVICE_CONFIG_SSL_FLAG_NO_RAW_FILTER = 0x00000004;
|
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_ALREADY_EXISTS = 183;
|
||||||
private const uint ERROR_FILE_NOT_FOUND = 2;
|
private const uint ERROR_FILE_NOT_FOUND = 2;
|
||||||
private const int ERROR_NO_MORE_ITEMS = 259;
|
private const int ERROR_NO_MORE_ITEMS = 259;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public methods
|
#region Public methods
|
||||||
|
|
||||||
public class SslCertificateInfo
|
public class SslCertificateInfo
|
||||||
{
|
{
|
||||||
public byte[] Hash { get; set; }
|
public byte[] Hash { get; set; }
|
||||||
@@ -192,162 +196,158 @@ namespace WebserverInitalConfig
|
|||||||
|
|
||||||
uint retVal;
|
uint retVal;
|
||||||
CallHttpApi(delegate
|
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;
|
GCHandle sockAddrHandle = CreateSockaddrStructure(ipPort);
|
||||||
int inputConfigInfoSize = Marshal.SizeOf(inputConfigInfoQuery);
|
IntPtr pIpPort = sockAddrHandle.AddrOfPinnedObject();
|
||||||
retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
|
HTTP_SERVICE_CONFIG_SSL_KEY sslKey = new HTTP_SERVICE_CONFIG_SSL_KEY(pIpPort);
|
||||||
queryType,
|
|
||||||
pInputConfigInfo,
|
|
||||||
inputConfigInfoSize,
|
|
||||||
pOutputConfigInfo,
|
|
||||||
returnLength,
|
|
||||||
out returnLength,
|
|
||||||
IntPtr.Zero);
|
|
||||||
if (retVal == ERROR_FILE_NOT_FOUND)
|
|
||||||
return;
|
|
||||||
|
|
||||||
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,
|
pOutputConfigInfo = Marshal.AllocCoTaskMem(returnLength);
|
||||||
queryType,
|
|
||||||
pInputConfigInfo,
|
try
|
||||||
inputConfigInfoSize,
|
{
|
||||||
pOutputConfigInfo,
|
retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
|
||||||
returnLength,
|
queryType,
|
||||||
out returnLength,
|
pInputConfigInfo,
|
||||||
IntPtr.Zero);
|
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);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void BindCertificate(IPEndPoint ipPort, byte[] hash, StoreName storeName, Guid appId)
|
public static void BindCertificate(IPEndPoint ipPort, byte[] hash, StoreName storeName, Guid appId)
|
||||||
{
|
{
|
||||||
if (ipPort == null) throw new ArgumentNullException("ipPort");
|
if (ipPort == null)
|
||||||
if (hash == null) throw new ArgumentNullException("hash");
|
throw new ArgumentNullException("ipPort");
|
||||||
|
if (hash == null)
|
||||||
|
throw new ArgumentNullException("hash");
|
||||||
|
|
||||||
CallHttpApi(
|
CallHttpApi(
|
||||||
delegate
|
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_SSL_SET configSslSet = new HTTP_SERVICE_CONFIG_SSL_SET();
|
||||||
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo,
|
|
||||||
pInputConfigInfo,
|
|
||||||
Marshal.SizeOf(configSslSet),
|
|
||||||
IntPtr.Zero);
|
|
||||||
|
|
||||||
if (ERROR_ALREADY_EXISTS != retVal)
|
GCHandle sockAddrHandle = CreateSockaddrStructure(ipPort);
|
||||||
{
|
IntPtr pIpPort = sockAddrHandle.AddrOfPinnedObject();
|
||||||
ThrowWin32ExceptionIfError(retVal);
|
HTTP_SERVICE_CONFIG_SSL_KEY httpServiceConfigSslKey =
|
||||||
}
|
new HTTP_SERVICE_CONFIG_SSL_KEY(pIpPort);
|
||||||
else
|
HTTP_SERVICE_CONFIG_SSL_PARAM configSslParam = new HTTP_SERVICE_CONFIG_SSL_PARAM();
|
||||||
{
|
|
||||||
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,
|
GCHandle handleHash = GCHandle.Alloc(hash, GCHandleType.Pinned);
|
||||||
pInputConfigInfo,
|
configSslParam.AppId = appId;
|
||||||
Marshal.SizeOf(configSslSet),
|
configSslParam.DefaultCertCheckMode = 0;
|
||||||
IntPtr.Zero);
|
configSslParam.DefaultFlags = 0; //HTTP_SERVICE_CONFIG_SSL_FLAG_NEGOTIATE_CLIENT_CERT;
|
||||||
ThrowWin32ExceptionIfError(retVal);
|
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
|
||||||
finally
|
{
|
||||||
{
|
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
||||||
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
if (handleHash.IsAllocated)
|
||||||
if (handleHash.IsAllocated)
|
handleHash.Free();
|
||||||
handleHash.Free();
|
if (sockAddrHandle.IsAllocated)
|
||||||
if (sockAddrHandle.IsAllocated)
|
sockAddrHandle.Free();
|
||||||
sockAddrHandle.Free();
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DeleteCertificateBinding(params IPEndPoint[] ipPorts)
|
public static void DeleteCertificateBinding(params IPEndPoint[] ipPorts)
|
||||||
@@ -356,41 +356,41 @@ namespace WebserverInitalConfig
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
CallHttpApi(
|
CallHttpApi(
|
||||||
delegate
|
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
|
|
||||||
{
|
{
|
||||||
uint retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
|
foreach (IPEndPoint ipPort in ipPorts)
|
||||||
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo,
|
{
|
||||||
pInputConfigInfo,
|
HTTP_SERVICE_CONFIG_SSL_SET configSslSet =
|
||||||
Marshal.SizeOf(configSslSet),
|
new HTTP_SERVICE_CONFIG_SSL_SET();
|
||||||
IntPtr.Zero);
|
|
||||||
ThrowWin32ExceptionIfError(retVal);
|
GCHandle sockAddrHandle = CreateSockaddrStructure(ipPort);
|
||||||
}
|
IntPtr pIpPort = sockAddrHandle.AddrOfPinnedObject();
|
||||||
finally
|
HTTP_SERVICE_CONFIG_SSL_KEY httpServiceConfigSslKey =
|
||||||
{
|
new HTTP_SERVICE_CONFIG_SSL_KEY(pIpPort);
|
||||||
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
configSslSet.KeyDesc = httpServiceConfigSslKey;
|
||||||
if (sockAddrHandle.IsAllocated)
|
|
||||||
sockAddrHandle.Free();
|
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()
|
public static SslCertificateInfo[] QuerySslCertificateInfo()
|
||||||
@@ -399,193 +399,186 @@ namespace WebserverInitalConfig
|
|||||||
|
|
||||||
CallHttpApi(
|
CallHttpApi(
|
||||||
delegate
|
delegate
|
||||||
{
|
|
||||||
uint token = 0;
|
|
||||||
|
|
||||||
uint retVal;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
HTTP_SERVICE_CONFIG_SSL_QUERY inputConfigInfoQuery =
|
uint token = 0;
|
||||||
new HTTP_SERVICE_CONFIG_SSL_QUERY
|
|
||||||
{
|
|
||||||
QueryDesc = HTTP_SERVICE_CONFIG_QUERY_TYPE.HttpServiceConfigQueryNext,
|
|
||||||
dwToken = token,
|
|
||||||
};
|
|
||||||
|
|
||||||
IntPtr pInputConfigInfo =
|
uint retVal;
|
||||||
Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_QUERY)));
|
do
|
||||||
Marshal.StructureToPtr(inputConfigInfoQuery, pInputConfigInfo, false);
|
|
||||||
|
|
||||||
IntPtr pOutputConfigInfo = IntPtr.Zero;
|
|
||||||
int returnLength = 0;
|
|
||||||
|
|
||||||
const HTTP_SERVICE_CONFIG_ID queryType = HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSSLCertInfo;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
int inputConfigInfoSize = Marshal.SizeOf(inputConfigInfoQuery);
|
HTTP_SERVICE_CONFIG_SSL_QUERY inputConfigInfoQuery =
|
||||||
retVal = HttpQueryServiceConfiguration(IntPtr.Zero,
|
new HTTP_SERVICE_CONFIG_SSL_QUERY
|
||||||
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,
|
QueryDesc = HTTP_SERVICE_CONFIG_QUERY_TYPE.HttpServiceConfigQueryNext,
|
||||||
Hash = hash,
|
dwToken = token,
|
||||||
StoreName = storeName,
|
|
||||||
IpPort = ipPort
|
|
||||||
};
|
};
|
||||||
result.Add(resultItem);
|
|
||||||
token++;
|
IntPtr pInputConfigInfo =
|
||||||
}
|
Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_QUERY)));
|
||||||
finally
|
Marshal.StructureToPtr(inputConfigInfoQuery, pInputConfigInfo, false);
|
||||||
{
|
|
||||||
Marshal.FreeCoTaskMem(pOutputConfigInfo);
|
IntPtr pOutputConfigInfo = IntPtr.Zero;
|
||||||
}
|
int returnLength = 0;
|
||||||
}
|
|
||||||
else
|
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
|
||||||
finally
|
{
|
||||||
{
|
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
||||||
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
}
|
||||||
}
|
} while (NOERROR == retVal);
|
||||||
|
});
|
||||||
} while (NOERROR == retVal);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ReserveURL(string networkURL, string securityDescriptor)
|
public static void ReserveURL(string networkURL, string securityDescriptor)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(networkURL)) throw new ArgumentNullException("networkURL");
|
if (String.IsNullOrEmpty(networkURL))
|
||||||
if (String.IsNullOrEmpty(securityDescriptor)) throw new ArgumentNullException("securityDescriptor");
|
throw new ArgumentNullException("networkURL");
|
||||||
|
if (String.IsNullOrEmpty(securityDescriptor))
|
||||||
|
throw new ArgumentNullException("securityDescriptor");
|
||||||
|
|
||||||
CallHttpApi(
|
CallHttpApi(
|
||||||
delegate
|
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,
|
uint retVal = (uint)NOERROR; // NOERROR = 0
|
||||||
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
|
|
||||||
pInputConfigInfo,
|
|
||||||
Marshal.SizeOf(inputConfigInfoSet),
|
|
||||||
IntPtr.Zero);
|
|
||||||
|
|
||||||
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,
|
retVal = HttpSetServiceConfiguration(IntPtr.Zero,
|
||||||
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
|
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
|
||||||
pInputConfigInfo,
|
pInputConfigInfo,
|
||||||
Marshal.SizeOf(inputConfigInfoSet),
|
Marshal.SizeOf(inputConfigInfoSet),
|
||||||
IntPtr.Zero);
|
IntPtr.Zero);
|
||||||
|
|
||||||
if ((uint)NOERROR == retVal)
|
if (ERROR_ALREADY_EXISTS == retVal) // ERROR_ALREADY_EXISTS = 183
|
||||||
{
|
{
|
||||||
retVal = HttpApi.HttpSetServiceConfiguration(IntPtr.Zero,
|
retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
|
||||||
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
|
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
|
||||||
pInputConfigInfo,
|
pInputConfigInfo,
|
||||||
Marshal.SizeOf(inputConfigInfoSet),
|
Marshal.SizeOf(inputConfigInfoSet),
|
||||||
IntPtr.Zero);
|
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);
|
|
||||||
|
|
||||||
HTTP_SERVICE_CONFIG_URLACL_SET inputConfigInfoSetOld = new HTTP_SERVICE_CONFIG_URLACL_SET();
|
if (NOERROR == retVal)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
retVal = HttpApi.HttpSetServiceConfiguration(IntPtr.Zero,
|
retVal = HttpSetServiceConfiguration(IntPtr.Zero,
|
||||||
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
|
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
|
||||||
pInputConfigInfo,
|
pInputConfigInfo,
|
||||||
Marshal.SizeOf(inputConfigInfoSet),
|
Marshal.SizeOf(inputConfigInfoSet),
|
||||||
IntPtr.Zero);
|
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
|
||||||
finally
|
{
|
||||||
{
|
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
||||||
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
HttpTerminate(HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
|
||||||
HttpApi.HttpTerminate(HttpApi.HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
|
}
|
||||||
}
|
if (NOERROR != retVal)
|
||||||
if ((uint)NOERROR != retVal)
|
ThrowWin32ExceptionIfError(retVal);
|
||||||
{
|
});
|
||||||
ThrowWin32ExceptionIfError(retVal);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static void ThrowWin32ExceptionIfError(uint retVal)
|
private static void ThrowWin32ExceptionIfError(uint retVal)
|
||||||
{
|
{
|
||||||
if (NOERROR != retVal)
|
if (NOERROR != retVal)
|
||||||
{
|
|
||||||
throw new Win32Exception(Convert.ToInt32(retVal));
|
throw new Win32Exception(Convert.ToInt32(retVal));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CallHttpApi(Action body)
|
private static void CallHttpApi(Action body)
|
||||||
@@ -604,7 +597,7 @@ namespace WebserverInitalConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates an unmanaged sockaddr structure to pass to a WinAPI function.
|
/// Creates an unmanaged sockaddr structure to pass to a WinAPI function.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ipEndPoint">IP address and port number</param>
|
/// <param name="ipEndPoint">IP address and port number</param>
|
||||||
/// <returns>a handle for the structure. Use the AddrOfPinnedObject Method to get a stable pointer to the object. </returns>
|
/// <returns>a handle for the structure. Use the AddrOfPinnedObject Method to get a stable pointer to the object. </returns>
|
||||||
@@ -617,14 +610,12 @@ namespace WebserverInitalConfig
|
|||||||
byte[] sockAddrStructureBytes = new byte[socketAddress.Size];
|
byte[] sockAddrStructureBytes = new byte[socketAddress.Size];
|
||||||
GCHandle sockAddrHandle = GCHandle.Alloc(sockAddrStructureBytes, GCHandleType.Pinned);
|
GCHandle sockAddrHandle = GCHandle.Alloc(sockAddrStructureBytes, GCHandleType.Pinned);
|
||||||
for (int i = 0; i < socketAddress.Size; ++i)
|
for (int i = 0; i < socketAddress.Size; ++i)
|
||||||
{
|
|
||||||
sockAddrStructureBytes[i] = socketAddress[i];
|
sockAddrStructureBytes[i] = socketAddress[i];
|
||||||
}
|
|
||||||
return sockAddrHandle;
|
return sockAddrHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads the unmanaged sockaddr structure returned by a WinAPI function
|
/// Reads the unmanaged sockaddr structure returned by a WinAPI function
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pSockaddrStructure">pointer to the unmanaged sockaddr structure</param>
|
/// <param name="pSockaddrStructure">pointer to the unmanaged sockaddr structure</param>
|
||||||
/// <returns>IP address and port number</returns>
|
/// <returns>IP address and port number</returns>
|
||||||
@@ -659,9 +650,7 @@ namespace WebserverInitalConfig
|
|||||||
// create SocketAddress from bytes
|
// create SocketAddress from bytes
|
||||||
var socketAddress = new SocketAddress(AddressFamily.Unspecified, sockAddrSructureSize);
|
var socketAddress = new SocketAddress(AddressFamily.Unspecified, sockAddrSructureSize);
|
||||||
for (int i = 0; i < sockAddrSructureSize; i++)
|
for (int i = 0; i < sockAddrSructureSize; i++)
|
||||||
{
|
|
||||||
socketAddress[i] = sockAddrSructureBytes[i];
|
socketAddress[i] = sockAddrSructureBytes[i];
|
||||||
}
|
|
||||||
|
|
||||||
// create IPEndPoint from SocketAddress
|
// create IPEndPoint from SocketAddress
|
||||||
IPEndPoint result = (IPEndPoint)ipEndPointAny.Create(socketAddress);
|
IPEndPoint result = (IPEndPoint)ipEndPointAny.Create(socketAddress);
|
||||||
@@ -669,4 +658,4 @@ namespace WebserverInitalConfig
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,30 @@
|
|||||||
using System;
|
#region license
|
||||||
using System.Collections.Generic;
|
// This file is part of Vocaluxe.
|
||||||
using System.Diagnostics;
|
//
|
||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Security.Principal;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace WebserverInitalConfig
|
namespace WebserverInitalConfig
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length != 2)
|
if (args.Length != 2)
|
||||||
{
|
{
|
||||||
@@ -20,22 +32,18 @@ namespace WebserverInitalConfig
|
|||||||
Environment.Exit(-1);
|
Environment.Exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHttpApi.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")
|
if (args[1].ToLower() == "true")
|
||||||
{
|
{
|
||||||
string hostname = Dns.GetHostName();
|
string hostname = Dns.GetHostName();
|
||||||
var cert = ConfigHttpApi.getSelfSignedCert("CN=" + hostname + " C=DE O=Vocaluxe OU=Vocaluxe Server");
|
X509Certificate2 cert = CConfigHttpApi.GetSelfSignedCert("CN=" + hostname + " C=DE O=Vocaluxe OU=Vocaluxe Server");
|
||||||
ConfigHttpApi.addCertToStore(cert);
|
CConfigHttpApi.AddCertToStore(cert);
|
||||||
ConfigHttpApi.bindCert("0.0.0.0", Int32.Parse(args[0]), cert);
|
CConfigHttpApi.BindCert("0.0.0.0", Int32.Parse(args[0]), cert);
|
||||||
ConfigHttpApi.reserveURL("https://+:" + args[0] + "/");
|
CConfigHttpApi.ReserveUrl("https://+:" + args[0] + "/");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
CConfigHttpApi.ReserveUrl("http://+:" + args[0] + "/");
|
||||||
ConfigHttpApi.reserveURL("http://+:" + args[0] + "/");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||||
// die mit einer Assembly verknüpft sind.
|
// die mit einer Assembly verknüpft sind.
|
||||||
|
|
||||||
[assembly: AssemblyTitle("Vocaluxe Server Config")]
|
[assembly: AssemblyTitle("Vocaluxe Server Config")]
|
||||||
[assembly: AssemblyDescription("Configures your computer to run the Vocaluxe Server")]
|
[assembly: AssemblyDescription("Configures your computer to run the Vocaluxe Server")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
@@ -17,9 +35,11 @@ using System.Runtime.InteropServices;
|
|||||||
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
|
// 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
|
// 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.
|
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
|
||||||
|
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
// 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")]
|
[assembly: Guid("b2df9255-3927-4125-ab3c-23c35794b04d")]
|
||||||
|
|
||||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
// 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
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>..\Output\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="ConfigHttpApi.cs" />
|
<Compile Include="CConfigHttpApi.cs" />
|
||||||
<Compile Include="HttpApi.cs" />
|
<Compile Include="HttpApi.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
@@ -76,6 +76,10 @@
|
|||||||
<Content Include="Vocaluxe.ico" />
|
<Content Include="Vocaluxe.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<PostBuildEvent>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
|||||||
Reference in new issue
Block a user