|
From: CVS C. to T. <the...@li...> - 2011-01-02 20:21:32
|
Revision: 596
http://themis.svn.sourceforge.net/themis/?rev=596&view=rev
Author: mark_hellegers
Date: 2011-01-02 20:21:26 +0000 (Sun, 02 Jan 2011)
Log Message:
-----------
Moved adding entry to its own method.
Modified Paths:
--------------
trunk/themis/framework/SiteEntry.cpp
trunk/themis/framework/SiteEntry.h
trunk/themis/framework/SiteHandler.cpp
trunk/themis/framework/SiteHandler.h
Modified: trunk/themis/framework/SiteEntry.cpp
===================================================================
--- trunk/themis/framework/SiteEntry.cpp 2011-01-02 19:22:26 UTC (rev 595)
+++ trunk/themis/framework/SiteEntry.cpp 2011-01-02 20:21:26 UTC (rev 596)
@@ -76,17 +76,41 @@
UrlEntry* entry = NULL;
// browse through the entry list to find the UrlEntry with the matching id
- vector<UrlEntry *>::iterator it;
- for (it = fEntryList.begin(); it != fEntryList.end(); it++) {
+ vector<UrlEntry *>::iterator it = fEntryList.begin();
+ while (it != fEntryList.end() && entry == NULL) {
if (((UrlEntry *)*it)->GetID() == id) {
entry = *it;
}
+ else {
+ it++;
+ }
}
return entry;
}
+UrlEntry * SiteEntry :: GetEntry(const char * aUrl) {
+
+ UrlEntry * entry = NULL;
+ BString urlString = aUrl;
+
+ // browse through the entry list to find the UrlEntry with the matching url
+ vector<UrlEntry *>::iterator it = fEntryList.begin();
+ while (it != fEntryList.end() && entry == NULL) {
+ BString listUrlString = ((UrlEntry *)*it)->GetUrl();
+ if (urlString == listUrlString) {
+ entry = *it;
+ }
+ else {
+ it++;
+ }
+ }
+
+ return entry;
+
+}
+
int32 SiteEntry :: GetID() {
return fID;
Modified: trunk/themis/framework/SiteEntry.h
===================================================================
--- trunk/themis/framework/SiteEntry.h 2011-01-02 19:22:26 UTC (rev 595)
+++ trunk/themis/framework/SiteEntry.h 2011-01-02 20:21:26 UTC (rev 596)
@@ -39,6 +39,7 @@
bool GetCookiesDisabled();
BBitmap * GetFavIcon();
UrlEntry * GetEntry(int32 id);
+ UrlEntry * GetEntry(const char * aUrl);
int32 GetID();
int8 GetLoadingProgress();
bool GetSecureConnection();
Modified: trunk/themis/framework/SiteHandler.cpp
===================================================================
--- trunk/themis/framework/SiteHandler.cpp 2011-01-02 19:22:26 UTC (rev 595)
+++ trunk/themis/framework/SiteHandler.cpp 2011-01-02 20:21:26 UTC (rev 596)
@@ -93,6 +93,17 @@
}
+SiteEntry * SiteHandler :: AddEntry(int32 aSiteID, const char * aUrl) {
+
+ SiteEntry * entry = new SiteEntry(aSiteID, aUrl);
+ fEntryList.push_back(entry);
+
+ /* Get an unique ID from the app */
+ int32 urlID = ((App *)be_app)->GetNewID();
+ entry->AddEntry(urlID, aUrl);
+
+}
+
BBitmap * SiteHandler :: GetFavIconFor(int32 id) {
fLocker->Lock();
@@ -196,69 +207,25 @@
case SH_LOAD_NEW_PAGE:
case SH_RELOAD_PAGE: {
/* create a SiteEntry, and add it to fEntryList */
- int32 site_id;
+ int32 siteID;
BString url;
- msg->FindInt32("site_id", &site_id);
+ msg->FindInt32("site_id", &siteID);
msg->FindString("url", &url);
- printf( "SiteHandler: adding following item: ID[%ld] URL[%s]\n", site_id, url.String() );
+ printf( "SiteHandler: adding following item: ID[%ld] URL[%s]\n", siteID, url.String() );
- SiteEntry * siteentry = new SiteEntry(site_id, url.String());
- fEntryList.push_back(siteentry);
+ SiteEntry * entry = AddEntry(siteID, url.String());
+ UrlEntry * urlEntry = entry->GetEntry(url.String());
/*
- * GENERAL PROCESSING IDEA:
- *
- * The main idea now would be to tell the network, to retrieve the site. When loading is
- * finished, the parser would be given the url for parsing. The parser then tells us if
- * the document is a single-framed or multi-framed document. According to this info,
- * we create the appropriate count of UrlEntry items in the parent SiteEntry.
- * Each UrlEntry for the site is then to be loaded from the network system, and loading
- * states are reported back accordingly.
- * An idea would be, that as soon, an url of the site is retrieved, the parser gets it for
- * parsing, and then returns the pointer to the dom tree, which is stored in the appropriate
- * UrlEntry for later processing by the Renderer.
- * If all URLs for the site are retrieved, we hand over all the dom tree pointers and stuff
- * to the Renderer with the SH_RENDER_START broadcast.
- * Though it is not said, that we may not even tell the Renderer to render parts ( URLs ) of
- * the site in between.
- *
- * Note: The first retrieve will contain an site_id > 0 and an url_id = 0. This makes it clear
- * for the SiteHandler that the response from the network is for the intial URL.
- */
-
- /*
- * WORKAROUND IDEA:
- *
- * As we currently can't ask the parser to tell us about the single- and/or multi-framed-ness
- * of a site, we just create an UrlEntry and store it in the SiteEntry.
- * Then we tell the network to retrieve exactly that site_id/url_id combination.
- * This means site_id > 0 and url_id > 0.
- */
-
- /* Go the workaround way */
-
- /* Get an unique ID from the app */
- int32 url_id = ((App *)be_app)->GetNewID();
- siteentry->AddEntry(url_id, url.String());
-
- /*
- * TODO
- *
- * I was planning to move all urlparsing and handler decision making from the windows
- * URL_OPEN/BUTTON_RELOAD switch in here.
- */
-
-
- /*
* Inform the protocol(s) to retrieve the site.
* Remember, this is the workaround way, with an url_id > 0.
*/
BMessage* retrieve = new BMessage(SH_RETRIEVE_START);
retrieve->AddInt32("command", COMMAND_RETRIEVE);
- retrieve->AddInt32("site_id", site_id);
- retrieve->AddInt32("url_id", url_id);
+ retrieve->AddInt32("site_id", siteID);
+ retrieve->AddInt32("url_id", urlEntry->GetID());
retrieve->AddString("url", url.String());
if (msg->what == SH_RELOAD_PAGE)
retrieve->AddBool("reload", true);
Modified: trunk/themis/framework/SiteHandler.h
===================================================================
--- trunk/themis/framework/SiteHandler.h 2011-01-02 19:22:26 UTC (rev 595)
+++ trunk/themis/framework/SiteHandler.h 2011-01-02 20:21:26 UTC (rev 596)
@@ -34,6 +34,7 @@
~SiteHandler();
SiteEntry * GetEntry(int32 id);
+ SiteEntry * AddEntry(int32 aSiteID, const char * aUrl);
void BroadcastFinished();
uint32 BroadcastTarget();
status_t BroadcastReply(BMessage * msg);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|