[mcrux] r162 committed - Injecting FileSystemQTModule to JavaScript. ( partial )

0 views
Skip to first unread message

mc...@googlecode.com

unread,
Nov 28, 2009, 7:17:57 AM11/28/09
to mcru...@googlegroups.com
Revision: 162
Author: mital.d.vora
Date: Sat Nov 28 04:16:50 2009
Log: Injecting FileSystemQTModule to JavaScript. ( partial )

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

Added:
/trunk/src/plugins/FileSystem/FileSystemQtModule.cpp
/trunk/src/plugins/FileSystem/FileSystemQtModule.h
Modified:
/trunk/src/include/mcrux/qt/MQtModule.h
/trunk/src/lib/plugin/MCruxPluginManager.cpp
/trunk/src/lib/window/MCruxQTWindow.cpp
/trunk/src/plugins/FileSystem/FileUtils.cpp
/trunk/src/plugins/FileSystem/FileUtils.h
/trunk/src/src.pro

=======================================
--- /dev/null
+++ /trunk/src/plugins/FileSystem/FileSystemQtModule.cpp Sat Nov 28
04:16:50 2009
@@ -0,0 +1,31 @@
+/**
+* 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 "FileSystemQtModule.h"
+
+static int myTypeID = qRegisterMetaType<FileSystemQtModule*>();
+
+FileSystemQtModule::FileSystemQtModule()
+{
+ this->setObjectName("fileSystem");
+}
+
+FileSystemQtModule::~FileSystemQtModule()
+{
+}
=======================================
--- /dev/null
+++ /trunk/src/plugins/FileSystem/FileSystemQtModule.h Sat Nov 28 04:16:50
2009
@@ -0,0 +1,51 @@
+/**
+* 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 _FILESYSTEMQTMODULE_H_
+#define _FILESYSTEMQTMODULE_H_
+
+#include <iostream>
+
+using namespace std;
+
+#include <QtGui/QtGui>
+
+#include <mcrux/qt/MQtModule.h>
+
+class FileSystemQtModule
+ : public MQtModule
+{
+ Q_OBJECT
+public slots:
+
+ QString *readFile(const QString &filePath)
+ {
+ qDebug() << "Param: " << filePath;
+ return NULL;
+ }
+public:
+
+ FileSystemQtModule();
+ virtual ~FileSystemQtModule();
+};
+
+
+Q_DECLARE_METATYPE(FileSystemQtModule*)
+
+#endif // _FILESYSTEMQTMODULE_H_
=======================================
--- /trunk/src/include/mcrux/qt/MQtModule.h Sun Nov 22 08:49:01 2009
+++ /trunk/src/include/mcrux/qt/MQtModule.h Sat Nov 28 04:16:50 2009
@@ -17,8 +17,8 @@
* @author: Mital Vora.
**/

-#ifndef _MJSCOREOBJECTABSTRACT_H_
-#define _MJSCOREOBJECTABSTRACT_H_
+#ifndef _MQTMODULE_H_
+#define _MQTMODULE_H_

#include <iostream>

@@ -27,7 +27,6 @@
#include <QtGui/QtGui>

#include <mcrux/abstract/MObject.h>
-//#include <mcrux/abstract/MObjectArray.h>

class MQtModule
: public QObject,
@@ -41,4 +40,4 @@
virtual ~MQtModule();
};

-#endif // _MJSCOREOBJECTABSTRACT_H_
+#endif // _MQTMODULE_H_
=======================================
--- /trunk/src/lib/plugin/MCruxPluginManager.cpp Sun Nov 22 08:49:01 2009
+++ /trunk/src/lib/plugin/MCruxPluginManager.cpp Sat Nov 28 04:16:50 2009
@@ -24,6 +24,10 @@
#include "MCruxJSObject.h"
#include <jscore/MJSCoreObject.h>
#include <jscore/MJSCoreObjectFactory.h>
+
+#else // for linux
+
+#include <plugins/FileSystem/FileSystemQtModule.h>
#endif

MCruxPluginManager::MCruxPluginManager(const list<wstring>
extensionPluginNames)
@@ -129,6 +133,13 @@
bool MCruxPluginManager::injectPlugins(QWebView * webView)
{
MQtModule * mcrux = new MQtModule("mcrux");
+// FileSystemQtModule * fs = new FileSystemQtModule();
+// QVariant v = (*fs);
+
+ QVariant v = qVariantFromValue(new FileSystemQtModule());
+ mcrux->setProperty("fileSystem", v);
+ QVariant v1(1);// = new Integer(1);
+ mcrux->setProperty("inte", v1);

webView->page()->mainFrame()->addToJavaScriptWindowObject(mcrux->objectName(),
mcrux);
return true;
}
=======================================
--- /trunk/src/lib/window/MCruxQTWindow.cpp Sun Nov 22 08:49:01 2009
+++ /trunk/src/lib/window/MCruxQTWindow.cpp Sat Nov 28 04:16:50 2009
@@ -19,6 +19,7 @@

#include <string>
using namespace std;
+
#include "MCruxQTWindow.h"


=======================================
--- /trunk/src/plugins/FileSystem/FileUtils.h Sun Jun 28 02:04:57 2009
+++ /trunk/src/plugins/FileSystem/FileUtils.h Sat Nov 28 04:16:50 2009
@@ -27,25 +27,25 @@

enum FileType_en
{
- FILETYPE_FILE = 0,
- FILETYPE_DIRECTORY,
+ FILETYPE_FILE = 0,
+ FILETYPE_DIRECTORY,
};


struct FileInfo
{
- FileType_en fileType;
- long fileSize;
- time_t lastModifiedTime;
- unsigned short permissionMode;
+ FileType_en fileType;
+ long fileSize;
+ time_t lastModifiedTime;
+ unsigned short permissionMode;
};


namespace FileUtils
{
- bool readDirectory(const string& dirName, vector<string>& files);
- FileInfo * getFileInfo(const string& fileName);
- bool Copy(const string& sourceFileName, const string& destFileName);
- bool ReadFile(const string& filename, string& str);
+ bool readDirectory(const string& dirName, vector<string>& files);
+ FileInfo * getFileInfo(const string& fileName);
+ bool Copy(const string& sourceFileName, const string& destFileName);
+ bool ReadFile(const string& filename, string& str);

};
=======================================
--- /trunk/src/src.pro Sun Nov 22 08:49:01 2009
+++ /trunk/src/src.pro Sat Nov 28 04:16:50 2009
@@ -30,6 +30,8 @@
lib/window/MCruxWindowManager.h \
lib/plugin/MCruxPluginManager.h

+HEADERS += plugins/FileSystem/FileSystemQtModule.h
+
SOURCES += bin/mcrux_linux.cpp \
lib/MCrux.cpp \
lib/MCruxSpecParser.cpp \
@@ -41,3 +43,5 @@
lib/window/MCruxWindowManager.cpp \
lib/qt/MQtModule.cpp \
lib/plugin/MCruxPluginManager.cpp
+
+SOURCES += plugins/FileSystem/FileSystemQtModule.cpp
Reply all
Reply to author
Forward
0 new messages