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