File indexing completed on 2024-05-05 04:44:58

0001 /*
0002  Copyright (C) 2004 Brad Hards <bradh@frogmouth.net>
0003 
0004  Permission is hereby granted, free of charge, to any person obtaining a copy
0005  of this software and associated documentation files (the "Software"), to deal
0006  in the Software without restriction, including without limitation the rights
0007  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0008  copies of the Software, and to permit persons to whom the Software is
0009  furnished to do so, subject to the following conditions:
0010 
0011  The above copyright notice and this permission notice shall be included in
0012  all copies or substantial portions of the Software.
0013 
0014  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
0017  AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
0018  AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0019  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0020 */
0021 
0022 // QtCrypto has the declarations for all of QCA
0023 #include <QCoreApplication>
0024 #include <QtCrypto>
0025 
0026 #include <iostream>
0027 #include <qstringlist.h>
0028 
0029 #ifdef QT_STATICPLUGIN
0030 #include "import_plugins.h"
0031 #endif
0032 
0033 int main(int argc, char **argv)
0034 {
0035     // the Initializer object sets things up, and
0036     // also does cleanup when it goes out of scope
0037     QCA::Initializer init;
0038 
0039     QCoreApplication app(argc, argv);
0040 
0041     // get all the available providers loaded.
0042     // you don't normally need this (because you test using isSupported())
0043     // but this is a special case.
0044     QCA::scanForPlugins();
0045 
0046     // this gives us all the plugin providers as a list
0047     const QCA::ProviderList qcaProviders = QCA::providers();
0048     for (const QCA::Provider *provider : qcaProviders) {
0049         // each provider has a name, which we can display
0050         std::cout << provider->name().toLatin1().data() << ": ";
0051         // ... and also a list of features
0052         QStringList capabilities = provider->features();
0053         // we turn the string list back into a single string,
0054         // and display it as well
0055         std::cout << capabilities.join(QStringLiteral(", ")).toLatin1().data() << std::endl;
0056     }
0057 
0058     // Note that the default provider isn't included in
0059     // the result of QCA::providers()
0060     std::cout << "default: ";
0061     // However it is still possible to get the features
0062     // supported by the default provider
0063     QStringList capabilities = QCA::defaultFeatures();
0064     std::cout << capabilities.join(QStringLiteral(", ")).toLatin1().data() << std::endl;
0065     return 0;
0066 }