@@ -61,29 +61,15 @@ public class Wingpanel.IndicatorManager : GLib.Object {
6161 */
6262 public signal void indicator_removed (Wingpanel .Indicator indicator );
6363
64- /**
65- * Place the files in /etc/wingpanel.d/ or ~/.config/wingpanel.d/
66- * default.forbidden, greeter.allowed or combinations of it.
67- */
68- private Gee . HashSet<string> forbidden_indicators;
69- private Gee . HashSet<string> allowed_indicators;
70-
7164 [CCode (has_target = false )]
7265 private delegate Wingpanel .Indicator ? RegisterPluginFunction (Module module , ServerType server_type );
7366
7467 private Gee . HashMap<string, Wingpanel . Indicator > indicators;
75-
7668 private FileMonitor ? monitor = null ;
77-
78- private FileMonitor ? root_restrictions_monitor = null ;
79- private FileMonitor ? user_restrictions_monitor = null ;
80-
8169 private ServerType server_type;
8270
8371 private IndicatorManager () {
8472 indicators = new Gee .HashMap<string, Wingpanel . Indicator > ();
85- forbidden_indicators = new Gee .HashSet<string> ();
86- allowed_indicators = new Gee .HashSet<string> ();
8773 }
8874
8975 /**
@@ -94,26 +80,6 @@ public class Wingpanel.IndicatorManager : GLib.Object {
9480 public void initialize (ServerType server_type ) {
9581 this . server_type = server_type;
9682
97- /* load inclusion/exclusion lists */
98- var root_restrictions_folder = File . new_for_path (" /etc/wingpanel.d/" );
99- var user_restrictions_folder = File . new_for_path (Path . build_filename (Environment . get_user_config_dir (), " wingpanel.d" ));
100-
101- try {
102- root_restrictions_monitor = root_restrictions_folder. monitor_directory (FileMonitorFlags . NONE , null );
103- root_restrictions_monitor. changed. connect ((file, trash, event) = > {
104- reload_restrictions (root_restrictions_folder, user_restrictions_folder);
105- });
106- user_restrictions_monitor = user_restrictions_folder. monitor_directory (FileMonitorFlags . NONE , null );
107- user_restrictions_monitor. changed. connect ((file, trash, event) = > {
108- reload_restrictions (root_restrictions_folder, user_restrictions_folder);
109- });
110-
111- load_restrictions (root_restrictions_folder);
112- load_restrictions (user_restrictions_folder);
113- } catch (Error error) {
114- warning (" Error while reading restrictions files: %s\n " , error. message);
115- }
116-
11783 /* load indicators */
11884 var base_folder = File . new_for_path (Build . INDICATORS_DIR );
11985
@@ -148,14 +114,6 @@ public class Wingpanel.IndicatorManager : GLib.Object {
148114 }
149115
150116 if (indicators. has_key (path)) {
151- return ;
152- } else if (check_forbidden_indicators (path)) {
153- debug (" Indicator %s will not be loaded since it is explicitly forbidden" , path);
154-
155- return ;
156- } else if (! check_allowed_indicators (path)) {
157- debug (" Indicator %s will not be loaded since it is not enabled" , path);
158-
159117 return ;
160118 }
161119
@@ -212,112 +170,6 @@ public class Wingpanel.IndicatorManager : GLib.Object {
212170 }
213171 }
214172
215- private bool check_forbidden_indicators (string path ) {
216- foreach (var indicator_file_name in forbidden_indicators) {
217- if (path. has_suffix (indicator_file_name)) {
218- return true ;
219- }
220- }
221-
222- return false ;
223- }
224-
225- private bool check_allowed_indicators (string path ) {
226- if (allowed_indicators. size == 0 ) {
227- return true ;
228- }
229-
230- foreach (var indicator_file_name in allowed_indicators) {
231- if (path. has_suffix (indicator_file_name)) {
232- return true ;
233- }
234- }
235-
236- return false ;
237- }
238-
239- private void reload_restrictions (File root_restrictions_folder , File user_restrictions_folder ) {
240- forbidden_indicators. clear ();
241- allowed_indicators. clear ();
242- load_restrictions (root_restrictions_folder);
243- load_restrictions (user_restrictions_folder);
244-
245- indicators. @foreach ((entry) = > {
246- if (check_forbidden_indicators (entry. key)) {
247- deregister_indicator (entry. key, entry. value );
248- } else if (! check_allowed_indicators (entry. key)) {
249- deregister_indicator (entry. key, entry. value );
250- }
251-
252- return true ;
253- });
254- find_plugins (File . new_for_path (Build . INDICATORS_DIR ));
255- }
256-
257- private void load_restrictions (File restrictions_folder ) {
258- if (! restrictions_folder. query_exists ()) {
259- return ;
260- }
261-
262- FileInfo file_info = null ;
263-
264- try {
265- var enumerator = restrictions_folder. enumerate_children (FileAttribute . STANDARD_NAME , 0 );
266-
267- while ((file_info = enumerator. next_file ()) != null ) {
268- unowned string file_name = file_info. get_name ();
269- if (! file_name. contains (server_type. restrictions_file_name ())) {
270- continue ;
271- }
272-
273- var file = restrictions_folder. get_child (file_name);
274-
275- if (file_name. has_suffix (" .allowed" )) {
276- foreach (var entry in get_restrictions_from_file (file)) {
277- allowed_indicators. add (entry);
278- }
279- } else if (file_name. has_suffix (" .forbidden" )) {
280- foreach (var entry in get_restrictions_from_file (file)) {
281- forbidden_indicators. add (entry);
282- }
283- } else if (file_name. has_suffix (" .whitelist" )) {
284- critical (" Using .whitelist files is deprecated and will be removed in next version, please use .allowed instead" );
285- foreach (var entry in get_restrictions_from_file (file)) {
286- allowed_indicators. add (entry);
287- }
288- } else if (file_name. has_suffix (" .blacklist" )) {
289- critical (" Using .blacklist files is deprecated and will be removed in next version, please use .forbidden instead" );
290- foreach (var entry in get_restrictions_from_file (file)) {
291- forbidden_indicators. add (entry);
292- }
293- }
294- }
295- } catch (Error error) {
296- warning (" Unable to scan restrictions folder %s : %s\n " , restrictions_folder. get_path (), error. message);
297- }
298- }
299-
300- private string [] get_restrictions_from_file (File file ) {
301- var restrictions = new string [] {};
302-
303- if (file. query_exists ()) {
304- try {
305- var dis = new DataInputStream (file. read ());
306- string line = null ;
307-
308- while ((line = dis. read_line ()) != null ) {
309- if (line. strip () != " " ) {
310- restrictions + = line;
311- }
312- }
313- } catch (Error error) {
314- warning (" Unable to load restrictions file %s : %s\n " , file. get_basename (), error. message);
315- }
316- }
317-
318- return restrictions;
319- }
320-
321173 /**
322174 * Register a new indicator.
323175 *
0 commit comments