reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TuIM.hxx
Go to the documentation of this file.
1#if !defined(RESIP_TUIM_HXX)
2#define RESIP_TUIM_HXX
3
4#include <list>
5
10#include "rutil/Timer.hxx"
11
12namespace resip
13{
14
15class GenericPidfContents;
16
17class TuIM
18{
19 private:
20 class Buddy;
21 class StateAgent;
22 class Page;
23
24public:
26 {
27 public:
28 virtual void receivedPage(const Data& msg,
29 const Uri& from,
30 const Data& signedBy,
31 SignatureStatus sigStatus,
32 bool wasEncryped ) = 0;
33 virtual void sendPageFailed(const Uri& dest, int respNumber ) =0;
34 virtual void receivePageFailed(const Uri& sender) =0;
35 virtual void registrationFailed(const Uri& dest, int respNumber ) =0;
36 virtual void registrationWorked(const Uri& dest ) =0;
37 virtual void presenceUpdate(const Uri& user, bool open, const Data& status ) =0;
38 virtual bool authorizeSubscription( const Uri& user ); // return
39 // true if
40 // sub is ok
41
42 virtual ~Callback();
43 };
44
45 TuIM(SipStack* stack,
46 const Uri& aor,
47 const Uri& contact,
49 const int registrationTimeSeconds = 1*60*60,
50 const int subscriptionTimeSeconds = 10*60 );
51
53 void setOutboundProxy( const Uri& uri );
54 void setDefaultProtocol( TransportType protocol );
55 void setUAName( const Data& name );
56
57 bool haveCerts( bool sign, const Data& encryptFor );
58 void sendPage(const Data& text, const Uri& dest,
59 const bool sign=false, const Data& encryptFor = Data::Empty );
60
61 void process();
62
63 // Registration management
64 void registerAor( const Uri& uri,
65 const Data& password = Data::Empty );
66
67 // Buddy List management
68 int getNumBuddies() const;
69 const Uri getBuddyUri(const int index);
70 const Data getBuddyGroup(const int index);
71 bool getBuddyStatus(const int index, Data* status=NULL);
72 void addBuddy( const Uri& uri, const Data& group );
73 void removeBuddy( const Uri& name);
74
75 // Presence management
76 void setMyPresence( const bool open,
77 const Data& status = Data::Empty,
78 const Data& user = Data::Empty );
79 void addStateAgent( const Uri& uri );
80 void authorizeSubscription( const Data& user );
81
82 private:
83 void processSipFrag(SipMessage* msg);
84
85 void processRequest(SipMessage* msg);
86 void processMessageRequest(SipMessage* msg);
87 void processSubscribeRequest(SipMessage* msg);
88 void processRegisterRequest(SipMessage* msg);
89 void processNotifyRequest(SipMessage* msg);
90
91 void processResponse(SipMessage* msg);
92 void processRegisterResponse(SipMessage* msg);
93 void processSubscribeResponse(SipMessage* msg, Buddy& buddy );
94 void processNotifyResponse(SipMessage* msg, DeprecatedDialog& d );
95 void processPublishResponse(SipMessage* msg, StateAgent& sa );
96 void processPageResponse(SipMessage* msg, Page& page );
97
98 void sendNotify(DeprecatedDialog* dialog);
99 void sendPublish(StateAgent& dialog);
100
101 void setOutbound( SipMessage& msg );
102
103 void subscribeBuddy( Buddy& buddy );
104
105 Callback* mCallback;
106 SipStack* mStack;
107 Uri mAor;
108 Uri mContact;
109
110 class Buddy
111 {
112 public:
113 Uri uri;
114 Data group;
115 DeprecatedDialog* presDialog;
116 uint64_t mNextTimeToSubscribe;
117 bool online;
118 Data status;
119
120 Buddy() {};
121 Buddy(const Buddy& rhs)
122 {
123 uri = rhs.uri;
124 group = rhs.group;
125 presDialog = rhs.presDialog;
126 mNextTimeToSubscribe = rhs.mNextTimeToSubscribe;
127 online = rhs.online;
128 status = rhs.status;
129 };
130 };
131
132 // people I subscribe to
133 std::vector<Buddy> mBuddies;
134 typedef std::vector<Buddy>::iterator BuddyIterator;
135
136 class StateAgent
137 {
138 public:
139 Uri uri;
140 DeprecatedDialog* dialog;
141 };
142 // people I publish to
143 std::list<StateAgent> mStateAgents;
144 typedef std::list<StateAgent>::iterator StateAgentIterator;
145
146 // people who subscribe to me
147 class Subscriber
148 {
149 public:
150 Data aor;
151 bool authorized;
152 DeprecatedDialog* dialog;
153 };
154 std::list<Subscriber> mSubscribers;
155 typedef std::list<Subscriber>::iterator SubscriberIterator;
156
157 class Page
158 {
159 public:
160 Data text;
161 Uri uri;
162 bool sign;
163 Data encryptFor;
164 DeprecatedDialog* dialog;
165 };
166 // outstanding messages
167 std::list<Page> mPages;
168 typedef std::list<Page>::iterator PageIterator;
169
170 // Current pres info
171 GenericPidfContents* mPidf;
172
173 // registration information
174 DeprecatedDialog mRegistrationDialog;
175 uint64_t mNextTimeToRegister;
176 Data mRegistrationPassword;
177 unsigned int mLastAuthCSeq; // This is the CSeq of the last registration message
178 // sent that included digest authorization information
179
180 const int mRegistrationTimeSeconds; // this is the default time to request in
181 // a registration
182
183 const int mSubscriptionTimeSeconds; // this is the default time to request in
184 // a subscription
185
186 Uri mOutboundProxy;
187 Data mUAName;
188 TransportType mDefaultProtocol;
189};
190
191}
192
193#endif
194
195/* ====================================================================
196 * The Vovida Software License, Version 1.0
197 *
198 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
199 *
200 * Redistribution and use in source and binary forms, with or without
201 * modification, are permitted provided that the following conditions
202 * are met:
203 *
204 * 1. Redistributions of source code must retain the above copyright
205 * notice, this list of conditions and the following disclaimer.
206 *
207 * 2. Redistributions in binary form must reproduce the above copyright
208 * notice, this list of conditions and the following disclaimer in
209 * the documentation and/or other materials provided with the
210 * distribution.
211 *
212 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
213 * and "Vovida Open Communication Application Library (VOCAL)" must
214 * not be used to endorse or promote products derived from this
215 * software without prior written permission. For written
216 * permission, please contact vocal@vovida.org.
217 *
218 * 4. Products derived from this software may not be called "VOCAL", nor
219 * may "VOCAL" appear in their name, without prior written
220 * permission of Vovida Networks, Inc.
221 *
222 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
223 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
224 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
225 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
226 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
227 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
228 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
229 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
230 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
231 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
232 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
233 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
234 * DAMAGE.
235 *
236 * ====================================================================
237 *
238 * This software consists of voluntary contributions made by Vovida
239 * Networks, Inc. and many individuals on behalf of Vovida Networks,
240 * Inc. For more information on Vovida Networks, Inc., please see
241 * <http://www.vovida.org/>.
242 *
243 */
static void callback(void *arg, int status, unsigned char *abuf, int alen)
Definition adig.c:388
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
Represents a SIP message.
This is the primary point of interaction between the app-layer and the stack.
Definition SipStack.hxx:160
virtual void registrationWorked(const Uri &dest)=0
virtual void registrationFailed(const Uri &dest, int respNumber)=0
virtual void sendPageFailed(const Uri &dest, int respNumber)=0
virtual bool authorizeSubscription(const Uri &user)
Definition TuIM.cxx:1446
virtual ~Callback()
Definition TuIM.cxx:57
virtual void presenceUpdate(const Uri &user, bool open, const Data &status)=0
virtual void receivePageFailed(const Uri &sender)=0
virtual void receivedPage(const Data &msg, const Uri &from, const Data &signedBy, SignatureStatus sigStatus, bool wasEncryped)=0
void process()
Definition TuIM.cxx:1102
bool getBuddyStatus(const int index, Data *status=NULL)
Definition TuIM.cxx:1231
const Uri getBuddyUri(const int index)
Definition TuIM.cxx:1211
void setDefaultProtocol(TransportType protocol)
Definition TuIM.cxx:1425
void authorizeSubscription(const Data &user)
Definition TuIM.cxx:1350
void registerAor(const Uri &uri, const Data &password=Data::Empty)
Definition TuIM.cxx:1176
const Data getBuddyGroup(const int index)
Definition TuIM.cxx:1221
void sendPage(const Data &text, const Uri &dest, const bool sign=false, const Data &encryptFor=Data::Empty)
Definition TuIM.cxx:124
void setOutboundProxy(const Uri &uri)
Definition TuIM.cxx:1379
void removeBuddy(const Uri &name)
Definition TuIM.cxx:1283
void setMyPresence(const bool open, const Data &status=Data::Empty, const Data &user=Data::Empty)
Definition TuIM.cxx:1357
void setUAName(const Data &name)
Definition TuIM.cxx:1387
void addBuddy(const Uri &uri, const Data &group)
Definition TuIM.cxx:1266
int getNumBuddies() const
Definition TuIM.cxx:1204
bool haveCerts(bool sign, const Data &encryptFor)
Definition TuIM.cxx:91
void addStateAgent(const Uri &uri)
Definition TuIM.cxx:1432
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
Definition Uri.hxx:22
dcm! – add UnusedChecking(_enum) below;
unsigned long long uint64_t
Definition Stun.hxx:39
TransportType
An enumeration of transport protocols.
unsigned __int64 uint64_t
Definition stdint.h:95