blob: 7aa6dd05cb8458555595fb4254b1175e34558c5d [file] [log] [blame]
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -05001/*
2 Copyright (C) 2006-2013 Werner Dittmann
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <stdio.h>
19
20#include <libzrtpcpp/ZIDCache.h>
21#include <libzrtpcpp/ZIDRecordDb.h>
22#include <libzrtpcpp/zrtpCacheDbBackend.h>
23
24#ifndef _ZIDCACHEDB_H_
25#define _ZIDCACHEDB_H_
26
27
28/**
29 * @file ZIDCacheDb.h
30 * @brief ZID cache management
31 *
32 * A ZID file stores (caches) some data that helps ZRTP to achives its
33 * key continuity feature. See @c ZIDRecordDb for further info which data
34 * the ZID file contains.
35 *
36 * @ingroup GNU_ZRTP
37 * @{
38 */
39
40/**
41 * This class implements a ZID (ZRTP Identifiers) file.
42 *
43 * The interface defintion @c ZIDCache.h contains the method documentation.
44 * The ZID cache file holds information about peers.
45 *
46 * @author: Werner Dittmann <Werner.Dittmann@t-online.de>
47 */
48
49class __EXPORT ZIDCacheDb: public ZIDCache {
50
51private:
52
53 void *zidFile;
54 unsigned char associatedZid[IDENTIFIER_LEN];
55
56 dbCacheOps_t cacheOps;
57
58 char errorBuffer[DB_CACHE_ERR_BUFF_SIZE];
59
60 void createZIDFile(char* name);
61
62public:
63
64 ZIDCacheDb(): zidFile(NULL) {
65 getDbCacheOps(&cacheOps);
66 };
67
68 ~ZIDCacheDb();
69
70 int open(char *name);
71
72 bool isOpen() { return (zidFile != NULL); };
73
74 void close();
75
76 ZIDRecord *getRecord(unsigned char *zid);
77
78 unsigned int saveRecord(ZIDRecord *zidRecord);
79
80 const unsigned char* getZid() { return associatedZid; };
81
82 int32_t getPeerName(const uint8_t *peerZid, std::string *name);
83
84 void putPeerName(const uint8_t *peerZid, const std::string name);
85
86 void cleanup();
87
88};
89
90/**
91 * @}
92 */
93#endif