16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# ***** BEGIN LICENSE BLOCK *****
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Version: MPL 1.1/GPL 2.0/LGPL 2.1
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# The contents of this file are subject to the Mozilla Public License Version
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# 1.1 (the "License"); you may not use this file except in compliance with
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# the License. You may obtain a copy of the License at
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# http://www.mozilla.org/MPL/
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Software distributed under the License is distributed on an "AS IS" basis,
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# for the specific language governing rights and limitations under the
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# License.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# The Original Code is Python XPCOM language bindings.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# The Initial Developer of the Original Code is
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# ActiveState Tool Corp.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Portions created by the Initial Developer are Copyright (C) 2001
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# the Initial Developer. All Rights Reserved.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Contributor(s):
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Mark Hammond <mhammond@skippinet.com.au> (original author)
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# Alternatively, the contents of this file may be used under the terms of
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# either the GNU General Public License Version 2 or later (the "GPL"), or
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# in which case the provisions of the GPL or the LGPL are applicable instead
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# of those above. If you wish to allow use of your version of this file only
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# under the terms of either the GPL or the LGPL, and not to allow others to
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# use your version of this file under the terms of the MPL, indicate your
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# decision by deleting the provisions above and replace them with the notice
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# and other provisions required by the GPL or the LGPL. If you do not delete
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# the provisions above, a recipient may use your version of this file under
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# the terms of any one of the MPL, the GPL or the LGPL.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# ***** END LICENSE BLOCK *****
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# regxpcom.py - basically the standard regxpcom.cpp ported to Python.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync# In general, you should use regxpcom.exe instead of this.
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncfrom xpcom import components, _xpcom
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncfrom xpcom.client import Component
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncimport sys
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncimport os
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncregistrar = Component(_xpcom.GetComponentRegistrar(),
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync components.interfaces.nsIComponentRegistrar)
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncdef ProcessArgs(args):
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync unregister = 0
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync for arg in args:
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync spec = components.classes['@mozilla.org/file/local;1'].createInstance()
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync spec = spec.QueryInterface(components.interfaces.nsILocalFile)
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync spec.initWithPath(os.path.abspath(arg))
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync if arg == "-u":
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync registrar.autoUnregister(spec)
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync print "Successfully unregistered", spec.path
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync else:
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync registrar.autoRegister(spec)
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync print "Successfully registered", spec.path
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncif len(sys.argv) < 2:
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync registrar.autoRegister( None)
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsyncelse:
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync ProcessArgs(sys.argv[1:])
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync
16a8d09569a2ebd598cef72fa605be6fb4563607vboxsync#_xpcom.NS_ShutdownXPCOM()