4 Test application for profile database and profile classes
6 Copyright (C) Brad Hards <bradh@openchange.org> 2010.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include <libmapi++/libmapi++.h>
27 #define PROFILEDB_NAME_TEMPLATE "/tmp/mapidbXXXXXX"
31 libmapipp::profile_database db;
33 std::cout << "default profile name: " << db.get_default_profile_name() << std::endl;
36 char *tmpname = (char*) calloc(sizeof(PROFILEDB_NAME_TEMPLATE) + 1, sizeof(char));
37 strncpy(tmpname, PROFILEDB_NAME_TEMPLATE, sizeof(PROFILEDB_NAME_TEMPLATE));
38 int ret = mkstemp(tmpname);
40 std::cout << "failed to create temporary file: " << strerror(errno) << std::endl;
42 if (libmapipp::profile_database::create_profile_store(tmpname)) {
43 std::cout << "success creating a temporary profile store" << std::endl;
45 std::cout << "failed to create a temporary profile store" << std::endl;
51 char *tmpname2 = (char*) calloc(sizeof(PROFILEDB_NAME_TEMPLATE) + 1, sizeof(char));
52 strncpy(tmpname2, PROFILEDB_NAME_TEMPLATE, sizeof(PROFILEDB_NAME_TEMPLATE));
53 int ret = mkstemp(tmpname2);
55 std::cout << "failed to create temporary file: " << strerror(errno) << std::endl;
57 if (libmapipp::profile_database::create_profile_store(std::string(tmpname2))) {
58 std::cout << "success creating a temporary profile store with std::string" << std::endl;
60 std::cout << "failed to create a temporary profile store with std::string" << std::endl;
65 std::cout << "finished profile and profile database tests" << std::endl;
67 catch (libmapipp::mapi_exception e) // Catch any mapi exceptions
69 std::cout << "MAPI Exception @ main: " << e.what() << std::endl;
71 catch (std::runtime_error e) // Catch runtime exceptions
73 std::cout << "std::runtime_error exception @ main: " << e.what() << std::endl;