Changeset ee52fc


Ignore:
Timestamp:
Sep 15, 2010, 5:15:43 PM (10 years ago)
Author:
rene <just@…>
Branches:
ng_0.6, ng_0.8, ng_0.9
Children:
250d2d
Parents:
b269e7
Message:

get rid of any added headers on uninstallation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/vI_getHeader.js

    rb269e7 ree52fc  
    2222    Contributor(s): Christian Weiske
    2323    Contributor(s): Patrick Brunschwig
     24    Contributor(s): http://xulsolutions.blogspot.com/2006/07/creating-uninstall-script-for.html
     25
    2426 * ***** END LICENSE BLOCK ***** */
    2527
     
    3133* some code copied and adapted from 'enigmail'
    3234* thanks to Patrick Brunschwig <patrick.brunschwig@gmx.net>
     35*/
     36/**
     37* some code copied and adapted from 'http://xulsolutions.blogspot.com/2006/07/creating-uninstall-script-for.html'
     38* thanks to the unknown programmer
    3339*/
    3440
     
    218224        vI_prepareHeader.prefroot.QueryInterface(Components.interfaces.nsIPrefBranch2);
    219225        vI_prepareHeader.prefroot.addObserver("extensions.virtualIdentity.smart_reply_headers", this, false);
     226        vI_prepareHeader.uninstallObserver.register();
    220227        vI_prepareHeader.observer_added = true;
    221228    },
     
    224231        if (!vI_prepareHeader.observer_added) return;
    225232        vI_prepareHeader.prefroot.removeObserver("extensions.virtualIdentity.smart_reply_headers", this);
     233        vI_prepareHeader.uninstallObserver.unregister();
    226234        vI_prepareHeader.observer_added = false;
    227235    },
     
    329337            MsgReload();
    330338        }
    331     }
     339    },
     340
     341//  code adapted from http://xulsolutions.blogspot.com/2006/07/creating-uninstall-script-for.html
     342    uninstallObserver : {
     343        MY_EXTENSION_UUID : "{dddd428e-5ac8-4a81-9f78-276c734f75b8}",
     344        _uninstall : false,
     345        observe : function(subject, topic, data) {
     346            if (topic == "em-action-requested") {
     347                var extension = subject.QueryInterface(Components.interfaces.nsIUpdateItem);
     348
     349                if (extension.id == this.MY_EXTENSION_UUID) {
     350                    if (data == "item-uninstalled") {
     351                        this._uninstall = true;
     352                    } else if (data == "item-cancel-action") {
     353                        this._uninstall = false;
     354                    }
     355                }
     356            } else if (topic == "quit-application-granted") {
     357                if (this._uninstall) {
     358                    /* uninstall stuff. */
     359                    vI_notificationBar.dump("## vI_uninstall: _uninstall \n");
     360                    vI_prepareHeader.removeExtraHeader();
     361                    vI_notificationBar.dump("## vI_uninstall: _uninstall done\n");
     362                }
     363                this.unregister();
     364            }
     365        },
     366        register : function() {
     367            var observerService =
     368            Components.classes["@mozilla.org/observer-service;1"].
     369                getService(Components.interfaces.nsIObserverService);
     370
     371            observerService.addObserver(this, "em-action-requested", false);
     372            observerService.addObserver(this, "quit-application-granted", false);
     373        },
     374        unregister : function() {
     375            var observerService =
     376                Components.classes["@mozilla.org/observer-service;1"].
     377                getService(Components.interfaces.nsIObserverService);
     378
     379            observerService.removeObserver(this,"em-action-requested");
     380            observerService.removeObserver(this,"quit-application-granted");
     381        }
     382    }
    332383}
    333384
     
    335386window.addEventListener("load", function(e) { vI_prepareHeader.init(); }, false);
    336387window.addEventListener("unload", function(e) { vI_prepareHeader.cleanup(); }, false);
     388// window.addEventListener("load", initializeOverlay, false);
Note: See TracChangeset for help on using the changeset viewer.