OPAL  Version 3.14.3
im_ep.h
Go to the documentation of this file.
1 /*
2  * im_ep.h
3  *
4  * Endpoint for Instant Messaging
5  *
6  * Open Phone Abstraction Library (OPAL)
7  *
8  * Copyright (c) 2008 Post Increment
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open Phone Abstraction Library.
21  *
22  * The Initial Developer of the Original Code is Post Increment
23  *
24  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 29863 $
27  * $Author: rjongbloed $
28  * $Date: 2013-06-03 10:41:08 +1000 (Mon, 03 Jun 2013) $
29  */
30 
31 #ifndef OPAL_IM_EP_H
32 #define OPAL_IM_EP_H
33 
34 #include <ptlib.h>
35 #include <opal_config.h>
36 
37 #if OPAL_HAS_IM
38 
39 #include <opal/endpoint.h>
40 
41 
45 {
46  public:
47  static const PCaselessString & Prefix();
48 
54 
55 
58  virtual PSafePtr<OpalConnection> MakeConnection(
59  OpalCall & call,
60  const PString & party,
61  void * userData = NULL,
62  unsigned int options = 0,
63  OpalConnection::StringOptions * stringOptions = NULL
64  );
65 
75  virtual OpalMediaFormatList GetMediaFormats() const;
76 
81  virtual PBoolean GarbageCollection();
82 
85  virtual void ShutDown();
87 
88 
98  PSafePtr<OpalIMContext> CreateContext(
99  const PURL & localURL,
100  const PURL & remoteURL,
101  const char * scheme = NULL
102  ) { return InternalCreateContext(localURL, remoteURL, scheme, false, NULL, NULL); }
103 
106  PSafePtr<OpalIMContext> CreateContext(
107  OpalCall & call
108  );
109 
114  void RemoveContext(OpalIMContext * context, bool byRemote);
115 
119  PSafePtr<OpalIMContext> FindContextByIdWithLock(
120  const PString & key,
121  PSafetyMode mode = PSafeReadWrite
122  );
123 
127  PSafePtr<OpalIMContext> FindContextByNamesWithLock(
128  const PURL & local,
129  const PURL & remote,
130  PSafetyMode mode = PSafeReadWrite
131  );
132 
136  PSafePtr<OpalIMContext> FindContextForMessageWithLock(
137  OpalIM & im,
138  OpalConnection * conn = NULL
139  );
141 
142 
149  virtual void OnConversation(
151  );
152 
154  typedef PNotifierTemplate<OpalIMContext::ConversationInfo> ConversationNotifier;
155 
157  #define PDECLARE_ConversationNotifier(cls, fn) PDECLARE_NOTIFIER2(OpalIMContext, cls, fn, OpalIMContext::ConversationInfo)
158 
160  #define PDECLARE_ASYNC_ConversationNotifier(cls, fn) PDECLARE_ASYNC_NOTIFIER2(OpalIMContext, cls, fn, OpalIMContext::ConversationInfo)
161 
163  #define PCREATE_ConversationNotifier(fn) PCREATE_NOTIFIER2(fn, OpalIMContext::ConversationInfo)
164 
171  void AddNotifier(
172  const ConversationNotifier & notifier,
173  const PString & scheme
174  );
175 
178  bool RemoveNotifier(const ConversationNotifier & notifier, const PString & scheme);
180 
181 
182  OpalIMContext::MessageDisposition OnRawMessageReceived(
183  OpalIM & message,
184  OpalConnection * connnection,
185  PString & errorInfo
186  );
187 
188  OpalManager & GetManager() const { return m_manager; }
189 
190  protected:
191  PSafePtr<OpalIMContext> InternalCreateContext(
192  const PURL & localURL,
193  const PURL & remoteURL,
194  const char * scheme,
195  bool byRemote,
196  OpalCall * call,
197  const char * conversationID
198  );
199 
201  typedef PSafeDictionary<PString, OpalIMContext> ContextsByConversationId;
203 
205  typedef std::multimap<PString, PString> ContextsByNames;
207 
209  typedef std::multimap<PString, ConversationNotifier> ConversationMap;
211 
214 };
215 
216 
222 {
223  PCLASSINFO(OpalIMConnection, OpalConnection);
224  public:
230  OpalCall & call,
232  void * userData,
233  unsigned options,
234  OpalConnection::StringOptions * stringOptions
235  );
237 
248  virtual PBoolean IsNetworkConnection() const { return false; }
249 
253  virtual PBoolean OnSetUpConnection();
254 
266  virtual void OnEstablished();
267 
274  virtual void OnReleased();
276 
277  protected:
279 };
280 
281 
282 #endif // OPAL_HAS_IM
283 
284 #endif // OPAL_IM_EP_H