Example #1
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser 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.EpisodeNum + "|"
                                + 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]");
                }
            }
        }
        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]");
            }
        }
Example #3
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser 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");
            }
        }
        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);
        }
Example #5
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser 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();
            ReceptionDetails details = server.GetReceptionDetails(cardID);

            server.HeartBeat(me);
            writer.write(details.signalLevel.ToString() + "|" + details.signalQuality.ToString());
              }
              catch
              {
            Console.WriteLine(getCommandToHandle() + ": failed");
            writer.write("");
              }
              //getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + "[:cardID]");
        }
        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);
        }
Example #7
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
        {
            string VersionNr = "1.0.0";

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

            writer.write(VersionNr);
        }
        /*
         * 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]");
            }
        }
Example #9
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()));
        }
Example #10
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser 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());
        }
Example #11
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
        {
            // this needs no arguments, and will just list all the tvgroups

            List<String> groups = TVServerConnection.GetTVGroups();
            foreach (String group in groups)
            {
                Console.WriteLine("GROUP : " + group);
            }

            writer.writeList(groups);
        }
Example #12
0
        /*
         * 1 optional argument: id
         */
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser 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());
        }
Example #13
0
        /*
         * No arguments needed, will list all commands available
         */
        public override void handleCommand(string myCommand, string[] arguments, ref TvControl.IUser 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");
        }
Example #14
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
        {
            if (arguments == null)
            {
                getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + ":ScheduleId");
                return;
            }

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

            bool result = TVServerConnection.DeleteSchedule(schedId);
            Console.WriteLine("DeleteSchedule result : " + result.ToString());
            writer.write(result.ToString());
        }
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
        {
            if ((arguments != null) && (arguments.Length == 1))
              {
            int recindex = int.Parse(arguments[0]);

            int result = TVServerConnection.GetRecordingStopTime(recindex);
            Console.WriteLine("GetRecordingStopTime result : " + result.ToString());
            writer.write(result.ToString());
              }
              else
              {
            getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + ":RecordingIndex");
              }
        }
        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);
        }
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
        {
            // we want to list all channels in group arg[0]
              if ((arguments != null) && (arguments.Length == 2))
              {
              int recindex = int.Parse(arguments[0]);
              int count = int.Parse(arguments[1]);

              bool result = TVServerConnection.SetRecordingTimesWatched(recindex, count);
              Console.WriteLine("SetRecordingTimesWatched result : " + result.ToString());
              writer.write(result.ToString());
              }
              else
              {
              getConnection().WriteLine("[ERROR]: Expected format: " + getCommandToHandle() + ":RecordingIndex|timesWatched");
              }
        }
Example #18
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser 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");
              }
        }
Example #19
0
        public void Start(TvControl.IController controller)
        {
            // set up our remote control interface
            try {
                connected = TVServerConnection.Init(controller);
                if (connected)
                {
                    Log.Info("TVServerXBMC: Start listening on port " + serverPort);

                    // start a thread for the listener

                    Listener l = new Listener(serverPort);
                    if (l.StartListening())
                    {
                        // start a thread to listen for clients
                        //(new Thread(new ThreadStart(ListenForClients)).Start ();
                        try
                        {
                            listenThread = new Thread(new ThreadStart(l.ListenForClients));
                            listenThread.Start();
                        }
                        catch
                        {
                            l.Stop();
                        }
                    }
                    else
                    {
                        connected = false;
                    }
                }
                else
                {
                    Log.Error("TVServerXBMC: TVServerConnection init failed.");
                }
            }
            catch
            {
                Log.Error("TVServerXBMC: TVServerConnection.Init failed!");
                Console.WriteLine("TVServerConnection.Init failed!");
            }
        }
        /*
         * 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));
        }
        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());
        }
Example #22
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser 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);
        }
Example #23
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser 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);
            }
        }
Example #24
0
 public override void handleCommand(string command, string[] arguments, ref TvControl.IUser 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");
       }
 }
Example #25
0
        /*
         * No arguments needed
         */
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
        {
            TimeShiftURLs timeShiftURLs = TVServerConnection.getTimeshiftURLs(ref me);
            bool result = true;

            if (timeShiftURLs == null || String.IsNullOrEmpty(timeShiftURLs.RTSPUrl) || String.IsNullOrEmpty(timeShiftURLs.TimeShiftFileName))
            {
                timeShiftURLs = new TimeShiftURLs { RTSPUrl = "", TimeShiftFileName = "" };
                result = false;
            }

            // 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(), timeShiftURLs.RTSPUrl, timeShiftURLs.TimeShiftFileName, c));
        }
Example #26
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
        {
            List<string> groups;

            if ((arguments != null) && (arguments[0].Length>0))
            {   //we want to list all channels in group arg[0]
                groups = new List<string>(arguments);
            }
            else
            {
                groups = new List<string>();
            }

            List<string> tvchannels = TVServerConnection.GetTVChannels(groups);

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

            writer.writeList(tvchannels);
        }
Example #27
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
        {
            try
              {
              bool seriesSupport = false;
              if (arguments != null && arguments.Length >= 1)
              {
                  if (arguments[0].Length > 0)
                  {
                      seriesSupport = Boolean.Parse(arguments[0]);
                  }
              }

              // we want to list all scheduled recordings
              List<string> results = new List<string>();

              results = TVServerConnection.GetSchedules(seriesSupport);
              writer.writeList(results);
            } catch {
              getConnection().WriteLine("[ERROR]: Usage: " + getCommandToHandle() + ":[seriesSupport=False]" );
             }
        }
        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("TV channels from group:" + group);

            List<string> tvchannels = TVServerConnection.GetTVChannels(group);

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

            writer.writeList(tvchannels);
        }
Example #29
0
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
        {
            bool timeshiftingUsers = false;
              List<string> results = new List<string>();

              if (arguments != null && arguments.Length == 1)
              {
              if (arguments[0] == "TimeshiftingUsers")
                  timeshiftingUsers = true;
              }

              if (timeshiftingUsers)
              {
              results = TVServerConnection.getTimeshiftingUserNames();
              }
              else
              {
              results.Add(me.Name);
              }

              writer.writeList(results);
        }
        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]");
        }