~ubuntu-branches/ubuntu/saucy/resiprocate/saucy-proposed

« back to all changes in this revision

Viewing changes to resip/stack/TuIM.hxx

  • Committer: Package Import Robot
  • Author(s): Daniel Pocock
  • Date: 2012-05-17 19:29:59 UTC
  • Revision ID: package-import@ubuntu.com-20120517192959-vv00m77isztdy64q
Tags: upstream-1.8.2
ImportĀ upstreamĀ versionĀ 1.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#if !defined(RESIP_TUIM_HXX)
 
2
#define RESIP_TUIM_HXX
 
3
 
 
4
#include <list>
 
5
 
 
6
#include "resip/stack/DeprecatedDialog.hxx"
 
7
#include "resip/stack/SecurityTypes.hxx"
 
8
#include "resip/stack/Transport.hxx"
 
9
#include "resip/stack/SipStack.hxx"
 
10
#include "rutil/Timer.hxx"
 
11
 
 
12
namespace resip
 
13
{
 
14
 
 
15
class Pidf;
 
16
 
 
17
class TuIM
 
18
{
 
19
   private:
 
20
      class Buddy;
 
21
      class StateAgent;
 
22
      class Page;
 
23
      
 
24
public:
 
25
      class Callback
 
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,
 
48
           Callback* callback,
 
49
           const int registrationTimeSeconds = 1*60*60,
 
50
           const int subscriptionTimeSeconds =   10*60 );
 
51
 
 
52
      ///
 
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 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
      Pidf* mPidf;
 
172
 
 
173
      // registration information
 
174
      DeprecatedDialog mRegistrationDialog;
 
175
      UInt64 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
 */