[Opalvoip-svn] SF.net SVN: opalvoip:[24291] opal/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <cso...@us...> - 2010-04-27 19:29:08
|
Revision: 24291 http://opalvoip.svn.sourceforge.net/opalvoip/?rev=24291&view=rev Author: csoutheren Date: 2010-04-27 19:29:01 +0000 (Tue, 27 Apr 2010) Log Message: ----------- Add generic implementation for sending messages via presentity interface Modified Paths: -------------- opal/trunk/include/opal/pres_ent.h opal/trunk/src/opal/pres_ent.cxx Modified: opal/trunk/include/opal/pres_ent.h =================================================================== --- opal/trunk/include/opal/pres_ent.h 2010-04-27 17:03:37 UTC (rev 24290) +++ opal/trunk/include/opal/pres_ent.h 2010-04-27 19:29:01 UTC (rev 24291) @@ -110,9 +110,13 @@ ostream & operator<<(ostream & strm, OpalPresenceInfo::State state); - //////////////////////////////////////////////////////////////////////////////////////////////////// +class OpalSetLocalPresenceCommand; +class OpalSubscribeToPresenceCommand; +class OpalAuthorisationRequestCommand; +class OpalSendMessageToCommand; + /**Representation of a presence identity. This class contains an abstraction of the functionality for "presence" using a URL string as the "identity". The concrete class depends on the @@ -133,6 +137,8 @@ OpalPresentity(); public: + ~OpalPresentity(); + /**Create a concrete class based on the scheme of the URL provided. */ static OpalPresentity * Create( @@ -459,7 +465,20 @@ virtual PString GetID() const; //@} + + + virtual bool SendMessageTo( + const PURL & to, + const PString & type, + const PString & body, + const PString & messageId + ); + void Internal_SendLocalPresence (const OpalSetLocalPresenceCommand & cmd); + void Internal_SubscribeToPresence (const OpalSubscribeToPresenceCommand & cmd); + void Internal_AuthorisationRequest(const OpalAuthorisationRequestCommand & cmd); + void Internal_SendMessageToCommand(const OpalSendMessageToCommand & cmd); + protected: OpalPresentityCommand * InternalCreateCommand(const char * cmdName); @@ -563,7 +582,6 @@ PThread * m_thread; }; - //////////////////////////////////////////////////////////////////////////////////////////////////// /**Abstract class for all OpelPresentity commands. @@ -636,6 +654,23 @@ }; +/** Command for sending an IM + */ +class OpalSendMessageToCommand : public OpalPresentityCommand +{ + public: + OpalSendMessageToCommand() + { } + + PURL m_to; + PString m_type; + PString m_body; + PString m_messageId; +}; + + + + /////////////////////////////////////////////////////////////////////////////// // Include concrete classes here so the factories are initialised Modified: opal/trunk/src/opal/pres_ent.cxx =================================================================== --- opal/trunk/src/opal/pres_ent.cxx 2010-04-27 17:03:37 UTC (rev 24290) +++ opal/trunk/src/opal/pres_ent.cxx 2010-04-27 19:29:01 UTC (rev 24291) @@ -151,7 +151,12 @@ { } +OpalPresentity::~OpalPresentity() +{ + m_manager->RemovePresentity(m_aor); +} + OpalPresentity * OpalPresentity::Create(OpalManager & manager, const PURL & url, const PString & scheme) { OpalPresentity * presEntity = PFactory<OpalPresentity>::CreateInstance(scheme.IsEmpty() ? url.GetScheme() : scheme); @@ -211,6 +216,21 @@ } +bool OpalPresentity::SendMessageTo(const PURL & to, const PString & type, const PString & body, const PString & messageId) +{ + OpalSendMessageToCommand * cmd = CreateCommand<OpalSendMessageToCommand>(); + if (cmd == NULL) + return false; + + cmd->m_to = to; + cmd->m_type = type; + cmd->m_body = body; + cmd->m_messageId = messageId; + SendCommand(cmd); + return true; +} + + void OpalPresentity::OnAuthorisationRequest(const AuthorisationRequest & request) { PWaitAndSignal mutex(m_notificationMutex); @@ -387,8 +407,10 @@ for (unsigned ancestor = 0; *(className = GetClass(ancestor)) != '\0'; ++ancestor) { OpalPresentityCommand * cmd = PFactory<OpalPresentityCommand>::CreateInstance(className+partialKey); - if (cmd != NULL) + if (cmd != NULL) { + PTRACE(3, "Opal\tCreating presentity command '" << className+partialKey << "'"); return cmd; + } } PAssertAlways(PUnimplementedFunction); @@ -404,6 +426,37 @@ } +void OpalPresentity::Internal_SendLocalPresence(const OpalSetLocalPresenceCommand &) +{ +} + +void OpalPresentity::Internal_SubscribeToPresence (const OpalSubscribeToPresenceCommand &) +{ +} + +void OpalPresentity::Internal_AuthorisationRequest(const OpalAuthorisationRequestCommand &) +{ +} + +void OpalPresentity::Internal_SendMessageToCommand(const OpalSendMessageToCommand & cmd) +{ + OpalEndPoint * endpoint = m_manager->FindEndPoint(m_aor.GetScheme()); + if (endpoint == NULL) { + PTRACE(1, "Opal\tCannot find endpoint for '" << m_aor.GetScheme() << "'"); + return; + } + + PString conversationId(cmd.m_messageId); + endpoint->Message(cmd.m_to, cmd.m_type, cmd.m_body, m_aor, conversationId); +} + + +OPAL_DEFINE_COMMAND(OpalSetLocalPresenceCommand, OpalPresentity, Internal_SendLocalPresence); +OPAL_DEFINE_COMMAND(OpalSubscribeToPresenceCommand, OpalPresentity, Internal_SubscribeToPresence); +OPAL_DEFINE_COMMAND(OpalAuthorisationRequestCommand, OpalPresentity, Internal_AuthorisationRequest); +OPAL_DEFINE_COMMAND(OpalSendMessageToCommand, OpalPresentity, Internal_SendMessageToCommand); + + ///////////////////////////////////////////////////////////////////////////// OpalPresentityWithCommandThread::OpalPresentityWithCommandThread() @@ -498,5 +551,4 @@ } } - ///////////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |