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

« back to all changes in this revision

Viewing changes to resip/dum/ClientSubscription.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_CLIENTSUBSCRIPTION_HXX)
 
2
#define RESIP_CLIENTSUBSCRIPTION_HXX
 
3
 
 
4
#include <deque>
 
5
#include "resip/dum/BaseSubscription.hxx"
 
6
 
 
7
namespace resip
 
8
{
 
9
 
 
10
class DialogUsageManager;
 
11
 
 
12
//!dcm! -- update contact in dialog if required
 
13
 
 
14
class ClientSubscription: public BaseSubscription
 
15
{
 
16
   public:      
 
17
      ClientSubscription(DialogUsageManager& dum, Dialog& dialog,
 
18
                         const SipMessage& request, UInt32 defaultSubExpiration);
 
19
 
 
20
      typedef Handle<ClientSubscription> ClientSubscriptionHandle;
 
21
      ClientSubscriptionHandle getHandle();
 
22
      
 
23
      //.dcm. no adornment for ease of use, can add if there is a use case
 
24
      void acceptUpdate(int statusCode = 200, const char* reason=0);
 
25
      void rejectUpdate(int statusCode = 400, const Data& reasonPhrase = Data::Empty);
 
26
      void requestRefresh(UInt32 expires = 0);  // 0 defaults to using original expires value (to remove call end() instead)
 
27
      virtual void end();
 
28
      void end(bool immediate); // If immediate is true then usage is destroyed with no further messaging
 
29
      virtual void reSubscribe();  // forms a new Subscription dialog - reusing the same target and AppDialogSet      
 
30
      /**
 
31
       * Provide asynchronous method access by using command
 
32
       */
 
33
      void acceptUpdateCommand(int statusCode = 200, const char* reason=0);
 
34
      void rejectUpdateCommand(int statusCode = 400, const Data& reasonPhrase = Data::Empty);
 
35
      void requestRefreshCommand(UInt32 expires = 0);  // 0 defaults to using original expires value (to remove call endCommand() instead)
 
36
      virtual void endCommand(bool immediate=false); // If immediate is true then usage is destroyed with no further messaging
 
37
 
 
38
      virtual EncodeStream& dump(EncodeStream& strm) const;
 
39
 
 
40
   protected:
 
41
      virtual ~ClientSubscription();
 
42
      virtual void dialogDestroyed(const SipMessage& msg);
 
43
      virtual void onReadyToSend(SipMessage& msg);
 
44
      virtual void send(SharedPtr<SipMessage> msg);
 
45
      virtual void flowTerminated();
 
46
 
 
47
   private:
 
48
      friend class Dialog;
 
49
      friend class InviteSession;      
 
50
 
 
51
      class QueuedNotify
 
52
      {
 
53
         public:
 
54
            QueuedNotify(const SipMessage& notify, bool outOfOrder)
 
55
               : mNotify(notify), mOutOfOrder(outOfOrder) {}
 
56
 
 
57
            SipMessage& notify() { return mNotify; }
 
58
            bool outOfOrder() { return mOutOfOrder; }
 
59
 
 
60
         private:
 
61
            SipMessage mNotify;
 
62
            bool mOutOfOrder;
 
63
      };
 
64
 
 
65
      typedef std::deque<QueuedNotify*> NotifyQueue;
 
66
      NotifyQueue mQueuedNotifies;
 
67
 
 
68
      typedef std::vector<QueuedNotify*> Dustbin;
 
69
      Dustbin mDustbin;
 
70
 
 
71
      bool mOnNewSubscriptionCalled;
 
72
      //SipMessage mLastNotify;      
 
73
      bool mEnded;
 
74
      // .bwc. This is when our next reSUB is scheduled to happen.
 
75
      UInt64 mNextRefreshSecs;
 
76
      UInt64 mLastSubSecs;
 
77
 
 
78
      // this is the expires value from the 2xx coming from the SUB message
 
79
      UInt32 mDefaultExpires;
 
80
 
 
81
      bool mRefreshing;
 
82
      bool mHaveQueuedRefresh;
 
83
      int mQueuedRefreshInterval;
 
84
 
 
85
      unsigned int mLargestNotifyCSeq;
 
86
 
 
87
      virtual void dispatch(const SipMessage& msg);
 
88
      virtual void dispatch(const DumTimeout& timer);
 
89
 
 
90
      void sendQueuedRefreshRequest();
 
91
      void processNextNotify();
 
92
      void processResponse(const SipMessage& response);
 
93
      void clearDustbin();
 
94
      void scheduleRefresh(unsigned long refreshInterval);
 
95
      
 
96
      // disabled
 
97
      ClientSubscription(const ClientSubscription&);
 
98
      ClientSubscription& operator=(const ClientSubscription&);
 
99
};
 
100
 
 
101
}
 
102
 
 
103
#endif
 
104
 
 
105
/* ====================================================================
 
106
 * The Vovida Software License, Version 1.0 
 
107
 * 
 
108
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
 
109
 * 
 
110
 * Redistribution and use in source and binary forms, with or without
 
111
 * modification, are permitted provided that the following conditions
 
112
 * are met:
 
113
 * 
 
114
 * 1. Redistributions of source code must retain the above copyright
 
115
 *    notice, this list of conditions and the following disclaimer.
 
116
 * 
 
117
 * 2. Redistributions in binary form must reproduce the above copyright
 
118
 *    notice, this list of conditions and the following disclaimer in
 
119
 *    the documentation and/or other materials provided with the
 
120
 *    distribution.
 
121
 * 
 
122
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
 
123
 *    and "Vovida Open Communication Application Library (VOCAL)" must
 
124
 *    not be used to endorse or promote products derived from this
 
125
 *    software without prior written permission. For written
 
126
 *    permission, please contact vocal@vovida.org.
 
127
 *
 
128
 * 4. Products derived from this software may not be called "VOCAL", nor
 
129
 *    may "VOCAL" appear in their name, without prior written
 
130
 *    permission of Vovida Networks, Inc.
 
131
 * 
 
132
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
 
133
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
134
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
 
135
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
 
136
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
 
137
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
 
138
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
139
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
140
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 
141
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
142
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 
143
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 
144
 * DAMAGE.
 
145
 * 
 
146
 * ====================================================================
 
147
 * 
 
148
 * This software consists of voluntary contributions made by Vovida
 
149
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
 
150
 * Inc.  For more information on Vovida Networks, Inc., please see
 
151
 * <http://www.vovida.org/>.
 
152
 *
 
153
 */