/************************************************************************* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 * only, as published by the Free Software Foundation. * * OpenOffice.org 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 version 3 for more details * (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_extensions.hxx" #include "errormail.hxx" #include "config.hxx" #include #include #include #include #if defined(UNIX) || defined(OS2) #include #endif #ifdef WIN32 #include #endif using namespace com::sun::star::lang; using namespace com::sun::star::uno; using namespace oooimprovement; using ::rtl::OUString; using ::rtl::OString; using ::rtl::OStringBuffer; namespace { static OString replaceAll(const OString& str, sal_Char old, const OString& replacement) { OStringBuffer result; sal_Int32 idx = 0; do { result.append(str.getToken(0, old, idx)); if(idx>=0) result.append(replacement); } while(idx >= 0); return result.makeStringAndClear(); }; static OString xmlAttrEncode(const OString& input) { OString result = replaceAll(input, '&', OString("&")); result = replaceAll(result, '<', OString("<")); result = replaceAll(result, '"', OString(""")); return replaceAll(result, '>', OString(">")); } static OString getPlatform() { #ifdef SOLARIS return "Solaris"; #elif defined LINUX return "Linux"; #elif defined WIN32 return "Win32"; #elif defined UNIX return "Unix"; #elif defined OS2 return "OS/2"; #else return "Unknown"; #endif }; #if defined(UNIX) || defined(OS2) static const OString getLocale() { const char * locale = getenv( "LC_ALL" ); if( NULL == locale ) locale = getenv( "LC_CTYPE" ); if( NULL == locale ) locale = getenv( "LANG" ); if( NULL == locale ) locale = "C"; return locale; }; static OString getSystemInfoXml(const Reference&) { struct utsname info; //memset(&info, 0, sizeof(info)); uname(&info); OStringBuffer result = "\n" "\n" "\n" "\n"; return result.makeStringAndClear(); }; #else static OString getSystemInfoXml(const Reference&) { OSVERSIONINFO info; ZeroMemory(&info, sizeof(OSVERSIONINFO)); info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&info); OStringBuffer result = OString( "\n" "(info.dwMajorVersion)); result.append(".").append(static_cast(info.dwMinorVersion)); result.append("\" build=\"").append(static_cast(info.dwBuildNumber)); result.append("\" locale=\"").append(static_cast(GetUserDefaultLangID())); result.append("\"/>\n"); result.append("\n" "\n"); return result.makeStringAndClear(); }; #endif static OString getOfficeInfoXml(const Reference& sf) { Config config(sf); const OString product = OUStringToOString(config.getCompleteProductname(), RTL_TEXTENCODING_ASCII_US); const OString platform = getPlatform(); const OString language = OUStringToOString(config.getSetupLocale(), RTL_TEXTENCODING_ASCII_US); // If the oooimprovement lib is packaged in an extension, this needs to // be done in another way: The build version string needs to be made // available in an UNO service (if no better place is found for this, // com.sun.star.comp.extensions.oooimprovecore.Core in oooimprovecore // is likely the best fit) const OString build = OUStringToOString(::utl::Bootstrap::getBuildIdData(OUString()), RTL_TEXTENCODING_ASCII_US); const OString exceptiontype = ""; OStringBuffer result = "\n"; return result.makeStringAndClear(); }; } namespace oooimprovement { Errormail::Errormail(const Reference& sf) : m_ServiceFactory(sf) {} OString Errormail::getXml() { Config config(m_ServiceFactory); const OString usertype; const OString email = OUStringToOString(config.getReporterEmail(), RTL_TEXTENCODING_ASCII_US); OString feedback; { OStringBuffer temp; temp.append(config.getReportCount()); feedback = temp.makeStringAndClear(); } const OString title; OStringBuffer result = "\n" "\n" "\n" "\n" "" + xmlAttrEncode(title) + "\n" "\n" "\n" + getOfficeInfoXml(m_ServiceFactory) + getSystemInfoXml(m_ServiceFactory) + "\n"; return result.makeStringAndClear(); } }