Skip to content
API Documentation
BastionGuard™
AppExcludeEntry Class Reference
Inheritance diagram for AppExcludeEntry:

Public Member Functions

 AppExcludeEntry (string _name, bool _is_include=false)
string tooltip_text ()

Static Public Member Functions

static void clear ()
static void add_app_exclude_entries_from_home (string home)
static void add_app_exclude_entries_from_path (string user_home)
static void add_item (string item_path, bool is_file, bool is_include)
static Gee.ArrayList< AppExcludeEntry > get_apps_list (Gee.ArrayList< string > selected_app_names)

Public Attributes

string name = ""
bool is_include = false
bool is_file = false
bool enabled = false
Gee.ArrayList< string > items
Gee.ArrayList< string > patterns

Static Public Attributes

static Gee.HashMap< string, AppExcludeEntry > app_map

Detailed Description

Definition at line 32 of file AppExcludeEntry.vala.

Constructor & Destructor Documentation

◆ AppExcludeEntry()

AppExcludeEntry.AppExcludeEntry ( string _name,
bool _is_include = false )
inline

Definition at line 44 of file AppExcludeEntry.vala.

44 {
45
46 name = _name;
47 is_include = _is_include;
48
49 items = new Gee.ArrayList<string>();
50 patterns = new Gee.ArrayList<string>();
51 }
Gee.ArrayList< string > patterns
Gee.ArrayList< string > items

References is_include, items, name, and patterns.

Referenced by add_item(), clear(), and get_apps_list().

Member Function Documentation

◆ add_app_exclude_entries_from_home()

void AppExcludeEntry.add_app_exclude_entries_from_home ( string home)
inlinestatic

Definition at line 79 of file AppExcludeEntry.vala.

79 {
80
81 log_debug("AppExcludeEntry: add_app_exclude_entries_from_home()");
82 log_debug("path=%s".printf(home));
83
84 try
85 {
86 File f_home = File.new_for_path (home);
87 if (!f_home.query_exists()){
88 return;
89 }
90
91 FileEnumerator enumerator = f_home.enumerate_children ("standard::*", 0);
92 FileInfo file;
93 while ((file = enumerator.next_file ()) != null) {
94 string name = file.get_name();
95 string item = home + "/" + name;
96 if (name.has_suffix(".lock")){ continue; }
97 if (name.has_suffix(".log")){ continue; }
98 if (name.has_suffix(".old")){ continue; }
99 if (name.has_suffix("~")){ continue; }
100
102 }
103 }
104 catch(Error e){
105 log_error (e.message);
106 }
107 }
static void add_app_exclude_entries_from_path(string user_home)
void log_debug(string message)
void log_error(string message, bool highlight=false, bool is_warning=false)

References add_app_exclude_entries_from_path(), Error, TeeJee.Logging.log_debug(), TeeJee.Logging.log_error(), and name.

Referenced by Main.add_app_exclude_entries_for_prefix().

◆ add_app_exclude_entries_from_path()

void AppExcludeEntry.add_app_exclude_entries_from_path ( string user_home)
inlinestatic

Definition at line 109 of file AppExcludeEntry.vala.

109 {
110
111 log_debug("AppExcludeEntry: add_app_exclude_entries_from_path()");
112 log_debug("path=%s".printf(user_home));
113
114 try
115 {
116 File f_home = File.new_for_path (user_home);
117 if (!f_home.query_exists()){
118 return;
119 }
120
121 FileEnumerator enumerator = f_home.enumerate_children ("standard::*", 0);
122 FileInfo file;
123 while ((file = enumerator.next_file ()) != null) {
124 string name = file.get_name();
125 string item = user_home + "/" + name;
126 if (!name.has_prefix(".")){ continue; }
127 if (name.has_suffix("~")){ continue; }
128 if (name == ".config"){ continue; }
129 if (name == ".local"){ continue; }
130 if (name == ".gvfs"){ continue; }
131 if (name == ".thumbnails"){ continue; }
132 if (name == ".cache"){ continue; }
133 if (name == ".temp"){ continue; }
134 if (name == ".sudo_as_admin_successful"){ continue; }
135 if (name.has_suffix(".lock")){ continue; }
136 if (name.has_suffix(".log")){ continue; }
137 if (name.has_suffix(".old")){ continue; }
138 if (name.has_suffix("~")){ continue; }
139
140 var relpath = "~/%s".printf(name);
141 add_item(relpath, !dir_exists(item), false);
142 }
143
144 File f_home_config = File.new_for_path (user_home + "/.config");
145 if (f_home_config.query_exists()){
146 enumerator = f_home_config.enumerate_children ("standard::*", 0);
147 while ((file = enumerator.next_file ()) != null) {
148 string name = file.get_name();
149 string item = user_home + "/.config/" + name;
150 if (name.has_suffix(".lock")){ continue; }
151 if (name.has_suffix(".log")){ continue; }
152 if (name.has_suffix(".old")){ continue; }
153 if (name.has_suffix("~")){ continue; }
154
155 var relpath = "~/.config/%s".printf(name);
156 add_item(relpath, !dir_exists(item), false);
157 }
158 }
159
160 File f_home_local = File.new_for_path (user_home + "/.local/share");
161 if (f_home_local.query_exists()){
162 enumerator = f_home_local.enumerate_children ("standard::*", 0);
163 while ((file = enumerator.next_file ()) != null) {
164 string name = file.get_name();
165 string item = user_home + "/.local/share/" + name;
166 if (name.has_suffix(".lock")){ continue; }
167 if (name.has_suffix(".log")){ continue; }
168 if (name.has_suffix(".old")){ continue; }
169 if (name.has_suffix("~")){ continue; }
170 if (name == "applications"){ continue; }
171 if (name == "Trash"){ continue; }
172
173 var relpath = "~/.local/share/%s".printf(name);
174 add_item(relpath, !dir_exists(item), false);
175 }
176 }
177 }
178 catch(Error e){
179 log_error (e.message);
180 }
181 }
static void add_item(string item_path, bool is_file, bool is_include)
bool dir_exists(string dir_path)

References add_item(), TeeJee.FileSystem.dir_exists(), Error, TeeJee.Logging.log_debug(), TeeJee.Logging.log_error(), and name.

Referenced by Main.add_app_exclude_entries_for_prefix(), and add_app_exclude_entries_from_home().

◆ add_item()

void AppExcludeEntry.add_item ( string item_path,
bool is_file,
bool is_include )
inlinestatic

Definition at line 183 of file AppExcludeEntry.vala.

183 {
184
185 if (app_map == null){
186 app_map = new Gee.HashMap<string, AppExcludeEntry>();
187 }
188
189 var name = file_basename(item_path);
190
191 if (name.has_suffix(".ini")){
192 name = name[0:name.length - ".ini".length];
193 }
194 else if (name.has_suffix(".sh")){
195 name = name[0:name.length - ".sh".length];
196 }
197 else if (name.has_suffix(".json")){
198 name = name[0:name.length - ".json".length];
199 }
200 else if (name.has_suffix(".conf")){
201 name = name[0:name.length - ".conf".length];
202 }
203 else if (name.has_suffix(".list")){
204 name = name[0:name.length - ".list".length];
205 }
206 else if (name.has_suffix(".xbel")){
207 name = name[0:name.length - ".xbel".length];
208 }
209 else if (name.has_suffix(".xbel.tbcache")){
210 name = name[0:name.length - ".xbel.tbcache".length];
211 }
212 else if (name.has_suffix(".bz2")){
213 name = name[0:name.length - ".bz2".length];
214 }
215 else if (name.has_suffix(".old")){
216 name = name[0:name.length - ".old".length];
217 }
218 else if (name.has_suffix(".dirs")){
219 name = name[0:name.length - ".dirs".length];
220 }
221 else if (name.has_suffix(".locale")){
222 name = name[0:name.length - ".locale".length];
223 }
224 else if (name.has_suffix(".dockitem")){
225 name = name[0:name.length - ".dockitem".length];
226 }
227 else if (name.has_suffix(".xml")){
228 name = name[0:name.length - ".xml".length];
229 }
230 else if (name.has_suffix(".log")){
231 name = name[0:name.length - ".log".length];
232 }
233 else if (name.has_suffix(".txt")){
234 name = name[0:name.length - ".txt".length];
235 }
236
237 if (name.has_prefix(".")){
238 name = name[1:name.length];
239 }
240
241 name = name.strip();
242
243 if (name.length == 0){
244 return;
245 }
246
247 AppExcludeEntry entry = null;
248 if (app_map.has_key(name)){
249 entry = app_map[name];
250 }
251 else if (app_map.has_key(name.down())){
252 entry = app_map[name.down()];
253 }
254 else{
255 entry = new AppExcludeEntry(name, is_include);
256 app_map[name] = entry;
257 }
258
259 if (!entry.items.contains(item_path)){
260 entry.items.add(item_path);
261 }
262
263 foreach(bool root_user in new bool[] { true, false } ){
264 string str = (is_include) ? "+ " : "";
265 str += (root_user) ? "/root" : "/home/*";
266 str += item_path[1:item_path.length];
267 //str += (is_file) ? "" : "/**";
268 entry.patterns.add(str);
269 }
270 }
static Gee.HashMap< string, AppExcludeEntry > app_map
AppExcludeEntry(string _name, bool _is_include=false)
string file_basename(string file_path)

References app_map, AppExcludeEntry(), TeeJee.FileSystem.file_basename(), is_file, is_include, items, and name.

Referenced by add_app_exclude_entries_from_path().

◆ clear()

void AppExcludeEntry.clear ( )
inlinestatic

Definition at line 67 of file AppExcludeEntry.vala.

67 {
68
69 log_debug("AppExcludeEntry: clear()");
70
71 if (app_map == null){
72 app_map = new Gee.HashMap<string, AppExcludeEntry>();
73 }
74 else{
75 app_map.clear();
76 }
77 }

References app_map, AppExcludeEntry(), and TeeJee.Logging.log_debug().

Referenced by Main.add_app_exclude_entries().

◆ get_apps_list()

Gee.ArrayList< AppExcludeEntry > AppExcludeEntry.get_apps_list ( Gee.ArrayList< string > selected_app_names)
inlinestatic

Definition at line 272 of file AppExcludeEntry.vala.

273 {
274
275 if (app_map == null){
276 app_map = new Gee.HashMap<string, AppExcludeEntry>();
277 }
278
279 foreach(var selected_name in selected_app_names){
280 if (app_map.has_key(selected_name)){
281 app_map[selected_name].enabled = true;
282 }
283 else{
284 app_map[selected_name].enabled = false;
285 }
286 }
287
288 var list = new Gee.ArrayList<AppExcludeEntry>();
289 foreach(var key in app_map.keys){
290 list.add(app_map[key]);
291 }
292
293 //sort the list
294 GLib.CompareDataFunc<AppExcludeEntry> entry_compare = (a, b) => {
295 return strcmp(a.name.down(),b.name.down());
296 };
297
298 list.sort((owned) entry_compare);
299
300 log_debug("apps: %d".printf(list.size));
301
302 return list;
303 }

References app_map, AppExcludeEntry(), and TeeJee.Logging.log_debug().

Referenced by Main.add_app_exclude_entries().

◆ tooltip_text()

string AppExcludeEntry.tooltip_text ( )
inline

Definition at line 53 of file AppExcludeEntry.vala.

53 {
54
55 string txt = "";
56 foreach(var item in items){
57 txt += "%s\n".printf(item);
58 }
59 if (txt.has_suffix("\n")){
60 txt = txt[0:txt.length - 1];
61 }
62 return txt;
63 }

References items.

Referenced by ExcludeAppsBox.create_row().

Member Data Documentation

◆ app_map

Gee.HashMap<string, AppExcludeEntry> AppExcludeEntry.app_map
static

◆ enabled

bool AppExcludeEntry.enabled = false

Definition at line 37 of file AppExcludeEntry.vala.

Referenced by ExcludeAppsBox.create_row().

◆ is_file

bool AppExcludeEntry.is_file = false

Definition at line 36 of file AppExcludeEntry.vala.

Referenced by add_item().

◆ is_include

bool AppExcludeEntry.is_include = false

Definition at line 35 of file AppExcludeEntry.vala.

Referenced by add_item(), and AppExcludeEntry().

◆ items

Gee.ArrayList<string> AppExcludeEntry.items

Definition at line 38 of file AppExcludeEntry.vala.

Referenced by add_item(), AppExcludeEntry(), and tooltip_text().

◆ name

◆ patterns

Gee.ArrayList<string> AppExcludeEntry.patterns

Definition at line 39 of file AppExcludeEntry.vala.

Referenced by AppExcludeEntry().


The documentation for this class was generated from the following file: