Esempio n. 1
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // Fetch the info for a particular recording
            String result;

            if (arguments != null)
            {
                try
                {
                    int  index       = Int32.Parse(arguments[0]);
                    bool withRTSPurl = false;

                    if (arguments.Length >= 2)
                    {
                        withRTSPurl = bool.Parse(arguments[1]);
                    }

                    result = TVServerConnection.getRecordingInfo(index, withRTSPurl);
                    Console.WriteLine(getCommandToHandle() + ":" + index + " " + result);

                    writer.write(result);
                }
                catch
                {
                    Console.WriteLine(getCommandToHandle() + ": failed");
                    writer.write("");
                }
            }
            else
            {
                getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + ":RecordingID[|withRTSPurl=False]");
            }
        }
Esempio n. 2
0
        /*
         * No arguments needed
         */
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            bool result = TVServerConnection.IsRecording();

            Console.WriteLine("IsRecording result: " + result.ToString());
            writer.write(result.ToString());
        }
Esempio n. 3
0
 public WebTvResult(int result, string rtspURL, string timeshiftFile, TvControl.User u)
 {
     this.result        = result;
     this.rtspURL       = rtspURL;
     user               = new WebTvServerUser(u);
     this.timeshiftFile = timeshiftFile;
 }
Esempio n. 4
0
        /*
         * No arguments needed
         */
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            bool result = TVServerConnection.StopTimeshift(ref me);

            Console.WriteLine("StopTimeshift result: " + result.ToString());
            writer.write(result.ToString());
        }
Esempio n. 5
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            int           cardID  = -1;
            List <string> results = new List <string>();

            try
            {
                if (arguments != null)
                {
                    cardID = Int32.Parse(arguments[0]);
                }
                else
                {
                    cardID = me.CardId;
                }

                TVServerController server = TVServerConnection.GetServerInterface();
                int level   = server.GetSignalLevel(cardID);
                int quality = server.GetSignalQuality(cardID);

                writer.write(level.ToString() + "|" + quality.ToString());
            }
            catch
            {
                Console.WriteLine(getCommandToHandle() + ": failed");
                writer.write("");
            }
            //getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + "[:cardID]");
        }
Esempio n. 6
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // we want to list all recorded TV shows
            List <string> results = new List <string>();

            List <RecordedInfo> recorded = TVServerConnection.getRecordedTV();

            foreach (RecordedInfo r in recorded)
            {
                Int32  runningTime = Convert.ToInt32((r.endTime.Ticks - r.startTime.Ticks) / 10000000);
                string streamURL   = TVServerConnection.getRecordingURL(Convert.ToInt32(r.ID));
                string recitem     = writer.makeItem(
                    r.ID.ToString(),
                    r.title.Replace(";", ""),
                    r.description.Replace(";", ""),
                    r.genre,
                    r.played.ToString(),
                    r.startTime.ToString(),
                    r.endTime.ToString(),
                    r.filename,
                    r.channelName.Replace(";", ""),
                    runningTime.ToString(),
                    streamURL);
                results.Add(recitem);
                Console.WriteLine("Recorded: " + recitem);
            }

            writer.writeList(results);
        }
Esempio n. 7
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // we want to list all recordings
            String result;

            if (arguments != null)
            {
                try
                {
                    int index = Int32.Parse(arguments[0]);

                    result = TVServerConnection.GetScheduleInfo(index);
                    Console.WriteLine("GetScheduleInfo:" + index + " " + result);

                    writer.write(result);
                }
                catch
                {
                    Console.WriteLine("GetScheduleInfo: failed");
                    writer.write("");
                }
            }
            else
            {
                getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + ":ScheduleID");
            }
        }
Esempio n. 8
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // we want to list all recordings
            List <string> results = new List <string>();

            results = TVServerConnection.GetSchedules();
            writer.writeList(results);
        }
Esempio n. 9
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            string VersionNr = "1.0.0";

            // Fetch the MediaPortal TVServer version
            VersionNr = TVServerConnection.GetVersion();

            writer.write(VersionNr);
        }
Esempio n. 10
0
        /*
         * Expect arguments: ChannelID
         */
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            if (arguments == null || arguments.Length < 1)
            {
                getConnection().WriteLine("[ERROR]: Usage: " + getCommandToHandle() + ":ChannelId[|ResolveIPs=False][|StopTimeshift=True]");
                return;
            }

            try {
                int    chanId        = int.Parse(arguments[0]);
                bool   resolveToIP   = true;
                bool   stoptimeshift = true;
                string originalURL   = "";
                string result;
                string timeShiftFileName = "";

                if (arguments.Length >= 2)
                {
                    resolveToIP = Boolean.Parse(arguments[1]);
                    if (arguments.Length >= 3)
                    {
                        stoptimeshift = Boolean.Parse(arguments[2]);
                    }

                    if (stoptimeshift)
                    {
                        TVServerConnection.StopTimeshift(ref me);
                    }

                    result = TVServerConnection.playChannel(chanId, resolveToIP, ref originalURL, ref me, ref timeShiftFileName);
                    if (!result.StartsWith("[ERROR]"))
                    {
                        if (resolveToIP == true)
                        {
                            result += "|" + originalURL;
                        }
                        else
                        {
                            result += "|";
                        }
                        result += "|" + timeShiftFileName +
                                  "|" + me.CardId.ToString();
                    }

                    writer.write(result);
                }
                else
                {   //backward compatibility
                    TVServerConnection.StopTimeshift(ref me);
                    result = TVServerConnection.playChannel(chanId, resolveToIP, ref originalURL, ref me, ref timeShiftFileName);
                    writer.write(result);
                }
            } catch {
                getConnection().WriteLine("[ERROR]: Usage: " + getCommandToHandle() + ":ChannelId[|ResolveIPs][|StopTimeshift]");
            }
        }
Esempio n. 11
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            DateTime localtime = DateTime.Now;
            DateTime utctime   = DateTime.UtcNow;
            TimeSpan utcdiff   = (localtime - utctime);

            Console.WriteLine("Local time: " + localtime + " UTC time: " + utctime + " Offset: " + utcdiff.Hours);
            //Format: dd-mm-yyyy hh:mm:ss;offset hours;offset seconds
            writer.write(writer.makeItem(localtime.ToString("u"),
                                         utcdiff.Hours.ToString(),
                                         utcdiff.Minutes.ToString()));
        }
Esempio n. 12
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // we want to list all channels in group arg[0]
            // String group = arguments[0];
            int count = 0;

            count = TVServerConnection.getRecordingCount();

            Console.WriteLine("GetRecordingCount: " + count);

            writer.write(count.ToString());
        }
Esempio n. 13
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // this needs no arguments, and will just list all the tvgroups

            List <String> groups = TVServerConnection.GetRadioGroups();

            foreach (String group in groups)
            {
                Console.WriteLine("RADIOGROUP : " + group);
            }

            writer.writeList(groups);
        }
Esempio n. 14
0
        /*
         * 1 optional argument: id
         */
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            int schedId = -1;

            if ((arguments != null) && (arguments.Length == 1))
            {
                schedId = int.Parse(arguments[0]);
            }

            bool result = TVServerConnection.StopRecording(schedId);

            Console.WriteLine("StopRecording result : " + result.ToString());
            writer.write(result.ToString());
        }
Esempio n. 15
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            if (arguments == null)
            {
                getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + ":RecordingId");
                return;
            }

            int recId = int.Parse(arguments[0]);

            bool result = TVServerConnection.DeleteRecordedTV(recId);

            Console.WriteLine("DeleteRecordedTV result : " + result.ToString());
            writer.write(result.ToString());
        }
Esempio n. 16
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // we want to list all recordings
            List <string> results     = new List <string>();
            bool          resolveToIP = true;
            string        originalURL = "";

            if (arguments != null && arguments.Length == 1)
            {
                resolveToIP = Boolean.Parse(arguments[0]);
            }

            results = TVServerConnection.GetRecordings(resolveToIP, ref originalURL);
            writer.writeList(results);
        }
Esempio n. 17
0
        /*
         * No arguments needed, will list all commands available
         */
        public override void handleCommand(string myCommand, string[] arguments, ref TvControl.User me)
        {
            // get a list of all commands
            Dictionary <String, CommandHandler> allCommands = this.getConnection().getAllHandlers();

            List <string> results = new List <string>();

            foreach (CommandHandler command in allCommands.Values)
            {
                results.Add(command.getCommandToHandle());
            }
            writer.writeList(results);

            Console.WriteLine("Returned " + results.Count + " commands");
        }
Esempio n. 18
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // we want to list all channels in group arg[0]
            if ((arguments != null) && (arguments.Length == 2))
            {
                int    recindex = int.Parse(arguments[0]);
                String name     = arguments[1];

                bool result = TVServerConnection.UpdateRecording(recindex, name);
                Console.WriteLine("UpdateRecording result : " + result.ToString());
                writer.write(result.ToString());
            }
            else
            {
                getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + ":RecordingIndex|NewName");
            }
        }
Esempio n. 19
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            String group;
            int    count = 0;

            if (arguments != null)
            {   //we want to list all channels in group arg[0]
                group = arguments[0];
            }
            else
            {
                group = "";
            }

            count = TVServerConnection.getChannelCount(group);

            Console.WriteLine("GetChannelCount: " + count);

            writer.write(count.ToString());
        }
Esempio n. 20
0
 public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
 {
     // we want to list all channels in group arg[0]
     if ((arguments != null) && (arguments.Length == 1))
     {
         try
         {
             String name = arguments[0];
             me = TVServerConnection.RequestUser(name);
             writer.write("True");
         }
         catch
         {
             writer.write("[ERROR]");
         }
     }
     else
     {
         getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + ":Name");
     }
 }
Esempio n. 21
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            //TvEngine.PowerScheduler.WaitableTimer tveps;
            TvBusinessLayer layer     = new TvBusinessLayer();
            int             schedtype = (int)TvDatabase.ScheduleRecordingType.Once;
            Schedule        newSchedule;

            DateTime startTime = new DateTime(2009, 11, 23, 10, 00, 00);
            DateTime endTime   = new DateTime(2009, 11, 23, 11, 15, 00);

            try
            {
                newSchedule = layer.AddSchedule(32, "Marcel test", startTime, endTime, schedtype);
                newSchedule.Persist();
                Console.WriteLine("Schedule added: " + newSchedule.IdChannel.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 22
0
        /*
         * No arguments needed
         */
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            string rtspUrl = TVServerConnection.getTimeshiftUrl(ref me);
            bool   result  = true;

            if (String.IsNullOrEmpty(rtspUrl))
            {
                result  = false;
                rtspUrl = "";
            }

            // results = isShifting;url;chanInfo as in ListChannels
            // chanInfo must be the same as the listchannel..
            ChannelInfo c = new ChannelInfo();

            if (result)
            {
                c = TVServerConnection.getTimeshiftInfo(ref me);
            }

            writer.write(writer.makeItemSmart(result.ToString(), rtspUrl, c));
        }
Esempio n. 23
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            int           cardID  = -1;
            List <string> results = new List <string>();

            try
            {
                if (arguments != null)
                {
                    cardID = Int32.Parse(arguments[0]);
                }

                TVServerController server = TVServerConnection.GetServerInterface();
                results = server.GetCardSettings(cardID);

                writer.writeList(results);
            }
            catch
            {
                Console.WriteLine(getCommandToHandle() + ": failed");
                writer.write("");
            }
            //getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + "[:cardID]");
        }
Esempio n. 24
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            String        group;
            List <string> results = new List <string>();

            if (arguments != null)
            {   //we want to list all channels in group arg[0]
                group = arguments[0];
            }
            else
            {
                group = "";
            }

            List <ChannelInfo> channels = TVServerConnection.getChannels(group);

            foreach (ChannelInfo c in channels)
            {
                results.Add(writer.makeItemSmart(c));
                Console.WriteLine("CHANNEL : " + c.channelID + ";" + c.name + ";" + c.isScrambled.ToString());
            }

            writer.writeList(results);
        }
Esempio n. 25
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            String group;

            if (arguments != null)
            {   //we want to list all channels in group arg[0]
                group = arguments[0];
            }
            else
            {
                group = "";
            }

            Console.WriteLine("Radio channels from group:" + group);

            List <string> radiochannels = TVServerConnection.GetRadioChannels(group);

            foreach (string channel in radiochannels)
            {
                Console.WriteLine(channel);
            }

            writer.writeList(radiochannels);
        }
Esempio n. 26
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // we want to get the EPG info for that channel

            List <string> results = new List <string>();

            if (arguments == null || arguments.Length < 1)
            {
                writer.write("[ERROR]: Usage: " + getCommandToHandle() + ":chanNr");
            }
            else
            {
                DateTime starttime;
                DateTime endtime;
                string   channel = arguments[0];

                if (arguments.Length >= 3)
                {
                    starttime = DateTime.Parse(arguments[1]);
                    endtime   = DateTime.Parse(arguments[2]);
                }
                else
                {
                    starttime = DateTime.Now;
                    endtime   = starttime;
                }

                if (channel != "")
                {
                    List <TvDatabase.Program> epgs = TVServerConnection.getEpg(int.Parse(arguments[0]), starttime, endtime);

                    foreach (TvDatabase.Program e in epgs)
                    {
                        string epg = e.StartTime.ToString("u") + "|"
                                     + e.EndTime.ToString("u") + "|"
                                     + e.Title.Replace("|", "") + "|"
                                     + e.Description.Replace("|", "") + "|"
                                     + e.Genre.Replace("|", "");
                        if (arguments.Length >= 3)
                        {
                            epg += "|"
                                   + e.IdProgram.ToString() + "|"
                                   + e.IdChannel.ToString() + "|"
                                   + e.SeriesNum + "|"
                                   + e.EpisodeNumber + "|"
                                   + e.EpisodeName + "|"
                                   + e.EpisodePart + "|"
                                   + e.OriginalAirDate.ToString("u") + "|"
                                   + e.Classification + "|"
                                   + e.StarRating.ToString() + "|"
                                   + e.ParentalRating.ToString();
                        }
                        results.Add(epg);
                    }
                    writer.writeList(results);
                }
                else
                {
                    writer.write("[ERROR]: Usage: " + getCommandToHandle() + ":chanNr[|startDateTime|endDateTime]");
                }
            }
        }
Esempio n. 27
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // we want to list all channels in group arg[0]
            if ((arguments != null) && (arguments.Length >= 14))
            {
                Int32    preRecordInterval  = -1;
                Int32    postRecordInterval = -1;
                int      scheduleType       = (int)TvDatabase.ScheduleRecordingType.Once;
                int      priority           = -1; // Use MediaPortal default
                int      keepmethod         = -1; // Use MediaPortal default
                DateTime keepdate;

                int    channelid = int.Parse(arguments[0]);
                String title     = arguments[1];

                int      year      = int.Parse(arguments[2]);
                int      month     = int.Parse(arguments[3]);
                int      day       = int.Parse(arguments[4]);
                int      hour      = int.Parse(arguments[5]);
                int      min       = int.Parse(arguments[6]);
                int      sec       = int.Parse(arguments[7]);
                DateTime starttime = new DateTime(year, month, day, hour, min, sec);

                year  = int.Parse(arguments[8]);
                month = int.Parse(arguments[9]);
                day   = int.Parse(arguments[10]);
                hour  = int.Parse(arguments[11]);
                min   = int.Parse(arguments[12]);
                sec   = int.Parse(arguments[13]);
                DateTime endtime = new DateTime(year, month, day, hour, min, sec);

                if (arguments.Length >= 25)
                {
                    scheduleType = int.Parse(arguments[14]);
                    priority     = int.Parse(arguments[15]);
                    keepmethod   = int.Parse(arguments[16]);

                    year     = int.Parse(arguments[17]);
                    month    = int.Parse(arguments[18]);
                    day      = int.Parse(arguments[19]);
                    hour     = int.Parse(arguments[20]);
                    min      = int.Parse(arguments[21]);
                    sec      = int.Parse(arguments[22]);
                    keepdate = new DateTime(year, month, day, hour, min, sec);

                    preRecordInterval  = Int32.Parse(arguments[23]);
                    postRecordInterval = Int32.Parse(arguments[24]);
                }
                else
                {
                    keepdate = new DateTime(2000, 01, 01, 0, 0, 0); //MediaPortal default value 2000-01-01 00:00:00
                }

                bool result = TVServerConnection.AddSchedule(channelid, title, starttime, endtime, scheduleType, priority, keepmethod, keepdate, preRecordInterval, postRecordInterval);
                Console.WriteLine("AddSchedule result : " + result.ToString());
                writer.write(result.ToString());
            }
            else
            {
                getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() +
                                          ":ChannelId|Title|Y|M|D|H|m|s|Y|M|D|H|m|s|preMin|postMin|schedType");
            }
        }
Esempio n. 28
0
 public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
 {
     writer.write(me.Name);
 }
Esempio n. 29
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.User me)
        {
            // does not matter what arguments it has.

            getConnection().Disconnect();
        }
        public void HandleConnection()
        {
            NetworkStream cStream = this.client.GetStream();
            StreamReader reader = new StreamReader(cStream);
            writer = new DataWriter(cStream);

            // first we get what version of the protocol
            // we expect "TVServerXBMC:0-2"
            String versionInfo = reader.ReadLine();
            if (versionInfo == null) return;

            // version 2 is not backards compatible
            versionInfo = Uri.UnescapeDataString(versionInfo);
            if (versionInfo.ToLower().Contains("telnet"))
            {
                // human connection
                writer.setArgumentSeparator("|");
                writer.setListSeparator(Environment.NewLine);
                writer.setHumanEncoders();

                //reader side:
                cmd_sep = ":";
                arg_sep = "|";

                WriteLine("Protocol Accepted; TVServerXBMC version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                Console.WriteLine("Correct protocol, telnet connection accepted!");
                Log.Debug("TVServerXBMC: telnet connection accepted!");

                username = "******";
                clientType = ClientType.telnet;
            }
            else if (Regex.IsMatch(versionInfo,"^TVServerXBMC:0-[0-3]$",RegexOptions.IgnoreCase))
            {
                WriteLine("Protocol-Accept;0-3");
                Console.WriteLine("Correct protocol, connection accepted!");
                Log.Debug("TVServerXBMC: connection accepted!");
                username = "******";
                clientType = ClientType.python;
            }
            else if (Regex.IsMatch(versionInfo, "^PVRclientXBMC:0-[1]$", RegexOptions.IgnoreCase))
            {
                writer.setArgumentSeparator("|");
                //reader side:
                cmd_sep = ":";
                arg_sep = "|";

                WriteLine("Protocol-Accept:0|" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                Console.WriteLine("Correct protocol, connection accepted!");
                Log.Debug("TVServerXBMC: connection accepted from XBMC PVR addon");

                username = "******" + clientnr;
                clientType = ClientType.pvrclient;
            }
            else
            {
                WriteLine("Unexpected Protocol");
                client.Close();
                Console.WriteLine("Unexpected protocol:" + versionInfo);
                Log.Debug("TVServerXBMC: Unexpected protocol:" + versionInfo);

                clientType = ClientType.unknown;
                return;
            }

            me = TVServerConnection.RequestUser(username);

            ProcessConnection(reader);
            reader.Dispose();
            cStream.Dispose();
        }
Esempio n. 31
0
 public WebTvServerUser(TvControl.User user)
 {
     this.idCard    = user.CardId;
     this.idChannel = user.IdChannel;
     this.name      = user.Name;
 }