From: <Rol...@us...> - 2010-12-06 12:49:18
|
Revision: 4012 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4012&view=rev Author: Rollsroyc3 Date: 2010-12-06 12:49:11 +0000 (Mon, 06 Dec 2010) Log Message: ----------- Modified Paths: -------------- trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj 2010-12-06 12:47:28 UTC (rev 4011) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj 2010-12-06 12:49:11 UTC (rev 4012) @@ -3,7 +3,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.21022</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{E508BE47-8031-4202-9FD2-404732F86696}</ProjectGuid> <OutputType>Library</OutputType> @@ -31,14 +31,13 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> - <Reference Include="Core, Version=1.1.1.11854, Culture=neutral, processorArchitecture=x86"> + <Reference Include="Core, Version=1.1.2.20593, Culture=neutral, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Core.dll</HintPath> + <HintPath>..\..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\Core.dll</HintPath> </Reference> - <Reference Include="Databases, Version=1.1.1.11856, Culture=neutral, processorArchitecture=x86"> + <Reference Include="Databases, Version=1.1.2.20596, Culture=neutral, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Databases.dll</HintPath> - <Private>False</Private> + <HintPath>..\..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\Databases.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> @@ -46,9 +45,9 @@ <Reference Include="System.Web" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> - <Reference Include="Utils, Version=2.2.7.11849, Culture=neutral, processorArchitecture=x86"> + <Reference Include="Utils, Version=2.2.7.20588, Culture=neutral, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Utils.dll</HintPath> + <HintPath>..\..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\Utils.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2010-12-06 12:47:28 UTC (rev 4011) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2010-12-06 12:49:11 UTC (rev 4012) @@ -739,7 +739,7 @@ if (year != string.Empty) { msg += "<Item>\r\n"; - msg += "<Year>" + HttpUtility.HtmlEncode(year) + "</Year>\r\n"; + msg += "<Year>" + HttpUtility.HtmlEncode(year).Replace(" ","%20") + "</Year>\r\n"; msg += "</Item>\r\n"; } } @@ -770,7 +770,7 @@ if (year != string.Empty) { msg += "<Item>\r\n"; - msg += "<Month>" + HttpUtility.HtmlEncode(year) + "</Month>\r\n"; + msg += "<Month>" + HttpUtility.HtmlEncode(year).Replace(" ", "%20") + "</Month>\r\n"; msg += "</Item>\r\n"; } } @@ -802,7 +802,7 @@ if (year != string.Empty) { msg += "<Item>\r\n"; - msg += "<Day>" + HttpUtility.HtmlEncode(year) + "</Day>\r\n"; + msg += "<Day>" + HttpUtility.HtmlEncode(year).Replace(" ", "%20") + "</Day>\r\n"; msg += "</Item>\r\n"; } } @@ -838,7 +838,7 @@ { msg += "<Item>\r\n"; msg += "<ID>" + HttpUtility.HtmlEncode(item[0]) + "</ID>\r\n"; - msg += "<Name>" + HttpUtility.HtmlEncode(item[1]) + "</Name>\r\n"; + msg += "<Name>" + HttpUtility.HtmlEncode(item[1]).Replace(" ", "%20") + "</Name>\r\n"; msg += "</Item>\r\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Rol...@us...> - 2011-03-30 22:43:02
|
Revision: 4157 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4157&view=rev Author: Rollsroyc3 Date: 2011-03-30 22:42:55 +0000 (Wed, 30 Mar 2011) Log Message: ----------- moving pictures update Modified Paths: -------------- trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj.user trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidServer.cs trunk/plugins/AndroidRemote/Server/AndroidRemote/Content/ExecuteCommand.cs trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs trunk/plugins/AndroidRemote/Server/AndroidRemote/Setup.cs Added Paths: ----------- trunk/plugins/AndroidRemote/Server/AndroidRemote/Content/MovingPicturesPictureHandler.cs trunk/plugins/AndroidRemote/Server/AndroidRemote/Plugins/MovingPictures.cs Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj 2011-03-30 21:19:13 UTC (rev 4156) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj 2011-03-30 22:42:55 UTC (rev 4157) @@ -3,7 +3,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.21022</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{E508BE47-8031-4202-9FD2-404732F86696}</ProjectGuid> <OutputType>Library</OutputType> @@ -21,6 +21,8 @@ <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> + <PlatformTarget>AnyCPU</PlatformTarget> + <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -52,16 +54,15 @@ <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Utils.dll</HintPath> <Private>False</Private> </Reference> - <Reference Include="VideoLan.Interop, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> - <Private>False</Private> - </Reference> </ItemGroup> <ItemGroup> <Compile Include="AndroidServer.cs" /> + <Compile Include="Content\MovingPicturesPictureHandler.cs" /> <Compile Include="Content\VideoHandler.cs" /> <Compile Include="Content\MusicHandler.cs" /> <Compile Include="Content\NowPlayingHandler.cs" /> <Compile Include="Content\PictureHandler.cs" /> + <Compile Include="Plugins\MovingPictures.cs" /> <Compile Include="Plugins\Weather.cs" /> <Compile Include="SocketHandler.cs" /> <Compile Include="Content\SomeUtils.cs" /> Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj.user =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj.user 2011-03-30 21:19:13 UTC (rev 4156) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidRemote.csproj.user 2011-03-30 22:42:55 UTC (rev 4157) @@ -4,6 +4,7 @@ </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <StartAction>Program</StartAction> - <StartProgram>C:\Program Files\Team MediaPortal\MediaPortal\MediaPortal.exe</StartProgram> + <StartProgram>C:\Program Files (x86)\Team MediaPortal\MediaPortal\MediaPortal.exe</StartProgram> + <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging> </PropertyGroup> </Project> \ No newline at end of file Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidServer.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidServer.cs 2011-03-30 21:19:13 UTC (rev 4156) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/AndroidServer.cs 2011-03-30 22:42:55 UTC (rev 4157) @@ -35,7 +35,7 @@ using System.Net; using System.Net.Sockets; -using VideoLan; +//using VideoLan; namespace AndroidRemote { @@ -59,7 +59,7 @@ private Thread grabPictures; private Thread cacheDB; - public static VideoLan.VlcControl vlc; + //public static VideoLan.VlcControl vlc; #region IPlugin public void Start() @@ -116,17 +116,17 @@ args = read.Split(' '); } - vlc = new VideoLan.VlcControl(args); - vlc.Visible = false; + //vlc = new VideoLan.VlcControl(args); + //vlc.Visible = false; - GUIGraphicsContext.form.Controls.Add(vlc); + //GUIGraphicsContext.form.Controls.Add(vlc); } } public void Stop() { logInfo("Stop server"); - if (vlc != null) vlc.Stop(); + // if (vlc != null) vlc.Stop(); } #endregion Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/Content/ExecuteCommand.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/Content/ExecuteCommand.cs 2011-03-30 21:19:13 UTC (rev 4156) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/Content/ExecuteCommand.cs 2011-03-30 22:42:55 UTC (rev 4157) @@ -591,44 +591,44 @@ } #endregion - #region vlc experimental - if (data["command"] == ("StreamFile")) - { - AndroidServer.logDebug("StreamFile : " + data["filename"]); - // parameter = filename + //#region vlc experimental + //if (data["command"] == ("StreamFile")) + //{ + // AndroidServer.logDebug("StreamFile : " + data["filename"]); + // // parameter = filename - try - { - if (AndroidServer.vlc != null) - { - if (AndroidServer.vlc.IsPlaying) - { - AndroidServer.vlc.Stop(); - System.Threading.Thread.Sleep(100); - } + // try + // { + // if (AndroidServer.vlc != null) + // { + // if (AndroidServer.vlc.IsPlaying) + // { + // AndroidServer.vlc.Stop(); + // System.Threading.Thread.Sleep(100); + // } - string filename = data["filename"].Replace("/", "\\"); + // string filename = data["filename"].Replace("/", "\\"); - directoryList = GetMpShare("movies"); - string local = GetLocalDir(filename, directoryList); - local = HttpUtility.UrlDecode(local); + // directoryList = GetMpShare("movies"); + // string local = GetLocalDir(filename, directoryList); + // local = HttpUtility.UrlDecode(local); - AndroidServer.logDebug("StreamFile play: " + local); + // AndroidServer.logDebug("StreamFile play: " + local); - StringBuilder shortPath = new StringBuilder(255); - GetShortPathName(local, shortPath, shortPath.Capacity); + // StringBuilder shortPath = new StringBuilder(255); + // GetShortPathName(local, shortPath, shortPath.Capacity); - AndroidServer.vlc.Open(shortPath.ToString()); - AndroidServer.vlc.Play(); - } - } - catch - { - // why ever - } - } + // AndroidServer.vlc.Open(shortPath.ToString()); + // AndroidServer.vlc.Play(); + // } + // } + // catch + // { + // // why ever + // } + //} - #endregion + //#endregion #region play video file if (data["command"] == ("PlayFile")) Added: trunk/plugins/AndroidRemote/Server/AndroidRemote/Content/MovingPicturesPictureHandler.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/Content/MovingPicturesPictureHandler.cs (rev 0) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/Content/MovingPicturesPictureHandler.cs 2011-03-30 22:42:55 UTC (rev 4157) @@ -0,0 +1,186 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +/* + * Copyright (C) 2005-2011 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program 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 2, or (at your option) + * any later version. + * + * This Program 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 GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Text; +using System.Net.Sockets; +using System.IO; +using System.Drawing; +using System.Web; + +using MediaPortal.GUI.Library; +using MediaPortal.Configuration; +using MediaPortal.Database; +using SQLite.NET; + +namespace AndroidRemote.Content +{ + public class MovingPicturesPictureHandler + { + + #region Moving Pictures DB Picture Code + + //public static void ReplyPicturesDbFile(Socket sock, string ID) + //{ + // SocketHandler handler = new SocketHandler(); + + // SQLiteClient sqlClient; + // sqlClient = new SQLiteClient(Config.GetFile(Config.Dir.Database, "PictureDatabase.db3")); + // sqlClient.BusyRetries = 10; + // sqlClient.BusyRetryDelay = 100; + // DatabaseUtility.SetPragmas(sqlClient); + + // string filePath = GetPicturePathById(sqlClient, ID); + + // if (File.Exists(filePath)) + // { + // Bitmap bit = (Bitmap)Bitmap.FromFile(filePath); + // byte[] b; + + // if ((bit.Width > 600) || (bit.Height > 600)) + // { + // Bitmap thumb = (Bitmap)bit.Clone(); + // thumb = MediaPortal.Util.BitmapResize.Resize(ref thumb, 600, 600, false, true); + + // b = SomeUtils.ImageToByteArray((Image)thumb); + // } + // else + // { + // b = SomeUtils.ImageToByteArray((Image)bit); + // } + + // if (b != null) + // { + // string msg = string.Empty; + // // header + // msg += "HTTP/1.0 200 Ok\r\n"; + // msg += "Content-Type: image/jpeg" + "\r\n"; + // msg += "Content-Length: " + b.Length + "\r\n"; + // msg += "Proxy-Connection: close" + "\r\n"; + // msg += "\r\n"; + + // handler.SendMessage(sock, msg); + // // content + // handler.SendBytes(sock, b); + + // AndroidServer.logDebug("Reply picture file"); + // } + // else + // { + // handler.SendServerError(sock, filePath, "ReplyPictureFile"); + // } + // } + // else + // { + // handler.SendErrorFile(sock, filePath); + // } + //} + + public static void ReplyMovingPicturesDbThumbFile(Socket sock, string ID) + { + SocketHandler handler = new SocketHandler(); + + SQLiteClient sqlClient; + sqlClient = new SQLiteClient(Config.GetFile(Config.Dir.Database, "movingpictures.db3")); + sqlClient.BusyRetries = 10; + sqlClient.BusyRetryDelay = 100; + DatabaseUtility.SetPragmas(sqlClient); + + string filePath = GetPicturePathById(sqlClient, ID); + + if (File.Exists(filePath)) + { + Bitmap bit = (Bitmap)Bitmap.FromFile(filePath); + byte[] b; + + Bitmap thumb = (Bitmap)bit.Clone(); + thumb = MediaPortal.Util.BitmapResize.Resize( ref thumb, 150, 250, false, false); + + b = SomeUtils.ImageToByteArray((Image)thumb); + + if (b != null) + { + string msg = string.Empty; + // header + msg += "HTTP/1.0 200 Ok\r\n"; + msg += "Content-Type: image/jpeg" + "\r\n"; + msg += "Content-Length: " + b.Length + "\r\n"; + msg += "Proxy-Connection: close" + "\r\n"; + msg += "\r\n"; + + handler.SendMessage(sock, msg); + // content + handler.SendBytes(sock, b); + + AndroidServer.logDebug("Reply moving picture file"); + } + else + { + handler.SendServerError(sock, filePath, "ReplyMovingPictureFile"); + } + } + else + { + handler.SendErrorFile(sock, filePath); + } + } + + private static string GetPicturePathById(SQLiteClient sqlClient, string ID) + { + { + if (sqlClient == null) + { + return string.Empty; + } + string strSQL = "select coverthumbfullpath from movie_info where id='" + ID + "'"; + SQLiteResultSet result; + try + { + result = sqlClient.Execute(strSQL); + if (result != null) + { + + if (result.Rows.Count == 1) + { + return DatabaseUtility.Get(result, 0, 0); + } + } + } + catch (Exception ex) + { + Log.Error("MediaPortal.MovingPictures.Database exception getting coverthumbfullpath by ID err:{0} stack:{1}", ex.Message, + ex.StackTrace); + //Open(); + } + return string.Empty; + } + } + + #endregion + + + + } +} Added: trunk/plugins/AndroidRemote/Server/AndroidRemote/Plugins/MovingPictures.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/Plugins/MovingPictures.cs (rev 0) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/Plugins/MovingPictures.cs 2011-03-30 22:42:55 UTC (rev 4157) @@ -0,0 +1,196 @@ +#region Copyright (C) 2005-2011 Team MediaPortal + +/* + * Copyright (C) 2005-2011 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program 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 2, or (at your option) + * any later version. + * + * This Program 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 GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.Collections; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Net; +using System.Threading; +using System.Xml; +using MediaPortal.Configuration; +using MediaPortal.GUI.Library; +using MediaPortal.Util; +using SQLite.NET; +using AndroidRemote.Content; +using MediaPortal.Database; + +namespace AndroidRemote.Plugins +{ + public class MovingPictures + { + + #region Classes + + private class Movie + { + public string ID; + public string Title; + public string Description; + public string Rating; + public string Runtime; + public string Image; + } + + #endregion + + #region variables + + private static ArrayList _listMovies = new ArrayList(); + private string _ID = string.Empty; + private string _Title = string.Empty; + private string _Description = string.Empty; + private string _Rating = string.Empty; + private string _Runtime = string.Empty; + private string _Image = string.Empty; + + #endregion + + #region Constructor + + public MovingPictures() + { + + Init(); + } + + #endregion + + #region Methods + + private void Init() + { + _listMovies.Clear(); + } + + #endregion + + + + public string GetMovies(string query) + { + string msg = string.Empty; + try + { + SocketHandler handler = new SocketHandler(); + SQLiteClient sqlClient; + sqlClient = new SQLiteClient(Config.GetFile(Config.Dir.Database, "movingpictures.db3")); + sqlClient.BusyRetries = 10; + sqlClient.BusyRetryDelay = 100; + DatabaseUtility.SetPragmas(sqlClient); + + _listMovies = new ArrayList(); + + LoadMovies(sqlClient, ""); + + + // header + msg += "HTTP/1.0 200 Ok\r\n"; + msg += "Content-Type: application/xml; charset=utf-8; filename=movingpictures.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 += "<Results>" + _listMovies.Count + "</Results>\r\n"; + msg += "<Start>0</Start>\r\n"; + + foreach (Movie m in _listMovies) + { + msg += "<Movie>\r\n"; + msg += "<ID>" + SomeUtils.EncodeString(m.ID.ToString()) + "</ID>\r\n"; + msg += "<Title>" + SomeUtils.EncodeString(m.Title) + "</Title>\r\n"; + msg += "<Description>" + SomeUtils.EncodeString(m.Description) + "</Description>\r\n"; + msg += "<Rating>" + SomeUtils.EncodeString(m.Rating.ToString()) + "</Rating>\r\n"; + msg += "<Runtime>" + SomeUtils.EncodeString(m.Runtime.ToString()) + "</Runtime>\r\n"; + msg += "<Image>" + SomeUtils.EncodeString(m.Image) + "</Image>\r\n"; + msg += "</Movie>\r\n"; + } + + msg += "</Database>\r\n\r\n"; + + } + catch (Exception ex) + { + Log.Error("MediaPortal.AndroidRemote.MovingPictures exception getting movies, err:{0} ", ex.Message); + //Open(); + } + return msg; + + } + + + + private static ArrayList LoadMovies(SQLiteClient sqlClient, string Query) + { + if (sqlClient == null) + { + return null; + } + string strSQL = "SELECT id,title,tagline,score,runtime,coverthumbfullpath FROM movie_info " + Query.ToString(); + SQLiteResultSet result; + try + { + result = sqlClient.Execute(strSQL); + if (result != null) + { + + if (result.Rows.Count > 0) + { + + foreach (SQLiteResultSet.Row row in result.Rows) + { + Movie movieItem = new Movie(); + movieItem.ID = row.fields[0]; + movieItem.Title = row.fields[1]; + movieItem.Description = row.fields[2]; + movieItem.Rating = row.fields[3]; + movieItem.Runtime = row.fields[4]; + movieItem.Image = row.fields[5]; + + _listMovies.Add(movieItem); + } + } + } + } + catch (Exception ex) + { + Log.Error("MediaPortal.AndroidRemote.MovingPictures exception loading movies, err:{0} ", ex.Message); + //Open(); + } + return _listMovies; + } + + } + + + + + + + +} \ No newline at end of file Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2011-03-30 21:19:13 UTC (rev 4156) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/Request.cs 2011-03-30 22:42:55 UTC (rev 4157) @@ -44,335 +44,363 @@ namespace AndroidRemote { - public class Request - { - private Socket socket; - private byte[] read; - - public Request(Socket Socket) + public class Request { - socket = Socket; - } + private Socket socket; + private byte[] read; - public void DoWork() - { - try - { - SocketHandler handler = new SocketHandler(); + public Request(Socket Socket) + { + socket = Socket; + } - string clientmessage = " "; - string allMessage = string.Empty; - - while (socket.Connected) + public void DoWork() { - read = new byte[1024]; - int bytes = handler.Readmessage(read, ref socket, ref clientmessage); + try + { + SocketHandler handler = new SocketHandler(); - int x = clientmessage.IndexOf(" "); - string msgTyp = ""; - if (x > 0) - msgTyp = clientmessage.Substring(0, x); + string clientmessage = " "; + string allMessage = string.Empty; - if (clientmessage.Contains("Continue")) - { - AndroidServer.logDebug("receive HTTP Continue"); + while (socket.Connected) + { + read = new byte[1024]; + int bytes = handler.Readmessage(read, ref socket, ref clientmessage); - allMessage = allMessage + clientmessage.Substring(0, bytes); - handler.SendContinue(socket); - } - else - { - allMessage = allMessage + clientmessage.Substring(0, bytes); + int x = clientmessage.IndexOf(" "); + string msgTyp = ""; + if (x > 0) + msgTyp = clientmessage.Substring(0, x); - if (msgTyp == "POST") - { - AndroidServer.logDebug("receive HTTP POST"); - ExecuteCommand cmd = new ExecuteCommand(socket, allMessage); - } - else if (clientmessage.Length > 0) - { - // GET - int index1 = clientmessage.IndexOf(' '); - int index2 = clientmessage.IndexOf(' ', index1 + 1); - string req = clientmessage.Substring(index1 + 1, index2 - index1).Trim(); + if (clientmessage.Contains("Continue")) + { + AndroidServer.logDebug("receive HTTP Continue"); - req = HttpUtility.UrlDecode(req); + allMessage = allMessage + clientmessage.Substring(0, bytes); + handler.SendContinue(socket); + } + else + { + allMessage = allMessage + clientmessage.Substring(0, bytes); - AndroidServer.logDebug("receive HTTP GET : " + req); + if (msgTyp == "POST") + { + AndroidServer.logDebug("receive HTTP POST"); + ExecuteCommand cmd = new ExecuteCommand(socket, allMessage); + } + else if (clientmessage.Length > 0) + { + // GET + int index1 = clientmessage.IndexOf(' '); + int index2 = clientmessage.IndexOf(' ', index1 + 1); + string req = clientmessage.Substring(index1 + 1, index2 - index1).Trim(); - if (req.StartsWith("/info")) - { - handler.ReplyInfo(socket); - } + req = HttpUtility.UrlDecode(req); - #region pictures - else if (req.StartsWith("/pictures")) - { - // handle pictures - req = req.Substring(9); - if (req.StartsWith("/")) req = req.Substring(1); + AndroidServer.logDebug("receive HTTP GET : " + req); - if (req == "") - { - // root - PictureHandler.ReplyPictureDir(socket, ""); - } - else - { - req = req.Replace("/", "\\"); + if (req.StartsWith("/info")) + { + handler.ReplyInfo(socket); + } - if (req.ToLower().EndsWith(".jpg")) - { - PictureHandler.ReplyPictureFile(socket, req); - } - else if (req.ToLower().EndsWith(".thb")) - { - PictureHandler.ReplyPictureThumbFile(socket, req); - } - else - { - PictureHandler.ReplyPictureDir(socket, req); - } - } - } - #endregion + #region pictures + else if (req.StartsWith("/pictures")) + { + // handle pictures + req = req.Substring(9); + if (req.StartsWith("/")) req = req.Substring(1); - #region pictured datatbase + if (req == "") + { + // root + PictureHandler.ReplyPictureDir(socket, ""); + } + else + { + req = req.Replace("/", "\\"); - else if (req.StartsWith("/db_pictures")) - { - // handle pictures - req = req.Replace("/db_pictures", ""); - if (req.StartsWith("/")) req = req.Substring(1); + if (req.ToLower().EndsWith(".jpg")) + { + PictureHandler.ReplyPictureFile(socket, req); + } + else if (req.ToLower().EndsWith(".thb")) + { + PictureHandler.ReplyPictureThumbFile(socket, req); + } + else + { + PictureHandler.ReplyPictureDir(socket, req); + } + } + } + #endregion - if (req == "years.xml") - { - PictureHandler.ReplyPicturesDbYears(socket); - } - if (req.StartsWith("months.xml")) - { - int pos = req.IndexOf("?"); - if (pos > 0) - { - string year = req.Substring(pos + 1); - PictureHandler.ReplyPicturesDbMonths(socket, 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) - { - PictureHandler.ReplyPicturesDbDays(socket, my[0], my[1]); - } - } - } - if (req.StartsWith("date.xml")) - { - int pos = req.IndexOf("?"); - if (pos > 0) - { - string date = req.Substring(pos + 1); - PictureHandler.ReplyPicturesDbByDate(socket, date); - } - } - if (req.StartsWith("getpicture")) - { - int pos = req.IndexOf("?"); - if (pos > 0) - { - string id = req.Substring(pos + 1); - id = id.Replace("id=", ""); - PictureHandler.ReplyPicturesDbFile(socket, id); - } - } - if (req.StartsWith("getthumb")) - { - int pos = req.IndexOf("?"); - if (pos > 0) - { - string id = req.Substring(pos + 1); - id = id.Replace("id=", ""); - PictureHandler.ReplyPicturesDbThumbFile(socket, id); - } - } - } + #region pictured datatbase - #endregion + else if (req.StartsWith("/db_pictures")) + { + // handle pictures + req = req.Replace("/db_pictures", ""); + if (req.StartsWith("/")) req = req.Substring(1); - #region music - else if (req.StartsWith("/music")) - { - // handle pictures - req = req.Substring(6); - if (req.StartsWith("/")) req = req.Substring(1); + if (req == "years.xml") + { + PictureHandler.ReplyPicturesDbYears(socket); + } + if (req.StartsWith("months.xml")) + { + int pos = req.IndexOf("?"); + if (pos > 0) + { + string year = req.Substring(pos + 1); + PictureHandler.ReplyPicturesDbMonths(socket, 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) + { + PictureHandler.ReplyPicturesDbDays(socket, my[0], my[1]); + } + } + } + if (req.StartsWith("date.xml")) + { + int pos = req.IndexOf("?"); + if (pos > 0) + { + string date = req.Substring(pos + 1); + PictureHandler.ReplyPicturesDbByDate(socket, date); + } + } + if (req.StartsWith("getpicture")) + { + int pos = req.IndexOf("?"); + if (pos > 0) + { + string id = req.Substring(pos + 1); + id = id.Replace("id=", ""); + PictureHandler.ReplyPicturesDbFile(socket, id); + } + } + if (req.StartsWith("getthumb")) + { + int pos = req.IndexOf("?"); + if (pos > 0) + { + string id = req.Substring(pos + 1); + id = id.Replace("id=", ""); + PictureHandler.ReplyPicturesDbThumbFile(socket, id); + } + } + } - if (req == "") - { - // root - MusicHandler.ReplyMusicDir(socket, ""); - } - else - { - req = req.Replace("/", "\\"); + #endregion - if (req.ToLower().EndsWith(".mp3")) - { + #region music + else if (req.StartsWith("/music")) + { + // handle pictures + req = req.Substring(6); + if (req.StartsWith("/")) req = req.Substring(1); - MusicHandler.ReplyMusicFile(socket, req, msgTyp); - } - else - { - MusicHandler.ReplyMusicDir(socket, req); - } - } - } - #endregion + if (req == "") + { + // root + MusicHandler.ReplyMusicDir(socket, ""); + } + else + { + req = req.Replace("/", "\\"); - #region music datatbase + if (req.ToLower().EndsWith(".mp3")) + { - else if (req.StartsWith("/db_music")) - { - // handle music db - req = req.Replace("/db_music", ""); - if (req.StartsWith("/")) req = req.Substring(1); + MusicHandler.ReplyMusicFile(socket, req, msgTyp); + } + else + { + MusicHandler.ReplyMusicDir(socket, req); + } + } + } + #endregion - if (req.StartsWith("artist.xml")) - { - MusicHandler.ReplyMusicDbArtist(socket, req); - } - if (req.StartsWith("album.xml")) - { - MusicHandler.ReplyMusicDbAlbum(socket, req); - } - if (req.StartsWith("song.xml")) - { - MusicHandler.ReplyMusicDbSongs(socket, req); - } + #region music datatbase - if (req.StartsWith("getfile")) - { - int pos = req.IndexOf("?"); - if (pos > 0) - { - string id = req.Substring(pos + 1); - id = id.Replace("id=", ""); - MusicHandler.ReplyMusicDbFile(socket, id, msgTyp); - } - } - } + else if (req.StartsWith("/db_music")) + { + // handle music db + req = req.Replace("/db_music", ""); + if (req.StartsWith("/")) req = req.Substring(1); - #endregion + if (req.StartsWith("artist.xml")) + { + MusicHandler.ReplyMusicDbArtist(socket, req); + } + if (req.StartsWith("album.xml")) + { + MusicHandler.ReplyMusicDbAlbum(socket, req); + } + if (req.StartsWith("song.xml")) + { + MusicHandler.ReplyMusicDbSongs(socket, req); + } - #region movies - else if (req.StartsWith("/movies")) - { - // handle movies - req = req.Substring(7); - if (req.StartsWith("/")) req = req.Substring(1); + if (req.StartsWith("getfile")) + { + int pos = req.IndexOf("?"); + if (pos > 0) + { + string id = req.Substring(pos + 1); + id = id.Replace("id=", ""); + MusicHandler.ReplyMusicDbFile(socket, id, msgTyp); + } + } + } - if (req == "") - { - // root - VideoHandler.ReplyVideoDir(socket, ""); - } - else - { - req = req.Replace("/", "\\"); - VideoHandler.ReplyVideoDir(socket, req); - } - } - #endregion + #endregion - #region nowplaying - else if (req.StartsWith("/nowplaying/now.xml")) - { - NowPlayingHandler.ReplyNowPlaying(socket); - } - else if (req.StartsWith("/nowplaying/list.xml")) - { - NowPlayingHandler.ReplyNowPlayingPlaylist(socket); - } - else if (req.StartsWith("/nowplaying/cover")) - { - NowPlayingHandler.ReplyNowCover(socket); - } - #endregion + #region movies + else if (req.StartsWith("/movies")) + { + // handle movies + req = req.Substring(7); + if (req.StartsWith("/")) req = req.Substring(1); - else if (req.StartsWith("/weather/now.xml")) - { - Plugins.Weather weather = new AndroidRemote.Plugins.Weather(); - weather.RefreshMe(false); - string s = weather.GetXmlData(); + if (req == "") + { + // root + VideoHandler.ReplyVideoDir(socket, ""); + } + else + { + req = req.Replace("/", "\\"); + VideoHandler.ReplyVideoDir(socket, req); + } + } + #endregion - handler.SendMessage(socket, s); - } + #region nowplaying + else if (req.StartsWith("/nowplaying/now.xml")) + { + NowPlayingHandler.ReplyNowPlaying(socket); + } + else if (req.StartsWith("/nowplaying/list.xml")) + { + NowPlayingHandler.ReplyNowPlayingPlaylist(socket); + } + else if (req.StartsWith("/nowplaying/cover")) + { + NowPlayingHandler.ReplyNowCover(socket); + } + #endregion - #region favicon - else if (req.StartsWith("/favicon.ico")) - { - handler.SendFavIcon(socket); - } - #endregion + else if (req.StartsWith("/weather/now.xml")) + { + Plugins.Weather weather = new AndroidRemote.Plugins.Weather(); + weather.RefreshMe(false); + string s = weather.GetXmlData(); - else if (req.StartsWith("/random/pictures")) - { - PictureHandler.ReplyRandomPicture(socket); - } + handler.SendMessage(socket, s); + } + else if (req.StartsWith("/movingpictures")) + { + Plugins.MovingPictures MP = new AndroidRemote.Plugins.MovingPictures(); - #region some test how to accces the gui - else if (req.StartsWith("/onlinevideos")) - { - GUIWindowManager.ActivateWindow(4755); - } - else if (req.StartsWith("/items")) - { - GUIWindow window = GUIWindowManager.GetWindow(4755); - GUIFacadeControl cont = (GUIFacadeControl)window.GetControl(50); + req = req.Replace("/movingpictures", ""); + Log.Error(req); + if (req.StartsWith("/")) req = req.Substring(1); + Log.Error(req); + if (req.StartsWith("allmovies.xml")) + { + string s = MP.GetMovies(""); + handler.SendMessage(socket, s); + } + else + { + //req = req.Replace("/", "\\"); + if (req.StartsWith("getthumb")) + { + int pos = req.IndexOf("?"); + if (pos > 0) + { + string id = req.Substring(pos + 1); + id = id.Replace("id=", ""); + Log.Error(id.ToString()); + MovingPicturesPictureHandler.ReplyMovingPicturesDbThumbFile(socket, id); + } + } + } + } + #region favicon + else if (req.StartsWith("/favicon.ico")) + { + handler.SendFavIcon(socket); + } + #endregion - cont.SelectedListItemIndex = 2; - GUIListItem i = cont.SelectedListItem; + else if (req.StartsWith("/random/pictures")) + { + PictureHandler.ReplyRandomPicture(socket); + } - // header - string 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\" encoding=\"UTF-8\"?>\r\n"; - msg += "<OnlineVideos>\r\n"; + #region some test how to accces the gui + else if (req.StartsWith("/onlinevideos")) + { + GUIWindowManager.ActivateWindow(4755); + } + else if (req.StartsWith("/items")) + { + GUIWindow window = GUIWindowManager.GetWindow(4755); + GUIFacadeControl cont = (GUIFacadeControl)window.GetControl(50); + cont.SelectedListItemIndex = 2; + GUIListItem i = cont.SelectedListItem; - msg += "<OnlineVideos>\r\n"; - } - #endregion + // header + string 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\" encoding=\"UTF-8\"?>\r\n"; + msg += "<OnlineVideos>\r\n"; - else - { - handler.SendErrorURL(socket, req); - } + msg += "<OnlineVideos>\r\n"; + } + #endregion + + else + { + handler.SendErrorURL(socket, req); + } + + } + + if (socket != null) + { + if (socket.Connected) + { + socket.Close(); + } + } + } + } } - - if (socket != null) + catch (Exception ex) { - if (socket.Connected) - { - socket.Close(); - } + AndroidServer.logInfo("Error on request : " + ex.Message); + AndroidServer.logInfo("Stacktrace : " + ex.StackTrace); } - } } - } - catch (Exception ex) - { - AndroidServer.logInfo("Error on request : " + ex.Message); - AndroidServer.logInfo("Stacktrace : " + ex.StackTrace); - } } - } } Modified: trunk/plugins/AndroidRemote/Server/AndroidRemote/Setup.cs =================================================================== --- trunk/plugins/AndroidRemote/Server/AndroidRemote/Setup.cs 2011-03-30 21:19:13 UTC (rev 4156) +++ trunk/plugins/AndroidRemote/Server/AndroidRemote/Setup.cs 2011-03-30 22:42:55 UTC (rev 4157) @@ -34,7 +34,7 @@ using MediaPortal.Configuration; -using VideoLan; +//using VideoLan; namespace AndroidRemote { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |