Compare commits

...

121 Commits

Author SHA1 Message Date
Siana Gearz
68ad5411c9 Shyotl's old llcurl 2012-08-07 13:13:45 +02:00
Siana Gearz
6ed9a62501 Disable texture auditing at start-up 2012-07-28 16:56:19 +02:00
Siana Gearz
89be317a00 Fix measurement tool 2012-07-23 14:18:45 +02:00
Siana Gearz
1ad4597d7a Fix alpha flicker when Show Updates is enabled 2012-07-23 12:00:33 +02:00
Siana Gearz
c65b659538 Dirty potential mesh crash fix 2012-07-23 10:50:05 +02:00
Siana Gearz
3c23163a29 Less intrusive notifications, by Tazy Scientist 2012-07-23 09:54:00 +02:00
Siana Gearz
c3900ee4f3 Merge branch 'AltCompilers' of git://github.com/LightDrake/SingularityViewer
Conflicts:
	indra/newview/llvieweraudio.cpp
2012-07-23 09:03:17 +02:00
Siana Gearz
9c5da9e42c Build fixes VC10 2012-07-23 08:13:13 +02:00
Drake Arconis
efa970c6a5 Uhm..
This fixes a build issue temp till can rebuild QT...*sigh*
2012-07-22 23:41:09 -04:00
Siana Gearz
179f04739d Merge commit 'c7bdaf66329b018159c834d75fcc3d807b188ccb' 2012-07-23 05:10:56 +02:00
Siana Gearz
b2f513caae Safer settings, EOL fix 2012-07-23 04:02:20 +02:00
Siana Gearz
9c1e74b0c0 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer
Conflicts:
	indra/llaudio/llstreamingaudio_fmodex.cpp
	indra/newview/skins/default/xui/en-us/panel_preferences_graphics1.xml
2012-07-23 03:04:33 +02:00
Siana Gearz
e53af58d4a Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer 2012-07-22 23:31:19 +02:00
Siana Gearz
d9cb2ce6c7 Looks like a bit of edit crash fix got missed, thx Drake 2012-07-22 23:30:41 +02:00
Siana Gearz
a967f2b037 Updated 'Show Updates' 2012-07-22 22:36:40 +02:00
Siana Gearz
db5a7578c9 Crash fix copy texture params 2012-07-22 21:44:41 +02:00
Siana Gearz
15086833a3 Random stab in the dark coming right up! 2012-07-22 11:26:36 +02:00
Drake Arconis
72a9b6b7fe Corrected issues
Corrected issue noted in media_plugin_webkit by Aleric.
Grr.
2012-07-21 03:23:02 -04:00
Drake Arconis
0d3fab40e5 Further header cleanup and a few updates
Updated llstring to current linden
Further linden_common cleanup
Header cleanup
Raised banlines to 5000 as per linden server change
Included missing llmediaentry.cpp file
Minor whitespace changes here and there
2012-07-21 03:01:42 -04:00
Shyotl
4e4d554ea4 Silence the diagnostic llinfos spam when listening to a stream. 2012-07-20 12:11:30 -05:00
Lirusaito
c7bdaf6632 Merge branch 'AltCompilers' of https://github.com/LightDrake/SingularityViewer 2012-07-20 10:50:40 -04:00
Lirusaito
92c7792e95 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer
Conflicts:
	indra/newview/skins/default/xui/en-us/panel_preferences_graphics1.xml - Resolved to the eye's pleasure.
2012-07-20 10:41:25 -04:00
Drake Arconis
1e81966b89 Clean up and updates
Cleaned up header bloatyness in linden_common
Moved around things to be in line with Linden Lab
Updated llinitparam and imported its new dependencies
Removed dohexeditor and related files
Removed unused legacy files

             /\_..._/\
             |/ \_/ \|
             | o.-.o |
             \ ( O ) /
             /'--U--'\
             |  .:.  | /\
             | /:;:\ |` /
   Drake     | |:;:| |-'
  Arconis   /  |'-'|  \
            `""`   `""`
2012-07-20 08:13:07 -04:00
Shyotl
b785b9d219 Added 'Transparent Water' checkbox to graphics panel, as we actually have space for it now. 2012-07-20 05:15:47 -05:00
Shyotl
85da7163a7 Changing the rolloff settings now immediately apply (with fmodex). Also added AudioLevelUnderwaterRolloff now that the underwater rolloff 3d setting doesnt immediately get clobbered. Also, divvied up sound channels into channelgroups if using the fmod profiler, so it actually has useful info to show now. 2012-07-20 04:00:02 -05:00
Lirusaito
f3f8bee83b Remove old spam stuffs, Clean up new spam stuffs to compile, UI new spam stuffs. 2012-07-19 23:40:07 -04:00
Drake Arconis
7843f51110 Merge remote-tracking branch 'singu/master' into AltCompilers 2012-07-19 17:51:18 -04:00
Drake Arconis
8bfdc98ef4 Improvements!
Fixed Boost library to not throw warnings
Changed PNG cmake slightly
Updated 32lib package for correct locations
Cleaned up flags a bit for linux64
2012-07-19 17:44:19 -04:00
Ruby
6673c89791 Add Antispam code from NaCl (Chalice Yao)
Amended by: Lirusaito <inusaito@gmail.com>
2012-07-19 16:36:39 -04:00
Siana Gearz
a8a30ae3b9 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer 2012-07-19 22:19:52 +02:00
Lirusaito
15af410e6f Fix typo in outbox icon name, when closed. 2012-07-19 14:02:11 -04:00
Shyotl
756a284048 Don't ever halt stalled fmodex streams, as they don't seem to truly 'stall'. Decrease delay between leaving starvation and unmuting down to 1 second (from 5). 2012-07-19 02:32:16 -05:00
Lirusaito
32e2b584b9 Translation Fix 2012-07-19 02:12:51 -04:00
Lirusaito
add52b4d57 Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer 2012-07-18 23:41:23 -04:00
Siana Gearz
a4d2cb3d12 Some fighting with Shyotl over FMOD Ex 2012-07-19 05:35:17 +02:00
Lirusaito
72fbb3f63e Merge branch 'master' of https://github.com/DamianZhaoying/SingularityViewer 2012-07-18 22:58:52 -04:00
Siana Gearz
c62290accb Merge branch 'master' of git://github.com/Lirusaito/SingularityViewer 2012-07-19 04:46:15 +02:00
Siana Gearz
8ad40c5d66 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer
Conflicts:
	indra/llaudio/llaudioengine_fmodex.cpp
2012-07-19 04:44:01 +02:00
Lirusaito
cd5a721c23 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer 2012-07-18 22:31:53 -04:00
Shyotl
643844c01d GCC being GCC-ey. Fix a couple errors and warnings 2012-07-18 21:27:46 -05:00
Lirusaito
c84f080fc8 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer 2012-07-18 22:08:06 -04:00
Shyotl
5fcdbfdd9e FMODEx diagnostics.
SHFMODExStreamBufferSize added. Determines stream buffer size in ms. (stream restart required)
SHFMODExDecodeBufferSize added. Determines decode buffer size in ms. (stream restart required)
Streams will mute themselves if they are starving, until they are free of starvation for 5 full seconds.
Streams that fail to accumulate any buffer progress while starving for 10 full updates will be stopped.
Stream buffer progress(buffer percent) is llinfos spewed every update. (temporary)
Doubled default stream buffer size
Increased default decode buffer size to 1000ms (from 400)
Temporarily using FMOD::Memory_Initialize to display raw stream/decode buffer sizes via llinfos.
Added llwarns messages for SigmaTel hardware or bad audio acceleration configuration.
2012-07-18 21:05:24 -05:00
Siana Gearz
96fa4af939 Initialize FMOD Ex with 44100 Hz, like FMOD 2012-07-19 03:26:02 +02:00
Siana Gearz
2334793554 Build SLPLugin.exe without tcmalloc, for SkyDrive 2012-07-19 03:24:44 +02:00
Lirusaito
20e445b4be Added icons for folders from phoenix, and created outbox folder icon for future use. 2012-07-18 20:26:19 -04:00
Lirusaito
085db93fc8 menu_inventory.xml translations update.
Brought the French up to date, translations on my own..
Brought the Spanish up to standard.
2012-07-18 16:04:12 -04:00
Damian Zhaoying
8fe6925414 New Spanish Translations 2012-07-18 15:30:03 -03:00
Damian Zhaoying
57ad7e62d2 Merge remote-tracking branch 'upstream/master' 2012-07-18 08:57:45 -03:00
Lirusaito
03608103b8 Tiny French Translation update
~Thanks Nomade~
2012-07-18 03:57:07 -04:00
Damian Zhaoying
675d171104 Merge remote-tracking branch 'upstream/master' 2012-07-18 03:16:39 -03:00
Lirusaito
405af67f45 Merge branch 'AltCompilers' 2012-07-17 22:30:48 -04:00
Shyotl
72d93b8723 Merge branch 'V2MultiWear' 2012-07-17 19:46:56 -05:00
Damian Zhaoying
51c5933b76 Merge remote-tracking branch 'upstream/master' 2012-07-17 19:49:33 -03:00
Lirusaito
465c6b9ed6 Bring back ASCENDED_DEVELOPER, and give it extra meaning! 2012-07-17 16:42:43 -04:00
Drake Arconis
39847c4688 Merge remote-tracking branch 'liruhub/master' into AltCompilers 2012-07-17 16:08:10 -04:00
Drake Arconis
7721c6e3da Resolved issue with glibc 2.16
Resolved issues introduced by changes made in glibc 2.16 removing the undocumented definition of struct siginfo from bits/siginfo.h
2012-07-17 16:06:31 -04:00
Lirusaito
c0fbf4bf55 Merge branch 'master' of https://github.com/DamianZhaoying/SingularityViewer 2012-07-17 12:17:32 -04:00
Damian Zhaoying
01818582cf Merge remote-tracking branch 'upstream/master' 2012-07-16 21:07:25 -03:00
Lirusaito
9a0620f140 Add Voodoo to tags. 2012-07-16 19:33:44 -04:00
Drake Arconis
0216925e05 Merge remote-tracking branch 'siana/master' into AltCompilers 2012-07-16 17:20:57 -04:00
Drake Arconis
32b24a98ca Merge remote-tracking branch 'shyotl/V2MultiWear' into AltCompilers 2012-07-16 17:20:47 -04:00
Drake Arconis
93d7a4938a Merge remote-tracking branch 'liru/master' into AltCompilers 2012-07-16 17:19:58 -04:00
Drake Arconis
56265b78ec Merge remote-tracking branch 'liru/V2MultiWear' into AltCompilers 2012-07-16 17:19:45 -04:00
Lirusaito
6ee76aa6f7 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-07-16 17:11:44 -04:00
Lirusaito
32d6aefe00 Merge branch 'V2MultiWear' of git://github.com/Shyotl/SingularityViewer 2012-07-16 17:10:01 -04:00
Lirusaito
84795863e5 Translations updated
Updated French Translation from Nomade's Zip for MultiWear.
Updated Translations to use basically the same format, and not have some cruft.
Abouts updated to include Spanish translators: Damian Zhaoying, and Franxizco Romano.
2012-07-16 17:07:22 -04:00
Drake Arconis
92a5b14347 Linux64 libs and fixes 2012-07-16 16:10:15 -04:00
Shyotl
3cee90fe8b Lets not call glDeleteTextures any more, since the glGenTextures/glDeleteTextures paradigm has gone away. 2012-07-16 01:00:55 -05:00
Drake Arconis
2bb58bac2e Corrected annoyance and inconsistencies for OSX 2012-07-15 23:32:12 -04:00
Damian Zhaoying
9dc1897b35 Fix English Inventory UI To translate other languages 2012-07-15 23:56:58 -03:00
Drake Arconis
7a7da24df5 Merge remote-tracking branch 'shyotl/V2MultiWear' into AltCompilers 2012-07-15 22:22:01 -04:00
Shyotl
46f7250f08 Fixup multisample rbos. Samplecount validation all done in LLMultisampleBuffer::allocate, and falls back to non-multisample safely if multisampled rbos cannot/shouldn't be used. 2012-07-15 21:12:31 -05:00
Drake Arconis
58bfe23e5a Merge remote-tracking branch 'shyotl/V2MultiWear' into AltCompilers 2012-07-15 17:46:51 -04:00
Drake Arconis
ccb914ea83 General cleanup of OSX support - not done
Updated with new cursors from LL
Corrected mispackaged OSX Libs
Corrected mouse flicker on menus

Signed-off-by: Drake Arconis <lightdrake@gmail.com>
2012-07-15 17:45:50 -04:00
Shyotl
10fe67f4a6 FBO tweaks. Release multisample fbo in LLPipeline::releaseScreenBuffers, and fixed LLRenderBuffer::mInternalFormat falling out of sync with LLRenderBuffer::mTex. 2012-07-15 16:41:31 -05:00
Lirusaito
0243c61ea1 Spanish Translation is complete, add it to the completed combo_box area, and keep to alphabetical order. 2012-07-15 15:23:53 -04:00
Lirusaito
d73d4e9d48 Merge branch 'master' of git://github.com/TighMacFanatic/SingularityViewer 2012-07-15 15:10:40 -04:00
Lirusaito
3d60d9e3c5 Merge branch 'V2MultiWear' of https://github.com/DamianZhaoying/SingularityViewer 2012-07-15 15:10:09 -04:00
Lirusaito
59e0367dd4 Merge branch 'master' of git://github.com/TighMacFanatic/SingularityViewer 2012-07-15 14:52:46 -04:00
Drake Arconis
102eca7d65 Merge remote-tracking branch 'siana/master' into AltCompilers 2012-07-15 10:37:06 -04:00
Lirusaito
55a1d54b8e Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-07-15 09:56:04 -04:00
Lirusaito
1e24b889dd Merge branch 'V2MultiWear' of git://github.com/Shyotl/SingularityViewer 2012-07-14 21:47:43 -04:00
Lirusaito
988e2c3fdf Merge branch 'V2MultiWear' of git://github.com/Shyotl/SingularityViewer 2012-07-14 20:47:27 -04:00
Lirusaito
92dc20850d Added Terrain Scale ComboBox to graphics preferences panel.
Fixed up feature tables to use correct names, and to use the 7 for high TerrainScale.
2012-07-14 20:45:59 -04:00
Lirusaito
3acaf773b8 Merge branch 'AltCompilers' of https://bitbucket.org/LightDrake/singularityviewer 2012-07-14 16:01:06 -04:00
Lirusaito
5080746fa0 Prevent build preferences from altering objects we've duplicated. Offer an off switch for build prefs.
Added LiruEnableBuildPrefs, for turning off, when users do not want to use their default build parameters for a few prims, but don't wish to reset them permanently.
    This should perhaps end up on the build floater somewhere... but for now, debug only.
Note some of this fix for duplication may be overly cautious, but better safe than sorry.
Added a check for physical default in during creation, so that building at great distances adheres a bit more to build preferences.
Added IsCOA into the build settings, since I'd forgotten, previously.
2012-07-14 15:54:36 -04:00
Drake Arconis
07e1f0e802 Added a terrain texture scale changer thing!
Need someone to add UI bits though >.<
2012-07-14 05:04:10 -04:00
Drake Arconis
340f8f1f17 MORE WINDLIGHTS! 2012-07-14 05:02:44 -04:00
Drake Arconis
0316b7ff9a OSX libwork
Started on osx libwork will need darwin builder to test
2012-07-14 04:10:09 -04:00
Lirusaito
533675416c Merge branch 'V2MultiWear'
Conflicts:
	indra/newview/app_settings/settings.xml - Removed SinguMuteGestures, since it's EnableGestureSounds now.
		~removed in llviewermessage.cpp as well.
2012-07-13 05:44:38 -04:00
Damian Zhaoying
8baceee06c Add Spanish Translation 2012-07-13 06:23:37 -03:00
Lirusaito
f7bf5c33bc Merge branch 'V2MultiWear' of git://github.com/Shyotl/SingularityViewer into V2MultiWear 2012-07-12 17:43:53 -04:00
Lirusaito
8805e3fb27 Nomade Zhao's 4 fixes for translation. Re: Issue 340 2012-03-28 00:00:42 -04:00
Lirusaito
64d8397ea5 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-03-27 19:48:05 -04:00
Lirusaito
4d4496fc4d Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-03-27 19:29:24 -04:00
Lirusaito
af67342969 Merge branch 'master' of git://github.com/siana/SingularityViewer
Conflicts:
	indra/llrender/llvertexbuffer.cpp
Also, reverts indra/newview/skins/default/xui/en-us/panel_audio.xml to before mute-gesture button (For now can be toggled through SinguMuteGestures debug setting)
2012-03-27 07:15:48 -04:00
Lirusaito
d9cbd52ea8 Fix for compiler warning in LLVertexBuffer::setupVertexArray. 2012-03-23 22:45:55 -04:00
Lirusaito
8b25d44bcf Replaced a tab with a space in XML so Windows doesn't show an awkward square there. 2012-03-23 17:21:50 -04:00
Lirusaito
3d6733bed8 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-03-23 17:20:04 -04:00
Lirusaito
c3f3db518b Fixed Issue 340, multiple instances of same name breaking translation.
Applies to advanced chat preferences only.
2012-03-19 18:08:17 -04:00
Lirusaito
385ec62e53 Added scale_image="false" to all mute buttons.
This will allow the mute icons to retain their normal look,
with Shyotl's changes to the UI code.
2012-03-14 08:55:10 -04:00
Lirusaito
881524831f Merge branch 'master' of https://bitbucket.org/Lirusaito/singularityviewer 2012-03-14 02:58:45 -04:00
Lirusaito
376be8b990 Spelling fix in a comment. 2012-03-14 02:53:44 -04:00
Lirusaito
96ddbf2a8b Added scale_image="false" to the gesture mute button so it won't span the width of the button. 2012-03-03 01:38:53 -05:00
Lirusaito
c2ee420917 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-03-01 18:16:39 -05:00
Lirusaito
74a1ba0d1e Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-02-29 10:52:26 -05:00
Lirusaito
0dc05a39e6 Use Ctrl-shift-D for creating a landmarks, instead, and fix previous misplacement of the shortcut. 2012-02-28 13:05:06 -05:00
Lirusaito
72fe406f64 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-02-24 18:39:25 -05:00
Lirusaito
90ac174260 Added Ctrl-D for creating a landmark
Most browsers use this for creating bookmarks, landmarks are pretty much
the same.
2012-02-24 14:07:58 -05:00
Lirusaito
b555e02220 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-02-23 16:27:46 -05:00
Lirusaito
507c94c24c Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-02-22 17:20:21 -05:00
Lirusaito
2699fa8cf9 Merge branch 'master' of https://github.com/LightDrake/SingularityViewer 2012-02-22 11:23:59 -05:00
Lirusaito
513002416c Corrected text to say viewer's website, since we are not Imprudence. 2012-02-22 09:50:19 -05:00
Lirusaito
22530cd77e Prevent snapshot resolution from going over window size, when showing UI or HUD in snapshots is enabled.
Otherwise snapshots do not have UI/HUD shown, despite enabling RenderUIInSnapshot or RenderHUDInSnapshot.
2012-02-22 09:23:09 -05:00
Lirusaito
81521b98fd Added gesture_muted icon, reworked the panel_audio to look better, and have mute gesture look more like the rest of the panel. 2012-02-22 06:22:05 -05:00
Lirusaito
73c2feee97 Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer 2012-02-21 16:46:22 -05:00
Lirusaito
d4212d390d Merge branch 'master' of git://github.com/TighMacFanatic/SingularityViewer 2012-02-20 17:27:52 -05:00
Lirusaito
2b8a55f396 Add DisableCameraConstraints to the "Camera Options:" checkboxes on Input & Camera Preferences(panel_preferences_input.xml) 2012-02-20 17:13:35 -05:00
Lirusaito
f253da09ec Added gesture muting feature, like phoenix has. 2012-02-20 16:02:56 -05:00
Lirusaito
e232abdab2 Merge branch 'master' of git://github.com/siana/SingularityViewer
Conflicts:
	indra/newview/skins/dark/colors_base.xml
	indra/newview/skins/gemini/colors_base.xml
	indra/newview/skins/pslgreen/colors_base.xml
	indra/newview/skins/pslpurple/colors_base.xml
	indra/newview/skins/sapphire/colors_base.xml
2012-02-20 00:01:04 -05:00
Lirusaito
fae40e0bdf Fix to "Replace all NotifyCautionBoxColor's and AlertCautionBoxColor's that were using tan with black"(0fef1407e3), to only apply to skins where the tan background was too similar to the font color.
Also, for skins now using this black background, adjust foreground color to show up and match the skin, in cases where it was black.
2012-02-19 19:58:34 -05:00
650 changed files with 47837 additions and 18707 deletions

View File

@@ -77,7 +77,6 @@ if (VIEWER)
add_subdirectory(${LIBS_OPEN_PREFIX}llcrashlogger) add_subdirectory(${LIBS_OPEN_PREFIX}llcrashlogger)
add_subdirectory(${LIBS_OPEN_PREFIX}llplugin) add_subdirectory(${LIBS_OPEN_PREFIX}llplugin)
add_subdirectory(${LIBS_OPEN_PREFIX}llui) add_subdirectory(${LIBS_OPEN_PREFIX}llui)
add_subdirectory(${LIBS_OPEN_PREFIX}llxuixml)
# viewer plugins directory # viewer plugins directory
add_subdirectory(${LIBS_OPEN_PREFIX}plugins) add_subdirectory(${LIBS_OPEN_PREFIX}plugins)

View File

@@ -190,10 +190,10 @@ if (LINUX)
endif (NOT STANDALONE) endif (NOT STANDALONE)
if (${ARCH} STREQUAL "x86_64") if (${ARCH} STREQUAL "x86_64")
add_definitions(-DLINUX64=1 -pipe) add_definitions(-DLINUX64=1 -pipe)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -ffast-math -funroll-loops")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -ffast-math -funroll-loops")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-math")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ffast-math")
else (${ARCH} STREQUAL "x86_64") else (${ARCH} STREQUAL "x86_64")
if (NOT STANDALONE) if (NOT STANDALONE)
set(MARCH_FLAG " -march=pentium4") set(MARCH_FLAG " -march=pentium4")
@@ -269,6 +269,7 @@ if (DARWIN)
add_definitions(-DLL_DARWIN=1 -D_XOPEN_SOURCE) add_definitions(-DLL_DARWIN=1 -D_XOPEN_SOURCE)
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first") set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
if(${CMAKE_C_COMPILER} MATCHES "gcc*")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-branch") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-branch")
# NOTE: it's critical that the optimization flag is put in front. # NOTE: it's critical that the optimization flag is put in front.
@@ -277,6 +278,14 @@ if (DARWIN)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
elseif(${CMAKE_C_COMPILER} MATCHES "clang*")
# NOTE: it's critical that the optimization flag is put in front.
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse3")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3")
endif()
endif (DARWIN) endif (DARWIN)
@@ -318,7 +327,7 @@ else (STANDALONE)
glib-2.0 glib-2.0
gstreamer-0.10 gstreamer-0.10
gtk-2.0 gtk-2.0
llfreetype2 freetype2
pango-1.0 pango-1.0
) )
endif (STANDALONE) endif (STANDALONE)

View File

@@ -33,8 +33,8 @@ else (STANDALONE)
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.dylib optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.dylib
) )
set(APRUTIL_LIBRARIES set(APRUTIL_LIBRARIES
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.0.dylib debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.dylib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.0.dylib optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.dylib
) )
set(APRICONV_LIBRARIES iconv) set(APRICONV_LIBRARIES iconv)
else (WINDOWS) else (WINDOWS)

View File

@@ -40,10 +40,10 @@ else (STANDALONE)
debug libboost_regex-vc${MSVC_SUFFIX}-${BOOST_DEBUG_SUFFIX}-${BOOST_VERSION}) debug libboost_regex-vc${MSVC_SUFFIX}-${BOOST_DEBUG_SUFFIX}-${BOOST_VERSION})
elseif (DARWIN) elseif (DARWIN)
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt) set(BOOST_FILESYSTEM_LIBRARY boost_filesystem)
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt) set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options)
set(BOOST_REGEX_LIBRARY boost_regex-mt) set(BOOST_REGEX_LIBRARY boost_regex)
set(BOOST_SYSTEM_LIBRARY boost_system-mt) set(BOOST_SYSTEM_LIBRARY boost_system)
elseif (LINUX) elseif (LINUX)
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt) set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt)
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt) set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt)

View File

@@ -14,6 +14,9 @@ else (STANDALONE)
optimized libcurl) optimized libcurl)
else (WINDOWS) else (WINDOWS)
set(CURL_LIBRARIES curl) set(CURL_LIBRARIES curl)
if(LINUX AND WORD_SIZE EQUAL 64)
list(APPEND CURL_LIBRARIES idn)
endif(LINUX AND WORD_SIZE EQUAL 64)
endif (WINDOWS) endif (WINDOWS)
set(CURL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) set(CURL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
endif (STANDALONE) endif (STANDALONE)

View File

@@ -18,7 +18,7 @@ if (NOT FMODEX_LIBRARY)
set(FMODEX_SDK_DIR CACHE PATH "Path to the FMOD Ex SDK.") set(FMODEX_SDK_DIR CACHE PATH "Path to the FMOD Ex SDK.")
if (FMODEX_SDK_DIR) if (FMODEX_SDK_DIR)
find_library(FMODEX_LIBRARY find_library(FMODEX_LIBRARY
fmodex fmodex_vc fmodexL_vc fmodex_vc fmodexL_vc fmodex fmodexL fmodex64 fmodexL64
PATHS PATHS
${FMODEX_SDK_DIR}/api/lib ${FMODEX_SDK_DIR}/api/lib
${FMODEX_SDK_DIR}/api ${FMODEX_SDK_DIR}/api

View File

@@ -1,12 +1,16 @@
# -*- cmake -*- # -*- cmake -*-
include(Prebuilt) include(Prebuilt)
if(WORD_SIZE EQUAL 64)
set(DISABLE_TCMALLOC TRUE)
endif(WORD_SIZE EQUAL 64)
if (STANDALONE) if (STANDALONE)
include(FindGooglePerfTools) include(FindGooglePerfTools)
else (STANDALONE) else (STANDALONE)
if (LINUX OR WINDOWS) if (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
use_prebuilt_binary(gperftools) use_prebuilt_binary(gperftools)
endif (LINUX OR WINDOWS) endif (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
if (WINDOWS) if (WINDOWS)
set(TCMALLOC_LIBRARIES libtcmalloc_minimal.lib) set(TCMALLOC_LIBRARIES libtcmalloc_minimal.lib)
set(TCMALLOC_LINKER_FLAGS "/INCLUDE:\"__tcmalloc\"") set(TCMALLOC_LINKER_FLAGS "/INCLUDE:\"__tcmalloc\"")

View File

@@ -6,7 +6,7 @@ if (STANDALONE)
else (STANDALONE) else (STANDALONE)
use_prebuilt_binary(hunspell) use_prebuilt_binary(hunspell)
set(HUNSPELL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/hunspell) set(HUNSPELL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/hunspell)
if (LINUX OR DARWIN) if (LINUX OR DARWIN)
set(HUNSPELL_LIBRARY hunspell-1.3) set(HUNSPELL_LIBRARY hunspell-1.3)

View File

@@ -13,8 +13,8 @@ else (STANDALONE)
set(JPEG_LIBRARIES jpeg) set(JPEG_LIBRARIES jpeg)
elseif (DARWIN) elseif (DARWIN)
set(JPEG_LIBRARIES set(JPEG_LIBRARIES
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/liblljpeg.a optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a
debug ${ARCH_PREBUILT_DIRS_DEBUG}/liblljpeg.a debug ${ARCH_PREBUILT_DIRS_DEBUG}/libjpeg.a
) )
elseif (WINDOWS) elseif (WINDOWS)
set(JPEG_LIBRARIES jpeglib) set(JPEG_LIBRARIES jpeglib)

View File

@@ -14,7 +14,7 @@ else (STANDALONE)
debug json_vc${MSVC_SUFFIX}d debug json_vc${MSVC_SUFFIX}d
optimized json_vc${MSVC_SUFFIX}) optimized json_vc${MSVC_SUFFIX})
elseif (DARWIN) elseif (DARWIN)
set(JSONCPP_LIBRARIES json_mac-universal-gcc_libmt) set(JSONCPP_LIBRARIES json_linux-gcc-4.0.1_libmt)
elseif (LINUX) elseif (LINUX)
set(JSONCPP_LIBRARIES jsoncpp) set(JSONCPP_LIBRARIES jsoncpp)
endif (WINDOWS) endif (WINDOWS)

View File

@@ -18,7 +18,11 @@ else (STANDALONE)
use_prebuilt_binary(SDL) use_prebuilt_binary(SDL)
set (SDL_FOUND TRUE) set (SDL_FOUND TRUE)
set (SDL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}) set (SDL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR})
if(WORD_SIZE EQUAL 64)
set (SDL_LIBRARY SDL)
else(WORD_SIZE EQUAL 64)
set (SDL_LIBRARY SDL directfb fusion direct) set (SDL_LIBRARY SDL directfb fusion direct)
endif(WORD_SIZE EQUAL 64)
endif (LINUX) endif (LINUX)
endif (STANDALONE) endif (STANDALONE)

View File

@@ -1,7 +0,0 @@
# -*- cmake -*-
set(LLXUIXML_INCLUDE_DIRS
${LIBS_OPEN_DIR}/llxuixml
)
set(LLXUIXML_LIBRARIES llxuixml)

View File

@@ -10,9 +10,9 @@ if (NOT STANDALONE)
set(ARCH_PREBUILT_DIRS_RELEASE ${ARCH_PREBUILT_DIRS}) set(ARCH_PREBUILT_DIRS_RELEASE ${ARCH_PREBUILT_DIRS})
set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS}) set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS})
elseif (DARWIN) elseif (DARWIN)
set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release) set(ARCH_PREBUILT_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib)
set(ARCH_PREBUILT_DIRS ${ARCH_PREBUILT_DIRS_RELEASE}) set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/release)
set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS_RELEASE}) set(ARCH_PREBUILT_DIRS_DEBUG ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/debug)
endif (WINDOWS) endif (WINDOWS)
endif (NOT STANDALONE) endif (NOT STANDALONE)

View File

@@ -16,8 +16,6 @@ else (STANDALONE)
set(OPENSSL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) set(OPENSSL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
endif (STANDALONE) endif (STANDALONE)
if (LINUX) if (LINUX OR DARWIN)
set(CRYPTO_LIBRARIES crypto) set(CRYPTO_LIBRARIES crypto)
elseif (DARWIN) endif (LINUX OR DARWIN)
set(CRYPTO_LIBRARIES llcrypto)
endif (LINUX)

View File

@@ -15,5 +15,5 @@ else (STANDALONE)
else(LINUX) else(LINUX)
set(PNG_LIBRARIES png15) set(PNG_LIBRARIES png15)
endif() endif()
set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/libpng15) set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/)
endif (STANDALONE) endif (STANDALONE)

View File

@@ -76,37 +76,36 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(DARWIN 1) set(DARWIN 1)
if(${CMAKE_GENERATOR} MATCHES Xcode)
#SDK Compiler and Deployment targets for XCode #SDK Compiler and Deployment targets for XCode
if (${XCODE_VERSION} VERSION_LESS 4.0.0) if (${XCODE_VERSION} VERSION_LESS 4.0.0)
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk) set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
set(CMAKE_XCODE_ATTIBUTE_GCC_VERSION "4.2") set(CMAKE_XCODE_ATTIBUTE_GCC_VERSION "4.2")
else (${XCODE_VERSION} VERSION_LESS 4.0.0) else (${XCODE_VERSION} VERSION_LESS 4.0.0)
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk) set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42") set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
endif (${XCODE_VERSION} VERSION_LESS 4.0.0) endif (${XCODE_VERSION} VERSION_LESS 4.0.0)
else()
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
endif(${CMAKE_GENERATOR} MATCHES Xcode)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5) ## We currently support only 32-bit i386 builds, so use these:
# NOTE: To attempt an i386/PPC Universal build, add this on the configure line:
# -DCMAKE_OSX_ARCHITECTURES:STRING='i386;ppc'
# Build only for i386 by default, system default on MacOSX 10.6 is x86_64
if (NOT CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES i386) set(CMAKE_OSX_ARCHITECTURES i386)
endif (NOT CMAKE_OSX_ARCHITECTURES)
if (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
set(ARCH universal)
else (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
set(ARCH ppc)
else (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
set(ARCH i386) set(ARCH i386)
endif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc") set(WORD_SIZE 32)
endif (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
## But if you want to compile for mixed 32/64 bit, try these:
# set(CMAKE_OSX_ARCHITECTURES i386;x86_64)
# set(ARCH universal)
# set(WORD_SIZE 64)
## Finally, set up the build output directories
set(LL_ARCH ${ARCH}_darwin) set(LL_ARCH ${ARCH}_darwin)
set(LL_ARCH_DIR universal-darwin) set(LL_ARCH_DIR universal-darwin)
set(WORD_SIZE 32)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

View File

@@ -43,11 +43,11 @@
#include "lluuid.h" #include "lluuid.h"
#include "llframetimer.h" #include "llframetimer.h"
#include "llassettype.h" #include "llassettype.h"
#include "llextendedstatus.h"
#include "lllistener.h" #include "lllistener.h"
const F32 LL_WIND_UPDATE_INTERVAL = 0.1f; const F32 LL_WIND_UPDATE_INTERVAL = 0.1f;
const F32 LL_ROLLOFF_MULTIPLIER_UNDER_WATER = 5.f; // How much sounds are weaker under water
const F32 LL_WIND_UNDERWATER_CENTER_FREQ = 20.f; const F32 LL_WIND_UNDERWATER_CENTER_FREQ = 20.f;
const F32 ATTACHED_OBJECT_TIMEOUT = 5.0f; const F32 ATTACHED_OBJECT_TIMEOUT = 5.0f;

View File

@@ -72,6 +72,8 @@ bool attemptDelayLoad()
FMOD_RESULT F_CALLBACK windCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels); FMOD_RESULT F_CALLBACK windCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels);
FMOD::ChannelGroup *LLAudioEngine_FMODEX::mChannelGroups[LLAudioEngine::AUDIO_TYPE_COUNT] = {0};
LLAudioEngine_FMODEX::LLAudioEngine_FMODEX(bool enable_profiler) LLAudioEngine_FMODEX::LLAudioEngine_FMODEX(bool enable_profiler)
{ {
mInited = false; mInited = false;
@@ -95,6 +97,28 @@ inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string)
return true; return true;
} }
void* F_STDCALL decode_alloc(unsigned int size, FMOD_MEMORY_TYPE type, const char *sourcestr)
{
if(type & FMOD_MEMORY_STREAM_DECODE)
{
llinfos << "Decode buffer size: " << size << llendl;
}
else if(type & FMOD_MEMORY_STREAM_FILE)
{
llinfos << "Strean buffer size: " << size << llendl;
}
return new char[size];
}
void* F_STDCALL decode_realloc(void *ptr, unsigned int size, FMOD_MEMORY_TYPE type, const char *sourcestr)
{
memset(ptr,0,size);
return ptr;
}
void F_STDCALL decode_dealloc(void *ptr, FMOD_MEMORY_TYPE type, const char *sourcestr)
{
delete[] (char*)ptr;
}
bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata) bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
{ {
@@ -108,6 +132,10 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
LL_DEBUGS("AppInit") << "LLAudioEngine_FMODEX::init() initializing FMOD" << LL_ENDL; LL_DEBUGS("AppInit") << "LLAudioEngine_FMODEX::init() initializing FMOD" << LL_ENDL;
result = FMOD::Memory_Initialize(NULL, 0, &decode_alloc, &decode_realloc, &decode_dealloc, FMOD_MEMORY_STREAM_DECODE | FMOD_MEMORY_STREAM_FILE);
if(Check_FMOD_Error(result, "FMOD::Memory_Initialize"))
return false;
result = FMOD::System_Create(&mSystem); result = FMOD::System_Create(&mSystem);
if(Check_FMOD_Error(result, "FMOD::System_Create")) if(Check_FMOD_Error(result, "FMOD::System_Create"))
return false; return false;
@@ -124,54 +152,8 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
<< ")! You should be using FMOD Ex" << FMOD_VERSION << LL_ENDL; << ")! You should be using FMOD Ex" << FMOD_VERSION << LL_ENDL;
} }
#if LL_WINDOWS result = mSystem->setSoftwareFormat(44100, FMOD_SOUND_FORMAT_PCM16, 0, 0, FMOD_DSP_RESAMPLER_LINEAR);
int numdrivers;
FMOD_SPEAKERMODE speakermode;
FMOD_CAPS caps;
char name[256];
//Is this block applicable to linux?
{
result = mSystem->getNumDrivers(&numdrivers);
Check_FMOD_Error(result, "FMOD::System::getNumDrivers");
if (numdrivers == 0)
{
result = mSystem->setOutput(FMOD_OUTPUTTYPE_NOSOUND);
Check_FMOD_Error(result, "FMOD::System::setOutput");
}
else
{
result = mSystem->getDriverCaps(0, &caps, 0, &speakermode);
Check_FMOD_Error(result,"FMOD::System::getDriverCaps");
/*
Set the user selected speaker mode.
*/
result = mSystem->setSpeakerMode(speakermode);
Check_FMOD_Error(result, "FMOD::System::setSpeakerMode");
if (caps & FMOD_CAPS_HARDWARE_EMULATED)
{
/*
The user has the 'Acceleration' slider set to off! This is really bad
for latency! You might want to warn the user about this.
*/
result = mSystem->setDSPBufferSize(1024, 10);
Check_FMOD_Error(result, "FMOD::System::setDSPBufferSize");
}
result = mSystem->getDriverInfo(0, name, 256, 0);
Check_FMOD_Error(result, "FMOD::System::getDriverInfo");
if (strstr(name, "SigmaTel"))
{
/*
Sigmatel sound devices crackle for some reason if the format is PCM 16bit.
PCM floating point output seems to solve it.
*/
result = mSystem->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0,0, FMOD_DSP_RESAMPLER_LINEAR);
Check_FMOD_Error(result,"FMOD::System::setSoftwareFormat"); Check_FMOD_Error(result,"FMOD::System::setSoftwareFormat");
}
}
}
#endif //LL_WINDOWS
// In this case, all sounds, PLUS wind and stream will be software. // In this case, all sounds, PLUS wind and stream will be software.
result = mSystem->setSoftwareChannels(num_channels + 2); result = mSystem->setSoftwareChannels(num_channels + 2);
@@ -179,7 +161,13 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
U32 fmod_flags = FMOD_INIT_NORMAL; U32 fmod_flags = FMOD_INIT_NORMAL;
if(mEnableProfiler) if(mEnableProfiler)
{
fmod_flags |= FMOD_INIT_ENABLE_PROFILE; fmod_flags |= FMOD_INIT_ENABLE_PROFILE;
mSystem->createChannelGroup("None", &mChannelGroups[AUDIO_TYPE_NONE]);
mSystem->createChannelGroup("SFX", &mChannelGroups[AUDIO_TYPE_SFX]);
mSystem->createChannelGroup("UI", &mChannelGroups[AUDIO_TYPE_UI]);
mSystem->createChannelGroup("Ambient", &mChannelGroups[AUDIO_TYPE_AMBIENT]);
}
#if LL_LINUX #if LL_LINUX
bool audio_ok = false; bool audio_ok = false;
@@ -297,6 +285,19 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
LL_INFOS("AppInit") << "LLAudioEngine_FMODEX::init() FMOD Ex initialized correctly" << LL_ENDL; LL_INFOS("AppInit") << "LLAudioEngine_FMODEX::init() FMOD Ex initialized correctly" << LL_ENDL;
int r_numbuffers, r_samplerate, r_channels, r_bits;
unsigned int r_bufferlength;
char r_name[256];
mSystem->getDSPBufferSize(&r_bufferlength, &r_numbuffers);
mSystem->getSoftwareFormat(&r_samplerate, NULL, &r_channels, NULL, NULL, &r_bits);
mSystem->getDriverInfo(0, r_name, 255, 0);
r_name[255] = '\0';
int latency = 1000.0 * r_bufferlength * r_numbuffers /r_samplerate;
LL_INFOS("AppInit") << "FMOD device: "<< r_name << "\n"
<< "FMOD Ex parameters: " << r_samplerate << " Hz * " << r_channels << " * " <<r_bits <<" bit\n"
<< "\tbuffer " << r_bufferlength << " * " << r_numbuffers << " (" << latency <<"ms)" << LL_ENDL;
mInited = true; mInited = true;
return true; return true;
@@ -611,6 +612,9 @@ void LLAudioChannelFMODEX::play()
Check_FMOD_Error(mChannelp->setPaused(false), "FMOD::Channel::pause"); Check_FMOD_Error(mChannelp->setPaused(false), "FMOD::Channel::pause");
getSource()->setPlayedOnce(true); getSource()->setPlayedOnce(true);
if(LLAudioEngine_FMODEX::mChannelGroups[getSource()->getType()])
mChannelp->setChannelGroup(LLAudioEngine_FMODEX::mChannelGroups[getSource()->getType()]);
} }

View File

@@ -44,6 +44,7 @@ namespace FMOD
{ {
class System; class System;
class Channel; class Channel;
class ChannelGroup;
class Sound; class Sound;
class DSP; class DSP;
} }
@@ -83,6 +84,9 @@ protected:
FMOD::DSP *mWindDSP; FMOD::DSP *mWindDSP;
FMOD::System *mSystem; FMOD::System *mSystem;
bool mEnableProfiler; bool mEnableProfiler;
public:
static FMOD::ChannelGroup *mChannelGroups[LLAudioEngine::AUDIO_TYPE_COUNT];
}; };

View File

@@ -106,6 +106,15 @@ void LLListener_FMODEX::commitDeferredChanges()
void LLListener_FMODEX::setRolloffFactor(F32 factor) void LLListener_FMODEX::setRolloffFactor(F32 factor)
{ {
//An internal FMODEx optimization skips 3D updates if there have not been changes to the 3D sound environment.
//Sadly, a change in rolloff is not accounted for, thus we must touch the listener properties as well.
//In short: Changing the position ticks a dirtyflag inside fmodex, which makes it not skip 3D processing next update call.
if(mRolloffFactor != factor)
{
LLVector3 pos = mVelocity - LLVector3(0.f,0.f,.1f);
mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)pos.mV, NULL, NULL, NULL);
mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mVelocity.mV, NULL, NULL, NULL);
}
mRolloffFactor = factor; mRolloffFactor = factor;
mSystem->set3DSettings(mDopplerFactor, 1.f, mRolloffFactor); mSystem->set3DSettings(mDopplerFactor, 1.f, mRolloffFactor);
} }

View File

@@ -58,6 +58,9 @@ class LLStreamingAudioInterface
virtual const LLSD *getMetaData() = 0; virtual const LLSD *getMetaData() = 0;
virtual bool supportsWaveData() = 0; virtual bool supportsWaveData() = 0;
virtual bool getWaveData(float* arr, S32 count, S32 stride = 1) = 0; virtual bool getWaveData(float* arr, S32 count, S32 stride = 1) = 0;
virtual bool supportsAdjustableBufferSizes(){return false;}
virtual void setBufferSizes(U32 streambuffertime, U32 decodebuffertime){};
}; };
#endif // LL_STREAMINGAUDIO_H #endif // LL_STREAMINGAUDIO_H

View File

@@ -50,7 +50,7 @@ public:
const std::string& getURL() { return mInternetStreamURL; } const std::string& getURL() { return mInternetStreamURL; }
FMOD_OPENSTATE getOpenState(); FMOD_OPENSTATE getOpenState(unsigned int* percentbuffered=NULL, bool* starving=NULL, bool* diskbusy=NULL);
protected: protected:
FMOD::System* mSystem; FMOD::System* mSystem;
FMOD::Channel* mStreamChannel; FMOD::Channel* mStreamChannel;
@@ -74,7 +74,7 @@ LLStreamingAudio_FMODEX::LLStreamingAudio_FMODEX(FMOD::System *system) :
{ {
// Number of milliseconds of audio to buffer for the audio card. // Number of milliseconds of audio to buffer for the audio card.
// Must be larger than the usual Second Life frame stutter time. // Must be larger than the usual Second Life frame stutter time.
const U32 buffer_seconds = 5; //sec const U32 buffer_seconds = 10; //sec
const U32 estimated_bitrate = 128; //kbit/sec const U32 estimated_bitrate = 128; //kbit/sec
mSystem->setStreamBufferSize(estimated_bitrate * buffer_seconds * 128/*bytes/kbit*/, FMOD_TIMEUNIT_RAWBYTES); mSystem->setStreamBufferSize(estimated_bitrate * buffer_seconds * 128/*bytes/kbit*/, FMOD_TIMEUNIT_RAWBYTES);
@@ -145,7 +145,10 @@ void LLStreamingAudio_FMODEX::update()
return; return;
} }
FMOD_OPENSTATE open_state = mCurrentInternetStreamp->getOpenState(); unsigned int progress;
bool starving;
bool diskbusy;
FMOD_OPENSTATE open_state = mCurrentInternetStreamp->getOpenState(&progress, &starving, &diskbusy);
if (open_state == FMOD_OPENSTATE_READY) if (open_state == FMOD_OPENSTATE_READY)
{ {
@@ -158,6 +161,7 @@ void LLStreamingAudio_FMODEX::update()
// Reset volume to previously set volume // Reset volume to previously set volume
setGain(getGain()); setGain(getGain());
mFMODInternetStreamChannelp->setPaused(false); mFMODInternetStreamChannelp->setPaused(false);
mLastStarved.stop();
} }
} }
else if(open_state == FMOD_OPENSTATE_ERROR) else if(open_state == FMOD_OPENSTATE_ERROR)
@@ -237,12 +241,29 @@ void LLStreamingAudio_FMODEX::update()
} }
} }
} }
if(starving)
{
if(!mLastStarved.getStarted())
{
llinfos << "Stream starvation detected! Muting stream audio until it clears." << llendl;
llinfos << " (diskbusy="<<diskbusy<<")" << llendl;
llinfos << " (progress="<<progress<<")" << llendl;
mFMODInternetStreamChannelp->setMute(true);
}
mLastStarved.start();
}
else if(mLastStarved.getStarted() && mLastStarved.getElapsedTimeF32() > 1.f)
{
mLastStarved.stop();
mFMODInternetStreamChannelp->setMute(false);
}
} }
} }
} }
void LLStreamingAudio_FMODEX::stop() void LLStreamingAudio_FMODEX::stop()
{ {
mLastStarved.stop();
if(mMetaData) if(mMetaData)
{ {
delete mMetaData; delete mMetaData;
@@ -341,6 +362,11 @@ void LLStreamingAudio_FMODEX::setGain(F32 vol)
if(!mFMODInternetStreamChannelp || !mCurrentInternetStreamp) if(!mFMODInternetStreamChannelp || !mCurrentInternetStreamp)
return false; return false;
bool muted=false;
mFMODInternetStreamChannelp->getMute(&muted);
if(muted)
return false;
static std::vector<float> local_array(count); //Have to have an extra buffer to mix channels. Bleh. static std::vector<float> local_array(count); //Have to have an extra buffer to mix channels. Bleh.
if(count > (S32)local_array.size()) //Expand the array if needed. Try to minimize allocation calls, so don't ever shrink. if(count > (S32)local_array.size()) //Expand the array if needed. Try to minimize allocation calls, so don't ever shrink.
local_array.resize(count); local_array.resize(count);
@@ -442,9 +468,19 @@ bool LLAudioStreamManagerFMODEX::stopStream()
} }
} }
FMOD_OPENSTATE LLAudioStreamManagerFMODEX::getOpenState() FMOD_OPENSTATE LLAudioStreamManagerFMODEX::getOpenState(unsigned int* percentbuffered, bool* starving, bool* diskbusy)
{ {
FMOD_OPENSTATE state; FMOD_OPENSTATE state;
mInternetStream->getOpenState(&state,NULL,NULL,NULL); mInternetStream->getOpenState(&state,percentbuffered,starving,diskbusy);
return state; return state;
} }
void LLStreamingAudio_FMODEX::setBufferSizes(U32 streambuffertime, U32 decodebuffertime)
{
mSystem->setStreamBufferSize(streambuffertime/1000*128*128, FMOD_TIMEUNIT_RAWBYTES);
FMOD_ADVANCEDSETTINGS settings;
memset(&settings,0,sizeof(settings));
settings.cbsize=sizeof(settings);
settings.defaultDecodeBufferSize = decodebuffertime;//ms
mSystem->setAdvancedSettings(&settings);
}

View File

@@ -37,6 +37,7 @@
#include "stdtypes.h" // from llcommon #include "stdtypes.h" // from llcommon
#include "llstreamingaudio.h" #include "llstreamingaudio.h"
#include "lltimer.h"
//Stubs //Stubs
class LLAudioStreamManagerFMODEX; class LLAudioStreamManagerFMODEX;
@@ -66,6 +67,8 @@ class LLStreamingAudio_FMODEX : public LLStreamingAudioInterface
/*virtual*/ const LLSD *getMetaData(){return mMetaData;} //return NULL if not playing. /*virtual*/ const LLSD *getMetaData(){return mMetaData;} //return NULL if not playing.
/*virtual*/ bool supportsWaveData(){return true;} /*virtual*/ bool supportsWaveData(){return true;}
/*virtual*/ bool getWaveData(float* arr, S32 count, S32 stride = 1); /*virtual*/ bool getWaveData(float* arr, S32 count, S32 stride = 1);
/*virtual*/ bool supportsAdjustableBufferSizes(){return true;}
/*virtual*/ void setBufferSizes(U32 streambuffertime, U32 decodebuffertime);
private: private:
FMOD::System *mSystem; FMOD::System *mSystem;
@@ -76,6 +79,8 @@ private:
std::string mURL; std::string mURL;
F32 mGain; F32 mGain;
LLTimer mLastStarved;
LLSD *mMetaData; LLSD *mMetaData;
}; };

View File

@@ -38,7 +38,6 @@
#include "llcharacter.h" #include "llcharacter.h"
#include "llstring.h" #include "llstring.h"
#include "llfasttimer.h"
#define SKEL_HEADER "Linden Skeleton 1.0" #define SKEL_HEADER "Linden Skeleton 1.0"

View File

@@ -250,9 +250,9 @@ BOOL LLHeadRotMotion::onUpdate(F32 time, U8* joint_mask)
head_rot_local = nlerp(head_slerp_amt, mLastHeadRot, head_rot_local); head_rot_local = nlerp(head_slerp_amt, mLastHeadRot, head_rot_local);
mLastHeadRot = head_rot_local; mLastHeadRot = head_rot_local;
if(mNeckState->getJoint() && mNeckState->getJoint()->getParent()) //Guess this has crashed? Taken from snowglobe -Shyotl
{
// Set the head rotation. // Set the head rotation.
if(mNeckState->getJoint() && mNeckState->getJoint()->getParent())
{
LLQuaternion torsoRotLocal = mNeckState->getJoint()->getParent()->getWorldRotation() * currentInvRootRotWorld; LLQuaternion torsoRotLocal = mNeckState->getJoint()->getParent()->getWorldRotation() * currentInvRootRotWorld;
head_rot_local = head_rot_local * ~torsoRotLocal; head_rot_local = head_rot_local * ~torsoRotLocal;
mNeckState->setRotation( nlerp(NECK_LAG, LLQuaternion::DEFAULT, head_rot_local) ); mNeckState->setRotation( nlerp(NECK_LAG, LLQuaternion::DEFAULT, head_rot_local) );

View File

@@ -93,6 +93,7 @@ class LLVisualParam
{ {
public: public:
typedef boost::function<LLVisualParam*(S32)> visual_param_mapper; typedef boost::function<LLVisualParam*(S32)> visual_param_mapper;
LLVisualParam(); LLVisualParam();
virtual ~LLVisualParam(); virtual ~LLVisualParam();

View File

@@ -53,6 +53,7 @@ set(llcommon_SOURCE_FILES
llformat.cpp llformat.cpp
llframetimer.cpp llframetimer.cpp
llheartbeat.cpp llheartbeat.cpp
llinitparam.cpp
llinstancetracker.cpp llinstancetracker.cpp
llindraconfigfile.cpp llindraconfigfile.cpp
llliveappconfig.cpp llliveappconfig.cpp
@@ -171,6 +172,7 @@ set(llcommon_HEADER_FILES
llheartbeat.h llheartbeat.h
llhttpstatuscodes.h llhttpstatuscodes.h
llindexedqueue.h llindexedqueue.h
llinitparam.h
llinstancetracker.h llinstancetracker.h
llindraconfigfile.h llindraconfigfile.h
llkeythrottle.h llkeythrottle.h
@@ -212,6 +214,7 @@ set(llcommon_HEADER_FILES
llsingleton.h llsingleton.h
llskiplist.h llskiplist.h
llskipmap.h llskipmap.h
llsortedvector.h
llstack.h llstack.h
llstacktrace.h llstacktrace.h
llstat.h llstat.h
@@ -226,6 +229,7 @@ set(llcommon_HEADER_FILES
llthreadsafequeue.h llthreadsafequeue.h
lltimer.h lltimer.h
lltreeiterators.h lltreeiterators.h
lltypeinfolookup.h
lluri.h lluri.h
lluuid.h lluuid.h
lluuidhashmap.h lluuidhashmap.h

View File

@@ -33,6 +33,11 @@
#ifndef LL_LINDEN_COMMON_H #ifndef LL_LINDEN_COMMON_H
#define LL_LINDEN_COMMON_H #define LL_LINDEN_COMMON_H
// *NOTE: Please keep includes here to a minimum!
//
// Files included here are included in every library .cpp file and
// are not precompiled.
#include "cwdebug.h" #include "cwdebug.h"
#if defined(LL_WINDOWS) && defined(_DEBUG) #if defined(LL_WINDOWS) && defined(_DEBUG)
@@ -55,34 +60,11 @@
#include <ctime> #include <ctime>
#include <iosfwd> #include <iosfwd>
// Work around Microsoft compiler warnings in STL headers
#ifdef LL_WINDOWS
#pragma warning (disable : 4702) // unreachable code
#pragma warning (disable : 4244) // conversion from time_t to S32
#endif // LL_WINDOWS
// *TODO: Eliminate these, most library .cpp files don't need them.
// Add them to llviewerprecompiledheaders.h if necessary.
#include <list>
#include <map>
#include <vector>
#include <string>
#ifdef LL_WINDOWS
// Reenable warnings we disabled above
#pragma warning (3 : 4702) // unreachable code, we like level 3, not 4
// moved msvc warnings to llpreprocessor.h *TODO - delete this comment after merge conflicts are unlikely -brad
#endif // LL_WINDOWS
// Linden only libs in alpha-order other than stdtypes.h // Linden only libs in alpha-order other than stdtypes.h
// *NOTE: Please keep includes here to a minimum, see above. // *NOTE: Please keep includes here to a minimum, see above.
#include "stdtypes.h" #include "stdtypes.h"
#include "lldefs.h" #include "lldefs.h"
#include "llerror.h" #include "llerror.h"
#include "llextendedstatus.h"
// Don't do this, adds 15K lines of header code to every library file.
//#include "llfasttimer.h"
#include "llfile.h" #include "llfile.h"
#include "llformat.h"
#endif #endif

View File

@@ -43,10 +43,14 @@ template <typename Type> class LLAtomic32;
typedef LLAtomic32<U32> LLAtomicU32; typedef LLAtomic32<U32> LLAtomicU32;
class LLErrorThread; class LLErrorThread;
class LLLiveFile; class LLLiveFile;
#if LL_LINUX #if LL_LINUX
typedef struct siginfo siginfo_t; #include <signal.h>
//typedef struct siginfo siginfo_t; //Removed as per changes in glibc 2.16 - Drake Arconis
#endif #endif
typedef void (*LLAppErrorHandler)(); typedef void (*LLAppErrorHandler)();
typedef void (*LLAppChildCallback)(int pid, bool exited, int status); typedef void (*LLAppChildCallback)(int pid, bool exited, int status);

View File

@@ -35,6 +35,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include "llerror.h" #include "llerror.h"
#include "lltypeinfolookup.h"
namespace LLInitParam namespace LLInitParam
{ {
@@ -205,7 +206,7 @@ namespace LLInitParam
mutable std::string mValueName; mutable std::string mValueName;
}; };
class Parser class LL_COMMON_API Parser
{ {
LOG_CLASS(Parser); LOG_CLASS(Parser);
@@ -227,9 +228,9 @@ namespace LLInitParam
typedef bool (*parser_write_func_t)(Parser& parser, const void*, name_stack_t&); typedef bool (*parser_write_func_t)(Parser& parser, const void*, name_stack_t&);
typedef boost::function<void (name_stack_t&, S32, S32, const possible_values_t*)> parser_inspect_func_t; typedef boost::function<void (name_stack_t&, S32, S32, const possible_values_t*)> parser_inspect_func_t;
typedef std::map<const std::type_info*, parser_read_func_t, CompareTypeID> parser_read_func_map_t; typedef LLTypeInfoLookup<parser_read_func_t> parser_read_func_map_t;
typedef std::map<const std::type_info*, parser_write_func_t, CompareTypeID> parser_write_func_map_t; typedef LLTypeInfoLookup<parser_write_func_t> parser_write_func_map_t;
typedef std::map<const std::type_info*, parser_inspect_func_t, CompareTypeID> parser_inspect_func_map_t; typedef LLTypeInfoLookup<parser_inspect_func_t> parser_inspect_func_map_t;
Parser(parser_read_func_map_t& read_map, parser_write_func_map_t& write_map, parser_inspect_func_map_t& inspect_map) Parser(parser_read_func_map_t& read_map, parser_write_func_map_t& write_map, parser_inspect_func_map_t& inspect_map)
: mParseSilently(false), : mParseSilently(false),
@@ -301,7 +302,7 @@ namespace LLInitParam
class Param; class Param;
// various callbacks and constraints associated with an individual param // various callbacks and constraints associated with an individual param
struct ParamDescriptor struct LL_COMMON_API ParamDescriptor
{ {
struct UserData struct UserData
{ {
@@ -341,7 +342,7 @@ namespace LLInitParam
typedef boost::shared_ptr<ParamDescriptor> ParamDescriptorPtr; typedef boost::shared_ptr<ParamDescriptor> ParamDescriptorPtr;
// each derived Block class keeps a static data structure maintaining offsets to various params // each derived Block class keeps a static data structure maintaining offsets to various params
class BlockDescriptor class LL_COMMON_API BlockDescriptor
{ {
public: public:
BlockDescriptor(); BlockDescriptor();
@@ -369,7 +370,7 @@ namespace LLInitParam
class BaseBlock* mCurrentBlockPtr; // pointer to block currently being constructed class BaseBlock* mCurrentBlockPtr; // pointer to block currently being constructed
}; };
class BaseBlock class LL_COMMON_API BaseBlock
{ {
public: public:
//TODO: implement in terms of owned_ptr //TODO: implement in terms of owned_ptr
@@ -566,7 +567,7 @@ namespace LLInitParam
static bool equals(const BaseBlock::Lazy<T>& a, const BaseBlock::Lazy<T>& b) { return !a.empty() || !b.empty(); } static bool equals(const BaseBlock::Lazy<T>& a, const BaseBlock::Lazy<T>& b) { return !a.empty() || !b.empty(); }
}; };
class Param class LL_COMMON_API Param
{ {
public: public:
void setProvided(bool is_provided = true) void setProvided(bool is_provided = true)
@@ -1253,15 +1254,16 @@ namespace LLInitParam
return mValues.back(); return mValues.back();
} }
void add(const value_t& item) self_t& add(const value_t& item)
{ {
param_value_t param_value; param_value_t param_value;
param_value.setValue(item); param_value.setValue(item);
mValues.push_back(param_value); mValues.push_back(param_value);
setProvided(); setProvided();
return *this;
} }
void add(const typename name_value_lookup_t::name_t& name) self_t& add(const typename name_value_lookup_t::name_t& name)
{ {
value_t value; value_t value;
@@ -1271,6 +1273,8 @@ namespace LLInitParam
add(value); add(value);
mValues.back().setValueName(name); mValues.back().setValueName(name);
} }
return *this;
} }
// implicit conversion // implicit conversion
@@ -1441,13 +1445,14 @@ namespace LLInitParam
return mValues.back(); return mValues.back();
} }
void add(const value_t& item) self_t& add(const value_t& item)
{ {
mValues.push_back(item); mValues.push_back(item);
setProvided(); setProvided();
return *this;
} }
void add(const typename name_value_lookup_t::name_t& name) self_t& add(const typename name_value_lookup_t::name_t& name)
{ {
value_t value; value_t value;
@@ -1457,6 +1462,7 @@ namespace LLInitParam
add(value); add(value);
mValues.back().setValueName(name); mValues.back().setValueName(name);
} }
return *this;
} }
// implicit conversion // implicit conversion
@@ -2057,8 +2063,8 @@ namespace LLInitParam
// block param interface // block param interface
bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); LL_COMMON_API bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name);
void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const; LL_COMMON_API void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const;
bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const
{ {
//TODO: implement LLSD params as schema type Any //TODO: implement LLSD params as schema type Any

View File

@@ -0,0 +1,152 @@
/**
* @file llsortedvector.h
* @author Nat Goodspeed
* @date 2012-04-08
* @brief LLSortedVector class wraps a vector that we maintain in sorted
* order so we can perform binary-search lookups.
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Copyright (c) 2012, Linden Research, Inc.
* $/LicenseInfo$
*/
#if ! defined(LL_LLSORTEDVECTOR_H)
#define LL_LLSORTEDVECTOR_H
#include <vector>
#include <algorithm>
/**
* LLSortedVector contains a std::vector<std::pair> that we keep sorted on the
* first of the pair. This makes insertion somewhat more expensive than simple
* std::vector::push_back(), but allows us to use binary search for lookups.
* It's intended for small aggregates where lookup is far more performance-
* critical than insertion; in such cases a binary search on a small, sorted
* std::vector can be more performant than a std::map lookup.
*/
template <typename KEY, typename VALUE>
class LLSortedVector
{
public:
typedef LLSortedVector<KEY, VALUE> self;
typedef KEY key_type;
typedef VALUE mapped_type;
typedef std::pair<key_type, mapped_type> value_type;
typedef std::vector<value_type> PairVector;
typedef typename PairVector::iterator iterator;
typedef typename PairVector::const_iterator const_iterator;
/// Empty
LLSortedVector() {}
/// Fixed initial size
LLSortedVector(std::size_t size):
mVector(size)
{}
/// Bulk load
template <typename ITER>
LLSortedVector(ITER begin, ITER end):
mVector(begin, end)
{
// Allow caller to dump in a bunch of (pairs convertible to)
// value_type if desired, but make sure we sort afterwards.
std::sort(mVector.begin(), mVector.end());
}
/// insert(key, value)
std::pair<iterator, bool> insert(const key_type& key, const mapped_type& value)
{
return insert(value_type(key, value));
}
/// insert(value_type)
std::pair<iterator, bool> insert(const value_type& pair)
{
typedef std::pair<iterator, bool> iterbool;
iterator found = std::lower_bound(mVector.begin(), mVector.end(), pair,
less<value_type>());
// have to check for end() before it's even valid to dereference
if (found == mVector.end())
{
std::size_t index(mVector.size());
mVector.push_back(pair);
// don't forget that push_back() invalidates 'found'
return iterbool(mVector.begin() + index, true);
}
if (found->first == pair.first)
{
return iterbool(found, false);
}
// remember that insert() invalidates 'found' -- save index
std::size_t index(found - mVector.begin());
mVector.insert(found, pair);
// okay, convert from index back to iterator
return iterbool(mVector.begin() + index, true);
}
iterator begin() { return mVector.begin(); }
iterator end() { return mVector.end(); }
const_iterator begin() const { return mVector.begin(); }
const_iterator end() const { return mVector.end(); }
bool empty() const { return mVector.empty(); }
std::size_t size() const { return mVector.size(); }
/// find
iterator find(const key_type& key)
{
iterator found = std::lower_bound(mVector.begin(), mVector.end(),
value_type(key, mapped_type()),
less<value_type>());
if (found == mVector.end() || found->first != key)
return mVector.end();
return found;
}
const_iterator find(const key_type& key) const
{
return const_cast<self*>(this)->find(key);
}
private:
// Define our own 'less' comparator so we can specialize without messing
// with std::less.
template <typename T>
struct less: public std::less<T> {};
// Specialize 'less' for an LLSortedVector::value_type involving
// std::type_info*. This is one of LLSortedVector's foremost use cases. We
// specialize 'less' rather than just defining a specific comparator
// because LLSortedVector should be usable for other key_types as well.
template <typename T>
struct less< std::pair<std::type_info*, T> >:
public std::binary_function<std::pair<std::type_info*, T>,
std::pair<std::type_info*, T>,
bool>
{
bool operator()(const std::pair<std::type_info*, T>& lhs,
const std::pair<std::type_info*, T>& rhs) const
{
return lhs.first->before(*rhs.first);
}
};
// Same as above, but with const std::type_info*.
template <typename T>
struct less< std::pair<const std::type_info*, T> >:
public std::binary_function<std::pair<const std::type_info*, T>,
std::pair<const std::type_info*, T>,
bool>
{
bool operator()(const std::pair<const std::type_info*, T>& lhs,
const std::pair<const std::type_info*, T>& rhs) const
{
return lhs.first->before(*rhs.first);
}
};
PairVector mVector;
};
#endif /* ! defined(LL_LLSORTEDVECTOR_H) */

View File

@@ -42,10 +42,10 @@ template <class Object> class LLStrider
U8* mBytep; U8* mBytep;
}; };
U32 mSkip; U32 mSkip;
//U32 mTypeSize;
public: public:
LLStrider() { mObjectp = NULL; /*mTypeSize = */mSkip = sizeof(Object); } LLStrider() { mObjectp = NULL; mSkip = sizeof(Object); }
~LLStrider() { } ~LLStrider() { }
const LLStrider<Object>& operator = (Object *first) { mObjectp = first; return *this;} const LLStrider<Object>& operator = (Object *first) { mObjectp = first; return *this;}
@@ -60,9 +60,6 @@ public:
return ret; return ret;
} }
//void setTypeSize (S32 typeBytes){ mTypeSize = (typeBytes ? typeBytes : sizeof(Object)); }
//bool isStrided() const { return mTypeSize != mSkip; }
void skip(const U32 index) { mBytep += mSkip*index;} void skip(const U32 index) { mBytep += mSkip*index;}
U32 getSkip() const { return mSkip; } U32 getSkip() const { return mSkip; }
Object* get() { return mObjectp; } Object* get() { return mObjectp; }
@@ -70,72 +67,9 @@ public:
Object& operator *() { return *mObjectp; } Object& operator *() { return *mObjectp; }
Object* operator ++(int) { Object* old = mObjectp; mBytep += mSkip; return old; } Object* operator ++(int) { Object* old = mObjectp; mBytep += mSkip; return old; }
Object* operator +=(int i) { mBytep += mSkip*i; return mObjectp; } Object* operator +=(int i) { mBytep += mSkip*i; return mObjectp; }
Object& operator[](U32 index) { return *(Object*)(mBytep + (mSkip * index)); } Object& operator[](U32 index) { return *(Object*)(mBytep + (mSkip * index)); }
/*void assignArray(U8* __restrict source, const size_t elem_size, const size_t elem_count)
{
llassert_always(sizeof(Object) <= elem_size);
U8* __restrict dest = mBytep; //refer to dest instead of mBytep to benefit from __restrict hint
const U32 bytes = elem_size * elem_count; //total bytes to copy from source to dest
//stride == sizeof(element) implies entire buffer is unstrided and thus memcpy-able, provided source buffer elements match in size.
//Because LLStrider is often passed an LLVector3 even if the reprensentation is LLVector4 in the vertex buffer, mTypeSize is set to
//the TRUE vbo datatype size via VertexBufferStrider::get
if(!isStrided() && mTypeSize == elem_size)
{
if(bytes >= sizeof(LLVector4) * 4) //Should be able to pull at least 3 16byte blocks from this. Smaller isn't really beneficial.
{
U8* __restrict aligned_source = LL_NEXT_ALIGNED_ADDRESS(source);
U8* __restrict aligned_dest = LL_NEXT_ALIGNED_ADDRESS(dest);
const U32 source_offset = aligned_source - source; //Offset to first aligned location in source buffer.
const U32 dest_offset = aligned_dest - dest; //Offset to first aligned location in dest buffer.
llassert_always(source_offset < 16);
llassert_always(dest_offset < 16);
if(source_offset == dest_offset) //delta to aligned location matches between source and destination! _mm_*_ps should be viable.
{
const U32 end_offset = (bytes - source_offset) % sizeof(LLVector4); //buffers may not neatly end on a 16byte alignment boundary.
const U32 aligned_bytes = bytes - source_offset - end_offset; //how many bytes to copy from aligned start to aligned end.
llassert_always(aligned_bytes > 0);
if(source_offset) //memcpy up to the aligned location if needed
memcpy(dest,source,source_offset);
LLVector4a::memcpyNonAliased16((F32*) aligned_dest, (F32*) aligned_source, aligned_bytes);
if(end_offset) //memcpy to the very end if needed.
memcpy(aligned_dest+aligned_bytes,aligned_source+aligned_bytes,end_offset);
}
else //buffers non-uniformly offset from aligned location. Using _mm_*u_ps.
{
U32 end = bytes/sizeof(LLVector4); //sizeof(LLVector4) = 16 bytes = 128 bits
llassert_always(end > 0);
__m128* dst = (__m128*) dest;
__m128* src = (__m128*) source;
for (U32 i = 0; i < end; i++) //copy 128bit chunks
{
__m128 res = _mm_loadu_ps((F32*)&src[i]);
_mm_storeu_ps((F32*)&dst[i], res);
}
end*=16;//Convert to real byte offset
if(end < bytes) //just memcopy the rest
memcpy(dest+end,source+end,bytes-end);
}
}
else //Too small. just do a simple memcpy.
memcpy(dest,source,bytes);
}
else
{
for(U32 i=0;i<elem_count;i++)
{
memcpy(dest,source,sizeof(Object));
dest+=mSkip;
source+=elem_size;
}
}
}*/
}; };
#endif // LL_LLSTRIDER_H #endif // LL_LLSTRIDER_H

View File

@@ -34,7 +34,6 @@
#include "llstring.h" #include "llstring.h"
#include "llerror.h" #include "llerror.h"
#include "llfasttimer.h"
#if LL_WINDOWS #if LL_WINDOWS
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
@@ -604,16 +603,10 @@ std::string utf8str_removeCRLF(const std::string& utf8str)
} }
const char CR = 13; const char CR = 13;
S32 i = utf8str.find(CR);
if(i == std::string::npos)
return utf8str; //Save us from a reserve call.
std::string out; std::string out;
out.reserve(utf8str.length()); out.reserve(utf8str.length());
const S32 len = (S32)utf8str.length(); const S32 len = (S32)utf8str.length();
if(i) for( S32 i = 0; i < len; i++ )
out.assign(utf8str,0,i); //Copy previous text to buffer
for( ++i; i < len; i++ )
{ {
if( utf8str[i] != CR ) if( utf8str[i] != CR )
{ {

View File

@@ -35,11 +35,10 @@
#include <string> #include <string>
#include <cstdio> #include <cstdio>
#include <algorithm>
#include <map>
#include <locale> #include <locale>
#include <iomanip> #include <iomanip>
#include "llsd.h" #include "llsd.h"
#include "llfasttimer.h"
#if LL_LINUX || LL_SOLARIS #if LL_LINUX || LL_SOLARIS
#include <wctype.h> #include <wctype.h>
@@ -47,6 +46,7 @@
#endif #endif
#include <string.h> #include <string.h>
#include <boost/scoped_ptr.hpp>
#if LL_SOLARIS #if LL_SOLARIS
// stricmp and strnicmp do not exist on Solaris: // stricmp and strnicmp do not exist on Solaris:
@@ -246,40 +246,77 @@ private:
static std::string sLocale; static std::string sLocale;
public: public:
typedef typename std::basic_string<T>::size_type size_type; typedef std::basic_string<T> string_type;
typedef typename string_type::size_type size_type;
public: public:
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
// Static Utility functions that operate on std::strings // Static Utility functions that operate on std::strings
static const std::basic_string<T> null; static const string_type null;
typedef std::map<LLFormatMapString, LLFormatMapString> format_map_t; typedef std::map<LLFormatMapString, LLFormatMapString> format_map_t;
LL_COMMON_API static void getTokens(const std::basic_string<T>& instr, std::vector<std::basic_string<T> >& tokens, const std::basic_string<T>& delims); /// considers any sequence of delims as a single field separator
LL_COMMON_API static void formatNumber(std::basic_string<T>& numStr, std::basic_string<T> decimals); LL_COMMON_API static void getTokens(const string_type& instr,
LL_COMMON_API static bool formatDatetime(std::basic_string<T>& replacement, std::basic_string<T> token, std::basic_string<T> param, S32 secFromEpoch); std::vector<string_type >& tokens,
LL_COMMON_API static S32 format(std::basic_string<T>& s, const format_map_t& substitutions); const string_type& delims);
LL_COMMON_API static S32 format(std::basic_string<T>& s, const LLSD& substitutions); /// like simple scan overload, but returns scanned vector
LL_COMMON_API static bool simpleReplacement(std::basic_string<T>& replacement, std::basic_string<T> token, const format_map_t& substitutions); static std::vector<string_type> getTokens(const string_type& instr,
LL_COMMON_API static bool simpleReplacement(std::basic_string<T>& replacement, std::basic_string<T> token, const LLSD& substitutions); const string_type& delims);
/// add support for keep_delims and quotes (either could be empty string)
static void getTokens(const string_type& instr,
std::vector<string_type>& tokens,
const string_type& drop_delims,
const string_type& keep_delims,
const string_type& quotes=string_type());
/// like keep_delims-and-quotes overload, but returns scanned vector
static std::vector<string_type> getTokens(const string_type& instr,
const string_type& drop_delims,
const string_type& keep_delims,
const string_type& quotes=string_type());
/// add support for escapes (could be empty string)
static void getTokens(const string_type& instr,
std::vector<string_type>& tokens,
const string_type& drop_delims,
const string_type& keep_delims,
const string_type& quotes,
const string_type& escapes);
/// like escapes overload, but returns scanned vector
static std::vector<string_type> getTokens(const string_type& instr,
const string_type& drop_delims,
const string_type& keep_delims,
const string_type& quotes,
const string_type& escapes);
LL_COMMON_API static void formatNumber(string_type& numStr, string_type decimals);
LL_COMMON_API static bool formatDatetime(string_type& replacement, string_type token, string_type param, S32 secFromEpoch);
LL_COMMON_API static S32 format(string_type& s, const format_map_t& substitutions);
LL_COMMON_API static S32 format(string_type& s, const LLSD& substitutions);
LL_COMMON_API static bool simpleReplacement(string_type& replacement, string_type token, const format_map_t& substitutions);
LL_COMMON_API static bool simpleReplacement(string_type& replacement, string_type token, const LLSD& substitutions);
LL_COMMON_API static void setLocale (std::string inLocale); LL_COMMON_API static void setLocale (std::string inLocale);
LL_COMMON_API static std::string getLocale (void); LL_COMMON_API static std::string getLocale (void);
static bool isValidIndex(const std::basic_string<T>& string, size_type i) static bool isValidIndex(const string_type& string, size_type i)
{ {
return !string.empty() && (0 <= i) && (i <= string.size()); return !string.empty() && (0 <= i) && (i <= string.size());
} }
static void trimHead(std::basic_string<T>& string); static bool contains(const string_type& string, T c, size_type i=0)
static void trimTail(std::basic_string<T>& string); {
static void trim(std::basic_string<T>& string) { trimHead(string); trimTail(string); } return string.find(c, i) != string_type::npos;
static void truncate(std::basic_string<T>& string, size_type count); }
static void toUpper(std::basic_string<T>& string); static void trimHead(string_type& string);
static void toLower(std::basic_string<T>& string); static void trimTail(string_type& string);
static void trim(string_type& string) { trimHead(string); trimTail(string); }
static void truncate(string_type& string, size_type count);
static void toUpper(string_type& string);
static void toLower(string_type& string);
// True if this is the head of s. // True if this is the head of s.
static BOOL isHead( const std::basic_string<T>& string, const T* s ); static BOOL isHead( const string_type& string, const T* s );
/** /**
* @brief Returns true if string starts with substr * @brief Returns true if string starts with substr
@@ -287,8 +324,8 @@ public:
* If etither string or substr are empty, this method returns false. * If etither string or substr are empty, this method returns false.
*/ */
static bool startsWith( static bool startsWith(
const std::basic_string<T>& string, const string_type& string,
const std::basic_string<T>& substr); const string_type& substr);
/** /**
* @brief Returns true if string ends in substr * @brief Returns true if string ends in substr
@@ -296,19 +333,32 @@ public:
* If etither string or substr are empty, this method returns false. * If etither string or substr are empty, this method returns false.
*/ */
static bool endsWith( static bool endsWith(
const std::basic_string<T>& string, const string_type& string,
const std::basic_string<T>& substr); const string_type& substr);
static void addCRLF(std::basic_string<T>& string); static void addCRLF(string_type& string);
static void removeCRLF(std::basic_string<T>& string); static void removeCRLF(string_type& string);
static void replaceTabsWithSpaces( std::basic_string<T>& string, size_type spaces_per_tab ); static void replaceTabsWithSpaces( string_type& string, size_type spaces_per_tab );
static void replaceNonstandardASCII( std::basic_string<T>& string, T replacement ); static void replaceNonstandardASCII( string_type& string, T replacement );
static void replaceChar( std::basic_string<T>& string, T target, T replacement ); static void replaceChar( string_type& string, T target, T replacement );
static void replaceString( std::basic_string<T>& string, std::basic_string<T> target, std::basic_string<T> replacement ); static void replaceString( string_type& string, string_type target, string_type replacement );
static BOOL containsNonprintable(const std::basic_string<T>& string); static BOOL containsNonprintable(const string_type& string);
static void stripNonprintable(std::basic_string<T>& string); static void stripNonprintable(string_type& string);
/**
* Double-quote an argument string if needed, unless it's already
* double-quoted. Decide whether it's needed based on the presence of any
* character in @a triggers (default space or double-quote). If we quote
* it, escape any embedded double-quote with the @a escape string (default
* backslash).
*
* Passing triggers="" means always quote, unless it's already double-quoted.
*/
static string_type quote(const string_type& str,
const string_type& triggers=" \"",
const string_type& escape="\\");
/** /**
* @brief Unsafe way to make ascii characters. You should probably * @brief Unsafe way to make ascii characters. You should probably
@@ -317,18 +367,18 @@ public:
* The 2 and 4 byte std::string probably work, so LLWStringUtil::_makeASCII * The 2 and 4 byte std::string probably work, so LLWStringUtil::_makeASCII
* should work. * should work.
*/ */
static void _makeASCII(std::basic_string<T>& string); static void _makeASCII(string_type& string);
// Conversion to other data types // Conversion to other data types
static BOOL convertToBOOL(const std::basic_string<T>& string, BOOL& value); static BOOL convertToBOOL(const string_type& string, BOOL& value);
static BOOL convertToU8(const std::basic_string<T>& string, U8& value); static BOOL convertToU8(const string_type& string, U8& value);
static BOOL convertToS8(const std::basic_string<T>& string, S8& value); static BOOL convertToS8(const string_type& string, S8& value);
static BOOL convertToS16(const std::basic_string<T>& string, S16& value); static BOOL convertToS16(const string_type& string, S16& value);
static BOOL convertToU16(const std::basic_string<T>& string, U16& value); static BOOL convertToU16(const string_type& string, U16& value);
static BOOL convertToU32(const std::basic_string<T>& string, U32& value); static BOOL convertToU32(const string_type& string, U32& value);
static BOOL convertToS32(const std::basic_string<T>& string, S32& value); static BOOL convertToS32(const string_type& string, S32& value);
static BOOL convertToF32(const std::basic_string<T>& string, F32& value); static BOOL convertToF32(const string_type& string, F32& value);
static BOOL convertToF64(const std::basic_string<T>& string, F64& value); static BOOL convertToF64(const string_type& string, F64& value);
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
// Utility functions for working with char*'s and strings // Utility functions for working with char*'s and strings
@@ -336,24 +386,24 @@ public:
// Like strcmp but also handles empty strings. Uses // Like strcmp but also handles empty strings. Uses
// current locale. // current locale.
static S32 compareStrings(const T* lhs, const T* rhs); static S32 compareStrings(const T* lhs, const T* rhs);
static S32 compareStrings(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs); static S32 compareStrings(const string_type& lhs, const string_type& rhs);
// case insensitive version of above. Uses current locale on // case insensitive version of above. Uses current locale on
// Win32, and falls back to a non-locale aware comparison on // Win32, and falls back to a non-locale aware comparison on
// Linux. // Linux.
static S32 compareInsensitive(const T* lhs, const T* rhs); static S32 compareInsensitive(const T* lhs, const T* rhs);
static S32 compareInsensitive(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs); static S32 compareInsensitive(const string_type& lhs, const string_type& rhs);
// Case sensitive comparison with good handling of numbers. Does not use current locale. // Case sensitive comparison with good handling of numbers. Does not use current locale.
// a.k.a. strdictcmp() // a.k.a. strdictcmp()
static S32 compareDict(const std::basic_string<T>& a, const std::basic_string<T>& b); static S32 compareDict(const string_type& a, const string_type& b);
// Case *in*sensitive comparison with good handling of numbers. Does not use current locale. // Case *in*sensitive comparison with good handling of numbers. Does not use current locale.
// a.k.a. strdictcmp() // a.k.a. strdictcmp()
static S32 compareDictInsensitive(const std::basic_string<T>& a, const std::basic_string<T>& b); static S32 compareDictInsensitive(const string_type& a, const string_type& b);
// Puts compareDict() in a form appropriate for LL container classes to use for sorting. // Puts compareDict() in a form appropriate for LL container classes to use for sorting.
static BOOL precedesDict( const std::basic_string<T>& a, const std::basic_string<T>& b ); static BOOL precedesDict( const string_type& a, const string_type& b );
// A replacement for strncpy. // A replacement for strncpy.
// If the dst buffer is dst_size bytes long or more, ensures that dst is null terminated and holds // If the dst buffer is dst_size bytes long or more, ensures that dst is null terminated and holds
@@ -361,7 +411,7 @@ public:
static void copy(T* dst, const T* src, size_type dst_size); static void copy(T* dst, const T* src, size_type dst_size);
// Copies src into dst at a given offset. // Copies src into dst at a given offset.
static void copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset); static void copyInto(string_type& dst, const string_type& src, size_type offset);
static bool isPartOfWord(T c) { return (c == (T)'_') || LLStringOps::isAlnum(c); } static bool isPartOfWord(T c) { return (c == (T)'_') || LLStringOps::isAlnum(c); }
@@ -371,7 +421,7 @@ public:
#endif #endif
private: private:
LL_COMMON_API static size_type getSubstitution(const std::basic_string<T>& instr, size_type& start, std::vector<std::basic_string<T> >& tokens); LL_COMMON_API static size_type getSubstitution(const string_type& instr, size_type& start, std::vector<string_type >& tokens);
}; };
template<class T> const std::basic_string<T> LLStringUtilBase<T>::null; template<class T> const std::basic_string<T> LLStringUtilBase<T>::null;
@@ -649,6 +699,321 @@ namespace LLStringFn
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// static
template <class T>
std::vector<typename LLStringUtilBase<T>::string_type>
LLStringUtilBase<T>::getTokens(const string_type& instr, const string_type& delims)
{
std::vector<string_type> tokens;
getTokens(instr, tokens, delims);
return tokens;
}
// static
template <class T>
std::vector<typename LLStringUtilBase<T>::string_type>
LLStringUtilBase<T>::getTokens(const string_type& instr,
const string_type& drop_delims,
const string_type& keep_delims,
const string_type& quotes)
{
std::vector<string_type> tokens;
getTokens(instr, tokens, drop_delims, keep_delims, quotes);
return tokens;
}
// static
template <class T>
std::vector<typename LLStringUtilBase<T>::string_type>
LLStringUtilBase<T>::getTokens(const string_type& instr,
const string_type& drop_delims,
const string_type& keep_delims,
const string_type& quotes,
const string_type& escapes)
{
std::vector<string_type> tokens;
getTokens(instr, tokens, drop_delims, keep_delims, quotes, escapes);
return tokens;
}
namespace LLStringUtilBaseImpl
{
/**
* Input string scanner helper for getTokens(), or really any other
* character-parsing routine that may have to deal with escape characters.
* This implementation defines the concept (also an interface, should you
* choose to implement the concept by subclassing) and provides trivial
* implementations for a string @em without escape processing.
*/
template <class T>
struct InString
{
typedef std::basic_string<T> string_type;
typedef typename string_type::const_iterator const_iterator;
InString(const_iterator b, const_iterator e):
mIter(b),
mEnd(e)
{}
virtual ~InString() {}
bool done() const { return mIter == mEnd; }
/// Is the current character (*mIter) escaped? This implementation can
/// answer trivially because it doesn't support escapes.
virtual bool escaped() const { return false; }
/// Obtain the current character and advance @c mIter.
virtual T next() { return *mIter++; }
/// Does the current character match specified character?
virtual bool is(T ch) const { return (! done()) && *mIter == ch; }
/// Is the current character any one of the specified characters?
virtual bool oneof(const string_type& delims) const
{
return (! done()) && LLStringUtilBase<T>::contains(delims, *mIter);
}
/**
* Scan forward from @from until either @a delim or end. This is primarily
* useful for processing quoted substrings.
*
* If we do see @a delim, append everything from @from until (excluding)
* @a delim to @a into, advance @c mIter to skip @a delim, and return @c
* true.
*
* If we do not see @a delim, do not alter @a into or @c mIter and return
* @c false. Do not pass GO, do not collect $200.
*
* @note The @c false case described above implements normal getTokens()
* treatment of an unmatched open quote: treat the quote character as if
* escaped, that is, simply collect it as part of the current token. Other
* plausible behaviors directly affect the way getTokens() deals with an
* unmatched quote: e.g. throwing an exception to treat it as an error, or
* assuming a close quote beyond end of string (in which case return @c
* true).
*/
virtual bool collect_until(string_type& into, const_iterator from, T delim)
{
const_iterator found = std::find(from, mEnd, delim);
// If we didn't find delim, change nothing, just tell caller.
if (found == mEnd)
return false;
// Found delim! Append everything between from and found.
into.append(from, found);
// advance past delim in input
mIter = found + 1;
return true;
}
const_iterator mIter, mEnd;
};
/// InString subclass that handles escape characters
template <class T>
class InEscString: public InString<T>
{
public:
typedef InString<T> super;
typedef typename super::string_type string_type;
typedef typename super::const_iterator const_iterator;
using super::done;
using super::mIter;
using super::mEnd;
InEscString(const_iterator b, const_iterator e, const string_type& escapes):
super(b, e),
mEscapes(escapes)
{
// Even though we've already initialized 'mIter' via our base-class
// constructor, set it again to check for initial escape char.
setiter(b);
}
/// This implementation uses the answer cached by setiter().
virtual bool escaped() const { return mIsEsc; }
virtual T next()
{
// If we're looking at the escape character of an escape sequence,
// skip that character. This is the one time we can modify 'mIter'
// without using setiter: for this one case we DO NOT CARE if the
// escaped character is itself an escape.
if (mIsEsc)
++mIter;
// If we were looking at an escape character, this is the escaped
// character; otherwise it's just the next character.
T result(*mIter);
// Advance mIter, checking for escape sequence.
setiter(mIter + 1);
return result;
}
virtual bool is(T ch) const
{
// Like base-class is(), except that an escaped character matches
// nothing.
return (! done()) && (! mIsEsc) && *mIter == ch;
}
virtual bool oneof(const string_type& delims) const
{
// Like base-class oneof(), except that an escaped character matches
// nothing.
return (! done()) && (! mIsEsc) && LLStringUtilBase<T>::contains(delims, *mIter);
}
virtual bool collect_until(string_type& into, const_iterator from, T delim)
{
// Deal with escapes in the characters we collect; that is, an escaped
// character must become just that character without the preceding
// escape. Collect characters in a separate string rather than
// directly appending to 'into' in case we do not find delim, in which
// case we're supposed to leave 'into' unmodified.
string_type collected;
// For scanning purposes, we're going to work directly with 'mIter'.
// Save its current value in case we fail to see delim.
const_iterator save_iter(mIter);
// Okay, set 'mIter', checking for escape.
setiter(from);
while (! done())
{
// If we see an unescaped delim, stop and report success.
if ((! mIsEsc) && *mIter == delim)
{
// Append collected chars to 'into'.
into.append(collected);
// Don't forget to advance 'mIter' past delim.
setiter(mIter + 1);
return true;
}
// We're not at end, and either we're not looking at delim or it's
// escaped. Collect this character and keep going.
collected.push_back(next());
}
// Here we hit 'mEnd' without ever seeing delim. Restore mIter and tell
// caller.
setiter(save_iter);
return false;
}
private:
void setiter(const_iterator i)
{
mIter = i;
// Every time we change 'mIter', set 'mIsEsc' to be able to repetitively
// answer escaped() without having to rescan 'mEscapes'. mIsEsc caches
// contains(mEscapes, *mIter).
// We're looking at an escaped char if we're not already at end (that
// is, *mIter is even meaningful); if *mIter is in fact one of the
// specified escape characters; and if there's one more character
// following it. That is, if an escape character is the very last
// character of the input string, it loses its special meaning.
mIsEsc = (! done()) &&
LLStringUtilBase<T>::contains(mEscapes, *mIter) &&
(mIter+1) != mEnd;
}
const string_type mEscapes;
bool mIsEsc;
};
/// getTokens() implementation based on InString concept
template <typename INSTRING, typename string_type>
void getTokens(INSTRING& instr, std::vector<string_type>& tokens,
const string_type& drop_delims, const string_type& keep_delims,
const string_type& quotes)
{
// There are times when we want to match either drop_delims or
// keep_delims. Concatenate them up front to speed things up.
string_type all_delims(drop_delims + keep_delims);
// no tokens yet
tokens.clear();
// try for another token
while (! instr.done())
{
// scan past any drop_delims
while (instr.oneof(drop_delims))
{
// skip this drop_delim
instr.next();
// but if that was the end of the string, done
if (instr.done())
return;
}
// found the start of another token: make a slot for it
tokens.push_back(string_type());
if (instr.oneof(keep_delims))
{
// *iter is a keep_delim, a token of exactly 1 character. Append
// that character to the new token and proceed.
tokens.back().push_back(instr.next());
continue;
}
// Here we have a non-delimiter token, which might consist of a mix of
// quoted and unquoted parts. Use bash rules for quoting: you can
// embed a quoted substring in the midst of an unquoted token (e.g.
// ~/"sub dir"/myfile.txt); you can ram two quoted substrings together
// to make a single token (e.g. 'He said, "'"Don't."'"'). We diverge
// from bash in that bash considers an unmatched quote an error. Our
// param signature doesn't allow for errors, so just pretend it's not
// a quote and embed it.
// At this level, keep scanning until we hit the next delimiter of
// either type (drop_delims or keep_delims).
while (! instr.oneof(all_delims))
{
// If we're looking at an open quote, search forward for
// a close quote, collecting characters along the way.
if (instr.oneof(quotes) &&
instr.collect_until(tokens.back(), instr.mIter+1, *instr.mIter))
{
// collect_until is cleverly designed to do exactly what we
// need here. No further action needed if it returns true.
}
else
{
// Either *iter isn't a quote, or there's no matching close
// quote: in other words, just an ordinary char. Append it to
// current token.
tokens.back().push_back(instr.next());
}
// having scanned that segment of this token, if we've reached the
// end of the string, we're done
if (instr.done())
return;
}
}
}
} // namespace LLStringUtilBaseImpl
// static
template <class T>
void LLStringUtilBase<T>::getTokens(const string_type& string, std::vector<string_type>& tokens,
const string_type& drop_delims, const string_type& keep_delims,
const string_type& quotes)
{
// Because this overload doesn't support escapes, use simple InString to
// manage input range.
LLStringUtilBaseImpl::InString<T> instring(string.begin(), string.end());
LLStringUtilBaseImpl::getTokens(instring, tokens, drop_delims, keep_delims, quotes);
}
// static
template <class T>
void LLStringUtilBase<T>::getTokens(const string_type& string, std::vector<string_type>& tokens,
const string_type& drop_delims, const string_type& keep_delims,
const string_type& quotes, const string_type& escapes)
{
// This overload must deal with escapes. Delegate that to InEscString
// (unless there ARE no escapes).
boost::scoped_ptr< LLStringUtilBaseImpl::InString<T> > instrp;
if (escapes.empty())
instrp.reset(new LLStringUtilBaseImpl::InString<T>(string.begin(), string.end()));
else
instrp.reset(new LLStringUtilBaseImpl::InEscString<T>(string.begin(), string.end(), escapes));
LLStringUtilBaseImpl::getTokens(*instrp, tokens, drop_delims, keep_delims, quotes);
}
// static // static
template<class T> template<class T>
@@ -678,7 +1043,7 @@ S32 LLStringUtilBase<T>::compareStrings(const T* lhs, const T* rhs)
//static //static
template<class T> template<class T>
S32 LLStringUtilBase<T>::compareStrings(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs) S32 LLStringUtilBase<T>::compareStrings(const string_type& lhs, const string_type& rhs)
{ {
return LLStringOps::collate(lhs.c_str(), rhs.c_str()); return LLStringOps::collate(lhs.c_str(), rhs.c_str());
} }
@@ -704,8 +1069,8 @@ S32 LLStringUtilBase<T>::compareInsensitive(const T* lhs, const T* rhs )
} }
else else
{ {
std::basic_string<T> lhs_string(lhs); string_type lhs_string(lhs);
std::basic_string<T> rhs_string(rhs); string_type rhs_string(rhs);
LLStringUtilBase<T>::toUpper(lhs_string); LLStringUtilBase<T>::toUpper(lhs_string);
LLStringUtilBase<T>::toUpper(rhs_string); LLStringUtilBase<T>::toUpper(rhs_string);
result = LLStringOps::collate(lhs_string.c_str(), rhs_string.c_str()); result = LLStringOps::collate(lhs_string.c_str(), rhs_string.c_str());
@@ -715,10 +1080,10 @@ S32 LLStringUtilBase<T>::compareInsensitive(const T* lhs, const T* rhs )
//static //static
template<class T> template<class T>
S32 LLStringUtilBase<T>::compareInsensitive(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs) S32 LLStringUtilBase<T>::compareInsensitive(const string_type& lhs, const string_type& rhs)
{ {
std::basic_string<T> lhs_string(lhs); string_type lhs_string(lhs);
std::basic_string<T> rhs_string(rhs); string_type rhs_string(rhs);
LLStringUtilBase<T>::toUpper(lhs_string); LLStringUtilBase<T>::toUpper(lhs_string);
LLStringUtilBase<T>::toUpper(rhs_string); LLStringUtilBase<T>::toUpper(rhs_string);
return LLStringOps::collate(lhs_string.c_str(), rhs_string.c_str()); return LLStringOps::collate(lhs_string.c_str(), rhs_string.c_str());
@@ -729,7 +1094,7 @@ S32 LLStringUtilBase<T>::compareInsensitive(const std::basic_string<T>& lhs, con
//static //static
template<class T> template<class T>
S32 LLStringUtilBase<T>::compareDict(const std::basic_string<T>& astr, const std::basic_string<T>& bstr) S32 LLStringUtilBase<T>::compareDict(const string_type& astr, const string_type& bstr)
{ {
const T* a = astr.c_str(); const T* a = astr.c_str();
const T* b = bstr.c_str(); const T* b = bstr.c_str();
@@ -770,7 +1135,7 @@ S32 LLStringUtilBase<T>::compareDict(const std::basic_string<T>& astr, const std
// static // static
template<class T> template<class T>
S32 LLStringUtilBase<T>::compareDictInsensitive(const std::basic_string<T>& astr, const std::basic_string<T>& bstr) S32 LLStringUtilBase<T>::compareDictInsensitive(const string_type& astr, const string_type& bstr)
{ {
const T* a = astr.c_str(); const T* a = astr.c_str();
const T* b = bstr.c_str(); const T* b = bstr.c_str();
@@ -805,7 +1170,7 @@ S32 LLStringUtilBase<T>::compareDictInsensitive(const std::basic_string<T>& astr
// Puts compareDict() in a form appropriate for LL container classes to use for sorting. // Puts compareDict() in a form appropriate for LL container classes to use for sorting.
// static // static
template<class T> template<class T>
BOOL LLStringUtilBase<T>::precedesDict( const std::basic_string<T>& a, const std::basic_string<T>& b ) BOOL LLStringUtilBase<T>::precedesDict( const string_type& a, const string_type& b )
{ {
if( a.size() && b.size() ) if( a.size() && b.size() )
{ {
@@ -819,7 +1184,7 @@ BOOL LLStringUtilBase<T>::precedesDict( const std::basic_string<T>& a, const std
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::toUpper(std::basic_string<T>& string) void LLStringUtilBase<T>::toUpper(string_type& string)
{ {
if( !string.empty() ) if( !string.empty() )
{ {
@@ -833,7 +1198,7 @@ void LLStringUtilBase<T>::toUpper(std::basic_string<T>& string)
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::toLower(std::basic_string<T>& string) void LLStringUtilBase<T>::toLower(string_type& string)
{ {
if( !string.empty() ) if( !string.empty() )
{ {
@@ -847,7 +1212,7 @@ void LLStringUtilBase<T>::toLower(std::basic_string<T>& string)
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::trimHead(std::basic_string<T>& string) void LLStringUtilBase<T>::trimHead(string_type& string)
{ {
if( !string.empty() ) if( !string.empty() )
{ {
@@ -862,7 +1227,7 @@ void LLStringUtilBase<T>::trimHead(std::basic_string<T>& string)
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::trimTail(std::basic_string<T>& string) void LLStringUtilBase<T>::trimTail(string_type& string)
{ {
if( string.size() ) if( string.size() )
{ {
@@ -881,7 +1246,7 @@ void LLStringUtilBase<T>::trimTail(std::basic_string<T>& string)
// Replace line feeds with carriage return-line feed pairs. // Replace line feeds with carriage return-line feed pairs.
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::addCRLF(std::basic_string<T>& string) void LLStringUtilBase<T>::addCRLF(string_type& string)
{ {
const T LF = 10; const T LF = 10;
const T CR = 13; const T CR = 13;
@@ -923,7 +1288,7 @@ void LLStringUtilBase<T>::addCRLF(std::basic_string<T>& string)
// Remove all carriage returns // Remove all carriage returns
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::removeCRLF(std::basic_string<T>& string) void LLStringUtilBase<T>::removeCRLF(string_type& string)
{ {
const T CR = 13; const T CR = 13;
@@ -944,10 +1309,10 @@ void LLStringUtilBase<T>::removeCRLF(std::basic_string<T>& string)
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::replaceChar( std::basic_string<T>& string, T target, T replacement ) void LLStringUtilBase<T>::replaceChar( string_type& string, T target, T replacement )
{ {
size_type found_pos = 0; size_type found_pos = 0;
while( (found_pos = string.find(target, found_pos)) != std::basic_string<T>::npos ) while( (found_pos = string.find(target, found_pos)) != string_type::npos )
{ {
string[found_pos] = replacement; string[found_pos] = replacement;
found_pos++; // avoid infinite defeat if target == replacement found_pos++; // avoid infinite defeat if target == replacement
@@ -956,10 +1321,10 @@ void LLStringUtilBase<T>::replaceChar( std::basic_string<T>& string, T target, T
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::replaceString( std::basic_string<T>& string, std::basic_string<T> target, std::basic_string<T> replacement ) void LLStringUtilBase<T>::replaceString( string_type& string, string_type target, string_type replacement )
{ {
size_type found_pos = 0; size_type found_pos = 0;
while( (found_pos = string.find(target, found_pos)) != std::basic_string<T>::npos ) while( (found_pos = string.find(target, found_pos)) != string_type::npos )
{ {
string.replace( found_pos, target.length(), replacement ); string.replace( found_pos, target.length(), replacement );
found_pos += replacement.length(); // avoid infinite defeat if replacement contains target found_pos += replacement.length(); // avoid infinite defeat if replacement contains target
@@ -968,7 +1333,7 @@ void LLStringUtilBase<T>::replaceString( std::basic_string<T>& string, std::basi
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::replaceNonstandardASCII( std::basic_string<T>& string, T replacement ) void LLStringUtilBase<T>::replaceNonstandardASCII( string_type& string, T replacement )
{ {
const char LF = 10; const char LF = 10;
const S8 MIN = 32; const S8 MIN = 32;
@@ -988,12 +1353,12 @@ void LLStringUtilBase<T>::replaceNonstandardASCII( std::basic_string<T>& string,
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::replaceTabsWithSpaces( std::basic_string<T>& str, size_type spaces_per_tab ) void LLStringUtilBase<T>::replaceTabsWithSpaces( string_type& str, size_type spaces_per_tab )
{ {
const T TAB = '\t'; const T TAB = '\t';
const T SPACE = ' '; const T SPACE = ' ';
std::basic_string<T> out_str; string_type out_str;
// Replace tabs with spaces // Replace tabs with spaces
for (size_type i = 0; i < str.length(); i++) for (size_type i = 0; i < str.length(); i++)
{ {
@@ -1012,7 +1377,7 @@ void LLStringUtilBase<T>::replaceTabsWithSpaces( std::basic_string<T>& str, size
//static //static
template<class T> template<class T>
BOOL LLStringUtilBase<T>::containsNonprintable(const std::basic_string<T>& string) BOOL LLStringUtilBase<T>::containsNonprintable(const string_type& string)
{ {
const char MIN = 32; const char MIN = 32;
BOOL rv = FALSE; BOOL rv = FALSE;
@@ -1029,7 +1394,7 @@ BOOL LLStringUtilBase<T>::containsNonprintable(const std::basic_string<T>& strin
//static //static
template<class T> template<class T>
void LLStringUtilBase<T>::stripNonprintable(std::basic_string<T>& string) void LLStringUtilBase<T>::stripNonprintable(string_type& string)
{ {
const char MIN = 32; const char MIN = 32;
size_type j = 0; size_type j = 0;
@@ -1061,7 +1426,42 @@ void LLStringUtilBase<T>::stripNonprintable(std::basic_string<T>& string)
} }
template<class T> template<class T>
void LLStringUtilBase<T>::_makeASCII(std::basic_string<T>& string) std::basic_string<T> LLStringUtilBase<T>::quote(const string_type& str,
const string_type& triggers,
const string_type& escape)
{
size_type len(str.length());
// If the string is already quoted, assume user knows what s/he's doing.
if (len >= 2 && str[0] == '"' && str[len-1] == '"')
{
return str;
}
// Not already quoted: do we need to? triggers.empty() is a special case
// meaning "always quote."
if ((! triggers.empty()) && str.find_first_of(triggers) == string_type::npos)
{
// no trigger characters, don't bother quoting
return str;
}
// For whatever reason, we must quote this string.
string_type result;
result.push_back('"');
for (typename string_type::const_iterator ci(str.begin()), cend(str.end()); ci != cend; ++ci)
{
if (*ci == '"')
{
result.append(escape);
}
result.push_back(*ci);
}
result.push_back('"');
return result;
}
template<class T>
void LLStringUtilBase<T>::_makeASCII(string_type& string)
{ {
// Replace non-ASCII chars with LL_UNKNOWN_CHAR // Replace non-ASCII chars with LL_UNKNOWN_CHAR
for (size_type i = 0; i < string.length(); i++) for (size_type i = 0; i < string.length(); i++)
@@ -1091,7 +1491,7 @@ void LLStringUtilBase<T>::copy( T* dst, const T* src, size_type dst_size )
// static // static
template<class T> template<class T>
void LLStringUtilBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset) void LLStringUtilBase<T>::copyInto(string_type& dst, const string_type& src, size_type offset)
{ {
if ( offset == dst.length() ) if ( offset == dst.length() )
{ {
@@ -1101,7 +1501,7 @@ void LLStringUtilBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_s
} }
else else
{ {
std::basic_string<T> tail = dst.substr(offset); string_type tail = dst.substr(offset);
dst = dst.substr(0, offset); dst = dst.substr(0, offset);
dst += src; dst += src;
@@ -1112,7 +1512,7 @@ void LLStringUtilBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_s
// True if this is the head of s. // True if this is the head of s.
//static //static
template<class T> template<class T>
BOOL LLStringUtilBase<T>::isHead( const std::basic_string<T>& string, const T* s ) BOOL LLStringUtilBase<T>::isHead( const string_type& string, const T* s )
{ {
if( string.empty() ) if( string.empty() )
{ {
@@ -1128,8 +1528,8 @@ BOOL LLStringUtilBase<T>::isHead( const std::basic_string<T>& string, const T* s
// static // static
template<class T> template<class T>
bool LLStringUtilBase<T>::startsWith( bool LLStringUtilBase<T>::startsWith(
const std::basic_string<T>& string, const string_type& string,
const std::basic_string<T>& substr) const string_type& substr)
{ {
if(string.empty() || (substr.empty())) return false; if(string.empty() || (substr.empty())) return false;
if(0 == string.find(substr)) return true; if(0 == string.find(substr)) return true;
@@ -1139,8 +1539,8 @@ bool LLStringUtilBase<T>::startsWith(
// static // static
template<class T> template<class T>
bool LLStringUtilBase<T>::endsWith( bool LLStringUtilBase<T>::endsWith(
const std::basic_string<T>& string, const string_type& string,
const std::basic_string<T>& substr) const string_type& substr)
{ {
if(string.empty() || (substr.empty())) return false; if(string.empty() || (substr.empty())) return false;
std::string::size_type idx = string.rfind(substr); std::string::size_type idx = string.rfind(substr);
@@ -1150,14 +1550,14 @@ bool LLStringUtilBase<T>::endsWith(
template<class T> template<class T>
BOOL LLStringUtilBase<T>::convertToBOOL(const std::basic_string<T>& string, BOOL& value) BOOL LLStringUtilBase<T>::convertToBOOL(const string_type& string, BOOL& value)
{ {
if( string.empty() ) if( string.empty() )
{ {
return FALSE; return FALSE;
} }
std::basic_string<T> temp( string ); string_type temp( string );
trim(temp); trim(temp);
if( if(
(temp == "1") || (temp == "1") ||
@@ -1187,7 +1587,7 @@ BOOL LLStringUtilBase<T>::convertToBOOL(const std::basic_string<T>& string, BOOL
} }
template<class T> template<class T>
BOOL LLStringUtilBase<T>::convertToU8(const std::basic_string<T>& string, U8& value) BOOL LLStringUtilBase<T>::convertToU8(const string_type& string, U8& value)
{ {
S32 value32 = 0; S32 value32 = 0;
BOOL success = convertToS32(string, value32); BOOL success = convertToS32(string, value32);
@@ -1200,7 +1600,7 @@ BOOL LLStringUtilBase<T>::convertToU8(const std::basic_string<T>& string, U8& va
} }
template<class T> template<class T>
BOOL LLStringUtilBase<T>::convertToS8(const std::basic_string<T>& string, S8& value) BOOL LLStringUtilBase<T>::convertToS8(const string_type& string, S8& value)
{ {
S32 value32 = 0; S32 value32 = 0;
BOOL success = convertToS32(string, value32); BOOL success = convertToS32(string, value32);
@@ -1213,7 +1613,7 @@ BOOL LLStringUtilBase<T>::convertToS8(const std::basic_string<T>& string, S8& va
} }
template<class T> template<class T>
BOOL LLStringUtilBase<T>::convertToS16(const std::basic_string<T>& string, S16& value) BOOL LLStringUtilBase<T>::convertToS16(const string_type& string, S16& value)
{ {
S32 value32 = 0; S32 value32 = 0;
BOOL success = convertToS32(string, value32); BOOL success = convertToS32(string, value32);
@@ -1226,7 +1626,7 @@ BOOL LLStringUtilBase<T>::convertToS16(const std::basic_string<T>& string, S16&
} }
template<class T> template<class T>
BOOL LLStringUtilBase<T>::convertToU16(const std::basic_string<T>& string, U16& value) BOOL LLStringUtilBase<T>::convertToU16(const string_type& string, U16& value)
{ {
S32 value32 = 0; S32 value32 = 0;
BOOL success = convertToS32(string, value32); BOOL success = convertToS32(string, value32);
@@ -1239,17 +1639,17 @@ BOOL LLStringUtilBase<T>::convertToU16(const std::basic_string<T>& string, U16&
} }
template<class T> template<class T>
BOOL LLStringUtilBase<T>::convertToU32(const std::basic_string<T>& string, U32& value) BOOL LLStringUtilBase<T>::convertToU32(const string_type& string, U32& value)
{ {
if( string.empty() ) if( string.empty() )
{ {
return FALSE; return FALSE;
} }
std::basic_string<T> temp( string ); string_type temp( string );
trim(temp); trim(temp);
U32 v; U32 v;
std::basic_istringstream<T> i_stream((std::basic_string<T>)temp); std::basic_istringstream<T> i_stream((string_type)temp);
if(i_stream >> v) if(i_stream >> v)
{ {
value = v; value = v;
@@ -1259,17 +1659,17 @@ BOOL LLStringUtilBase<T>::convertToU32(const std::basic_string<T>& string, U32&
} }
template<class T> template<class T>
BOOL LLStringUtilBase<T>::convertToS32(const std::basic_string<T>& string, S32& value) BOOL LLStringUtilBase<T>::convertToS32(const string_type& string, S32& value)
{ {
if( string.empty() ) if( string.empty() )
{ {
return FALSE; return FALSE;
} }
std::basic_string<T> temp( string ); string_type temp( string );
trim(temp); trim(temp);
S32 v; S32 v;
std::basic_istringstream<T> i_stream((std::basic_string<T>)temp); std::basic_istringstream<T> i_stream((string_type)temp);
if(i_stream >> v) if(i_stream >> v)
{ {
//TODO: figure out overflow and underflow reporting here //TODO: figure out overflow and underflow reporting here
@@ -1286,7 +1686,7 @@ BOOL LLStringUtilBase<T>::convertToS32(const std::basic_string<T>& string, S32&
} }
template<class T> template<class T>
BOOL LLStringUtilBase<T>::convertToF32(const std::basic_string<T>& string, F32& value) BOOL LLStringUtilBase<T>::convertToF32(const string_type& string, F32& value)
{ {
F64 value64 = 0.0; F64 value64 = 0.0;
BOOL success = convertToF64(string, value64); BOOL success = convertToF64(string, value64);
@@ -1299,17 +1699,17 @@ BOOL LLStringUtilBase<T>::convertToF32(const std::basic_string<T>& string, F32&
} }
template<class T> template<class T>
BOOL LLStringUtilBase<T>::convertToF64(const std::basic_string<T>& string, F64& value) BOOL LLStringUtilBase<T>::convertToF64(const string_type& string, F64& value)
{ {
if( string.empty() ) if( string.empty() )
{ {
return FALSE; return FALSE;
} }
std::basic_string<T> temp( string ); string_type temp( string );
trim(temp); trim(temp);
F64 v; F64 v;
std::basic_istringstream<T> i_stream((std::basic_string<T>)temp); std::basic_istringstream<T> i_stream((string_type)temp);
if(i_stream >> v) if(i_stream >> v)
{ {
//TODO: figure out overflow and underflow reporting here //TODO: figure out overflow and underflow reporting here
@@ -1326,7 +1726,7 @@ BOOL LLStringUtilBase<T>::convertToF64(const std::basic_string<T>& string, F64&
} }
template<class T> template<class T>
void LLStringUtilBase<T>::truncate(std::basic_string<T>& string, size_type count) void LLStringUtilBase<T>::truncate(string_type& string, size_type count)
{ {
size_type cur_size = string.size(); size_type cur_size = string.size();
string.resize(count < cur_size ? count : cur_size); string.resize(count < cur_size ? count : cur_size);

View File

@@ -0,0 +1,110 @@
/**
* @file lltypeinfolookup.h
* @author Nat Goodspeed
* @date 2012-04-08
* @brief Template data structure like std::map<std::type_info*, T>
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Copyright (c) 2012, Linden Research, Inc.
* $/LicenseInfo$
*/
#if ! defined(LL_LLTYPEINFOLOOKUP_H)
#define LL_LLTYPEINFOLOOKUP_H
#include "llsortedvector.h"
#include <typeinfo>
/**
* LLTypeInfoLookup is specifically designed for use cases for which you might
* consider std::map<std::type_info*, VALUE>. We have several such data
* structures in the viewer. The trouble with them is that at least on Linux,
* you can't rely on always getting the same std::type_info* for a given type:
* different load modules will produce different std::type_info*.
* LLTypeInfoLookup contains a workaround to address this issue.
*
* Specifically, when we don't find the passed std::type_info*,
* LLTypeInfoLookup performs a linear search over registered entries to
* compare name() strings. Presuming that this succeeds, we cache the new
* (previously unrecognized) std::type_info* to speed future lookups.
*
* This worst-case fallback search (linear search with string comparison)
* should only happen the first time we look up a given type from a particular
* load module other than the one from which we initially registered types.
* (However, a lookup which wouldn't succeed anyway will always have
* worst-case performance.) This class is probably best used with less than a
* few dozen different types.
*/
template <typename VALUE>
class LLTypeInfoLookup
{
public:
typedef LLTypeInfoLookup<VALUE> self;
typedef LLSortedVector<const std::type_info*, VALUE> vector_type;
typedef typename vector_type::key_type key_type;
typedef typename vector_type::mapped_type mapped_type;
typedef typename vector_type::value_type value_type;
typedef typename vector_type::iterator iterator;
typedef typename vector_type::const_iterator const_iterator;
LLTypeInfoLookup() {}
iterator begin() { return mVector.begin(); }
iterator end() { return mVector.end(); }
const_iterator begin() const { return mVector.begin(); }
const_iterator end() const { return mVector.end(); }
bool empty() const { return mVector.empty(); }
std::size_t size() const { return mVector.size(); }
std::pair<iterator, bool> insert(const std::type_info* key, const VALUE& value)
{
return insert(value_type(key, value));
}
std::pair<iterator, bool> insert(const value_type& pair)
{
return mVector.insert(pair);
}
// const find() forwards to non-const find(): this can alter mVector!
const_iterator find(const std::type_info* key) const
{
return const_cast<self*>(this)->find(key);
}
// non-const find() caches previously-unknown type_info* to speed future
// lookups.
iterator find(const std::type_info* key)
{
iterator found = mVector.find(key);
if (found != mVector.end())
{
// If LLSortedVector::find() found, great, we're done.
return found;
}
// Here we didn't find the passed type_info*. On Linux, though, even
// for the same type, typeid(sametype) produces a different type_info*
// when used in different load modules. So the fact that we didn't
// find the type_info* we seek doesn't mean this type isn't
// registered. Scan for matching name() string.
for (typename vector_type::iterator ti(mVector.begin()), tend(mVector.end());
ti != tend; ++ti)
{
if (std::string(ti->first->name()) == key->name())
{
// This unrecognized 'key' is for the same type as ti->first.
// To speed future lookups, insert a new entry that lets us
// look up ti->second using this same 'key'.
return insert(key, ti->second).first;
}
}
// We simply have never seen a type with this type_info* from any load
// module.
return mVector.end();
}
private:
vector_type mVector;
};
#endif /* ! defined(LL_LLTYPEINFOLOOKUP_H) */

View File

@@ -34,7 +34,6 @@
#include <iostream> #include <iostream>
#include <set> #include <set>
#include <vector>
#include "stdtypes.h" #include "stdtypes.h"
#include "llpreprocessor.h" #include "llpreprocessor.h"

View File

@@ -35,8 +35,8 @@
#include "lluuid.h" #include "lluuid.h"
#include "llstring.h" #include "llstring.h"
#include "llmemtype.h"
#include "llthread.h" #include "llthread.h"
#include "llmemtype.h"
#include "aithreadsafe.h" #include "aithreadsafe.h"
const S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2 const S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2

View File

@@ -32,7 +32,7 @@
#ifndef LL_LLPNGWRAPPER_H #ifndef LL_LLPNGWRAPPER_H
#define LL_LLPNGWRAPPER_H #define LL_LLPNGWRAPPER_H
#include "png.h" #include "libpng15/png.h"
#include "llimage.h" #include "llimage.h"
class LLPngWrapper class LLPngWrapper

View File

@@ -51,7 +51,7 @@ const S32 PARCEL_UNIT_AREA = 16;
const F32 PARCEL_HEIGHT = 50.f; const F32 PARCEL_HEIGHT = 50.f;
//Height above ground which parcel boundries exist for explicitly banned avatars //Height above ground which parcel boundries exist for explicitly banned avatars
const F32 BAN_HEIGHT = 768.f; const F32 BAN_HEIGHT = 5000.f;
// Maximum number of entries in an access list // Maximum number of entries in an access list
const S32 PARCEL_MAX_ACCESS_LIST = 300; const S32 PARCEL_MAX_ACCESS_LIST = 300;
@@ -260,7 +260,7 @@ public:
void setMediaURLResetTimer(F32 time); void setMediaURLResetTimer(F32 time);
virtual void setLocalID(S32 local_id); virtual void setLocalID(S32 local_id);
// blow away all the extra crap lurking in parcels, including urls, access lists, etc // blow away all the extra stuff lurking in parcels, including urls, access lists, etc
void clearParcel(); void clearParcel();
// This value is not persisted out to the parcel file, it is only // This value is not persisted out to the parcel file, it is only
@@ -686,6 +686,7 @@ public:
std::map<LLUUID,LLAccessEntry> mBanList; std::map<LLUUID,LLAccessEntry> mBanList;
std::map<LLUUID,LLAccessEntry> mTempBanList; std::map<LLUUID,LLAccessEntry> mTempBanList;
std::map<LLUUID,LLAccessEntry> mTempAccessList; std::map<LLUUID,LLAccessEntry> mTempAccessList;
}; };

View File

@@ -32,9 +32,6 @@
#ifndef LL_LLPERMISSIONSFLAGS_H #ifndef LL_LLPERMISSIONSFLAGS_H
#define LL_LLPERMISSIONSFLAGS_H #define LL_LLPERMISSIONSFLAGS_H
// llpermissionsflags.h
// Copyright 2002, Linden Research, Inc.
//
// Flags for various permissions bits. // Flags for various permissions bits.
// Shared between viewer and simulator. // Shared between viewer and simulator.

View File

@@ -74,6 +74,7 @@ const S32 TRANS_CLASSIFIED_RENEW = 2005;
// automatically end up in the list below :-( // automatically end up in the list below :-(
// So make sure you check the transaction_description table // So make sure you check the transaction_description table
const S32 TRANS_RECURRING_GENERIC = 2100; const S32 TRANS_RECURRING_GENERIC = 2100;
// Codes 3000-3999 reserved for inventory transactions // Codes 3000-3999 reserved for inventory transactions
const S32 TRANS_GIVE_INVENTORY = 3000; const S32 TRANS_GIVE_INVENTORY = 3000;

View File

@@ -39,7 +39,6 @@
#include "llapr.h" #include "llapr.h"
#include "llareslistener.h" #include "llareslistener.h"
#include "llscopedvolatileaprpool.h"
#if defined(LL_WINDOWS) #if defined(LL_WINDOWS)
#pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally #pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally
@@ -469,6 +468,7 @@ bool LLAres::process(U64 timeout)
ares_socket_t socks[ARES_GETSOCK_MAXNUM]; ares_socket_t socks[ARES_GETSOCK_MAXNUM];
apr_pollfd_t aprFds[ARES_GETSOCK_MAXNUM]; apr_pollfd_t aprFds[ARES_GETSOCK_MAXNUM];
apr_int32_t nsds = 0; apr_int32_t nsds = 0;
apr_status_t status;
int nactive = 0; int nactive = 0;
int bitmask; int bitmask;
@@ -479,8 +479,6 @@ bool LLAres::process(U64 timeout)
return nsds > 0; return nsds > 0;
} }
LLScopedVolatileAPRPool scoped_pool;
for (int i = 0; i < ARES_GETSOCK_MAXNUM; i++) for (int i = 0; i < ARES_GETSOCK_MAXNUM; i++)
{ {
if (ARES_GETSOCK_READABLE(bitmask, i)) if (ARES_GETSOCK_READABLE(bitmask, i))
@@ -496,7 +494,7 @@ bool LLAres::process(U64 timeout)
apr_socket_t *aprSock = NULL; apr_socket_t *aprSock = NULL;
apr_status_t status = apr_os_sock_put(&aprSock, (apr_os_sock_t *) &socks[i], scoped_pool); status = apr_os_sock_put(&aprSock, (apr_os_sock_t *) &socks[i], LLAPRRootPool::get()());
if (status != APR_SUCCESS) if (status != APR_SUCCESS)
{ {
ll_apr_warn_status(status); ll_apr_warn_status(status);
@@ -505,7 +503,7 @@ bool LLAres::process(U64 timeout)
aprFds[nactive].desc.s = aprSock; aprFds[nactive].desc.s = aprSock;
aprFds[nactive].desc_type = APR_POLL_SOCKET; aprFds[nactive].desc_type = APR_POLL_SOCKET;
aprFds[nactive].p = scoped_pool; aprFds[nactive].p = LLAPRRootPool::get()();
aprFds[nactive].rtnevents = 0; aprFds[nactive].rtnevents = 0;
aprFds[nactive].client_data = &socks[i]; aprFds[nactive].client_data = &socks[i];
@@ -514,7 +512,7 @@ bool LLAres::process(U64 timeout)
if (nactive > 0) if (nactive > 0)
{ {
apr_status_t status = apr_poll(aprFds, nactive, &nsds, timeout); status = apr_poll(aprFds, nactive, &nsds, timeout);
if (status != APR_SUCCESS && status != APR_TIMEUP) if (status != APR_SUCCESS && status != APR_TIMEUP)
{ {

View File

@@ -28,7 +28,6 @@
#include "linden_common.h" #include "linden_common.h"
#include "llbuffer.h" #include "llbuffer.h"
#include <iterator>
#include "llmath.h" #include "llmath.h"
#include "llmemtype.h" #include "llmemtype.h"

File diff suppressed because it is too large Load Diff

View File

@@ -42,11 +42,8 @@
#include "lliopipe.h" #include "lliopipe.h"
#include "llsd.h" #include "llsd.h"
#include "llthread.h" #include "llthread.h"
#include "llqueuedthread.h"
#include "llframetimer.h"
class LLMutex; class LLMutex;
class LLCurlThread;
// For whatever reason, this is not typedef'd in curl.h // For whatever reason, this is not typedef'd in curl.h
typedef size_t (*curl_header_callback)(void *ptr, size_t size, size_t nmemb, void *stream); typedef size_t (*curl_header_callback)(void *ptr, size_t size, size_t nmemb, void *stream);
@@ -59,6 +56,8 @@ public:
class Easy; class Easy;
class Multi; class Multi;
static bool sMultiThreaded;
struct TransferInfo struct TransferInfo
{ {
TransferInfo() : mSizeDownload(0.0), mTotalTime(0.0), mSpeedDownload(0.0) {} TransferInfo() : mSizeDownload(0.0), mTotalTime(0.0), mSpeedDownload(0.0) {}
@@ -125,7 +124,6 @@ public:
{ {
return false; return false;
} }
public: /* but not really -- don't touch this */ public: /* but not really -- don't touch this */
U32 mReferenceCount; U32 mReferenceCount;
@@ -163,7 +161,7 @@ public:
/** /**
* @ brief Initialize LLCurl class * @ brief Initialize LLCurl class
*/ */
static void initClass(F32 curl_reuest_timeout = 120.f, S32 max_number_handles = 256, bool multi_threaded = false); static void initClass(bool multi_threaded = false);
/** /**
* @ brief Cleanup LLCurl class * @ brief Cleanup LLCurl class
@@ -182,25 +180,10 @@ public:
static void ssl_locking_callback(int mode, int type, const char *file, int line); static void ssl_locking_callback(int mode, int type, const char *file, int line);
static unsigned long ssl_thread_id(void); static unsigned long ssl_thread_id(void);
static LLCurlThread* getCurlThread() { return sCurlThread ;}
static CURLM* newMultiHandle() ;
static CURLMcode deleteMultiHandle(CURLM* handle) ;
static CURL* newEasyHandle() ;
static void deleteEasyHandle(CURL* handle) ;
private: private:
static std::string sCAPath; static std::string sCAPath;
static std::string sCAFile; static std::string sCAFile;
static const unsigned int MAX_REDIRECTS; static const unsigned int MAX_REDIRECTS;
static LLCurlThread* sCurlThread;
static LLMutex* sHandleMutexp ;
static S32 sTotalHandles ;
static S32 sMaxHandles;
public:
static bool sNotQuitting;
static F32 sCurlRequestTimeOut;
}; };
class LLCurl::Easy class LLCurl::Easy
@@ -223,7 +206,7 @@ public:
// These assume the setter does not free value! // These assume the setter does not free value!
void setopt(CURLoption option, void* value); void setopt(CURLoption option, void* value);
void setopt(CURLoption option, char* value); void setopt(CURLoption option, char* value);
// Copies the string so that it is guaranteed to stick around // Copies the string so that it is gauranteed to stick around
void setoptString(CURLoption option, const std::string& value); void setoptString(CURLoption option, const std::string& value);
void slist_append(const char* str); void slist_append(const char* str);
@@ -232,7 +215,7 @@ public:
U32 report(CURLcode); U32 report(CURLcode);
void getTransferInfo(LLCurl::TransferInfo* info); void getTransferInfo(LLCurl::TransferInfo* info);
void prepRequest(const std::string& url, const std::vector<std::string>& headers, LLCurl::ResponderPtr, S32 time_out = 0, bool post = false); void prepRequest(const std::string& url, const std::vector<std::string>& headers, ResponderPtr, S32 time_out = 0, bool post = false);
const char* getErrorBuffer(); const char* getErrorBuffer();
@@ -263,126 +246,69 @@ private:
// Note: char*'s not strings since we pass pointers to curl // Note: char*'s not strings since we pass pointers to curl
std::vector<char*> mStrings; std::vector<char*> mStrings;
LLCurl::ResponderPtr mResponder; ResponderPtr mResponder;
static std::set<CURL*> sFreeHandles; static std::set<CURL*> sFreeHandles;
static std::set<CURL*> sActiveHandles; static std::set<CURL*> sActiveHandles;
static LLMutex* sHandleMutexp ; static LLMutex* sHandleMutex;
static LLMutex* sMultiMutex;
}; };
class LLCurl::Multi class LLCurl::Multi : public LLThread
{ {
LOG_CLASS(Multi); LOG_CLASS(Multi);
friend class LLCurlThread ;
private:
~Multi();
void markDead() ;
bool doPerform();
public: public:
typedef enum typedef enum
{ {
STATE_READY=0, PERFORM_STATE_READY=0,
STATE_PERFORMING=1, PERFORM_STATE_PERFORMING=1,
STATE_COMPLETED=2 PERFORM_STATE_COMPLETED=2
} ePerformState; } ePerformState;
Multi(F32 idle_time_out = 0.f); Multi();
~Multi();
LLCurl::Easy* allocEasy(); Easy* allocEasy();
bool addEasy(LLCurl::Easy* easy); bool addEasy(Easy* easy);
void removeEasy(LLCurl::Easy* easy);
void lock() ; void removeEasy(Easy* easy);
void unlock() ;
void setState(ePerformState state) ;
ePerformState getState() ;
bool isCompleted() ;
bool isValid() {return mCurlMultiHandle != NULL && mValid;}
bool isDead() {return mDead;}
bool waitToComplete() ;
S32 process(); S32 process();
void perform();
void doPerform();
virtual void run();
CURLMsg* info_read(S32* msgs_in_queue); CURLMsg* info_read(S32* msgs_in_queue);
S32 mQueued; S32 mQueued;
S32 mErrorCount; S32 mErrorCount;
S32 mPerformState;
LLCondition* mSignal;
bool mQuitting;
bool mThreaded;
private: private:
void easyFree(LLCurl::Easy*); void easyFree(Easy*);
void cleanup(bool deleted = false);
CURLM* mCurlMultiHandle; CURLM* mCurlMultiHandle;
typedef std::set<LLCurl::Easy*> easy_active_list_t; typedef std::set<Easy*> easy_active_list_t;
easy_active_list_t mEasyActiveList; easy_active_list_t mEasyActiveList;
typedef std::map<CURL*, LLCurl::Easy*> easy_active_map_t; typedef std::map<CURL*, Easy*> easy_active_map_t;
easy_active_map_t mEasyActiveMap; easy_active_map_t mEasyActiveMap;
typedef std::set<LLCurl::Easy*> easy_free_list_t; typedef std::set<Easy*> easy_free_list_t;
easy_free_list_t mEasyFreeList; easy_free_list_t mEasyFreeList;
LLQueuedThread::handle_t mHandle ;
ePerformState mState;
BOOL mDead ;
BOOL mValid ;
LLMutex* mMutexp ;
LLMutex* mDeletionMutexp ;
LLMutex* mEasyMutexp ;
LLFrameTimer mIdleTimer ;
F32 mIdleTimeOut;
}; };
class LLCurlThread : public LLQueuedThread namespace boost
{ {
public:
class CurlRequest : public LLQueuedThread::QueuedRequest
{
protected:
virtual ~CurlRequest(); // use deleteRequest()
public:
CurlRequest(handle_t handle, LLCurl::Multi* multi, LLCurlThread* curl_thread);
/*virtual*/ bool processRequest();
/*virtual*/ void finishRequest(bool completed);
private:
// input
LLCurl::Multi* mMulti;
LLCurlThread* mCurlThread;
};
friend class CurlRequest;
public:
LLCurlThread(bool threaded = true) ;
virtual ~LLCurlThread() ;
S32 update(F32 max_time_ms);
void addMulti(LLCurl::Multi* multi) ;
void killMulti(LLCurl::Multi* multi) ;
private:
bool doMultiPerform(LLCurl::Multi* multi) ;
void deleteMulti(LLCurl::Multi* multi) ;
void cleanupMulti(LLCurl::Multi* multi) ;
} ;
//namespace boost
//{
void intrusive_ptr_add_ref(LLCurl::Responder* p); void intrusive_ptr_add_ref(LLCurl::Responder* p);
void intrusive_ptr_release(LLCurl::Responder* p); void intrusive_ptr_release(LLCurl::Responder* p);
//}; };
class LLCurlRequest class LLCurlRequest
@@ -412,6 +338,7 @@ private:
LLCurl::Multi* mActiveMulti; LLCurl::Multi* mActiveMulti;
S32 mActiveRequestCount; S32 mActiveRequestCount;
BOOL mProcessing; BOOL mProcessing;
U32 mThreadID; // debug
}; };
class LLCurlEasyRequest class LLCurlEasyRequest
@@ -429,11 +356,9 @@ public:
void slist_append(const char* str); void slist_append(const char* str);
void sendRequest(const std::string& url); void sendRequest(const std::string& url);
void requestComplete(); void requestComplete();
void perform();
bool getResult(CURLcode* result, LLCurl::TransferInfo* info = NULL); bool getResult(CURLcode* result, LLCurl::TransferInfo* info = NULL);
std::string getErrorString(); std::string getErrorString();
bool isCompleted() {return mMulti->isCompleted() ;}
bool wait() { return mMulti->waitToComplete(); }
bool isValid() {return mMulti && mMulti->isValid(); }
LLCurl::Easy* getEasy() const { return mEasy; } LLCurl::Easy* getEasy() const { return mEasy; }

View File

@@ -29,7 +29,6 @@
#include "lldispatcher.h" #include "lldispatcher.h"
#include <algorithm> #include <algorithm>
#include <iterator>
#include "llstl.h" #include "llstl.h"
#include "message.h" #include "message.h"

View File

@@ -80,7 +80,6 @@
#include "llbuffer.h" #include "llbuffer.h"
#include "llbufferstream.h" #include "llbufferstream.h"
#include "llfasttimer.h"
#include "llmemorystream.h" #include "llmemorystream.h"
#include "llsd.h" #include "llsd.h"
#include "llsdserialize.h" #include "llsdserialize.h"

View File

@@ -25,7 +25,7 @@
*/ */
#include "linden_common.h" #include "linden_common.h"
#include <openssl/x509_vfy.h>
#include "llhttpclient.h" #include "llhttpclient.h"
#include "llassetstorage.h" #include "llassetstorage.h"
@@ -40,10 +40,8 @@
#include "message.h" #include "message.h"
#include <curl/curl.h> #include <curl/curl.h>
const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f; const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f;
LLURLRequest::SSLCertVerifyCallback LLHTTPClient::mCertVerifyCallback = NULL; LLURLRequest::SSLCertVerifyCallback LLHTTPClient::mCertVerifyCallback = NULL;
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Responder class moved to LLCurl // Responder class moved to LLCurl
@@ -158,9 +156,9 @@ namespace
if(fstream.is_open()) if(fstream.is_open())
{ {
fstream.seekg(0, std::ios::end); fstream.seekg(0, std::ios::end);
U32 fileSize = fstream.tellg(); U32 fileSize = (U32)fstream.tellg();
fstream.seekg(0, std::ios::beg); fstream.seekg(0, std::ios::beg);
std::vector<char> fileBuffer(fileSize); std::vector<char> fileBuffer(fileSize); //Mem leak fix'd
fstream.read(&fileBuffer[0], fileSize); fstream.read(&fileBuffer[0], fileSize);
ostream.write(&fileBuffer[0], fileSize); ostream.write(&fileBuffer[0], fileSize);
fstream.close(); fstream.close();
@@ -189,11 +187,9 @@ namespace
LLVFile vfile(gVFS, mUUID, mAssetType, LLVFile::READ); LLVFile vfile(gVFS, mUUID, mAssetType, LLVFile::READ);
S32 fileSize = vfile.getSize(); S32 fileSize = vfile.getSize();
U8* fileBuffer; std::vector<U8> fileBuffer(fileSize);
fileBuffer = new U8 [fileSize]; vfile.read(&fileBuffer[0], fileSize);
vfile.read(fileBuffer, fileSize); ostream.write((char*)&fileBuffer[0], fileSize);
ostream.write((char*)fileBuffer, fileSize);
delete [] fileBuffer;
eos = true; eos = true;
return STATUS_DONE; return STATUS_DONE;
} }
@@ -202,7 +198,6 @@ namespace
LLAssetType::EType mAssetType; LLAssetType::EType mAssetType;
}; };
LLPumpIO* theClientPump = NULL; LLPumpIO* theClientPump = NULL;
} }
@@ -217,8 +212,7 @@ static void request(
Injector* body_injector, Injector* body_injector,
LLCurl::ResponderPtr responder, LLCurl::ResponderPtr responder,
const F32 timeout = HTTP_REQUEST_EXPIRY_SECS, const F32 timeout = HTTP_REQUEST_EXPIRY_SECS,
const LLSD& headers = LLSD() const LLSD& headers = LLSD())
)
{ {
if (!LLHTTPClient::hasPump()) if (!LLHTTPClient::hasPump())
{ {
@@ -228,26 +222,12 @@ static void request(
LLPumpIO::chain_t chain; LLPumpIO::chain_t chain;
LLURLRequest* req = new LLURLRequest(method, url); LLURLRequest* req = new LLURLRequest(method, url);
if(!req->isValid())//failed
{
delete req ;
return ;
}
req->setSSLVerifyCallback(LLHTTPClient::getCertVerifyCallback(), (void *)req); req->setSSLVerifyCallback(LLHTTPClient::getCertVerifyCallback(), (void *)req);
// Insert custom headers is the caller sent any
lldebugs << LLURLRequest::actionAsVerb(method) << " " << url << " "
<< headers << llendl;
// Insert custom headers if the caller sent any
if (headers.isMap()) if (headers.isMap())
{ {
if (headers.has("Cookie"))
{
req->allowCookies();
}
LLSD::map_const_iterator iter = headers.beginMap(); LLSD::map_const_iterator iter = headers.beginMap();
LLSD::map_const_iterator end = headers.endMap(); LLSD::map_const_iterator end = headers.endMap();
@@ -429,17 +409,12 @@ static LLSD blocking_request(
{ {
lldebugs << "blockingRequest of " << url << llendl; lldebugs << "blockingRequest of " << url << llendl;
char curl_error_buffer[CURL_ERROR_SIZE] = "\0"; char curl_error_buffer[CURL_ERROR_SIZE] = "\0";
CURL* curlp = LLCurl::newEasyHandle(); CURL* curlp = curl_easy_init();
llassert_always(curlp != NULL) ;
LLHTTPBuffer http_buffer; LLHTTPBuffer http_buffer;
std::string body_str; std::string body_str;
// other request method checks root cert first, we skip? // other request method checks root cert first, we skip?
// Apply configured proxy settings
LLProxy::getInstance()->applyProxySettings(curlp);
// * Set curl handle options // * Set curl handle options
curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts
curl_easy_setopt(curlp, CURLOPT_TIMEOUT, timeout); // seconds, see warning at top of function. curl_easy_setopt(curlp, CURLOPT_TIMEOUT, timeout); // seconds, see warning at top of function.
@@ -525,7 +500,7 @@ static LLSD blocking_request(
} }
// * Cleanup // * Cleanup
LLCurl::deleteEasyHandle(curlp); curl_easy_cleanup(curlp);
return response; return response;
} }
@@ -625,7 +600,6 @@ bool LLHTTPClient::hasPump()
return theClientPump != NULL; return theClientPump != NULL;
} }
//static
LLPumpIO &LLHTTPClient::getPump() LLPumpIO &LLHTTPClient::getPump()
{ {
return *theClientPump; return *theClientPump;

View File

@@ -34,10 +34,11 @@
#include <string> #include <string>
#include <boost/intrusive_ptr.hpp> #include <boost/intrusive_ptr.hpp>
#include "llurlrequest.h"
#include "llassettype.h" #include "llassettype.h"
#include "llcurl.h" #include "llcurl.h"
#include "lliopipe.h" #include "lliopipe.h"
#include "llurlrequest.h"
extern const F32 HTTP_REQUEST_EXPIRY_SECS; extern const F32 HTTP_REQUEST_EXPIRY_SECS;
@@ -55,7 +56,6 @@ public:
typedef LLCurl::Responder Responder; typedef LLCurl::Responder Responder;
typedef LLCurl::ResponderPtr ResponderPtr; typedef LLCurl::ResponderPtr ResponderPtr;
/** @name non-blocking API */ /** @name non-blocking API */
//@{ //@{
static void head( static void head(

View File

@@ -33,7 +33,6 @@
#include "llapr.h" #include "llapr.h"
#include "llbuffer.h" #include "llbuffer.h"
#include "llbufferstream.h" #include "llbufferstream.h"
#include "llfasttimer.h"
#include "llhttpnode.h" #include "llhttpnode.h"
#include "lliopipe.h" #include "lliopipe.h"
#include "lliosocket.h" #include "lliosocket.h"

View File

@@ -32,7 +32,6 @@
#include "llapr.h" #include "llapr.h"
#include "llbuffer.h" #include "llbuffer.h"
#include "llfasttimer.h"
#include "llhost.h" #include "llhost.h"
#include "llmemtype.h" #include "llmemtype.h"
#include "llpumpio.h" #include "llpumpio.h"

View File

@@ -37,6 +37,7 @@
* OS poll indicates it will not block. * OS poll indicates it will not block.
*/ */
#include "llaprpool.h"
#include "lliopipe.h" #include "lliopipe.h"
#include "apr_network_io.h" #include "apr_network_io.h"
#include "llchainio.h" #include "llchainio.h"

View File

@@ -27,8 +27,8 @@
*/ */
#include "linden_common.h" #include "linden_common.h"
#include "llfasttimer.h"
#include "llioutil.h" #include "llioutil.h"
#include "llfasttimer.h"
/** /**
* LLIOFlush * LLIOFlush

View File

@@ -50,7 +50,6 @@
#include "llstring.h" #include "llstring.h"
#include "lluuid.h" #include "lluuid.h"
#include "net.h" #include "net.h"
#include "llaprpool.h"
// //
// constants // constants
@@ -58,7 +57,7 @@
const size_t LL_MAX_KNOWN_GOOD_MAIL_SIZE = 4096; const size_t LL_MAX_KNOWN_GOOD_MAIL_SIZE = 4096;
static bool gMailEnabled = true; static bool gMailEnabled = true;
static LLAPRPool gMailPool; static apr_pool_t* gMailPool;
static apr_sockaddr_t* gSockAddr; static apr_sockaddr_t* gSockAddr;
static apr_socket_t* gMailSocket; static apr_socket_t* gMailSocket;
@@ -83,7 +82,7 @@ bool connect_smtp()
gSockAddr->sa.sin.sin_family, gSockAddr->sa.sin.sin_family,
SOCK_STREAM, SOCK_STREAM,
APR_PROTO_TCP, APR_PROTO_TCP,
gMailPool()); gMailPool);
if(ll_apr_warn_status(status)) return false; if(ll_apr_warn_status(status)) return false;
status = apr_socket_connect(gMailSocket, gSockAddr); status = apr_socket_connect(gMailSocket, gSockAddr);
if(ll_apr_warn_status(status)) if(ll_apr_warn_status(status))
@@ -140,19 +139,19 @@ BOOL LLMail::send(
} }
// static // static
void LLMail::init(const std::string& hostname) void LLMail::init(const std::string& hostname, apr_pool_t* pool)
{ {
gMailSocket = NULL; gMailSocket = NULL;
if (hostname.empty()) if(hostname.empty() || !pool)
{ {
gMailPool = NULL;
gSockAddr = NULL; gSockAddr = NULL;
gMailPool.destroy();
} }
else else
{ {
gMailPool.create(); gMailPool = pool;
// Collect all the information into a sockaddr structure. the // collect all the information into a socaddr sturcture. the
// documentation is a bit unclear, but I either have to // documentation is a bit unclear, but I either have to
// specify APR_UNSPEC or not specify any flags. I am not sure // specify APR_UNSPEC or not specify any flags. I am not sure
// which option is better. // which option is better.
@@ -162,7 +161,7 @@ void LLMail::init(const std::string& hostname)
APR_UNSPEC, APR_UNSPEC,
25, 25,
APR_IPV4_ADDR_OK, APR_IPV4_ADDR_OK,
gMailPool()); gMailPool);
ll_apr_warn_status(status); ll_apr_warn_status(status);
} }
} }

View File

@@ -27,13 +27,15 @@
#ifndef LL_LLMAIL_H #ifndef LL_LLMAIL_H
#define LL_LLMAIL_H #define LL_LLMAIL_H
typedef struct apr_pool_t apr_pool_t;
#include "llsd.h" #include "llsd.h"
class LLMail class LLMail
{ {
public: public:
// if hostname is NULL, then the host is resolved as 'mail' // if hostname is NULL, then the host is resolved as 'mail'
static void init(const std::string& hostname); static void init(const std::string& hostname, apr_pool_t* pool);
// Allow all email transmission to be disabled/enabled. // Allow all email transmission to be disabled/enabled.
static void enable(bool mail_enabled); static void enable(bool mail_enabled);

View File

@@ -388,7 +388,7 @@ bool LLMimeParser::Impl::parseHeaders(
// not to read past limit when we get() the newline. // not to read past limit when we get() the newline.
S32 max_get = llmin((S32)LINE_BUFFER_LENGTH, limit - mScanCount - 1); S32 max_get = llmin((S32)LINE_BUFFER_LENGTH, limit - mScanCount - 1);
istr.getline(mBuffer, max_get, '\r'); istr.getline(mBuffer, max_get, '\r');
mScanCount += istr.gcount(); mScanCount += (S32)istr.gcount();
int c = istr.get(); int c = istr.get();
if(EOF == c) if(EOF == c)
{ {
@@ -496,7 +496,7 @@ void LLMimeParser::Impl::scanPastSeparator(
// past limit when we get() the newline. // past limit when we get() the newline.
S32 max_get = llmin((S32)LINE_BUFFER_LENGTH, limit - mScanCount - 1); S32 max_get = llmin((S32)LINE_BUFFER_LENGTH, limit - mScanCount - 1);
istr.getline(mBuffer, max_get, '\r'); istr.getline(mBuffer, max_get, '\r');
mScanCount += istr.gcount(); mScanCount += (S32)istr.gcount();
if(istr.gcount() >= LINE_BUFFER_LENGTH - 1) if(istr.gcount() >= LINE_BUFFER_LENGTH - 1)
{ {
// that's way too long to be a separator, so ignore it. // that's way too long to be a separator, so ignore it.

View File

@@ -4,25 +4,31 @@
* @date 2004-11-21 * @date 2004-11-21
* @brief Implementation of the i/o pump and related functions. * @brief Implementation of the i/o pump and related functions.
* *
* $LicenseInfo:firstyear=2004&license=viewerlgpl$ * $LicenseInfo:firstyear=2004&license=viewergpl$
*
* Copyright (c) 2004-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code * Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc. * The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
* *
* This library is free software; you can redistribute it and/or * There are special exceptions to the terms and conditions of the GPL as
* modify it under the terms of the GNU Lesser General Public * it is applied to this Source Code. View the full text of the exception
* License as published by the Free Software Foundation; * in the file doc/FLOSS-exception.txt in this software distribution, or
* version 2.1 of the License only. * online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
* *
* This library is distributed in the hope that it will be useful, * By copying, modifying or distributing this software, you acknowledge
* but WITHOUT ANY WARRANTY; without even the implied warranty of * that you have read and understood your obligations described above,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * and agree to abide by those obligations.
* Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* License along with this library; if not, write to the Free Software * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * COMPLETENESS OR PERFORMANCE.
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
@@ -34,11 +40,12 @@
#include "apr_poll.h" #include "apr_poll.h"
#include "llapr.h" #include "llapr.h"
#include "llfasttimer.h"
#include "llmemtype.h" #include "llmemtype.h"
#include "llstl.h" #include "llstl.h"
#include "llstat.h" #include "llstat.h"
#include "llthread.h" #include "llthread.h"
#include "llfasttimer.h"
#include <iterator> //VS2010
// These should not be enabled in production, but they can be // These should not be enabled in production, but they can be
// intensely useful during development for finding certain kinds of // intensely useful during development for finding certain kinds of
@@ -184,21 +191,10 @@ LLPumpIO::LLPumpIO(void) :
LLPumpIO::~LLPumpIO() LLPumpIO::~LLPumpIO()
{ {
LLMemType m1(LLMemType::MTYPE_IO_PUMP); LLMemType m1(LLMemType::MTYPE_IO_PUMP);
#if LL_THREADS_APR cleanup();
if (mChainsMutex) apr_thread_mutex_destroy(mChainsMutex);
if (mCallbackMutex) apr_thread_mutex_destroy(mCallbackMutex);
#endif
mChainsMutex = NULL;
mCallbackMutex = NULL;
if(mPollset)
{
// lldebugs << "cleaning up pollset" << llendl;
apr_pollset_destroy(mPollset);
mPollset = NULL;
}
} }
bool LLPumpIO::addChain(const chain_t& chain, F32 timeout, bool has_curl_request) bool LLPumpIO::addChain(const chain_t& chain, F32 timeout)
{ {
LLMemType m1(LLMemType::MTYPE_IO_PUMP); LLMemType m1(LLMemType::MTYPE_IO_PUMP);
if(chain.empty()) return false; if(chain.empty()) return false;
@@ -207,10 +203,8 @@ bool LLPumpIO::addChain(const chain_t& chain, F32 timeout, bool has_curl_request
LLScopedLock lock(mChainsMutex); LLScopedLock lock(mChainsMutex);
#endif #endif
LLChainInfo info; LLChainInfo info;
info.mHasCurlRequest = has_curl_request;
info.setTimeoutSeconds(timeout); info.setTimeoutSeconds(timeout);
info.mData = LLIOPipe::buffer_ptr_t(new LLBufferArray); info.mData = LLIOPipe::buffer_ptr_t(new LLBufferArray);
info.mData->setThreaded(has_curl_request);
LLLinkInfo link; LLLinkInfo link;
#if LL_DEBUG_PIPE_TYPE_IN_PUMP #if LL_DEBUG_PIPE_TYPE_IN_PUMP
lldebugs << "LLPumpIO::addChain() " << chain[0] << " '" lldebugs << "LLPumpIO::addChain() " << chain[0] << " '"
@@ -444,15 +438,6 @@ void LLPumpIO::pump()
static LLFastTimer::DeclareTimer FTM_PUMP_IO("Pump IO"); static LLFastTimer::DeclareTimer FTM_PUMP_IO("Pump IO");
LLPumpIO::current_chain_t LLPumpIO::removeRunningChain(LLPumpIO::current_chain_t& run_chain)
{
std::for_each(
(*run_chain).mDescriptors.begin(),
(*run_chain).mDescriptors.end(),
ll_delete_apr_pollset_fd_client_data());
return mRunningChains.erase(run_chain);
}
//timeout is in microseconds //timeout is in microseconds
void LLPumpIO::pump(const S32& poll_timeout) void LLPumpIO::pump(const S32& poll_timeout)
{ {
@@ -598,16 +583,10 @@ void LLPumpIO::pump(const S32& poll_timeout)
// << (*run_chain).mChainLinks[0].mPipe // << (*run_chain).mChainLinks[0].mPipe
// << " because we reached the end." << llendl; // << " because we reached the end." << llendl;
#endif #endif
run_chain = removeRunningChain(run_chain); run_chain = mRunningChains.erase(run_chain);
continue; continue;
} }
} }
else if(isChainExpired(*run_chain))
{
run_chain = removeRunningChain(run_chain);
continue;
}
PUMP_DEBUG; PUMP_DEBUG;
if((*run_chain).mLock) if((*run_chain).mLock)
{ {
@@ -715,7 +694,11 @@ void LLPumpIO::pump(const S32& poll_timeout)
PUMP_DEBUG; PUMP_DEBUG;
// This chain is done. Clean up any allocated memory and // This chain is done. Clean up any allocated memory and
// erase the chain info. // erase the chain info.
run_chain = removeRunningChain(run_chain); std::for_each(
(*run_chain).mDescriptors.begin(),
(*run_chain).mDescriptors.end(),
ll_delete_apr_pollset_fd_client_data());
run_chain = mRunningChains.erase(run_chain);
// *NOTE: may not always need to rebuild the pollset. // *NOTE: may not always need to rebuild the pollset.
mRebuildPollset = true; mRebuildPollset = true;
@@ -850,6 +833,22 @@ void LLPumpIO::initialize(void)
apr_thread_mutex_create(&mCallbackMutex, APR_THREAD_MUTEX_UNNESTED, mPool()); apr_thread_mutex_create(&mCallbackMutex, APR_THREAD_MUTEX_UNNESTED, mPool());
#endif #endif
} }
void LLPumpIO::cleanup()
{
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
#if LL_THREADS_APR
if (mChainsMutex) apr_thread_mutex_destroy(mChainsMutex);
if (mCallbackMutex) apr_thread_mutex_destroy(mCallbackMutex);
#endif
mChainsMutex = NULL;
mCallbackMutex = NULL;
if(mPollset)
{
// lldebugs << "cleaning up pollset" << llendl;
apr_pollset_destroy(mPollset);
mPollset = NULL;
}
}
void LLPumpIO::rebuildPollset() void LLPumpIO::rebuildPollset()
{ {
@@ -1084,24 +1083,6 @@ void LLPumpIO::processChain(LLChainInfo& chain)
PUMP_DEBUG; PUMP_DEBUG;
} }
bool LLPumpIO::isChainExpired(LLChainInfo& chain)
{
if(!chain.mHasCurlRequest)
{
return false ;
}
for(links_t::iterator iter = chain.mChainLinks.begin(); iter != chain.mChainLinks.end(); ++iter)
{
if(!(*iter).mPipe->isValid())
{
return true ;
}
}
return false ;
}
bool LLPumpIO::handleChainError( bool LLPumpIO::handleChainError(
LLChainInfo& chain, LLChainInfo& chain,
LLIOPipe::EStatus error) LLIOPipe::EStatus error)
@@ -1143,9 +1124,6 @@ bool LLPumpIO::handleChainError(
#endif #endif
keep_going = false; keep_going = false;
break; break;
case LLIOPipe::STATUS_EXPIRED:
keep_going = false;
break ;
default: default:
if(LLIOPipe::isSuccess(error)) if(LLIOPipe::isSuccess(error))
{ {
@@ -1168,7 +1146,6 @@ LLPumpIO::LLChainInfo::LLChainInfo() :
mInit(false), mInit(false),
mLock(0), mLock(0),
mEOS(false), mEOS(false),
mHasCurlRequest(false),
mDescriptorsPool(new LLAPRPool(LLThread::tldata().mRootPool)) mDescriptorsPool(new LLAPRPool(LLThread::tldata().mRootPool))
{ {
LLMemType m1(LLMemType::MTYPE_IO_PUMP); LLMemType m1(LLMemType::MTYPE_IO_PUMP);
@@ -1180,9 +1157,7 @@ void LLPumpIO::LLChainInfo::setTimeoutSeconds(F32 timeout)
LLMemType m1(LLMemType::MTYPE_IO_PUMP); LLMemType m1(LLMemType::MTYPE_IO_PUMP);
if(timeout > 0.0f) if(timeout > 0.0f)
{ {
mTimer.start(); mTimer.start(timeout);
mTimer.reset();
mTimer.setTimerExpirySec(timeout);
} }
else else
{ {

View File

@@ -4,25 +4,31 @@
* @date 2004-11-19 * @date 2004-11-19
* @brief Declaration of pump class which manages io chains. * @brief Declaration of pump class which manages io chains.
* *
* $LicenseInfo:firstyear=2004&license=viewerlgpl$ * $LicenseInfo:firstyear=2004&license=viewergpl$
*
* Copyright (c) 2004-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code * Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc. * The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
* *
* This library is free software; you can redistribute it and/or * There are special exceptions to the terms and conditions of the GPL as
* modify it under the terms of the GNU Lesser General Public * it is applied to this Source Code. View the full text of the exception
* License as published by the Free Software Foundation; * in the file doc/FLOSS-exception.txt in this software distribution, or
* version 2.1 of the License only. * online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
* *
* This library is distributed in the hope that it will be useful, * By copying, modifying or distributing this software, you acknowledge
* but WITHOUT ANY WARRANTY; without even the implied warranty of * that you have read and understood your obligations described above,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * and agree to abide by those obligations.
* Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* License along with this library; if not, write to the Free Software * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * COMPLETENESS OR PERFORMANCE.
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
@@ -100,10 +106,9 @@ public:
* @param chain The pipes for the chain * @param chain The pipes for the chain
* @param timeout The number of seconds in the future to * @param timeout The number of seconds in the future to
* expire. Pass in 0.0f to never expire. * expire. Pass in 0.0f to never expire.
* @param has_curl_request The chain contains LLURLRequest if true.
* @return Returns true if anything was added to the pump. * @return Returns true if anything was added to the pump.
*/ */
bool addChain(const chain_t& chain, F32 timeout, bool has_curl_request = false); bool addChain(const chain_t& chain, F32 timeout);
/** /**
* @brief Struct to associate a pipe with it's buffer io indexes. * @brief Struct to associate a pipe with it's buffer io indexes.
@@ -346,13 +351,12 @@ protected:
// basic member data // basic member data
bool mInit; bool mInit;
bool mEOS;
bool mHasCurlRequest;
S32 mLock; S32 mLock;
LLFrameTimer mTimer; LLFrameTimer mTimer;
links_t::iterator mHead; links_t::iterator mHead;
links_t mChainLinks; links_t mChainLinks;
LLIOPipe::buffer_ptr_t mData; LLIOPipe::buffer_ptr_t mData;
bool mEOS;
LLSD mContext; LLSD mContext;
// tracking inside the pump // tracking inside the pump
@@ -393,8 +397,8 @@ protected:
protected: protected:
void initialize(); void initialize();
void cleanup();
current_chain_t removeRunningChain(current_chain_t& chain) ;
/** /**
* @brief Given the internal state of the chains, rebuild the pollset * @brief Given the internal state of the chains, rebuild the pollset
* @see setConditional() * @see setConditional()
@@ -421,9 +425,6 @@ protected:
*/ */
bool handleChainError(LLChainInfo& chain, LLIOPipe::EStatus error); bool handleChainError(LLChainInfo& chain, LLIOPipe::EStatus error);
//if the chain is expired, remove it
bool isChainExpired(LLChainInfo& chain) ;
public: public:
/** /**
* @brief Return number of running chains. * @brief Return number of running chains.

View File

@@ -88,7 +88,7 @@ bool LLSDMessage::httpListener(const LLSD& request)
request, request,
url, "POST", reply, error), url, "POST", reply, error),
LLSD(), // headers LLSD(), // headers
timeout); (F32)timeout);
return false; return false;
} }

View File

@@ -317,7 +317,7 @@ void LLSDMessageBuilder::copyFromMessageData(const LLMsgData& data)
// S64 not supported in LLSD so we just truncate it // S64 not supported in LLSD so we just truncate it
case MVT_S64: case MVT_S64:
addS32(varname, *(S64*)mvci.getData()); addS32(varname, (S32)*(S64*)mvci.getData());
break; break;
case MVT_F32: case MVT_F32:

View File

@@ -32,17 +32,17 @@
#include <algorithm> #include <algorithm>
#include <openssl/x509_vfy.h> #include <openssl/x509_vfy.h>
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include "llcurl.h" #include "llcurl.h"
#include "llfasttimer.h"
#include "llioutil.h" #include "llioutil.h"
#include "llmemtype.h" #include "llmemtype.h"
#include "llproxy.h"
#include "llpumpio.h" #include "llpumpio.h"
#include "llsd.h" #include "llsd.h"
#include "llstring.h" #include "llstring.h"
#include "apr_env.h" #include "apr_env.h"
#include "llapr.h" #include "llapr.h"
#include "llscopedvolatileaprpool.h" #include "llscopedvolatileaprpool.h"
#include "llfasttimer.h"
static const U32 HTTP_STATUS_PIPE_ERROR = 499; static const U32 HTTP_STATUS_PIPE_ERROR = 499;
/** /**
@@ -66,7 +66,7 @@ public:
~LLURLRequestDetail(); ~LLURLRequestDetail();
std::string mURL; std::string mURL;
LLCurlEasyRequest* mCurlRequest; LLCurlEasyRequest* mCurlRequest;
LLIOPipe::buffer_ptr_t mResponseBuffer; LLBufferArray* mResponseBuffer;
LLChannelDescriptors mChannels; LLChannelDescriptors mChannels;
U8* mLastRead; U8* mLastRead;
U32 mBodyLimit; U32 mBodyLimit;
@@ -77,26 +77,21 @@ public:
LLURLRequestDetail::LLURLRequestDetail() : LLURLRequestDetail::LLURLRequestDetail() :
mCurlRequest(NULL), mCurlRequest(NULL),
mResponseBuffer(NULL),
mLastRead(NULL), mLastRead(NULL),
mBodyLimit(0), mBodyLimit(0),
mByteAccumulator(0), mByteAccumulator(0),
mIsBodyLimitSet(false), mIsBodyLimitSet(false)
mSSLVerifyCallback(NULL)
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
mCurlRequest = new LLCurlEasyRequest(); mCurlRequest = new LLCurlEasyRequest();
if(!mCurlRequest->isValid()) //failed.
{
delete mCurlRequest ;
mCurlRequest = NULL ;
}
} }
LLURLRequestDetail::~LLURLRequestDetail() LLURLRequestDetail::~LLURLRequestDetail()
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
delete mCurlRequest; delete mCurlRequest;
mResponseBuffer = NULL;
mLastRead = NULL; mLastRead = NULL;
} }
@@ -128,7 +123,6 @@ CURLcode LLURLRequest::_sslCtxCallback(CURL * curl, void *sslctx, void *param)
SSL_CTX_set_cert_verify_callback(ctx, req->mDetail->mSSLVerifyCallback, (void *)req); SSL_CTX_set_cert_verify_callback(ctx, req->mDetail->mSSLVerifyCallback, (void *)req);
// the calls are void // the calls are void
return CURLE_OK; return CURLE_OK;
} }
/** /**
@@ -189,7 +183,6 @@ std::string LLURLRequest::getURL() const
{ {
return mDetail->mURL; return mDetail->mURL;
} }
void LLURLRequest::addHeader(const char* header) void LLURLRequest::addHeader(const char* header)
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
@@ -240,9 +233,9 @@ void LLURLRequest::useProxy(bool use_proxy)
} }
} }
lldebugs << "use_proxy = " << (use_proxy?'Y':'N') << ", env_proxy = \"" << env_proxy << "\"" << llendl; LL_DEBUGS("Proxy") << "use_proxy = " << (use_proxy?'Y':'N') << ", env_proxy = " << (!env_proxy.empty() ? env_proxy : "(null)") << LL_ENDL;
if (use_proxy) if (use_proxy && !env_proxy.empty())
{ {
mDetail->mCurlRequest->setoptString(CURLOPT_PROXY, env_proxy); mDetail->mCurlRequest->setoptString(CURLOPT_PROXY, env_proxy);
} }
@@ -262,24 +255,12 @@ void LLURLRequest::allowCookies()
mDetail->mCurlRequest->setoptString(CURLOPT_COOKIEFILE, ""); mDetail->mCurlRequest->setoptString(CURLOPT_COOKIEFILE, "");
} }
//virtual
bool LLURLRequest::isValid()
{
return mDetail->mCurlRequest && mDetail->mCurlRequest->isValid();
}
// virtual // virtual
LLIOPipe::EStatus LLURLRequest::handleError( LLIOPipe::EStatus LLURLRequest::handleError(
LLIOPipe::EStatus status, LLIOPipe::EStatus status,
LLPumpIO* pump) LLPumpIO* pump)
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
if(!isValid())
{
return STATUS_EXPIRED ;
}
if(mCompletionCallback && pump) if(mCompletionCallback && pump)
{ {
LLURLRequestComplete* complete = NULL; LLURLRequestComplete* complete = NULL;
@@ -309,6 +290,7 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
//llinfos << "LLURLRequest::process_impl()" << llendl; //llinfos << "LLURLRequest::process_impl()" << llendl;
if (!buffer) return STATUS_ERROR; if (!buffer) return STATUS_ERROR;
if (!mDetail) return STATUS_ERROR; //Seems to happen on occasion. Need to hunt down why.
// we're still waiting or prcessing, check how many // we're still waiting or prcessing, check how many
// bytes we have accumulated. // bytes we have accumulated.
@@ -348,7 +330,7 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
// *FIX: bit of a hack, but it should work. The configure and // *FIX: bit of a hack, but it should work. The configure and
// callback method expect this information to be ready. // callback method expect this information to be ready.
mDetail->mResponseBuffer = buffer; mDetail->mResponseBuffer = buffer.get();
mDetail->mChannels = channels; mDetail->mChannels = channels;
if(!configure()) if(!configure())
{ {
@@ -367,10 +349,7 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
static LLFastTimer::DeclareTimer FTM_URL_PERFORM("Perform"); static LLFastTimer::DeclareTimer FTM_URL_PERFORM("Perform");
{ {
LLFastTimer t(FTM_URL_PERFORM); LLFastTimer t(FTM_URL_PERFORM);
if(!mDetail->mCurlRequest->wait()) mDetail->mCurlRequest->perform();
{
return status ;
}
} }
while(1) while(1)
@@ -465,12 +444,6 @@ void LLURLRequest::initialize()
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
mState = STATE_INITIALIZED; mState = STATE_INITIALIZED;
mDetail = new LLURLRequestDetail; mDetail = new LLURLRequestDetail;
if(!isValid())
{
return ;
}
mDetail->mCurlRequest->setopt(CURLOPT_NOSIGNAL, 1); mDetail->mCurlRequest->setopt(CURLOPT_NOSIGNAL, 1);
mDetail->mCurlRequest->setWriteCallback(&downCallback, (void*)this); mDetail->mCurlRequest->setWriteCallback(&downCallback, (void*)this);
mDetail->mCurlRequest->setReadCallback(&upCallback, (void*)this); mDetail->mCurlRequest->setReadCallback(&upCallback, (void*)this);

View File

@@ -40,7 +40,6 @@
#include "llerror.h" #include "llerror.h"
#include "llcurl.h" #include "llcurl.h"
extern const std::string CONTEXT_REQUEST; extern const std::string CONTEXT_REQUEST;
extern const std::string CONTEXT_DEST_URI_SD_LABEL; extern const std::string CONTEXT_DEST_URI_SD_LABEL;
extern const std::string CONTEXT_RESPONSE; extern const std::string CONTEXT_RESPONSE;
@@ -145,7 +144,6 @@ public:
*/ */
void setSSLVerifyCallback(SSLCertVerifyCallback callback, void * param); void setSSLVerifyCallback(SSLCertVerifyCallback callback, void * param);
/** /**
* @brief Return at most size bytes of body. * @brief Return at most size bytes of body.
* *
@@ -190,15 +188,12 @@ public:
*/ */
void allowCookies(); void allowCookies();
/*virtual*/ bool isValid() ;
public: public:
/** /**
* @brief Give this pipe a chance to handle a generated error * @brief Give this pipe a chance to handle a generated error
*/ */
virtual EStatus handleError(EStatus status, LLPumpIO* pump); virtual EStatus handleError(EStatus status, LLPumpIO* pump);
protected: protected:
/** /**
* @brief Process the data in buffer * @brief Process the data in buffer

View File

@@ -29,6 +29,7 @@
#include "message.h" #include "message.h"
#include "lltimer.h" #include "lltimer.h"
#include "llextendedstatus.h"
const S32 LL_XFER_LARGE_PAYLOAD = 7680; const S32 LL_XFER_LARGE_PAYLOAD = 7680;

View File

@@ -97,10 +97,8 @@ std::string get_shared_secret();
class LLMessagePollInfo class LLMessagePollInfo
{ {
public: public:
LLMessagePollInfo(void) : mPool(LLThread::tldata().mRootPool) { }
apr_socket_t *mAPRSocketp; apr_socket_t *mAPRSocketp;
apr_pollfd_t mPollFD; apr_pollfd_t mPollFD;
LLAPRPool mPool;
}; };
namespace namespace
@@ -289,13 +287,15 @@ LLMessageSystem::LLMessageSystem(const std::string& filename, U32 port,
} }
// LL_DEBUGS("Messaging") << << "*** port: " << mPort << llendl; // LL_DEBUGS("Messaging") << << "*** port: " << mPort << llendl;
mPollInfop = new LLMessagePollInfo; //
// Create the data structure that we can poll on
//
apr_socket_t *aprSocketp = NULL; apr_socket_t *aprSocketp = NULL;
apr_os_sock_put(&aprSocketp, (apr_os_sock_t*)&mSocket, mPollInfop->mPool()); apr_os_sock_put(&aprSocketp, (apr_os_sock_t*)&mSocket, LLAPRRootPool::get()());
mPollInfop = new LLMessagePollInfo;
mPollInfop->mAPRSocketp = aprSocketp; mPollInfop->mAPRSocketp = aprSocketp;
mPollInfop->mPollFD.p = mPollInfop->mPool(); mPollInfop->mPollFD.p = LLAPRRootPool::get()();
mPollInfop->mPollFD.desc_type = APR_POLL_SOCKET; mPollInfop->mPollFD.desc_type = APR_POLL_SOCKET;
mPollInfop->mPollFD.reqevents = APR_POLLIN; mPollInfop->mPollFD.reqevents = APR_POLLIN;
mPollInfop->mPollFD.rtnevents = 0; mPollInfop->mPollFD.rtnevents = 0;
@@ -3142,7 +3142,7 @@ bool LLMessageSystem::generateDigestForWindowAndUUIDs(char* digest, const S32 wi
LL_ERRS("Messaging") << "Trying to generate complex digest on a machine without a shared secret!" << llendl; LL_ERRS("Messaging") << "Trying to generate complex digest on a machine without a shared secret!" << llendl;
} }
U32 now = time(NULL); U32 now = (U32)time(NULL);
now /= window; now /= window;
@@ -3162,7 +3162,7 @@ bool LLMessageSystem::isMatchingDigestForWindowAndUUIDs(const char* digest, cons
} }
char our_digest[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */ char our_digest[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */
U32 now = time(NULL); U32 now = (U32)time(NULL);
now /= window; now /= window;
@@ -3208,7 +3208,7 @@ bool LLMessageSystem::generateDigestForWindow(char* digest, const S32 window) co
LL_ERRS("Messaging") << "Trying to generate simple digest on a machine without a shared secret!" << llendl; LL_ERRS("Messaging") << "Trying to generate simple digest on a machine without a shared secret!" << llendl;
} }
U32 now = time(NULL); U32 now = (U32)time(NULL);
now /= window; now /= window;

View File

@@ -55,7 +55,6 @@ set_target_properties(SLPlugin
) )
target_link_libraries(SLPlugin target_link_libraries(SLPlugin
${GOOGLE_PERFTOOLS_LIBRARIES}
${LLPLUGIN_LIBRARIES} ${LLPLUGIN_LIBRARIES}
${LLMESSAGE_LIBRARIES} ${LLMESSAGE_LIBRARIES}
${LLCOMMON_LIBRARIES} ${LLCOMMON_LIBRARIES}
@@ -82,11 +81,4 @@ if (DARWIN)
) )
endif (DARWIN) endif (DARWIN)
if (WINDOWS)
set_target_properties(SLPlugin
PROPERTIES
LINK_FLAGS "${GOOGLE_PERFTOOLS_LINKER_FLAGS}"
)
endif (WINDOWS)
#ll_deploy_sharedlibs_command(SLPlugin) #ll_deploy_sharedlibs_command(SLPlugin)

View File

@@ -17,6 +17,7 @@ include_directories(
set(llprimitive_SOURCE_FILES set(llprimitive_SOURCE_FILES
llmaterialtable.cpp llmaterialtable.cpp
llmediaentry.cpp
llmodel.cpp llmodel.cpp
llprimitive.cpp llprimitive.cpp
llprimtexturelist.cpp llprimtexturelist.cpp

View File

@@ -137,6 +137,7 @@ void LLMaterialTable::initTableTransNames(std::map<std::string, std::string> nam
infop->mName = namemap[name]; infop->mName = namemap[name];
} }
} }
void LLMaterialTable::initBasicTable() void LLMaterialTable::initBasicTable()
{ {
// *TODO: Translate // *TODO: Translate

View File

@@ -0,0 +1,596 @@
/**
* @file llmediaentry.cpp
* @brief This is a single instance of media data related to the face of a prim
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "llmediaentry.h"
#include "lllslconstants.h"
#include <boost/regex.hpp>
// LLSD key defines
// DO NOT REORDER OR REMOVE THESE!
// Some LLSD keys. Do not change!
#define MEDIA_ALT_IMAGE_ENABLE_KEY_STR "alt_image_enable"
#define MEDIA_CONTROLS_KEY_STR "controls"
#define MEDIA_CURRENT_URL_KEY_STR "current_url"
#define MEDIA_HOME_URL_KEY_STR "home_url"
#define MEDIA_AUTO_LOOP_KEY_STR "auto_loop"
#define MEDIA_AUTO_PLAY_KEY_STR "auto_play"
#define MEDIA_AUTO_SCALE_KEY_STR "auto_scale"
#define MEDIA_AUTO_ZOOM_KEY_STR "auto_zoom"
#define MEDIA_FIRST_CLICK_INTERACT_KEY_STR "first_click_interact"
#define MEDIA_WIDTH_PIXELS_KEY_STR "width_pixels"
#define MEDIA_HEIGHT_PIXELS_KEY_STR "height_pixels"
// "security" fields
#define MEDIA_WHITELIST_ENABLE_KEY_STR "whitelist_enable"
#define MEDIA_WHITELIST_KEY_STR "whitelist"
// "permissions" fields
#define MEDIA_PERMS_INTERACT_KEY_STR "perms_interact"
#define MEDIA_PERMS_CONTROL_KEY_STR "perms_control"
// "general" fields
const char* LLMediaEntry::ALT_IMAGE_ENABLE_KEY = MEDIA_ALT_IMAGE_ENABLE_KEY_STR;
const char* LLMediaEntry::CONTROLS_KEY = MEDIA_CONTROLS_KEY_STR;
const char* LLMediaEntry::CURRENT_URL_KEY = MEDIA_CURRENT_URL_KEY_STR;
const char* LLMediaEntry::HOME_URL_KEY = MEDIA_HOME_URL_KEY_STR;
const char* LLMediaEntry::AUTO_LOOP_KEY = MEDIA_AUTO_LOOP_KEY_STR;
const char* LLMediaEntry::AUTO_PLAY_KEY = MEDIA_AUTO_PLAY_KEY_STR;
const char* LLMediaEntry::AUTO_SCALE_KEY = MEDIA_AUTO_SCALE_KEY_STR;
const char* LLMediaEntry::AUTO_ZOOM_KEY = MEDIA_AUTO_ZOOM_KEY_STR;
const char* LLMediaEntry::FIRST_CLICK_INTERACT_KEY = MEDIA_FIRST_CLICK_INTERACT_KEY_STR;
const char* LLMediaEntry::WIDTH_PIXELS_KEY = MEDIA_WIDTH_PIXELS_KEY_STR;
const char* LLMediaEntry::HEIGHT_PIXELS_KEY = MEDIA_HEIGHT_PIXELS_KEY_STR;
// "security" fields
const char* LLMediaEntry::WHITELIST_ENABLE_KEY = MEDIA_WHITELIST_ENABLE_KEY_STR;
const char* LLMediaEntry::WHITELIST_KEY = MEDIA_WHITELIST_KEY_STR;
// "permissions" fields
const char* LLMediaEntry::PERMS_INTERACT_KEY = MEDIA_PERMS_INTERACT_KEY_STR;
const char* LLMediaEntry::PERMS_CONTROL_KEY = MEDIA_PERMS_CONTROL_KEY_STR;
#define DEFAULT_URL_PREFIX "http://"
// Constructor(s)
LLMediaEntry::LLMediaEntry() :
mAltImageEnable(false),
mControls(STANDARD),
mCurrentURL(""),
mHomeURL(""),
mAutoLoop(false),
mAutoPlay(false),
mAutoScale(false),
mAutoZoom(false),
mFirstClickInteract(false),
mWidthPixels(0),
mHeightPixels(0),
mWhiteListEnable(false),
// mWhiteList
mPermsInteract(PERM_ALL),
mPermsControl(PERM_ALL),
mMediaIDp(NULL)
{
}
LLMediaEntry::LLMediaEntry(const LLMediaEntry &rhs) :
mMediaIDp(NULL)
{
// "general" fields
mAltImageEnable = rhs.mAltImageEnable;
mControls = rhs.mControls;
mCurrentURL = rhs.mCurrentURL;
mHomeURL = rhs.mHomeURL;
mAutoLoop = rhs.mAutoLoop;
mAutoPlay = rhs.mAutoPlay;
mAutoScale = rhs.mAutoScale;
mAutoZoom = rhs.mAutoZoom;
mFirstClickInteract = rhs.mFirstClickInteract;
mWidthPixels = rhs.mWidthPixels;
mHeightPixels = rhs.mHeightPixels;
// "security" fields
mWhiteListEnable = rhs.mWhiteListEnable;
mWhiteList = rhs.mWhiteList;
// "permissions" fields
mPermsInteract = rhs.mPermsInteract;
mPermsControl = rhs.mPermsControl;
}
LLMediaEntry::~LLMediaEntry()
{
if (NULL != mMediaIDp)
{
delete mMediaIDp;
}
}
LLSD LLMediaEntry::asLLSD() const
{
LLSD sd;
asLLSD(sd);
return sd;
}
//
// LLSD functions
//
void LLMediaEntry::asLLSD(LLSD& sd) const
{
// "general" fields
sd[ALT_IMAGE_ENABLE_KEY] = mAltImageEnable;
sd[CONTROLS_KEY] = (LLSD::Integer)mControls;
sd[CURRENT_URL_KEY] = mCurrentURL;
sd[HOME_URL_KEY] = mHomeURL;
sd[AUTO_LOOP_KEY] = mAutoLoop;
sd[AUTO_PLAY_KEY] = mAutoPlay;
sd[AUTO_SCALE_KEY] = mAutoScale;
sd[AUTO_ZOOM_KEY] = mAutoZoom;
sd[FIRST_CLICK_INTERACT_KEY] = mFirstClickInteract;
sd[WIDTH_PIXELS_KEY] = mWidthPixels;
sd[HEIGHT_PIXELS_KEY] = mHeightPixels;
// "security" fields
sd[WHITELIST_ENABLE_KEY] = mWhiteListEnable;
sd.erase(WHITELIST_KEY);
for (U32 i=0; i<mWhiteList.size(); i++)
{
sd[WHITELIST_KEY].append(mWhiteList[i]);
}
// "permissions" fields
sd[PERMS_INTERACT_KEY] = mPermsInteract;
sd[PERMS_CONTROL_KEY] = mPermsControl;
}
// static
bool LLMediaEntry::checkLLSD(const LLSD& sd)
{
if (sd.isUndefined()) return true;
LLMediaEntry temp;
return temp.fromLLSDInternal(sd, true);
}
void LLMediaEntry::fromLLSD(const LLSD& sd)
{
(void)fromLLSDInternal(sd, true);
}
void LLMediaEntry::mergeFromLLSD(const LLSD& sd)
{
(void)fromLLSDInternal(sd, false);
}
// *NOTE: returns true if NO failures to set occurred, false otherwise.
// However, be aware that if a failure to set does occur, it does
// not stop setting fields from the LLSD!
bool LLMediaEntry::fromLLSDInternal(const LLSD& sd, bool overwrite)
{
// *HACK: we sort of cheat here and assume that status is a
// bit field. We "or" into status and instead of returning
// it, we return whether it finishes off as LSL_STATUS_OK or not.
U32 status = LSL_STATUS_OK;
// "general" fields
if ( overwrite || sd.has(ALT_IMAGE_ENABLE_KEY) )
{
status |= setAltImageEnable( sd[ALT_IMAGE_ENABLE_KEY] );
}
if ( overwrite || sd.has(CONTROLS_KEY) )
{
status |= setControls( (MediaControls)(LLSD::Integer)sd[CONTROLS_KEY] );
}
if ( overwrite || sd.has(CURRENT_URL_KEY) )
{
// Don't check whitelist
status |= setCurrentURLInternal( sd[CURRENT_URL_KEY], false );
}
if ( overwrite || sd.has(HOME_URL_KEY) )
{
status |= setHomeURL( sd[HOME_URL_KEY] );
}
if ( overwrite || sd.has(AUTO_LOOP_KEY) )
{
status |= setAutoLoop( sd[AUTO_LOOP_KEY] );
}
if ( overwrite || sd.has(AUTO_PLAY_KEY) )
{
status |= setAutoPlay( sd[AUTO_PLAY_KEY] );
}
if ( overwrite || sd.has(AUTO_SCALE_KEY) )
{
status |= setAutoScale( sd[AUTO_SCALE_KEY] );
}
if ( overwrite || sd.has(AUTO_ZOOM_KEY) )
{
status |= setAutoZoom( sd[AUTO_ZOOM_KEY] );
}
if ( overwrite || sd.has(FIRST_CLICK_INTERACT_KEY) )
{
status |= setFirstClickInteract( sd[FIRST_CLICK_INTERACT_KEY] );
}
if ( overwrite || sd.has(WIDTH_PIXELS_KEY) )
{
status |= setWidthPixels( (LLSD::Integer)sd[WIDTH_PIXELS_KEY] );
}
if ( overwrite || sd.has(HEIGHT_PIXELS_KEY) )
{
status |= setHeightPixels( (LLSD::Integer)sd[HEIGHT_PIXELS_KEY] );
}
// "security" fields
if ( overwrite || sd.has(WHITELIST_ENABLE_KEY) )
{
status |= setWhiteListEnable( sd[WHITELIST_ENABLE_KEY] );
}
if ( overwrite || sd.has(WHITELIST_KEY) )
{
status |= setWhiteList( sd[WHITELIST_KEY] );
}
// "permissions" fields
if ( overwrite || sd.has(PERMS_INTERACT_KEY) )
{
status |= setPermsInteract( 0xff & (LLSD::Integer)sd[PERMS_INTERACT_KEY] );
}
if ( overwrite || sd.has(PERMS_CONTROL_KEY) )
{
status |= setPermsControl( 0xff & (LLSD::Integer)sd[PERMS_CONTROL_KEY] );
}
return LSL_STATUS_OK == status;
}
LLMediaEntry& LLMediaEntry::operator=(const LLMediaEntry &rhs)
{
if (this != &rhs)
{
// "general" fields
mAltImageEnable = rhs.mAltImageEnable;
mControls = rhs.mControls;
mCurrentURL = rhs.mCurrentURL;
mHomeURL = rhs.mHomeURL;
mAutoLoop = rhs.mAutoLoop;
mAutoPlay = rhs.mAutoPlay;
mAutoScale = rhs.mAutoScale;
mAutoZoom = rhs.mAutoZoom;
mFirstClickInteract = rhs.mFirstClickInteract;
mWidthPixels = rhs.mWidthPixels;
mHeightPixels = rhs.mHeightPixels;
// "security" fields
mWhiteListEnable = rhs.mWhiteListEnable;
mWhiteList = rhs.mWhiteList;
// "permissions" fields
mPermsInteract = rhs.mPermsInteract;
mPermsControl = rhs.mPermsControl;
}
return *this;
}
bool LLMediaEntry::operator==(const LLMediaEntry &rhs) const
{
return (
// "general" fields
mAltImageEnable == rhs.mAltImageEnable &&
mControls == rhs.mControls &&
mCurrentURL == rhs.mCurrentURL &&
mHomeURL == rhs.mHomeURL &&
mAutoLoop == rhs.mAutoLoop &&
mAutoPlay == rhs.mAutoPlay &&
mAutoScale == rhs.mAutoScale &&
mAutoZoom == rhs.mAutoZoom &&
mFirstClickInteract == rhs.mFirstClickInteract &&
mWidthPixels == rhs.mWidthPixels &&
mHeightPixels == rhs.mHeightPixels &&
// "security" fields
mWhiteListEnable == rhs.mWhiteListEnable &&
mWhiteList == rhs.mWhiteList &&
// "permissions" fields
mPermsInteract == rhs.mPermsInteract &&
mPermsControl == rhs.mPermsControl
);
}
bool LLMediaEntry::operator!=(const LLMediaEntry &rhs) const
{
return (
// "general" fields
mAltImageEnable != rhs.mAltImageEnable ||
mControls != rhs.mControls ||
mCurrentURL != rhs.mCurrentURL ||
mHomeURL != rhs.mHomeURL ||
mAutoLoop != rhs.mAutoLoop ||
mAutoPlay != rhs.mAutoPlay ||
mAutoScale != rhs.mAutoScale ||
mAutoZoom != rhs.mAutoZoom ||
mFirstClickInteract != rhs.mFirstClickInteract ||
mWidthPixels != rhs.mWidthPixels ||
mHeightPixels != rhs.mHeightPixels ||
// "security" fields
mWhiteListEnable != rhs.mWhiteListEnable ||
mWhiteList != rhs.mWhiteList ||
// "permissions" fields
mPermsInteract != rhs.mPermsInteract ||
mPermsControl != rhs.mPermsControl
);
}
U32 LLMediaEntry::setWhiteList( const std::vector<std::string> &whitelist )
{
// *NOTE: This code is VERY similar to the setWhitelist below.
// IF YOU CHANGE THIS IMPLEMENTATION, BE SURE TO CHANGE THE OTHER!
U32 size = 0;
U32 count = 0;
// First count to make sure the size constraint is not violated
std::vector<std::string>::const_iterator iter = whitelist.begin();
std::vector<std::string>::const_iterator end = whitelist.end();
for ( ; iter < end; ++iter)
{
const std::string &entry = (*iter);
size += entry.length() + 1; // Include one for \0
count ++;
if (size > MAX_WHITELIST_SIZE || count > MAX_WHITELIST_COUNT)
{
return LSL_STATUS_BOUNDS_ERROR;
}
}
// Next clear the vector
mWhiteList.clear();
// Then re-iterate and copy entries
iter = whitelist.begin();
for ( ; iter < end; ++iter)
{
const std::string &entry = (*iter);
mWhiteList.push_back(entry);
}
return LSL_STATUS_OK;
}
U32 LLMediaEntry::setWhiteList( const LLSD &whitelist )
{
// If whitelist is undef, the whitelist is cleared
if (whitelist.isUndefined())
{
mWhiteList.clear();
return LSL_STATUS_OK;
}
// However, if the whitelist is an empty array, erase it.
if (whitelist.isArray())
{
// *NOTE: This code is VERY similar to the setWhitelist above.
// IF YOU CHANGE THIS IMPLEMENTATION, BE SURE TO CHANGE THE OTHER!
U32 size = 0;
U32 count = 0;
// First check to make sure the size and count constraints are not violated
LLSD::array_const_iterator iter = whitelist.beginArray();
LLSD::array_const_iterator end = whitelist.endArray();
for ( ; iter < end; ++iter)
{
const std::string &entry = (*iter).asString();
size += entry.length() + 1; // Include one for \0
count ++;
if (size > MAX_WHITELIST_SIZE || count > MAX_WHITELIST_COUNT)
{
return LSL_STATUS_BOUNDS_ERROR;
}
}
// Next clear the vector
mWhiteList.clear();
// Then re-iterate and copy entries
iter = whitelist.beginArray();
for ( ; iter < end; ++iter)
{
const std::string &entry = (*iter).asString();
mWhiteList.push_back(entry);
}
return LSL_STATUS_OK;
}
else
{
return LSL_STATUS_MALFORMED_PARAMS;
}
}
static void prefix_with(std::string &str, const char *chars, const char *prefix)
{
// Given string 'str', prefix all instances of any character in 'chars'
// with 'prefix'
size_t found = str.find_first_of(chars);
size_t prefix_len = strlen(prefix);
while (found != std::string::npos)
{
str.insert(found, prefix, prefix_len);
found = str.find_first_of(chars, found+prefix_len+1);
}
}
static bool pattern_match(const std::string &candidate_str, const std::string &pattern)
{
// If the pattern is empty, it matches
if (pattern.empty()) return true;
// 'pattern' is a glob pattern, we only accept '*' chars
// copy it
std::string expression = pattern;
// Escape perl's regexp chars with a backslash, except all "*" chars
prefix_with(expression, ".[{()\\+?|^$", "\\");
prefix_with(expression, "*", ".");
// case-insensitive matching:
boost::regex regexp(expression, boost::regex::perl|boost::regex::icase);
return boost::regex_match(candidate_str, regexp);
}
bool LLMediaEntry::checkCandidateUrl(const std::string& url) const
{
if (getWhiteListEnable())
{
return checkUrlAgainstWhitelist(url, getWhiteList());
}
else
{
return true;
}
}
// static
bool LLMediaEntry::checkUrlAgainstWhitelist(const std::string& url,
const std::vector<std::string> &whitelist)
{
bool passes = true;
// *NOTE: no entries? Don't check
if (whitelist.size() > 0)
{
passes = false;
// Case insensitive: the reason why we toUpper both this and the
// filter
std::string candidate_url = url;
// Use lluri to see if there is a path part in the candidate URL. No path? Assume "/"
LLURI candidate_uri(candidate_url);
std::vector<std::string>::const_iterator iter = whitelist.begin();
std::vector<std::string>::const_iterator end = whitelist.end();
for ( ; iter < end; ++iter )
{
std::string filter = *iter;
LLURI filter_uri(filter);
bool scheme_passes = pattern_match( candidate_uri.scheme(), filter_uri.scheme() );
if (filter_uri.scheme().empty())
{
filter_uri = LLURI(DEFAULT_URL_PREFIX + filter);
}
bool authority_passes = pattern_match( candidate_uri.authority(), filter_uri.authority() );
bool path_passes = pattern_match( candidate_uri.escapedPath(), filter_uri.escapedPath() );
if (scheme_passes && authority_passes && path_passes)
{
passes = true;
break;
}
}
}
return passes;
}
U32 LLMediaEntry::setStringFieldWithLimit( std::string &field, const std::string &value, U32 limit )
{
if ( value.length() > limit )
{
return LSL_STATUS_BOUNDS_ERROR;
}
else
{
field = value;
return LSL_STATUS_OK;
}
}
U32 LLMediaEntry::setControls(LLMediaEntry::MediaControls controls)
{
if (controls == STANDARD ||
controls == MINI)
{
mControls = controls;
return LSL_STATUS_OK;
}
return LSL_STATUS_BOUNDS_ERROR;
}
U32 LLMediaEntry::setPermsInteract( U8 val )
{
mPermsInteract = val & PERM_MASK;
return LSL_STATUS_OK;
}
U32 LLMediaEntry::setPermsControl( U8 val )
{
mPermsControl = val & PERM_MASK;
return LSL_STATUS_OK;
}
U32 LLMediaEntry::setCurrentURL(const std::string& current_url)
{
return setCurrentURLInternal( current_url, true );
}
U32 LLMediaEntry::setCurrentURLInternal(const std::string& current_url, bool check_whitelist)
{
if ( ! check_whitelist || checkCandidateUrl(current_url))
{
return setStringFieldWithLimit( mCurrentURL, current_url, MAX_URL_LENGTH );
}
else
{
return LSL_STATUS_WHITELIST_FAILED;
}
}
U32 LLMediaEntry::setHomeURL(const std::string& home_url)
{
return setStringFieldWithLimit( mHomeURL, home_url, MAX_URL_LENGTH );
}
U32 LLMediaEntry::setWidthPixels(U16 width)
{
if (width > MAX_WIDTH_PIXELS) return LSL_STATUS_BOUNDS_ERROR;
mWidthPixels = width;
return LSL_STATUS_OK;
}
U32 LLMediaEntry::setHeightPixels(U16 height)
{
if (height > MAX_HEIGHT_PIXELS) return LSL_STATUS_BOUNDS_ERROR;
mHeightPixels = height;
return LSL_STATUS_OK;
}
const LLUUID &LLMediaEntry::getMediaID() const
{
// Lazily generate media ID
if (NULL == mMediaIDp)
{
mMediaIDp = new LLUUID();
mMediaIDp->generate();
}
return *mMediaIDp;
}

View File

@@ -83,7 +83,6 @@ LLModel::~LLModel()
bool get_dom_sources(const domInputLocalOffset_Array& inputs, S32& pos_offset, S32& tc_offset, S32& norm_offset, S32 &idx_stride, bool get_dom_sources(const domInputLocalOffset_Array& inputs, S32& pos_offset, S32& tc_offset, S32& norm_offset, S32 &idx_stride,
domSource* &pos_source, domSource* &tc_source, domSource* &norm_source) domSource* &pos_source, domSource* &tc_source, domSource* &norm_source)
{ {
idx_stride = 0; idx_stride = 0;
for (U32 j = 0; j < inputs.getCount(); ++j) for (U32 j = 0; j < inputs.getCount(); ++j)
@@ -210,7 +209,6 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector<LLVolumeFace>& fa
n[idx[i+norm_offset]*3+2])); n[idx[i+norm_offset]*3+2]));
} }
BOOL found = FALSE; BOOL found = FALSE;
LLVolumeFace::VertexMapData::PointMap::iterator point_iter; LLVolumeFace::VertexMapData::PointMap::iterator point_iter;
@@ -276,7 +274,6 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector<LLVolumeFace>& fa
face = LLVolumeFace(); face = LLVolumeFace();
point_map.clear(); point_map.clear();
} }
} }
if (!verts.empty()) if (!verts.empty())
@@ -539,7 +536,6 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
const domInputLocalOffset_Array& inputs = poly->getInput_array(); const domInputLocalOffset_Array& inputs = poly->getInput_array();
S32 v_offset = -1; S32 v_offset = -1;
S32 n_offset = -1; S32 n_offset = -1;
S32 t_offset = -1; S32 t_offset = -1;
@@ -652,7 +648,6 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
t->get(t_idx+1)); t->get(t_idx+1));
} }
verts.push_back(vert); verts.push_back(vert);
} }
} }
@@ -1467,7 +1462,6 @@ LLSD LLModel::writeModel(
} }
} }
LLVector2 tc_range = max_tc - min_tc; LLVector2 tc_range = max_tc - min_tc;
for (U32 j = 0; j < (U32)face.mNumVertices; ++j) for (U32 j = 0; j < (U32)face.mNumVertices; ++j)
@@ -1983,6 +1977,7 @@ bool LLModel::matchMaterialOrder(LLModel* ref, int& refFaceCnt, int& modelFaceCn
//build a map of material slot names to face indexes //build a map of material slot names to face indexes
bool reorder = false; bool reorder = false;
std::set<std::string> base_mat; std::set<std::string> base_mat;
std::set<std::string> cur_mat; std::set<std::string> cur_mat;

View File

@@ -435,11 +435,7 @@ LLGLManager::LLGLManager() :
mHasPointParameters(FALSE), mHasPointParameters(FALSE),
mHasDrawBuffers(FALSE), mHasDrawBuffers(FALSE),
mHasTextureRectangle(FALSE), mHasTextureRectangle(FALSE),
mHasTextureMultisample(FALSE),
mHasTransformFeedback(FALSE), mHasTransformFeedback(FALSE),
mMaxSampleMaskWords(0),
mMaxColorTextureSamples(0),
mMaxDepthTextureSamples(0),
mMaxIntegerSamples(0), mMaxIntegerSamples(0),
mHasAnisotropic(FALSE), mHasAnisotropic(FALSE),
@@ -732,12 +728,10 @@ bool LLGLManager::initGL()
stop_glerror(); stop_glerror();
if (mHasTextureMultisample) if (mHasFramebufferMultisample)
{ {
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &mMaxColorTextureSamples);
glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &mMaxDepthTextureSamples);
glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples); glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples);
glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &mMaxSampleMaskWords); glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples);
} }
stop_glerror(); stop_glerror();
@@ -749,24 +743,12 @@ bool LLGLManager::initGL()
} }
#endif #endif
stop_glerror(); stop_glerror();
mHasTextureMultisample = FALSE;
#if LL_WINDOWS
if (mIsATI)
{ //using multisample textures on ATI results in black screen for some reason
mHasTextureMultisample = FALSE;
}
#endif
if (mIsIntel && mGLVersion <= 3.f) if (mIsIntel && mGLVersion <= 3.f)
{ //never try to use framebuffer objects on older intel drivers (crashy) { //never try to use framebuffer objects on older intel drivers (crashy)
mHasFramebufferObject = FALSE; mHasFramebufferObject = FALSE;
} }
if (mHasFramebufferObject)
{
glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples);
}
stop_glerror(); stop_glerror();
setToDebugGPU(); setToDebugGPU();
@@ -847,14 +829,6 @@ std::string LLGLManager::getRawGLString()
return gl_string; return gl_string;
} }
U32 LLGLManager::getNumFBOFSAASamples(U32 samples)
{
samples = llmin(samples, (U32) mMaxColorTextureSamples);
samples = llmin(samples, (U32) mMaxDepthTextureSamples);
samples = llmin(samples, (U32) 4);
return samples;
}
void LLGLManager::shutdownGL() void LLGLManager::shutdownGL()
{ {
if (mInited) if (mInited)
@@ -960,7 +934,6 @@ void LLGLManager::initExtensions()
mHasDrawBuffers = ExtensionExists("GL_ARB_draw_buffers", gGLHExts.mSysExts); mHasDrawBuffers = ExtensionExists("GL_ARB_draw_buffers", gGLHExts.mSysExts);
mHasBlendFuncSeparate = ExtensionExists("GL_EXT_blend_func_separate", gGLHExts.mSysExts); mHasBlendFuncSeparate = ExtensionExists("GL_EXT_blend_func_separate", gGLHExts.mSysExts);
mHasTextureRectangle = ExtensionExists("GL_ARB_texture_rectangle", gGLHExts.mSysExts); mHasTextureRectangle = ExtensionExists("GL_ARB_texture_rectangle", gGLHExts.mSysExts);
mHasTextureMultisample = ExtensionExists("GL_ARB_texture_multisample", gGLHExts.mSysExts);
mHasDebugOutput = ExtensionExists("GL_ARB_debug_output", gGLHExts.mSysExts); mHasDebugOutput = ExtensionExists("GL_ARB_debug_output", gGLHExts.mSysExts);
mHasTransformFeedback = mGLVersion >= 4.f ? TRUE : FALSE; mHasTransformFeedback = mGLVersion >= 4.f ? TRUE : FALSE;
#if !LL_DARWIN #if !LL_DARWIN
@@ -1198,13 +1171,6 @@ void LLGLManager::initExtensions()
{ {
glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBlendFuncSeparateEXT"); glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBlendFuncSeparateEXT");
} }
if (mHasTextureMultisample)
{
glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) GLH_EXT_GET_PROC_ADDRESS("glTexImage2DMultisample");
glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) GLH_EXT_GET_PROC_ADDRESS("glTexImage3DMultisample");
glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) GLH_EXT_GET_PROC_ADDRESS("glGetMultisamplefv");
glSampleMaski = (PFNGLSAMPLEMASKIPROC) GLH_EXT_GET_PROC_ADDRESS("glSampleMaski");
}
if (mHasTransformFeedback) if (mHasTransformFeedback)
{ {
glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) GLH_EXT_GET_PROC_ADDRESS("glBeginTransformFeedback"); glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) GLH_EXT_GET_PROC_ADDRESS("glBeginTransformFeedback");

View File

@@ -104,11 +104,7 @@ public:
BOOL mHasDrawBuffers; BOOL mHasDrawBuffers;
BOOL mHasDepthClamp; BOOL mHasDepthClamp;
BOOL mHasTextureRectangle; BOOL mHasTextureRectangle;
BOOL mHasTextureMultisample;
BOOL mHasTransformFeedback; BOOL mHasTransformFeedback;
S32 mMaxSampleMaskWords;
S32 mMaxColorTextureSamples;
S32 mMaxDepthTextureSamples;
S32 mMaxIntegerSamples; S32 mMaxIntegerSamples;
// Other extensions. // Other extensions.
@@ -155,7 +151,6 @@ public:
void printGLInfoString(); void printGLInfoString();
void getGLInfo(LLSD& info); void getGLInfo(LLSD& info);
U32 getNumFBOFSAASamples(U32 desired_samples = 32);
// In ALL CAPS // In ALL CAPS
std::string mGLVendor; std::string mGLVendor;
std::string mGLVendorShort; std::string mGLVendorShort;
@@ -521,4 +516,5 @@ extern BOOL gGLActive;
#ifndef GL_DEPTH24_STENCIL8 #ifndef GL_DEPTH24_STENCIL8
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
#endif #endif
#endif // LL_LLGL_H #endif // LL_LLGL_H

View File

@@ -783,6 +783,7 @@ extern PFNGLDEBUGMESSAGECONTROLARBPROC glDebugMessageControlARB;
extern PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB; extern PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB;
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB; extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB;
#elif LL_DARWIN #elif LL_DARWIN
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// LL_DARWIN // LL_DARWIN
@@ -825,6 +826,7 @@ extern void glGenerateMipmapEXT(GLenum target) AVAILABLE_MAC_OS_X_VERSION_10_4_A
#define glGenerateMipmap glGenerateMipmapEXT #define glGenerateMipmap glGenerateMipmapEXT
#define GL_MAX_SAMPLES 0x8D57 #define GL_MAX_SAMPLES 0x8D57
#endif #endif
// GL_ARB_draw_buffers // GL_ARB_draw_buffers
extern void glDrawBuffersARB(GLsizei n, const GLenum* bufs) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; extern void glDrawBuffersARB(GLsizei n, const GLenum* bufs) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
@@ -997,7 +999,7 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
} }
#endif #endif
#include <AGL/gl.h> #include <OpenGL/gl.h>
#endif // LL_MESA / LL_WINDOWS / LL_DARWIN #endif // LL_MESA / LL_WINDOWS / LL_DARWIN
@@ -1029,4 +1031,5 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC #define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC
#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD #define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
#endif #endif
#endif // LL_LLGLHEADERS_H #endif // LL_LLGLHEADERS_H

View File

@@ -330,7 +330,6 @@ S32 LLImageGL::updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 categ
//static //static
void LLImageGL::destroyGL(BOOL save_state) void LLImageGL::destroyGL(BOOL save_state)
{ {
deleteDeadTextures(); //Dump unimportant textures.
for (S32 stage = 0; stage < gGLManager.mNumTextureUnits; stage++) for (S32 stage = 0; stage < gGLManager.mNumTextureUnits; stage++)
{ {
gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE);
@@ -364,7 +363,6 @@ void LLImageGL::destroyGL(BOOL save_state)
} }
llinfos << "Storing " << stored_count << " images..." << llendl; llinfos << "Storing " << stored_count << " images..." << llendl;
sAllowReadBackRaw = false ; sAllowReadBackRaw = false ;
deleteDeadTextures();//Now, actually call glDeleteTextures for everything.
} }
//static //static
@@ -1528,7 +1526,7 @@ void LLImageGL::deleteDeadTextures()
{ {
bool reset = false; bool reset = false;
for(U32 i=0;i<LLTexUnit::TT_NONE;++i) /*for(U32 i=0;i<LLTexUnit::TT_NONE;++i)
{ {
for(dead_texturelist_t::iterator it=sDeadTextureList[i].begin();it!=sDeadTextureList[i].end();++it) for(dead_texturelist_t::iterator it=sDeadTextureList[i].begin();it!=sDeadTextureList[i].end();++it)
{ {
@@ -1554,7 +1552,7 @@ void LLImageGL::deleteDeadTextures()
stop_glerror(); stop_glerror();
} }
} }
} }*/
if (reset) if (reset)
{ {

View File

@@ -699,6 +699,28 @@ bool LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth
release(); release();
stop_glerror(); stop_glerror();
if (!gGLManager.mHasFramebufferMultisample || !gGLManager.mHasFramebufferObject || !(sUseFBO || use_fbo))
return false;
if(color_fmt != GL_RGBA)
{
llwarns << "Unsupported color format: " << color_fmt << llendl;
return false;
}
//Restrict to valid sample count
{
mSamples = samples;
mSamples = llmin(mSamples, (U32)4); //Cap to prevent memory bloat.
mSamples = llmin(mSamples, (U32) gGLManager.mMaxIntegerSamples);//GL_RGBA
if(depth && !stencil)
mSamples = llmin(mSamples, (U32) gGLManager.mMaxSamples); //GL_DEPTH_COMPONENT16_ARB
}
if (mSamples <= 1)
return false;
mResX = resx; mResX = resx;
mResY = resy; mResY = resy;
@@ -706,30 +728,16 @@ bool LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth
mUseDepth = depth; mUseDepth = depth;
mStencil = stencil; mStencil = stencil;
if (!gGLManager.mHasFramebufferMultisample)
{
llerrs << "Attempting to allocate unsupported render target type!" << llendl;
return false;
}
mSamples = gGLManager.getNumFBOFSAASamples(samples);
if (mSamples <= 1)
{
llerrs << "Cannot create a multisample buffer with less than 2 samples." << llendl;
return false;
}
stop_glerror();
if ((sUseFBO || use_fbo) && gGLManager.mHasFramebufferObject)
{ {
if (depth) if (depth)
{ {
stop_glerror(); stop_glerror();
if(!allocateDepth()) if(!allocateDepth())
{
release();
return false; return false;
}
stop_glerror(); stop_glerror();
} }
glGenFramebuffers(1, (GLuint *) &mFBO); glGenFramebuffers(1, (GLuint *) &mFBO);
@@ -779,6 +787,7 @@ bool LLMultisampleBuffer::addColorAttachment(U32 color_fmt)
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
llwarns << "Unable to allocate color buffer for multisample render target." << llendl; llwarns << "Unable to allocate color buffer for multisample render target." << llendl;
release();
return false; return false;
} }

View File

@@ -231,7 +231,6 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
if (features->hasLighting) if (features->hasLighting)
{ {
if (features->hasWaterFog) if (features->hasWaterFog)
{ {
if (features->disableTextureIndex) if (features->disableTextureIndex)

View File

@@ -12,7 +12,6 @@ include(LLRender)
include(LLWindow) include(LLWindow)
include(LLVFS) include(LLVFS)
include(LLXML) include(LLXML)
include(LLXUIXML)
include_directories( include_directories(
${LLCOMMON_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS}
@@ -24,7 +23,6 @@ include_directories(
${LLWINDOW_INCLUDE_DIRS} ${LLWINDOW_INCLUDE_DIRS}
${LLVFS_INCLUDE_DIRS} ${LLVFS_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS}
${LLXUIXML_INCLUDE_DIRS}
) )
set(llui_SOURCE_FILES set(llui_SOURCE_FILES
@@ -73,6 +71,7 @@ set(llui_SOURCE_FILES
lltextparser.cpp lltextparser.cpp
lltrans.cpp lltrans.cpp
llui.cpp llui.cpp
lluicolor.cpp
lluictrl.cpp lluictrl.cpp
lluictrlfactory.cpp lluictrlfactory.cpp
lluiimage.cpp lluiimage.cpp
@@ -142,6 +141,7 @@ set(llui_HEADER_FILES
lluictrl.h lluictrl.h
lluifwd.h lluifwd.h
llui.h llui.h
lluicolor.h
lluiimage.h lluiimage.h
lluistring.h lluistring.h
lluixmltags.h lluixmltags.h
@@ -165,7 +165,6 @@ target_link_libraries(llui
llwindow llwindow
llimage llimage
llvfs # ugh, just for LLDir llvfs # ugh, just for LLDir
llxuixml
llxml llxml
llcommon # must be after llimage, llwindow, llrender llcommon # must be after llimage, llwindow, llrender
llmath llmath

View File

@@ -45,17 +45,20 @@ class LLMouseHandler
public: public:
LLMouseHandler() {} LLMouseHandler() {}
virtual ~LLMouseHandler() {} virtual ~LLMouseHandler() {}
typedef enum { typedef enum {
SHOW_NEVER, SHOW_NEVER,
SHOW_IF_NOT_BLOCKED, SHOW_IF_NOT_BLOCKED,
SHOW_ALWAYS, SHOW_ALWAYS,
} EShowToolTip; } EShowToolTip;
typedef enum { typedef enum {
CLICK_LEFT, CLICK_LEFT,
CLICK_MIDDLE, CLICK_MIDDLE,
CLICK_RIGHT, CLICK_RIGHT,
CLICK_DOUBLELEFT CLICK_DOUBLELEFT
} EClickType; } EClickType;
virtual BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down); virtual BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down);
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) = 0; virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) = 0;
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask) = 0; virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask) = 0;

View File

@@ -113,6 +113,7 @@ LLWindow::LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags)
mSupportedResolutions(NULL), mSupportedResolutions(NULL),
mNumSupportedResolutions(0), mNumSupportedResolutions(0),
mCurrentCursor(UI_CURSOR_ARROW), mCurrentCursor(UI_CURSOR_ARROW),
mNextCursor(UI_CURSOR_ARROW),
mCursorHidden(FALSE), mCursorHidden(FALSE),
mBusyCount(0), mBusyCount(0),
mIsMouseClipping(FALSE), mIsMouseClipping(FALSE),
@@ -125,7 +126,6 @@ LLWindow::LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags)
LLWindow::~LLWindow() LLWindow::~LLWindow()
{ {
} }
//virtual //virtual
@@ -139,6 +139,7 @@ BOOL LLWindow::canDelete()
{ {
return TRUE; return TRUE;
} }
// virtual // virtual
void LLWindow::incBusyCount() void LLWindow::incBusyCount()
{ {

View File

@@ -104,12 +104,14 @@ public:
virtual S32 getBusyCount() const; virtual S32 getBusyCount() const;
// Sets cursor, may set to arrow+hourglass // Sets cursor, may set to arrow+hourglass
virtual void setCursor(ECursorType cursor) = 0; virtual void setCursor(ECursorType cursor) { mNextCursor = cursor; };
virtual ECursorType getCursor() const; virtual ECursorType getCursor() const;
virtual void updateCursor() = 0;
virtual void captureMouse() = 0; virtual void captureMouse() = 0;
virtual void releaseMouse() = 0; virtual void releaseMouse() = 0;
virtual void setMouseClipping( BOOL b ) = 0; virtual void setMouseClipping( BOOL b ) = 0;
virtual BOOL isClipboardTextAvailable() = 0; virtual BOOL isClipboardTextAvailable() = 0;
virtual BOOL pasteTextFromClipboard(LLWString &dst) = 0; virtual BOOL pasteTextFromClipboard(LLWString &dst) = 0;
virtual BOOL copyTextToClipboard(const LLWString &src) = 0; virtual BOOL copyTextToClipboard(const LLWString &src) = 0;
@@ -196,6 +198,7 @@ protected:
LLWindowResolution* mSupportedResolutions; LLWindowResolution* mSupportedResolutions;
S32 mNumSupportedResolutions; S32 mNumSupportedResolutions;
ECursorType mCurrentCursor; ECursorType mCurrentCursor;
ECursorType mNextCursor;
BOOL mCursorHidden; BOOL mCursorHidden;
S32 mBusyCount; // how deep is the "cursor busy" stack? S32 mBusyCount; // how deep is the "cursor busy" stack?
BOOL mIsMouseClipping; // Is this window currently clipping the mouse BOOL mIsMouseClipping; // Is this window currently clipping the mouse

View File

@@ -91,5 +91,4 @@ public:
}; };
#endif #endif

View File

@@ -61,7 +61,7 @@ public:
/*virtual*/ void showCursorFromMouseMove() {}; /*virtual*/ void showCursorFromMouseMove() {};
/*virtual*/ void hideCursorUntilMouseMove() {}; /*virtual*/ void hideCursorUntilMouseMove() {};
/*virtual*/ BOOL isCursorHidden() {return FALSE;}; /*virtual*/ BOOL isCursorHidden() {return FALSE;};
/*virtual*/ void setCursor(ECursorType cursor) {}; /*virtual*/ void updateCursor() {};
//virtual ECursorType getCursor() { return mCurrentCursor; }; //virtual ECursorType getCursor() { return mCurrentCursor; };
/*virtual*/ void captureMouse() {}; /*virtual*/ void captureMouse() {};
/*virtual*/ void releaseMouse() {}; /*virtual*/ void releaseMouse() {};

View File

@@ -50,6 +50,11 @@ void setupCocoa()
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// The following prevents the Cocoa command line parser from trying to open 'unknown' arguements as documents.
// ie. running './secondlife -set Language fr' would cause a pop-up saying can't open document 'fr'
// when init'ing the Cocoa App window.
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"];
// This is a bit of voodoo taken from the Apple sample code "CarbonCocoa_PictureCursor": // This is a bit of voodoo taken from the Apple sample code "CarbonCocoa_PictureCursor":
// http://developer.apple.com/samplecode/CarbonCocoa_PictureCursor/index.html // http://developer.apple.com/samplecode/CarbonCocoa_PictureCursor/index.html
@@ -60,6 +65,8 @@ void setupCocoa()
[[[NSWindow alloc] init] release]; [[[NSWindow alloc] init] release];
[pool release]; [pool release];
inited = true;
} }
} }

View File

@@ -484,7 +484,6 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
true, true,
(long)this); (long)this);
if (!mWindow) if (!mWindow)
{ {
setupFailure("Window creation error", "Error", OSMB_OK); setupFailure("Window creation error", "Error", OSMB_OK);
@@ -1042,6 +1041,7 @@ void LLWindowMacOSX::hide()
HideWindow(mWindow); HideWindow(mWindow);
} }
//virtual
void LLWindowMacOSX::minimize() void LLWindowMacOSX::minimize()
{ {
setMouseClipping(FALSE); setMouseClipping(FALSE);
@@ -1049,6 +1049,7 @@ void LLWindowMacOSX::minimize()
CollapseWindow(mWindow, true); CollapseWindow(mWindow, true);
} }
//virtual
void LLWindowMacOSX::restore() void LLWindowMacOSX::restore()
{ {
show(); show();
@@ -1169,6 +1170,8 @@ void LLWindowMacOSX::gatherInput()
} }
} }
updateCursor();
} }
BOOL LLWindowMacOSX::getPosition(LLCoordScreen *position) BOOL LLWindowMacOSX::getPosition(LLCoordScreen *position)
@@ -1441,7 +1444,7 @@ static void fixOrigin(void)
::GetPortBounds(port, &portrect); ::GetPortBounds(port, &portrect);
if((portrect.left != 0) || (portrect.top != 0)) if((portrect.left != 0) || (portrect.top != 0))
{ {
// Mozilla sometimes changes our port origin. Fuckers. // Mozilla sometimes changes our port origin.
::SetOrigin(0,0); ::SetOrigin(0,0);
} }
} }
@@ -2133,6 +2136,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
{ {
UInt32 modifiers = 0; UInt32 modifiers = 0;
// First, process the raw event. // First, process the raw event.
{ {
EventRef rawEvent = NULL; EventRef rawEvent = NULL;
@@ -2843,7 +2847,7 @@ static void initPixmapCursor(int cursorid, int hotspotX, int hotspotY)
gCursors[cursorid] = createImageCursor(fullpath.c_str(), hotspotX, hotspotY); gCursors[cursorid] = createImageCursor(fullpath.c_str(), hotspotX, hotspotY);
} }
void LLWindowMacOSX::setCursor(ECursorType cursor) void LLWindowMacOSX::updateCursor()
{ {
OSStatus result = noErr; OSStatus result = noErr;
@@ -2851,30 +2855,30 @@ void LLWindowMacOSX::setCursor(ECursorType cursor)
{ {
// A drag is in progress...remember the requested cursor and we'll // A drag is in progress...remember the requested cursor and we'll
// restore it when it is done // restore it when it is done
mCurrentCursor = cursor; mCurrentCursor = mNextCursor;
return; return;
} }
if (cursor == UI_CURSOR_ARROW if (mNextCursor == UI_CURSOR_ARROW
&& mBusyCount > 0) && mBusyCount > 0)
{ {
cursor = UI_CURSOR_WORKING; mNextCursor = UI_CURSOR_WORKING;
} }
if(mCurrentCursor == cursor) if(mCurrentCursor == mNextCursor)
return; return;
// RN: replace multi-drag cursors with single versions // RN: replace multi-drag cursors with single versions
if (cursor == UI_CURSOR_ARROWDRAGMULTI) if (mNextCursor == UI_CURSOR_ARROWDRAGMULTI)
{ {
cursor = UI_CURSOR_ARROWDRAG; mNextCursor = UI_CURSOR_ARROWDRAG;
} }
else if (cursor == UI_CURSOR_ARROWCOPYMULTI) else if (mNextCursor == UI_CURSOR_ARROWCOPYMULTI)
{ {
cursor = UI_CURSOR_ARROWCOPY; mNextCursor = UI_CURSOR_ARROWCOPY;
} }
switch(cursor) switch(mNextCursor)
{ {
default: default:
case UI_CURSOR_ARROW: case UI_CURSOR_ARROW:
@@ -2926,7 +2930,7 @@ void LLWindowMacOSX::setCursor(ECursorType cursor)
case UI_CURSOR_TOOLBUY: case UI_CURSOR_TOOLBUY:
case UI_CURSOR_TOOLOPEN: case UI_CURSOR_TOOLOPEN:
case UI_CURSOR_TOOLPAY: case UI_CURSOR_TOOLPAY:
result = setImageCursor(gCursors[cursor]); result = setImageCursor(gCursors[mNextCursor]);
break; break;
} }
@@ -2936,7 +2940,7 @@ void LLWindowMacOSX::setCursor(ECursorType cursor)
InitCursor(); InitCursor();
} }
mCurrentCursor = cursor; mCurrentCursor = mNextCursor;
} }
ECursorType LLWindowMacOSX::getCursor() const ECursorType LLWindowMacOSX::getCursor() const
@@ -2967,9 +2971,9 @@ void LLWindowMacOSX::initCursors()
initPixmapCursor(UI_CURSOR_TOOLPLAY, 1, 1); initPixmapCursor(UI_CURSOR_TOOLPLAY, 1, 1);
initPixmapCursor(UI_CURSOR_TOOLPAUSE, 1, 1); initPixmapCursor(UI_CURSOR_TOOLPAUSE, 1, 1);
initPixmapCursor(UI_CURSOR_TOOLMEDIAOPEN, 1, 1); initPixmapCursor(UI_CURSOR_TOOLMEDIAOPEN, 1, 1);
initPixmapCursor(UI_CURSOR_TOOLSIT, 1, 1); initPixmapCursor(UI_CURSOR_TOOLSIT, 20, 15);
initPixmapCursor(UI_CURSOR_TOOLBUY, 1, 1); initPixmapCursor(UI_CURSOR_TOOLBUY, 20, 15);
initPixmapCursor(UI_CURSOR_TOOLOPEN, 1, 1); initPixmapCursor(UI_CURSOR_TOOLOPEN, 20, 15);
initPixmapCursor(UI_CURSOR_TOOLPAY, 1, 1); initPixmapCursor(UI_CURSOR_TOOLPAY, 1, 1);
initPixmapCursor(UI_CURSOR_SIZENWSE, 10, 10); initPixmapCursor(UI_CURSOR_SIZENWSE, 10, 10);

View File

@@ -73,7 +73,7 @@ public:
/*virtual*/ void showCursorFromMouseMove(); /*virtual*/ void showCursorFromMouseMove();
/*virtual*/ void hideCursorUntilMouseMove(); /*virtual*/ void hideCursorUntilMouseMove();
/*virtual*/ BOOL isCursorHidden(); /*virtual*/ BOOL isCursorHidden();
/*virtual*/ void setCursor(ECursorType cursor); /*virtual*/ void updateCursor();
/*virtual*/ ECursorType getCursor() const; /*virtual*/ ECursorType getCursor() const;
/*virtual*/ void captureMouse(); /*virtual*/ void captureMouse();
/*virtual*/ void releaseMouse(); /*virtual*/ void releaseMouse();

View File

@@ -65,7 +65,7 @@ public:
/*virtual*/ void showCursorFromMouseMove() {}; /*virtual*/ void showCursorFromMouseMove() {};
/*virtual*/ void hideCursorUntilMouseMove() {}; /*virtual*/ void hideCursorUntilMouseMove() {};
/*virtual*/ BOOL isCursorHidden() {return FALSE;}; /*virtual*/ BOOL isCursorHidden() {return FALSE;};
/*virtual*/ void setCursor(ECursorType cursor) {}; /*virtual*/ void updateCursor() {};
//virtual ECursorType getCursor() { return mCurrentCursor; }; //virtual ECursorType getCursor() { return mCurrentCursor; };
/*virtual*/ void captureMouse() {}; /*virtual*/ void captureMouse() {};
/*virtual*/ void releaseMouse() {}; /*virtual*/ void releaseMouse() {};

View File

@@ -39,6 +39,7 @@
#include "llwindowcallbacks.h" #include "llwindowcallbacks.h"
#include "llkeyboardsdl.h" #include "llkeyboardsdl.h"
#include "llerror.h" #include "llerror.h"
#include "llgl.h" #include "llgl.h"
#include "llstring.h" #include "llstring.h"
@@ -221,15 +222,14 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks,
#endif // LL_X11 #endif // LL_X11
#if LL_GTK #if LL_GTK
// We MUST be the first to initialize GTK, i.e. we have to beat // We MUST be the first to initialize GTK so that GTK doesn't get badly
// our embedded Mozilla to the punch so that GTK doesn't get badly
// initialized with a non-C locale and cause lots of serious random // initialized with a non-C locale and cause lots of serious random
// weirdness. // weirdness.
ll_try_gtk_init(); ll_try_gtk_init();
#endif // LL_GTK #endif // LL_GTK
// Get the original aspect ratio of the main device. // Assume 4:3 aspect ratio until we know better
mOriginalAspectRatio = 1024.0 / 768.0; // !!! *FIX: ? //(double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay); mOriginalAspectRatio = 1024.0 / 768.0;
if (title.empty()) if (title.empty())
mWindowTitle = "SDL Window"; // *FIX: (???) mWindowTitle = "SDL Window"; // *FIX: (???)
@@ -425,7 +425,6 @@ static int x11_detect_VRAM_kb()
BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync) BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync)
{ {
//bool glneedsinit = false; //bool glneedsinit = false;
// const char *gllibname = null;
llinfos << "createContext, fullscreen=" << fullscreen << llinfos << "createContext, fullscreen=" << fullscreen <<
" size=" << width << "x" << height << llendl; " size=" << width << "x" << height << llendl;
@@ -856,11 +855,13 @@ void LLWindowSDL::hide()
// *FIX: What to do with SDL? // *FIX: What to do with SDL?
} }
//virtual
void LLWindowSDL::minimize() void LLWindowSDL::minimize()
{ {
// *FIX: What to do with SDL? // *FIX: What to do with SDL?
} }
//virtual
void LLWindowSDL::restore() void LLWindowSDL::restore()
{ {
// *FIX: What to do with SDL? // *FIX: What to do with SDL?
@@ -1680,12 +1681,13 @@ void check_vm_bloat()
} }
#endif // LL_LINUX #endif // LL_LINUX
} }
// virtual // virtual
void LLWindowSDL::processMiscNativeEvents() void LLWindowSDL::processMiscNativeEvents()
{ {
#if LL_GTK #if LL_GTK
// Pump GTK events to avoid starvation for: // Pump GTK events to avoid starvation for:
// * Embedded Gecko
// * DBUS servicing // * DBUS servicing
// * Anything else which quietly hooks into the default glib/GTK loop // * Anything else which quietly hooks into the default glib/GTK loop
if (ll_try_gtk_init()) if (ll_try_gtk_init())
@@ -1747,6 +1749,7 @@ void LLWindowSDL::gatherInput()
mKeyScanCode = event.key.keysym.scancode; mKeyScanCode = event.key.keysym.scancode;
mKeyVirtualKey = event.key.keysym.unicode; mKeyVirtualKey = event.key.keysym.unicode;
mKeyModifiers = event.key.keysym.mod; mKeyModifiers = event.key.keysym.mod;
gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod); gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod);
// part of the fix for SL-13243 // part of the fix for SL-13243
if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0) if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0)
@@ -1933,6 +1936,8 @@ void LLWindowSDL::gatherInput()
} }
} }
updateCursor();
#if LL_X11 #if LL_X11
// This is a good time to stop flashing the icon if our mFlashTimer has // This is a good time to stop flashing the icon if our mFlashTimer has
// expired. // expired.
@@ -2018,7 +2023,7 @@ static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty
return sdlcursor; return sdlcursor;
} }
void LLWindowSDL::setCursor(ECursorType cursor) void LLWindowSDL::updateCursor()
{ {
if (ATIbug) { if (ATIbug) {
// cursor-updating is very flaky when this bug is // cursor-updating is very flaky when this bug is
@@ -2026,11 +2031,11 @@ void LLWindowSDL::setCursor(ECursorType cursor)
return; return;
} }
if (mCurrentCursor != cursor) if (mCurrentCursor != mNextCursor)
{ {
if (cursor < UI_CURSOR_COUNT) if (mNextCursor < UI_CURSOR_COUNT)
{ {
SDL_Cursor *sdlcursor = mSDLCursors[cursor]; SDL_Cursor *sdlcursor = mSDLCursors[mNextCursor];
// Try to default to the arrow for any cursors that // Try to default to the arrow for any cursors that
// did not load correctly. // did not load correctly.
if (!sdlcursor && mSDLCursors[UI_CURSOR_ARROW]) if (!sdlcursor && mSDLCursors[UI_CURSOR_ARROW])
@@ -2038,9 +2043,9 @@ void LLWindowSDL::setCursor(ECursorType cursor)
if (sdlcursor) if (sdlcursor)
SDL_SetCursor(sdlcursor); SDL_SetCursor(sdlcursor);
} else { } else {
llwarns << "Tried to set invalid cursor number " << cursor << llendl; llwarns << "Tried to set invalid cursor number " << mNextCursor << llendl;
} }
mCurrentCursor = cursor; mCurrentCursor = mNextCursor;
} }
} }

View File

@@ -78,7 +78,7 @@ public:
/*virtual*/ void showCursorFromMouseMove(); /*virtual*/ void showCursorFromMouseMove();
/*virtual*/ void hideCursorUntilMouseMove(); /*virtual*/ void hideCursorUntilMouseMove();
/*virtual*/ BOOL isCursorHidden(); /*virtual*/ BOOL isCursorHidden();
/*virtual*/ void setCursor(ECursorType cursor); /*virtual*/ void updateCursor();
/*virtual*/ void captureMouse(); /*virtual*/ void captureMouse();
/*virtual*/ void releaseMouse(); /*virtual*/ void releaseMouse();
/*virtual*/ void setMouseClipping( BOOL b ); /*virtual*/ void setMouseClipping( BOOL b );

View File

@@ -677,6 +677,7 @@ void LLWindowWin32::hide()
ShowWindow(mWindowHandle, SW_HIDE); ShowWindow(mWindowHandle, SW_HIDE);
} }
//virtual
void LLWindowWin32::minimize() void LLWindowWin32::minimize()
{ {
setMouseClipping(FALSE); setMouseClipping(FALSE);
@@ -684,7 +685,7 @@ void LLWindowWin32::minimize()
ShowWindow(mWindowHandle, SW_MINIMIZE); ShowWindow(mWindowHandle, SW_MINIMIZE);
} }
//virtual
void LLWindowWin32::restore() void LLWindowWin32::restore()
{ {
ShowWindow(mWindowHandle, SW_RESTORE); ShowWindow(mWindowHandle, SW_RESTORE);
@@ -1019,6 +1020,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
dw_style = WS_OVERLAPPEDWINDOW; dw_style = WS_OVERLAPPEDWINDOW;
} }
// don't post quit messages when destroying old windows // don't post quit messages when destroying old windows
mPostQuit = FALSE; mPostQuit = FALSE;
@@ -1070,6 +1072,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
return FALSE; return FALSE;
} }
LL_INFOS("Window") << "Device context retrieved." << llendl ;
if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd))) if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd)))
{ {
close(); close();
@@ -1078,6 +1082,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
return FALSE; return FALSE;
} }
LL_INFOS("Window") << "Pixel format chosen." << llendl ;
// Verify what pixel format we actually received. // Verify what pixel format we actually received.
if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR), if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR),
&pfd)) &pfd))
@@ -1673,18 +1679,18 @@ void LLWindowWin32::initCursors()
void LLWindowWin32::setCursor(ECursorType cursor) void LLWindowWin32::updateCursor()
{ {
if (cursor == UI_CURSOR_ARROW if (mNextCursor == UI_CURSOR_ARROW
&& mBusyCount > 0) && mBusyCount > 0)
{ {
cursor = UI_CURSOR_WORKING; mNextCursor = UI_CURSOR_WORKING;
} }
if( mCurrentCursor != cursor ) if( mCurrentCursor != mNextCursor )
{ {
mCurrentCursor = cursor; mCurrentCursor = mNextCursor;
SetCursor( mCursor[cursor] ); SetCursor( mCursor[mNextCursor] );
} }
} }
@@ -1764,6 +1770,8 @@ void LLWindowWin32::gatherInput()
mInputProcessingPaused = FALSE; mInputProcessingPaused = FALSE;
updateCursor();
// clear this once we've processed all mouse messages that might have occurred after // clear this once we've processed all mouse messages that might have occurred after
// we slammed the mouse position // we slammed the mouse position
mMousePositionModified = FALSE; mMousePositionModified = FALSE;

View File

@@ -72,7 +72,7 @@ public:
/*virtual*/ void showCursorFromMouseMove(); /*virtual*/ void showCursorFromMouseMove();
/*virtual*/ void hideCursorUntilMouseMove(); /*virtual*/ void hideCursorUntilMouseMove();
/*virtual*/ BOOL isCursorHidden(); /*virtual*/ BOOL isCursorHidden();
/*virtual*/ void setCursor(ECursorType cursor); /*virtual*/ void updateCursor();
/*virtual*/ ECursorType getCursor() const; /*virtual*/ ECursorType getCursor() const;
/*virtual*/ void captureMouse(); /*virtual*/ void captureMouse();
/*virtual*/ void releaseMouse(); /*virtual*/ void releaseMouse();

View File

@@ -1,40 +0,0 @@
# -*- cmake -*-
project(llxuixml)
include(00-Common)
include(LLCommon)
include(LLMath)
include(LLXML)
include_directories(
${LLCOMMON_INCLUDE_DIRS}
${LLMATH_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS}
)
set(llxuixml_SOURCE_FILES
llinitparam.cpp
lluicolor.cpp
)
set(llxuixml_HEADER_FILES
CMakeLists.txt
llinitparam.h
lluicolor.h
)
set_source_files_properties(${llxuixml_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
list(APPEND llxuixml_SOURCE_FILES ${llxuixml_HEADER_FILES})
add_library (llxuixml ${llxuixml_SOURCE_FILES})
# Libraries on which this library depends, needed for Linux builds
# Sort by high-level to low-level
target_link_libraries(llxuixml
llxml
llcommon
llmath
)

View File

@@ -37,7 +37,6 @@ include(LLUI)
include(LLVFS) include(LLVFS)
include(LLWindow) include(LLWindow)
include(LLXML) include(LLXML)
include(LLXUIXML)
include(LScript) include(LScript)
include(Linking) include(Linking)
include(NDOF) include(NDOF)
@@ -72,7 +71,6 @@ include_directories(
${LLVFS_INCLUDE_DIRS} ${LLVFS_INCLUDE_DIRS}
${LLWINDOW_INCLUDE_DIRS} ${LLWINDOW_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS}
${LLXUIXML_INCLUDE_DIRS}
${LSCRIPT_INCLUDE_DIRS} ${LSCRIPT_INCLUDE_DIRS}
${LSCRIPT_INCLUDE_DIRS}/lscript_compile ${LSCRIPT_INCLUDE_DIRS}/lscript_compile
) )
@@ -98,11 +96,7 @@ set(viewer_SOURCE_FILES
ascentprefschat.cpp ascentprefschat.cpp
ascentprefssys.cpp ascentprefssys.cpp
ascentprefsvan.cpp ascentprefsvan.cpp
#dhparam.cpp
#dsaparam.cpp
emeraldboobutils.cpp emeraldboobutils.cpp
dofloaterhex.cpp
dohexeditor.cpp
floatersculptpreview.cpp floatersculptpreview.cpp
hbfloatergrouptitles.cpp hbfloatergrouptitles.cpp
hgfloatertexteditor.cpp hgfloatertexteditor.cpp
@@ -115,6 +109,7 @@ set(viewer_SOURCE_FILES
jcfloaterareasearch.cpp jcfloaterareasearch.cpp
chatbar_as_cmdline.cpp chatbar_as_cmdline.cpp
qtoolalign.cpp qtoolalign.cpp
NACLantispam.cpp
llaccountingcostmanager.cpp llaccountingcostmanager.cpp
llagent.cpp llagent.cpp
llagentaccess.cpp llagentaccess.cpp
@@ -474,8 +469,6 @@ set(viewer_SOURCE_FILES
llviewerfoldertype.cpp llviewerfoldertype.cpp
llviewergenericmessage.cpp llviewergenericmessage.cpp
llviewergesture.cpp llviewergesture.cpp
#llviewerimage.cpp
#llviewerimagelist.cpp
llviewerinventory.cpp llviewerinventory.cpp
llviewerjoint.cpp llviewerjoint.cpp
llviewerjointattachment.cpp llviewerjointattachment.cpp
@@ -528,7 +521,6 @@ set(viewer_SOURCE_FILES
llvopartgroup.cpp llvopartgroup.cpp
llvosky.cpp llvosky.cpp
llvosurfacepatch.cpp llvosurfacepatch.cpp
llvotextbubble.cpp
llvotree.cpp llvotree.cpp
llvovolume.cpp llvovolume.cpp
llvowater.cpp llvowater.cpp
@@ -576,6 +568,7 @@ set(viewer_HEADER_FILES
CMakeLists.txt CMakeLists.txt
ViewerInstall.cmake ViewerInstall.cmake
NACLantispam.h
sgmemstat.h sgmemstat.h
sgversion.h sgversion.h
llviewerobjectbackup.h llviewerobjectbackup.h
@@ -595,8 +588,6 @@ set(viewer_HEADER_FILES
ascentprefssys.h ascentprefssys.h
ascentprefsvan.h ascentprefsvan.h
emeraldboobutils.h emeraldboobutils.h
dofloaterhex.h
dohexeditor.h
floatersculptpreview.h floatersculptpreview.h
hbfloatergrouptitles.h hbfloatergrouptitles.h
hgfloatertexteditor.h hgfloatertexteditor.h
@@ -976,8 +967,6 @@ set(viewer_HEADER_FILES
llviewerfoldertype.h llviewerfoldertype.h
llviewergenericmessage.h llviewergenericmessage.h
llviewergesture.h llviewergesture.h
#llviewerimage.h
#llviewerimagelist.h
llviewerinventory.h llviewerinventory.h
llviewerjoint.h llviewerjoint.h
llviewerjointattachment.h llviewerjointattachment.h
@@ -1030,7 +1019,6 @@ set(viewer_HEADER_FILES
llvopartgroup.h llvopartgroup.h
llvosky.h llvosky.h
llvosurfacepatch.h llvosurfacepatch.h
llvotextbubble.h
llvotree.h llvotree.h
llvotreenew.h llvotreenew.h
llvovolume.h llvovolume.h
@@ -1372,6 +1360,7 @@ if (FMOD OR FMODEX)
endif (FMOD) endif (FMOD)
if (DARWIN) if (DARWIN)
if(FMOD)
set(fmodwrapper_SOURCE_FILES fmodwrapper.cpp) set(fmodwrapper_SOURCE_FILES fmodwrapper.cpp)
add_library(fmodwrapper SHARED ${fmodwrapper_SOURCE_FILES}) add_library(fmodwrapper SHARED ${fmodwrapper_SOURCE_FILES})
if (FMODEX) if (FMODEX)
@@ -1389,6 +1378,10 @@ if (FMOD OR FMODEX)
) )
set(FMODWRAPPER_LIBRARY fmodwrapper) set(FMODWRAPPER_LIBRARY fmodwrapper)
target_link_libraries(fmodwrapper ${fmodwrapper_needed_LIBRARIES}) target_link_libraries(fmodwrapper ${fmodwrapper_needed_LIBRARIES})
endif(FMOD)
if(FMODEX)
set(FMODWRAPPER_LIBRARY ${FMODEX_LIBRARY})
endif(FMODEX)
else (DARWIN) else (DARWIN)
# fmodwrapper unnecessary on linux or windows, for fmod and fmodex # fmodwrapper unnecessary on linux or windows, for fmod and fmodex
if (FMODEX) if (FMODEX)
@@ -1547,7 +1540,6 @@ target_link_libraries(${VIEWER_BINARY_NAME}
${LLVFS_LIBRARIES} ${LLVFS_LIBRARIES}
${LLWINDOW_LIBRARIES} ${LLWINDOW_LIBRARIES}
${LLXML_LIBRARIES} ${LLXML_LIBRARIES}
${LLXUIXML_LIBRARIES}
${LSCRIPT_LIBRARIES} ${LSCRIPT_LIBRARIES}
${LLMATH_LIBRARIES} ${LLMATH_LIBRARIES}
${LLCOMMON_LIBRARIES} ${LLCOMMON_LIBRARIES}
@@ -1798,7 +1790,7 @@ endif (WINDOWS)
if (DARWIN) if (DARWIN)
# Don't do this here -- it's taken care of by viewer_manifest.py # Don't do this here -- it's taken care of by viewer_manifest.py
# add_custom_command(TARGET ${VIEWER_BINARY_NAME} POST_BUILD # add_custom_command(TARGET ${VIEWER_BINARY_NAME} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libllqtwebkit.dylib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/llplugin/ # COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib/release/libllqtwebkit.dylib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/llplugin/
# DEPENDS ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libllqtwebkit.dylib # DEPENDS ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib/release/libllqtwebkit.dylib
# ) # )
endif (DARWIN) endif (DARWIN)

View File

@@ -2,6 +2,6 @@
CFBundleName = "Singularity"; CFBundleName = "Singularity";
CFBundleShortVersionString = "Singularity Viewer 1.5.0.0"; CFBundleShortVersionString = "Singularity Viewer 1.7.0.0";
CFBundleGetInfoString = "Singularity Viewer 1.5.0.0, Copyright 2010 Siana Gearz"; CFBundleGetInfoString = "Singularity Viewer 1.7.0.0, Copyright 2012 Siana Gearz";

View File

@@ -9,7 +9,7 @@
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>singularity.icns</string> <string>singularity.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.secondlife.indra.viewer</string> <string>org.singularityviewer.singularity</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>

View File

@@ -0,0 +1,406 @@
#include "llviewerprecompiledheaders.h"
#include "NACLantispam.h"
#include "llviewercontrol.h"
#include "llnotificationsutil.h"
#include "llviewerobjectlist.h"
#include "llagent.h"
#include <time.h>
U32 NACLAntiSpamRegistry::globalAmount;
U32 NACLAntiSpamRegistry::globalTime;
bool NACLAntiSpamRegistry::bGlobalQueue;
NACLAntiSpamQueue* NACLAntiSpamRegistry::queues[NACLAntiSpamRegistry::QUEUE_MAX] = {0};
std::tr1::unordered_map<std::string,NACLAntiSpamQueueEntry*> NACLAntiSpamRegistry::globalEntries;
std::tr1::unordered_map<std::string,NACLAntiSpamQueueEntry*>::iterator NACLAntiSpamRegistry::it2;
const std::string COLLISION_SOUNDS[] ={"dce5fdd4-afe4-4ea1-822f-dd52cac46b08","51011582-fbca-4580-ae9e-1a5593f094ec","68d62208-e257-4d0c-bbe2-20c9ea9760bb","75872e8c-bc39-451b-9b0b-042d7ba36cba","6a45ba0b-5775-4ea8-8513-26008a17f873","992a6d1b-8c77-40e0-9495-4098ce539694","2de4da5a-faf8-46be-bac6-c4d74f1e5767","6e3fb0f7-6d9c-42ca-b86b-1122ff562d7d","14209133-4961-4acc-9649-53fc38ee1667","bc4a4348-cfcc-4e5e-908e-8a52a8915fe6","9e5c1297-6eed-40c0-825a-d9bcd86e3193","e534761c-1894-4b61-b20c-658a6fb68157","8761f73f-6cf9-4186-8aaa-0948ed002db1","874a26fd-142f-4173-8c5b-890cd846c74d","0e24a717-b97e-4b77-9c94-b59a5a88b2da","75cf3ade-9a5b-4c4d-bb35-f9799bda7fb2","153c8bf7-fb89-4d89-b263-47e58b1b4774","55c3e0ce-275a-46fa-82ff-e0465f5e8703","24babf58-7156-4841-9a3f-761bdbb8e237","aca261d8-e145-4610-9e20-9eff990f2c12","0642fba6-5dcf-4d62-8e7b-94dbb529d117","25a863e8-dc42-4e8a-a357-e76422ace9b5","9538f37c-456e-4047-81be-6435045608d4","8c0f84c3-9afd-4396-b5f5-9bca2c911c20","be582e5d-b123-41a2-a150-454c39e961c8","c70141d4-ba06-41ea-bcbc-35ea81cb8335","7d1826f4-24c4-4aac-8c2e-eff45df37783","063c97d3-033a-4e9b-98d8-05c8074922cb","00000000-0000-0000-0000-000000000120"};
const int COLLISION_SOUNDS_SIZE=29;
// NaClAntiSpamQueueEntry
NACLAntiSpamQueueEntry::NACLAntiSpamQueueEntry()
{
entryTime=0;
entryAmount=0;
blocked=false;
}
void NACLAntiSpamQueueEntry::clearEntry()
{
entryTime=0;
entryAmount=0;
blocked=false;
}
U32 NACLAntiSpamQueueEntry::getEntryAmount()
{
return entryAmount;
}
U32 NACLAntiSpamQueueEntry::getEntryTime()
{
return entryTime;
}
void NACLAntiSpamQueueEntry::updateEntryAmount()
{
entryAmount++;
}
void NACLAntiSpamQueueEntry::updateEntryTime()
{
entryTime=time(0);
}
void NACLAntiSpamQueueEntry::setBlocked()
{
blocked=true;
}
bool NACLAntiSpamQueueEntry::getBlocked()
{
return blocked;
}
// NaClAntiSpamQueue
NACLAntiSpamQueue::NACLAntiSpamQueue(U32 time, U32 amount)
{
queueTime=time;
queueAmount=amount;
}
void NACLAntiSpamQueue::setAmount(U32 amount)
{
queueAmount=amount;
}
void NACLAntiSpamQueue::setTime(U32 time)
{
queueTime=time;
}
void NACLAntiSpamQueue::clearEntries()
{
for(it = entries.begin(); it != entries.end(); it++)
{
it->second->clearEntry();
}
}
void NACLAntiSpamQueue::purgeEntries()
{
for(it = entries.begin(); it != entries.end(); it++)
{
delete it->second;
}
entries.clear();
}
void NACLAntiSpamQueue::blockEntry(LLUUID& source)
{
it=entries.find(source.asString());
if(it == entries.end())
{
entries[source.asString()]=new NACLAntiSpamQueueEntry();
}
entries[source.asString()]->setBlocked();
}
int NACLAntiSpamQueue::checkEntry(LLUUID& name, U32 multiplier)
{
it=entries.find(name.asString());
if(it != entries.end())
{
if(it->second->getBlocked()) return 2;
U32 eTime=it->second->getEntryTime();
U32 currentTime=time(0);
if((currentTime-eTime) <= queueTime)
{
it->second->updateEntryAmount();
U32 eAmount=it->second->getEntryAmount();
if(eAmount > (queueAmount*multiplier))
{
it->second->setBlocked();
return 1;
}
else
return 0;
}
else
{
it->second->clearEntry();
it->second->updateEntryAmount();
it->second->updateEntryTime();
return 0;
}
}
else
{
entries[name.asString()]=new NACLAntiSpamQueueEntry();
entries[name.asString()]->updateEntryAmount();
entries[name.asString()]->updateEntryTime();
return 0;
}
}
// NaClAntiSpamRegistry
static const char* QUEUE_NAME[NACLAntiSpamRegistry::QUEUE_MAX] = {
"Chat",
"Inventory",
"Instant Message",
"Calling Card",
"Sound",
"Sound Preload",
"Script Dialog",
"Teleport"};
NACLAntiSpamRegistry::NACLAntiSpamRegistry(U32 time, U32 amount)
{
globalTime=time;
globalAmount=amount;
static LLCachedControl<bool> _NACL_AntiSpamGlobalQueue(gSavedSettings,"_NACL_AntiSpamGlobalQueue");
bGlobalQueue=_NACL_AntiSpamGlobalQueue;
for(int queue = 0; queue < QUEUE_MAX; ++queue)
{
queues[queue] = new NACLAntiSpamQueue(time,amount);
}
}
const char* NACLAntiSpamRegistry::getQueueName(U32 queue_id)
{
if(queue_id >= QUEUE_MAX)
return "Unknown";
return QUEUE_NAME[queue_id];
}
void NACLAntiSpamRegistry::registerQueues(U32 time, U32 amount)
{
globalTime=time;
globalAmount=amount;
static LLCachedControl<bool> _NACL_AntiSpamGlobalQueue(gSavedSettings,"_NACL_AntiSpamGlobalQueue");
bGlobalQueue=_NACL_AntiSpamGlobalQueue;
for(int queue = 0; queue < QUEUE_MAX; ++queue)
{
queues[queue] = new NACLAntiSpamQueue(time,amount);
}
}
void NACLAntiSpamRegistry::registerQueue(U32 name, U32 time, U32 amount)
{
/*
it=queues.find(name);
if(it == queues.end())
{
queues[name]=new NACLAntiSpamQueue(time,amount);
}
*/
}
void NACLAntiSpamRegistry::setRegisteredQueueTime(U32 name, U32 time)
{
if(name >= QUEUE_MAX || queues[name] == 0)
{
LL_ERRS("AntiSpam") << "CODE BUG: Attempting to use a antispam queue that was not created or was outside of the reasonable range of queues. Queue: " << getQueueName(name) << llendl;
return;
}
queues[name]->setTime(time);
}
void NACLAntiSpamRegistry::setRegisteredQueueAmount(U32 name, U32 amount)
{
if(name >= QUEUE_MAX || queues[name] == 0)
{
LL_ERRS("AntiSpam") << "CODE BUG: Attempting to use a antispam queue that was not created or was outside of the reasonable range of queues. Queue: " << getQueueName(name) << llendl;
return;
}
queues[name]->setAmount(amount);
}
void NACLAntiSpamRegistry::setAllQueueTimes(U32 time)
{
globalTime=time;
for(int queue = 0; queue < QUEUE_MAX; ++queue)
queues[queue]->setTime(time);
}
void NACLAntiSpamRegistry::setAllQueueAmounts(U32 amount)
{
globalAmount=amount;
for(int queue = 0; queue < QUEUE_MAX; ++queue)
{
if(queue == QUEUE_SOUND || queue == QUEUE_SOUND_PRELOAD)
queues[queue]->setAmount(amount*5);
else
queues[queue]->setAmount(amount);
}
}
void NACLAntiSpamRegistry::clearRegisteredQueue(U32 name)
{
if(name >= QUEUE_MAX || queues[name] == 0)
{
LL_ERRS("AntiSpam") << "CODE BUG: Attempting to use a antispam queue that was not created or was outside of the reasonable range of queues. Queue: " << getQueueName(name) << llendl;
return;
}
queues[name]->clearEntries();
}
void NACLAntiSpamRegistry::purgeRegisteredQueue(U32 name)
{
if(name >= QUEUE_MAX || queues[name] == 0)
{
LL_ERRS("AntiSpam") << "CODE BUG: Attempting to use a antispam queue that was not created or was outside of the reasonable range of queues. Queue: " << getQueueName(name) << llendl;
return;
}
queues[name]->purgeEntries();
}
void NACLAntiSpamRegistry::blockOnQueue(U32 name, LLUUID& source)
{
if(bGlobalQueue)
{
NACLAntiSpamRegistry::blockGlobalEntry(source);
}
else
{
if(name >= QUEUE_MAX || queues[name] == 0)
{
LL_ERRS("AntiSpam") << "CODE BUG: Attempting to use a antispam queue that was not created or was outside of the reasonable range of queues. Queue: " << getQueueName(name) << llendl;
return;
}
queues[name]->blockEntry(source);
}
}
void NACLAntiSpamRegistry::blockGlobalEntry(LLUUID& source)
{
it2=globalEntries.find(source.asString());
if(it2 == globalEntries.end())
{
globalEntries[source.asString()]=new NACLAntiSpamQueueEntry();
}
globalEntries[source.asString()]->setBlocked();
}
bool NACLAntiSpamRegistry::checkQueue(U32 name, LLUUID& source, U32 multiplier, bool silent)
{
if(source.isNull()) return false;
if(gAgent.getID() == source) return false;
LLViewerObject *obj=gObjectList.findObject(source);
if(obj)
if(obj->permYouOwner()) return false;
int result;
if(bGlobalQueue)
{
result=NACLAntiSpamRegistry::checkGlobalEntry(source,multiplier);
}
else
{
if(name >= QUEUE_MAX || queues[name] == 0)
{
LL_ERRS("AntiSpam") << "CODE BUG: Attempting to use a antispam queue that was not created or was outside of the reasonable range of queues. Queue: " << getQueueName(name) << llendl;
return false;
}
result=queues[name]->checkEntry(source,multiplier);
}
if(result==0)
{
return false;
}
else if(result==2)
{
return true;
}
else
{
if(!silent)
{
LLSD args;
args["MESSAGE"] = std::string(getQueueName(name))+": Blocked object "+source.asString();
LLNotificationsUtil::add("SystemMessageTip", args);
}
return true;
}
}
// Global queue stoof
void NACLAntiSpamRegistry::setGlobalQueue(bool value)
{
NACLAntiSpamRegistry::purgeAllQueues();
bGlobalQueue=value;
}
void NACLAntiSpamRegistry::setGlobalAmount(U32 amount)
{
globalAmount=amount;
}
void NACLAntiSpamRegistry::setGlobalTime(U32 time)
{
globalTime=time;
}
void NACLAntiSpamRegistry::clearAllQueues()
{
if(bGlobalQueue)
NACLAntiSpamRegistry::clearGlobalEntries();
else
for(int queue = 0; queue < QUEUE_MAX; ++queue)
{
queues[queue]->clearEntries();
}
}
void NACLAntiSpamRegistry::purgeAllQueues()
{
if(bGlobalQueue)
NACLAntiSpamRegistry::purgeGlobalEntries();
else
for(int queue = 0; queue < QUEUE_MAX; ++queue)
{
queues[queue]->purgeEntries();
}
}
int NACLAntiSpamRegistry::checkGlobalEntry(LLUUID& name, U32 multiplier)
{
it2=globalEntries.find(name.asString());
if(it2 != globalEntries.end())
{
if(it2->second->getBlocked()) return 2;
U32 eTime=it2->second->getEntryTime();
U32 currentTime=time(0);
if((currentTime-eTime) <= globalTime)
{
it2->second->updateEntryAmount();
U32 eAmount=it2->second->getEntryAmount();
if(eAmount > (globalAmount*multiplier))
return 1;
else
return 0;
}
else
{
it2->second->clearEntry();
it2->second->updateEntryAmount();
it2->second->updateEntryTime();
return 0;
}
}
else
{
globalEntries[name.asString()]=new NACLAntiSpamQueueEntry();
globalEntries[name.asString()]->updateEntryAmount();
globalEntries[name.asString()]->updateEntryTime();
return 0;
}
}
void NACLAntiSpamRegistry::clearGlobalEntries()
{
for(it2 = globalEntries.begin(); it2 != globalEntries.end(); it2++)
{
it2->second->clearEntry();
}
}
void NACLAntiSpamRegistry::purgeGlobalEntries()
{
for(it2 = globalEntries.begin(); it2 != globalEntries.end(); it2++)
{
delete it2->second;
it2->second = 0;
}
globalEntries.clear();
}
bool NACLAntiSpamRegistry::handleNaclAntiSpamGlobalQueueChanged(const LLSD& newvalue)
{
setGlobalQueue(newvalue.asBoolean());
return true;
}
bool NACLAntiSpamRegistry::handleNaclAntiSpamTimeChanged(const LLSD& newvalue)
{
setAllQueueTimes(newvalue.asInteger());
return true;
}
bool NACLAntiSpamRegistry::handleNaclAntiSpamAmountChanged(const LLSD& newvalue)
{
setAllQueueAmounts(newvalue.asInteger());
return true;
}

View File

@@ -0,0 +1,93 @@
#ifndef NACLANTISPAM_H
#define NACLANTISPAM_H
#include <boost/tr1/unordered_map.hpp>
#include "stdtypes.h"
#include "lluuid.h"
class NACLAntiSpamQueueEntry
{
friend class NACLAntiSpamQueue;
friend class NACLAntiSpamRegistry;
protected:
NACLAntiSpamQueueEntry();
void clearEntry();
U32 getEntryAmount();
U32 getEntryTime();
void updateEntryAmount();
void updateEntryTime();
bool getBlocked();
void setBlocked();
private:
U32 entryAmount;
U32 entryTime;
bool blocked;
};
class NACLAntiSpamQueue
{
friend class NACLAntiSpamRegistry;
protected:
NACLAntiSpamQueue(U32 time, U32 amount);
void setAmount(U32 amount);
void setTime(U32 time);
void clearEntries();
void purgeEntries();
void blockEntry(LLUUID& source);
int checkEntry(LLUUID& source, U32 multiplier);
private:
std::tr1::unordered_map<std::string,NACLAntiSpamQueueEntry*> entries;
std::tr1::unordered_map<std::string,NACLAntiSpamQueueEntry*>::iterator it;
U32 queueAmount;
U32 queueTime;
};
class NACLAntiSpamRegistry
{
public:
NACLAntiSpamRegistry(U32 time=2, U32 amount=10);
static void registerQueues(U32 time=2, U32 amount=10);
static void registerQueue(U32 name, U32 time, U32 amount);
static void setRegisteredQueueTime(U32 name, U32 time);
static void setRegisteredQueueAmount(U32 name,U32 amount);
static void setAllQueueTimes(U32 amount);
static void setAllQueueAmounts(U32 time);
static bool checkQueue(U32 name, LLUUID& source, U32 multiplier=1, bool silent=false);
static bool handleNaclAntiSpamGlobalQueueChanged(const LLSD& newvalue);
static bool handleNaclAntiSpamTimeChanged(const LLSD& newvalue);
static bool handleNaclAntiSpamAmountChanged(const LLSD& newvalue);
static void clearRegisteredQueue(U32 name);
static void purgeRegisteredQueue(U32 name);
static void clearAllQueues();
static void purgeAllQueues();
static void setGlobalQueue(bool value);
static void setGlobalAmount(U32 amount);
static void setGlobalTime(U32 time);
static void blockOnQueue(U32 name,LLUUID& owner_id);
enum {
QUEUE_CHAT,
QUEUE_INVENTORY,
QUEUE_IM,
QUEUE_CALLING_CARD,
QUEUE_SOUND,
QUEUE_SOUND_PRELOAD,
QUEUE_SCRIPT_DIALOG,
QUEUE_TELEPORT,
QUEUE_MAX
};
private:
static const char* getQueueName(U32 queue_id);
static NACLAntiSpamQueue* queues[QUEUE_MAX];
static std::tr1::unordered_map<std::string,NACLAntiSpamQueueEntry*> globalEntries;
static std::tr1::unordered_map<std::string,NACLAntiSpamQueueEntry*>::iterator it2;
static U32 globalTime;
static U32 globalAmount;
static bool bGlobalQueue;
static int checkGlobalEntry(LLUUID& source, U32 multiplier);
static void clearGlobalEntries();
static void purgeGlobalEntries();
static void blockGlobalEntry(LLUUID& source);
};
extern const std::string COLLISION_SOUNDS[];
extern const int COLLISION_SOUNDS_SIZE;
#endif //NACLANTISPAM_H

View File

@@ -786,6 +786,18 @@
<real>0.7843137254902</real> <real>0.7843137254902</real>
<real>1</real> <real>1</real>
</array> </array>
</map>
<key>5886ec80-cf56-11e1-9b23-0800200c9a66</key>
<map>
<key>name</key>
<string>Voodoo</string>
<key>color</key>
<array>
<real>0.70588235294118</real>
<real>0.7843137254902</real>
<real>0.7843137254902</real>
<real>1</real>
</array>
</map> </map>
<key>734bae36-a197-b087-ee2d-a098d58fed55</key> <key>734bae36-a197-b087-ee2d-a098d58fed55</key>
<map> <map>

View File

@@ -8,7 +8,6 @@
<string>settings_sh.xml</string> <string>settings_sh.xml</string>
<string>settings_rlv.xml</string> <string>settings_rlv.xml</string>
</array> </array>
<key>SianaRenderDeferredInvisiprim</key> <key>SianaRenderDeferredInvisiprim</key>
<map> <map>
<key>Comment</key> <key>Comment</key>
@@ -894,6 +893,83 @@
<string>Boolean</string> <string>Boolean</string>
<key>Value</key> <key>Value</key>
<integer>1</integer> <integer>1</integer>
</map>
<key>_NACL_Antispam</key>
<map>
<key>Comment</key>
<string>When true, all dialogs will be blocked, resets on restart.</string>
<key>Persist</key>
<integer>0</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>_NACL_AntiSpamGlobalQueue</key>
<map>
<key>Comment</key>
<string> </string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>_NACL_AntiSpamTime</key>
<map>
<key>Comment</key>
<string> </string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>2</integer>
</map>
<key>_NACL_AntiSpamAmount</key>
<map>
<key>Comment</key>
<string> </string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>10</integer>
</map>
<key>_NACL_AntiSpamSoundMulti</key>
<map>
<key>Comment</key>
<string> </string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>4</integer>
</map>
<key>_NACL_AntiSpamNewlines</key>
<map>
<key>Comment</key>
<string>How many newlines a message can have before it's considered spam.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>30</integer>
</map>
<key>_NACL_AntiSpamSoundPreloadMulti</key>
<map>
<key>Comment</key>
<string> </string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>4</integer>
</map> </map>
<!-- Vanilla SL settings that are now optionally Account-Specific --> <!-- Vanilla SL settings that are now optionally Account-Specific -->
<key>AgentChatColor</key> <key>AgentChatColor</key>
@@ -1725,6 +1801,17 @@
<key>Value</key> <key>Value</key>
<real>1.0</real> <real>1.0</real>
</map> </map>
<key>AudioLevelUnderwaterRolloff</key>
<map>
<key>Comment</key>
<string>Controls the distance-based dropoff of audio volume when camera is submerged (fraction or multiple of default audio rolloff)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>4.0</real>
</map>
<key>AudioLevelSFX</key> <key>AudioLevelSFX</key>
<map> <map>
<key>Comment</key> <key>Comment</key>
@@ -1796,7 +1883,7 @@
<key>Comment</key> <key>Comment</key>
<string>Enable texture auditting.</string> <string>Enable texture auditting.</string>
<key>Persist</key> <key>Persist</key>
<integer>1</integer> <integer>0</integer>
<key>Type</key> <key>Type</key>
<string>Boolean</string> <string>Boolean</string>
<key>Value</key> <key>Value</key>
@@ -15097,3 +15184,4 @@
</map> </map>
</map> </map>
</llsd> </llsd>

Some files were not shown because too many files have changed in this diff Show More