IMPORTANT: Format of all files with Resharper
NO functional changes. If you have problems merging your changes, merge/rebase on previous commit then merge this. Conflicts can easily be resolved (take yours if in doubt) After that merge next commits
This commit is contained in:
1 parent
3a110804d8
commit
149026ec32
36 files changed
+582
-439
No files matched your search
@@ -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;
|
||||||
@@ -25,7 +42,6 @@ namespace ServerLib
|
|||||||
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")
|
public CDiscover(int Port, string Keyword, string BroadcastAddress = "255.255.255.255")
|
||||||
@@ -36,7 +52,7 @@ namespace ServerLib
|
|||||||
|
|
||||||
_DiscoverRunning = false;
|
_DiscoverRunning = false;
|
||||||
_BroadcastTimer = new System.Timers.Timer();
|
_BroadcastTimer = new System.Timers.Timer();
|
||||||
_BroadcastTimer.Elapsed += new ElapsedEventHandler(OnBroadcastEvent);
|
_BroadcastTimer.Elapsed += OnBroadcastEvent;
|
||||||
_BroadcastTimer.Interval = 2500;
|
_BroadcastTimer.Interval = 2500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,173 +25,164 @@ 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",
|
||||||
@@ -186,29 +194,26 @@ namespace ServerLib
|
|||||||
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,13 +57,11 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -59,9 +72,7 @@ namespace ServerLib
|
|||||||
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,
|
||||||
|
|||||||
@@ -1,12 +1,31 @@
|
|||||||
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,
|
{
|
||||||
|
{
|
||||||
|
EUserRoles.TR_USERROLE_ADMIN,
|
||||||
(EUserRights.EditAllProfiles |
|
(EUserRights.EditAllProfiles |
|
||||||
EUserRights.UploadPhotos |
|
EUserRights.UploadPhotos |
|
||||||
EUserRights.ViewOtherProfiles |
|
EUserRights.ViewOtherProfiles |
|
||||||
@@ -15,27 +34,39 @@ namespace ServerLib
|
|||||||
EUserRights.ReorderPlaylists |
|
EUserRights.ReorderPlaylists |
|
||||||
EUserRights.CreatePlaylists |
|
EUserRights.CreatePlaylists |
|
||||||
EUserRights.DeletePlaylists |
|
EUserRights.DeletePlaylists |
|
||||||
EUserRights.RemoveSongsFromPlaylists)},
|
EUserRights.RemoveSongsFromPlaylists)
|
||||||
{EUserRoles.TR_USERROLE_GUEST,
|
},
|
||||||
EUserRights.None},
|
{
|
||||||
{EUserRoles.TR_USERROLE_NORMAL,
|
EUserRoles.TR_USERROLE_GUEST,
|
||||||
|
EUserRights.None
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EUserRoles.TR_USERROLE_NORMAL,
|
||||||
(EUserRights.UploadPhotos |
|
(EUserRights.UploadPhotos |
|
||||||
EUserRights.ViewOtherProfiles)},
|
EUserRights.ViewOtherProfiles)
|
||||||
{EUserRoles.TR_USERROLE_KEYBOARDUSER,
|
},
|
||||||
EUserRights.UseKeyboard},
|
{
|
||||||
{EUserRoles.TR_USERROLE_ADDSONGSUSER,
|
EUserRoles.TR_USERROLE_KEYBOARDUSER,
|
||||||
EUserRights.AddSongToPlaylist},
|
EUserRights.UseKeyboard
|
||||||
{EUserRoles.TR_USERROLE_PLAYLISTEDITOR,
|
},
|
||||||
|
{
|
||||||
|
EUserRoles.TR_USERROLE_ADDSONGSUSER,
|
||||||
|
EUserRights.AddSongToPlaylist
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EUserRoles.TR_USERROLE_PLAYLISTEDITOR,
|
||||||
(EUserRights.AddSongToPlaylist |
|
(EUserRights.AddSongToPlaylist |
|
||||||
EUserRights.ReorderPlaylists |
|
EUserRights.ReorderPlaylists |
|
||||||
EUserRights.CreatePlaylists |
|
EUserRights.CreatePlaylists |
|
||||||
EUserRights.DeletePlaylists |
|
EUserRights.DeletePlaylists |
|
||||||
EUserRights.RemoveSongsFromPlaylists)},
|
EUserRights.RemoveSongsFromPlaylists)
|
||||||
{EUserRoles.TR_USERROLE_PROFILEEDITOR,
|
},
|
||||||
EUserRights.EditAllProfiles}
|
{
|
||||||
|
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))
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Back()
|
public override void Back()
|
||||||
{
|
{
|
||||||
SPartyNameOptions options = GetData();
|
SPartyNameOptions options = GetData();
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void OnShow()
|
public override void OnShow()
|
||||||
{
|
{
|
||||||
base.OnShow();
|
base.OnShow();
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,10 +203,7 @@ namespace Vocaluxe.Base.Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -306,10 +287,8 @@ namespace Vocaluxe.Base.Server
|
|||||||
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,9 +520,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,9 +538,7 @@ namespace Vocaluxe.Base.Server
|
|||||||
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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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,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 Gst;
|
using Gst;
|
||||||
using GLib;
|
using GLib;
|
||||||
@@ -36,10 +53,8 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
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,10 +64,8 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -195,10 +208,8 @@ namespace Vocaluxe.Lib.Sound
|
|||||||
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,7 +269,7 @@ 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();
|
||||||
}
|
}
|
||||||
@@ -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,10 +425,7 @@ 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)
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -63,10 +63,14 @@ namespace Vocaluxe.Lib.Video
|
|||||||
/// 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);
|
||||||
|
|||||||
+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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -141,7 +142,8 @@ 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())
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
@@ -568,9 +571,7 @@ namespace VocaluxeLib.Menu
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (_NumTeams - 1 >= _PartyMode.GetMinTeams())
|
if (_NumTeams - 1 >= _PartyMode.GetMinTeams())
|
||||||
{
|
|
||||||
_NumTeams--;
|
_NumTeams--;
|
||||||
}
|
|
||||||
_UpdateButtonState();
|
_UpdateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,7 +604,6 @@ namespace VocaluxeLib.Menu
|
|||||||
}
|
}
|
||||||
|
|
||||||
#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,7 +662,6 @@ 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()
|
||||||
@@ -711,11 +708,9 @@ 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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void _RemovePlayerByIndex(int team, int index)
|
private void _RemovePlayerByIndex(int team, int index)
|
||||||
{
|
{
|
||||||
@@ -745,7 +740,6 @@ namespace VocaluxeLib.Menu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
@@ -487,12 +488,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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,21 @@
|
|||||||
using Security.Cryptography;
|
#region license
|
||||||
|
// This file is part of Vocaluxe.
|
||||||
|
//
|
||||||
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Vocaluxe is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using Security.Cryptography;
|
||||||
using Security.Cryptography.X509Certificates;
|
using Security.Cryptography.X509Certificates;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -21,19 +38,15 @@ namespace WebserverInitalConfig
|
|||||||
HttpApi.ReserveURL(networkString, "D:(A;;GX;;;S-1-1-0)");
|
HttpApi.ReserveURL(networkString, "D:(A;;GX;;;S-1-1-0)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void BindCert(string ip, int port, X509Certificate2 cert)
|
public static void BindCert(string ip, int port, X509Certificate2 cert)
|
||||||
{
|
{
|
||||||
IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(ip), port);
|
IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(ip), port);
|
||||||
if (HttpApi.QuerySslCertificateInfo(endpoint) != null)
|
if (HttpApi.QuerySslCertificateInfo(endpoint) != null)
|
||||||
{
|
|
||||||
HttpApi.DeleteCertificateBinding(endpoint);
|
HttpApi.DeleteCertificateBinding(endpoint);
|
||||||
}
|
|
||||||
|
|
||||||
HttpApi.BindCertificate(endpoint, cert.GetCertHash(), StoreName.My, new Guid("{7baf41f1-48b7-42cb-b145-f815499cb48f}"));
|
HttpApi.BindCertificate(endpoint, cert.GetCertHash(), StoreName.My, new Guid("{7baf41f1-48b7-42cb-b145-f815499cb48f}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void AddCertToStore(X509Certificate2 cert)
|
public static void AddCertToStore(X509Certificate2 cert)
|
||||||
{
|
{
|
||||||
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
|
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
|
||||||
@@ -42,16 +55,13 @@ namespace WebserverInitalConfig
|
|||||||
X509Certificate2Collection oldCerts = store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName,
|
X509Certificate2Collection oldCerts = store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName,
|
||||||
cert.SubjectName.Name, false);
|
cert.SubjectName.Name, false);
|
||||||
|
|
||||||
foreach (var oldCert in oldCerts)
|
foreach (X509Certificate2 oldCert in oldCerts)
|
||||||
{
|
|
||||||
store.Remove(oldCert);
|
store.Remove(oldCert);
|
||||||
}
|
|
||||||
|
|
||||||
store.Add(cert);
|
store.Add(cert);
|
||||||
store.Close();
|
store.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static X509Certificate2 GetSelfSignedCert(string subjectName)
|
public static X509Certificate2 GetSelfSignedCert(string subjectName)
|
||||||
{
|
{
|
||||||
var keyParam = new CngKeyCreationParameters
|
var keyParam = new CngKeyCreationParameters
|
||||||
@@ -134,6 +144,7 @@ namespace WebserverInitalConfig
|
|||||||
_AddFirewallRuleForProfile(manage.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_STANDARD), exePath, port, isTCP);
|
_AddFirewallRuleForProfile(manage.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_STANDARD), exePath, port, isTCP);
|
||||||
_AddFirewallRuleForProfile(manage.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_CURRENT), exePath, port, isTCP);
|
_AddFirewallRuleForProfile(manage.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_CURRENT), exePath, port, isTCP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static X509Certificate2 getCert(string subject)
|
/*public static X509Certificate2 getCert(string subject)
|
||||||
{
|
{
|
||||||
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
|
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
|
||||||
|
|||||||
@@ -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,20 +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,
|
IntPtr serviceIntPtr,
|
||||||
HTTP_SERVICE_CONFIG_ID configId,
|
HTTP_SERVICE_CONFIG_ID configId,
|
||||||
IntPtr pConfigInformation,
|
IntPtr pConfigInformation,
|
||||||
@@ -32,7 +48,7 @@ namespace WebserverInitalConfig
|
|||||||
IntPtr pOverlapped);
|
IntPtr pOverlapped);
|
||||||
|
|
||||||
[DllImport("httpapi.dll", SetLastError = true)]
|
[DllImport("httpapi.dll", SetLastError = true)]
|
||||||
static extern uint HttpDeleteServiceConfiguration(
|
private static extern uint HttpDeleteServiceConfiguration(
|
||||||
IntPtr serviceIntPtr,
|
IntPtr serviceIntPtr,
|
||||||
HTTP_SERVICE_CONFIG_ID configId,
|
HTTP_SERVICE_CONFIG_ID configId,
|
||||||
IntPtr pConfigInformation,
|
IntPtr pConfigInformation,
|
||||||
@@ -40,26 +56,23 @@ namespace WebserverInitalConfig
|
|||||||
IntPtr pOverlapped);
|
IntPtr pOverlapped);
|
||||||
|
|
||||||
[DllImport("httpapi.dll", SetLastError = true)]
|
[DllImport("httpapi.dll", SetLastError = true)]
|
||||||
static extern uint HttpTerminate(
|
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; }
|
||||||
@@ -260,18 +264,14 @@ namespace WebserverInitalConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ThrowWin32ExceptionIfError(retVal);
|
ThrowWin32ExceptionIfError(retVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
||||||
if (sockAddrHandle.IsAllocated)
|
if (sockAddrHandle.IsAllocated)
|
||||||
sockAddrHandle.Free();
|
sockAddrHandle.Free();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -279,8 +279,10 @@ namespace WebserverInitalConfig
|
|||||||
|
|
||||||
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
|
||||||
@@ -319,9 +321,7 @@ namespace WebserverInitalConfig
|
|||||||
IntPtr.Zero);
|
IntPtr.Zero);
|
||||||
|
|
||||||
if (ERROR_ALREADY_EXISTS != retVal)
|
if (ERROR_ALREADY_EXISTS != retVal)
|
||||||
{
|
|
||||||
ThrowWin32ExceptionIfError(retVal);
|
ThrowWin32ExceptionIfError(retVal);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
|
retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
|
||||||
@@ -358,7 +358,7 @@ namespace WebserverInitalConfig
|
|||||||
CallHttpApi(
|
CallHttpApi(
|
||||||
delegate
|
delegate
|
||||||
{
|
{
|
||||||
foreach (var ipPort in ipPorts)
|
foreach (IPEndPoint ipPort in ipPorts)
|
||||||
{
|
{
|
||||||
HTTP_SERVICE_CONFIG_SSL_SET configSslSet =
|
HTTP_SERVICE_CONFIG_SSL_SET configSslSet =
|
||||||
new HTTP_SERVICE_CONFIG_SSL_SET();
|
new HTTP_SERVICE_CONFIG_SSL_SET();
|
||||||
@@ -476,17 +476,13 @@ namespace WebserverInitalConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ThrowWin32ExceptionIfError(retVal);
|
ThrowWin32ExceptionIfError(retVal);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (NOERROR == retVal);
|
} while (NOERROR == retVal);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
@@ -494,8 +490,10 @@ namespace WebserverInitalConfig
|
|||||||
|
|
||||||
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
|
||||||
@@ -513,29 +511,29 @@ namespace WebserverInitalConfig
|
|||||||
Marshal.StructureToPtr(inputConfigInfoSet, pInputConfigInfo, false);
|
Marshal.StructureToPtr(inputConfigInfoSet, pInputConfigInfo, false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
|
||||||
if ((uint)ERROR_ALREADY_EXISTS == retVal) // ERROR_ALREADY_EXISTS = 183
|
if (ERROR_ALREADY_EXISTS == retVal) // ERROR_ALREADY_EXISTS = 183
|
||||||
{
|
{
|
||||||
retVal = HttpApi.HttpDeleteServiceConfiguration(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);
|
||||||
|
|
||||||
if ((uint)NOERROR == retVal)
|
if (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 ((uint)ERROR_FILE_NOT_FOUND == retVal) // ERROR_FILE_NOT_FOUND = 2
|
else if (ERROR_FILE_NOT_FOUND == retVal) // ERROR_FILE_NOT_FOUND = 2
|
||||||
{
|
{
|
||||||
string networkURLOld = networkURL.Contains("https") ? networkURL.Replace("https", "http") :
|
string networkURLOld = networkURL.Contains("https") ? networkURL.Replace("https", "http") :
|
||||||
networkURL.Replace("http", "https");
|
networkURL.Replace("http", "https");
|
||||||
@@ -549,15 +547,15 @@ namespace WebserverInitalConfig
|
|||||||
IntPtr pInputConfigInfoOld = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));
|
IntPtr pInputConfigInfoOld = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));
|
||||||
Marshal.StructureToPtr(inputConfigInfoSetOld, pInputConfigInfoOld, false);
|
Marshal.StructureToPtr(inputConfigInfoSetOld, pInputConfigInfoOld, false);
|
||||||
|
|
||||||
retVal = HttpApi.HttpDeleteServiceConfiguration(IntPtr.Zero,
|
retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
|
||||||
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
|
HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
|
||||||
pInputConfigInfoOld,
|
pInputConfigInfoOld,
|
||||||
Marshal.SizeOf(inputConfigInfoSetOld),
|
Marshal.SizeOf(inputConfigInfoSetOld),
|
||||||
IntPtr.Zero);
|
IntPtr.Zero);
|
||||||
|
|
||||||
if ((uint)NOERROR == retVal)
|
if (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),
|
||||||
@@ -569,24 +567,19 @@ namespace WebserverInitalConfig
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
Marshal.FreeCoTaskMem(pInputConfigInfo);
|
||||||
HttpApi.HttpTerminate(HttpApi.HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
|
HttpTerminate(HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
if ((uint)NOERROR != retVal)
|
if (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)
|
||||||
{
|
{
|
||||||
@@ -617,9 +610,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -1,12 +1,30 @@
|
|||||||
using System;
|
#region license
|
||||||
|
// This file is part of Vocaluxe.
|
||||||
|
//
|
||||||
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Vocaluxe is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -19,17 +37,13 @@ namespace WebserverInitalConfig
|
|||||||
if (args[1].ToLower() == "true")
|
if (args[1].ToLower() == "true")
|
||||||
{
|
{
|
||||||
string hostname = Dns.GetHostName();
|
string hostname = Dns.GetHostName();
|
||||||
var cert = CConfigHttpApi.GetSelfSignedCert("CN=" + hostname + " C=DE O=Vocaluxe OU=Vocaluxe Server");
|
X509Certificate2 cert = CConfigHttpApi.GetSelfSignedCert("CN=" + hostname + " C=DE O=Vocaluxe OU=Vocaluxe Server");
|
||||||
CConfigHttpApi.AddCertToStore(cert);
|
CConfigHttpApi.AddCertToStore(cert);
|
||||||
CConfigHttpApi.BindCert("0.0.0.0", Int32.Parse(args[0]), cert);
|
CConfigHttpApi.BindCert("0.0.0.0", Int32.Parse(args[0]), cert);
|
||||||
CConfigHttpApi.ReserveUrl("https://+:" + args[0] + "/");
|
CConfigHttpApi.ReserveUrl("https://+:" + args[0] + "/");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
CConfigHttpApi.ReserveUrl("http://+:" + args[0] + "/");
|
CConfigHttpApi.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")]
|
||||||
Reference in new issue
Block a user