[API CHANGE] tdf#49602: Remove legacy osl/profile Implementation

Change-Id: Ida2f39cd657f846c4b31fa88a46ef3e02baabdf7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196372
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
This commit is contained in:
shlok3640
2026-01-23 19:36:08 +01:00
committed by Stephan Bergmann
parent 270fe90efb
commit f268a212e7
11 changed files with 48 additions and 4653 deletions
-151
View File
@@ -1,151 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
/*
* This file is part of LibreOffice published API.
*/
#ifndef INCLUDED_OSL_PROFILE_H
#define INCLUDED_OSL_PROFILE_H
#include "sal/config.h"
#include "rtl/ustring.h"
#include "sal/saldllapi.h"
#include "sal/types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef sal_uInt32 oslProfileOption;
#define osl_Profile_DEFAULT 0x0000
#define osl_Profile_SYSTEM 0x0001 /* use system depended functionality */
#define osl_Profile_READLOCK 0x0002 /* lock file for reading */
#define osl_Profile_WRITELOCK 0x0004 /* lock file for writing */
#define osl_Profile_FLUSHWRITE 0x0010 /* writing only with flush */
typedef void* oslProfile;
/** Deprecated API.
Open or create a configuration profile.
@retval 0 if the profile could not be created, otherwise a handle to the profile.
@deprecated
*/
SAL_DLLPUBLIC oslProfile SAL_CALL osl_openProfile(
rtl_uString *strProfileName, oslProfileOption Options) SAL_COLD;
/** Deprecated API.
Close the opened profile an flush all data to the disk.
@param Profile handle to an opened profile.
@deprecated
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_closeProfile(
oslProfile Profile) SAL_COLD;
/** Deprecated API.
@deprecated
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_flushProfile(
oslProfile Profile) SAL_COLD;
/** Deprecated API.
@deprecated
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_readProfileString(
oslProfile Profile,
const char* pszSection, const char* pszEntry,
char* pszString, sal_uInt32 MaxLen,
const char* pszDefault) SAL_COLD;
/** Deprecated API.
@deprecated
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_readProfileBool(
oslProfile Profile,
const char* pszSection, const char* pszEntry,
sal_Bool Default) SAL_COLD;
/** Deprecated API.
@deprecated
*/
SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_readProfileIdent(
oslProfile Profile,
const char* pszSection, const char* pszEntry,
sal_uInt32 FirstId, const char* Strings[],
sal_uInt32 Default) SAL_COLD;
/** Deprecated API.
@deprecated
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_writeProfileString(
oslProfile Profile,
const char* pszSection, const char* pszEntry,
const char* pszString) SAL_COLD;
/** Deprecated API.
@deprecated
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_writeProfileBool(
oslProfile Profile,
const char* pszSection, const char* pszEntry,
sal_Bool Value) SAL_COLD;
/** Deprecated API.
@deprecated
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_writeProfileIdent(
oslProfile Profile,
const char* pszSection, const char* pszEntry,
sal_uInt32 FirstId, const char* Strings[],
sal_uInt32 Value) SAL_COLD;
/** Deprecated API.
Acquire the mutex, block if already acquired by another thread.
@retval False if section or entry could not be found.
@deprecated
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_removeProfileEntry(
oslProfile Profile,
const char *pszSection, const char *pszEntry) SAL_COLD;
/** Deprecated API.
Get all entries belonging to the specified section.
@returns Pointer to an array of pointers.
@deprecated
*/
SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getProfileSectionEntries(
oslProfile Profile, const char *pszSection,
char* pszBuffer, sal_uInt32 MaxLen) SAL_COLD;
/** Deprecated API.
Get all section entries
@retval Pointer to an array of pointers.
@deprecated
*/
SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getProfileSections(
oslProfile Profile, char* pszBuffer, sal_uInt32 MaxLen) SAL_COLD;
#ifdef __cplusplus
}
#endif
#endif // INCLUDED_OSL_PROFILE_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-213
View File
@@ -1,213 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
/*
* This file is part of LibreOffice published API.
*/
#ifndef INCLUDED_OSL_PROFILE_HXX
#define INCLUDED_OSL_PROFILE_HXX
#include "osl/profile.h"
#include "rtl/ustring.hxx"
#include <string.h>
#include <exception>
#include <list>
namespace osl {
typedef oslProfileOption ProfileOption;
const int Profile_DEFAULT = osl_Profile_DEFAULT;
const int Profile_SYSTEM = osl_Profile_SYSTEM; /* use system depended functionality */
const int Profile_READLOCK = osl_Profile_READLOCK; /* lock file for reading */
const int Profile_WRITELOCK = osl_Profile_WRITELOCK; /* lock file for writing */
/** Deprecated API.
@deprecated
*/
class Profile {
oslProfile profile;
public:
/** Open or create a configuration profile.
Sets a handle to the profile, otherwise if the profile could not be opened then throw an exception.
*/
Profile(const rtl::OUString & strProfileName, oslProfileOption Options = Profile_DEFAULT )
{
profile = osl_openProfile(strProfileName.pData, Options);
if( ! profile )
throw std::exception();
}
/** Close the opened profile an flush all data to the disk.
*/
~Profile()
{
osl_closeProfile(profile);
}
bool flush()
{
return osl_flushProfile(profile);
}
rtl::OString readString( const rtl::OString& rSection, const rtl::OString& rEntry,
const rtl::OString& rDefault)
{
char aBuf[1024];
return osl_readProfileString( profile,
rSection.getStr(),
rEntry.getStr(),
aBuf,
sizeof( aBuf ),
rDefault.getStr() ) ? rtl::OString( aBuf ) : rtl::OString();
}
bool readBool( const rtl::OString& rSection, const rtl::OString& rEntry, bool bDefault )
{
return osl_readProfileBool( profile, rSection.getStr(), rEntry.getStr(), bDefault );
}
sal_uInt32 readIdent(const rtl::OString& rSection, const rtl::OString& rEntry,
sal_uInt32 nFirstId, const std::list< rtl::OString >& rStrings,
sal_uInt32 nDefault)
{
size_t nItems = rStrings.size();
const char** pStrings = new const char*[ nItems+1 ];
std::list< rtl::OString >::const_iterator it = rStrings.begin();
nItems = 0;
while( it != rStrings.end() )
{
pStrings[ nItems++ ] = it->getStr();
++it;
}
pStrings[ nItems ] = NULL;
sal_uInt32 nRet = osl_readProfileIdent(profile, rSection.getStr(), rEntry.getStr(), nFirstId, pStrings, nDefault);
delete[] pStrings;
return nRet;
}
bool writeString(const rtl::OString& rSection, const rtl::OString& rEntry,
const rtl::OString& rString)
{
return osl_writeProfileString(profile, rSection.getStr(), rEntry.getStr(), rString.getStr());
}
bool writeBool(const rtl::OString& rSection, const rtl::OString& rEntry, bool Value)
{
return osl_writeProfileBool(profile, rSection.getStr(), rEntry.getStr(), Value);
}
bool writeIdent(const rtl::OString& rSection, const rtl::OString& rEntry,
sal_uInt32 nFirstId, const std::list< rtl::OString >& rStrings,
sal_uInt32 nValue)
{
size_t nItems = rStrings.size();
const char** pStrings = new const char*[ nItems+1 ];
std::list< rtl::OString >::const_iterator it = rStrings.begin();
nItems = 0;
while( it != rStrings.end() )
{
pStrings[ nItems++ ] = it->getStr();
++it;
}
pStrings[ nItems ] = NULL;
bool bRet =
osl_writeProfileIdent(profile, rSection.getStr(), rEntry.getStr(), nFirstId, pStrings, nValue );
delete[] pStrings;
return bRet;
}
/** Remove an entry from a section.
@param rSection Name of the section.
@param rEntry Name of the entry to remove.
@retval False if section or entry could not be found.
*/
bool removeEntry(const rtl::OString& rSection, const rtl::OString& rEntry)
{
return osl_removeProfileEntry(profile, rSection.getStr(), rEntry.getStr());
}
/** Get all entries belonging to the specified section.
@param rSection Name of the section.
@return Pointer to an array of pointers.
*/
std::list< rtl::OString > getSectionEntries(const rtl::OString& rSection )
{
std::list< rtl::OString > aEntries;
// count buffer size necessary
size_t n = osl_getProfileSectionEntries( profile, rSection.getStr(), NULL, 0 );
if( n > 1 )
{
char* pBuf = new char[ n+1 ];
osl_getProfileSectionEntries( profile, rSection.getStr(), pBuf, n+1 );
size_t nLen;
for( n = 0; ; n += nLen+1 )
{
nLen = strlen( pBuf+n );
if (!nLen)
break;
aEntries.push_back( rtl::OString( pBuf+n ) );
}
delete[] pBuf;
}
return aEntries;
}
/** Get all section entries
@return Pointer to an array of pointers.
*/
std::list< rtl::OString > getSections()
{
std::list< rtl::OString > aSections;
// count buffer size necessary
size_t n = osl_getProfileSections( profile, NULL, 0 );
if( n > 1 )
{
char* pBuf = new char[ n+1 ];
osl_getProfileSections( profile, pBuf, n+1 );
size_t nLen;
for( n = 0; ; n += nLen+1 )
{
nLen = strlen( pBuf+n );
if (!nLen)
break;
aSections.push_back( rtl::OString( pBuf+n ) );
}
delete[] pBuf;
}
return aSections;
}
};
}
#endif // INCLUDED_OSL_PROFILE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-2
View File
@@ -102,8 +102,6 @@ $(eval $(call gb_Package_add_files_with_dir,odk_headers,$(SDKDIRNAME)/include,\
osl/pipe.hxx \
osl/pipe_decl.hxx \
osl/process.h \
osl/profile.h \
osl/profile.hxx \
osl/security.h \
osl/security.hxx \
osl/security_decl.hxx \
-1
View File
@@ -21,7 +21,6 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sal_osl,\
sal/qa/osl/pipe/osl_Pipe \
sal/qa/osl/process/osl_process \
sal/qa/osl/process/osl_Thread \
sal/qa/osl/profile/osl_old_testprofile \
sal/qa/osl/setthreadname/test-setthreadname \
sal/qa/osl/socket \
))
-2
View File
@@ -171,7 +171,6 @@ $(eval $(call gb_Library_add_exception_objects,sal,\
sal/osl/unx/pipe \
sal/osl/unx/process \
sal/osl/unx/process_impl \
sal/osl/unx/profile \
sal/osl/unx/random \
sal/osl/unx/readwrite_helper \
sal/osl/unx/salinit \
@@ -235,7 +234,6 @@ $(eval $(call gb_Library_add_exception_objects,sal,\
sal/osl/w32/pipe \
sal/osl/w32/process \
sal/osl/w32/procimpl \
sal/osl/w32/profile \
sal/osl/w32/random \
sal/osl/w32/salinit \
sal/osl/w32/security \
-1
View File
@@ -59,7 +59,6 @@
#include <osl/mutex.hxx>
#include <osl/pipe.h>
#include <osl/process.h>
#include <osl/profile.hxx>
#include <osl/security.hxx>
#include <osl/signal.h>
#include <osl/socket.h>
+48
View File
@@ -47,6 +47,10 @@ SAL_DLLPUBLIC void SAL_CALL osl_clearSocketSet(void *) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_closeProfile(void*) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT void * SAL_CALL osl_createSemaphore(sal_uInt32) {
for (;;) { std::abort(); } // avoid "must return a value" warnings
}
@@ -69,14 +73,42 @@ SAL_DLLPUBLIC void SAL_CALL osl_destroySocketSet(void *) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_flushProfile(void*) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_getEthernetAddress(sal_uInt8 *) {
for (;;) { std::abort(); } // avoid "must return a value" warnings
}
SAL_DLLPUBLIC_EXPORT sal_uInt32 SAL_CALL osl_getProfileSectionEntries(void*, const char*, char*, sal_uInt32) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_uInt32 SAL_CALL osl_getProfileSections(void*, char*, sal_uInt32) {
std::abort();
}
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isInSocketSet(void *, oslSocket) {
for (;;) { std::abort(); } // avoid "must return a value" warnings
}
SAL_DLLPUBLIC_EXPORT void* SAL_CALL osl_openProfile(rtl_uString*, sal_uInt32) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_readProfileBool(void*, const char*, const char*, sal_Bool) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_uInt32 SAL_CALL osl_readProfileIdent(void*, const char*, const char*, sal_uInt32, const char**, sal_uInt32) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_readProfileString(void*, const char*, const char*, char*, sal_uInt32, const char*) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT oslSocket SAL_CALL osl_receiveResourcePipe(oslPipe) {
for (;;) { std::abort(); } // avoid "must return a value" warnings
}
@@ -85,6 +117,10 @@ SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_releaseSemaphore(void *) {
for (;;) { std::abort(); } // avoid "must return a value" warnings
}
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_removeProfileEntry(void*, const char*, const char*) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_Int32 SAL_CALL osl_reportError(
sal_uInt32, char const *)
{
@@ -125,6 +161,18 @@ SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_tryToAcquireSemaphore(void *) {
for (;;) { std::abort(); } // avoid "must return a value" warnings
}
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_writeProfileBool(void*, const char*, const char*, sal_Bool) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_writeProfileIdent(void*, const char*, const char*, sal_uInt32, const char**, sal_uInt32) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_writeProfileString(void*, const char*, const char*, const char*) {
std::abort();
}
SAL_DLLPUBLIC_EXPORT sal_Int32 SAL_CALL rtl_addUnloadingListener(
void (SAL_CALL *)(void *), void *)
{
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,60 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <osl/profile.h>
#include <rtl/bootstrap.hxx>
namespace osl_Profile
{
class oldtests : public CppUnit::TestFixture
{
public:
void test_profile();
CPPUNIT_TEST_SUITE( oldtests );
CPPUNIT_TEST( test_profile );
CPPUNIT_TEST_SUITE_END( );
};
void oldtests::test_profile()
{
OUString baseUrl;
CPPUNIT_ASSERT(rtl::Bootstrap::get(u"UserInstallation"_ustr, baseUrl));
// successful write
oslProfile hProfile = osl_openProfile( OUString(baseUrl + "/soffice.ini").pData, osl_Profile_WRITELOCK );
CPPUNIT_ASSERT(hProfile != nullptr);
CPPUNIT_ASSERT_MESSAGE(
"cannot write into init file",
osl_writeProfileBool( hProfile, "testsection", "testbool", true ));
CPPUNIT_ASSERT(osl_closeProfile( hProfile ));
// unsuccessful open
CPPUNIT_ASSERT_EQUAL(oslProfile(nullptr), osl_openProfile( OUString(baseUrl + "/not_existing_path/soffice.ini").pData, osl_Profile_WRITELOCK ));
}
} // namespace osl_Profile
CPPUNIT_TEST_SUITE_REGISTRATION( osl_Profile::oldtests );
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-5
View File
@@ -5254,8 +5254,6 @@ include/osl/nlsupport.h
include/osl/pipe.h
include/osl/pipe.hxx
include/osl/process.h
include/osl/profile.h
include/osl/profile.hxx
include/osl/security.h
include/osl/security.hxx
include/osl/security_decl.hxx
@@ -7328,7 +7326,6 @@ sal/osl/unx/osxlocale.cxx
sal/osl/unx/pipe.cxx
sal/osl/unx/process.cxx
sal/osl/unx/process_impl.cxx
sal/osl/unx/profile.cxx
sal/osl/unx/readwrite_helper.cxx
sal/osl/unx/salinit.cxx
sal/osl/unx/security.cxx
@@ -7358,7 +7355,6 @@ sal/osl/w32/path_helper.hxx
sal/osl/w32/pipe.cxx
sal/osl/w32/process.cxx
sal/osl/w32/procimpl.cxx
sal/osl/w32/profile.cxx
sal/osl/w32/salinit.cxx
sal/osl/w32/security.cxx
sal/osl/w32/socket.cxx
@@ -7384,7 +7380,6 @@ sal/qa/osl/pipe/osl_Pipe.cxx
sal/qa/osl/process/osl_Thread.cxx
sal/qa/osl/process/osl_process.cxx
sal/qa/osl/process/osl_process_child.cxx
sal/qa/osl/profile/osl_old_testprofile.cxx
sal/qa/osl/security/TODO.h
sal/qa/osl/security/osl_Security.cxx
sal/qa/osl/setthreadname/test-setthreadname.cxx