!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 //@line 38 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/components/preferences/general.js"
2
3 var gGeneralPane = {
4 mPane: null,
5 mStartPageUrl: "",
6
init
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
7 init: function ()
8 {
9 this.mPane = document.getElementById("paneGeneral");
10 this.startPageCheck();
11
12 this.updatePlaySound();
13 },
14
15 //@line 52 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/components/preferences/general.js"
16 /**
17 * Checks whether Thunderbird is currently registered with the operating
18 * system as the default app for mail, rss and news. If Thunderbird is not currently the
19 * default app, the user is given the option of making it the default for each type;
20 * otherwise, the user is informed that Thunderbird is already the default.
21 */
checkDefaultNow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
22 checkDefaultNow: function (aAppType)
23 {
24 var nsIShellService = Components.interfaces.nsIShellService;
25 var shellSvc;
26 try {
27 shellSvc = Components.classes["@mozilla.org/mail/shell-service;1"].getService(nsIShellService);
28 } catch (ex) { return; }
29
30 // if we are already the default for all the types we handle, then alert the user.
31 if (shellSvc.isDefaultClient(false, nsIShellService.MAIL | nsIShellService.NEWS | nsIShellService.RSS))
32 {
33 var brandBundle = document.getElementById("bundleBrand");
34 var shellBundle = document.getElementById("bundleShell");
35 var brandShortName = brandBundle.getString("brandShortName");
36 var promptTitle = shellBundle.getString("alreadyDefaultClientTitle");
37 var promptMessage;
38 const IPS = Components.interfaces.nsIPromptService;
39 var psvc = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
40 .getService(IPS);
41
42 promptMessage = shellBundle.getFormattedString("alreadyDefault", [brandShortName]);
43 psvc.alert(window, promptTitle, promptMessage);
44 }
45 else
46 {
47 // otherwise, bring up the default client dialog
48 window.openDialog("chrome://messenger/content/defaultClientDialog.xul", "Default Client",
49 "modal,centerscreen,chrome,resizable=no");
50 }
51 },
52 //@line 89 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/components/preferences/general.js"
53
startPageCheck
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
54 startPageCheck: function()
55 {
56 document.getElementById("mailnewsStartPageUrl").disabled = !document.getElementById("mailnewsStartPageEnabled").checked;
57 },
58
59 /**
60 * Restores the default start page as the user's start page
61 */
restoreDefaultStartPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
62 restoreDefaultStartPage: function()
63 {
64 var startPage = document.getElementById("mailnews.start_page.url");
65 startPage.value = startPage.defaultValue;
66 if (startPage.hasUserValue)
67 startPage.reset();
68 },
69
70 /**
71 * Returns a formatted url corresponding to the value of mailnews.start_page.url
72 * Stores the original value of mailnews.start_page.url
73 */
readStartPageUrl
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
74 readStartPageUrl: function()
75 {
76 var pref = document.getElementById("mailnews.start_page.url");
77 this.mStartPageUrl = pref.value;
78 var formatter = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"].
79 getService(Components.interfaces.nsIURLFormatter);
80 return formatter.formatURL(this.mStartPageUrl);
81 },
82
83 /**
84 * Returns the value of the mailnews start page url represented by the UI.
85 * If the url matches the formatted version of our stored value, then
86 * return the unformatted url.
87 */
writeStartPageUrl
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
88 writeStartPageUrl: function()
89 {
90 var startPage = document.getElementById('mailnewsStartPageUrl');
91 var formatter = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"].
92 getService(Components.interfaces.nsIURLFormatter);
93 return formatter.formatURL(this.mStartPageUrl) == startPage.value ? this.mStartPageUrl : startPage.value;
94 },
95
customizeMailAlert
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
96 customizeMailAlert: function()
97 {
98 document.documentElement
99 .openSubDialog("chrome://messenger/content/preferences/notifications.xul",
100 "", null);
101 },
102
convertURLToLocalFile
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
103 convertURLToLocalFile: function(aFileURL)
104 {
105 // convert the file url into a nsILocalFile
106 if (aFileURL)
107 {
108 var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
109 var fph = ios.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
110 return fph.getFileFromURLSpec(aFileURL);
111 }
112 else
113 return null;
114 },
115
readSoundLocation
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
116 readSoundLocation: function()
117 {
118 var soundUrlLocation = document.getElementById("soundUrlLocation");
119 soundUrlLocation.value = document.getElementById("mail.biff.play_sound.url").value;
120 if (soundUrlLocation.value)
121 {
122 soundUrlLocation.label = this.convertURLToLocalFile(soundUrlLocation.value).leafName;
123 soundUrlLocation.image = "moz-icon://" + soundUrlLocation.label + "?size=16";
124 }
125 return undefined;
126 },
127
previewSound
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
128 previewSound: function ()
129 {
130 sound = Components.classes["@mozilla.org/sound;1"].createInstance(Components.interfaces.nsISound);
131
132 var soundLocation;
133 soundLocation = document.getElementById('soundType').value == 1 ?
134 document.getElementById('soundUrlLocation').value : "_moz_mailbeep"
135
136 if (soundLocation.indexOf("file://") == -1)
137 sound.playSystemSound(soundLocation);
138 else
139 {
140 var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
141 sound.play(ioService.newURI(soundLocation, null, null));
142 }
143 },
144
browseForSoundFile
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
145 browseForSoundFile: function ()
146 {
147 const nsIFilePicker = Components.interfaces.nsIFilePicker;
148 var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
149
150 // if we already have a sound file, then use the path for that sound file
151 // as the initial path in the dialog.
152 var localFile = this.convertURLToLocalFile(document.getElementById('soundUrlLocation').value);
153 if (localFile)
154 fp.displayDirectory = localFile;
155
156 // XXX todo, persist the last sound directory and pass it in
157 fp.init(window, document.getElementById("bundlePreferences").getString("soundFilePickerTitle"), nsIFilePicker.modeOpen);
158 fp.appendFilter("*.wav", "*.wav");
159
160 var ret = fp.show();
161 if (ret == nsIFilePicker.returnOK)
162 {
163 // convert the nsILocalFile into a nsIFile url
164 document.getElementById("mail.biff.play_sound.url").value = fp.fileURL.spec;
165 this.readSoundLocation(); // XXX We shouldn't have to be doing this by hand
166 this.updatePlaySound();
167 }
168 },
169
updatePlaySound
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
170 updatePlaySound: function()
171 {
172 // update the sound type radio buttons based on the state of the play sound checkbox
173 var soundsDisabled = !document.getElementById('newMailNotification').checked;
174 var soundTypeEl = document.getElementById('soundType');
175 soundTypeEl.disabled = soundsDisabled;
176 document.getElementById('browseForSound').disabled = soundsDisabled || soundTypeEl.value != 1;
177 document.getElementById('playSound').disabled = soundsDisabled || soundTypeEl.value != 1;
178 }
179 };