|
reSIProcate/stack
9694
|
00001 #if !defined(RESIP_TUIM_HXX) 00002 #define RESIP_TUIM_HXX 00003 00004 #include <list> 00005 00006 #include "resip/stack/DeprecatedDialog.hxx" 00007 #include "resip/stack/SecurityTypes.hxx" 00008 #include "resip/stack/Transport.hxx" 00009 #include "resip/stack/SipStack.hxx" 00010 #include "rutil/Timer.hxx" 00011 00012 namespace resip 00013 { 00014 00015 class Pidf; 00016 00017 class TuIM 00018 { 00019 private: 00020 class Buddy; 00021 class StateAgent; 00022 class Page; 00023 00024 public: 00025 class Callback 00026 { 00027 public: 00028 virtual void receivedPage(const Data& msg, 00029 const Uri& from, 00030 const Data& signedBy, 00031 SignatureStatus sigStatus, 00032 bool wasEncryped ) = 0; 00033 virtual void sendPageFailed(const Uri& dest, int respNumber ) =0; 00034 virtual void receivePageFailed(const Uri& sender) =0; 00035 virtual void registrationFailed(const Uri& dest, int respNumber ) =0; 00036 virtual void registrationWorked(const Uri& dest ) =0; 00037 virtual void presenceUpdate(const Uri& user, bool open, const Data& status ) =0; 00038 virtual bool authorizeSubscription( const Uri& user ); // return 00039 // true if 00040 // sub is ok 00041 00042 virtual ~Callback(); 00043 }; 00044 00045 TuIM(SipStack* stack, 00046 const Uri& aor, 00047 const Uri& contact, 00048 Callback* callback, 00049 const int registrationTimeSeconds = 1*60*60, 00050 const int subscriptionTimeSeconds = 10*60 ); 00051 00053 void setOutboundProxy( const Uri& uri ); 00054 void setDefaultProtocol( TransportType protocol ); 00055 void setUAName( const Data& name ); 00056 00057 bool haveCerts( bool sign, const Data& encryptFor ); 00058 void sendPage(const Data& text, const Uri& dest, 00059 const bool sign=false, const Data& encryptFor = Data::Empty ); 00060 00061 void process(); 00062 00063 // Registration management 00064 void registerAor( const Uri& uri, 00065 const Data& password = Data::Empty ); 00066 00067 // Buddy List management 00068 int getNumBuddies() const; 00069 const Uri getBuddyUri(const int index); 00070 const Data getBuddyGroup(const int index); 00071 bool getBuddyStatus(const int index, Data* status=NULL); 00072 void addBuddy( const Uri& uri, const Data& group ); 00073 void removeBuddy( const Uri& name); 00074 00075 // Presence management 00076 void setMyPresence( const bool open, 00077 const Data& status = Data::Empty, 00078 const Data& user = Data::Empty ); 00079 void addStateAgent( const Uri& uri ); 00080 void authorizeSubscription( const Data& user ); 00081 00082 private: 00083 void processSipFrag(SipMessage* msg); 00084 00085 void processRequest(SipMessage* msg); 00086 void processMessageRequest(SipMessage* msg); 00087 void processSubscribeRequest(SipMessage* msg); 00088 void processRegisterRequest(SipMessage* msg); 00089 void processNotifyRequest(SipMessage* msg); 00090 00091 void processResponse(SipMessage* msg); 00092 void processRegisterResponse(SipMessage* msg); 00093 void processSubscribeResponse(SipMessage* msg, Buddy& buddy ); 00094 void processNotifyResponse(SipMessage* msg, DeprecatedDialog& d ); 00095 void processPublishResponse(SipMessage* msg, StateAgent& sa ); 00096 void processPageResponse(SipMessage* msg, Page& page ); 00097 00098 void sendNotify(DeprecatedDialog* dialog); 00099 void sendPublish(StateAgent& dialog); 00100 00101 void setOutbound( SipMessage& msg ); 00102 00103 void subscribeBuddy( Buddy& buddy ); 00104 00105 Callback* mCallback; 00106 SipStack* mStack; 00107 Uri mAor; 00108 Uri mContact; 00109 00110 class Buddy 00111 { 00112 public: 00113 Uri uri; 00114 Data group; 00115 DeprecatedDialog* presDialog; 00116 UInt64 mNextTimeToSubscribe; 00117 bool online; 00118 Data status; 00119 00120 Buddy() {}; 00121 Buddy(const Buddy& rhs) 00122 { 00123 uri = rhs.uri; 00124 group = rhs.group; 00125 presDialog = rhs.presDialog; 00126 mNextTimeToSubscribe = rhs.mNextTimeToSubscribe; 00127 online = rhs.online; 00128 status = rhs.status; 00129 }; 00130 }; 00131 00132 // people I subscribe to 00133 std::vector<Buddy> mBuddies; 00134 typedef std::vector<Buddy>::iterator BuddyIterator; 00135 00136 class StateAgent 00137 { 00138 public: 00139 Uri uri; 00140 DeprecatedDialog* dialog; 00141 }; 00142 // people I publish to 00143 std::list<StateAgent> mStateAgents; 00144 typedef std::list<StateAgent>::iterator StateAgentIterator; 00145 00146 // people who subscribe to me 00147 class Subscriber 00148 { 00149 public: 00150 Data aor; 00151 bool authorized; 00152 DeprecatedDialog* dialog; 00153 }; 00154 std::list<Subscriber> mSubscribers; 00155 typedef std::list<Subscriber>::iterator SubscriberIterator; 00156 00157 class Page 00158 { 00159 public: 00160 Data text; 00161 Uri uri; 00162 bool sign; 00163 Data encryptFor; 00164 DeprecatedDialog* dialog; 00165 }; 00166 // outstanding messages 00167 std::list<Page> mPages; 00168 typedef std::list<Page>::iterator PageIterator; 00169 00170 // Current pres info 00171 Pidf* mPidf; 00172 00173 // registration information 00174 DeprecatedDialog mRegistrationDialog; 00175 UInt64 mNextTimeToRegister; 00176 Data mRegistrationPassword; 00177 unsigned int mLastAuthCSeq; // This is the CSeq of the last registration message 00178 // sent that included digest authorization information 00179 00180 const int mRegistrationTimeSeconds; // this is the default time to request in 00181 // a registration 00182 00183 const int mSubscriptionTimeSeconds; // this is the default time to request in 00184 // a subscription 00185 00186 Uri mOutboundProxy; 00187 Data mUAName; 00188 TransportType mDefaultProtocol; 00189 }; 00190 00191 } 00192 00193 #endif 00194 00195 /* ==================================================================== 00196 * The Vovida Software License, Version 1.0 00197 * 00198 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00199 * 00200 * Redistribution and use in source and binary forms, with or without 00201 * modification, are permitted provided that the following conditions 00202 * are met: 00203 * 00204 * 1. Redistributions of source code must retain the above copyright 00205 * notice, this list of conditions and the following disclaimer. 00206 * 00207 * 2. Redistributions in binary form must reproduce the above copyright 00208 * notice, this list of conditions and the following disclaimer in 00209 * the documentation and/or other materials provided with the 00210 * distribution. 00211 * 00212 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00213 * and "Vovida Open Communication Application Library (VOCAL)" must 00214 * not be used to endorse or promote products derived from this 00215 * software without prior written permission. For written 00216 * permission, please contact vocal@vovida.org. 00217 * 00218 * 4. Products derived from this software may not be called "VOCAL", nor 00219 * may "VOCAL" appear in their name, without prior written 00220 * permission of Vovida Networks, Inc. 00221 * 00222 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00223 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00224 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00225 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00226 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00227 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00228 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00229 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00230 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00231 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00232 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00233 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00234 * DAMAGE. 00235 * 00236 * ==================================================================== 00237 * 00238 * This software consists of voluntary contributions made by Vovida 00239 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00240 * Inc. For more information on Vovida Networks, Inc., please see 00241 * <http://www.vovida.org/>. 00242 * 00243 */
1.7.5.1