Esempio n. 1
0
        private void LoadSortSchema()
        {
            if (ChildSortTypes.Length == 0)
            {
                return;
            }

            if (unique_id == null && type_unique_id == null)
            {
                Hyena.Log.WarningFormat("Trying to LoadSortSchema, but source's id not set! {0}", UniqueId);
                return;
            }

            child_sort_schema = CreateSchema <string> ("child_sort_id", DefaultChildSort.Id, "", "");
            string child_sort_id = child_sort_schema.Get();

            foreach (SourceSortType sort_type in ChildSortTypes)
            {
                if (sort_type.Id == child_sort_id)
                {
                    child_sort = sort_type;
                    break;
                }
            }

            separate_by_type_schema = CreateSchema <bool> ("separate_by_type", false, "", "");
            SortChildSources();
        }
Esempio n. 2
0
        public UPnPServerSource(Device device) :  base(Catalog.GetString("UPnP Share"), device.FriendlyName, 300)
        {
            Properties.SetStringList("Icon.Name", "computer", "network-server");
            TypeUniqueId    = "upnp-container";
            expanded_schema = new SchemaEntry <bool> ("plugins.upnp." + device.Udn, "expanded", true,
                                                      "UPnP Share expanded", "UPnP Share expanded");
            udn = device.Udn;

            ContentDirectoryController content_directory = null;

            foreach (Service service in device.Services)
            {
                Log.Debug("UPnPService \"" + device.FriendlyName + "\" Implements " + service.Type);
                if (service.Type.Type == "ContentDirectory")
                {
                    content_directory = new ContentDirectoryController(service.GetController());
                }
            }

            if (content_directory == null)
            {
                throw new ArgumentNullException("content_directory");
            }

            ThreadAssist.Spawn(delegate {
                Parse(device, content_directory);
            });
        }
Esempio n. 3
0
        public SchemaPreference <T> Add <T> (SchemaEntry <T> schema)
        {
            SchemaPreference <T> pref = new SchemaPreference <T> (schema, schema.ShortDescription, schema.LongDescription);

            Add(pref);
            return(pref);
        }
Esempio n. 4
0
        private void BuildPreferences()
        {
            conf_ns         = "sync";
            manually_manage = dap.CreateSchema <bool> (conf_ns, "enabled", true,
                                                       Catalog.GetString("Manually manage this device"),
                                                       Catalog.GetString("Manually managing your device means you can drag and drop items onto the device, and manually remove them.")
                                                       );

            auto_sync = dap.CreateSchema <bool> (conf_ns, "auto_sync", false,
                                                 Catalog.GetString("Automatically sync the device when plugged in or when the libraries change"),
                                                 Catalog.GetString("Begin synchronizing the device as soon as the device is plugged in or the libraries change.")
                                                 );

            dap_prefs_section = new Section("dap", Catalog.GetString("Sync Preferences"), 0);
            pref_sections.Add(dap_prefs_section);

            manually_manage_pref = dap_prefs_section.Add(manually_manage);
            manually_manage_pref.ShowDescription = true;
            manually_manage_pref.ShowLabel       = false;
            manually_manage_pref.ValueChanged   += OnManuallyManageChanged;

            auto_sync_pref = dap_prefs_section.Add(auto_sync);
            auto_sync_pref.ValueChanged += OnAutoSyncChanged;

            //manually_manage_pref.Changed += OnEnabledChanged;
            //auto_sync_pref.Changed += delegate { OnUpdated (); };
            //OnEnabledChanged (null);
        }
        public FilteredListSourceContents(string name,
                                          SchemaEntry <int> pane_top_position,
                                          SchemaEntry <int> pane_left_position)
        {
            this.name = name;
            this.pane_top_position  = pane_top_position;
            this.pane_left_position = pane_left_position;

            InitializeViews();

            string position = Layout();

            if (ForcePosition != null)
            {
                return;
            }

            if (ServiceManager.Contains("InterfaceActionService"))
            {
                action_service = ServiceManager.Get <InterfaceActionService> ();

                if (action_service.FindActionGroup("BrowserView") == null)
                {
                    browser_view_actions = new ActionGroup("BrowserView");

                    browser_view_actions.Add(new RadioActionEntry [] {
                        new RadioActionEntry("BrowserLeftAction", null,
                                             Catalog.GetString("Browser on Left"), null,
                                             Catalog.GetString("Show the artist/album browser to the left of the track list"), 0),

                        new RadioActionEntry("BrowserTopAction", null,
                                             Catalog.GetString("Browser on Top"), null,
                                             Catalog.GetString("Show the artist/album browser above the track list"), 1),
                    }, position == "top" ? 1 : 0, null);

                    browser_view_actions.Add(new ToggleActionEntry [] {
                        new ToggleActionEntry("BrowserVisibleAction", null,
                                              Catalog.GetString("Show Browser"), "<control>B",
                                              Catalog.GetString("Show or hide the artist/album browser"),
                                              null, BrowserVisible.Get())
                    });

                    action_service.AddActionGroup(browser_view_actions);
                    //action_merge_id = action_service.UIManager.NewMergeId ();
                    action_service.UIManager.AddUiFromString(menu_xml);
                }

                (action_service.FindAction("BrowserView.BrowserLeftAction") as RadioAction).Changed += OnViewModeChanged;
                (action_service.FindAction("BrowserView.BrowserTopAction") as RadioAction).Changed  += OnViewModeChanged;
                action_service.FindAction("BrowserView.BrowserVisibleAction").Activated             += OnToggleBrowser;
            }

            ServiceManager.SourceManager.ActiveSourceChanged += delegate {
                ThreadAssist.ProxyToMain(delegate {
                    browser_container.Visible = ActiveSourceCanHasBrowser ? BrowserVisible.Get() : false;
                });
            };

            NoShowAll = true;
        }
Esempio n. 6
0
        private void PrimarySourceInitialize()
        {
            // Scope the tracks to this primary source
            DatabaseTrackModel.AddCondition(String.Format("CoreTracks.PrimarySourceID = {0}", DbId));

            primary_sources[DbId] = this;

            // If there was a crash, tracks can be left behind, for example in DaapSource.
            // Temporary playlists are cleaned up by the PlaylistSource.LoadAll call below
            if (IsTemporary && SavedCount > 0)
            {
                PurgeTracks();
            }

            // Load our playlists and smart playlists
            foreach (PlaylistSource pl in PlaylistSource.LoadAll(this))
            {
                AddChildSource(pl);
            }

            int sp_count = 0;

            foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll(this))
            {
                AddChildSource(pl);
                sp_count++;
            }

            // Create default smart playlists if we haven't done it ever before, and if the
            // user has zero smart playlists.
            if (!HaveCreatedSmartPlaylists)
            {
                if (sp_count == 0)
                {
                    foreach (SmartPlaylistDefinition def in DefaultSmartPlaylists)
                    {
                        SmartPlaylistSource pl = def.ToSmartPlaylistSource(this);
                        pl.Save();
                        AddChildSource(pl);
                        pl.RefreshAndReload();
                        sp_count++;
                    }
                }

                // Only save it if we already had some smart playlists, or we actually created some (eg not
                // if we didn't have any and the list of default ones is empty atm).
                if (sp_count > 0)
                {
                    HaveCreatedSmartPlaylists = true;
                }
            }

            expanded_schema = new SchemaEntry <bool> (
                String.Format("sources.{0}", ParentConfigurationId), "expanded", true, "Is source expanded", "Is source expanded"
                );
        }
Esempio n. 7
0
        public void Normalized_Name()
        {
            var str = SchemaEntry.NormalizedName(null, null);

            Assert.AreEqual(".", str);

            str = SchemaEntry.NormalizedName("Table", null);
            Assert.AreEqual("Table.", str);

            str = SchemaEntry.NormalizedName(null, "Column");
            Assert.AreEqual(".Column", str);
        }
Esempio n. 8
0
 public WindowConfiguration(SchemaEntry <int> widthSchema,
                            SchemaEntry <int> heightSchema,
                            SchemaEntry <int> xPosSchema,
                            SchemaEntry <int> yPosSchema,
                            SchemaEntry <bool> maximizedSchema)
 {
     WidthSchema     = widthSchema;
     HeightSchema    = heightSchema;
     XPosSchema      = xPosSchema;
     YPosSchema      = yPosSchema;
     MaximizedSchema = maximizedSchema;
 }
Esempio n. 9
0
        public void Shutdown()
        {
            for (int i = 0; i < columns.Count; ++i)
            {
                TreeViewColumn    tmpCol    = columns[i] as TreeViewColumn;
                SchemaEntry <int> tmpSchema = (SchemaEntry <int>)schemas[i];

                if (tmpCol.Width != 0)
                {
                    tmpSchema.Set(tmpCol.Width);
                }
            }
        }
Esempio n. 10
0
        private void BuildPreferences()
        {
            conf_ns = String.Format("{0}.{1}", sync.ConfigurationNamespace, library.ParentConfigurationId);

            enabled = sync.Dap.CreateSchema <bool> (conf_ns, "enabled", sync.LegacyManuallyManage.Get(),
                                                    String.Format(Catalog.GetString("Sync {0}"), library.Name), "");

            sync_entire_library = sync.Dap.CreateSchema <bool> (conf_ns, "sync_entire_library", true,
                                                                "Whether to sync the entire library and all playlists.", "");

            sync_source = sync.Dap.CreateSchema <string> (conf_ns, "sync_source", null,
                                                          "If sync_entire_library is false, this contains the source to sync from", "");
        }
        private void Layout(bool top)
        {
            //Hyena.Log.Information ("ListBrowser LayoutLeft");
            Reset();

            SchemaEntry <int> current_entry = top ? pane_top_position : pane_left_position;

            container = GetPane(!top);
            Paned filter_box = GetPane(top);

            filter_box.PositionSet = true;
            Paned current_pane = filter_box;

            for (int i = 0; i < filter_scrolled_windows.Count; i++)
            {
                ScrolledWindow window           = filter_scrolled_windows[i];
                bool           last_even_filter = (i == filter_scrolled_windows.Count - 1 && filter_scrolled_windows.Count % 2 == 0);
                if (i > 0 && !last_even_filter)
                {
                    Paned new_pane = GetPane(top);
                    current_pane.Pack2(new_pane, true, false);
                    current_pane.Position = top ? 180 : 350;
                    PersistentPaneController.Control(current_pane, ControllerName(top, i));
                    current_pane = new_pane;
                }

                if (last_even_filter)
                {
                    current_pane.Pack2(window, true, false);
                    current_pane.Position = top ? 180 : 350;
                    PersistentPaneController.Control(current_pane, ControllerName(top, i));
                }
                else
                {
                    current_pane.Pack1(window, false, false);
                }
            }

            container.Pack1(filter_box, false, false);
            container.Pack2(main_scrolled_window, true, false);
            browser_container = filter_box;

            if (current_entry.Equals(SchemaEntry <int> .Zero))
            {
                throw new InvalidOperationException(String.Format("No SchemaEntry found for {0} position of {1}",
                                                                  top ? "top" : "left", this.GetType().FullName));
            }
            container.Position = current_entry.DefaultValue;
            PersistentPaneController.Control(container, current_entry);
            ShowPack();
        }
Esempio n. 12
0
        private static void listSchemaMetadataDiffBreakdown(SchemaEntry e1, SchemaEntry e2)
        {
            SchemaComparableList <AttributeMetadata> mdList1 = null;
            SchemaComparableList <AttributeMetadata> mdList2 = null;

            if (e1 != null && e2 != null)
            {
                mdList1 = e1.GetMetadataList();
                mdList2 = e2.GetMetadataList();

                TupleList <AttributeMetadata, AttributeMetadata> diff = mdList1.GetDiff(mdList2);

                Console.WriteLine("\tBASE: {0}", e1.defName);
                foreach (Tuple <AttributeMetadata, AttributeMetadata> t in diff)
                {
                    Console.WriteLine("\t\t{0}", t.Item1);
                }

                Console.WriteLine("\tOTHE: {0}", e2.defName);
                foreach (Tuple <AttributeMetadata, AttributeMetadata> t in diff)
                {
                    Console.WriteLine("\t\t{0}", t.Item2);
                }
            }
            else if (e1 != null)
            {
                mdList1 = e1.GetMetadataList();

                Console.WriteLine("\tBASE: {0}", e1.defName);
                foreach (AttributeMetadata md in mdList1)
                {
                    Console.WriteLine("\t\t{0}", md);
                }
                Console.WriteLine("\tOTHE:");
            }
            else
            {
                mdList2 = e2.GetMetadataList();

                Console.WriteLine("\tBASE:");
                Console.WriteLine("\tOTHE: {0}", e2.defName);
                foreach (AttributeMetadata md in mdList2)
                {
                    Console.WriteLine("\t\t{0}", md);
                }
            }

            Console.WriteLine("\t-----");
        }
Esempio n. 13
0
        private ConfigProvider()
        {
            _localConfigRoot = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                               .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                               .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true)
                               .Build();

            var ConfigManager = ConfigManagerFactory <ConfigWrapper> .CreateConfigManager(
                GetGlobalConfiguration,
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json"),
                new List <SchemaEntry>
            {
                SchemaEntry.Create <OrganizationSchema>()
            });

            _configManager = new CachingConfigManagerDecorator <ConfigWrapper>(ConfigManager);
        }
Esempio n. 14
0
        private void BuildPreferences()
        {
            conf_ns = "sync";
            LegacyManuallyManage = dap.CreateSchema <bool> (conf_ns, "enabled", false, "", "");

            auto_sync = dap.CreateSchema <bool> (conf_ns, "auto_sync", false,
                                                 Catalog.GetString("Sync when first plugged in and when the libraries change"),
                                                 Catalog.GetString("Begin synchronizing the device as soon as the device is plugged in or the libraries change.")
                                                 );

            sync_prefs = new Section("sync", Catalog.GetString("Sync Preferences"), 0);
            pref_sections.Add(sync_prefs);

            sync_prefs.Add(new VoidPreference("library-options"));

            auto_sync_pref = sync_prefs.Add(auto_sync);
            auto_sync_pref.ValueChanged += OnAutoSyncChanged;
        }
Esempio n. 15
0
        private void BuildPreferences()
        {
            conf_ns = String.Format("{0}.{1}", sync.ConfigurationNamespace, library.ParentConfigurationId);

            enabled = sync.Dap.CreateSchema <bool> (conf_ns, "enabled", true,
                                                    String.Format(Catalog.GetString("Sync {0}"), library.Name), "");

            sync_entire_library = sync.Dap.CreateSchema <bool> (conf_ns, "sync_entire_library", true,
                                                                "Whether to sync the entire library and all playlists.", "");

            playlist_ids = sync.Dap.CreateSchema <string[]> (conf_ns, "playlist_ids", new string [0],
                                                             "If sync_entire_library is false, this contains a list of playlist ids specifically to sync", "");

            library_prefs_section        = new Section(String.Format("{0} sync", library.Name), library.Name, 0);
            enabled_pref                 = library_prefs_section.Add <bool> (enabled);
            enabled_pref.ShowDescription = true;
            enabled_pref.ShowLabel       = false;
        }
Esempio n. 16
0
        public PersistentWindowController(Gtk.Window window, string configNameSpace, int defaultWidth, int defaultHeight, WindowPersistOptions options)
        {
            this.window  = window;
            this.options = options;

            WidthSchema = new SchemaEntry <int>(
                configNameSpace, "width",
                defaultWidth,
                "Window Width",
                "Width of the main interface window."
                );

            HeightSchema = new SchemaEntry <int>(
                configNameSpace, "height",
                defaultHeight,
                "Window Height",
                "Height of the main interface window."
                );

            XPosSchema = new SchemaEntry <int>(
                configNameSpace, "x_pos",
                0,
                "Window Position X",
                "Pixel position of Main Player Window on the X Axis"
                );

            YPosSchema = new SchemaEntry <int>(
                configNameSpace, "y_pos",
                0,
                "Window Position Y",
                "Pixel position of Main Player Window on the Y Axis"
                );

            MaximizedSchema = new SchemaEntry <bool>(
                configNameSpace, "maximized",
                false,
                "Window Maximized",
                "True if main window is to be maximized, false if it is not."
                );

            window.ConfigureEvent   += OnChanged;
            window.WindowStateEvent += OnChanged;
            window.DestroyEvent     += OnDestroy;
        }
        private void listSchemaMetadataDiffBreakdown(SchemaEntry e1, SchemaEntry e2)
        {
            SchemaComparableList <AttributeMetadata> mdList1 = null;
            SchemaComparableList <AttributeMetadata> mdList2 = null;

            if (e1 != null && e2 != null)
            {
                mdList1 = e1.GetMetadataList();
                mdList2 = e2.GetMetadataList();

                VmDirInterop.Schema.Utils.TupleList <AttributeMetadata, AttributeMetadata> diff = mdList1.GetDiff(mdList2);

                foreach (VmDirInterop.Schema.Utils.Tuple <AttributeMetadata, AttributeMetadata> t in diff)
                {
                    //baseMetaData
                    string baseData    = (t.item1 != null) ? e1.defName + " : " + t.item1.ToString() : VMDirSchemaConstants.MISING_METADATA;
                    string currentData = (t.item2 != null) ? e1.defName + " : " + t.item2.ToString() : VMDirSchemaConstants.MISING_METADATA;
                    MetaDataDiff.Add(new KeyValuePair <string, string>(baseData, currentData));
                }
            }
            else if (e1 != null)
            {
                mdList1 = e1.GetMetadataList();
                foreach (AttributeMetadata md in mdList1)
                {
                    string baseData    = e1.defName + " : " + md;
                    string currentData = VMDirSchemaConstants.MISING_METADATA;
                    MetaDataDiff.Add(new KeyValuePair <string, string>(baseData, currentData));
                }
            }
            else
            {
                mdList2 = e2.GetMetadataList();
                foreach (AttributeMetadata md in mdList2)
                {
                    string currentData = e1.defName + " : " + md;
                    string baseData    = VMDirSchemaConstants.MISING_METADATA;
                    MetaDataDiff.Add(new KeyValuePair <string, string>(baseData, currentData));
                }
            }
        }
Esempio n. 18
0
        private TreeViewColumn NewColumn(string title,
                                         int sortColumn,
                                         SchemaEntry <int> schema)
        {
            TreeViewColumn tmp_column = new TreeViewColumn();

            tmp_column.Resizable    = true;
            tmp_column.Clickable    = true;
            tmp_column.Reorderable  = false;
            tmp_column.Visible      = true;
            tmp_column.Sizing       = TreeViewColumnSizing.Fixed;
            tmp_column.Title        = title;
            tmp_column.SortColumnId = sortColumn;

            tmp_column.FixedWidth = schema.Get();

            schemas.Add(schema);
            columns.Add(tmp_column);

            return(tmp_column);
        }
Esempio n. 19
0
        public void Validation_Rules()
        {
            SchemaEntry.ValidateTable(null);

            // Relaxed: empty strings are translated into nulls...
            //try { SchemaEntry.ValidateTable(string.Empty); Assert.Fail(); }
            //catch (EmptyException) { }

            // Relaxed: empty strings are translated into nulls...
            //try { SchemaEntry.ValidateTable("  "); Assert.Fail(); }
            //catch (EmptyException) { }

            try { SchemaEntry.ValidateColumn(null); Assert.Fail(); }
            catch (ArgumentNullException) { }

            try { SchemaEntry.ValidateColumn(string.Empty); Assert.Fail(); }
            catch (EmptyException) { }

            try { SchemaEntry.ValidateColumn("  "); Assert.Fail(); }
            catch (EmptyException) { }
        }
        private void AssertAreSchemaEntriesEqual(
            TupleList <SchemaEntry, SchemaEntry> expectedDiff,
            TupleList <SchemaEntry, SchemaEntry> actualDiff
            )
        {
            Assert.AreEqual(expectedDiff.Count, actualDiff.Count);
            for (int i = 0; i < expectedDiff.Count; i++)
            {
                SchemaEntry expected1 = expectedDiff[i].item1;
                SchemaEntry expected2 = expectedDiff[i].item2;
                SchemaEntry actual1   = actualDiff[i].item1;
                SchemaEntry actual2   = actualDiff[i].item2;

                if (expected1 != null && expected2 != null)
                {
                    TupleList <AttributeMetadata, AttributeMetadata> expectedMdDiff =
                        expected1.GetMetadataList().GetDiff(expected2.GetMetadataList());
                    TupleList <AttributeMetadata, AttributeMetadata> actualMdDiff =
                        actual1.GetMetadataList().GetDiff(actual2.GetMetadataList());

                    AssertAreMetadataEqual(expectedMdDiff, actualMdDiff);
                }
                else if (expected1 == null)
                {
                    Assert.IsNull(actual1);
                }
                else if (expected2 == null)
                {
                    Assert.IsNull(actual2);
                }
                else
                {
                    Assert.Fail();  // they both can't be null
                }
            }
        }
Esempio n. 21
0
 public static T Get <T> (this IConfigurationClient client, SchemaEntry <T> entry)
 {
     return(client.Get <T> (entry.Namespace, entry.Key, entry.DefaultValue));
 }
 public T Get <T> (SchemaEntry <T> entry)
 {
     return(Get <T> (entry.Namespace, entry.Key, entry.DefaultValue));
 }
 public T Get <T> (SchemaEntry <T> entry, T fallback)
 {
     return(Get <T> (entry.Namespace, entry.Key, fallback));
 }
Esempio n. 24
0
 public void Setup()
 {
     test_entry = new SchemaEntry<int> ("", "test", 25,
         "Test Value", "Used for Questar unit tests.");
 }
Esempio n. 25
0
 public static void Set <T> (this IConfigurationClient client, SchemaEntry <T> entry, T value)
 {
     client.Set(entry.Namespace, entry.Key, value);
 }
 public void Set <T> (SchemaEntry <T> entry, T value)
 {
     Set <T> (entry.Namespace, entry.Key, value);
 }
Esempio n. 27
0
 public static T Get <T> (this IConfigurationClient client, SchemaEntry <T> entry, T fallback)
 {
     return(client.Get <T> (entry.Namespace, entry.Key, fallback));
 }
Esempio n. 28
0
 public static void Control(Paned pane, SchemaEntry <int> entry)
 {
     Control(pane, entry.Namespace, entry.Key, entry.DefaultValue);
 }
Esempio n. 29
0
 public SchemaPreference(SchemaEntry <T> schema, string name, string description, SchemaPreferenceUpdatedHandler handler)
     : base(schema.Key, name, description)
 {
     this.schema  = schema;
     this.handler = handler;
 }
Esempio n. 30
0
 public SchemaPreference(SchemaEntry <T> schema, string name, string description)
     : this(schema, name, description, null)
 {
 }
Esempio n. 31
0
 public SchemaPreference(SchemaEntry <T> schema, string name) : this(schema, name, null)
 {
 }