reSIProcate/stack  9694
MessageWaitingContents.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_MESSAGEWAITINGCONTENTS_HXX)
00002 #define RESIP_MESSAGEWAITINGCONTENTS_HXX 
00003 
00004 #include <map>
00005 
00006 #include "resip/stack/Contents.hxx"
00007 #include "rutil/Data.hxx"
00008 
00009 namespace resip
00010 {
00011 
00012 const char* skipSipLWS(ParseBuffer& pb);
00013 
00018 typedef enum {mw_voice=0, mw_fax, mw_pager, mw_multimedia, mw_text, mw_none, MW_MAX} HeaderType;
00019 
00026 class MessageWaitingContents : public Contents
00027 {
00028    public:
00029       MessageWaitingContents();
00030       MessageWaitingContents(const HeaderFieldValue& hfv, const Mime& contentType);
00031       MessageWaitingContents(const Data& data, const Mime& contentType);
00032       MessageWaitingContents(const MessageWaitingContents& rhs);
00033       virtual ~MessageWaitingContents();
00034       MessageWaitingContents& operator=(const MessageWaitingContents& rhs);
00035 
00039       virtual Contents* clone() const;
00040 
00041       static const Mime& getStaticType() ;
00042 
00043       virtual EncodeStream& encodeParsed(EncodeStream& str) const;
00044       virtual void parse(ParseBuffer& pb);
00045 
00046       class Header;
00047 
00052       Header& header(HeaderType ht);
00053       const Header& header(HeaderType ht) const;
00054 
00059       bool exists(HeaderType ht) const;
00060 
00064       void remove(HeaderType ht);
00065 
00077       class AccountHeader {};
00078 
00083       const Uri& header(const AccountHeader& ht) const;
00084       Uri& header(const AccountHeader& ht);
00085 
00095       bool exists(const AccountHeader& ht) const;
00096 
00100       void remove(const AccountHeader& ht);
00101 
00109       const Data& header(const Data& hn) const;
00110       Data& header(const Data& hn);
00111 
00116       bool exists(const Data& hn) const;
00117 
00121       void remove(const Data& hn);
00122 
00126       bool& hasMessages() { checkParsed(); return mHasMessages; }
00127 
00130       class Header
00131       {
00132          public:
00138             Header(unsigned int numNew,
00139                    unsigned int numOld);
00140 
00148             Header(unsigned int numNew,
00149                    unsigned int numOld,
00150                    unsigned int numUrgentNew,
00151                    unsigned int numUrgentOld);
00152 
00156             const unsigned int& newCount() const {return mNew;}
00157 
00161             unsigned int& newCount() {return mNew;}
00162 
00166             const unsigned int& oldCount() const {return mOld;}
00167 
00171             unsigned int& oldCount() {return mOld;}
00172 
00177             const bool& urgent() const {return mHasUrgent;}
00178 
00183             bool& urgent() {return mHasUrgent;}
00184 
00188             const unsigned int& urgentNewCount() const {return mUrgentNew;}
00189 
00193             unsigned int& urgentNewCount() {return mUrgentNew;}
00194 
00198             const unsigned int& urgentOldCount() const {return mUrgentOld;}
00199 
00203             unsigned int& urgentOldCount() {return mUrgentOld;}
00204 
00205          private:
00206             unsigned int mNew;
00207             unsigned int mOld;
00208             bool mHasUrgent;
00209             unsigned int mUrgentNew;
00210             unsigned int mUrgentOld;
00211 
00212             friend class MessageWaitingContents;
00213       };
00214 
00215       static bool init();
00216    private:
00217       void clear();
00218 
00219       bool mHasMessages;
00220       Uri* mAccountUri;
00221       Header* mHeaders[MW_MAX];
00222       std::map<Data, Data> mExtensions;
00223 };
00224 
00227 extern MessageWaitingContents::AccountHeader mw_account;
00228 static bool invokeMessageWaitingContentsInit = MessageWaitingContents::init();
00229 
00230 }
00231 
00232 #endif
00233 
00234 /* ====================================================================
00235  * The Vovida Software License, Version 1.0 
00236  * 
00237  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00238  * 
00239  * Redistribution and use in source and binary forms, with or without
00240  * modification, are permitted provided that the following conditions
00241  * are met:
00242  * 
00243  * 1. Redistributions of source code must retain the above copyright
00244  *    notice, this list of conditions and the following disclaimer.
00245  * 
00246  * 2. Redistributions in binary form must reproduce the above copyright
00247  *    notice, this list of conditions and the following disclaimer in
00248  *    the documentation and/or other materials provided with the
00249  *    distribution.
00250  * 
00251  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00252  *    and "Vovida Open Communication Application Library (VOCAL)" must
00253  *    not be used to endorse or promote products derived from this
00254  *    software without prior written permission. For written
00255  *    permission, please contact vocal@vovida.org.
00256  *
00257  * 4. Products derived from this software may not be called "VOCAL", nor
00258  *    may "VOCAL" appear in their name, without prior written
00259  *    permission of Vovida Networks, Inc.
00260  * 
00261  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00262  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00263  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00264  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00265  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00266  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00267  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00268  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00269  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00270  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00271  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00272  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00273  * DAMAGE.
00274  * 
00275  * ====================================================================
00276  * 
00277  * This software consists of voluntary contributions made by Vovida
00278  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00279  * Inc.  For more information on Vovida Networks, Inc., please see
00280  * <http://www.vovida.org/>.
00281  *
00282  */