Exemplo n.º 1
0
        void LoadSettings()
        {
            string path = Path.Combine(Config.GetFolder(Config.Dir.Config), "MediaPortal.xml");

            using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(path))
            //using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
            {
                server   = xmlreader.GetValue("mydbox", "IP");
                username = xmlreader.GetValue("mydbox", "UserName");
                password = xmlreader.GetValue("mydbox", "Password");
            }

            ShowBoutiques();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load the settings from the mediaportal config
        /// </summary>
        public static void Load()
        {
            using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml"))) {
                username = reader.GetValue(Helper.PLUGIN_NAME, "username");
                server   = reader.GetValue(Helper.PLUGIN_NAME, "server");
                string tmpSettingsString = reader.GetValue(Helper.PLUGIN_NAME, "resource");
                if (!String.IsNullOrEmpty(tmpSettingsString))
                {
                    resource = tmpSettingsString;
                }
                string encryptedPassword = reader.GetValue(Helper.PLUGIN_NAME, "password");
                password                 = decryptString(encryptedPassword);
                autoConnectStartup       = reader.GetValueAsBool(Helper.PLUGIN_NAME, "autoConnectStartup", autoConnectStartup);
                notifyOnMessagePlugin    = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnMessagePlugin", notifyOnMessagePlugin);
                notifyOnMessageGlobally  = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnMessageGlobally", notifyOnMessageGlobally);
                notifyOnStatusPlugin     = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnStatusPlugin", notifyOnStatusPlugin);
                notifyOnStatusGlobally   = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnStatusGlobally", notifyOnStatusGlobally);
                notifyOnMoodPlugin       = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnMoodPlugin", notifyOnMoodPlugin);
                notifyOnMoodGlobally     = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnMoodGlobally", notifyOnMoodGlobally);
                notifyOnActivityPlugin   = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnActivityPlugin", notifyOnActivityPlugin);
                notifyOnActivityGlobally = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnActivityGlobally", notifyOnActivityGlobally);
                notifyOnTunePlugin       = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnTunePlugin", notifyOnTunePlugin);
                notifyOnTuneGlobally     = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnTuneGlobally", notifyOnTuneGlobally);
                notifyOnErrorPlugin      = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnErrorPlugin", notifyOnErrorPlugin);
                notifyOnErrorGlobally    = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnErrorGlobally", notifyOnErrorGlobally);
                selectStatusOnStartup    = reader.GetValueAsBool(Helper.PLUGIN_NAME, "selectStatusOnStartup", selectStatusOnStartup);
                notifyTimeOut            = reader.GetValueAsInt(Helper.PLUGIN_NAME, "notifyTimeOut", notifyTimeOut);
                autoIdleTimeOut          = reader.GetValueAsInt(Helper.PLUGIN_NAME, "autoIdleTimeOut", autoIdleTimeOut);
                autoIdleStatusType       = (Enums.StatusType)reader.GetValueAsInt(Helper.PLUGIN_NAME, "autoIdleStatusType", (int)autoIdleStatusType);
                tmpSettingsString        = reader.GetValue(Helper.PLUGIN_NAME, "autoIdleStatusMessage");
                if (!String.IsNullOrEmpty(tmpSettingsString))
                {
                    autoIdleStatusMessage = tmpSettingsString;
                }
                defaultStatusType = (Enums.StatusType)reader.GetValueAsInt(Helper.PLUGIN_NAME, "defaultStatusType", (int)defaultStatusType);
                tmpSettingsString = reader.GetValue(Helper.PLUGIN_NAME, "defaultStatusMessage");
                if (!String.IsNullOrEmpty(tmpSettingsString))
                {
                    defaultStatusMessage = tmpSettingsString;
                }
                defaultMoodType   = (Enums.MoodType)reader.GetValueAsInt(Helper.PLUGIN_NAME, "defaultMoodType", (int)defaultMoodType);
                tmpSettingsString = reader.GetValue(Helper.PLUGIN_NAME, "defaultMoodMessage");
                if (!String.IsNullOrEmpty(tmpSettingsString))
                {
                    defaultMoodMessage = tmpSettingsString;
                }
                defaultActivityType = (Enums.ActivityType)reader.GetValueAsInt(Helper.PLUGIN_NAME, "defaultActivityType", (int)defaultActivityType);
                tmpSettingsString   = reader.GetValue(Helper.PLUGIN_NAME, "defaultActivityMessage");
                if (!String.IsNullOrEmpty(tmpSettingsString))
                {
                    defaultActivityMessage = tmpSettingsString;
                }
                notifyWindowType    = (Helper.PLUGIN_NOTIFY_WINDOWS)reader.GetValueAsInt(Helper.PLUGIN_NAME, "notifyWindowType", (int)notifyWindowType);
                defaultKeyboardType = (Dialog.KeyBoardTypes)reader.GetValueAsInt(Helper.PLUGIN_NAME, "defaultKeyboardType", (int)Dialog.KeyBoardTypes.Default);

                publishTuneInfo          = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishTuneInfo", publishTuneInfo);
                publishActivityMusic     = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishActivityMusic", publishActivityMusic);
                publishActivityRadio     = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishActivityRadio", publishActivityRadio);
                publishActivityMovie     = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishActivityMovie", publishActivityMovie);
                publishActivityTV        = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishActivityTV", publishActivityTV);
                publishActivityRecording = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishActivityRecording", publishActivityRecording);
            }
        }
        internal void GetLatestMediaInfo()
        {
            int z = 1;

            if (Utils.LatestTVRecordings)
            {
                //TV Recordings
                LatestsCollection latestTVRecordings = null;
                try
                {
                    MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"));

                    string useArgus = xmlreader.GetValue("plugins", "ARGUS TV");
                    string dllFile  = Config.GetFile(Config.Dir.Plugins, @"Windows\ArgusTV.UI.MediaPortal.dll");

                    if (useArgus != null && useArgus.Equals("yes", StringComparison.CurrentCulture) && File.Exists(dllFile))
                    {
                        FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(dllFile);
                        logger.Debug("Argus version = {0}", myFileVersionInfo.FileVersion);

                        if (Largusrh == null)
                        {
                            Largusrh = new LatestArgusRecordingsHandler(this);
                        }

                        ResolveEventHandler assemblyResolve = Largusrh.OnAssemblyResolve;
                        try
                        {
                            AppDomain currentDomain = AppDomain.CurrentDomain;
                            currentDomain.AssemblyResolve        += new ResolveEventHandler(Largusrh.OnAssemblyResolve);
                            Largusrh.IsGetTypeRunningOnThisThread = true;
                            latestTVRecordings = Largusrh.GetArgusRecordings();
                            Largusrh.UpdateActiveRecordings();
                            AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolve;
                            Utils.UsedArgus = true;
                        }
                        catch (FileNotFoundException)
                        {
                            //do nothing
                        }
                        catch (MissingMethodException)
                        {
                            //do nothing
                        }
                        catch (Exception ex)
                        {
                            logger.Error("GetLatestMediaInfo (TV Argus Recordings): " + ex.ToString());
                            AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolve;
                        }
                    }
                    else
                    {
                        if (Ltvrh == null)
                        {
                            Ltvrh = new LatestTVRecordingsHandler(this);
                        }
                        latestTVRecordings = Ltvrh.GetTVRecordings();
                        Ltvrh.UpdateActiveRecordings();
                        Utils.UsedArgus = false;
                    }
                }
                catch (FileNotFoundException)
                {
                    //do nothing
                }
                catch (MissingMethodException)
                {
                    //do nothing
                }
                catch (Exception ex)
                {
                    logger.Error("GetLatestMediaInfo (TV Recordings): " + ex.ToString());
                }
                bool noNewRecordings = false;
                if ((latestTVRecordings != null && latestTVRecordings.Count > 0) &&
                    Utils.GetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".title").Equals(latestTVRecordings[0].Title, StringComparison.CurrentCulture))
                {
                    noNewRecordings = true;
                    logger.Info("Updating Latest Media Info: TV Recording: No new recordings since last check!");
                }

                if (latestTVRecordings != null && latestTVRecordings.Count > 0)
                {
                    if (!noNewRecordings)
                    {
                        EmptyLatestMediaProperties();
                        z = 1;
                        for (int i = 0; i < latestTVRecordings.Count && i < Utils.LatestsMaxTVNum; i++)
                        {
                            logger.Info("Updating Latest Media Info: TV Recording: Recording " + z + ": " + latestTVRecordings[i].Title);

                            string recsummary        = (string.IsNullOrEmpty(latestTVRecordings[i].Summary) ? Translation.NoDescription : latestTVRecordings[i].Summary);
                            string recsummaryoutline = Utils.GetSentences(recsummary, Utils.LatestPlotOutlineSentencesNum);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".thumb", latestTVRecordings[i].Thumb);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".title", latestTVRecordings[i].Title);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".dateAdded", latestTVRecordings[i].DateAdded);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".genre", latestTVRecordings[i].Genre);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".summary", recsummary);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".summaryoutline", recsummaryoutline);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".series", latestTVRecordings[i].SeriesIndex);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".episode", latestTVRecordings[i].EpisodeIndex);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".episodename", latestTVRecordings[i].ThumbSeries);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".directory", latestTVRecordings[i].Directory);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".new", latestTVRecordings[i].New);
                            z++;
                        }
                        //latestTVRecordings.Clear();
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.latest.enabled", "true");
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.hasnew", CurrentFacade.HasNew ? "true" : "false");
                        logger.Debug("Updating Latest Media Info: TV Recording: Has new: " + (CurrentFacade.HasNew ? "true" : "false"));
                    }
                }
                else
                {
                    EmptyLatestMediaProperties();
                    logger.Info("Updating Latest Media Info: TV Recording: No recordings found!");
                }
                //latestTVRecordings = null;
                z = 1;
            }
            else
            {
                EmptyLatestMediaProperties();
            }
            Utils.UpdateLatestsUpdate(Utils.LatestsCategory.TV, DateTime.Now);
        }
Exemplo n.º 4
0
    public void LoadSettings()
    {
      using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml"))
      {
        server = xmlreader.GetValue("mydbox", "IP");
        username = xmlreader.GetValue("mydbox", "UserName");
        password = xmlreader.GetValue("mydbox", "Password");
        boxtype = xmlreader.GetValue("mydbox", "Boxtype");

        RecDir = xmlreader.GetValue("mydbox", "Record");
        SnapDir = xmlreader.GetValue("mydbox", "Snapshot");

        AutoOn = xmlreader.GetValue("mydbox", "AutoOn");
        ErrorLog("loaded settings - box = " + boxtype);
      }
    }