diff options
author | Jacek Antonelli | 2008-08-15 23:45:54 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:54 -0500 |
commit | d0b03a62fd799317d5da0bd56615739ce3b5b052 (patch) | |
tree | 8bc79bbbb52e18294f62810d9fa66ce136f90e2d /linden/indra/newview/llwearablelist.cpp | |
parent | Second Life viewer sources 1.20.8 (diff) | |
download | meta-impy-d0b03a62fd799317d5da0bd56615739ce3b5b052.zip meta-impy-d0b03a62fd799317d5da0bd56615739ce3b5b052.tar.gz meta-impy-d0b03a62fd799317d5da0bd56615739ce3b5b052.tar.bz2 meta-impy-d0b03a62fd799317d5da0bd56615739ce3b5b052.tar.xz |
Second Life viewer sources 1.20.9
Diffstat (limited to 'linden/indra/newview/llwearablelist.cpp')
-rw-r--r-- | linden/indra/newview/llwearablelist.cpp | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/linden/indra/newview/llwearablelist.cpp b/linden/indra/newview/llwearablelist.cpp index cabf20a..75986c1 100644 --- a/linden/indra/newview/llwearablelist.cpp +++ b/linden/indra/newview/llwearablelist.cpp | |||
@@ -57,13 +57,15 @@ struct LLWearableArrivedData | |||
57 | mAssetType( asset_type ), | 57 | mAssetType( asset_type ), |
58 | mCallback( asset_arrived_callback ), | 58 | mCallback( asset_arrived_callback ), |
59 | mUserdata( userdata ), | 59 | mUserdata( userdata ), |
60 | mName( wearable_name ) | 60 | mName( wearable_name ), |
61 | mRetries(0) | ||
61 | {} | 62 | {} |
62 | 63 | ||
63 | LLAssetType::EType mAssetType; | 64 | LLAssetType::EType mAssetType; |
64 | void (*mCallback)(LLWearable*, void* userdata); | 65 | void (*mCallback)(LLWearable*, void* userdata); |
65 | void* mUserdata; | 66 | void* mUserdata; |
66 | LLString mName; | 67 | LLString mName; |
68 | S32 mRetries; | ||
67 | }; | 69 | }; |
68 | 70 | ||
69 | 71 | ||
@@ -99,12 +101,12 @@ void LLWearableList::getAsset( const LLAssetID& assetID, const LLString& wearabl | |||
99 | // static | 101 | // static |
100 | void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID& uuid, void* userdata, S32 status, LLExtStat ext_status ) | 102 | void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID& uuid, void* userdata, S32 status, LLExtStat ext_status ) |
101 | { | 103 | { |
102 | BOOL success = FALSE; | ||
103 | LLWearableArrivedData* data = (LLWearableArrivedData*) userdata; | 104 | LLWearableArrivedData* data = (LLWearableArrivedData*) userdata; |
104 | 105 | LLWearable* wearable = NULL; // NULL indicates failure | |
106 | |||
105 | if( !filename ) | 107 | if( !filename ) |
106 | { | 108 | { |
107 | llinfos << "Bad Wearable Asset: missing file." << llendl; | 109 | LL_WARNS("Wearable") << "Bad Wearable Asset: missing file." << LL_ENDL; |
108 | } | 110 | } |
109 | else | 111 | else |
110 | if( status >= 0 ) | 112 | if( status >= 0 ) |
@@ -113,38 +115,16 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID | |||
113 | LLFILE* fp = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ | 115 | LLFILE* fp = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ |
114 | if( !fp ) | 116 | if( !fp ) |
115 | { | 117 | { |
116 | llinfos << "Bad Wearable Asset: unable to open file: '" << filename << "'" << llendl; | 118 | LL_WARNS("Wearable") << "Bad Wearable Asset: unable to open file: '" << filename << "'" << LL_ENDL; |
117 | } | 119 | } |
118 | else | 120 | else |
119 | { | 121 | { |
120 | LLWearable *wearable = new LLWearable(uuid); | 122 | wearable = new LLWearable(uuid); |
121 | if( wearable->importFile( fp ) ) | 123 | bool res = wearable->importFile( fp ); |
122 | { | 124 | if (!res) |
123 | // llinfos << "processGetAssetReply()" << llendl; | ||
124 | // wearable->dump(); | ||
125 | |||
126 | gWearableList.mList[ uuid ] = wearable; | ||
127 | if( data->mCallback ) | ||
128 | { | ||
129 | data->mCallback( wearable, data->mUserdata ); | ||
130 | } | ||
131 | success = TRUE; | ||
132 | } | ||
133 | else | ||
134 | { | 125 | { |
135 | LLString::format_map_t args; | ||
136 | // *TODO:translate | ||
137 | args["[TYPE]"] = LLAssetType::lookupHumanReadable(data->mAssetType); | ||
138 | if (data->mName.empty()) | ||
139 | { | ||
140 | LLNotifyBox::showXml("FailedToLoadWearableUnnamed", args); | ||
141 | } | ||
142 | else | ||
143 | { | ||
144 | args["[DESC]"] = data->mName; | ||
145 | LLNotifyBox::showXml("FailedToLoadWearable", args); | ||
146 | } | ||
147 | delete wearable; | 126 | delete wearable; |
127 | wearable = NULL; | ||
148 | } | 128 | } |
149 | 129 | ||
150 | fclose( fp ); | 130 | fclose( fp ); |
@@ -162,44 +142,64 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID | |||
162 | } | 142 | } |
163 | LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); | 143 | LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); |
164 | 144 | ||
165 | llwarns << "Wearable download failed: " << LLAssetStorage::getErrorString( status ) << " " << uuid << llendl; | 145 | LL_WARNS("Wearable") << "Wearable download failed: " << LLAssetStorage::getErrorString( status ) << " " << uuid << LL_ENDL; |
166 | switch( status ) | 146 | switch( status ) |
167 | { | 147 | { |
168 | case LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE: | 148 | case LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE: |
169 | { | 149 | { |
170 | LLString::format_map_t args; | 150 | // Fail |
171 | // *TODO:translate | 151 | break; |
172 | args["[TYPE]"] = LLAssetType::lookupHumanReadable(data->mAssetType); | 152 | } |
173 | if (data->mName.empty()) | 153 | default: |
154 | { | ||
155 | static const S32 MAX_RETRIES = 3; | ||
156 | if (data->mRetries < MAX_RETRIES) | ||
174 | { | 157 | { |
175 | LLNotifyBox::showXml("FailedToFindWearableUnnamed", args); | 158 | // Try again |
159 | data->mRetries++; | ||
160 | gAssetStorage->getAssetData(uuid, | ||
161 | data->mAssetType, | ||
162 | LLWearableList::processGetAssetReply, | ||
163 | userdata); // re-use instead of deleting. | ||
164 | return; | ||
176 | } | 165 | } |
177 | else | 166 | else |
178 | { | 167 | { |
179 | args["[DESC]"] = data->mName; | 168 | // Fail |
180 | LLNotifyBox::showXml("FailedToFindWearable", args); | 169 | break; |
181 | } | 170 | } |
182 | |||
183 | // Asset does not exist in the database. | ||
184 | // Can't load asset, so return NULL | ||
185 | if( data->mCallback ) | ||
186 | { | ||
187 | data->mCallback( NULL, data->mUserdata ); | ||
188 | } | ||
189 | break; | ||
190 | } | ||
191 | default: | ||
192 | { | ||
193 | // Try again | ||
194 | gAssetStorage->getAssetData(uuid, | ||
195 | data->mAssetType, | ||
196 | LLWearableList::processGetAssetReply, | ||
197 | userdata); // re-use instead of deleting. | ||
198 | return; | ||
199 | } | 171 | } |
200 | } | 172 | } |
201 | } | 173 | } |
202 | 174 | ||
175 | if (wearable) // success | ||
176 | { | ||
177 | gWearableList.mList[ uuid ] = wearable; | ||
178 | LL_DEBUGS("Wearable") << "processGetAssetReply()" << LL_ENDL; | ||
179 | LL_DEBUGS("Wearable") << wearable << LL_ENDL; | ||
180 | } | ||
181 | else | ||
182 | { | ||
183 | LLString::format_map_t args; | ||
184 | // *TODO:translate | ||
185 | args["[TYPE]"] = LLAssetType::lookupHumanReadable(data->mAssetType); | ||
186 | if (data->mName.empty()) | ||
187 | { | ||
188 | LLNotifyBox::showXml("FailedToFindWearableUnnamed", args); | ||
189 | } | ||
190 | else | ||
191 | { | ||
192 | args["[DESC]"] = data->mName; | ||
193 | LLNotifyBox::showXml("FailedToFindWearable", args); | ||
194 | } | ||
195 | } | ||
196 | // Always call callback; wearable will be NULL if we failed | ||
197 | { | ||
198 | if( data->mCallback ) | ||
199 | { | ||
200 | data->mCallback( wearable, data->mUserdata ); | ||
201 | } | ||
202 | } | ||
203 | delete data; | 203 | delete data; |
204 | } | 204 | } |
205 | 205 | ||