KIMAP

common.h
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2008 Jarosław Staniek <staniek@kde.org>
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
14extern "C" {
15#include <sasl/sasl.h>
16}
17
18inline 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}
KIOCORE_EXPORT QString dir(const QString &fileClass)
QStringList libraryPaths()
QByteArray encodeName(const QString &fileName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:06:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.