Sophie

Sophie

distrib > Mandriva > 9.0 > i586 > by-pkgid > 738a681b5c2e2fed80f2ba9a5506a4b5 > files > 54

OpenOffice.org-1.0.1-9mdk.src.rpm

/*  Create %{_libdir}/openoffice/share/config/registry/cache
 *
 *  Copyright 2002 by Red Hat, Inc.
 *  Written by Jakub Jelinek <jakub@redhat.com>.
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 ************************************************************************/

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <string.h>
#include <tools/svwin.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <registry/registry.hxx>
#include <vcl/system.hxx>
#include <vcl/wrkwin.hxx>
#include <tools/config.hxx>
#include <vos/mutex.hxx>
#include <osl/file.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/registry/XSimpleRegistry.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <cppuhelper/servicefactory.hxx>

using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::registry;
using namespace ::com::sun::star::beans;
using namespace ::cppu;

int main (int argc, char **argv)
{
  if (argc < 4)
    {
      fputs ("Usage: createcache file:///PATH/applicat.rdb REGISTRY XML_FILE_NAME\n", stderr);
      _exit (10);
    }

  ::rtl::OUString regURL = ::rtl::OUString::createFromAscii (argv[1]);
  Reference <XMultiServiceFactory> xORB = createRegistryServiceFactory (regURL, sal_True);
  if (!xORB.is ())
    {
      fputs ("Failed to create ORB\n", stderr);
      _exit (1);
    }

  Reference <XMultiServiceFactory> xCfgProvider;
  try {
    Sequence <Any> aCPArgs (2);
    Any aAny;

    aAny <<= ::rtl::OUString::createFromAscii ("setup");
    PropertyValue aPropertyUser = PropertyValue (::rtl::OUString::createFromAscii ("servertype"), -1, aAny,
						 PropertyState_DIRECT_VALUE);
    aCPArgs[0] <<= aPropertyUser;

    ::rtl::OUString sSourcePath = ::rtl::OUString::createFromAscii (argv[2]);
    aAny <<= sSourcePath;
    aPropertyUser = PropertyValue (::rtl::OUString::createFromAscii ("sourcepath"), -1, aAny,
				  PropertyState_DIRECT_VALUE);
    aCPArgs[1] <<= aPropertyUser;

    ::rtl::OUString provStr = ::rtl::OUString::createFromAscii ("com.sun.star.configuration.AdministrationProvider");
    xCfgProvider = Reference <XMultiServiceFactory> (
		     Reference <XMultiServiceFactory> (
		       xORB->createInstanceWithArguments (provStr, aCPArgs), UNO_QUERY));
  } catch (...) {
    fputs ("Failed to create xCfgProvider\n", stderr);
    _exit (2);
  }

  try {
    Sequence< Any > aCPArgs (1);
    Any aAny;
    ::rtl::OUString aItemPath;

    aItemPath = ::rtl::OUString::createFromAscii (argv[3]);
    aAny <<= aItemPath;
    PropertyValue aPropertyUser (::rtl::OUString::createFromAscii ("nodepath"), -1,
				 aAny, PropertyState_DIRECT_VALUE);
    aCPArgs[0] <<= aPropertyUser;

    Reference <XInterface> xRoot;
    xRoot = xCfgProvider->createInstanceWithArguments (
		::rtl::OUString::createFromAscii ("com.sun.star.configuration.ConfigurationAccess"),
		aCPArgs);
    _exit (0);
  } catch (...) {
    _exit (3);
  }
}