lldelayedgestureerror.cpp

Go to the documentation of this file.
00001 
00033 #include "llviewerprecompiledheaders.h"
00034 #include "lldelayedgestureerror.h"
00035 #include <list>
00036 #include "llnotify.h"
00037 #include "llcallbacklist.h"
00038 #include "llinventory.h"
00039 #include "llviewerinventory.h"
00040 #include "llinventorymodel.h"
00041 
00042 const F32 MAX_NAME_WAIT_TIME = 5.0f;
00043 
00044 LLDelayedGestureError::ErrorQueue LLDelayedGestureError::sQueue;
00045 
00046 //static
00047 void LLDelayedGestureError::gestureMissing(const LLUUID &id)
00048 {
00049         LLErrorEntry ent("GestureMissing", id);
00050         if ( ! doDialog(ent) )
00051         {
00052                 enqueue(ent);
00053         }
00054 }
00055 
00056 //static
00057 void LLDelayedGestureError::gestureFailedToLoad(const LLUUID &id)
00058 {
00059         LLErrorEntry ent("UnableToLoadGesture", id);
00060 
00061         if ( ! doDialog(ent) )
00062         {
00063                 enqueue(ent);
00064         }
00065 }
00066 
00067 //static
00068 void LLDelayedGestureError::enqueue(const LLErrorEntry &ent)
00069 {
00070         if ( sQueue.empty() )
00071         {
00072                 gIdleCallbacks.addFunction(onIdle, NULL);
00073         }
00074 
00075         sQueue.push_back(ent);
00076 }
00077 
00078 //static 
00079 void LLDelayedGestureError::onIdle(void *userdata)
00080 {
00081         if ( ! sQueue.empty() )
00082         {
00083                 LLErrorEntry ent = sQueue.front();
00084                 sQueue.pop_front();
00085 
00086                 if ( ! doDialog(ent, false ) )
00087                 {
00088                         enqueue(ent);
00089                 }
00090         }
00091         else
00092         {
00093                 // Nothing to do anymore
00094                 gIdleCallbacks.deleteFunction(onIdle, NULL);
00095         }
00096 }
00097 
00098 //static 
00099 bool LLDelayedGestureError::doDialog(const LLErrorEntry &ent, bool uuid_ok)
00100 {
00101         LLStringBase<char>::format_map_t args;
00102         LLInventoryItem *item = gInventory.getItem( ent.mItemID );
00103 
00104         if ( item )
00105         {
00106                 args["[NAME]"] = item->getName();
00107         }
00108         else
00109         {
00110                 if ( uuid_ok || ent.mTimer.getElapsedTimeF32() > MAX_NAME_WAIT_TIME )
00111                 {
00112                         args["[NAME]"] = LLString( ent.mItemID.asString() );
00113                 }
00114                 else
00115                 {
00116                         return false;
00117                 }
00118         }
00119          
00120 
00121         LLNotifyBox::showXml(ent.mNotifyName, args);
00122 
00123         return true;
00124 }
00125 

Generated on Fri May 16 08:33:17 2008 for SecondLife by  doxygen 1.5.5