|
From: CVS C. to T. <the...@li...> - 2011-01-15 23:06:28
|
Revision: 605
http://themis.svn.sourceforge.net/themis/?rev=605&view=rev
Author: mark_hellegers
Date: 2011-01-15 23:06:22 +0000 (Sat, 15 Jan 2011)
Log Message:
-----------
Added DOMEntry class. Now used to pass around the DOM from the HTML parser instead of passing the pointer directly. Doesn't include any other information yet. Converted the renderer and the dom viewer addons to find the information the new way.
Modified Paths:
--------------
trunk/themis/common/BaseEntry.cpp
trunk/themis/common/BaseEntry.hpp
trunk/themis/framework/SiteHandler.cpp
trunk/themis/framework/SiteHandler.h
trunk/themis/makefile
trunk/themis/modules/DOMView/DOMViewer.cpp
trunk/themis/modules/HTMLParser/HTMLParser.cpp
trunk/themis/modules/HTMLParser/HTMLParser.h
trunk/themis/modules/Renderer/TRenderer.cpp
Added Paths:
-----------
trunk/themis/common/DOMEntry.cpp
trunk/themis/common/DOMEntry.hpp
Modified: trunk/themis/common/BaseEntry.cpp
===================================================================
--- trunk/themis/common/BaseEntry.cpp 2011-01-15 21:28:55 UTC (rev 604)
+++ trunk/themis/common/BaseEntry.cpp 2011-01-15 23:06:22 UTC (rev 605)
@@ -33,6 +33,8 @@
*/
+#include <stdio.h>
+
// Themis headers
#include "BaseEntry.hpp"
@@ -65,19 +67,32 @@
BaseEntry * BaseEntry :: getEntry(int32 aId) {
+ printf("Trying to find %ld\n", aId);
+
BaseEntry * result = NULL;
// browse through the entry list to find the UrlEntry with the matching id
vector<BaseEntry *>::iterator it = fChildEntries.begin();
while (it != fChildEntries.end() && result == NULL) {
- if (((BaseEntry *)*it)->getId() == aId) {
+ BaseEntry * entry = (BaseEntry *)*it;
+ if (entry->getId() == aId) {
result = *it;
}
else {
- it++;
+ result = entry->getEntry(aId);
+ if (result == NULL) {
+ it++;
+ }
}
}
+ if (result == NULL) {
+ printf("Failed to find %ld\n", aId);
+ }
+ else {
+ printf("Found %ld\n", aId);
+ }
+
return result;
}
@@ -136,22 +151,38 @@
};
}
+void BaseEntry :: set(const string aName, SharedPtr aValue) {
+
+ if (mSharedPtrs.count(aName) == 0) {
+ mSharedPtrs.insert(
+ map<string, SharedPtr>::value_type(aName, aValue));
+ }
+ else {
+ mSharedPtrs[aName] = aValue;
+ };
+}
+
string BaseEntry :: getString(const string aName) {
return mStrings[aName];
}
bool BaseEntry :: getBoolean(const string aName) {
-
+
return mBooleans[aName];
}
int BaseEntry :: getInteger(const string aName) {
-
+
return mIntegers[aName];
}
void * BaseEntry :: getPointer(const string aName) {
-
+
return mPointers[aName];
}
+
+SharedPtr BaseEntry :: getSharedPtr(const string aName) {
+
+ return mSharedPtrs[aName];
+}
Modified: trunk/themis/common/BaseEntry.hpp
===================================================================
--- trunk/themis/common/BaseEntry.hpp 2011-01-15 21:28:55 UTC (rev 604)
+++ trunk/themis/common/BaseEntry.hpp 2011-01-15 23:06:22 UTC (rev 605)
@@ -47,11 +47,18 @@
// BeOS headers
#include <be/support/SupportDefs.h>
+// Boost headers
+#include "boost/shared_ptr.hpp"
+#include "boost/weak_ptr.hpp"
+
// Namespaces used
using std::map;
using std::string;
using std::vector;
+// Typedefs declared.
+typedef boost::shared_ptr<void> SharedPtr;
+
class BaseEntry {
private:
@@ -61,6 +68,7 @@
map<string, bool> mBooleans;
map<string, int> mIntegers;
map<string, void *> mPointers;
+ map<string, SharedPtr> mSharedPtrs;
protected:
vector<BaseEntry *> fChildEntries;
@@ -76,10 +84,12 @@
void set(const string aName, const bool aValue);
void set(const string aName, const int aValue);
void set(const string aName, void * aValue);
+ void set(const string aName, SharedPtr aValue);
string getString(const string aName);
bool getBoolean(const string aName);
int getInteger(const string aName);
void * getPointer(const string aName);
+ SharedPtr getSharedPtr(const string aName);
};
Added: trunk/themis/common/DOMEntry.cpp
===================================================================
--- trunk/themis/common/DOMEntry.cpp (rev 0)
+++ trunk/themis/common/DOMEntry.cpp 2011-01-15 23:06:22 UTC (rev 605)
@@ -0,0 +1,57 @@
+/*
+ Copyright (c) 2011 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: January 15, 2011
+*/
+
+/* DOMEntry implementation
+ See DOMEntry.hpp for more information
+*/
+
+// Standard C headers
+#include <stdio.h>
+
+// DOM headers
+#include "TDocument.h"
+
+// SGMLParser headers
+#include "DOMEntry.hpp"
+
+// Constants declared
+const string kDOMDocument = "DOM Document";
+
+DOMEntry :: DOMEntry(int32 aId, TDocumentPtr aDocument)
+ : BaseEntry(aId) {
+
+ set(kDOMDocument, shared_static_cast<void>(aDocument));
+
+}
+
+TDocumentPtr DOMEntry :: getDocument() {
+
+ return shared_static_cast<TDocument>(getSharedPtr(kDOMDocument));
+}
Added: trunk/themis/common/DOMEntry.hpp
===================================================================
--- trunk/themis/common/DOMEntry.hpp (rev 0)
+++ trunk/themis/common/DOMEntry.hpp 2011-01-15 23:06:22 UTC (rev 605)
@@ -0,0 +1,49 @@
+/*
+ Copyright (c) 2011 Mark Hellegers. All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or
+ sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice
+ shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Original Author: Mark Hellegers (ma...@fi...)
+ Project Start Date: October 18, 2000
+ Class Start Date: January 15, 2011
+*/
+
+#ifndef DOMENTRY_HPP
+#define DOMENTRY_HPP
+
+// DOM headers
+#include "DOMSupport.h"
+
+// Themis headers
+#include "BaseEntry.hpp"
+
+class DOMEntry : public BaseEntry {
+
+ public:
+ DOMEntry(int32 aId, TDocumentPtr aDocument);
+
+ TDocumentPtr getDocument();
+
+};
+
+#endif
Modified: trunk/themis/framework/SiteHandler.cpp
===================================================================
--- trunk/themis/framework/SiteHandler.cpp 2011-01-15 21:28:55 UTC (rev 604)
+++ trunk/themis/framework/SiteHandler.cpp 2011-01-15 23:06:22 UTC (rev 605)
@@ -15,6 +15,7 @@
#include "ThemisIcons.h"
#include "../common/commondefs.h"
#include "../common/cacheplug.h"
+#include "../common/BaseEntry.hpp"
#include "UrlEntry.h"
#include "SiteEntry.h"
#include "SiteHandler.h"
@@ -102,6 +103,23 @@
fLocker->Unlock();
}
+void SiteHandler :: AddEntry(BaseEntry * aEntry,
+ int32 aSiteId,
+ int32 aParentId) {
+
+ SiteEntry * site = GetEntry(aSiteId);
+
+ if (site != NULL) {
+ fLocker->Lock();
+
+ BaseEntry * parent = site->getEntry(aParentId);
+ parent->addEntry(aEntry);
+
+ fLocker->Unlock();
+ }
+
+}
+
BBitmap * SiteHandler :: GetFavIconFor(int32 id) {
fLocker->Lock();
Modified: trunk/themis/framework/SiteHandler.h
===================================================================
--- trunk/themis/framework/SiteHandler.h 2011-01-15 21:28:55 UTC (rev 604)
+++ trunk/themis/framework/SiteHandler.h 2011-01-15 23:06:22 UTC (rev 605)
@@ -19,6 +19,7 @@
class BBitmap;
class BMessage;
class SiteEntry;
+class BaseEntry;
class CachePlug;
class SiteHandler : public MessageSystem {
@@ -35,6 +36,7 @@
SiteEntry * GetEntry(int32 id);
void AddEntry(SiteEntry * aEntry);
+ void AddEntry(BaseEntry * aEntry, int32 aSiteId, int32 aParentId);
void BroadcastFinished();
uint32 BroadcastTarget();
status_t BroadcastReply(BMessage * msg);
Modified: trunk/themis/makefile
===================================================================
--- trunk/themis/makefile 2011-01-15 21:28:55 UTC (rev 604)
+++ trunk/themis/makefile 2011-01-15 23:06:22 UTC (rev 605)
@@ -119,7 +119,8 @@
common/TTextView.cpp \
common/prefsman.cpp \
common/BasePrefsView.cpp \
- common/BaseEntry.cpp
+ common/BaseEntry.cpp \
+ common/DOMEntry.cpp
#add similar lines for new plugins, libraries, etc.
HTTPADDONSOURCES= \
http/optionshandler.cpp \
@@ -540,11 +541,11 @@
$(COMMON_DEPENDS_DIR)%.d: common/%.cpp
@echo "Common: Updating dependency file $(notdir $@)"
- @set -e;VAR1=$(shell echo "$(COMMON_DEPENDS_DIR)$(notdir $@)"|sed 's/\//\\\//g');VAR2=$(shell echo "$(COMMON_OBJECT_DIR)"|sed 's/\//\\\//g'); $(CC) -Icommon -I./ -M $(CPPFLAGS) $< | sed 's/\($*\)\.o[ :]*/objects\/common\/\1.o depends\/common\/\1.d : /g' > $@;[ -s $@ ] || rm -f $@
+ @set -e;VAR1=$(shell echo "$(COMMON_DEPENDS_DIR)$(notdir $@)"|sed 's/\//\\\//g');VAR2=$(shell echo "$(COMMON_OBJECT_DIR)"|sed 's/\//\\\//g'); $(CC) -Icommon -I./ -Iframework/DOM -M $(CPPFLAGS) $< | sed 's/\($*\)\.o[ :]*/objects\/common\/\1.o depends\/common\/\1.d : /g' > $@;[ -s $@ ] || rm -f $@
$(COMMON_OBJECT_DIR)%.o: common/%.cpp $(COMMON_DEPENDS_DIR)%.d
@echo "Common: Updating object file $(notdir $@)"
- @$(CC) $(CFLAGS) $(COMPILE_FLAGS) -Icommon -I./ -c $< -o $@
+ @$(CC) $(CFLAGS) $(COMPILE_FLAGS) -Icommon -I./ -Iframework/DOM -c $< -o $@
#renderer
Modified: trunk/themis/modules/DOMView/DOMViewer.cpp
===================================================================
--- trunk/themis/modules/DOMView/DOMViewer.cpp 2011-01-15 21:28:55 UTC (rev 604)
+++ trunk/themis/modules/DOMView/DOMViewer.cpp 2011-01-15 23:06:22 UTC (rev 605)
@@ -44,158 +44,164 @@
#include <Autolock.h>
// Themis headers
+#include "framework/app.h"
+#include "framework/SiteHandler.h"
+#include "framework/SiteEntry.h"
+#include "DOMEntry.hpp"
#include "commondefs.h"
DOMViewer * viewer;
BMessage ** appSettings_p;
BMessage * appSettings;
-status_t Initialize( void * aInfo ) {
-
+status_t Initialize(void * aInfo) {
+
viewer = NULL;
- if ( aInfo != NULL ) {
+ if (aInfo != NULL) {
BMessage * message = (BMessage *) aInfo;
- if ( message->HasPointer( "settings_message_ptr" ) ) {
- message->FindPointer( "settings_message_ptr", (void **) & appSettings_p );
+ if (message->HasPointer("settings_message_ptr")) {
+ message->FindPointer("settings_message_ptr", (void **) & appSettings_p);
appSettings = *appSettings_p;
}
- viewer = new DOMViewer( message );
+ viewer = new DOMViewer(message);
}
- else {
+ else {
viewer = new DOMViewer();
}
-
+
return B_OK;
-
+
}
-status_t Shutdown( bool aNow ) {
-
+status_t Shutdown(bool aNow) {
+
delete viewer;
-
+
return B_OK;
-
+
}
-PlugClass * GetObject() {
-
+PlugClass * GetObject() {
+
return viewer;
-
+
}
-DOMViewer :: DOMViewer( BMessage * aInfo )
- : BHandler( "DOMViewer" ), PlugClass( aInfo ) {
-
+DOMViewer :: DOMViewer(BMessage * aInfo)
+ : BHandler("DOMViewer"), PlugClass(aInfo) {
+
mView = NULL;
-
+
}
-DOMViewer :: ~DOMViewer() {
+DOMViewer :: ~DOMViewer() {
- if ( mView ) {
- BMessenger messenger( mView );
- messenger.SendMessage( B_QUIT_REQUESTED );
+ if (mView) {
+ BMessenger messenger(mView);
+ messenger.SendMessage(B_QUIT_REQUESTED);
}
-
+
}
-void DOMViewer :: MessageReceived( BMessage * aMessage ) {
-
+void DOMViewer :: MessageReceived( BMessage * aMessage) {
+
}
-bool DOMViewer :: IsHandler() {
-
+bool DOMViewer :: IsHandler() {
+
return true;
-
+
}
-BHandler * DOMViewer :: Handler() {
-
+BHandler * DOMViewer :: Handler() {
+
return this;
-
+
}
-bool DOMViewer :: IsPersistent() {
-
+bool DOMViewer :: IsPersistent() {
+
return true;
-
+
}
-uint32 DOMViewer :: PlugID() {
-
+uint32 DOMViewer :: PlugID() {
+
return 'tree';
-
+
}
-char * DOMViewer :: PlugName() {
-
+char * DOMViewer :: PlugName() {
+
return "DOM Viewer";
-
+
}
-float DOMViewer :: PlugVersion() {
-
- return 0.1;
-
+float DOMViewer :: PlugVersion() {
+
+ return 0.2;
+
}
-void DOMViewer :: Heartbeat() {
-
+void DOMViewer :: Heartbeat() {
+
}
-status_t DOMViewer :: ReceiveBroadcast( BMessage * aMessage ) {
-
+status_t DOMViewer :: ReceiveBroadcast(BMessage * aMessage) {
+
int32 command = 0;
- aMessage->FindInt32( "command", &command );
-
- switch ( command ) {
- case COMMAND_INFO: {
+ aMessage->FindInt32("command", &command);
+
+ switch (command) {
+ case COMMAND_INFO: {
// Check if it is dom data
- BString type;
- aMessage->FindString( "type", &type );
- if ( type == "dom" ) {
- // Get the pointer out
- void * document = NULL;
- aMessage->FindPointer( "dom_tree_pointer", &document );
- if ( document ) {
- TDocumentPtr * temp = (TDocumentPtr *) document;
- TDocumentPtr copy = *temp;
- if ( ! mView ) {
- mView = new DOMView( copy );
- }
- else {
- BAutolock viewLock( mView );
- if ( viewLock.IsLocked() ) {
- mView->setDocument( copy );
+ BString typeOfDocument;
+ aMessage->FindString("type", &typeOfDocument);
+ if (typeOfDocument == "dom") {
+ int32 siteId = aMessage->FindInt32("site_id");
+ SiteEntry * site = ((App *)be_app)->GetSiteHandler()->GetEntry(siteId);
+ if (site != NULL) {
+ int32 domId = aMessage->FindInt32("dom_id");
+ DOMEntry * entry = (DOMEntry *) site->getEntry(domId);
+ if (entry != NULL) {
+ TDocumentPtr document = entry->getDocument();
+ if (!mView) {
+ mView = new DOMView(document);
}
+ else {
+ BAutolock viewLock(mView);
+ if (viewLock.IsLocked()) {
+ mView->setDocument(document);
+ }
+ }
}
}
}
break;
}
- default: {
+ default: {
return PLUG_DOESNT_HANDLE;
}
}
-
+
return PLUG_HANDLE_GOOD;
-
+
}
-status_t DOMViewer::BroadcastReply( BMessage * aMessage ) {
+status_t DOMViewer :: BroadcastReply(BMessage * aMessage) {
return B_OK;
}
-uint32 DOMViewer::BroadcastTarget() {
+uint32 DOMViewer :: BroadcastTarget() {
return MS_TARGET_DOM_VIEWER;
}
-int32 DOMViewer :: Type() {
-
+int32 DOMViewer :: Type() {
+
return TARGET_DOM;
-
+
}
Modified: trunk/themis/modules/HTMLParser/HTMLParser.cpp
===================================================================
--- trunk/themis/modules/HTMLParser/HTMLParser.cpp 2011-01-15 21:28:55 UTC (rev 604)
+++ trunk/themis/modules/HTMLParser/HTMLParser.cpp 2011-01-15 23:06:22 UTC (rev 605)
@@ -18,9 +18,7 @@
// HTMLParser headers
#include "HTMLParser.h"
-#include "commondefs.h"
-#include "plugman.h"
-#include "PrefsDefs.h"
+#include "DOMEntry.hpp"
// DOM headers
#include "TDocument.h"
@@ -31,6 +29,13 @@
#include "SGMLScanner.hpp"
#include "HTMLParserPrefsView.hpp"
+// Themis headers
+#include "framework/app.h"
+#include "framework/SiteHandler.h"
+#include "commondefs.h"
+#include "plugman.h"
+#include "PrefsDefs.h"
+
HTMLParser * parser;
BMessage ** appSettings_p;
BMessage * appSettings;
@@ -199,21 +204,27 @@
}
-void HTMLParser :: NotifyParseFinished(void * aDocument,
+void HTMLParser :: NotifyParseFinished(TDocumentPtr aDocument,
string aType,
BMessage * aOriginalMessage) {
- int32 siteID = 0;
- int32 urlID = 0;
- aOriginalMessage->FindInt32("site_id", &siteID);
- aOriginalMessage->FindInt32("url_id", &urlID);
+ int32 siteId = 0;
+ int32 urlId = 0;
+ aOriginalMessage->FindInt32("site_id", &siteId);
+ aOriginalMessage->FindInt32("url_id", &urlId);
+ /* Get an unique ID from the app for the DOM entry */
+ int32 domId = ((App *)be_app)->GetNewID();
+ DOMEntry * entry = new DOMEntry(domId, aDocument);
+ ((App *)be_app)->GetSiteHandler()->AddEntry(entry, siteId, urlId);
+
BMessage * done = new BMessage(SH_PARSE_DOC_FINISHED);
done->AddInt32("command", COMMAND_INFO);
done->AddString("type", aType.c_str());
- done->AddPointer("dom_tree_pointer", aDocument);
- done->AddInt32("site_id", siteID);
- done->AddInt32("url_id", urlID);
+ done->AddInt32("site_id", siteId);
+ done->AddInt32("url_id", urlId);
+ done->AddInt32("dom_id", domId);
+
// Message created. Broadcast it.
Broadcast(MS_TARGET_ALL, done);
@@ -269,7 +280,7 @@
document->setDocumentURI(aURL);
mDocuments.push_back(document);
- NotifyParseFinished(mDocuments.end() - 1, "dom", aOriginalMessage);
+ NotifyParseFinished(document, "dom", aOriginalMessage);
}
}
}
Modified: trunk/themis/modules/HTMLParser/HTMLParser.h
===================================================================
--- trunk/themis/modules/HTMLParser/HTMLParser.h 2011-01-15 21:28:55 UTC (rev 604)
+++ trunk/themis/modules/HTMLParser/HTMLParser.h 2011-01-15 23:06:22 UTC (rev 605)
@@ -64,7 +64,7 @@
// Function to check if the document is a supported one.
bool IsDocumentSupported(BMessage * aMessage);
// Function to notify plugins that parsing is finished.
- void NotifyParseFinished(void * aDocument,
+ void NotifyParseFinished(TDocumentPtr aDocument,
string aType,
BMessage * aOriginalMessage);
// Function to parse a document.
Modified: trunk/themis/modules/Renderer/TRenderer.cpp
===================================================================
--- trunk/themis/modules/Renderer/TRenderer.cpp 2011-01-15 21:28:55 UTC (rev 604)
+++ trunk/themis/modules/Renderer/TRenderer.cpp 2011-01-15 23:06:22 UTC (rev 605)
@@ -27,6 +27,16 @@
Project Start Date: October 18, 2000
*/
+// BeOS headers
+#include <String.h>
+
+// Themis headers
+#include "framework/app.h"
+#include "framework/SiteHandler.h"
+#include "framework/SiteEntry.h"
+#include "DOMEntry.hpp"
+
+// Renderer headers
#include "Globals.h"
#include "TRenderer.h"
@@ -120,60 +130,33 @@
cache = NULL;
}break;
case SH_PARSE_DOC_FINISHED: {
- void *buffer = NULL;
- TDocumentPtr document;
- message->FindPointer("dom_tree_pointer",&buffer);
- if (!buffer)
- break;
- TDocumentPtr *typer = (TDocumentPtr *)buffer;
- document = *typer;
- DOMTrees.push_back(document);
- //Start Processing in a new thread
- // allocate the struct on the heap now ;) (thx emwe)
- preprocess_thread_param* param = new preprocess_thread_param;
- param->document = document;
- param->renderer = this;
- param->siteID = message->FindInt32("site_id");
- param->urlID = message->FindInt32("url_id");
- //feeding the random generator
- srand(time(NULL));
- thread_id id = spawn_thread(PreProcess,THREAD_NAME[rand()%THREAD_NAMES],30,(void *)param);
- resume_thread(id);
- } break;
-/* case ReturnedData:{ //OLD WAY TO DO
- BString type = message->FindString("type");
- if (type == "dom"){
- void *buffer = NULL;
- TDocumentPtr document;
- message->FindPointer("data_pointer", &buffer);
- if (!buffer)
- break;
- TDocumentPtr *typer = (TDocumentPtr *)buffer;
- document = *typer;
-
- //Start Processing
- preprocess_thread_param param = {document,new TRenderView(UIBox(800,450),document),this};
- thread_id id = spawn_thread(PreProcess,"\"boing boing\" says the renderer",30,(void *)¶m);
- resume_thread(id);
+ BString typeOfDocument;
+ message->FindString("type", &typeOfDocument);
+ if (typeOfDocument == "dom") {
+ int32 siteId = message->FindInt32("site_id");
+ SiteEntry * site = ((App *)be_app)->GetSiteHandler()->GetEntry(siteId);
+ if (site != NULL) {
+ int32 domId = message->FindInt32("dom_id");
+ DOMEntry * entry = (DOMEntry *) site->getEntry(domId);
+ if (entry != NULL) {
+ TDocumentPtr document = entry->getDocument();
+ DOMTrees.push_back(document);
+ //Start Processing in a new thread
+ // allocate the struct on the heap now ;) (thx emwe)
+ preprocess_thread_param* param = new preprocess_thread_param;
+ param->document = document;
+ param->renderer = this;
+ param->siteID = siteId;
+ param->urlID = message->FindInt32("url_id");
+ //feeding the random generator
+ srand(time(NULL));
+ thread_id id = spawn_thread(PreProcess,THREAD_NAME[rand()%THREAD_NAMES],30,(void *)param);
+ resume_thread(id);
+ }
+ }
}
- }break; */
-/* case R_WELCOME:{
- printf("RENDERER: R_WELCOME received\n");
- BRect rect;
- int32 doc_number, view_number;
- BMessenger userInterface;
-
- //Retrieve data sent by UI
- message->FindRect("rect",&rect);
- message->FindInt32("document_number",&doc_number);
- message->FindInt32("view_number",&view_number);
- message->FindMessenger("messenger",&userInterface);
-
- //Start Processing
- PreProcess(doc_number,view_number,rect,userInterface);
- }break; */
+ } break;
default:{
-// printf("Renderer doesn't handle this broadcast\n");
return PLUG_DOESNT_HANDLE;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|