[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17603] branches/web-plugin: the basic Ydea changes, except for enabling python sandbox.

Marcelo Coraça de Freitas mfreitas at ydeasolutions.com.br
Fri Nov 28 21:44:12 CET 2008


Revision: 17603
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17603
Author:   mfreitas
Date:     2008-11-28 21:44:10 +0100 (Fri, 28 Nov 2008)

Log Message:
-----------
the basic Ydea changes, except for enabling python sandbox. We're going to enabled it in the near future for two main reasons:
1. in Windows (ActiveX) the control already runs in a sandbox mode. There is no much harm the plugin can do there.
2. Linux (and firefox in general) is not our main priority right now.

The code to enable sandbox in python is quite simple, but we intend to change the way sandbox will work. Some more thoughs on this later.

Modified Paths:
--------------
    branches/web-plugin/intern/ghost/intern/GHOST_SystemWin32.cpp
    branches/web-plugin/intern/ghost/intern/GHOST_WindowWin32.cpp
    branches/web-plugin/intern/ghost/intern/GHOST_WindowWin32.h
    branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
    branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_Application.h
    branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
    branches/web-plugin/source/gameengine/Ketsji/KX_PythonInit.cpp

Added Paths:
-----------
    branches/web-plugin/source/gameengine/Ketsji/KX_PyParameters.cpp
    branches/web-plugin/source/gameengine/Ketsji/KX_PyParameters.h
    branches/web-plugin/source/gameengine/Ketsji/KX_PyParametersWrapper.cpp
    branches/web-plugin/source/gameengine/Ketsji/KX_PyParametersWrapper.h

Modified: branches/web-plugin/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- branches/web-plugin/intern/ghost/intern/GHOST_SystemWin32.cpp	2008-11-28 18:21:50 UTC (rev 17602)
+++ branches/web-plugin/intern/ghost/intern/GHOST_SystemWin32.cpp	2008-11-28 20:44:10 UTC (rev 17603)
@@ -172,7 +172,7 @@
 	bool stereoVisual, const GHOST_TEmbedderWindowID parentWindow )
 {
 	GHOST_Window* window = 0;
-	window = new GHOST_WindowWin32 (title, left, top, width, height, state, type, stereoVisual);
+	window = new GHOST_WindowWin32 (title, left, top, width, height, state, parentWindow, type, stereoVisual);
 	if (window) {
 		if (window->getValid()) {
 			// Store the pointer to the window
@@ -906,9 +906,9 @@
 		system->pushEvent(event);
 		lResult = 0;
 	}
-	else {
+	//else {
 		lResult = ::DefWindowProc(hwnd, msg, wParam, lParam);
-	}
+	//}
 	return lResult;
 }
 

Modified: branches/web-plugin/intern/ghost/intern/GHOST_WindowWin32.cpp
===================================================================
--- branches/web-plugin/intern/ghost/intern/GHOST_WindowWin32.cpp	2008-11-28 18:21:50 UTC (rev 17602)
+++ branches/web-plugin/intern/ghost/intern/GHOST_WindowWin32.cpp	2008-11-28 20:44:10 UTC (rev 17603)
@@ -101,6 +101,7 @@
 	GHOST_TUns32 width,
 	GHOST_TUns32 height,
 	GHOST_TWindowState state,
+	const GHOST_TEmbedderWindowID parentWindow,
 	GHOST_TDrawingContextType type,
 	const bool stereoVisual)
 :
@@ -117,22 +118,48 @@
 	m_maxPressure(0)
 {
 	if (state != GHOST_kWindowStateFullScreen) {
+		if( parentWindow == 0 ) {
 			/* Convert client size into window size */
-		width += GetSystemMetrics(SM_CXSIZEFRAME)*2;
-		height += GetSystemMetrics(SM_CYSIZEFRAME)*2 + GetSystemMetrics(SM_CYCAPTION);
+			width += GetSystemMetrics(SM_CXSIZEFRAME)*2;
+			height += GetSystemMetrics(SM_CYSIZEFRAME)*2 + GetSystemMetrics(SM_CYCAPTION);
 
-		m_hWnd = ::CreateWindow(
-			s_windowClassName,			// pointer to registered class name
-			title,						// pointer to window name
-			WS_OVERLAPPEDWINDOW,		// window style
-			left,						// horizontal position of window
- 			top,						// vertical position of window
-			width,						// window width
-			height,						// window height
-			0,							// handle to parent or owner window
-			0,							// handle to menu or child-window identifier
-			::GetModuleHandle(0),		// handle to application instance
-			0);							// pointer to window-creation data
+			m_hWnd = ::CreateWindow(
+				s_windowClassName,			// pointer to registered class name
+				title,						// pointer to window name
+				WS_OVERLAPPEDWINDOW,		// window style
+				left,						// horizontal position of window
+ 				top,						// vertical position of window
+				width,						// window width
+				height,						// window height
+				0,							// handle to parent or owner window
+				0,							// handle to menu or child-window identifier
+				::GetModuleHandle(0),		// handle to application instance
+				0);							// pointer to window-creation data
+		}
+		else {
+			// We've got to change width and height to fit the parent window.
+		
+			RECT rc;
+			HWND parent_hWnd = (HWND) parentWindow;
+
+			GetWindowRect(parent_hWnd,&rc);
+			
+			width  = rc.right-rc.left;
+			height = rc.bottom-rc.top;
+
+			m_hWnd = ::CreateWindow(
+				s_windowClassName,		// pointer to registered class name
+				title,				// pointer to window name
+				WS_CHILDWINDOW,			// window style
+				left,				// horizontal position of window
+ 				top,				// vertical position of window
+				width,				// window width
+				height,				// window height
+				parent_hWnd,			// handle to parent or owner window
+				0,				// handle to menu or child-window identifier
+				::GetModuleHandle(0),		// handle to application instance
+				0);				// pointer to window-creation data
+		}
 	}
 	else {
 		m_hWnd = ::CreateWindow(

Modified: branches/web-plugin/intern/ghost/intern/GHOST_WindowWin32.h
===================================================================
--- branches/web-plugin/intern/ghost/intern/GHOST_WindowWin32.h	2008-11-28 18:21:50 UTC (rev 17602)
+++ branches/web-plugin/intern/ghost/intern/GHOST_WindowWin32.h	2008-11-28 20:44:10 UTC (rev 17603)
@@ -69,6 +69,7 @@
 	 * @param top		The coordinate of the top edge of the window.
 	 * @param width		The width the window.
 	 * @param height	The height the window.
+	 * @param parentWindow	Parent (embedder) window
 	 * @param state		The state the window is initially opened with.
 	 * @param type		The type of drawing context installed in this window.
 	 * @param stereoVisual	Stereo visual for quad buffered stereo.
@@ -80,6 +81,7 @@
 		GHOST_TUns32 width,
 		GHOST_TUns32 height,
 		GHOST_TWindowState state,
+		const GHOST_TEmbedderWindowID parentWindow,
 		GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
 		const bool stereoVisual = false
 	);

Modified: branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
===================================================================
--- branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_Application.cpp	2008-11-28 18:21:50 UTC (rev 17602)
+++ branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_Application.cpp	2008-11-28 20:44:10 UTC (rev 17603)
@@ -131,7 +131,10 @@
 	  m_blenderglslmat(0),
 	  m_pyGlobalDictString(0),
 	  m_pyGlobalDictString_Length(0)
+	 
 {
+	parameters = NULL;
+	
 	fSystem = system;
 }
 
@@ -301,6 +304,15 @@
 
 #endif
 
+
+void GPG_Application::setPyParameters(KX_PyParameters *params) {
+	this->parameters = params;
+}
+
+
+
+
+
 bool GPG_Application::startWindow(STR_String& title,
 	int windowLeft,
 	int windowTop,
@@ -686,7 +698,7 @@
 		initGameKeys();
 		initPythonConstraintBinding();
 		initMathutils();
-        initVideoTexture();
+        //initVideoTexture();
 
 		// Set the GameLogic.globalDict from marshal'd data, so we can
 		// load new blend files and keep data in GameLogic.globalDict

Modified: branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_Application.h
===================================================================
--- branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_Application.h	2008-11-28 18:21:50 UTC (rev 17602)
+++ branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_Application.h	2008-11-28 20:44:10 UTC (rev 17603)
@@ -30,6 +30,8 @@
 
 #include "GHOST_IEventConsumer.h"
 #include "STR_String.h"
+#include "KX_PythonInit.h"
+#include "KX_PyParameters.h"
 
 #ifdef WIN32
 #include <wtypes.h>
@@ -68,6 +70,10 @@
 			bool startScreenSaverPreview(HWND parentWindow,	const bool stereoVisual, const int stereoMode);
 #endif
 
+	
+
+	void setPyParameters(KX_PyParameters *params);
+
 	virtual	bool processEvent(GHOST_IEvent* event);
 			int getExitRequested(void);
 			const STR_String& getExitString(void);
@@ -154,5 +160,10 @@
 	 */
 	char* m_pyGlobalDictString;
 	int m_pyGlobalDictString_Length;
+
+
+	KX_PyParameters *parameters;
+	
 };
 
+

Modified: branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
===================================================================
--- branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp	2008-11-28 18:21:50 UTC (rev 17602)
+++ branches/web-plugin/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp	2008-11-28 20:44:10 UTC (rev 17603)
@@ -45,6 +45,8 @@
 #include "GEN_messaging.h"
 #include "KX_KetsjiEngine.h"
 #include "KX_PythonInit.h"
+#include "KX_PyParameters.h"
+#include "KX_PyParametersWrapper.h"
 
 /**********************************
 * Begin Blender include block
@@ -183,9 +185,8 @@
 	printf("                   anaglyph         (Red-Blue glasses)\n");
 	printf("                   vinterlace       (Vertical interlace for autostereo display)\n");
 	printf("                             depending on the type of stereo you want\n");
-#ifndef _WIN32
+	printf("  -P: parameters for python scripts conform to the format param1=val1;param2=val2;paramN=valN.\n");
 	printf("  -i: parent windows ID \n");
-#endif
 #ifdef _WIN32
 	printf("  -c: keep console window open\n");
 #endif
@@ -305,9 +306,9 @@
 	int fullScreenBpp = 32;
 	int fullScreenFrequency = 60;
 	GHOST_TEmbedderWindowID parentWindow = 0;
+	
+	KX_PyParameters *params = NULL;
 
-
-	
 #ifdef __linux__
 #ifdef __alpha__
 	signal (SIGFPE, SIG_IGN);
@@ -483,20 +484,27 @@
 				usage(argv[0]);
 				return 0;
 				break;
-#ifndef _WIN32
 			case 'i':
 				i++;
 				if ( (i + 1) < argc )
-					parentWindow = atoi(argv[i++]); 					
+					parentWindow = atoi(argv[i++]);
 #ifndef NDEBUG
-				printf("XWindows ID = %d\n", parentWindow);
+			printf("Windows ID = %d\n", parentWindow);
 #endif //NDEBUG
+				break;
 
-#endif  // _WIN32			
+			case 'P':
+				{
+					i++;
+					params = new KX_PyParameters(argv[i]);
+				}
+				break;
+
 			case 'c':
 				i++;
 				closeConsole = false;
 				break;
+
 			case 's':  // stereo
 				i++;
 				if ((i + 1) < argc)
@@ -603,6 +611,10 @@
 				char pathname[FILE_MAXDIR + FILE_MAXFILE];
 				char *titlename;
 
+				
+				
+				app.setPyParameters(params);
+			
 				get_filename(argc, argv, filename);
 				if(filename[0])
 					BLI_convertstringcwd(filename);
@@ -818,3 +830,4 @@
 }
 
 
+

Added: branches/web-plugin/source/gameengine/Ketsji/KX_PyParameters.cpp
===================================================================
--- branches/web-plugin/source/gameengine/Ketsji/KX_PyParameters.cpp	                        (rev 0)
+++ branches/web-plugin/source/gameengine/Ketsji/KX_PyParameters.cpp	2008-11-28 20:44:10 UTC (rev 17603)
@@ -0,0 +1,99 @@
+/**
+ * $Id: KX_PyParameters.h 16558 2008-09-16 19:25:35Z blendix $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list