[mcrux] r160 committed - Adding "mcrux" object to JavaScript Context.

0 views
Skip to first unread message

codesite...@google.com

unread,
Nov 22, 2009, 11:49:31 AM11/22/09
to mcru...@googlegroups.com
Revision: 160
Author: mital.d.vora
Date: Sun Nov 22 08:49:01 2009
Log: Adding "mcrux" object to JavaScript Context.


http://code.google.com/p/mcrux/source/detail?r=160

Added:
/trunk/src/include/mcrux/qt
/trunk/src/include/mcrux/qt/MQtModule.h
/trunk/src/lib/qt
/trunk/src/lib/qt/MQtModule.cpp
Modified:
/trunk/src/include/mcrux/abstract/MObject.h
/trunk/src/include/mcrux/jscore/MJSCoreObject.h
/trunk/src/lib/plugin/MCruxPluginManager.cpp
/trunk/src/lib/plugin/MCruxPluginManager.h
/trunk/src/lib/window/MCruxQTWindow.cpp
/trunk/src/lib/window/MCruxQTWindow.h
/trunk/src/lib/window/MCruxWindowManager.cpp
/trunk/src/src.pro

=======================================
--- /dev/null
+++ /trunk/src/include/mcrux/qt/MQtModule.h Sun Nov 22 08:49:01 2009
@@ -0,0 +1,44 @@
+/**
+* copyright (C) 2009 Mital Vora. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* 3. Neither the name of MCrux nor the names of its contributors may be
+* used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* @author: Mital Vora.
+**/
+
+#ifndef _MJSCOREOBJECTABSTRACT_H_
+#define _MJSCOREOBJECTABSTRACT_H_
+
+#include <iostream>
+
+using namespace std;
+
+#include <QtGui/QtGui>
+
+#include <mcrux/abstract/MObject.h>
+//#include <mcrux/abstract/MObjectArray.h>
+
+class MQtModule
+ : public QObject,
+ public MObject
+{
+ Q_OBJECT
+
+public:
+
+ MQtModule(const string & _name = "MQtModule");
+ virtual ~MQtModule();
+};
+
+#endif // _MJSCOREOBJECTABSTRACT_H_
=======================================
--- /dev/null
+++ /trunk/src/lib/qt/MQtModule.cpp Sun Nov 22 08:49:01 2009
@@ -0,0 +1,30 @@
+/**
+* copyright (C) 2009 Mital Vora. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* 3. Neither the name of MCrux nor the names of its contributors may be
+* used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* @author: Mital Vora.
+**/
+
+#include <mcrux/qt/MQtModule.h>
+
+
+MQtModule::MQtModule(const string& _name)
+{
+ this->setObjectName(_name.c_str());
+}
+
+MQtModule::~MQtModule()
+{
+}
=======================================
--- /trunk/src/include/mcrux/abstract/MObject.h Sat Oct 31 20:31:05 2009
+++ /trunk/src/include/mcrux/abstract/MObject.h Sun Nov 22 08:49:01 2009
@@ -21,11 +21,9 @@
#define _MOBJECT_H_


-#include <mcrux/abstract/callback.h>
-
#ifdef WIN32
+#include <mcrux/abstract/callback.h>
#include <win32/MCruxExport.h>
-#endif

class MObject;
class MObjectArray;
@@ -33,6 +31,11 @@

typedef Callback2<const MObjectArray&, MObjectContainer &>::Type
MCruxMethodCallback;

+#else // for linux
+
+#define MCRUX_API
+
+#endif

class MCRUX_API MObject
{
=======================================
--- /trunk/src/lib/plugin/MCruxPluginManager.cpp Sat Nov 21 04:05:39 2009
+++ /trunk/src/lib/plugin/MCruxPluginManager.cpp Sun Nov 22 08:49:01 2009
@@ -123,4 +123,14 @@
// TODO: inject a new object called currentWindow
// this object will be responsible for handling various events of
currentwindow.
}
+#else // for linux
+
+
+bool MCruxPluginManager::injectPlugins(QWebView * webView)
+{
+ MQtModule * mcrux = new MQtModule("mcrux");
+
webView->page()->mainFrame()->addToJavaScriptWindowObject(mcrux->objectName(),
mcrux);
+ return true;
+}
+
#endif
=======================================
--- /trunk/src/lib/plugin/MCruxPluginManager.h Sat Nov 21 04:05:39 2009
+++ /trunk/src/lib/plugin/MCruxPluginManager.h Sun Nov 22 08:49:01 2009
@@ -32,6 +32,8 @@
#ifdef WIN32
#include <WebKit/WebKit.h>
#include "MCruxJSObject.h"
+#else // for linux
+#include <mcrux/qt/MQtModule.h>
#endif

#include <mcrux/MCrux.h>
@@ -46,9 +48,9 @@
{
bool pluginDllsLoaded;
list<wstring> pluginNames;
-#ifdef WIN32
map<string, MObject *> plugins;

+#ifdef WIN32
bool AddPlugin(const wstring & pluginName, JSContextRef ctx);
void loadExtensionPlugins(JSContextRef ctx);
MObject * getMCruxJSObject(JSContextRef ctx);
@@ -64,6 +66,8 @@
HRESULT injectPlugins(IWebView *webView,
JSContextRef context,
JSObjectRef windowScriptObject);
+#else // for linux
+ bool injectPlugins(QWebView * webView);
#endif
};

=======================================
--- /trunk/src/lib/window/MCruxQTWindow.cpp Sun Nov 8 04:26:31 2009
+++ /trunk/src/lib/window/MCruxQTWindow.cpp Sun Nov 22 08:49:01 2009
@@ -22,11 +22,10 @@
#include "MCruxQTWindow.h"


-MCruxQTWindow::MCruxQTWindow(const MCruxWindowConfiguration * _config)
- : MCruxWindow(_config)
-#ifndef WIN32 // for linux
- , webView(this)
-#endif
+MCruxQTWindow::MCruxQTWindow(const MCruxWindowConfiguration * config,
+ MCruxPluginManager * pluginManager, MCruxWindowManager *
windowManager)
+ : MCruxWindow(config),
+ webView(this)
{
webView.createWebView();
if(!webView.navigateTo(config->getURL()))
@@ -34,8 +33,8 @@
cerr << "Error navigating to url:" << endl;
}
connect(webView.getWebView()->page()->mainFrame(),
SIGNAL(javaScriptWindowObjectCleared()), this,
SLOT(javaScriptWindowObjectCleared()));
- // get the mainFrame and call addToJavaScriptWindowObject
- //webView->page()->mainFrame();
+
+ pluginManager->injectPlugins(webView.getWebView());
}


=======================================
--- /trunk/src/lib/window/MCruxQTWindow.h Sat Nov 21 04:05:39 2009
+++ /trunk/src/lib/window/MCruxQTWindow.h Sun Nov 22 08:49:01 2009
@@ -22,22 +22,12 @@

#include <QtGui/QtGui>
#include <abstract/MCruxWindow.h>
+#include <plugin/MCruxPluginManager.h>
#include <window/MCruxWindowConfiguration.h>

#include "MCruxWebView.h"
-//#include "plugin/MCruxPluginManager.h"
-
-class MyObject :public QObject
-{
- Q_OBJECT
-
-public slots:
- void myFunction(){
- cout << "Hello World" << endl;
- }
- public:
- MyObject() { }
-};
+
+class MCruxWindowManager;

class MCruxQTWindow
: public QMainWindow,
@@ -52,7 +42,9 @@
void javaScriptWindowObjectCleared();

public:
- MCruxQTWindow(const MCruxWindowConfiguration * _config);
+ MCruxQTWindow(const MCruxWindowConfiguration * config,
+ MCruxPluginManager * pluginManager,
+ MCruxWindowManager * windowManager);
virtual ~MCruxQTWindow();

virtual int ShowWindow();
=======================================
--- /trunk/src/lib/window/MCruxWindowManager.cpp Sat Nov 21 04:05:39 2009
+++ /trunk/src/lib/window/MCruxWindowManager.cpp Sun Nov 22 08:49:01 2009
@@ -41,7 +41,7 @@
#ifdef WIN32
newWindow = new MCruxWin32Window(windowConfig, pluginManager, this);
#else
- newWindow = new MCruxQTWindow(windowConfig);
+ newWindow = new MCruxQTWindow(windowConfig, pluginManager, this);
#endif

newWindow->ShowWindow();
=======================================
--- /trunk/src/src.pro Sat Nov 21 04:05:39 2009
+++ /trunk/src/src.pro Sun Nov 22 08:49:01 2009
@@ -6,6 +6,8 @@
TARGET = mcrux.bin
LIBS += -lxml2
QT += webkit
+OBJECTS_DIR = ./obj
+MOC_DIR = ./obj
DEPENDPATH += . \
/usr/include/libxml2 \
bin \
@@ -20,7 +22,8 @@
HEADERS += lib/MCruxSpecParser.h \
lib/MCruxWebView.h \
include/mcrux/MCrux.h \
- include/mcrux/abstract/callback.h \
+ include/mcrux/abstract/MObject.h \
+ include/mcrux/qt/MQtModule.h \
lib/abstract/MCruxWindow.h \
lib/window/MCruxQTWindow.h \
lib/window/MCruxWindowConfiguration.h \
@@ -31,8 +34,10 @@
lib/MCrux.cpp \
lib/MCruxSpecParser.cpp \
lib/MCruxWebView.cpp \
+ lib/abstract/MObject.cpp \
lib/abstract/MCruxWindow.cpp \
lib/window/MCruxQTWindow.cpp \
lib/window/MCruxWindowConfiguration.cpp \
lib/window/MCruxWindowManager.cpp \
+ lib/qt/MQtModule.cpp \
lib/plugin/MCruxPluginManager.cpp
Reply all
Reply to author
Forward
0 new messages