/usr/include/resip/dum/InMemorySyncPubDb.hxx is in libresiprocate-1.11-dev 1:1.11.0~beta5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | #if !defined(RESIP_INMEMORYSYNCPUBDB_HXX)
#define RESIP_INMEMORYSYNCPUBDB_HXX
#include <list>
#include "resip/dum/PublicationPersistenceManager.hxx"
#include "rutil/Mutex.hxx"
#include "rutil/Lock.hxx"
namespace resip
{
class SecurityAttributes;
class InMemorySyncPubDbHandler
{
public:
typedef enum
{
SyncServer,
AllChanges
} HandlerMode;
InMemorySyncPubDbHandler(HandlerMode mode = SyncServer) : mMode(mode) {}
virtual ~InMemorySyncPubDbHandler(){}
HandlerMode getMode() { return mMode; }
virtual void onDocumentModified(bool sync, const Data& eventType, const Data& documentKey, const Data& eTag, UInt64 expirationTime, UInt64 lastUpdated, const Contents* contents, const SecurityAttributes* securityAttributes) = 0;
virtual void onDocumentRemoved(bool sync, const Data& eventType, const Data& documentKey, const Data& eTag, UInt64 lastUpdated) = 0;
virtual void onInitialSyncDocument(unsigned int connectionId, const Data& eventType, const Data& documentKey, const Data& eTag, UInt64 expirationTime, UInt64 lastUpdated, const Contents* contents, const SecurityAttributes* securityAttributes) {}
protected:
HandlerMode mMode;
};
/**
Implementation of a persistence manager. This class keeps
all publications in memory, and is used for remote replication.
The InMemorySyncPubDbHandler can be used by an external mechanism to
transport publication documents to a remote peer for replication.
See the RegSyncClient and RegSyncServer implementations in the repro
project.
*/
class InMemorySyncPubDb : public PublicationPersistenceManager
{
public:
InMemorySyncPubDb(bool syncEnabled = false);
virtual ~InMemorySyncPubDb();
virtual void addHandler(InMemorySyncPubDbHandler* handler);
virtual void removeHandler(InMemorySyncPubDbHandler* handler);
virtual void initialSync(unsigned int connectionId);
// PublicationPersistenceManager Methods
virtual void addUpdateDocument(const PubDocument& document);
virtual void addUpdateDocument(const Data& eventType, const Data& documentKey, const Data& eTag, UInt64 expirationTime, const Contents* contents, const SecurityAttributes* securityAttributes, bool syncPublication = false);
virtual bool removeDocument(const Data& eventType, const Data& documentKey, const Data& eTag, UInt64 lastUpdated, bool syncPublication = false);
virtual bool getMergedETags(const Data& eventType, const Data& documentKey, ETagMerger& merger, Contents* destination);
virtual bool documentExists(const Data& eventType, const Data& documentKey, const Data& eTag);
virtual bool checkExpired(const Data& eventType, const Data& documentKey, const Data& eTag, UInt64 lastUpdated);
virtual void lockDocuments();
virtual KeyToETagMap& getDocuments(); // Ensure you lock before calling this and unlock when done
virtual void unlockDocuments();
protected:
void invokeOnDocumentModified(bool sync, const Data& eventType, const Data& documentKey, const Data& eTag, UInt64 expirationTime, UInt64 lastUpdated, const Contents* contents, const SecurityAttributes* securityAttributes);
void invokeOnDocumentRemoved(bool sync, const Data& eventType, const Data& documentKey, const Data& eTag, UInt64 lastUpdated);
void invokeOnInitialSyncDocument(unsigned int connectionId, const Data& eventType, const Data& documentKey, const Data& eTag, UInt64 expirationTime, UInt64 lastUpdated, const Contents* contents, const SecurityAttributes* securityAttributes);
bool shouldEraseDocument(PubDocument& document, UInt64 now);
bool mSyncEnabled;
typedef std::list<InMemorySyncPubDbHandler*> HandlerList;
HandlerList mHandlers; // use list over set to preserve add order
Mutex mHandlerMutex;
KeyToETagMap mPublicationDb;
Mutex mDatabaseMutex;
};
}
#endif
/* ====================================================================
*
* Copyright (c) 2015 SIP Spectrum, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. Neither the name of the author(s) nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* ====================================================================
*
*/
/*
* vi: set shiftwidth=3 expandtab:
*/
|