1 //
2 // aegis - project change supervisor
3 // Copyright (C) 2003-2008, 2012 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published
7 // by the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18
19 #include <common/ac/assert.h>
20 #include <common/ac/stdio.h>
21 #include <common/ac/string.h>
22
23 #include <common/str_list.h>
24 #include <libaegis/ael/attribu_list.h>
25 #include <libaegis/attribute.h>
26 #include <libaegis/change.h>
27 #include <libaegis/change/file.h>
28 #include <libaegis/emit/edit_number.h>
29 #include <libaegis/http.h>
30 #include <libaegis/project.h>
31 #include <libaegis/project/file.h>
32
33 #include <aeget/get/change/files.h>
34
35
36 void
get_change_files(change::pointer cp,string_ty *,string_list_ty *)37 get_change_files(change::pointer cp, string_ty *, string_list_ty *)
38 {
39 string_list_ty attr_name;
40 for (size_t j = 0; ; ++j)
41 {
42 fstate_src_ty *src;
43
44 if (cp->bogus)
45 src = cp->pp->file_nth(j, view_path_simple);
46 else
47 src = change_file_nth(cp, j, view_path_first);
48 if (!src)
49 break;
50 if (src->attribute)
51 {
52 for (size_t k = 0; k < src->attribute->length; ++k)
53 {
54 attributes_ty *ap;
55
56 ap = src->attribute->list[k];
57 if
58 (
59 ael_attribute_listable(ap)
60 &&
61 !attr_name.member_nocase(ap->name)
62 )
63 {
64 attr_name.push_back(ap->name);
65 }
66 }
67 }
68 }
69 attr_name.sort_nocase();
70
71 html_header(0, cp);
72 printf("<title>Project\n");
73 html_encode_string(project_name_get(cp->pp));
74 if (!cp->bogus)
75 printf(", Change %ld", magic_zero_decode(cp->number));
76 printf(", Files\n");
77 printf("</title></head><body>\n");
78 html_header_ps(0, cp);
79 printf("<h1 align=center>\n");
80 emit_change(cp);
81 printf(",<br>\nList of Files</h1>\n");
82 printf("<div class=\"information\">\n");
83
84 printf("<table align=center>\n");
85 printf("<tr class=\"even-group\"><th>Type</th><th>Action</th>");
86 printf("<th>Edit</th>\n");
87 for (size_t j2 = 0; j2 < attr_name.nstrings; ++j2)
88 {
89 printf("<th>");
90 html_encode_string(attr_name.string[j2]);
91 printf("</th>\n");
92 }
93 printf("<th>File Name</th></tr>\n");
94
95 size_t file_num;
96 for (file_num = 0; ; ++file_num)
97 {
98 fstate_src_ty *src;
99
100 if (cp->bogus)
101 src = cp->pp->file_nth(file_num, view_path_simple);
102 else
103 src = change_file_nth(cp, file_num, view_path_first);
104 if (!src)
105 break;
106
107 printf
108 (
109 "<tr class=\"%s-group\">\n",
110 (file_num % 6 < 3 ? "odd" : "even")
111 );
112
113 printf("<td valign=top>%s</td>\n", file_usage_ename(src->usage));
114 printf("<td valign=top>%s</td>\n", file_action_ename(src->action));
115 printf("<td valign=top align=right>\n");
116 emit_edit_number(cp, src, 0);
117 printf("</td>\n");
118 for (size_t k = 0; k < attr_name.nstrings; ++k)
119 {
120 const char *aname = attr_name.string[k]->str_text;
121 printf("<td valign=top>");
122 attributes_ty *ap = attributes_list_find(src->attribute, aname);
123 if (ap)
124 html_encode_string(ap->value);
125 printf("</td>\n");
126 }
127 printf("<td valign=top>\n");
128 emit_file_href(cp, src->file_name, "menu");
129 printf("<span class=\"filename\">");
130 html_encode_string(src->file_name);
131 printf("</span></a>");
132 if (src->deleted_by)
133 {
134 printf("<br>\nDeleted by change ");
135 emit_change_href_n(cp->pp, src->deleted_by, "menu");
136 printf("%ld</a>.", src->deleted_by);
137 }
138 if (src->about_to_be_created_by)
139 {
140 printf("<br>\nAbout to be created by change ");
141 emit_change_href_n(cp->pp, src->about_to_be_created_by, "menu");
142 printf("%ld</a>.", src->about_to_be_created_by);
143 }
144 if (src->locked_by)
145 {
146 printf("<br>\nLocked by change ");
147 emit_change_href_n(cp->pp, src->locked_by, "menu");
148 printf("%ld</a>.", src->locked_by);
149 }
150 if (src->about_to_be_copied_by)
151 {
152 printf("<br>\nAbout to be copied by change ");
153 emit_change_href_n(cp->pp, src->about_to_be_copied_by, "menu");
154 printf("%ld</a>.", src->about_to_be_copied_by);
155 }
156 if (src->move)
157 {
158 switch (src->action)
159 {
160 case file_action_create:
161 printf("<br>\nMoved from ");
162 emit_file_href(cp, src->move, "menu");
163 printf("<span class=\"filename\">");
164 html_encode_string(src->move);
165 printf("</span></a>");
166 break;
167
168 case file_action_remove:
169 printf("<br>\nMoved to ");
170 emit_file_href(cp, src->move, "menu");
171 printf("<span class=\"filename\">");
172 html_encode_string(src->move);
173 printf("</span></a>");
174 break;
175
176 case file_action_modify:
177 case file_action_insulate:
178 case file_action_transparent:
179 assert(0);
180 break;
181 }
182 }
183 printf("</td></tr>\n");
184 }
185 printf("<tr class=\"even-group\"><td colspan=4>\n");
186 printf("Listed %ld files.\n", (long)file_num);
187 printf("</td></tr>\n");
188 printf("</table>\n");
189
190 if (!cp->bogus)
191 {
192 cstate_ty *cstate_data = cp->cstate_get();
193 if (cstate_data->state >= cstate_state_being_developed)
194 {
195 printf("<p>\n");
196 printf("You may also be interested in the ");
197 emit_change_href(cp, "file+history");
198 printf("history</a> listing.\n");
199 }
200 }
201 printf("</div>\n");
202
203 printf("<hr>A similar report may be obtained from the command line,\n");
204 printf("with one of\n<blockquote><pre>");
205 if (!cp->bogus)
206 {
207 printf("ael cf -p ");
208 html_encode_string(project_name_get(cp->pp));
209 printf(" -c %ld\n", magic_zero_decode(cp->number));
210 printf("aer cf -p ");
211 html_encode_string(project_name_get(cp->pp));
212 printf(" -c %ld", magic_zero_decode(cp->number));
213 }
214 else
215 {
216 printf("ael pf -p ");
217 html_encode_string(project_name_get(cp->pp));
218 printf("\naer proj_files -p ");
219 html_encode_string(project_name_get(cp->pp));
220 }
221 printf("</pre></blockquote>\n");
222
223 printf("<hr>\n");
224 printf("<p align=center class=\"navbar\">[\n");
225 printf("<a href=\"%s/\">Project List</a> |\n", http_script_name());
226 emit_project_href(cp->pp, "menu");
227 printf("Project Menu</a> |\n");
228 emit_project_href(cp->pp, "changes");
229 printf("Change List</a>\n");
230 if (!cp->bogus)
231 {
232 printf("| ");
233 emit_change_href(cp, "menu");
234 printf("Change Menu</a>\n");
235 }
236 printf("]</p>\n");
237
238 html_footer(0, cp);
239 }
240
241
242 // vim: set ts=8 sw=4 et :
243