Commits

Anonymous committed 3b473b2

#i10000# missing changes from jl111

Comments (0)

Files changed (25)

desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx

 {
     uno::Any request( xRequest->getRequest() );
     OSL_ASSERT( request.getValueTypeClass() == uno::TypeClass_EXCEPTION );
-#if OSL_DEBUG_LEVEL > 1
-    OSL_TRACE( "[dp_gui_cmdenv.cxx] incoming request:\n%s\n",
-               ::rtl::OUStringToOString( ::comphelper::anyToString(request),
-                                         RTL_TEXTENCODING_UTF8 ).getStr() );
-#endif
+    dp_misc::TRACE( OUSTR("[dp_gui_cmdenv.cxx] incoming request:\n")
+        + ::comphelper::anyToString(request) + OUSTR("\n"));
     
     lang::WrappedTargetException wtExc;
     deployment::DependencyException depExc;
     {
         if ( m_wakeup.wait() != osl::Condition::result_ok )
         {
-            OSL_TRACE( "dp_gui::ExtensionCmdQueue::Thread::run: ignored "
-                       "osl::Condition::wait failure" );
+            dp_misc::TRACE( "dp_gui::ExtensionCmdQueue::Thread::run: ignored "
+                       "osl::Condition::wait failure\n" );
         }
         m_wakeup.reset();
 

desktop/source/deployment/gui/dp_gui_updatability.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dp_gui_updatability.cxx,v $
- * $Revision: 1.6 $
+ * $Revision: 1.6.86.1 $
  *
  * This file is part of OpenOffice.org.
  *
 
 void Updatability::Thread::execute() {
     for (;;) {
+
         if (m_wakeup.wait() != osl::Condition::result_ok) {
-            OSL_TRACE(
-                "dp_gui::Updatability::Thread::run: ignored "
-                "osl::Condition::wait failure");
+            dp_misc::TRACE("dp_gui::Updatability::Thread::run: ignored \n");
+            dp_misc::TRACE("osl::Condition::wait failure\n");
         }
         m_wakeup.reset();
         Input input;

desktop/source/deployment/gui/dp_gui_updatedialog.cxx

     }
     catch( const css::uno::Exception& e )
     {
-         OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
-            rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
+        dp_misc::TRACE( OUSTR("Caught exception: ") 
+            + e.Message + OUSTR("\n thread terminated.\n\n"));
     }
 }
 

desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx

 {
     cssu::Any request( xRequest->getRequest() );
     OSL_ASSERT( request.getValueTypeClass() == cssu::TypeClass_EXCEPTION );
-#if OSL_DEBUG_LEVEL > 1
-    OSL_TRACE( "[dp_gui_cmdenv.cxx] incoming request:\n%s\n",
-               ::rtl::OUStringToOString( ::comphelper::anyToString(request),
-                                         RTL_TEXTENCODING_UTF8 ).getStr() );
-#endif
+    dp_misc::TRACE(OUSTR("[dp_gui_cmdenv.cxx] incoming request:\n")
+        + ::comphelper::anyToString(request) + OUSTR("\n\n"));
     
     css::deployment::VersionException verExc;	
     bool approve = false;

desktop/source/deployment/inc/dp_descriptioninfoset.hxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dp_descriptioninfoset.hxx,v $
- * $Revision: 1.9 $
+ * $Revision: 1.9.34.1 $
  *
  * This file is part of OpenOffice.org.
  *
     */
     ::boost::optional< ::rtl::OUString > getLocalizedUpdateWebsiteURL() const;
 
+    /** returns the relative URL to the description. 
+        
+       The URL is relative to the root directory of the extensions.
+    */
+    ::rtl::OUString getLocalizedDescriptionURL() const;
     /**
        Return the dependencies.
 

desktop/source/deployment/inc/dp_misc.h

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dp_misc.h,v $
- * $Revision: 1.13 $
+ * $Revision: 1.13.86.2 $
  *
  * This file is part of OpenOffice.org.
  *
 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
 ::rtl::OUString getExtensionDefaultUpdateURL();
 
+/** writes the argument string to the console.
+    On Linux/Unix/etc. it converts the UTF16 string to an ANSI string using 
+    osl_getThreadTextEncoding() as target encoding. On Windows it uses WriteFile
+    with the standard out stream. unopkg.com reads the data and prints them out using
+    WriteConsoleW.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+void writeConsole(::rtl::OUString const & sText);
 
+/** writes the argument string to the console.
+    On Linux/Unix/etc. the string is passed into fprintf without any conversion.
+    On Windows the string is converted to UTF16 assuming the argument is UTF8 
+    encoded. The UTF16 string is written to stdout with WriteFile. unopkg.com 
+    reads the data and prints them out using WriteConsoleW.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+void writeConsole(::rtl::OString const & sText);
+
+/** writes the argument to the console using the error stream. 
+    Otherwise the same as writeConsole.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+void writeConsoleError(::rtl::OUString const & sText);
+
+
+/** writes the argument to the console using the error stream. 
+    Otherwise the same as writeConsole.
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+void writeConsoleError(::rtl::OString const & sText);
+
+
+/** reads from the console.
+    On Linux/Unix/etc. it uses fgets to read char values and converts them to OUString
+    using osl_getThreadTextEncoding as target encoding. The returned string has a maximum
+    size of 1024 and does NOT include leading and trailing white space(applied OUString::trim())
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+::rtl::OUString readConsole();
+
+/** print the text to the console in a debug build.
+    The argument is forwarded to writeConsole. The function does not add new line.
+    The code is only executed if  OSL_DEBUG_LEVEL > 1
+*/
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+void TRACE(::rtl::OUString const & sText);
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
+void TRACE(::rtl::OString const & sText);
 }
 
 #endif

desktop/source/deployment/manager/dp_manager.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dp_manager.cxx,v $
- * $Revision: 1.34 $
+ * $Revision: 1.33.8.2 $
  *
  * This file is part of OpenOffice.org.
  *
     {
 		Any request(
 			deployment::InstallException(
-				OUSTR("Extension ") + id + OUSTR("is about to be installed."),
+				OUSTR("Extension ") + id + OUSTR(" is about to be installed."),
 				static_cast<OWeakObject *>(this), package));
 	    bool approve = false, abort = false;
         if (! interactContinuation(

desktop/source/deployment/misc/dp_descriptioninfoset.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dp_descriptioninfoset.cxx,v $
- * $Revision: 1.7 $
+ * $Revision: 1.7.34.1 $
  *
  * This file is part of OpenOffice.org.
  *
 
 }
 
+::rtl::OUString DescriptionInfoset::getLocalizedDescriptionURL() const
+{
+    return getLocalizedHREFAttrFromChild(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+        "/desc:description/desc:extension-description")), NULL);
+}
+
 css::uno::Reference< css::xml::dom::XNode > 
 DescriptionInfoset::getLocalizedChild( const ::rtl::OUString & sParent) const
 {

desktop/source/deployment/misc/dp_misc.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dp_misc.cxx,v $
- * $Revision: 1.20 $
+ * $Revision: 1.19.8.4 $
  *
  * This file is part of OpenOffice.org.
  *
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_desktop.hxx"
 
+
 #include "dp_misc.h"
 #include "dp_interact.h"
 #include "rtl/uri.hxx"
 #include "boost/scoped_array.hpp"
 #include "boost/shared_ptr.hpp"
 
+#ifdef WNT
+//#include "tools/prewin.h"
+#define UNICODE
+#define _UNICODE
+#define WIN32_LEAN_AND_MEAN
+#include <Windows.h>
+//#include "tools/postwin.h"
+#endif
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using ::rtl::OUString;
+using ::rtl::OString;
 
 
 #define SOFFICE1 "soffice.exe"
 }
 
 
+#ifdef WNT
+void writeConsoleWithStream(::rtl::OUString const & sText, HANDLE stream)
+{
+    DWORD nWrittenChars = 0;
+    WriteFile(stream, sText.getStr(), 
+        sText.getLength() * 2, &nWrittenChars, NULL);
 }
+#else
+void writeConsoleWithStream(::rtl::OUString const & sText, FILE * stream)
+{
+    OString s = OUStringToOString(sText, osl_getThreadTextEncoding());
+    fprintf(stream, "%s", s.getStr());
+    fflush(stream);
+}
+#endif
+
+#ifdef WNT
+void writeConsoleWithStream(::rtl::OString const & sText, HANDLE stream)
+{
+    writeConsoleWithStream(OStringToOUString(
+        sText, RTL_TEXTENCODING_UTF8), stream);
+}
+#else
+void writeConsoleWithStream(::rtl::OString const & sText, FILE * stream)
+{
+    fprintf(stream, "%s", sText.getStr());
+    fflush(stream);
+}
+#endif
+
+void writeConsole(::rtl::OUString const & sText)
+{
+#ifdef WNT
+    writeConsoleWithStream(sText, GetStdHandle(STD_OUTPUT_HANDLE));
+#else
+    writeConsoleWithStream(sText, stdout);
+#endif
+}
+
+void writeConsole(::rtl::OString const & sText)
+{
+#ifdef WNT
+    writeConsoleWithStream(sText, GetStdHandle(STD_OUTPUT_HANDLE));
+#else
+    writeConsoleWithStream(sText, stdout);
+#endif
+}
+
+void writeConsoleError(::rtl::OUString const & sText)
+{
+#ifdef WNT
+    writeConsoleWithStream(sText, GetStdHandle(STD_ERROR_HANDLE));
+#else
+    writeConsoleWithStream(sText, stderr);
+#endif
+}
+
+
+void writeConsoleError(::rtl::OString const & sText)
+{
+#ifdef WNT
+    writeConsoleWithStream(sText, GetStdHandle(STD_ERROR_HANDLE));
+#else
+    writeConsoleWithStream(sText, stderr);
+#endif
+}
+
+
+
+OUString readConsole()
+{
+#ifdef WNT
+    sal_Unicode aBuffer[1024];
+	DWORD	dwRead = 0;
+    //unopkg.com feeds unopkg.exe with wchar_t|s
+    if (ReadFile( GetStdHandle(STD_INPUT_HANDLE), &aBuffer, sizeof(aBuffer), &dwRead, NULL ) )
+	{
+        OSL_ASSERT((dwRead % 2) == 0);
+        OUString value( aBuffer, dwRead / 2);
+        value = value.trim();
+        return value;
+	}
+    return OUString();
+
+#else
+	char buf[1024];
+	rtl_zeroMemory(buf, 1024);
+	// read one char less so that the last char in buf is always zero
+	fgets(buf, 1024, stdin);
+    OUString value = ::rtl::OStringToOUString(::rtl::OString(buf), osl_getThreadTextEncoding());
+    return value.trim();
+#endif
+}
+
+void TRACE(::rtl::OUString const & sText)
+{
+    (void) sText;
+#if OSL_DEBUG_LEVEL > 1
+    writeConsole(sText);
+#endif
+}
+
+void TRACE(::rtl::OString const & sText)
+{
+    (void) sText;
+#if OSL_DEBUG_LEVEL > 1
+    writeConsole(sText);
+#endif
+}
+
+}

desktop/source/deployment/misc/dp_platform.cxx

  *
  * $RCSfile: dp_platform.cxx,v $
  *
- * $Revision: 1.3 $
+ * $Revision: 1.2.86.2 $
  *
  * This file is part of OpenOffice.org.
  *
 #define PLATFORM_FREEBSD_X86_64     "freebsd_x86_64"
 #define PLATFORM_MACOSX_X86         "macosx_x86"
 #define PLATFORM_MACOSX_PPC         "macosx_powerpc"
-#define PLATFORM_OS2_X86            "os/2_x86"
+#define PLATFORM_OS2_X86            "os2_x86"
 
 
 
         else if (token.equals(OUSTR(PLATFORM_MACOSX_PPC)))
             ret = checkOSandCPU(OUSTR("MacOSX"), OUSTR("PowerPC"));
         else if (token.equals(OUSTR(PLATFORM_OS2_X86)))
-            ret = checkOSandCPU(OUSTR("OS/2"), OUSTR("x86"));
+            ret = checkOSandCPU(OUSTR("OS2"), OUSTR("x86"));
         else
         {
             OSL_ENSURE(0, "Extension Manager: The extension supports an unknown platform. "

desktop/source/deployment/registry/dp_registry.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dp_registry.cxx,v $
- * $Revision: 1.12 $
+ * $Revision: 1.12.86.1 $
  *
  * This file is part of OpenOffice.org.
  *
 using namespace ::com::sun::star::ucb;
 using ::rtl::OUString;
 
+
 namespace dp_registry {
 
 namespace backend {
     // dump tables:
     {
         t_registryset allBackends;        
-        OSL_TRACE( "> [dp_registry.cxx] media-type detection:" );
+        dp_misc::TRACE("> [dp_registry.cxx] media-type detection:\n\n" );
         for ( t_string2string::const_iterator iPos(
                   that->m_filter2mediaType.begin() );
               iPos != that->m_filter2mediaType.end(); ++iPos )
             buf.append( Reference<lang::XServiceInfo>(
                             xBackend, UNO_QUERY_THROW )
                         ->getImplementationName() );
-            OSL_TRACE( ::rtl::OUStringToOString(
-                           buf.makeStringAndClear(),
-                           RTL_TEXTENCODING_UTF8 ).getStr() );
+            dp_misc::writeConsole( buf.makeStringAndClear() + OUSTR("\n"));
         }
-        OSL_TRACE( "> [dp_registry.cxx] ambiguous backends:" );
+        dp_misc::TRACE( "> [dp_registry.cxx] ambiguous backends:\n\n" );
         for ( t_registryset::const_iterator iPos(
                   that->m_ambiguousBackends.begin() );
               iPos != that->m_ambiguousBackends.end(); ++iPos )
                 if (pos < (types.getLength() - 1))
                     buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") );
             }
-            OSL_TRACE( ::rtl::OUStringToOString(
-                           buf.makeStringAndClear(),
-                           RTL_TEXTENCODING_UTF8 ).getStr() );
+            dp_misc::TRACE(buf.makeStringAndClear() + OUSTR("\n\n"));
         }
         allBackends.insert( that->m_ambiguousBackends.begin(),
                             that->m_ambiguousBackends.end() );

desktop/source/deployment/registry/package/dp_package.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dp_package.cxx,v $
- * $Revision: 1.35 $
+ * $Revision: 1.34.16.2 $
  *
  * This file is part of OpenOffice.org.
  *
     class PackageImpl : public ::dp_registry::backend::Package
     {
         BackendImpl * getMyBackend() const;
-        
-        OUString m_description;
+        /** constains the old tooltip description for the Extension Manager GUI in OOo v.2.x
+            We keep it for backward compatibility.
+        */
+        OUString m_oldDescription;
         OUString m_url_expanded;
         const bool m_legacyBundle;
         Sequence< Reference<deployment::XPackage> > m_bundle;
 					css::ucb::CommandFailedException, 
 					css::ucb::CommandAbortedException, 
 					css::uno::RuntimeException);
-		OUString getLicenseText(
+        // @throws DeploymentException
+		OUString getTextFromURL(
 			const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv,
 			const OUString& licenseUrl);
 
         present, beans::Ambiguous<sal_Bool>(reg, ambig) );
 }
 
-OUString BackendImpl::PackageImpl::getLicenseText(
+OUString BackendImpl::PackageImpl::getTextFromURL(
 	const css::uno::Reference< css::ucb::XCommandEnvironment >& xCmdEnv,
 	const OUString& licenseUrl)
 {
 	try
 	{
 		::ucbhelper::Content descContent(licenseUrl, xCmdEnv);
-		css::uno::Reference<css::io::XInputStream> xInput = descContent.openStream();
-
-		//read out the complete content and create a string
-		const sal_Int32 nConstBufferSize = 32000;
-		sal_Int32 nRead = 0;
-		css::uno::Sequence<sal_Int8> seqTemp(nConstBufferSize);
-		css::uno::Sequence<sal_Int8> seqAll(0);
-
-		do
-		{
-			nRead = xInput->readBytes ( seqTemp, nConstBufferSize );
-			sal_Int32 lenAll = seqAll.getLength();
-			seqAll.realloc(seqAll.getLength() + nRead);
-			sal_Int8 const * arTemp = seqTemp.getConstArray();
-			sal_Int8 * arAll = seqAll.getArray();
-			rtl_copyMemory(arAll + lenAll, arTemp, nRead);
-		}
-		while ( nRead == nConstBufferSize );
-
-		xInput->closeInput();
-
-		OUString sLic(reinterpret_cast<sal_Char const *>(seqAll.getConstArray()),
-			seqAll.getLength(), RTL_TEXTENCODING_UTF8);
-
-		return sLic;
+        ::rtl::ByteSequence seq = dp_misc::readFile(descContent);
+        return OUString( reinterpret_cast<sal_Char const *>(
+            seq.getConstArray()), seq.getLength(), RTL_TEXTENCODING_UTF8);
 	}
 	catch (css::uno::Exception&)
 	{	
 		Any exc( ::cppu::getCaughtException() );
 			throw css::deployment::DeploymentException(
-				OUSTR("Could not read license text in ") + licenseUrl, 0, exc);
+				OUSTR("Could not read file ") + licenseUrl, 0, exc);
 	}
 
 }
             throw css::deployment::DeploymentException(
                 OUSTR("Could not obtain path to license. Possible error in description.xml"), 0, Any()); 	
         OUString sHref = desc.getExtensionRootUrl() + OUSTR("/") + sLic;
-   		OUString sLicense = getLicenseText(xCmdEnv, sHref);
+   		OUString sLicense = getTextFromURL(xCmdEnv, sHref);
 		//determine who has to agree to the license
 		css::uno::Reference<css::xml::xpath::XXPathObject> nodeAttribWho3 = 
 			xPath->eval(nodeSimpleLic, 
 //______________________________________________________________________________
 OUString BackendImpl::PackageImpl::getDescription() throw (RuntimeException)
 {
-     return m_description;
+    const OUString sRelativeURL(getDescriptionInfoset().getLocalizedDescriptionURL());
+    OUString sDescription;
+    if (sRelativeURL.getLength())   
+    {
+        OUString sURL = m_url_expanded + OUSTR("/") + sRelativeURL;
+        sDescription = getTextFromURL(
+            css::uno::Reference< css::ucb::XCommandEnvironment >(), sURL);
+
+    }
+    if (sDescription.getLength())
+        return sDescription;       
+    else if(m_oldDescription.getLength() == 0)
+        return m_oldDescription;
+    else
+        return OUString();
 }
 
 //______________________________________________________________________________
 			{
 	            buf.append( Package::getDescription() );
 			}
-            m_description = buf.makeStringAndClear();
+            m_oldDescription = buf.makeStringAndClear();
         }
     }
 }

desktop/source/deployment/registry/sfwk/dp_parceldesc.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dp_parceldesc.cxx,v $
- * $Revision: 1.7 $
+ * $Revision: 1.7.86.1 $
  *
  * This file is part of OpenOffice.org.
  *
 
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_desktop.hxx"
+#include "dp_misc.h"
 #include "dp_parceldesc.hxx"
 
+
+
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 
         throw ( xml::sax::SAXException,
             RuntimeException )
 {
-    OSL_TRACE("ParcelDescDocHandler::startElement() for %s",
-        rtl::OUStringToOString( aName, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ 
+    dp_misc::TRACE(OUSTR("ParcelDescDocHandler::startElement() for ") + 
+        aName + OUSTR("\n"));
     if ( !skipIndex )
     {
         if ( aName.equals( OUString::createFromAscii( "parcel" ) ) )
     }
     else
     {
-        OSL_TRACE("ParcelDescDocHandler::startElement() skipping for %s",
-            rtl::OUStringToOString( aName, RTL_TEXTENCODING_ASCII_US ).getStr() );
+        dp_misc::TRACE(OUSTR("ParcelDescDocHandler::startElement() skipping for ")
+            + aName + OUSTR("\n"));
     }
     
 }
     if ( skipIndex )
     {
         --skipIndex;
-        OSL_TRACE("ParcelDescDocHandler::endElement() skipping for %s",
-            rtl::OUStringToOString( aName, RTL_TEXTENCODING_ASCII_US ).getStr() );
+        dp_misc::TRACE(OUSTR("ParcelDescDocHandler::endElement() skipping for ")
+            + aName + OUSTR("\n"));
     }
 }
 

desktop/source/deployment/registry/sfwk/dp_sfwk.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: dp_sfwk.cxx,v $
- * $Revision: 1.16 $
+ * $Revision: 1.16.66.1 $
  *
  * This file is part of OpenOffice.org.
  *
         rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
     m_name = m_displayName;
 
-    OSL_TRACE("PakageImpl displayName is %s",
-        ::rtl::OUStringToOString( m_displayName , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+    dp_misc::TRACE(OUSTR("PakageImpl displayName is ") + m_displayName);
 }
 
 //______________________________________________________________________________
                 sal_Int32 startOfReplace = sfwkLibType.indexOf( MACRONAME );
                 sal_Int32 charsToReplace = MACRONAME.getLength();
                 sfwkLibType = sfwkLibType.replaceAt( startOfReplace, charsToReplace, lang );
-                OSL_TRACE("******************************");
-                OSL_TRACE(" BackEnd detected lang = %s  ",
-                     rtl::OUStringToOString( lang, RTL_TEXTENCODING_ASCII_US ).getStr() );
-                OSL_TRACE(" for url %s",
-                     rtl::OUStringToOString( sParcelDescURL, RTL_TEXTENCODING_ASCII_US ).getStr() );
-                OSL_TRACE("******************************");
+                dp_misc::TRACE("******************************\n");
+                dp_misc::TRACE(OUSTR(" BackEnd detected lang = ") + lang + OUSTR("\n"));
+                dp_misc::TRACE(OUSTR(" for url ") + sParcelDescURL + OUSTR("\n") );
+                dp_misc::TRACE("******************************\n");
                 return new PackageImpl( this, url, sfwkLibType );
             }
         }
 {
     if ( !m_xNameCntrPkgHandler.is() )
     {
-        OSL_TRACE("no package handler!!!!");   
+        dp_misc::TRACE("no package handler!!!!\n");   
         throw RuntimeException( OUSTR("No package Handler " ), 
             Reference< XInterface >() );
     }     

desktop/source/pkgchk/unopkg/unopkg_app.cxx

 
 // MARKER(update_precomp.py): autogen include statement, do not remove
 
+#include "dp_misc.h"
 #include "unopkg_main.h"
 #include "unopkg_shared.h"
 #include "dp_identifier.hxx"
 #include <stdio.h>
 #include <vector>
 
-#define APP_NAME "unopkg"
-
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 " --deployment-context    expert feature: explicit deployment context\n"
 "     <context>\n"
 "\n"
-"For details concerning deployment and this tool, please read the developer's\n"
-"guide: http://api.openoffice.org/DevelopersGuide/" APP_NAME ".html\n";
+"To learn more about the Extension Manager and extensions, see:\n"
+"http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Extensions/Extensions\n\n";
 
 //------------------------------------------------------------------------------
 const OptionInfo s_option_infos [] = {
 {
     tools::extendApplicationEnvironment();
     DisposeGuard disposeGuard;
-    rtl_TextEncoding textenc = osl_getThreadTextEncoding();
     bool bNoOtherErrorMsg = false;
     OUString subCommand;
     bool option_shared = false;
         sal_uInt32 nCount = osl_getCommandArgCount();
         if (nCount == 0 || isOption( info_help, &nPos ))
         {
-            printf( "%s\n", s_usingText );
+            dp_misc::writeConsole(s_usingText);
             return 0;
         }
         else if (isOption( info_version, &nPos )) {
-            printf( "\n%s Version 1.0\n", APP_NAME );
+            dp_misc::writeConsole("\n"APP_NAME" Version 3.0\n");
             return 0;
         }
         //consume all bootstrap variables which may occur before the subcommannd
-        while(isBootstrapVariable(&nPos)) ;
+        while(isBootstrapVariable(&nPos));
        
         if(nPos >= nCount)
             return 0;
                     if (cmdArg[ 0 ] == '-')
                     {
                         // is option:
-                        fprintf( stderr,
-                                 "\nERROR: unexpected option %s!\n"
-                                 "       Use " APP_NAME
-                                 " %s to print all options.\n",
-                                 ::rtl::OUStringToOString(
-                                     cmdArg, textenc ).getStr(),
-                                 toString( info_help ).getStr() );
+                        dp_misc::writeConsoleError(
+                                 OUSTR("\nERROR: unexpected option ") +
+                                 cmdArg +
+                                 OUSTR("!\n") +
+                                 OUSTR("       Use " APP_NAME " ") + 
+                                 toString(info_help) +
+                                 OUSTR(" to print all options.\n"));
                         return 1;
                     }
                     else
         //make sure the bundled option was provided together with shared
         if (option_bundled && !option_shared)
         {
-            fprintf( stderr,
+            dp_misc::writeConsoleError(
                 "\nERROR: option --bundled can only be used together with --shared!");
             return 1;
         }
                 option_shared = true;
             }
             else if (option_shared) {
-                fprintf( stderr,
-                         "WARNING: explicit context given!  "
-                         "Ignoring option %s!\n",
-                         toString( info_shared ).getStr() );
+                dp_misc::writeConsoleError(
+                    OUSTR("WARNING: explicit context given!  ") +
+                    OUSTR("Ignoring option ") +
+                    toString( info_shared ) +
+                    OUSTR("!\n") );
             }
         }
         
             {
                 packages = xPackageManager->getDeployedPackages(
                     Reference<task::XAbortChannel>(), xCmdEnv );
-                printf( "all deployed %s packages:\n",
-                        ::rtl::OUStringToOString(
-                            deploymentContext, textenc ).getStr() );
+                dp_misc::writeConsole(
+                    OUSTR("all deployed ") + deploymentContext + OUSTR(" packages:\n"));
             }
             else
             {
         }
         else
         {
-            fprintf( stderr,
-                     "\nERROR: unknown sub-command %s!\n"
-                     "       Use " APP_NAME " %s to print all options.\n",
-                     ::rtl::OUStringToOString( subCommand, textenc ).getStr(),
-                     toString( info_help ).getStr() );
+            dp_misc::writeConsoleError(
+                OUSTR("\nERROR: unknown sub-command ") + 
+                subCommand +
+                OUSTR("!\n") + 
+                OUSTR("       Use " APP_NAME " ") + 
+                toString(info_help) +
+                OUSTR(" to print all options.\n"));
             return 1;
         }
         
         if (option_verbose)
-            printf( "\n%s done.\n", APP_NAME );
+            dp_misc::writeConsole(OUSTR("\n"APP_NAME" done.\n"));
         //Force to release all bridges which connect us to the child processes
         disposeBridges(xLocalComponentContext);
         return 0;
     }
-    catch (ucb::CommandFailedException &e) {
-        fprintf(stderr, "%s\n", ::rtl::OUStringToOString(e.Message, textenc).getStr());
+    catch (ucb::CommandFailedException &e) 
+    {
+        dp_misc::writeConsoleError(e.Message + OUSTR("\n"));
         bNoOtherErrorMsg = true;    
     }
-    catch (ucb::CommandAbortedException &) {
-        fprintf( stderr, "\n%s aborted!\n", APP_NAME );
+    catch (ucb::CommandAbortedException &) 
+    {
+        dp_misc::writeConsoleError("\n"APP_NAME" aborted!\n");
     }
-    catch (deployment::DeploymentException & exc) {
-        fprintf( stderr,
-                 "\nERROR: %s\n"
-                 "       Cause: %s\n",
-                 ::rtl::OUStringToOString(
-                     exc.Message, textenc ).getStr(),
-                 ::rtl::OUStringToOString(
-                     option_verbose
-                     ? ::comphelper::anyToString(exc.Cause)
-                     : reinterpret_cast<
-                     ::com::sun::star::uno::Exception const *>(
-                         exc.Cause.getValue())->Message, textenc).getStr() );
+    catch (deployment::DeploymentException & exc) 
+    {
+        dp_misc::writeConsoleError(
+            OUSTR("\nERROR: ") +
+            exc.Message + OUSTR("\n") +
+            OUSTR("       Cause: ") + 
+            OUString(option_verbose ? ::comphelper::anyToString(exc.Cause): 
+                reinterpret_cast< css::uno::Exception const *>(
+                         exc.Cause.getValue())->Message) +
+            OUSTR("\n"));
+    }
+    catch (LockFileException & e) 
+    {
+        if (!subcmd_gui)
+            dp_misc::writeConsoleError(e.Message);
+        bNoOtherErrorMsg = true;
     }
     catch (::com::sun::star::uno::Exception & e ) {
         Any exc( ::cppu::getCaughtException() );
  
-        fprintf( stderr, "\nERROR: %s\n", ::rtl::OUStringToOString( 
-            option_verbose  ? e.Message + OUSTR("\nException details: \n") + 
-            ::comphelper::anyToString(exc) : e.Message, textenc).getStr() );
+        dp_misc::writeConsoleError(
+            OUSTR("\nERROR: ") +  
+            OUString(option_verbose  ? e.Message + OUSTR("\nException details: \n") + 
+            ::comphelper::anyToString(exc) : e.Message) +
+            OUSTR("\n"));
     }
     if (!bNoOtherErrorMsg)
-        fprintf( stderr, "\n%s failed.\n", APP_NAME );
+        dp_misc::writeConsoleError("\n"APP_NAME" failed.\n");
     disposeBridges(xLocalComponentContext);
     return 1;
 }

desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: unopkg_cmdenv.cxx,v $
- * $Revision: 1.12 $
+ * $Revision: 1.12.8.3 $
  *
  * This file is part of OpenOffice.org.
  *
 
 namespace {
 
-inline ::com::sun::star::lang::Locale toLocale( ::rtl::OUString const & slang )
-{
-    ::com::sun::star::lang::Locale locale;
-    sal_Int32 nIndex = 0;
-    locale.Language = slang.getToken( 0, '-', nIndex );
-    locale.Country = slang.getToken( 0, '-', nIndex );
-    locale.Variant = slang.getToken( 0, '-', nIndex );
-    return locale;
-}
-
-
 //==============================================================================
 struct OfficeLocale :
         public rtl::StaticWithInit<const lang::Locale, OfficeLocale> {
 {
     ResMgr * pResMgr = DeploymentResMgr::get();
 	OUString s1 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_1, *pResMgr));
-	::rtl::OString os1 = ::rtl::OUStringToOString(s1, osl_getThreadTextEncoding());
 	OUString s2 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_2, *pResMgr));
-	::rtl::OString os2 = ::rtl::OUStringToOString(s2, osl_getThreadTextEncoding());
 	OUString s3 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_3, *pResMgr));
-	::rtl::OString os3 = ::rtl::OUStringToOString(s3, osl_getThreadTextEncoding());
 	OUString s4 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_4, *pResMgr));
-	::rtl::OString os4 = ::rtl::OUStringToOString(s4, osl_getThreadTextEncoding());
 	OUString sYES = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_YES, *pResMgr));
 	OUString sY = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_Y, *pResMgr));
 	OUString sNO = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_NO, *pResMgr));
 	OUString sN = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_N, *pResMgr));
-
-	fprintf(stdout, "\n\n%s\n\n", os1.getStr());
-	fprintf(stdout, "%s\n\n", OUStringToOString(sLicense, osl_getThreadTextEncoding()).getStr());
-	fprintf(stdout, "%s\n", os2.getStr());
-	fprintf(stdout, "%s", os3.getStr());
-    fflush(stdout);
-
+    
+    OUString sNewLine(RTL_CONSTASCII_USTRINGPARAM("\n"));
+    
+    dp_misc::writeConsole(sNewLine + sNewLine + s1 + sNewLine + sNewLine);
+    dp_misc::writeConsole(sLicense + sNewLine + sNewLine);
+    dp_misc::writeConsole(s2 + sNewLine);
+    dp_misc::writeConsole(s3);
 	
 	//the user may enter "yes" or "no", we compare in a case insensitive way
 	Reference< css::i18n::XCollator > xCollator(
 
 	do
 	{
-		char buf[16];
-		rtl_zeroMemory(buf, 16);
-		// read one char less so that the last char in buf is always zero
-		fgets(buf, 15, stdin);
-		OUString sAnswer = ::rtl::OStringToOUString(::rtl::OString(buf), osl_getThreadTextEncoding());
-		sAnswer = sAnswer.trim();
-		
+        OUString sAnswer = dp_misc::readConsole();
 		if (xCollator->compareString(sAnswer, sYES) == 0
 			|| xCollator->compareString(sAnswer, sY) == 0)
 		{
 		}
 		else
 		{
-			fprintf(stdout, "\n\n%s\n", os4.getStr());
-            fflush(stdout);
+            dp_misc::writeConsole(sNewLine + sNewLine + s4 + sNewLine);
 		}
 	}
 	while(true);
 {
     Any request( xRequest->getRequest() );
     OSL_ASSERT( request.getValueTypeClass() == TypeClass_EXCEPTION );
-#if OSL_DEBUG_LEVEL > 1
-    OSL_TRACE( "[unopkg_cmdenv.cxx] incoming request:\n%s\n",
-               ::rtl::OUStringToOString( ::comphelper::anyToString(request),
-                                         RTL_TEXTENCODING_UTF8 ).getStr() );
-#endif
+    dp_misc::TRACE(OUSTR("[unopkg_cmdenv.cxx] incoming request:\n") 
+        + ::comphelper::anyToString(request) + OUSTR("\n\n"));
     
     // selections:
     bool approve = false;
     {
         String sResMsg( ResId( RID_STR_UNOPKG_NO_SHARED_ALLOWED, *DeploymentResMgr::get() ) );
         sResMsg.SearchAndReplaceAllAscii( "%NAME", licAgreementExc.ExtensionName );
-        ::rtl::OString oMsg = ::rtl::OUStringToOString(sResMsg, osl_getThreadTextEncoding());
-        fprintf(stdout, "\n%s\n\n", oMsg.getStr());
+        dp_misc::writeConsole(OUSTR("\n") + sResMsg + OUSTR("\n\n"));
         abort = true;
     }
 	else if (request >>= licExc)
     {
         String sMsg(ResId(RID_STR_UNSUPPORTED_PLATFORM, *dp_gui::DeploymentGuiResMgr::get()));
         sMsg.SearchAndReplaceAllAscii("%Name", platExc.package->getDisplayName());
-        ::rtl::OString oMsg = ::rtl::OUStringToOString(sMsg, osl_getThreadTextEncoding());
-
-        fprintf(stdout, "\n%s\n\n", oMsg.getStr());
+        dp_misc::writeConsole(OUSTR("\n") + sMsg + OUSTR("\n\n"));
         approve = true;
     }
     else {
     if (abort && m_option_verbose && !bLicenseException) 
     { 
         OUString msg = ::comphelper::anyToString(request);
-        fprintf( stderr, "\nERROR: %s\n",
-            ::rtl::OUStringToOString(
-            msg, osl_getThreadTextEncoding() ).getStr() );
+        dp_misc::writeConsoleError(
+            OUSTR("\nERROR: ") + msg + OUSTR("\n"));
     }
     
     // select:
 {
     if (! Status.hasValue())
         return;
-    
-    FILE * stream;
+    bool bUseErr = false;
     OUString msg;
     if (Status >>= msg) {
         if (! m_option_verbose)
             return;
-        stream = stdout;
     }
     else {
         ::rtl::OUStringBuffer buf;
             buf.append( ::comphelper::anyToString(Status) );
         }
         msg = buf.makeStringAndClear();
-        stream = stderr;
+        bUseErr = true;
     }
     OSL_ASSERT( m_logLevel >= 0 );
     for ( sal_Int32 n = 0; n < m_logLevel; ++n )
-        fprintf( stream, " " );
-    fprintf( stream, "%s\n", ::rtl::OUStringToOString(
-                 msg, osl_getThreadTextEncoding() ).getStr() );
+    {
+        if (bUseErr)
+            dp_misc::writeConsoleError(" ");
+        else
+            dp_misc::writeConsole(" ");
+    }
+
+    if (bUseErr)
+        dp_misc::writeConsoleError(msg + OUSTR("\n"));
+    else
+        dp_misc::writeConsole(msg + OUSTR("\n"));
 }
 
 //______________________________________________________________________________

desktop/source/pkgchk/unopkg/unopkg_shared.h

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: unopkg_shared.h,v $
- * $Revision: 1.9 $
+ * $Revision: 1.9.8.3 $
  *
  * This file is part of OpenOffice.org.
  *
  ************************************************************************/
 
 #include "dp_misc.h"
+#include "com/sun/star/uno/Exception.hpp"
 #include "com/sun/star/lang/XComponent.hpp"
 #include "com/sun/star/uno/XComponentContext.hpp"
 #include "com/sun/star/ucb/XCommandEnvironment.hpp"
 #include "com/sun/star/deployment/XPackage.hpp"
 #include "tools/resmgr.hxx"
+#include "rtl/ustring.hxx"
+#include "unotools/configmgr.hxx"
 
 
+#define APP_NAME "unopkg"
 
 namespace css = ::com::sun::star;
 
 namespace unopkg {
 
+    inline ::com::sun::star::lang::Locale toLocale( ::rtl::OUString const & slang )
+    {
+        ::com::sun::star::lang::Locale locale;
+        sal_Int32 nIndex = 0;
+        locale.Language = slang.getToken( 0, '-', nIndex );
+        locale.Country = slang.getToken( 0, '-', nIndex );
+        locale.Variant = slang.getToken( 0, '-', nIndex );
+        return locale;
+    }
+
+
+	struct OfficeLocale :
+		public rtl::StaticWithInit<const css::lang::Locale, OfficeLocale> {
+			const css::lang::Locale operator () () {
+				::rtl::OUString slang;
+        if (! (::utl::ConfigManager::GetDirectConfigProperty(
+                   ::utl::ConfigManager::LOCALE ) >>= slang))
+            throw css::uno::RuntimeException( OUSTR("Cannot determine language!"), 0 );
+        if (slang.getLength() == 0)
+            slang = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en-US"));
+		return toLocale(slang);
+    }
+};
+
 struct DeploymentResMgr :  public rtl::StaticWithInit< ResMgr *, DeploymentResMgr > 
 {
 	ResMgr * operator () () {
-		return ResMgr::CreateResMgr( "deployment" );
+        return ResMgr::CreateResMgr( "deployment", OfficeLocale::get());
 	}
 };
 
     bool m_has_argument;
 };
 
+struct LockFileException : public css::uno::Exception
+{
+    LockFileException(::rtl::OUString const & sMessage) : 
+        css::uno::Exception(sMessage, css::uno::Reference< css::uno::XInterface > ()) {}
+};
+
 //==============================================================================
-::rtl::OString toString( OptionInfo const * info );
+::rtl::OUString toString( OptionInfo const * info );
 
 //==============================================================================
 OptionInfo const * getOptionInfo(

desktop/test/deployment/description/desc1.oxt

Binary file added.

desktop/test/deployment/description/desc2.oxt

Binary file added.

desktop/test/deployment/description/desc3.oxt

Binary file added.

desktop/test/deployment/description/desc4.oxt

Binary file added.

desktop/test/deployment/description/desc5.oxt

Binary file added.

desktop/test/deployment/description/readme.txt

+The folder contains extensions which use in the description.xml the following:
+-The <extension-description> element The element contains localized child
+elements.
+
+The following table shows what localized item is used, when the Office the locale 
+en-US uses. The displayed extension description contains the locale.
+
+
+Localization:
+
+Installed office: en-US
+          | locale     
+=========================
+desc1.oxt | en-US      
+-------------------------
+desc2.oxt | en-US-region1 
+--------------------------
+desc3.oxt | en            
+--------------------------
+desc4.oxt | en-GB         
+--------------------------
+desc5.oxt | de            
+

desktop/win32/source/guistdio/guistdio.inc

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: guistdio.inc,v $
- * $Revision: 1.3 $
+ * $Revision: 1.3.86.3 $
  *
  * This file is part of OpenOffice.org.
  *
 // Thread that reads from child process standard output pipe
 //---------------------------------------------------------------------------
 
+#ifdef UNOPKG
+
+DWORD passOutputToConsole(HANDLE readPipe, HANDLE console)
+{
+	BYTE aBuffer[1024];
+	DWORD dwRead = 0;
+	HANDLE hReadPipe = readPipe;
+	BOOL fSuccess;
+	DWORD dwWritten;
+
+	//Indicates that we read an odd number of bytes. That is, we only read half of the last
+	//wchar_t
+	bool bIncompleteWchar = false;
+	//fprintf, fwprintf will both send char data without the terminating zero. 
+	//fwprintf converts the unicode string first.
+	//We expect here to receive unicode without the terminating zero. 
+	//unopkg and the extension manager code MUST 
+	//use dp_misc::writeConsole instead of using fprintf, etc.
+	
+	DWORD dwToRead = sizeof(aBuffer);
+	BYTE * pBuffer = aBuffer;
+	while ( ReadFile( hReadPipe, pBuffer, dwToRead, &dwRead, NULL ) )
+	{
+		//If the previous ReadFile call read an odd number of bytes, then the last one was
+		//put at the front of the buffer. We increase the number of read bytes by one to reflect
+		//that one byte.
+		if (bIncompleteWchar)
+			dwRead++;
+		//We must make sure that only complete wchar_t|s are written. WriteConsolse takes
+		//the number of wchar_t|s as argument. ReadFile, however, reads bytes.
+		bIncompleteWchar = dwRead % 2 ? true : false;
+		if (bIncompleteWchar)
+		{
+			//To test this case, give aBuffer a small odd size, e.g. aBuffer[3]
+			//The last byte, which is the incomplete wchar_t (half of it), will not be written.
+			fSuccess = WriteConsoleW( console, aBuffer, 
+				(dwRead - 1) / 2, &dwWritten, NULL );
+			
+			//Move the last byte to the front of the buffer, so that it is the start of the 
+			//next string
+			aBuffer[0] = aBuffer[dwRead - 1];
+			
+			//Make sure that ReadFile does not overwrite the first byte the next time
+			dwToRead = sizeof(aBuffer) - 1;
+			pBuffer = aBuffer + 1;
+			
+		}
+		else
+		{	//We have read an even number of bytes. Therefore, we do not put the last incomplete
+			//wchar_t at the front of the buffer. We will use the complete buffer the next time 
+			//when ReadFile is called.
+			dwToRead = sizeof(aBuffer);
+			pBuffer = aBuffer;
+			fSuccess = WriteConsoleW( console, 
+				aBuffer, dwRead / 2, &dwWritten, NULL );
+		}
+	}
+
+	return 0;
+}
+
+#endif
+
+#ifdef UNOPKG
+DWORD WINAPI OutputThread( LPVOID pParam )
+{
+	return passOutputToConsole((HANDLE)pParam, GetStdHandle( STD_OUTPUT_HANDLE ));
+}
+
+#else
 DWORD WINAPI OutputThread( LPVOID pParam )
 {
 	BYTE	aBuffer[256];
 	DWORD	dwRead = 0;
 	HANDLE	hReadPipe = (HANDLE)pParam;
-
 	while ( ReadFile( hReadPipe, &aBuffer, sizeof(aBuffer), &dwRead, NULL ) )
 	{
 		BOOL	fSuccess;
 
 	return 0;
 }
-
+#endif
 //---------------------------------------------------------------------------
 // Thread that reads from child process standard error pipe
 //---------------------------------------------------------------------------
 
+#ifdef UNOPKG
+DWORD WINAPI ErrorThread( LPVOID pParam )
+{
+	return passOutputToConsole((HANDLE)pParam, GetStdHandle( STD_ERROR_HANDLE ));
+}
+
+#else
 DWORD WINAPI ErrorThread( LPVOID pParam )
 {
 	BYTE	aBuffer[256];
 
 	return 0;
 }
-
+#endif
 //---------------------------------------------------------------------------
 // Thread that writes to child process standard input pipe
 //---------------------------------------------------------------------------
+#ifdef UNOPKG
+DWORD WINAPI InputThread( LPVOID pParam )
+{
+	const DWORD dwBufferSize = 256;
+	wchar_t	aBuffer[dwBufferSize];
+	DWORD	dwRead = 0;
+	HANDLE	hWritePipe = (HANDLE)pParam;
+		
+	while (ReadConsoleW( GetStdHandle( STD_INPUT_HANDLE ), &aBuffer, dwBufferSize, &dwRead, NULL ) )
+	{
+		BOOL	fSuccess;
+		DWORD	dwWritten;
 
+		fSuccess = WriteFile( hWritePipe, aBuffer, dwRead * 2, &dwWritten, NULL );
+	}
+
+	return 0;
+}
+#else
 DWORD WINAPI InputThread( LPVOID pParam )
 {
 	BYTE	aBuffer[256];
 
 	return 0;
 }
+#endif
 
 //---------------------------------------------------------------------------
 // Thread that waits until child process reached input idle
 {
 	HANDLE	hProcess = (HANDLE)pParam;
 
-#ifndef GUISTDIO_KEEPRUNNING
-	if ( !_tgetenv( TEXT("GUISTDIO_KEEPRUNNING") ) )
+#ifndef UNOPKG
+	if ( !_tgetenv( TEXT("UNOPKG") ) )
 		WaitForInputIdle( hProcess, INFINITE );
 	else
 #endif
         //the threads then data may be lost. For example running unopkg without arguments shall print out
         //the help text. Without this workaround some text would be missing.
         //ifdef only for unopkg
-#ifdef GUISTDIO_KEEPRUNNING
+#ifdef UNOPKG
         Sleep(1000);    
 #endif        
 		CloseHandle( hOutputThread );

desktop/win32/source/guistdio/unopkgio.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: unopkgio.cxx,v $
- * $Revision: 1.3 $
+ * $Revision: 1.3.86.1 $
  *
  * This file is part of OpenOffice.org.
  *
 
 #include "precompiled_desktop.hxx"
 
-#define GUISTDIO_KEEPRUNNING
+#define UNOPKG
 #include "guistdio.inc"