|
|
@ -155,26 +155,35 @@ var pEpHdrView = { |
|
|
|
pEpController.log.debug("pEpHdrView: init()"); |
|
|
|
this.win = win; |
|
|
|
this.localeMessagesMap = localeMessagesMap; |
|
|
|
|
|
|
|
// Step 1: UI.
|
|
|
|
this.initUI(win); |
|
|
|
|
|
|
|
pEpController.init(localeMessagesMap); |
|
|
|
// Step 2: pEp column.
|
|
|
|
columnOverlay.init(win); |
|
|
|
|
|
|
|
this.tb_CanDetachAttachments = this.win.CanDetachAttachments; |
|
|
|
|
|
|
|
// Usually the column handler is added when the window loads.
|
|
|
|
// In our setup it's added later and we may miss the first notification.
|
|
|
|
// So we fire one ourserves.
|
|
|
|
// So we fire one ourselves.
|
|
|
|
if (win.gDBView && win.document.documentElement.getAttribute("windowtype") == "mail:3pane") { |
|
|
|
Services.obs.notifyObservers(null, "MsgCreateDBView"); |
|
|
|
} |
|
|
|
|
|
|
|
// Step 3: Attachment hack.
|
|
|
|
this.tb_CanDetachAttachments = this.win.CanDetachAttachments; |
|
|
|
|
|
|
|
// Step 4: Header listener.
|
|
|
|
this.headerListener = { |
|
|
|
onStartHeaders: this.onStartHeaders.bind(this), |
|
|
|
onEndHeaders: () => {}, |
|
|
|
}; |
|
|
|
win.gMessageListeners.push(this.headerListener); |
|
|
|
|
|
|
|
// Step 5: trust changes observer.
|
|
|
|
Services.obs.addObserver(this, "pEp-trust-changed"); |
|
|
|
|
|
|
|
// Step 6: Finally the controller. This can fail if no adapter is running.
|
|
|
|
pEpController.init(localeMessagesMap); |
|
|
|
}, |
|
|
|
|
|
|
|
openOptions() { |
|
|
@ -216,19 +225,31 @@ var pEpHdrView = { |
|
|
|
|
|
|
|
destroy() { |
|
|
|
pEpController.log.debug("pEpHdrView: destroy()"); |
|
|
|
|
|
|
|
// Undo everything we did in step 1 to 6 during `init()`.
|
|
|
|
// Step 1: UI.
|
|
|
|
const privacyNode = this.win.document.getElementById(TAG_PRIVACY_NODE_ID); |
|
|
|
if (privacyNode) privacyNode.remove(); |
|
|
|
Services.obs.removeObserver(this, "pEp-trust-changed"); |
|
|
|
|
|
|
|
// Step 2: pEp column.
|
|
|
|
columnOverlay.destroy(); |
|
|
|
|
|
|
|
// Step 3: Attachment hack.
|
|
|
|
this.win.CanDetachAttachments = this.tb_CanDetachAttachments; |
|
|
|
|
|
|
|
// Step 4: Header listener.
|
|
|
|
for (let i = 0; i < this.win.gMessageListeners.length; i++) { |
|
|
|
if (this.win.gMessageListeners[i] === this.headerListener) { |
|
|
|
this.win.gMessageListeners.splice(i, 1); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
columnOverlay.destroy(); |
|
|
|
pEpController.shutdown(); |
|
|
|
|
|
|
|
this.win.CanDetachAttachments = this.tb_CanDetachAttachments; |
|
|
|
// Step 5: trust changes observer.
|
|
|
|
Services.obs.removeObserver(this, "pEp-trust-changed"); |
|
|
|
|
|
|
|
// Step 6: Finally the controller.
|
|
|
|
pEpController.shutdown(); |
|
|
|
}, |
|
|
|
|
|
|
|
observe(aSubject, aTopic, aData) { |
|
|
|