cid#1606940 Check of thread-shared field evades lock acquisition
[LibreOffice.git] / dbaccess / source / ui / dlg / dbadmin.cxx
blob27b2262567369d96d0249eb2b90d6f3180b0b77e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "ConnectionPage.hxx"
21 #include "DbAdminImpl.hxx"
22 #include "DriverSettings.hxx"
23 #include "adminpages.hxx"
24 #include <dbadmin.hxx>
25 #include <svl/stritem.hxx>
26 #include <svl/eitem.hxx>
27 #include <svl/intitem.hxx>
28 #include <core_resource.hxx>
29 #include <strings.hrc>
30 #include <dsitems.hxx>
31 #include "dsnItem.hxx"
32 #include "optionalboolitem.hxx"
33 #include <stringlistitem.hxx>
35 #include <unotools/confignode.hxx>
37 namespace dbaui
39 using namespace com::sun::star::uno;
40 using namespace com::sun::star::sdbc;
41 using namespace com::sun::star::beans;
43 // ODbAdminDialog
44 ODbAdminDialog::ODbAdminDialog(weld::Window* pParent,
45 SfxItemSet const * _pItems,
46 const Reference< XComponentContext >& _rxContext)
47 : SfxTabDialogController(pParent, u"dbaccess/ui/admindialog.ui"_ustr, u"AdminDialog"_ustr, _pItems)
48 , m_sMainPageID(u"advanced"_ustr)
50 m_pImpl.reset(new ODbDataSourceAdministrationHelper(_rxContext, m_xDialog.get(), pParent, this));
52 // add the initial tab page
53 AddTabPage(m_sMainPageID, OConnectionTabPage::Create, nullptr);
55 // remove the reset button - it's meaning is much too ambiguous in this dialog
56 RemoveResetButton();
59 ODbAdminDialog::~ODbAdminDialog()
61 SetInputSet(nullptr);
64 short ODbAdminDialog::Ok()
66 SfxTabDialogController::Ok();
67 return ( AR_LEAVE_MODIFIED == implApplyChanges() ) ? RET_OK : RET_CANCEL;
68 // TODO : AR_ERROR is not handled correctly, we always close the dialog here
71 void ODbAdminDialog::PageCreated(const OUString& rId, SfxTabPage& _rPage)
73 // register ourself as modified listener
74 static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory( getORB() );
75 static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this);
77 SfxTabDialogController::PageCreated(rId, _rPage);
80 void ODbAdminDialog::addDetailPage(const OUString& rPageId, TranslateId pTextId, CreateTabPage pCreateFunc)
82 AddTabPage(rPageId, DBA_RES(pTextId), pCreateFunc);
85 void ODbAdminDialog::impl_selectDataSource(const css::uno::Any& _aDataSourceName)
87 m_pImpl->setDataSourceOrName(_aDataSourceName);
88 Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
89 impl_resetPages( xDatasource );
91 const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const DbuTypeCollectionItem*>(getOutputSet()->GetItem(DSID_TYPECOLLECTION));
92 assert(pCollectionItem && "must exist");
93 ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection();
94 ::dbaccess::DATASOURCE_TYPE eType = pCollection->determineType(getDatasourceType(*getOutputSet()));
96 // and insert the new ones
97 switch ( eType )
99 case ::dbaccess::DST_DBASE:
100 addDetailPage(u"dbase"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateDbase);
101 break;
103 case ::dbaccess::DST_ADO:
104 addDetailPage(u"ado"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdo);
105 break;
107 case ::dbaccess::DST_FLAT:
108 addDetailPage(u"text"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateText);
109 break;
111 case ::dbaccess::DST_ODBC:
112 addDetailPage(u"odbc"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateODBC);
113 break;
115 case ::dbaccess::DST_MYSQL_ODBC:
116 addDetailPage(u"mysqlodbc"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLODBC);
117 break;
119 case ::dbaccess::DST_MYSQL_JDBC:
120 addDetailPage(u"mysqljdbc"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLJDBC);
121 break;
123 case ::dbaccess::DST_ORACLE_JDBC:
124 addDetailPage(u"oraclejdbc"_ustr, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateOracleJDBC);
125 break;
127 case ::dbaccess::DST_LDAP:
128 addDetailPage(u"ldap"_ustr,STR_PAGETITLE_ADVANCED,ODriversSettings::CreateLDAP);
129 break;
130 case ::dbaccess::DST_USERDEFINE1: /// first user defined driver
131 case ::dbaccess::DST_USERDEFINE2:
132 case ::dbaccess::DST_USERDEFINE3:
133 case ::dbaccess::DST_USERDEFINE4:
134 case ::dbaccess::DST_USERDEFINE5:
135 case ::dbaccess::DST_USERDEFINE6:
136 case ::dbaccess::DST_USERDEFINE7:
137 case ::dbaccess::DST_USERDEFINE8:
138 case ::dbaccess::DST_USERDEFINE9:
139 case ::dbaccess::DST_USERDEFINE10:
141 OUString aTitle(DBA_RES(STR_PAGETITLE_ADVANCED));
142 AddTabPage("user" + OUString::number(eType - dbaccess::DST_USERDEFINE1 + 1), aTitle, ODriversSettings::CreateUser);
144 break;
145 default:
146 break;
150 void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasource)
152 // the selection is valid if and only if we have a datasource now
153 GetInputSetImpl()->Put(SfxBoolItem(DSID_INVALID_SELECTION, !_rxDatasource.is()));
154 // (sal_False tells the tab pages to disable and reset all their controls, which is different
155 // from "just set them to readonly")
157 // reset the pages
159 // prevent flicker
160 m_xDialog->freeze();
162 // remove all items which relate to indirect properties from the input set
163 // (without this, the following may happen: select an arbitrary data source where some indirect properties
164 // are set. Select another data source of the same type, where the indirect props are not set (yet). Then,
165 // the indirect property values of the first ds are shown in the second ds ...)
166 const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties();
167 for (auto const& elem : rMap)
168 GetInputSetImpl()->ClearItem( static_cast<sal_uInt16>(elem.first) );
170 // extract all relevant data from the property set of the data source
171 m_pImpl->translateProperties(_rxDatasource, *GetInputSetImpl());
173 // reset the example set
174 m_xExampleSet.reset(new SfxItemSet(*GetInputSetImpl()));
176 // special case: MySQL Native does not have the generic "advanced" page
178 const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const DbuTypeCollectionItem*>(getOutputSet()->GetItem(DSID_TYPECOLLECTION));
179 assert(pCollectionItem && "must exist");
180 ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection();
181 if ( pCollection->determineType(getDatasourceType( *m_xExampleSet )) == ::dbaccess::DST_MYSQL_NATIVE )
183 OUString sMySqlNative(u"mysqlnative"_ustr);
184 AddTabPage(sMySqlNative, DBA_RES(STR_PAGETITLE_CONNECTION), ODriversSettings::CreateMySQLNATIVE);
185 RemoveTabPage(u"advanced"_ustr);
186 m_sMainPageID = sMySqlNative;
189 SetCurPageId(m_sMainPageID);
190 SfxTabPage* pConnectionPage = GetTabPage(m_sMainPageID);
191 if ( pConnectionPage )
192 pConnectionPage->Reset(GetInputSetImpl());
193 // if this is NULL, the page has not been created yet, which means we're called before the
194 // dialog was displayed (probably from inside the ctor)
196 m_xDialog->thaw();
199 void ODbAdminDialog::setTitle(const OUString& rTitle)
201 m_xDialog->set_title(rTitle);
204 void ODbAdminDialog::enableConfirmSettings( bool ) {}
206 void ODbAdminDialog::saveDatasource()
208 PrepareLeaveCurrentPage();
211 ODbAdminDialog::ApplyResult ODbAdminDialog::implApplyChanges()
213 if (!PrepareLeaveCurrentPage())
214 { // the page did not allow us to leave
215 return AR_KEEP;
218 if ( !m_pImpl->saveChanges(*m_xExampleSet) )
219 return AR_KEEP;
221 return AR_LEAVE_MODIFIED;
224 void ODbAdminDialog::selectDataSource(const css::uno::Any& _aDataSourceName)
226 impl_selectDataSource(_aDataSourceName);
229 const SfxItemSet* ODbAdminDialog::getOutputSet() const
231 return GetExampleSet();
234 SfxItemSet* ODbAdminDialog::getWriteOutputSet()
236 return m_xExampleSet.get();
239 std::pair< Reference<XConnection>,bool> ODbAdminDialog::createConnection()
241 return m_pImpl->createConnection();
244 Reference< XComponentContext > ODbAdminDialog::getORB() const
246 return m_pImpl->getORB();
249 Reference< XDriver > ODbAdminDialog::getDriver()
251 return m_pImpl->getDriver();
254 OUString ODbAdminDialog::getDatasourceType(const SfxItemSet& _rSet) const
256 return dbaui::ODbDataSourceAdministrationHelper::getDatasourceType(_rSet);
259 void ODbAdminDialog::clearPassword()
261 m_pImpl->clearPassword();
264 static ItemInfoPackage& getItemInfoPackageAdminDlg()
266 class ItemInfoPackageAdminDlg : public ItemInfoPackage
268 typedef std::array<ItemInfoStatic, DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1> ItemInfoArrayAdminDlg;
269 ItemInfoArrayAdminDlg maItemInfos {{
270 // m_nWhich, m_pItem, m_nSlotID, m_nItemInfoFlags
271 { DSID_NAME, new SfxStringItem(DSID_NAME, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
272 { DSID_ORIGINALNAME, new SfxStringItem(DSID_ORIGINALNAME, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
273 { DSID_CONNECTURL, new SfxStringItem(DSID_CONNECTURL, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
275 // gets added in constructor below once for LO runtime as static default
276 { DSID_TABLEFILTER, nullptr, 0, SFX_ITEMINFOFLAG_NONE },
278 // gets added by callback for each new Pool as dynamic default
279 { DSID_TYPECOLLECTION, nullptr, 0, SFX_ITEMINFOFLAG_NONE },
281 { DSID_INVALID_SELECTION, new SfxBoolItem(DSID_INVALID_SELECTION, false), 0, SFX_ITEMINFOFLAG_NONE },
282 { DSID_READONLY, new SfxBoolItem(DSID_READONLY, false), 0, SFX_ITEMINFOFLAG_NONE },
283 { DSID_USER, new SfxStringItem(DSID_USER, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
284 { DSID_PASSWORD, new SfxStringItem(DSID_PASSWORD, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
285 { DSID_ADDITIONALOPTIONS, new SfxStringItem(DSID_ADDITIONALOPTIONS, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
286 { DSID_CHARSET, new SfxStringItem(DSID_CHARSET, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
287 { DSID_PASSWORDREQUIRED, new SfxBoolItem(DSID_PASSWORDREQUIRED, false), 0, SFX_ITEMINFOFLAG_NONE },
288 { DSID_SHOWDELETEDROWS, new SfxBoolItem(DSID_SHOWDELETEDROWS, false), 0, SFX_ITEMINFOFLAG_NONE },
289 { DSID_ALLOWLONGTABLENAMES, new SfxBoolItem(DSID_ALLOWLONGTABLENAMES, false), 0, SFX_ITEMINFOFLAG_NONE },
290 { DSID_JDBCDRIVERCLASS, new SfxStringItem(DSID_JDBCDRIVERCLASS, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
291 { DSID_FIELDDELIMITER, new SfxStringItem(DSID_FIELDDELIMITER, OUString(',')), 0, SFX_ITEMINFOFLAG_NONE },
292 { DSID_TEXTDELIMITER, new SfxStringItem(DSID_TEXTDELIMITER, OUString('"')), 0, SFX_ITEMINFOFLAG_NONE },
293 { DSID_DECIMALDELIMITER, new SfxStringItem(DSID_DECIMALDELIMITER, OUString('.')), 0, SFX_ITEMINFOFLAG_NONE },
294 { DSID_THOUSANDSDELIMITER, new SfxStringItem(DSID_THOUSANDSDELIMITER, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
295 { DSID_TEXTFILEEXTENSION, new SfxStringItem(DSID_TEXTFILEEXTENSION, u"txt"_ustr), 0, SFX_ITEMINFOFLAG_NONE },
296 { DSID_TEXTFILEHEADER, new SfxBoolItem(DSID_TEXTFILEHEADER, true), 0, SFX_ITEMINFOFLAG_NONE },
297 { DSID_PARAMETERNAMESUBST, new SfxBoolItem(DSID_PARAMETERNAMESUBST, false), 0, SFX_ITEMINFOFLAG_NONE },
298 { DSID_CONN_PORTNUMBER, new SfxInt32Item(DSID_CONN_PORTNUMBER, 8100), 0, SFX_ITEMINFOFLAG_NONE },
299 { DSID_SUPPRESSVERSIONCL, new SfxBoolItem(DSID_SUPPRESSVERSIONCL, false), 0, SFX_ITEMINFOFLAG_NONE },
300 { DSID_CONN_SHUTSERVICE, new SfxBoolItem(DSID_CONN_SHUTSERVICE, false), 0, SFX_ITEMINFOFLAG_NONE },
301 { DSID_CONN_DATAINC, new SfxInt32Item(DSID_CONN_DATAINC, 20), 0, SFX_ITEMINFOFLAG_NONE },
302 { DSID_CONN_CACHESIZE, new SfxInt32Item(DSID_CONN_CACHESIZE, 20), 0, SFX_ITEMINFOFLAG_NONE },
303 { DSID_CONN_CTRLUSER, new SfxStringItem(DSID_CONN_CTRLUSER, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
304 { DSID_CONN_CTRLPWD, new SfxStringItem(DSID_CONN_CTRLPWD, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
305 { DSID_USECATALOG, new SfxBoolItem(DSID_USECATALOG, false), 0, SFX_ITEMINFOFLAG_NONE },
306 { DSID_CONN_HOSTNAME, new SfxStringItem(DSID_CONN_HOSTNAME, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
307 { DSID_CONN_LDAP_BASEDN, new SfxStringItem(DSID_CONN_LDAP_BASEDN, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
308 { DSID_CONN_LDAP_PORTNUMBER, new SfxInt32Item(DSID_CONN_LDAP_PORTNUMBER, 389), 0, SFX_ITEMINFOFLAG_NONE },
309 { DSID_CONN_LDAP_ROWCOUNT, new SfxInt32Item(DSID_CONN_LDAP_ROWCOUNT, 100), 0, SFX_ITEMINFOFLAG_NONE },
310 { DSID_SQL92CHECK, new SfxBoolItem(DSID_SQL92CHECK, false), 0, SFX_ITEMINFOFLAG_NONE },
311 { DSID_AUTOINCREMENTVALUE, new SfxStringItem(DSID_AUTOINCREMENTVALUE, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
312 { DSID_AUTORETRIEVEVALUE, new SfxStringItem(DSID_AUTORETRIEVEVALUE, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
313 { DSID_AUTORETRIEVEENABLED, new SfxBoolItem(DSID_AUTORETRIEVEENABLED, false), 0, SFX_ITEMINFOFLAG_NONE },
314 { DSID_APPEND_TABLE_ALIAS, new SfxBoolItem(DSID_APPEND_TABLE_ALIAS, false), 0, SFX_ITEMINFOFLAG_NONE },
315 { DSID_MYSQL_PORTNUMBER, new SfxInt32Item(DSID_MYSQL_PORTNUMBER, 3306), 0, SFX_ITEMINFOFLAG_NONE },
316 { DSID_IGNOREDRIVER_PRIV, new SfxBoolItem(DSID_IGNOREDRIVER_PRIV, true), 0, SFX_ITEMINFOFLAG_NONE },
317 { DSID_BOOLEANCOMPARISON, new SfxInt32Item(DSID_BOOLEANCOMPARISON, 0), 0, SFX_ITEMINFOFLAG_NONE },
318 { DSID_ORACLE_PORTNUMBER, new SfxInt32Item(DSID_ORACLE_PORTNUMBER, 1521), 0, SFX_ITEMINFOFLAG_NONE },
319 { DSID_ENABLEOUTERJOIN, new SfxBoolItem(DSID_ENABLEOUTERJOIN, true), 0, SFX_ITEMINFOFLAG_NONE },
320 { DSID_CATALOG, new SfxBoolItem(DSID_CATALOG, true), 0, SFX_ITEMINFOFLAG_NONE },
321 { DSID_SCHEMA, new SfxBoolItem(DSID_SCHEMA, true), 0, SFX_ITEMINFOFLAG_NONE },
322 { DSID_INDEXAPPENDIX, new SfxBoolItem(DSID_INDEXAPPENDIX, true), 0, SFX_ITEMINFOFLAG_NONE },
323 { DSID_CONN_LDAP_USESSL, new SfxBoolItem(DSID_CONN_LDAP_USESSL, false), 0, SFX_ITEMINFOFLAG_NONE },
324 { DSID_DOCUMENT_URL, new SfxStringItem(DSID_DOCUMENT_URL, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
325 { DSID_DOSLINEENDS, new SfxBoolItem(DSID_DOSLINEENDS, false), 0, SFX_ITEMINFOFLAG_NONE },
326 { DSID_DATABASENAME, new SfxStringItem(DSID_DATABASENAME, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
327 { DSID_AS_BEFORE_CORRNAME, new SfxBoolItem(DSID_AS_BEFORE_CORRNAME, false), 0, SFX_ITEMINFOFLAG_NONE },
328 { DSID_CHECK_REQUIRED_FIELDS, new SfxBoolItem(DSID_CHECK_REQUIRED_FIELDS, true), 0, SFX_ITEMINFOFLAG_NONE },
329 { DSID_IGNORECURRENCY, new SfxBoolItem(DSID_IGNORECURRENCY, false), 0, SFX_ITEMINFOFLAG_NONE },
330 { DSID_CONN_SOCKET, new SfxStringItem(DSID_CONN_SOCKET, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
331 { DSID_ESCAPE_DATETIME, new SfxBoolItem(DSID_ESCAPE_DATETIME, true), 0, SFX_ITEMINFOFLAG_NONE },
332 { DSID_NAMED_PIPE, new SfxStringItem(DSID_NAMED_PIPE, OUString()), 0, SFX_ITEMINFOFLAG_NONE },
333 { DSID_PRIMARY_KEY_SUPPORT, new OptionalBoolItem( DSID_PRIMARY_KEY_SUPPORT ), 0, SFX_ITEMINFOFLAG_NONE },
334 { DSID_MAX_ROW_SCAN, new SfxInt32Item(DSID_MAX_ROW_SCAN, 100), 0, SFX_ITEMINFOFLAG_NONE },
335 { DSID_RESPECTRESULTSETTYPE, new SfxBoolItem( DSID_RESPECTRESULTSETTYPE,false ), 0, SFX_ITEMINFOFLAG_NONE },
336 { DSID_POSTGRES_PORTNUMBER, new SfxInt32Item(DSID_POSTGRES_PORTNUMBER, 5432), 0, SFX_ITEMINFOFLAG_NONE }
339 virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
341 public:
342 ItemInfoPackageAdminDlg()
344 static constexpr OUString sFilterAll( u"%"_ustr );
345 setItemAtItemInfoStatic(
346 new OStringListItem(DSID_TABLEFILTER, Sequence< OUString >{sFilterAll}),
347 maItemInfos[DSID_TABLEFILTER - DSID_FIRST_ITEM_ID]);
350 virtual size_t size() const override { return maItemInfos.size(); }
351 virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override { return maItemInfos[nIndex]; }
354 static std::unique_ptr<ItemInfoPackageAdminDlg> g_aItemInfoPackageAdminDlg;
355 if (!g_aItemInfoPackageAdminDlg)
356 g_aItemInfoPackageAdminDlg.reset(new ItemInfoPackageAdminDlg);
357 return *g_aItemInfoPackageAdminDlg;
360 void ODbAdminDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, ::dbaccess::ODsnTypeCollection* _pTypeCollection)
362 // just to be sure...
363 _rpSet = nullptr;
364 _rpPool = nullptr;
365 _rpPool = new SfxItemPool(u"DSAItemPool"_ustr);
367 // here we have to use the callback to create all needed default entries since
368 // the DSID_TYPECOLLECTION needs the local given _pTypeCollection. Thus this will
369 // be a ItemInfoDynamic created by SfxItemPool::registerItemInfoPackage. That
370 // (and the contained Item) will be owned by the Pool and cleaned up when it goes
371 // down (see SfxItemPool::cleanupItemInfos())
372 _rpPool->registerItemInfoPackage(
373 getItemInfoPackageAdminDlg(),
374 [&_pTypeCollection](sal_uInt16 nWhich)
376 SfxPoolItem* pRetval(nullptr);
377 if (DSID_TYPECOLLECTION == nWhich)
378 pRetval = new DbuTypeCollectionItem(DSID_TYPECOLLECTION, _pTypeCollection);
379 return pRetval;
382 // and, finally, the set
383 _rpSet.reset(new SfxItemSet(*_rpPool));
386 void ODbAdminDialog::destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool)
388 // _first_ delete the set (referring the pool)
389 _rpSet.reset();
391 // delete the pool
392 _rpPool = nullptr;
395 } // namespace dbaui
397 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */