diff options
Diffstat (limited to 'linden/indra/llplugin')
-rwxr-xr-x | linden/indra/llplugin/llpluginclassmedia.cpp | 9 | ||||
-rwxr-xr-x | linden/indra/llplugin/llpluginclassmedia.h | 5 | ||||
-rwxr-xr-x | linden/indra/llplugin/llpluginmessage.cpp | 13 | ||||
-rwxr-xr-x | linden/indra/llplugin/llpluginprocesschild.cpp | 57 | ||||
-rwxr-xr-x | linden/indra/llplugin/llpluginprocesschild.h | 6 |
5 files changed, 84 insertions, 6 deletions
diff --git a/linden/indra/llplugin/llpluginclassmedia.cpp b/linden/indra/llplugin/llpluginclassmedia.cpp index f0a44f7..31a9d1d 100755 --- a/linden/indra/llplugin/llpluginclassmedia.cpp +++ b/linden/indra/llplugin/llpluginclassmedia.cpp | |||
@@ -1143,6 +1143,15 @@ void LLPluginClassMedia::setBrowserUserAgent(const std::string& user_agent) | |||
1143 | sendMessage(message); | 1143 | sendMessage(message); |
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | #if LL_WINDOWS | ||
1147 | void LLPluginClassMedia::showConsole() | ||
1148 | { | ||
1149 | LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "show_console"); | ||
1150 | |||
1151 | sendMessage(message); | ||
1152 | } | ||
1153 | #endif | ||
1154 | |||
1146 | void LLPluginClassMedia::crashPlugin() | 1155 | void LLPluginClassMedia::crashPlugin() |
1147 | { | 1156 | { |
1148 | LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "crash"); | 1157 | LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "crash"); |
diff --git a/linden/indra/llplugin/llpluginclassmedia.h b/linden/indra/llplugin/llpluginclassmedia.h index 0004971..098312d 100755 --- a/linden/indra/llplugin/llpluginclassmedia.h +++ b/linden/indra/llplugin/llpluginclassmedia.h | |||
@@ -229,6 +229,11 @@ public: | |||
229 | std::string getMediaName() const { return mMediaName; }; | 229 | std::string getMediaName() const { return mMediaName; }; |
230 | std::string getMediaDescription() const { return mMediaDescription; }; | 230 | std::string getMediaDescription() const { return mMediaDescription; }; |
231 | 231 | ||
232 | #if LL_WINDOWS | ||
233 | //Open a debug console for this plugin. | ||
234 | void showConsole(); | ||
235 | #endif | ||
236 | |||
232 | // Crash the plugin. If you use this outside of a testbed, you will be punished. | 237 | // Crash the plugin. If you use this outside of a testbed, you will be punished. |
233 | void crashPlugin(); | 238 | void crashPlugin(); |
234 | 239 | ||
diff --git a/linden/indra/llplugin/llpluginmessage.cpp b/linden/indra/llplugin/llpluginmessage.cpp index 0810a04..9c4940a 100755 --- a/linden/indra/llplugin/llpluginmessage.cpp +++ b/linden/indra/llplugin/llpluginmessage.cpp | |||
@@ -368,7 +368,8 @@ std::string LLPluginMessage::generate(void) const | |||
368 | 368 | ||
369 | // Pretty XML may be slightly easier to deal with while debugging... | 369 | // Pretty XML may be slightly easier to deal with while debugging... |
370 | // LLSDSerialize::toXML(mMessage, result); | 370 | // LLSDSerialize::toXML(mMessage, result); |
371 | LLSDSerialize::toPrettyXML(mMessage, result); | 371 | // LLSDSerialize::toPrettyXML(mMessage, result); |
372 | result << mMessage; | ||
372 | 373 | ||
373 | return result.str(); | 374 | return result.str(); |
374 | } | 375 | } |
@@ -383,10 +384,12 @@ int LLPluginMessage::parse(const std::string &message) | |||
383 | // clear any previous state | 384 | // clear any previous state |
384 | clear(); | 385 | clear(); |
385 | 386 | ||
386 | std::istringstream input(message); | 387 | std::istringstream input(message); |
387 | 388 | ||
388 | S32 parse_result = LLSDSerialize::fromXML(mMessage, input); | 389 | |
389 | 390 | // S32 parse_result = LLSDSerialize::fromXML(test, input); | |
391 | S32 parse_result = LLSDSerialize::fromNotation( mMessage, input, LLSDSerialize::SIZE_UNLIMITED) ; | ||
392 | |||
390 | return (int)parse_result; | 393 | return (int)parse_result; |
391 | } | 394 | } |
392 | 395 | ||
diff --git a/linden/indra/llplugin/llpluginprocesschild.cpp b/linden/indra/llplugin/llpluginprocesschild.cpp index 0d95cac..168236e 100755 --- a/linden/indra/llplugin/llpluginprocesschild.cpp +++ b/linden/indra/llplugin/llpluginprocesschild.cpp | |||
@@ -42,6 +42,14 @@ | |||
42 | #include "llpluginmessagepipe.h" | 42 | #include "llpluginmessagepipe.h" |
43 | #include "llpluginmessageclasses.h" | 43 | #include "llpluginmessageclasses.h" |
44 | 44 | ||
45 | #if LL_WINDOWS | ||
46 | #include <windows.h> | ||
47 | #include <fcntl.h> | ||
48 | #include <io.h> | ||
49 | #include <iostream> | ||
50 | #include <fstream> | ||
51 | #endif | ||
52 | |||
45 | static const F32 HEARTBEAT_SECONDS = 1.0f; | 53 | static const F32 HEARTBEAT_SECONDS = 1.0f; |
46 | static const F32 PLUGIN_IDLE_SECONDS = 1.0f / 100.0f; // Each call to idle will give the plugin this much time. | 54 | static const F32 PLUGIN_IDLE_SECONDS = 1.0f / 100.0f; // Each call to idle will give the plugin this much time. |
47 | 55 | ||
@@ -420,6 +428,12 @@ void LLPluginProcessChild::receiveMessageRaw(const std::string &message) | |||
420 | { | 428 | { |
421 | mSleepTime = parsed.getValueReal("time"); | 429 | mSleepTime = parsed.getValueReal("time"); |
422 | } | 430 | } |
431 | #if LL_WINDOWS | ||
432 | else if(message_name == "show_console") | ||
433 | { | ||
434 | createConsole(); | ||
435 | } | ||
436 | #endif | ||
423 | else if(message_name == "crash") | 437 | else if(message_name == "crash") |
424 | { | 438 | { |
425 | // Crash the plugin | 439 | // Crash the plugin |
@@ -569,3 +583,46 @@ void LLPluginProcessChild::deliverQueuedMessages() | |||
569 | } | 583 | } |
570 | } | 584 | } |
571 | } | 585 | } |
586 | |||
587 | #if LL_WINDOWS | ||
588 | void LLPluginProcessChild::createConsole() | ||
589 | { | ||
590 | const S32 MAX_CONSOLE_LINES = 500; | ||
591 | |||
592 | int h_con_handle; | ||
593 | long l_std_handle; | ||
594 | |||
595 | CONSOLE_SCREEN_BUFFER_INFO coninfo; | ||
596 | FILE *fp; | ||
597 | |||
598 | // allocate a console for this app | ||
599 | AllocConsole(); | ||
600 | |||
601 | // set the screen buffer to be big enough to let us scroll text | ||
602 | GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); | ||
603 | coninfo.dwSize.Y = MAX_CONSOLE_LINES; | ||
604 | SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); | ||
605 | |||
606 | // redirect unbuffered STDOUT to the console | ||
607 | l_std_handle = (long)GetStdHandle(STD_OUTPUT_HANDLE); | ||
608 | h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT); | ||
609 | fp = _fdopen( h_con_handle, "w" ); | ||
610 | *stdout = *fp; | ||
611 | setvbuf( stdout, NULL, _IONBF, 0 ); | ||
612 | |||
613 | // redirect unbuffered STDIN to the console | ||
614 | l_std_handle = (long)GetStdHandle(STD_INPUT_HANDLE); | ||
615 | h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT); | ||
616 | fp = _fdopen( h_con_handle, "r" ); | ||
617 | *stdin = *fp; | ||
618 | setvbuf( stdin, NULL, _IONBF, 0 ); | ||
619 | |||
620 | // redirect unbuffered STDERR to the console | ||
621 | l_std_handle = (long)GetStdHandle(STD_ERROR_HANDLE); | ||
622 | h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT); | ||
623 | fp = _fdopen( h_con_handle, "w" ); | ||
624 | *stderr = *fp; | ||
625 | setvbuf( stderr, NULL, _IOFBF, 1024 ); //Assigning a buffer improves speed a LOT, esp on vista/win7 | ||
626 | //_IOLBF is borked. | ||
627 | } | ||
628 | #endif \ No newline at end of file | ||
diff --git a/linden/indra/llplugin/llpluginprocesschild.h b/linden/indra/llplugin/llpluginprocesschild.h index 5d643d7..6d864bb 100755 --- a/linden/indra/llplugin/llpluginprocesschild.h +++ b/linden/indra/llplugin/llpluginprocesschild.h | |||
@@ -76,7 +76,11 @@ public: | |||
76 | 76 | ||
77 | // Inherited from LLPluginInstanceMessageListener | 77 | // Inherited from LLPluginInstanceMessageListener |
78 | /* virtual */ void receivePluginMessage(const std::string &message); | 78 | /* virtual */ void receivePluginMessage(const std::string &message); |
79 | 79 | ||
80 | #if LL_WINDOWS | ||
81 | void createConsole(); | ||
82 | #endif | ||
83 | |||
80 | private: | 84 | private: |
81 | 85 | ||
82 | enum EState | 86 | enum EState |