From: <kro...@us...> - 2010-12-04 18:31:32
|
Revision: 4006 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4006&view=rev Author: kroko_koenig Date: 2010-12-04 18:31:25 +0000 (Sat, 04 Dec 2010) Log Message: ----------- add support for picture db Modified Paths: -------------- trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs trunk/plugins/AndroidRemote/Server/AndroidRemote.suo Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2010-12-04 17:50:02 UTC (rev 4005) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2010-12-04 18:31:25 UTC (rev 4006) @@ -39,6 +39,9 @@ using MediaPortal.Utils; using MediaPortal.Database; +using MediaPortal.Player; +using MediaPortal.Playlists; + namespace AndroidRemote { public class Request @@ -147,6 +150,53 @@ } #endregion + #region pictured datatbase + + else if (req.StartsWith("/db_pictures")) + { + // handle pictures + req = req.Replace("/db_pictures", ""); + if (req.StartsWith("/")) req = req.Substring(1); + + if (req == "years.xml") + { + ReplyPicturesDbYears(); + } + if (req.StartsWith("months.xml")) + { + int pos = req.IndexOf("?"); + if (pos > 0) + { + string year = req.Substring(pos + 1); + ReplyPicturesDbMonths(year); + } + } + if (req.StartsWith("days.xml")) + { + int pos = req.IndexOf("?"); + if (pos > 0) + { + string date = req.Substring(pos + 1); + string[] my = date.Split('&'); + if (my.Length == 2) + { + ReplyPicturesDbDays(my[0], my[1]); + } + } + } + if (req.StartsWith("date.xml")) + { + int pos = req.IndexOf("?"); + if (pos > 0) + { + string date = req.Substring(pos + 1); + ReplyPicturesDbByDate(date); + } + } + } + + #endregion + #region music else if (req.StartsWith("/music")) { @@ -272,159 +322,175 @@ data.Add(child.Name, child.InnerText); } - #region player - if (Message.Contains("ACTION_PLAY")) - { - Action action = new Action(Action.ActionType.ACTION_PLAY, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_STOP")) - { - Action action = new Action(Action.ActionType.ACTION_STOP, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_PAUSE")) - { - Action action = new Action(Action.ActionType.ACTION_PAUSE, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_NEXT_ITEM")) - { - Action action = new Action(Action.ActionType.ACTION_NEXT_ITEM, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_PREV_ITEM")) - { - Action action = new Action(Action.ActionType.ACTION_PREV_ITEM, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_FORWARD")) - { - Action action = new Action(Action.ActionType.ACTION_FORWARD, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_REWIND")) - { - Action action = new Action(Action.ActionType.ACTION_REWIND, 0, 0); - GUIGraphicsContext.OnAction(action); - } - #endregion + //PlayListPlayer playlistPlayer = PlayListPlayer.SingletonPlayer; + //PlayList playList = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC); - #region navigate - if (Message.Contains("ACTION_MOVE_RIGHT")) - { - Action action = new Action(Action.ActionType.ACTION_MOVE_RIGHT, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_MOVE_LEFT")) - { - Action action = new Action(Action.ActionType.ACTION_MOVE_LEFT, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_MOVE_UP")) - { - Action action = new Action(Action.ActionType.ACTION_MOVE_UP, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_MOVE_DOWN")) - { - Action action = new Action(Action.ActionType.ACTION_MOVE_DOWN, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_SELECT_ITEM")) - { - Action action = new Action(Action.ActionType.ACTION_SELECT_ITEM, 0, 0); - GUIGraphicsContext.OnAction(action); - } - #endregion + //PlayListItem playlistItem = new PlayListItem(); + //playlistItem.Type = PlayListItem.PlayListItemType.Audio; + //playlistItem.FileName = "c:\\mp3\\the-gossip-heavy-cross-full-length-hq--lyrics.mp3"; + //playlistItem.Description = "My Desc"; + //playlistItem.Duration = 1234; - #region menu - if (Message.Contains("ACTION_PREVIOUS_MENU")) - { - Action action = new Action(Action.ActionType.ACTION_PREVIOUS_MENU, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_PARENT_DIR")) - { - Action action = new Action(Action.ActionType.ACTION_PARENT_DIR, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_SHOW_INFO")) - { - Action action = new Action(Action.ActionType.ACTION_SHOW_INFO, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_CONTEXT_MENU")) - { - Action action = new Action(Action.ActionType.ACTION_CONTEXT_MENU, 0, 0); - GUIGraphicsContext.OnAction(action); - } - #endregion + //playlistItem.MusicTag = null; + //playList.Add(playlistItem); - #region volume / programm - if (Message.Contains("ACTION_VOLUME_UP")) + if (data.ContainsKey("command")) { - Action action = new Action(Action.ActionType.ACTION_VOLUME_UP, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_VOLUME_DOWN")) - { - Action action = new Action(Action.ActionType.ACTION_VOLUME_DOWN, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_VOLUME_MUTE")) - { - Action action = new Action(Action.ActionType.ACTION_VOLUME_MUTE, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_NEXT_CHANNEL")) - { - Action action = new Action(Action.ActionType.ACTION_NEXT_CHANNEL, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_PREV_CHANNEL")) - { - Action action = new Action(Action.ActionType.ACTION_PREV_CHANNEL, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_PREV_CHANNEL")) - { - Action action = new Action(Action.ActionType.ACTION_PREV_CHANNEL, 0, 0); - GUIGraphicsContext.OnAction(action); - } + #region player + if (data["command"] == "ACTION_PLAY") + { + Action action = new Action(Action.ActionType.ACTION_PLAY, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_STOP")) + { + Action action = new Action(Action.ActionType.ACTION_STOP, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_PAUSE")) + { + Action action = new Action(Action.ActionType.ACTION_PAUSE, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_NEXT_ITEM")) + { + Action action = new Action(Action.ActionType.ACTION_NEXT_ITEM, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_PREV_ITEM")) + { + Action action = new Action(Action.ActionType.ACTION_PREV_ITEM, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_FORWARD")) + { + Action action = new Action(Action.ActionType.ACTION_FORWARD, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_REWIND")) + { + Action action = new Action(Action.ActionType.ACTION_REWIND, 0, 0); + GUIGraphicsContext.OnAction(action); + } + #endregion - #endregion + #region navigate + if (data["command"] == ("ACTION_MOVE_RIGHT")) + { + Action action = new Action(Action.ActionType.ACTION_MOVE_RIGHT, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_MOVE_LEFT")) + { + Action action = new Action(Action.ActionType.ACTION_MOVE_LEFT, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_MOVE_UP")) + { + Action action = new Action(Action.ActionType.ACTION_MOVE_UP, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_MOVE_DOWN")) + { + Action action = new Action(Action.ActionType.ACTION_MOVE_DOWN, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_SELECT_ITEM")) + { + Action action = new Action(Action.ActionType.ACTION_SELECT_ITEM, 0, 0); + GUIGraphicsContext.OnAction(action); + } + #endregion - #region power control - if (Message.Contains("ACTION_EXIT")) - { - Action action = new Action(Action.ActionType.ACTION_EXIT, 0, 0); - GUIGraphicsContext.OnAction(action); - } + #region menu + if (data["command"] == ("ACTION_PREVIOUS_MENU")) + { + Action action = new Action(Action.ActionType.ACTION_PREVIOUS_MENU, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_PARENT_DIR")) + { + Action action = new Action(Action.ActionType.ACTION_PARENT_DIR, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_SHOW_INFO")) + { + Action action = new Action(Action.ActionType.ACTION_SHOW_INFO, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_CONTEXT_MENU")) + { + Action action = new Action(Action.ActionType.ACTION_CONTEXT_MENU, 0, 0); + GUIGraphicsContext.OnAction(action); + } + #endregion - // TODO: these actions need confirmation so we need to do change it later.... - if (Message.Contains("ACTION_SUSPEND")) - { - Action action = new Action(Action.ActionType.ACTION_SUSPEND, 0, 0); - GUIGraphicsContext.OnAction(action); + #region volume / programm + if (data["command"] == ("ACTION_VOLUME_UP")) + { + Action action = new Action(Action.ActionType.ACTION_VOLUME_UP, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_VOLUME_DOWN")) + { + Action action = new Action(Action.ActionType.ACTION_VOLUME_DOWN, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_VOLUME_MUTE")) + { + Action action = new Action(Action.ActionType.ACTION_VOLUME_MUTE, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_NEXT_CHANNEL")) + { + Action action = new Action(Action.ActionType.ACTION_NEXT_CHANNEL, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_PREV_CHANNEL")) + { + Action action = new Action(Action.ActionType.ACTION_PREV_CHANNEL, 0, 0); + GUIGraphicsContext.OnAction(action); + } + + if (data["command"] == ("ACTION_PREV_CHANNEL")) + { + Action action = new Action(Action.ActionType.ACTION_PREV_CHANNEL, 0, 0); + GUIGraphicsContext.OnAction(action); + } + + #endregion + + #region power control + if (data["command"] == ("ACTION_EXIT")) + { + Action action = new Action(Action.ActionType.ACTION_EXIT, 0, 0); + GUIGraphicsContext.OnAction(action); + } + + // TODO: these actions need confirmation so we need to do change it later.... + if (data["command"] == ("ACTION_SUSPEND")) + { + Action action = new Action(Action.ActionType.ACTION_SUSPEND, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_HIBERNATE")) + { + Action action = new Action(Action.ActionType.ACTION_HIBERNATE, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_REBOOT")) + { + Action action = new Action(Action.ActionType.ACTION_REBOOT, 0, 0); + GUIGraphicsContext.OnAction(action); + } + if (data["command"] == ("ACTION_POWER_OFF")) + { + Action action = new Action(Action.ActionType.ACTION_POWER_OFF, 0, 0); + GUIGraphicsContext.OnAction(action); + } + #endregion } - if (Message.Contains("ACTION_HIBERNATE")) - { - Action action = new Action(Action.ActionType.ACTION_HIBERNATE, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_REBOOT")) - { - Action action = new Action(Action.ActionType.ACTION_REBOOT, 0, 0); - GUIGraphicsContext.OnAction(action); - } - if (Message.Contains("ACTION_POWER_OFF")) - { - Action action = new Action(Action.ActionType.ACTION_POWER_OFF, 0, 0); - GUIGraphicsContext.OnAction(action); - } - #endregion } } @@ -571,6 +637,131 @@ } } + private void ReplyPicturesDbYears() + { + string msg = string.Empty; + // header + msg += "HTTP/1.0 200 Ok\r\n"; + msg += "Content-Type: application/xml; charset=utf-8; filename=info.xml" + "\r\n"; + msg += "Proxy-Connection: close" + "\r\n"; + msg += "\r\n"; + // content + msg += "<?xml version=\"1.0\"?>\r\n"; + msg += "<Database>\r\n"; + + List<string> aList = new List<string>(); + MediaPortal.Picture.Database.PictureDatabase.ListYears(ref aList); + + foreach (string year in aList) + { + if (year != string.Empty) + { + msg += "<Item>\r\n"; + msg += "<Year>" + HttpUtility.HtmlEncode(year) + "</Year>\r\n"; + msg += "</Item>\r\n"; + } + } + + msg += "</Database>\r\n\r\n"; + // send + sendMessage(socket, msg); + AndroidServer.logDebug("Reply db pictures years"); + } + private void ReplyPicturesDbMonths(string Year) + { + string msg = string.Empty; + // header + msg += "HTTP/1.0 200 Ok\r\n"; + msg += "Content-Type: application/xml; charset=utf-8; filename=info.xml" + "\r\n"; + msg += "Proxy-Connection: close" + "\r\n"; + msg += "\r\n"; + // content + msg += "<?xml version=\"1.0\"?>\r\n"; + msg += "<Database>\r\n"; + msg += "<Year>" + Year + "</Year>\r\n"; + + List<string> aList = new List<string>(); + MediaPortal.Picture.Database.PictureDatabase.ListMonths(Year, ref aList); + + foreach (string year in aList) + { + if (year != string.Empty) + { + msg += "<Item>\r\n"; + msg += "<Month>" + HttpUtility.HtmlEncode(year) + "</Month>\r\n"; + msg += "</Item>\r\n"; + } + } + + msg += "</Database>\r\n\r\n"; + // send + sendMessage(socket, msg); + AndroidServer.logDebug("Reply db pictures month"); + } + private void ReplyPicturesDbDays(string Month, string Year) + { + string msg = string.Empty; + // header + msg += "HTTP/1.0 200 Ok\r\n"; + msg += "Content-Type: application/xml; charset=utf-8; filename=info.xml" + "\r\n"; + msg += "Proxy-Connection: close" + "\r\n"; + msg += "\r\n"; + // content + msg += "<?xml version=\"1.0\"?>\r\n"; + msg += "<Database>\r\n"; + msg += "<Month>" + Month + "</Month>\r\n"; + msg += "<Year>" + Year + "</Year>\r\n"; + + List<string> aList = new List<string>(); + MediaPortal.Picture.Database.PictureDatabase.ListDays(Month, Year, ref aList); + + foreach (string year in aList) + { + if (year != string.Empty) + { + msg += "<Item>\r\n"; + msg += "<Day>" + HttpUtility.HtmlEncode(year) + "</Day>\r\n"; + msg += "</Item>\r\n"; + } + } + + msg += "</Database>\r\n\r\n"; + // send + sendMessage(socket, msg); + AndroidServer.logDebug("Reply db pictures days"); + } + private void ReplyPicturesDbByDate(string Date) + { + string msg = string.Empty; + // header + msg += "HTTP/1.0 200 Ok\r\n"; + msg += "Content-Type: application/xml; charset=utf-8; filename=info.xml" + "\r\n"; + msg += "Proxy-Connection: close" + "\r\n"; + msg += "\r\n"; + // content + msg += "<?xml version=\"1.0\"?>\r\n"; + msg += "<Database>\r\n"; + msg += "<Date>" + Date + "</Date>\r\n"; + + List<string> aList = new List<string>(); + MediaPortal.Picture.Database.PictureDatabase.ListPicsByDate(Date, ref aList); + + foreach (string year in aList) + { + if (year != string.Empty) + { + msg += "<Item>\r\n"; + msg += "<Picture>" + HttpUtility.HtmlEncode(year) + "</Picture>\r\n"; + msg += "</Item>\r\n"; + } + } + + msg += "</Database>\r\n\r\n"; + // send + sendMessage(socket, msg); + AndroidServer.logDebug("Reply db pictures date"); + } + private void ReplyMusicDir(string dir, string request) { if (Directory.Exists(dir)) Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote.suo =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |