private void GetStatus(HttpListenerResponse response)
        {
            // RvS 2013-08-09 It does not make much sense to show connected/disconnected.. the device is always connected when using the web interface
            // RvS 2013-10-03 Show status if connected to the internet and not if just connected to a local network.
            // RvS 2013-10-22 Changed Internet.IsConnected() to Network.IsConnected. Internet.IsConnected could block for some seconds.

            var result = new JSON();
            result.Add("time", DateTime.Now)
            #if MF_FRAMEWORK_VERSION_V4_2 || MF_FRAMEWORK_VERSION_V4_3
                .Add("network", Network.IsConnected ? "Connected" : "Disconnected")
            #if G120
                .Add("biosVersion", "CO" + SystemInfo.Version.Major + "." + SystemInfo.Version.Minor + "." + SystemInfo.Version.Build + "." + SystemInfo.Version.Revision)
            #endif
            #if FEZ_SPIDER
                .Add("biosVersion", "SP" + SystemInfo.Version.Major + "." + SystemInfo.Version.Minor + "." + SystemInfo.Version.Build + "." + SystemInfo.Version.Revision)
            #endif

            #else
                .Add("network", "Connected") // TODO
                .Add("biosVersion","Windows")
            #endif
                .Add("playing", _audio.CurrentlyMediaName)
                .Add("appVersion", Settings.System.AppVersion)
                .End();

            response.ContentType = "text/html";
            response.ContentLength64 = result.Length;

            result.WriteToResponse(response);
        }
        private void GetSettings(HttpListenerResponse response)
        {
            var result = new JSON();
            result.Add("WC_IP", Settings.Web.IP);
            result.Add("WC_NETMASK", Settings.Web.Netmask);
            result.Add("WC_GATEWAY", Settings.Web.Gateway);
            result.Add("WC_ADMIN_PASSWORD", Settings.Web.AdminPassword);
            result.Add("WC_CONTROL_PASSWORD", Settings.Web.ValetPassword);
            result.Add("SY_TIMEZONE_OFFSET", Settings.System.TimeZoneOffset);
            result.Add("SY_TIMESERVER", Settings.System.TimeServer);
            result.Add("SY_TIMESERVER_ALT", Settings.System.TimeServerAlt);
            result.Add("SY_TIMESERVER_EN", Settings.System.TimeServicesSync);
            result.Add("SY_KNOB_CONTROL", Settings.System.KnobControlEnabled);
            result.Add("SC_AUDIO_VOLUME", Settings.System.AudioVolume);
            result.Add("SY_RTC_UPDATE_TIME", Settings.System.RTCUpdateTime);
            result.End();

            response.ContentType = "text/html";
            response.ContentLength64 = result.Length;

            result.WriteToResponse(response);
            #if MF_FRAMEWORK_VERSION_V4_2
            response.OutputStream.Flush();
            response.OutputStream.Close();
            #endif
        }
        private void GetSchedule(HttpListenerResponse response)
        {
            var result = new JSON();
            result.StartArray("schedule");

            for (int i = 0; i < _scheduler.MediaEntries.Count; i++)
            {
                var item = (AudioCore.MediaEntry) _scheduler.MediaEntries[i];

                result.StartObject();
                result.Add("name", item.Name);
                result.Add("index", i + 1);
                result.Add("until", item.EndTime != TimeSpan.MaxValue ? item.EndTime.ToString() : "");
                result.Add("every", item.Every != 0 ? item.Every : 0);
                result.Add("loops", item.RepeatCount); // B73 : changed item.RepeatCount-1
                result.Add("shuffle", item.Shuffle ? "Yes" : "-");

                if (item.Type == AudioCore.MediaEntry.PlayType.SpecificDate)
                {
                    result.Add("time", item.PlayDate.Add(item.StartTime));
                }
                else if (item.Type == AudioCore.MediaEntry.PlayType.DayOfWeek)
                {
                    string day = "";
                    switch (item.PlayDay)
                    {
                        case DayOfWeek.Monday:
                            day = "Monday";
                            break;
                        case DayOfWeek.Tuesday:
                            day = "Tuesday";
                            break;
                        case DayOfWeek.Wednesday:
                            day = "Wednesday";
                            break;
                        case DayOfWeek.Thursday:
                            day = "Thursday";
                            break;
                        case DayOfWeek.Friday:
                            day = "Friday";
                            break;
                        case DayOfWeek.Saturday:
                            day = "Saturday";
                            break;
                        case DayOfWeek.Sunday:
                            day = "Sunday";
                            break;
                    }
                    result.Add("time", day + "s " + item.StartTime);
                }
                else if (item.Type == AudioCore.MediaEntry.PlayType.Weekdays)
                {
                    result.Add("time", "Weekdays " + item.StartTime);
                }
                else if (item.Type == AudioCore.MediaEntry.PlayType.Weekends)
                {
                    result.Add("time", "Weekends " + item.StartTime);
                }
                else if (item.Type == AudioCore.MediaEntry.PlayType.Daily)
                {
                    result.Add("time", "Daily " + item.StartTime);
                }

                result.EndObject();
            }

            result.EndArray().End();

            response.ContentType = "text/html";
            response.ContentLength64 = result.Length;

            result.WriteToResponse(response);
            #if MF_FRAMEWORK_VERSION_V4_2
            response.OutputStream.Flush();
            response.OutputStream.Close();
            #endif
        }
        private void GetPlayListNames(HttpListenerResponse response)
        {
            var result = new JSON();
            result.StartArray("playlist");

            ArrayList fileList = FileCore.GetPlayListNames();

            foreach (PlayListFileInfo plfi in fileList)
            {
                result.StartObject();
                result.Add("name", plfi.ContainsSongs + ";" + plfi.FileName);
                result.EndObject();
            }

            result.EndArray().End();

            response.ContentType = "text/html";
            response.ContentLength64 = result.Length;

            result.WriteToResponse(response);
            #if MF_FRAMEWORK_VERSION_V4_2
            response.OutputStream.Flush();
            response.OutputStream.Close();
            #endif
        }
        private void GetPlayListContent(HttpListenerRequest request, HttpListenerResponse response)
        {
            try
            {
                string[] s = request.RawUrl.Split('?');
                string[] s1 = s[1].Split('&');
                string[] s2 = s1[0].Split('=');

                string names = s2[1].ReplaceHtmlHexCodes() + ".m3u"; // "";//request.QueryString.GetValues("name");

                ArrayList content = FileCore.GetPlayListContent(names);

                var result = new JSON();
                result.StartArray("playlistContent");

                foreach (PlayListContent nameValue in content)
                {
                    result.StartObject();
                    result.Add("avail", nameValue.Available);
                    result.Add("name", nameValue.FileName);
                    result.Add("pause", nameValue.Pause);
                    result.EndObject();
                }

                result.EndArray().End();

                response.ContentType = "text/html";
                response.ContentLength64 = result.Length;

                result.WriteToResponse(response);
            #if MF_FRAMEWORK_VERSION_V4_2
                response.OutputStream.Flush();
                response.OutputStream.Close();
            #endif
            }
            catch (Exception ex)
            {
                Log.WriteException(ex);
            }
        }
        private void GetKnob(HttpListenerResponse response)
        {
            var result = new JSON();
            result.StartArray("schedule");

            for (int i = 0; i < _knob.KnobEntries.Count; i++)
            {
                var item = (AudioCore.MediaEntry) _knob.KnobEntries[i];

                result.StartObject();
                result.Add("name", item.Name);
                result.Add("index", i + 1);

                if (item.Type == AudioCore.MediaEntry.PlayType.Push)
                    result.Add("type", "Push");
                else if (item.Type == AudioCore.MediaEntry.PlayType.Loop)
                    result.Add("type", "Loop");
                else if (item.Type == AudioCore.MediaEntry.PlayType.Once)
                    result.Add("type", "Once");
                result.Add("shuffle", item.Shuffle ? "Yes" : "-");
                result.EndObject();
            }

            result.EndArray().End();

            response.ContentType = "text/html";
            response.ContentLength64 = result.Length;

            result.WriteToResponse(response);
            #if MF_FRAMEWORK_VERSION_V4_2
            response.OutputStream.Flush();
            response.OutputStream.Close();
            #endif
        }