reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
SiloStore.cxx
Go to the documentation of this file.
1#include "rutil/Logger.hxx"
3#include "rutil/Lock.hxx"
4
6
7#include "repro/SiloStore.hxx"
9
10
11using namespace resip;
12using namespace repro;
13using namespace std;
14
15#define RESIPROCATE_SUBSYSTEM Subsystem::REPRO
16
17
19 mDb(db)
20{
21}
22
26
27bool
29 const resip::Data& sourceUri,
30 time_t originalSendTime,
31 const resip::Data& tid,
32 const resip::Data& mimeType,
33 const resip::Data& messageBody)
34{
36 rec.mDestUri = destUri;
37 rec.mSourceUri = sourceUri;
38 rec.mOriginalSentTime = originalSendTime;
39 rec.mTid = tid;
40 rec.mMimeType = mimeType;
41 rec.mMessageBody = messageBody;
42
43 Key key = buildKey(originalSendTime, tid);
44 return mDb.addToSilo(key, rec);
45}
46
47bool
49{
50 // Note: This fn uses the secondary cursor, and cleanupExpiredSiloRecords uses the
51 // primary cursor, so there should be no need to provide locking at this level (at
52 // least that's the theory - assuming the db performs it's own locking properly)
53 return mDb.getSiloRecords(uri, recordList);
54}
55
56void
57SiloStore::deleteSiloRecord(time_t originalSendTime, const resip::Data& tid)
58{
59 Key key = buildKey(originalSendTime, tid);
60 mDb.eraseSiloRecord(key);
61}
62
63void
64SiloStore::cleanupExpiredSiloRecords(uint64_t now, unsigned long expirationTime)
65{
66 mDb.cleanupExpiredSiloRecords(now, expirationTime);
67}
68
70SiloStore::buildKey(time_t originalSendTime, const resip::Data& tid) const
71{
72 Key key((uint64_t)originalSendTime);
73 key += ":" + tid;
74 return key;
75}
76
77/* ====================================================================
78 * The Vovida Software License, Version 1.0
79 *
80 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
81 *
82 * Redistribution and use in source and binary forms, with or without
83 * modification, are permitted provided that the following conditions
84 * are met:
85 *
86 * 1. Redistributions of source code must retain the above copyright
87 * notice, this list of conditions and the following disclaimer.
88 *
89 * 2. Redistributions in binary form must reproduce the above copyright
90 * notice, this list of conditions and the following disclaimer in
91 * the documentation and/or other materials provided with the
92 * distribution.
93 *
94 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
95 * and "Vovida Open Communication Application Library (VOCAL)" must
96 * not be used to endorse or promote products derived from this
97 * software without prior written permission. For written
98 * permission, please contact vocal@vovida.org.
99 *
100 * 4. Products derived from this software may not be called "VOCAL", nor
101 * may "VOCAL" appear in their name, without prior written
102 * permission of Vovida Networks, Inc.
103 *
104 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
105 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
106 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
107 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
108 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
109 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
110 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
111 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
112 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
113 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
114 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
115 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
116 * DAMAGE.
117 *
118 * ====================================================================
119 */
virtual bool addToSilo(const Key &key, const SiloRecord &rec)
virtual void cleanupExpiredSiloRecords(uint64_t now, unsigned long expirationTime)
std::vector< SiloRecord > SiloRecordList
virtual void eraseSiloRecord(const Key &key)
virtual bool getSiloRecords(const Key &skey, SiloRecordList &recordList)
void deleteSiloRecord(time_t originalSendTime, const resip::Data &tid)
Definition SiloStore.cxx:57
void cleanupExpiredSiloRecords(uint64_t now, unsigned long expirationTime)
Definition SiloStore.cxx:64
SiloStore(AbstractDb &db)
Definition SiloStore.cxx:18
resip::Data Key
Definition SiloStore.hxx:20
bool addMessage(const resip::Data &destUri, const resip::Data &sourceUri, time_t originalSendTime, const resip::Data &tid, const resip::Data &mimeType, const resip::Data &messageBody)
Definition SiloStore.cxx:28
bool getSiloRecords(const resip::Data &uri, AbstractDb::SiloRecordList &recordList)
Definition SiloStore.cxx:48
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
unsigned __int64 uint64_t
Definition stdint.h:95