!import
1 //@line 37 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/base/content/defaultClientDialog.js"
2
3 // this dialog can only be opened if we have a shell service
4
5 var gDefaultClientDialog = {
onLoad
6 onLoad: function ()
7 {
8 var nsIShellService = Components.interfaces.nsIShellService;
9 var shellSvc = Components.classes["@mozilla.org/mail/shell-service;1"]
10 .getService(nsIShellService);
11
12 // initialize the check boxes based on the default app states.
13 var mailCheckbox = document.getElementById('checkMail');
14 var newsCheckbox = document.getElementById('checkNews');
15 var rssCheckbox = document.getElementById('checkRSS');
16
17 mailCheckbox.disabled = shellSvc.isDefaultClient(false, nsIShellService.MAIL);
18 // as an optimization, if we aren't already the default mail client, then pre-check that option
19 // for the user. We'll leave news and RSS alone.
20 mailCheckbox.checked = true;
21 newsCheckbox.checked = newsCheckbox.disabled = shellSvc.isDefaultClient(false, nsIShellService.NEWS);
22 rssCheckbox.checked = rssCheckbox.disabled = shellSvc.isDefaultClient(false, nsIShellService.RSS);
23
24 // read the raw pref value and not shellSvc.shouldCheckDefaultMail
25 var prefs = Components.classes["@mozilla.org/preferences-service;1"]
26 .getService(Components.interfaces.nsIPrefBranch);
27 document.getElementById('checkOnStartup').checked = prefs.getBoolPref("mail.shell.checkDefaultClient");
28 },
29
onAccept
30 onAccept: function()
31 {
32 // for each checked item, if we aren't already the default, make us the default.
33 var nsIShellService = Components.interfaces.nsIShellService;
34 var shellSvc = Components.classes["@mozilla.org/mail/shell-service;1"]
35 .getService(nsIShellService);
36 var appTypes = 0;
37 if (document.getElementById('checkMail').checked && !shellSvc.isDefaultClient(false, nsIShellService.MAIL))
38 appTypes |= nsIShellService.MAIL;
39 if (document.getElementById('checkNews').checked && !shellSvc.isDefaultClient(false, nsIShellService.NEWS))
40 appTypes |= nsIShellService.NEWS;
41 if (document.getElementById('checkRSS').checked && !shellSvc.isDefaultClient(false, nsIShellService.RSS))
42 appTypes |= nsIShellService.RSS;
43
44 if (appTypes)
45 shellSvc.setDefaultClient(false, appTypes);
46
47 shellSvc.shouldCheckDefaultClient = document.getElementById('checkOnStartup').checked;
48 }
49 };