Libksieve

sasl-common.h
1 /* This file is part of the KDE project
2  Copyright (C) 2008 JarosÅ‚aw Staniek <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 //krazy:excludeall=null since used by SASL (C library)
21 
22 #ifndef KSIEVE_KMANAGESIEVE_SASL_COMMON_H
23 #define KSIEVE_KMANAGESIEVE_SASL_COMMON_H
24 
25 #include <stdio.h>
26 #include <QFile>
27 #include <QDir>
28 
29 #ifdef Q_OS_WIN
30 #include <QCoreApplication>
31 #endif
32 
33 extern "C" {
34 #include <sasl/sasl.h>
35 }
36 
37 inline bool initSASL()
38 {
39 #ifdef Q_OS_WIN //krazy:exclude=cpp
40  for (const auto &path : QCoreApplication::libraryPaths()) {
41  QDir dir(path);
42  if (dir.exists(QStringLiteral("sasl2"))) {
43  auto libInstallPath = QFile::encodeName(dir.absoluteFilePath(QStringLiteral("sasl2")));
44  if (sasl_set_path(SASL_PATH_TYPE_PLUGIN, libInstallPath.data()) != SASL_OK) {
45  fprintf(stderr, "SASL path initialization failed!\n");
46  return false;
47  }
48  break;
49  }
50  }
51 #endif
52 
53  if (sasl_client_init(nullptr) != SASL_OK) {
54  fprintf(stderr, "SASL library initialization failed!\n");
55  return false;
56  }
57  return true;
58 }
59 
60 #endif
QStringList libraryPaths()
KIOFILEWIDGETS_EXPORT QString dir(const QString &fileClass)
QByteArray encodeName(const QString &fileName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Aug 10 2020 23:12:59 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.