|
reSIProcate/DialogUsageManager
9680
|
00001 #include "resip/stack/SipStack.hxx" 00002 #include "resip/dum/DialogUsageManager.hxx" 00003 #include "resip/dum/DumProcessHandler.hxx" 00004 #include "rutil/Logger.hxx" 00005 00006 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM 00007 00008 namespace resip { 00009 00010 DumProcessHandler::DumProcessHandler(ExternalTimer* et) : 00011 mHaveActiveTimer(false), 00012 mDum(0), 00013 mExternalTimer(et), 00014 mStopped(false), 00015 mCurrentlyProcessing(false) 00016 { 00017 } 00018 00019 void 00020 DumProcessHandler::start(DialogUsageManager* dum) 00021 { 00022 mDum = dum; 00023 mExternalTimer->setHandler(this); 00024 mTimerID = mExternalTimer->generateAsyncID(); 00025 } 00026 00027 void 00028 DumProcessHandler::handleProcessNotification() 00029 { 00030 #if 0 // !dcm! this needs to be fixed in the new model 00031 //only works when there is exactly one thread causing notifications; could be 00032 //made thread safecancelled 00033 if (!mCurrentlyProcessing && !mStopped) 00034 { 00035 mCurrentlyProcessing = true; 00036 //very temporary 00037 //FD_ISSET ?? 00038 FdSet fds; 00039 mDum->buildFdSet(fds); 00040 if (fds.size > 0) 00041 { 00042 fds.selectMilliSeconds((long)0); 00043 } 00044 00045 int timeTillProcess = 0; 00046 do 00047 { 00048 mDum->process(fds); 00049 timeTillProcess = mDum->getTimeTillNextProcessMS(); 00050 } 00051 while (timeTillProcess == 0); 00052 if (timeTillProcess != INT_MAX) 00053 { 00054 if (mHaveActiveTimer) 00055 { 00056 mExternalTimer->deleteTimer(mTimerID); 00057 } 00058 assert(timeTillProcess < 60*4*60*1000); //4hr sanity check 00059 mTimerID = mExternalTimer->generateAsyncID(); 00060 DebugLog ( << "Setting dum process timer: " << timeTillProcess); 00061 mExternalTimer->createTimer(mTimerID, timeTillProcess); 00062 mHaveActiveTimer = true; 00063 } 00064 mCurrentlyProcessing = false; 00065 } 00066 #endif 00067 } 00068 00069 void 00070 DumProcessHandler::handleTimeout(AsyncID timerID) 00071 { 00072 assert(timerID == mTimerID); 00073 mHaveActiveTimer = false; 00074 handleProcessNotification(); 00075 } 00076 00077 00078 void 00079 DumProcessHandler::stop() 00080 { 00081 mStopped = true; 00082 if (mHaveActiveTimer) 00083 { 00084 mExternalTimer->deleteTimer(mTimerID); 00085 } 00086 } 00087 00088 } // namespace resip 00089 00090 /* ==================================================================== 00091 * The Vovida Software License, Version 1.0 00092 * 00093 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00094 * 00095 * Redistribution and use in source and binary forms, with or without 00096 * modification, are permitted provided that the following conditions 00097 * are met: 00098 * 00099 * 1. Redistributions of source code must retain the above copyright 00100 * notice, this list of conditions and the following disclaimer. 00101 * 00102 * 2. Redistributions in binary form must reproduce the above copyright 00103 * notice, this list of conditions and the following disclaimer in 00104 * the documentation and/or other materials provided with the 00105 * distribution. 00106 * 00107 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00108 * and "Vovida Open Communication Application Library (VOCAL)" must 00109 * not be used to endorse or promote products derived from this 00110 * software without prior written permission. For written 00111 * permission, please contact vocal@vovida.org. 00112 * 00113 * 4. Products derived from this software may not be called "VOCAL", nor 00114 * may "VOCAL" appear in their name, without prior written 00115 * permission of Vovida Networks, Inc. 00116 * 00117 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00118 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00119 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00120 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00121 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00122 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00123 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00124 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00125 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00126 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00127 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00128 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00129 * DAMAGE. 00130 * 00131 * ==================================================================== 00132 * 00133 * This software consists of voluntary contributions made by Vovida 00134 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00135 * Inc. For more information on Vovida Networks, Inc., please see 00136 * <http://www.vovida.org/>. 00137 * 00138 */
1.7.5.1