KIMAP

common.h
1 /* This file is part of the KDE project
2  SPDX-FileCopyrightText: 2008 JarosÅ‚aw Staniek <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QCoreApplication>
10 #include <QDir>
11 #include <QFile>
12 #include <stdio.h>
13 
14 extern "C" {
15 #include <sasl/sasl.h>
16 }
17 
18 inline bool initSASL()
19 {
20 #ifdef Q_OS_WIN // krazy:exclude=cpp
21  for (const auto &path : QCoreApplication::libraryPaths()) {
22  QDir dir(path);
23  if (dir.exists(QStringLiteral("sasl2"))) {
24  auto libInstallPath = QFile::encodeName(dir.absoluteFilePath(QStringLiteral("sasl2")));
25  if (sasl_set_path(SASL_PATH_TYPE_PLUGIN, libInstallPath.data()) != SASL_OK) {
26  fprintf(stderr, "SASL path initialization failed!\n");
27  return false;
28  }
29  break;
30  }
31  }
32 #endif
33 
34  if (sasl_client_init(nullptr) != SASL_OK) {
35  fprintf(stderr, "SASL library initialization failed!\n");
36  return false;
37  }
38  return true;
39 }
QByteArray encodeName(const QString &fileName)
QStringList libraryPaths()
KIOFILEWIDGETS_EXPORT QString dir(const QString &fileClass)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 03:51:44 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.