1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <config_folders.h>
22 #include <unx/gensys.h>
26 #include <rtl/strbuf.hxx>
27 #include <rtl/bootstrap.hxx>
28 #include <osl/process.h>
29 #include <osl/thread.h>
30 #include <unotools/configmgr.hxx>
32 using namespace com::sun::star
;
34 SalGenericSystem::SalGenericSystem()
38 SalGenericSystem::~SalGenericSystem()
42 int SalGenericSystem::ShowNativeMessageBox( const OUString
& rTitle
, const OUString
& rMessage
)
44 std::vector
< OUString
> aButtons
;
45 int nButtonIds
[5] = {0}, nBut
= 0;
49 aButtons
.push_back( "OK" );
50 nButtonIds
[nBut
++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK
;
51 int nResult
= ShowNativeDialog( rTitle
, rMessage
, aButtons
);
53 return nResult
!= -1 ? nButtonIds
[ nResult
] : 0;
56 #if !defined(ANDROID) && !defined(IOS)
60 const char* SalGenericSystem::getFrameResName()
62 /* according to ICCCM:
63 * first search command line for -name parameter
64 * then try RESOURCE_NAME environment variable
65 * then use argv[0] stripped by directories
67 static OStringBuffer aResName
;
68 if( aResName
.isEmpty() )
70 int nArgs
= osl_getCommandArgCount();
71 for( int n
= 0; n
< nArgs
-1; n
++ )
74 osl_getCommandArg( n
, &aArg
.pData
);
75 if( aArg
.equalsIgnoreAsciiCase("-name") )
77 osl_getCommandArg( n
+1, &aArg
.pData
);
78 aResName
.append( OUStringToOString( aArg
, osl_getThreadTextEncoding() ) );
82 if( aResName
.isEmpty() )
84 const char* pEnv
= getenv( "RESOURCE_NAME" );
86 aResName
.append( pEnv
);
88 if( aResName
.isEmpty() )
89 aResName
.append( OUStringToOString( utl::ConfigManager::getProductName().toAsciiLowerCase(),
90 osl_getThreadTextEncoding()));
92 return aResName
.getStr();
95 const char* SalGenericSystem::getFrameClassName()
97 static OStringBuffer aClassName
;
98 if( aClassName
.isEmpty() )
100 OUString aIni
, aProduct
;
101 rtl::Bootstrap::get( "BRAND_BASE_DIR", aIni
);
102 aIni
+= "/" LIBO_ETC_FOLDER
"/" SAL_CONFIGFILE( "bootstrap" );
103 rtl::Bootstrap
aBootstrap( aIni
);
104 aBootstrap
.getFrom( "ProductKey", aProduct
);
106 if( !aProduct
.isEmpty() )
107 aClassName
.append( OUStringToOString( aProduct
, osl_getThreadTextEncoding() ) );
109 aClassName
.append( OUStringToOString( utl::ConfigManager::getProductName(), osl_getThreadTextEncoding()));
111 return aClassName
.getStr();
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */