17#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
21 bool presenceUsesRegistrationState,
22 bool presenceNotifyClosedStateForNonPublishedUsers)
26 mPublicationDb(dynamic_cast<
InMemorySyncPubDb*>(dum.getPublicationPersistenceManager())),
27 mRegistrationDb(dynamic_cast<
InMemorySyncRegDb*>(dum.getRegistrationPersistenceManager())),
28 mPresenceUsesRegistrationState(presenceUsesRegistrationState),
29 mPresenceNotifyClosedStateForNonPublishedUsers(presenceNotifyClosedStateForNonPublishedUsers),
30 mUserDispatcher(userDispatcher)
53 InfoLog(<<
"PresenceSubscriptionHandler::onNewSubscription: msg=" << std::endl << sub);
67 InfoLog(<<
"PresenceSubscriptionHandler::onRefresh: aor=" << aor <<
", registered=" << isRegistered <<
", maxRegExpires=" << maxExpires);
71 if (maxExpires && isRegistered)
92 InfoLog(<<
"PresenceSubscriptionHandler::onPublished: docKey=" << associated->
getDocumentKey() <<
", contents=" << std::endl << *contents);
96 InfoLog(<<
"PresenceSubscriptionHandler::onPublished: no contents, docKey=" << associated->
getDocumentKey());
113 InfoLog(<<
"PresenceSubscriptionHandler::onError: docKey=" << h->
getDocumentKey() <<
", msg=" << std::endl << msg);
124 DebugLog(<<
"PresenceSubscriptionHandler::notifyPresence: attempting to notify published presence for aor=" << aor);
137 DebugLog(<<
"PresenceSubscriptionHandler::notifyPresence: attempting to notify published presence for aor=" << aor);
152 ErrLog(<<
"PresenceSubscriptionHandler::notifyPresence: problem notifying presence: " << ex);
163 DebugLog(<<
"PresenceSubscriptionHandler::notifyPresenceNoPublication: no publication for aor=" << aor <<
", registered=" << isRegistered);
184 std::unique_ptr<ApplicationMessage> app(async);
192 if (mServerSubscriptionHandle.
isValid())
201 DebugLog(<<
"PresenceSubscriptionHandler::continueNotifyPresenceAfterUserExistsCheck: aor=" << aor <<
", userExists=" << userExists);
204 if (sendAcceptReject)
243 else if (sendAcceptReject)
257 if (sendAcceptReject)
291 notify.
header(h_SubscriptionState).param(p_expires) =
resipMin(scaledUpTimeSoSubRefreshComesAfter, notify.
header(h_SubscriptionState).param(p_expires));
297 InfoLog(<<
"PresenceSubscriptionHandler::fabricateSimplePresence: aor=" << aor <<
", online=" << online <<
", maxRegExpires=" << regMaxExpires);
303 if (sendAcceptReject)
308 auto notify = h->
update(&pidf);
309 if (regMaxExpires && online)
321 if (destPidf && srcPidf)
326 *destPidf = *srcPidf;
330 destPidf->
merge(*srcPidf);
342 : mHandler(handler), mAor(aor), mRegistered(registered), mRegMaxExpires(regMaxExpires) {}
351 return strm <<
"PresenceServerRegStateChangeCommand: aor=" << mAor <<
", registered=" << mRegistered;
365 mHandler(handler), mAor(aor), mOnline(online), mRegMaxExpires(regMaxExpires) {}
395 bool stateChanged =
false;
397 if (online && !registered)
402 DebugLog(<<
"PresenceSubscriptionHandler::checkRegistrationStateChanged: registration changed for aor=" << aor <<
", no longer registered");
404 else if (!online && registered)
409 DebugLog(<<
"PresenceSubscriptionHandler::checkRegistrationStateChanged: registration changed for aor=" << aor <<
", now registered");
419 DebugLog(<<
"PresenceSubscriptionHandler::checkRegistrationStateChanged: registration state unchanged for aor=" << aor);
427 bool registered =
false;
432 ContactList::const_iterator it = contacts.begin();
433 for (; it != contacts.end(); it++)
435 if (it->mRegExpires > now)
438 maxExpirationTime =
resipMax(maxExpirationTime, it->mRegExpires);
442 DebugLog(<<
"PresenceSubscriptionHandler::onAorModified: registration updated aor=" << aor <<
", registered=" << registered);
468 : mHandler(handler), mDocumentKey(documentKey) {}
477 return strm <<
"PresenceServerDocStateChangeCommand: aor=" << mDocumentKey;
489 : mHandler(handler), mDocumentKey(documentKey), mETag(eTag), mLastUpdated(lastUpdated) {}
493 mHandler.
checkExpired(mDocumentKey, mETag, mLastUpdated);
498 return strm <<
"PresenceServerCheckDocExpiredCommand: aor=" << mDocumentKey;
527 DebugLog(<<
"PresenceSubscriptionHandler::onDocumentModified: aor=" << documentKey <<
", eTag=" << eTag);
536 if (expiresSeconds > 0)
550 DebugLog(<<
"PresenceSubscriptionHandler::onDocumentRemoved: aor=" << documentKey <<
", eTag=" << eTag);
const uint32_t ReSubGraceTime
#define resip_assert(x)
This file needs to work for both C and C++ code.
PresenceServerCheckDocExpiredCommand(PresenceSubscriptionHandler &handler, const resip::Data &documentKey, const resip::Data &eTag, uint64_t lastUpdated)
virtual EncodeStream & encodeBrief(EncodeStream &strm) const
output a brief description to stream
virtual void executeCommand()
virtual void executeCommand()
PresenceServerDocStateChangeCommand(PresenceSubscriptionHandler &handler, const resip::Data &documentKey)
virtual EncodeStream & encodeBrief(EncodeStream &strm) const
output a brief description to stream
virtual void executeCommand()
virtual EncodeStream & encodeBrief(EncodeStream &strm) const
output a brief description to stream
PresenceServerRegStateChangeCommand(PresenceSubscriptionHandler &handler, const resip::Uri &aor, bool registered, uint64_t regMaxExpires)
virtual ~PresenceServerSubscriptionFunctor()
PresenceServerSubscriptionFunctor(PresenceSubscriptionHandler &handler)
virtual void operator()(ServerSubscriptionHandle h)
virtual ~PresenceServerSubscriptionRegFunctor()
virtual void operator()(ServerSubscriptionHandle h)
PresenceServerSubscriptionRegFunctor(PresenceSubscriptionHandler &handler, const resip::Uri &aor, bool online, uint64_t regMaxExpires)
friend class PresenceUserExists
virtual bool mergeETag(resip::Contents *eTagDest, resip::Contents *eTagSrc, bool isFirst)
bool checkRegistrationStateChanged(const resip::Uri &aor, bool registered, uint64_t regMaxExpires)
void adjustNotifyExpiresTime(resip::SipMessage ¬ify, uint64_t regMaxExpires)
virtual void onError(resip::ServerSubscriptionHandle, const resip::SipMessage &msg)
virtual void onNewSubscription(resip::ServerSubscriptionHandle h, const resip::SipMessage &sub)
bool sendPublishedPresence(resip::ServerSubscriptionHandle h, bool sendAcceptReject)
friend class PresenceServerCheckDocExpiredCommand
void notifySubscriptions(const resip::Data &documentKey)
friend class PresenceServerRegStateChangeCommand
virtual void onDocumentRemoved(bool sync, const resip::Data &eventType, const resip::Data &documentKey, const resip::Data &eTag, uint64_t lastUpdated)
void fabricateSimplePresence(resip::ServerSubscriptionHandle h, bool sendAcceptReject, const resip::Uri &aor, bool online, uint64_t regMaxExpires)
resip::DialogUsageManager & mDum
bool mPresenceUsesRegistrationState
void checkExpired(const resip::Data &documentKey, const resip::Data &eTag, uint64_t lastUpdated)
friend class PresenceServerDocStateChangeCommand
void continueNotifyPresenceAfterUserExistsCheck(resip::ServerSubscriptionHandle h, bool sendAcceptReject, const resip::Uri &aor, bool userExists)
virtual void onDocumentModified(bool sync, const resip::Data &eventType, const resip::Data &documentKey, const resip::Data &eTag, uint64_t expirationTime, uint64_t lastUpdated, const resip::Contents *contents, const resip::SecurityAttributes *securityAttributes)
resip::InMemorySyncPubDb * mPublicationDb
virtual void onPublished(resip::ServerSubscriptionHandle associated, resip::ServerPublicationHandle publication, const resip::Contents *contents, const resip::SecurityAttributes *attrs)
std::set< resip::Uri > mOnlineAors
virtual void onTerminated(resip::ServerSubscriptionHandle)
void notifyPresenceNoPublication(resip::ServerSubscriptionHandle h, bool sendAcceptReject, const resip::Uri &aor, bool isRegistered, uint64_t regMaxExpires)
PresenceSubscriptionHandler(resip::DialogUsageManager &dum, resip::Dispatcher *userDispatcher, bool presenceUsesRegistrationState, bool PresenceNotifyClosedStateForNonPublishedUsers)
bool mPresenceNotifyClosedStateForNonPublishedUsers
void notifyPresence(resip::ServerSubscriptionHandle h, bool sendAcceptReject)
resip::InMemorySyncRegDb * mRegistrationDb
virtual ~PresenceSubscriptionHandler()
resip::Dispatcher * mUserDispatcher
virtual void onRefresh(resip::ServerSubscriptionHandle, const resip::SipMessage &sub)
virtual void onAorModified(const resip::Uri &aor, const resip::ContactList &contacts)
virtual void executeCommand()
The abstract base-class for all exceptions thrown by resip code.
const Data & getEventType() const noexcept
const Data & getDocumentKey() const noexcept
Base class for all SIP body types.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
UnaryFunction applyToServerSubscriptions(const Data &aor, const Data &eventType, UnaryFunction &applyFn)
A generic thread-bank class.
virtual bool post(std::unique_ptr< resip::ApplicationMessage > &work)
Posts a message to this thread bank.
SIP body type for holding PIDF contents (MIME content-type application/pidf+xml).
void setSimplePresenceTupleNode(const Data &id, bool online, const Data ×tamp=Data::Empty, const Data ¬e=Data::Empty, const Data &contact=Data::Empty, const Data &contactPriority=Data::Empty)
static Data generateNowTimestampData()
void setEntity(const Uri &entity)
bool merge(const GenericPidfContents &other)
Implementation of a persistence manager.
virtual bool checkExpired(const Data &eventType, const Data &documentKey, const Data &eTag, uint64_t lastUpdated)
virtual void addHandler(InMemorySyncPubDbHandler *handler)
virtual void removeHandler(InMemorySyncPubDbHandler *handler)
virtual bool getMergedETags(const Data &eventType, const Data &documentKey, ETagMerger &merger, Contents *destination)
Implementation of a persistence manager.
virtual void addHandler(InMemorySyncRegDbHandler *handler)
virtual bool aorIsRegistered(const Uri &aor)
virtual void removeHandler(InMemorySyncRegDbHandler *handler)
std::shared_ptr< SipMessage > neutralNotify()
void setSubscriptionState(SubscriptionState state)
void end(TerminateReason reason, const Contents *document=0, int retryAfter=0)
std::shared_ptr< SipMessage > update(const Contents *document)
std::shared_ptr< SipMessage > accept(int statusCode=202)
void send(std::shared_ptr< SipMessage > msg) override
std::shared_ptr< SipMessage > reject(int responseCode)
Represents a SIP message.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
bool exists(const HeaderBase &headerType) const
Returns true if the given header field is present, false otherwise.
void post(std::unique_ptr< ApplicationMessage > message, unsigned int secondsLater, TransactionUser *tu=0)
Makes the message available to the TU at some later time, specified in seconds.
static const char * Presence
static uint64_t getTimeSecs()
Returns the current clock time in seconds.
void post(Message *msg)
Posts a Message to this TransactionUser's fifo.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
const _Tp & resipMin(const _Tp &__a, const _Tp &__b)
const _Tp & resipMax(const _Tp &__a, const _Tp &__b)
std::list< ContactInstanceRecord > ContactList
unsigned __int64 uint64_t