File indexing completed on 2024-05-12 05:17:21
0001 /* This file is part of the KDE project 0002 Copyright (C) 2008 Jarosław Staniek <staniek@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef _KIOSLAVE_COMMON_H 0021 #define _KIOSLAVE_COMMON_H 0022 0023 #include <stdio.h> 0024 #include <QFile> 0025 #include <QDir> 0026 #include <QCoreApplication> 0027 0028 extern "C" { 0029 #include <sasl/sasl.h> 0030 } 0031 0032 inline bool initSASL() 0033 { 0034 #ifdef Q_OS_WIN 0035 for (const auto &path : QCoreApplication::libraryPaths()) { 0036 QDir dir(path); 0037 if (dir.exists(QStringLiteral("sasl2"))) { 0038 auto libInstallPath = QFile::encodeName(dir.absoluteFilePath(QStringLiteral("sasl2"))); 0039 if (sasl_set_path(SASL_PATH_TYPE_PLUGIN, libInstallPath.data()) != SASL_OK) { 0040 fprintf(stderr, "SASL path initialization failed!\n"); 0041 return false; 0042 } 0043 break; 0044 } 0045 } 0046 #endif 0047 0048 if (sasl_client_init(Q_NULLPTR) != SASL_OK) { 0049 fprintf(stderr, "SASL library initialization failed!\n"); 0050 return false; 0051 } 0052 return true; 0053 } 0054 0055 #endif