reSIProcate/DialogUsageManager  9694
SubscriptionHandler.cxx
Go to the documentation of this file.
00001 #include "resip/dum/SubscriptionHandler.hxx"
00002 #include "resip/dum/ServerSubscription.hxx"
00003 #include "resip/dum/ClientSubscription.hxx"
00004 #include "resip/stack/SecurityAttributes.hxx"
00005 #include "rutil/Logger.hxx"
00006 
00007 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM
00008 
00009 using namespace resip;
00010 
00011 static Mimes empty;
00012 
00013 void 
00014 ClientSubscriptionHandler::onReadyToSend(ClientSubscriptionHandle h, SipMessage& msg)
00015 {
00016    // default is to do nothing. this is for adornment
00017 }
00018 
00019 void 
00020 ClientSubscriptionHandler::onNotifyNotReceived(ClientSubscriptionHandle h)
00021 {
00022    // By default, tear down the sub.
00023    h->end();
00024 }
00025 
00026 void 
00027 ClientSubscriptionHandler::onFlowTerminated(ClientSubscriptionHandle h)
00028 {
00029    // re-Subscribe
00030    InfoLog(<< "ClientSubscriptionHandler::onFlowTerminated");
00031    h->reSubscribe();
00032 }
00033 
00034 const Mimes& 
00035 ServerSubscriptionHandler::getSupportedMimeTypes() const
00036 {
00037    return empty;
00038 }
00039 
00040 void 
00041 ServerSubscriptionHandler::onError(ServerSubscriptionHandle, const SipMessage& msg)
00042 {
00043 }
00044 
00045 void 
00046 ServerSubscriptionHandler::onExpiredByClient(ServerSubscriptionHandle, const SipMessage& sub, SipMessage& notify)
00047 {
00048 }
00049 
00050 void 
00051 ServerSubscriptionHandler::onExpired(ServerSubscriptionHandle, SipMessage& notify)
00052 {
00053 }
00054 
00056 bool 
00057 ServerSubscriptionHandler::hasDefaultExpires() const
00058 {
00059    return false;
00060 }
00061 
00062 UInt32 
00063 ServerSubscriptionHandler::getDefaultExpires() const
00064 {
00065    return 0;
00066 }
00067 
00068 bool 
00069 ServerSubscriptionHandler::hasMinExpires() const
00070 {
00071    return false;
00072 }
00073 
00074 UInt32 
00075 ServerSubscriptionHandler::getMinExpires() const
00076 {
00077    return 0;
00078 }
00079 bool 
00080 ServerSubscriptionHandler::hasMaxExpires() const
00081 {
00082    return false;
00083 }
00084 
00085 UInt32 
00086 ServerSubscriptionHandler::getMaxExpires() const
00087 {
00088    return 0;
00089 }
00090 
00091 void
00092 ServerSubscriptionHandler::getExpires(const SipMessage &msg, UInt32 &expires, int &errorResponseCode)
00093 {
00094    if (msg.exists(h_Expires))
00095    {         
00096       expires = msg.header(h_Expires).value();
00097 
00098       if (expires > 0)
00099       {
00100          if (hasMinExpires() && (expires < getMinExpires()))
00101          {
00102             errorResponseCode = 423;
00103          }
00104          else if (hasMaxExpires() && (expires > getMaxExpires()))
00105          {
00106             expires = getMaxExpires();
00107          }
00108       }
00109    }
00110    else if (hasDefaultExpires())
00111    {
00112       expires = getDefaultExpires();
00113    }
00114    else
00115    {
00116       errorResponseCode = 400;     
00117    }
00118 }
00119 
00120 void 
00121 ServerSubscriptionHandler::onRefresh(ServerSubscriptionHandle handle, const SipMessage& sub)
00122 {
00123    handle->send(handle->accept(200));
00124    handle->send(handle->neutralNotify());
00125 }
00126 
00127 void 
00128 ServerSubscriptionHandler::onPublished(ServerSubscriptionHandle associated, 
00129                                        ServerPublicationHandle publication, 
00130                                        const Contents* contents,
00131                                        const SecurityAttributes* attrs)
00132 {
00133    // do nothing by default
00134 }
00135 
00136 
00137 void 
00138 ServerSubscriptionHandler::onNotifyRejected(ServerSubscriptionHandle h, const SipMessage& msg)
00139 {
00140 }
00141 
00142 void 
00143 ServerSubscriptionHandler::onReadyToSend(ServerSubscriptionHandle h, SipMessage& msg)
00144 {
00145    // default is to do nothing. this is for adornment   
00146 }
00147 
00148 void
00149 ServerSubscriptionHandler::onNewSubscriptionFromRefer(ServerSubscriptionHandle, const SipMessage& sub)
00150 {
00151 }
00152 
00153 void 
00154 ServerSubscriptionHandler::onFlowTerminated(ServerSubscriptionHandle h)
00155 {
00156    InfoLog(<< "ServerSubscriptionHandler::onFlowTerminated");
00157    // By default, tear down the sub.
00158    h->end();
00159 }
00160 
00161 
00162 
00163 /* ====================================================================
00164  * The Vovida Software License, Version 1.0 
00165  * 
00166  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00167  * 
00168  * Redistribution and use in source and binary forms, with or without
00169  * modification, are permitted provided that the following conditions
00170  * are met:
00171  * 
00172  * 1. Redistributions of source code must retain the above copyright
00173  *    notice, this list of conditions and the following disclaimer.
00174  * 
00175  * 2. Redistributions in binary form must reproduce the above copyright
00176  *    notice, this list of conditions and the following disclaimer in
00177  *    the documentation and/or other materials provided with the
00178  *    distribution.
00179  * 
00180  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00181  *    and "Vovida Open Communication Application Library (VOCAL)" must
00182  *    not be used to endorse or promote products derived from this
00183  *    software without prior written permission. For written
00184  *    permission, please contact vocal@vovida.org.
00185  *
00186  * 4. Products derived from this software may not be called "VOCAL", nor
00187  *    may "VOCAL" appear in their name, without prior written
00188  *    permission of Vovida Networks, Inc.
00189  * 
00190  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00191  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00192  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00193  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00194  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00195  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00196  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00197  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00198  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00199  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00200  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00201  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00202  * DAMAGE.
00203  * 
00204  * ====================================================================
00205  * 
00206  * This software consists of voluntary contributions made by Vovida
00207  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00208  * Inc.  For more information on Vovida Networks, Inc., please see
00209  * <http://www.vovida.org/>.
00210  *
00211  */