|
1 // //////////////////////////////////////////////////////////////////////////// |
|
2 // Symbian Foundation Example Code |
|
3 // |
|
4 // This software is in the public domain. No copyright is claimed, and you |
|
5 // may use it for any purpose without license from the Symbian Foundation. |
|
6 // No warranty for any purpose is expressed or implied by the authors or |
|
7 // the Symbian Foundation. |
|
8 // //////////////////////////////////////////////////////////////////////////// |
|
9 |
|
10 var bugzillaTableStyle = "bugzilla"; |
|
11 var mypackage; |
|
12 var open_reader; |
|
13 var proposed_reader; |
|
14 var features_reader; |
|
15 var newtext ="New Bugs"; |
|
16 var proposedtext ="Proposed Fixes"; |
|
17 var featurestext = "My Feature Backlog"; |
|
18 var forum_reader; |
|
19 var open_presenter; |
|
20 var features_presenter; |
|
21 var proposed_presenter; |
|
22 var mybuilds; |
|
23 |
|
24 // Bugzilla access |
|
25 |
|
26 function BugzillaSearchPanel(parent) { |
|
27 |
|
28 //ListView.prototype.init.call(this, null, null); |
|
29 |
|
30 // add the banner and 'title bar' - avoids the caption bug |
|
31 this.openButton = new NavigationButton (1,"right.gif", newtext); |
|
32 this.ProposedButton = new NavigationButton (1,"right.gif", proposedtext); |
|
33 this.featuresButton = new NavigationButton (1,"right.gif", featurestext); |
|
34 this.BuildButton = new NavigationButton (1,"right.gif", "Package Build Results"); |
|
35 this.ForumButton = new NavigationButton (1,"right.gif", "My Discussion Forum"); |
|
36 |
|
37 |
|
38 |
|
39 var self = this; |
|
40 |
|
41 mylabel = new Label ("packagelabel",null); |
|
42 this.addControl (mylabel); |
|
43 |
|
44 this.openButton.addEventListener("ActionPerformed", function(){ |
|
45 open_reader.update(true); |
|
46 open_reader.show(); |
|
47 }); |
|
48 |
|
49 this.addControl(this.openButton); |
|
50 |
|
51 this.ProposedButton.addEventListener("ActionPerformed", function(){ |
|
52 |
|
53 proposed_reader.update(true); |
|
54 proposed_reader.show(); |
|
55 }); |
|
56 |
|
57 this.addControl(this.ProposedButton); |
|
58 |
|
59 this.featuresButton.addEventListener("ActionPerformed", function(){ |
|
60 features_reader.update(true); |
|
61 features_reader.show(); |
|
62 }); |
|
63 |
|
64 this.addControl(this.featuresButton); |
|
65 |
|
66 mybuilds = new buildview(this); |
|
67 |
|
68 this.BuildButton.addEventListener("ActionPerformed", function(){ |
|
69 //openURL (buildresultsUrl + Packageid); |
|
70 mybuilds.show(); |
|
71 |
|
72 |
|
73 }); |
|
74 |
|
75 this.addControl(this.BuildButton); |
|
76 this.ForumButton.addEventListener("ActionPerformed", function(){ |
|
77 self.readforum(); |
|
78 }); |
|
79 |
|
80 this.addControl(this.ForumButton); |
|
81 |
|
82 mypackage=Packageid; |
|
83 |
|
84 |
|
85 |
|
86 //self.update(true); |
|
87 |
|
88 } |
|
89 |
|
90 |
|
91 BugzillaSearchPanel.prototype = new ListView("bugzillaview","<img src=logo.png>"); |
|
92 |
|
93 BugzillaSearchPanel.prototype.update = function(myflag){ |
|
94 var self = this; |
|
95 |
|
96 if (myflag) { |
|
97 self.openbugs(); |
|
98 self.proposedbugs(); |
|
99 self.features(); |
|
100 mylabel.setText(Packageid); |
|
101 mybuilds.update(true); |
|
102 } |
|
103 } |
|
104 |
|
105 //http://developer.symbian.org/bugs/buglist.cgi?bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&content=test&field-1-0-0=bug_status&field-1-1-0=product&field-1-2-0=content&product=classicui&query_format=specific&remaction=&type-1-0-0=anyexact&type-1-1-0=anyexact&type-1-2-0=matches&value-1-0-0=UNCONFIRMED%2CNEW%2CASSIGNED&value-1-1-0=classicui&value-1-2-0=test&title=Bug%20List&ctype=atom |
|
106 BugzillaSearchPanel.prototype.bugzillaSearchClicked = function() { |
|
107 // create the RssReader for bugzilla |
|
108 if(!Packageid){return;} |
|
109 var searchString = Packageid; |
|
110 var title = "Bugzilla: " + searchString; |
|
111 var url = symbianOrgBaseUrl + "/bugs/buglist.cgi?" |
|
112 + "bug_status=NEW" |
|
113 + "&field-1-0-0=bug_status&field0-0-0=product&" |
|
114 + "&query_format=advanced&remaction=&type-1-0-0=anyexact" |
|
115 + "&type0-0-0=substring&type0-0-3=substring" |
|
116 + "&value-1-0-0=NEW" |
|
117 + "&value0-0-0=" + searchString |
|
118 + "&title=Bug List&ctype=atom"; |
|
119 var reader = new RssReader(title, url, new BugzillaFeedPresenter(null), this, parseBugzillaFeed); |
|
120 reader.show(); |
|
121 } |
|
122 BugzillaSearchPanel.prototype.openbugs = function() { |
|
123 // create the RssReader for bugzilla |
|
124 if(!Packageid){return;} |
|
125 mypackage=Packageid; |
|
126 var title = newtext + " : " + mypackage; |
|
127 var url = symbianOrgBaseUrl + "/bugs/buglist.cgi?" |
|
128 + "bug_file_loc=&bug_file_loc_type=allwordssubstr&bug_id=&bug_status=NEW&bug_severity=Critical&bug_severity=Major&bug_severity=normal&bug_severity=Minor&bug_severity=enhancement" |
|
129 + "&bugidtype=include&chfieldfrom=&chfieldto=Now&chfieldvalue=&deadlinefrom=&deadlineto=&email1=&email2=&emailassigned_to1=1" |
|
130 + "&emailassigned_to2=1&emailcc2=1&emailreporter2=1&emailtype1=substring&emailtype2=substring&field-1-0-0=product&field-1-1-0=bug_status&field-1-2-0=bug_severity&field0-0-0=noop&keywords=&keywords_type=allwords&long_desc=&long_desc_type=substring" |
|
131 + "&product=" + mypackage |
|
132 + "&query_format=advanced&remaction=&short_desc=&short_desc_type=allwordssubstr&" |
|
133 + "type-1-0-0=anyexact" |
|
134 + "&type-1-2-0=anyexact" |
|
135 + "&type-1-1-0=anyexact&type0-0-0=noop&" |
|
136 + "value-1-0-0=" + mypackage |
|
137 + "&value-1-2-0=critical&Cmajor&normal&minor&enhancement" |
|
138 + "&value-1-1-0=NEW" |
|
139 + "&value0-0-0=&title=Bug%20List&ctype=atom"; |
|
140 open_presenter=new BugzillaFeedPresenter(null); |
|
141 open_reader = new RssReader(title, url, open_presenter, this, parseBugzillaFeed); |
|
142 open_reader.UpdateButton = this.openButton; |
|
143 open_reader.ButtonText=newtext; |
|
144 open_reader.update(true); |
|
145 |
|
146 } |
|
147 BugzillaSearchPanel.prototype.proposedbugs = function() { |
|
148 // create the RssReader for bugzilla |
|
149 if(!Packageid){return;} |
|
150 mypackage=Packageid; |
|
151 var title = proposedtext + " : " + mypackage; |
|
152 var url = symbianOrgBaseUrl + "/bugs/buglist.cgi?" |
|
153 + "bug_file_loc=&bug_file_loc_type=allwordssubstr&bug_id=&bug_status=Proposed" |
|
154 + "&bugidtype=include&chfieldfrom=&chfieldto=Now&chfieldvalue=&deadlinefrom=&deadlineto=&email1=&email2=&emailassigned_to1=1" |
|
155 + "&emailassigned_to2=1&emailcc2=1&emailreporter2=1&emailtype1=substring&emailtype2=substring&field-1-0-0=product&field-1-1-0=bug_status&field-1-2-0=bug_severity&field0-0-0=noop&keywords=&keywords_type=allwords&long_desc=&long_desc_type=substring" |
|
156 + "&product=" + mypackage |
|
157 + "&query_format=advanced&remaction=&short_desc=&short_desc_type=allwordssubstr&" |
|
158 + "type-1-0-0=anyexact" |
|
159 + "&type-1-2-0=anyexact" |
|
160 + "&type-1-1-0=anyexact&type0-0-0=noop&" |
|
161 + "value-1-0-0=" + mypackage |
|
162 + "&value-1-2-0=critical%2Cmajor%2Cnormal%2Cminor%2Cenhancement" |
|
163 + "&value-1-1-0=PROPOSED" |
|
164 + "&value0-0-0=&title=Bug%20List&ctype=atom"; |
|
165 proposed_presenter=new BugzillaFeedPresenter(null); |
|
166 proposed_reader = new RssReader(title, url, proposed_presenter, this, parseBugzillaFeed); |
|
167 proposed_reader.UpdateButton = this.ProposedButton; |
|
168 proposed_reader.ButtonText=proposedtext; |
|
169 proposed_reader.update(true); |
|
170 |
|
171 } |
|
172 |
|
173 BugzillaSearchPanel.prototype.features = function() { |
|
174 // create the RssReader for bugzilla |
|
175 if(!Packageid){return;} |
|
176 mypackage=Packageid; |
|
177 var title = featurestext + " : " + mypackage; |
|
178 var url = symbianOrgBaseUrl + "/bugs/buglist.cgi?" |
|
179 + "bug_file_loc=&bug_file_loc_type=allwordssubstr&bug_id=&bug_status=NEW&bug_status=ASSIGNED&bug_status=PROPOSED&bug_severity=Feature" |
|
180 + "&bugidtype=include&chfieldfrom=&chfieldto=Now&chfieldvalue=&deadlinefrom=&deadlineto=&email1=&email2=&emailassigned_to1=1" |
|
181 + "&emailassigned_to2=1&emailcc2=1&emailreporter2=1&emailtype1=substring&emailtype2=substring&field-1-0-0=product&field-1-1-0=bug_status&field-1-2-0=bug_severity&field0-0-0=noop&keywords=&keywords_type=allwords&long_desc=&long_desc_type=substring" |
|
182 + "&product=" + mypackage |
|
183 + "&query_format=advanced&remaction=&short_desc=&short_desc_type=allwordssubstr&" |
|
184 + "type-1-0-0=anyexact" |
|
185 + "&type-1-2-0=anyexact" |
|
186 + "&type-1-1-0=anyexact&type0-0-0=noop&" |
|
187 + "value-1-0-0=" + mypackage |
|
188 + "&value-1-2-0=Feature" |
|
189 + "&value-1-1-0=NEW&PROPOSED&ASSIGNED" |
|
190 + "&value0-0-0=&title=Bug%20List&ctype=atom"; |
|
191 features_presenter=new BugzillaFeedPresenter(null); |
|
192 features_reader = new RssReader(title, url, features_presenter, this, parseBugzillaFeed); |
|
193 features_reader.UpdateButton = this.featuresButton; |
|
194 features_reader.ButtonText=featurestext; |
|
195 features_reader.update(true); |
|
196 |
|
197 } |
|
198 |
|
199 BugzillaSearchPanel.prototype.readforum = function() { |
|
200 |
|
201 if (!myforumid) { |
|
202 var forum_choose = new RssReader(mypackage, forumsListUrl + "18", new ForumsSettingsFeedPresenter(null), bugzilla, forumListResponseParser); |
|
203 forum_choose.show(); |
|
204 } |
|
205 else { |
|
206 forum_reader = new RssReader(myforumtitle, forumFeedURL + forumsForumSpecQuery + myforumid, new ThreadListFeedPresenter(null), bugzilla, null); |
|
207 forum_reader.show(); |
|
208 } |
|
209 } |
|
210 |
|
211 function parseBugzillaFeed(broker, responseStatus, xmlDoc) { |
|
212 if (responseStatus == 200 && xmlDoc != null) { |
|
213 // node ref for iterating |
|
214 var node; |
|
215 |
|
216 // for compatibility with rss |
|
217 var lastModified = new Date(); |
|
218 |
|
219 // init result items array |
|
220 var items = []; |
|
221 |
|
222 var itemElements = xmlDoc.getElementsByTagName("entry"); |
|
223 |
|
224 for (var i = 0; i < itemElements.length; i++) { |
|
225 // iterate through child nodes of this item and gather |
|
226 // all the data we need for a feed item |
|
227 var title = null; |
|
228 var date = null; |
|
229 var description = null; |
|
230 var url = null; |
|
231 var author = null; |
|
232 var bugid; |
|
233 node = itemElements[i].firstChild; |
|
234 while (node != null) { |
|
235 if (node.nodeType == Node.ELEMENT_NODE) { |
|
236 if (node.nodeName == "title") { |
|
237 // item title |
|
238 title = getTextOfNode(node); |
|
239 if ( title.length > 48) { |
|
240 title = title.substring(0,45) + "..."; |
|
241 } |
|
242 } else if (node.nodeName == "updated" ) { |
|
243 // item publishing date |
|
244 date = getTextOfNode(node); |
|
245 } else if (node.nodeName == "summary" && !this.ignoreContent ) { |
|
246 // item description |
|
247 description = getTextOfNode(node); |
|
248 } else if (node.nodeName == "link") { |
|
249 // link URL |
|
250 url = node.getAttribute("href"); |
|
251 // extract bug id |
|
252 var ind = url.indexOf("?id="); |
|
253 if ( ind != -1 ) { |
|
254 bugid = url.substring(ind + 4); |
|
255 url = symbianOrgBaseUrl + "/bugtracker/show_bug.cgi?ctype=xml&id="+bugid; |
|
256 } |
|
257 } else if (node.nodeName == "author" ) { |
|
258 author = getTextOfNode(node); |
|
259 } |
|
260 } |
|
261 node = node.nextSibling; |
|
262 } |
|
263 items.push({ title: title, date: date, description: description, url: url, author: author }); |
|
264 } |
|
265 |
|
266 // update was completed successfully |
|
267 return { status: "ok", lastModified: lastModified, items: items }; |
|
268 } else { |
|
269 // update failed |
|
270 return { status: "error" }; |
|
271 } |
|
272 } |
|
273 |
|
274 |
|
275 // Implementation of FeedPresenter that shows feed as a clickable |
|
276 // button and shows feed entry title as label |
|
277 function BugzillaFeedPresenter(rssreader) { |
|
278 ButtonFeedPresenter.prototype.init.call(this, rssreader); |
|
279 } |
|
280 |
|
281 // BugzillaFeedPresenter is a subclass of ButtonFeedPresenter |
|
282 BugzillaFeedPresenter.prototype = new ButtonFeedPresenter(null); |
|
283 |
|
284 // Handle the button-press |
|
285 BugzillaFeedPresenter.prototype.feedClicked = function(event){ |
|
286 var clickedButton = event.source; |
|
287 var id = clickedButton.id; |
|
288 var url = this.items[id].url; |
|
289 var presenter = new HtmlFeedPresenter(null); |
|
290 presenter.expanded = true; |
|
291 var reader = new RssReader(this.items[id].title, url, |
|
292 presenter, uiManager.currentView, parseBugzillaBugFeed); |
|
293 reader.show(); |
|
294 } |
|
295 |
|
296 |
|
297 function parseBugzillaBugFeed(broker, responseStatus, xmlDoc) { |
|
298 if (responseStatus == 200 && xmlDoc != null) { |
|
299 // node ref for iterating |
|
300 var node; |
|
301 |
|
302 // for compatibility with rss |
|
303 var lastModified = new Date(); |
|
304 |
|
305 // init result items array |
|
306 var items = []; |
|
307 |
|
308 var itemElements = xmlDoc.getElementsByTagName("bug"); |
|
309 |
|
310 for (var i = 0; i < itemElements.length; i++) { |
|
311 // iterate through child nodes of this item and gather |
|
312 // all the data we need for a feed item |
|
313 var title = null; |
|
314 var date = null; |
|
315 var url = null; |
|
316 var author = null; |
|
317 var bugid = null; |
|
318 var creationTime = "Not specified"; |
|
319 var product = "Not specified"; |
|
320 var component = "Not specified"; |
|
321 var classification = "Not specified"; |
|
322 var op_sys = "Not specified"; |
|
323 var bug_status = "Not specified"; |
|
324 var bug_file_loc = "Not specified"; |
|
325 var priority = "Not specified"; |
|
326 var severity = "Not specified"; |
|
327 var target_milestone = "Not specified"; |
|
328 var version = "Not specified"; |
|
329 var platform = "Not specified"; |
|
330 var assignedToName = "Not specified"; |
|
331 var solutionDetails = "Not specified"; |
|
332 var keywords = "None"; |
|
333 var longdesc = ""; |
|
334 var shortDesc = ""; |
|
335 var bugid = ""; |
|
336 var buglink = ""; |
|
337 |
|
338 node = itemElements[i].firstChild; |
|
339 while (node != null) { |
|
340 if (node.nodeType == Node.ELEMENT_NODE) { |
|
341 if (node.nodeName == "bug_id") { |
|
342 // item title |
|
343 bugid = "Bug " + getTextOfNode(node); |
|
344 buglink = bugUrl + getTextOfNode(node); |
|
345 } else if (node.nodeName == "updated" ) { |
|
346 // item publishing date |
|
347 date = getTextOfNode(node); |
|
348 } else if (node.nodeName == "creation_ts" ) { |
|
349 // item publishing date |
|
350 creationTime = getTextOfNode(node); |
|
351 } else if (node.nodeName == "short_desc" && !this.ignoreContent ) { |
|
352 // item description |
|
353 title = getTextOfNode(node); |
|
354 } else if (node.nodeName == "reporter" ) { |
|
355 author = getTextOfNode(node); |
|
356 } else if (node.nodeName == "product" ) { |
|
357 product = getTextOfNode(node); |
|
358 } else if (node.nodeName == "component" ) { |
|
359 component = getTextOfNode(node); |
|
360 } else if (node.nodeName == "classification" ) { |
|
361 classification = getTextOfNode(node); |
|
362 } else if (node.nodeName == "version" ) { |
|
363 version = getTextOfNode(node); |
|
364 } else if (node.nodeName == "op_sys" ) { |
|
365 op_sys = getTextOfNode(node); |
|
366 } else if (node.nodeName == "bug_status" ) { |
|
367 bug_status = getTextOfNode(node); |
|
368 } else if (node.nodeName == "bug_file_loc" ) { |
|
369 bug_file_loc = getTextOfNode(node); |
|
370 } else if (node.nodeName == "priority" ) { |
|
371 priority = getTextOfNode(node); |
|
372 } else if (node.nodeName == "bug_severity" ) { |
|
373 severity = getTextOfNode(node); |
|
374 } else if (node.nodeName == "target_milestone" ) { |
|
375 target_milestone = getTextOfNode(node); |
|
376 } else if (node.nodeName == "platform" ) { |
|
377 platform = getTextOfNode(node); |
|
378 } else if (node.nodeName == "cf_solutiondetails" ) { |
|
379 solutionDetails = getTextOfNode(node); |
|
380 } else if (node.nodeName == "keywords" ) { |
|
381 keywords = getTextOfNode(node); |
|
382 } else if (node.nodeName == "long_desc" ) { |
|
383 longdesc += "<br><table style="+bugzillaTableStyle+">"; |
|
384 var ld_nodes = node.childNodes; |
|
385 for ( var tmp = 0 ; tmp < ld_nodes.length ; tmp++ ) { |
|
386 longdesc += "<tr><td>" |
|
387 + getTextOfNode(ld_nodes[tmp]) + "</td></tr>"; |
|
388 } |
|
389 longdesc += "</table>"; |
|
390 } else if (node.nodeName == "assigned_to" ) { |
|
391 assignedToName = getTextOfNode(node); |
|
392 } |
|
393 } |
|
394 node = node.nextSibling; |
|
395 } |
|
396 // format the description |
|
397 |
|
398 var mybuf = "<br><div class=\"FeedItemLink\">"; |
|
399 mybuf += "<a href=\"JavaScript:void(0)\" onclick=\"openURL('" + buglink + "'); return false;\">"; |
|
400 mybuf += "Click here to edit..."; |
|
401 mybuf += "</a>"; |
|
402 mybuf += "</div><br>"; |
|
403 var description = "<table style="+bugzillaTableStyle+">"; |
|
404 description += "<tr><td>Reported:" + "</td><td>" + creationTime + "</td></tr>"; |
|
405 description += "<tr><td>Product:" + "</td><td>" + product + "</td></tr>"; |
|
406 description += "<tr><td>Component:" + "</td><td>" + component + "</td></tr>"; |
|
407 description += "<tr><td>Classification:" + "</td><td>" + classification + "</td></tr>"; |
|
408 // description += "<tr><td>Operating system:" + "</td><td>" + op_sys + "</td></tr>"; |
|
409 description += "<tr><td>Status:" + "</td><td>" + bug_status + "</td></tr>"; |
|
410 description += "<tr><td>Priority:" + "</td><td>" + priority + "</td></tr>"; |
|
411 description += "<tr><td>Severity:" + "</td><td>" + severity + "</td></tr>"; |
|
412 description += "<tr><td>Version:" + "</td><td>" + version + "</td></tr>"; |
|
413 // description += "<tr><td>Platform:" + "</td><td>" + platform + "</td></tr>"; |
|
414 description += "<tr><td>Reported by:" + "</td><td>" + author + "</td></tr>"; |
|
415 description += "<tr><td>Assigned to:" + "</td><td>" + assignedToName + "</td></tr>"; |
|
416 // description += "<tr><td>Target milestone:" + "</td><td>" + target_milestone + "</td></tr>"; |
|
417 // description += "<tr><td>File location:" + "</td><td>" + bug_file_loc + "</td></tr>"; |
|
418 description += "<tr><td>keywords:" + "</td><td>" + keywords + "</td></tr>"; |
|
419 description += "</table>"; |
|
420 |
|
421 description += mybuf ; |
|
422 |
|
423 description += "<table style="+bugzillaTableStyle+">"; |
|
424 description += "<tr><td>Description:" + "</td></tr>"; |
|
425 description += "<tr><td>" + longdesc + "</td></tr>"; |
|
426 description += "</table>"; |
|
427 |
|
428 description += "<table style="+bugzillaTableStyle+">"; |
|
429 description += "<tr><td>Solution details:" + "</td></tr>"; |
|
430 description += "<tr><td>" + solutionDetails + "</td></tr>"; |
|
431 description += "</table>"; |
|
432 |
|
433 items.push({ title: title, date: date, description: description, url: null, author: author }); |
|
434 } |
|
435 |
|
436 // update was completed successfully |
|
437 return { status: "ok", lastModified: lastModified, items: items }; |
|
438 } else { |
|
439 // update failed |
|
440 return { status: "error" }; |
|
441 } |
|
442 } |
|
443 |