1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--- src/contractor.vala	2011-12-28 15:44:19 +0000
+++ src/contractor.vala	2011-12-28 18:42:03 +0000
@@ -41,6 +41,7 @@
         private bool is_native;
         private string common_parent;
         private string cmd_uris;
+        private Gee.Set<string>? mimes;
 
         GLib.HashTable<string,string>[] filtered;
 
@@ -85,6 +86,44 @@
                 }
             }
 
+            /* get all common eaction_files mime by mime and intersect them */
+            Gee.List<ContractFileInfo>? list_mime0 = null;
+            Gee.List<ContractFileInfo>? list_intersect = null;
+            foreach (var mime in mimes) {
+                //message ("mime %s", mime);
+                if (list_mime0 == null) {
+                    list_mime0 = cfs.get_contract_files_for_type (mime);
+                    if (list_mime0.size == 0)
+                        break;
+                    continue;
+                }
+                var list_mime1 = cfs.get_contract_files_for_type (mime);
+                if (list_mime1.size > 0) {
+                    list_intersect = new Gee.ArrayList<ContractFileInfo> ();
+                    foreach (var entry0 in list_mime0) {
+                        foreach (var entry1 in list_mime1)
+                            if (entry0.name == entry1.name) { 
+                                //message ("entry match %s", entry0.name);
+                                list_intersect.add (entry0);
+                            }
+                    }
+                    if (list_intersect.size == 0) {
+                        //message ("xxxxxxxxxxxx");
+                        break;
+                    }
+                    list_mime0 = list_intersect;
+
+                } else {
+                    //message ("xxxxxxxxxxxx");
+                    break;
+                }
+            }
+
+            if (list_intersect != null)
+            foreach (var entry in list_intersect)
+                multi_args_add_contract_to_filtered_table (entry);
+
+
             /* conditional contracts are contracts which own mime_type entries containing special conditional character(s) like ! for negation. Thoses conditionnals characters can apply to another contract mime group, a parent_mime or a mime type. At the moment it's relatively simple but maybe later we can extend conditionals to characters like & | () */
             foreach (var cc in cfs.conditional_contracts) {
                 debug ("CC %s %s", cc.name, cc.conditional_mime);
@@ -264,6 +303,7 @@
             all_native = true;
             common_parent = null;
             cmd_uris = "";
+            mimes = new Gee.HashSet<string> ();
 
             foreach (var location in locations) {       
                 var uri = location.lookup ("uri");
@@ -272,6 +312,8 @@
                 string mimetype = location.lookup ("mimetype");
                 if (mimetype == null || mimetype.length <= 0)
                     mimetype = query_content_type (file);
+                if (mimetype != null)
+                    mimes.add (mimetype);
                 pmimes += get_parent_mime (mimetype);
                 natives += file.is_native ();
             }