comparison 3rdparty/vmime/examples/example7.cpp @ 0:a4671277546c tip

created the repository for the thymian project
author ferencd
date Tue, 17 Aug 2021 11:19:54 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a4671277546c
1 //
2 // VMime library (http://www.vmime.org)
3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 3 of
8 // the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // Linking this library statically or dynamically with other modules is making
20 // a combined work based on this library. Thus, the terms and conditions of
21 // the GNU General Public License cover the whole combination.
22 //
23
24 //
25 // EXAMPLE DESCRIPTION:
26 // ====================
27 // This sample program demonstrates how to enumerate encoders and
28 // messaging services in VMime.
29 //
30 // For more information, please visit:
31 // http://www.vmime.org/
32 //
33
34 #include <iostream>
35 #include <locale>
36 #include <clocale>
37
38 #include "vmime/vmime.hpp"
39 #include "vmime/platforms/posix/posixHandler.hpp"
40
41
42 int main()
43 {
44 // Enumerate encoders
45 vmime::shared_ptr <vmime::utility::encoder::encoderFactory> ef =
46 vmime::utility::encoder::encoderFactory::getInstance();
47
48 std::cout << "Available encoders:" << std::endl;
49
50 for (int i = 0 ; i < ef->getEncoderCount() ; ++i)
51 {
52 vmime::shared_ptr <const vmime::utility::encoder::encoderFactory::registeredEncoder>
53 enc = ef->getEncoderAt(i);
54
55 std::cout << " * " << enc->getName() << std::endl;
56
57 vmime::shared_ptr <vmime::utility::encoder::encoder> e =
58 vmime::utility::encoder::encoderFactory::getInstance()->create(enc->getName());
59
60 std::vector <vmime::string> props = e->getAvailableProperties();
61
62 for (std::vector <vmime::string>::const_iterator it = props.begin() ; it != props.end() ; ++it)
63 std::cout << " - " << *it << std::endl;
64 }
65
66 std::cout << std::endl;
67
68 // Enumerate messaging services and their properties
69 vmime::shared_ptr <vmime::net::serviceFactory> sf =
70 vmime::net::serviceFactory::getInstance();
71
72 std::cout << "Available messaging services:" << std::endl;
73
74 for (int i = 0 ; i < sf->getServiceCount() ; ++i)
75 {
76 const vmime::net::serviceFactory::registeredService& serv = *sf->getServiceAt(i);
77
78 std::cout << " * " << serv.getName() << std::endl;
79
80 std::vector <vmime::net::serviceInfos::property> props =
81 serv.getInfos().getAvailableProperties();
82
83 for (std::vector <vmime::net::serviceInfos::property>::const_iterator it = props.begin() ;
84 it != props.end() ; ++it)
85 {
86 const vmime::net::serviceInfos::property& p = *it;
87
88 const vmime::string name = serv.getInfos().getPropertyPrefix() + p.getName();
89
90 vmime::string type;
91
92 switch (p.getType())
93 {
94 case vmime::net::serviceInfos::property::TYPE_INTEGER: type = "TYPE_INTEGER"; break;
95 case vmime::net::serviceInfos::property::TYPE_STRING: type = "TYPE_STRING"; break;
96 case vmime::net::serviceInfos::property::TYPE_BOOLEAN: type = "TYPE_BOOLEAN"; break;
97 default: type = "(unknown)"; break;
98 }
99
100 vmime::string flags;
101
102 if (p.getFlags() & vmime::net::serviceInfos::property::FLAG_REQUIRED)
103 flags += " FLAG_REQUIRED";
104 if (p.getFlags() & vmime::net::serviceInfos::property::FLAG_HIDDEN)
105 flags += " FLAG_HIDDEN";
106
107 std::cout << " - " << serv.getInfos().getPropertyPrefix() + p.getName();
108 std::cout << " (type=" << type << ", flags=" << flags;
109 std::cout << ", defaultValue=" << p.getDefaultValue() << ")" << std::endl;
110 }
111 }
112
113 std::cout << std::endl;
114 }
115