Webserver:

- Create/edit/delete playlists in the app
- Fixed projektconfiguration (some project builds were disabled)
- hide menue lines if the user has no right
This commit is contained in:
lukeIam committed 2013-12-13 18:01:43 +01:00
1 parent 959a11a4a2
commit 35657f8698
19 files changed
+572 -113

No files matched your search

+4 -4
View File
@@ -124,7 +124,7 @@ namespace Vocaluxe.Base
public static EOffOn ServerActive = EOffOn.TR_CONFIG_OFF;
public static EOffOn ServerEncryption = EOffOn.TR_CONFIG_OFF;
public static int ServerPort = 3000;
public static string ServerPassword = "vocaluxe";
//public static string ServerPassword = "vocaluxe";
//Lists to save parameters and values
private static readonly List<string> _Params = new List<string>();
@@ -299,7 +299,7 @@ namespace Vocaluxe.Base
if (ServerPort < 1 || ServerPort > 65535)
ServerPort = 3000;
xmlReader.GetValue("//root/Server/ServerPassword", out ServerPassword, ServerPassword);
//xmlReader.GetValue("//root/Server/ServerPassword", out ServerPassword, ServerPassword);
#endregion Server
}
@@ -573,8 +573,8 @@ namespace Vocaluxe.Base
writer.WriteComment("Server Port (default: 3000) [1..65535]");
writer.WriteElementString("ServerPort", ServerPort.ToString());
writer.WriteComment("Server Password (default: vocaluxe)");
writer.WriteElementString("ServerPassword", ServerPassword);
//writer.WriteComment("Server Password (default: vocaluxe)");
//writer.WriteElementString("ServerPassword", ServerPassword);
writer.WriteEndElement();
#endregion Server
+14 -14
View File
@@ -1,18 +1,18 @@
#region license
// This file is part of Vocaluxe.
#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 free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
// 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;
@@ -77,7 +77,7 @@ namespace Vocaluxe.Base
foreach (string file in files)
{
var playlist = new CPlaylistFile(file);
CPlaylistFile playlist = new CPlaylistFile(file, files.IndexOf(file));
_Playlists.Add(playlist);
}
}
@@ -125,7 +125,7 @@ namespace Vocaluxe.Base
public static int NewPlaylist()
{
var pl = new CPlaylistFile {PlaylistName = "New Playlist"};
CPlaylistFile pl = new CPlaylistFile { PlaylistName = "New Playlist", Id = _Playlists.Count };
_Playlists.Add(pl);
return _Playlists.Count - 1;
}
+54 -26
View File
@@ -47,7 +47,6 @@ namespace Vocaluxe.Base.Server
_Clients = new Dictionary<int, CClientHandler>();
_Server = new CServer(CConfig.ServerPort, CConfig.ServerEncryption == EOffOn.TR_CONFIG_ON);
//TODO: remove CConfig.ServerPassword
CServer.SendKeyEvent = _SendKeyEvent;
CServer.GetProfileData = _GetProfileData;
@@ -64,6 +63,15 @@ namespace Vocaluxe.Base.Server
CServer.SetUserRole = _SetUserRole;
CServer.GetUserIdFromUsername = _GetUserIdFromUsername;
CServer.GetDelayedImage = _GetDelayedImage;
CServer.GetPlaylists = _GetPlaylists;
CServer.GetPlaylist = _GetPlaylist;
CServer.AddSongToPlaylist = _AddSongToPlaylist;
CServer.RemoveSongFromPlaylist = _RemoveSongFromPlaylist;
CServer.MoveSongInPlaylist = _MoveSongInPlaylist;
CServer.PlaylistContainsSong = _PlaylistContainsSong;
CServer.GetPlaylistSongs = _GetPlaylistSongs;
CServer.RemovePlaylist = _RemovePlaylist;
CServer.AddPlaylist = _AddPlaylist;
_Discover = new CDiscover(CConfig.ServerPort, CCommands.BroadcastKeyword);
Controller.Init();
@@ -432,31 +440,32 @@ namespace Vocaluxe.Base.Server
#region playlist
public static SPlaylistInfo[] GetPlaylists()
private static SPlaylistInfo[] _GetPlaylists()
{
return (from p in CPlaylists.Playlists
select _GetPlaylistInfo(p)).ToArray();
}
public static SPlaylistInfo GetPlaylist(int playlistId)
private static SPlaylistInfo _GetPlaylist(int playlistId)
{
if (CPlaylists.Playlists.Length <= playlistId)
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
{
throw new ArgumentException("invalid playlistId");
}
return _GetPlaylistInfo(CPlaylists.Playlists[playlistId]);
}
public static void AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates)
private static void _AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates)
{
if (CPlaylists.Playlists.Length <= playlistId)
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
{
throw new ArgumentException("invalid playlistId");
}
if (allowDuplicates || PlaylistContainsSong(songId, playlistId))
if (allowDuplicates || !_PlaylistContainsSong(songId, playlistId))
{
CPlaylists.AddPlaylistSong(playlistId, songId);
CPlaylists.SavePlaylist(playlistId);
}
else
{
@@ -464,57 +473,58 @@ namespace Vocaluxe.Base.Server
}
}
public static void RemoveSongFromPlaylist(int position, int playlistId, int songId)
private static void _RemoveSongFromPlaylist(int position, int playlistId, int songId)
{
if (CPlaylists.Playlists.Length <= playlistId)
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
{
throw new ArgumentException("invalid playlistId");
}
if (!PlaylistContainsSong(songId, playlistId))
if (!_PlaylistContainsSong(songId, playlistId))
{
throw new ArgumentException("invalid songId");
}
if (CPlaylists.Playlists[playlistId].Songs.Count <= position || CPlaylists.Playlists[playlistId].Songs[position].SongID != songId)
if (position < 0 || CPlaylists.Playlists[playlistId].Songs.Count <= position
|| CPlaylists.Playlists[playlistId].Songs[position].SongID != songId)
{
throw new ArgumentException("invalid position");
}
CPlaylists.Playlists[playlistId].DeleteSong(position);
CPlaylists.SavePlaylist(playlistId);
}
public static void MoveSongInPlaylist(int oldPosition, int newPosition, int playlistId, int songId)
private static void _MoveSongInPlaylist(int newPosition, int playlistId, int songId)
{
if (CPlaylists.Playlists.Length <= playlistId)
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
{
throw new ArgumentException("invalid playlistId");
}
if (!PlaylistContainsSong(songId, playlistId))
if (!_PlaylistContainsSong(songId, playlistId))
{
throw new ArgumentException("invalid songId");
}
if (CPlaylists.Playlists[playlistId].Songs.Count <= oldPosition || CPlaylists.Playlists[playlistId].Songs[oldPosition].SongID != songId)
{
throw new ArgumentException("invalid oldPosition");
}
if (CPlaylists.Playlists[playlistId].Songs.Count < newPosition )
if (CPlaylists.Playlists[playlistId].Songs.Count < newPosition)
{
throw new ArgumentException("invalid newPosition");
}
CPlaylists.MovePlaylistSong(playlistId,oldPosition, newPosition);
int oldPosition = CPlaylists.Playlists[playlistId].Songs.FindIndex(s => s.SongID == songId);
CPlaylists.MovePlaylistSong(playlistId, oldPosition, newPosition);
CPlaylists.SavePlaylist(playlistId);
}
public static bool PlaylistContainsSong(int songId, int playlistId)
private static bool _PlaylistContainsSong(int songId, int playlistId)
{
if (CPlaylists.Playlists.Length <= playlistId)
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
{
throw new ArgumentException("invalid playlistId");
}
return CPlaylists.Playlists[playlistId].Songs.Any(s => s.SongID == songId);
}
public static SPlaylistSongInfo[] GetPlaylistSongs(int playlistId)
private static SPlaylistSongInfo[] _GetPlaylistSongs(int playlistId)
{
if (CPlaylists.Playlists.Length <= playlistId)
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
{
throw new ArgumentException("invalid playlistId");
}
@@ -540,7 +550,7 @@ namespace Vocaluxe.Base.Server
SPlaylistSongInfo[] result = new SPlaylistSongInfo[playlist.Songs.Count];
for (int i = 0; i < playlist.Songs.Count; i++)
{
result[i] = _GetPlaylistSongInfo(playlist.Songs[i], 1 /*TODO:PlaylistID???*/, i);
result[i] = _GetPlaylistSongInfo(playlist.Songs[i], playlist.Id, i);
}
return result;
}
@@ -549,13 +559,31 @@ namespace Vocaluxe.Base.Server
{
return new SPlaylistInfo
{
PlaylistId = 1, /*TODO: PlaylistId*/
PlaylistId = playlist.Id,
PlaylistName = playlist.PlaylistName,
SongCount = playlist.Songs.Count,
LastChanged = DateTime.Now.ToLongDateString()
};
}
private static void _RemovePlaylist(int playlistId)
{
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
{
throw new ArgumentException("invalid playlistId");
}
CPlaylists.DeletePlaylist(playlistId);
}
private static int _AddPlaylist(string playlistName)
{
int newPlaylistId = CPlaylists.NewPlaylist();
CPlaylists.Playlists[newPlaylistId].PlaylistName = playlistName;
CPlaylists.SavePlaylist(newPlaylistId);
return newPlaylistId;
}
#endregion
#region user management