[haiku-commits] haiku: hrev46369 - src/apps/webpositive src/kits/network/libnetapi build/jam/repositories/HaikuPorts build/jam

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 15 Nov 2013 18:53:32 +0100 (CET)

hrev46369 adds 2 changesets to branch 'master'
old head: d34a680c043c72bae01662cc730ca81cb4cd2615
new head: cb7df3b1da881c3fadef628b0a0d5a122f131bd0
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=cb7df3b+%5Ed34a680

----------------------------------------------------------------------------

564e256: Various fixes to Services Kit
  
   * Remove useless dummy protocol loop in UrlRequest
   * Stop HTTP requests before deleting the socket and other things the
  loop may still be using
   * Deletion of items from the authentication map wasn't working
   * Remove some debug traces

cb7df3b: Update webkit and cmake packages
  
   * Some changes required in WebPositive to store the cookies on disk

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

13 files changed, 53 insertions(+), 55 deletions(-)
build/jam/BuildFeatures                          |  5 +---
build/jam/repositories/HaikuPorts/x86_gcc2       |  7 ++---
headers/os/net/UrlRequest.h                      |  2 +-
src/apps/webpositive/BrowserApp.cpp              | 31 ++++++++++----------
src/apps/webpositive/BrowserApp.h                |  3 +-
src/apps/webpositive/BrowserWindow.cpp           | 12 ++++++--
src/apps/webpositive/BrowserWindow.h             |  4 +++
src/apps/webpositive/Jamfile                     |  2 +-
src/kits/network/libnetapi/HttpRequest.cpp       |  6 ++--
src/kits/network/libnetapi/NetworkCookieJar.cpp  |  4 +--
src/kits/network/libnetapi/UrlContext.cpp        | 18 +++++++-----
src/kits/network/libnetapi/UrlProtocolRoster.cpp |  3 --
src/kits/network/libnetapi/UrlRequest.cpp        | 11 -------

############################################################################

Commit:      564e2566492c1b9cf9bf7fdaede7ea7683dab5dd
URL:         http://cgit.haiku-os.org/haiku/commit/?id=564e256
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Fri Nov 15 15:32:18 2013 UTC

Various fixes to Services Kit

 * Remove useless dummy protocol loop in UrlRequest
 * Stop HTTP requests before deleting the socket and other things the
loop may still be using
 * Deletion of items from the authentication map wasn't working
 * Remove some debug traces

----------------------------------------------------------------------------

diff --git a/headers/os/net/UrlRequest.h b/headers/os/net/UrlRequest.h
index 870b124..b61b963 100644
--- a/headers/os/net/UrlRequest.h
+++ b/headers/os/net/UrlRequest.h
@@ -47,7 +47,7 @@ public:
 
 protected:
        static  int32                                   _ThreadEntry(void* arg);
-       virtual status_t                                _ProtocolLoop();
+       virtual status_t                                _ProtocolLoop() = 0;
        virtual void                                    
_EmitDebug(BUrlProtocolDebugMessage type,
                                                                                
const char* format, ...);
 protected:
diff --git a/src/kits/network/libnetapi/HttpRequest.cpp 
b/src/kits/network/libnetapi/HttpRequest.cpp
index 3620d31..f382c04 100644
--- a/src/kits/network/libnetapi/HttpRequest.cpp
+++ b/src/kits/network/libnetapi/HttpRequest.cpp
@@ -57,6 +57,8 @@ BHttpRequest::BHttpRequest(const BUrl& url, bool ssl, const 
char* protocolName,
 
 BHttpRequest::~BHttpRequest()
 {
+       Stop();
+
        delete fSocket;
 
        delete fOptInputData;
@@ -550,7 +552,6 @@ BHttpRequest::_MakeRequest()
        ssize_t bytesTotal = 0;
        char* inputTempBuffer = NULL;
        ssize_t chunkSize = -1;
-       fQuit = false;
 
        while (!fQuit && !(receiveEnd && parseEnd)) {
                if (!receiveEnd) {
@@ -560,8 +561,7 @@ BHttpRequest::_MakeRequest()
 
                        if (bytesRead < 0) {
                                readError = true;
-                               fQuit = true;
-                               continue;
+                               break;
                        } else if (bytesRead == 0)
                                receiveEnd = true;
 
diff --git a/src/kits/network/libnetapi/UrlContext.cpp 
b/src/kits/network/libnetapi/UrlContext.cpp
index 429eb59..8e34e0a 100644
--- a/src/kits/network/libnetapi/UrlContext.cpp
+++ b/src/kits/network/libnetapi/UrlContext.cpp
@@ -21,8 +21,7 @@ BUrlContext::BUrlContext()
        fAuthenticationMap(NULL)
 {
        fAuthenticationMap = new(std::nothrow) BHttpAuthenticationMap();
-       if(!fAuthenticationMap)
-               return;
+
        // This is the default authentication, used when nothing else is found.
        // The empty string used as a key will match all the domain strings, 
once
        // we have removed all components.
@@ -35,7 +34,7 @@ BUrlContext::~BUrlContext()
        BHttpAuthenticationMap::Iterator iterator =
                fAuthenticationMap->GetIterator();
        while(iterator.HasNext())
-               delete iterator.Remove().value;
+               delete *iterator.NextValue();
 
        delete fAuthenticationMap;
 }
@@ -59,10 +58,15 @@ BUrlContext::AddAuthentication(const BUrl& url,
        domain += url.Path();
        BPrivate::HashString hostHash(domain.String(), domain.Length());
 
-       delete fAuthenticationMap->Get(hostHash);
-               // Make sure we don't leak memory by overriding a previous
-               // authentication for the same domain.
-       fAuthenticationMap->Put(hostHash, authentication);
+       BHttpAuthentication* previous = fAuthenticationMap->Get(hostHash);
+
+       // Make sure we don't leak memory by overriding a previous
+       // authentication for the same domain.
+       if(authentication != previous) {
+               fAuthenticationMap->Put(hostHash, authentication);
+                       // replaces the old one
+               delete previous;
+       }
 }
 
 
diff --git a/src/kits/network/libnetapi/UrlProtocolRoster.cpp 
b/src/kits/network/libnetapi/UrlProtocolRoster.cpp
index 830bd2b..c023c9b 100644
--- a/src/kits/network/libnetapi/UrlProtocolRoster.cpp
+++ b/src/kits/network/libnetapi/UrlProtocolRoster.cpp
@@ -29,11 +29,8 @@ BUrlProtocolRoster::MakeRequest(const BUrl& url,
                return new(std::nothrow) BHttpRequest(url, true, "HTTPS", 
listener,
                        context);
        } else if (url.Protocol() == "file") {
-               puts("*** FILE URL");
                return new(std::nothrow) BFileRequest(url, listener, context);
        }
 
-       puts("*** UNKNOWN protocol");
-
        return NULL;
 }
diff --git a/src/kits/network/libnetapi/UrlRequest.cpp 
b/src/kits/network/libnetapi/UrlRequest.cpp
index add7361..1d6dbae 100644
--- a/src/kits/network/libnetapi/UrlRequest.cpp
+++ b/src/kits/network/libnetapi/UrlRequest.cpp
@@ -231,17 +231,6 @@ BUrlRequest::_ThreadEntry(void* arg)
 }
 
 
-status_t
-BUrlRequest::_ProtocolLoop()
-{
-       // Dummy _ProtocolLoop
-       while (!fQuit)
-               snooze(1000);
-
-       return B_PROT_SUCCESS;
-}
-
-
 void
 BUrlRequest::_EmitDebug(BUrlProtocolDebugMessage type,
        const char* format, ...)

############################################################################

Revision:    hrev46369
Commit:      cb7df3b1da881c3fadef628b0a0d5a122f131bd0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=cb7df3b
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Fri Nov 15 17:39:07 2013 UTC

Update webkit and cmake packages

 * Some changes required in WebPositive to store the cookies on disk

----------------------------------------------------------------------------

diff --git a/build/jam/BuildFeatures b/build/jam/BuildFeatures
index 6d66836..10b8cf0 100644
--- a/build/jam/BuildFeatures
+++ b/build/jam/BuildFeatures
@@ -398,10 +398,7 @@ if [ IsPackageAvailable haikuwebkit_devel ] {
                file: devel haikuwebkit_devel
                        depends: base
                        libraries:
-                               $(developLibDir)/libwtf.so
-                               $(developLibDir)/libjavascriptcore.so
-                               $(developLibDir)/libwebcore.so
-                               $(developLibDir)/libwebkit.so
+                               $(developLibDir)/libWebKit.so
                        headers: $(developHeadersDir)
                ;
 
diff --git a/build/jam/repositories/HaikuPorts/x86_gcc2 
b/build/jam/repositories/HaikuPorts/x86_gcc2
index 34feb96..e0f095a 100644
--- a/build/jam/repositories/HaikuPorts/x86_gcc2
+++ b/build/jam/repositories/HaikuPorts/x86_gcc2
@@ -25,7 +25,7 @@ RemotePackageRepository HaikuPorts
        bzip2-1.0.6-3
        caya-2013.07.31-3
        cdrtools-3.01~a07-3
-       cmake-2.8.11.2-2
+       cmake-2.8.11.2-4
        ctags-5.8-3
        curl-7.26.0-5
        curl_devel-7.26.0-5
@@ -148,8 +148,8 @@ RemotePackageRepository HaikuPorts
        gettext_x86_libintl-0.18.1.1-5
        glu_x86-9.0.0-2
        glu_x86_devel-9.0.0-2
-       haikuwebkit_x86-1.1.3_2013_08_09-2
-       haikuwebkit_x86_devel-1.1.3_2013_08_09-2
+       haikuwebkit_x86-1.2.0-2
+       haikuwebkit_x86_devel-1.2.0-2
        icu_x86-4.8.1.1-4
        icu_x86_devel-4.8.1.1-4
        jpeg_x86-9-3
@@ -218,7 +218,6 @@ RemotePackageRepository HaikuPorts
        gperf
        grep
        groff
-       haikuwebkit_x86
        htmldoc
        icu
        jam
diff --git a/src/apps/webpositive/BrowserApp.cpp 
b/src/apps/webpositive/BrowserApp.cpp
index 5b17b6c..0a9517b 100644
--- a/src/apps/webpositive/BrowserApp.cpp
+++ b/src/apps/webpositive/BrowserApp.cpp
@@ -38,6 +38,7 @@
 #include <Locale.h>
 #include <Path.h>
 #include <Screen.h>
+#include <UrlContext.h>
 #include <debugger.h>
 
 #include <stdio.h>
@@ -61,7 +62,7 @@ const char* kApplicationSignature = 
"application/x-vnd.Haiku-WebPositive";
 const char* kApplicationName = B_TRANSLATE_SYSTEM_NAME("WebPositive");
 static const uint32 PRELOAD_BROWSING_HISTORY = 'plbh';
 
-#define ENABLE_NATIVE_COOKIES 0
+#define ENABLE_NATIVE_COOKIES 1
 
 
 BrowserApp::BrowserApp()
@@ -73,10 +74,19 @@ BrowserApp::BrowserApp()
        fInitialized(false),
        fSettings(NULL),
        fCookies(NULL),
-       fCookieJar(NULL),
+       fContext(NULL),
        fDownloadWindow(NULL),
        fSettingsWindow(NULL)
 {
+#if ENABLE_NATIVE_COOKIES
+       BString cookieStorePath = kApplicationName;
+       cookieStorePath << "/Cookies";
+       fCookies = new SettingsMessage(B_USER_SETTINGS_DIRECTORY,
+               cookieStorePath.String());
+       BMessage cookieArchive = fCookies->GetValue("cookies", cookieArchive);
+       fContext = new BUrlContext();
+       fContext->SetCookieJar(BNetworkCookieJar(&cookieArchive));
+#endif
 }
 
 
@@ -85,7 +95,7 @@ BrowserApp::~BrowserApp()
        delete fLaunchRefsMessage;
        delete fSettings;
        delete fCookies;
-       delete fCookieJar;
+       delete fContext;
 }
 
 
@@ -166,16 +176,6 @@ BrowserApp::ReadyToRun()
        mainSettingsPath << "/Application";
        fSettings = new SettingsMessage(B_USER_SETTINGS_DIRECTORY,
                mainSettingsPath.String());
-#if ENABLE_NATIVE_COOKIES
-       mainSettingsPath = kApplicationName;
-       mainSettingsPath << "/Cookies";
-       fCookies = new SettingsMessage(B_USER_SETTINGS_DIRECTORY,
-               mainSettingsPath.String());
-       BMessage cookieArchive;
-       cookieArchive = fCookies->GetValue("cookies", cookieArchive);
-       fCookieJar = new BNetworkCookieJar(cookieArchive);
-       BWebPage::SetCookieJar(fCookieJar);
-#endif
 
        fLastWindowFrame = fSettings->GetValue("window frame", 
fLastWindowFrame);
        BRect defaultDownloadWindowFrame(-10, -10, 365, 265);
@@ -344,7 +344,8 @@ BrowserApp::QuitRequested()
        }
 
        BMessage cookieArchive;
-       if (fCookieJar != NULL && fCookieJar->Archive(&cookieArchive) == B_OK)
+       BNetworkCookieJar& cookieJar = fContext->GetCookieJar();
+       if (cookieJar.Archive(&cookieArchive) == B_OK)
                fCookies->SetValue("cookies", cookieArchive);
 
        return true;
@@ -429,7 +430,7 @@ BrowserApp::_CreateNewWindow(const BString& url, bool 
fullscreen)
                fLastWindowFrame.OffsetTo(50, 50);
 
        BrowserWindow* window = new BrowserWindow(fLastWindowFrame, fSettings,
-               url);
+               url, fContext);
        if (fullscreen)
                window->ToggleFullscreen();
        window->Show();
diff --git a/src/apps/webpositive/BrowserApp.h 
b/src/apps/webpositive/BrowserApp.h
index 2836627..062e6f0 100644
--- a/src/apps/webpositive/BrowserApp.h
+++ b/src/apps/webpositive/BrowserApp.h
@@ -35,6 +35,7 @@
 
 
 class BNetworkCookieJar;
+class BUrlContext;
 class DownloadWindow;
 class BrowserWindow;
 class SettingsMessage;
@@ -74,7 +75,7 @@ private:
 
                        SettingsMessage*        fSettings;
                        SettingsMessage*        fCookies;
-                       BNetworkCookieJar*      fCookieJar;
+                       BUrlContext*            fContext;
 
                        DownloadWindow*         fDownloadWindow;
                        SettingsWindow*         fSettingsWindow;
diff --git a/src/apps/webpositive/BrowserWindow.cpp 
b/src/apps/webpositive/BrowserWindow.cpp
index 292994e..54a3354 100644
--- a/src/apps/webpositive/BrowserWindow.cpp
+++ b/src/apps/webpositive/BrowserWindow.cpp
@@ -322,7 +322,8 @@ private:
 
 
 BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
-               const BString& url, uint32 interfaceElements, BWebView* webView)
+               const BString& url, BUrlContext* context, uint32 
interfaceElements,
+               BWebView* webView)
        :
        BWebWindow(frame, kApplicationName,
                B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
@@ -331,6 +332,7 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* 
appSettings,
        fInterfaceVisible(false),
        fPulseRunner(NULL),
        fVisibleInterfaceElements(interfaceElements),
+       fContext(context),
        fAppSettings(appSettings),
        fZoomTextOnly(true),
        fShowTabsIfSinglePageOpen(true),
@@ -1200,13 +1202,16 @@ BrowserWindow::IsBlankTab() const
 
 
 void
-BrowserWindow::CreateNewTab(const BString& _url, bool select, BWebView* 
webView)
+BrowserWindow::CreateNewTab(const BString& _url, bool select,
+       BWebView* webView)
 {
        bool applyNewPagePolicy = webView == NULL;
        // Executed in app thread (new BWebPage needs to be created in app 
thread).
        if (webView == NULL)
                webView = new BWebView("web view");
 
+       webView->SetContext(fContext);
+
        bool isNewWindow = fTabManager->CountTabs() == 0;
 
        fTabManager->AddTab(webView, B_TRANSLATE("New tab"));
@@ -1298,7 +1303,8 @@ BrowserWindow::NewPageCreated(BWebView* view, BRect 
windowFrame,
 {
        if (windowFrame.IsValid()) {
                BrowserWindow* window = new BrowserWindow(windowFrame, 
fAppSettings,
-                       BString(), INTERFACE_ELEMENT_STATUS, view);
+                       BString(), fContext, INTERFACE_ELEMENT_STATUS,
+                       view);
                window->Show();
        } else
                CreateNewTab(BString(), activate, view);
diff --git a/src/apps/webpositive/BrowserWindow.h 
b/src/apps/webpositive/BrowserWindow.h
index 5b87aa3..e9840b4 100644
--- a/src/apps/webpositive/BrowserWindow.h
+++ b/src/apps/webpositive/BrowserWindow.h
@@ -46,6 +46,7 @@ class BPath;
 class BStatusBar;
 class BStringView;
 class BTextControl;
+class BUrlContext;
 class BWebView;
 class SettingsMessage;
 class TabManager;
@@ -90,6 +91,7 @@ public:
                                                                
BrowserWindow(BRect frame,
                                                                        
SettingsMessage* appSettings,
                                                                        const 
BString& url,
+                                                                       
BUrlContext* context,
                                                                        uint32 
interfaceElements
                                                                                
= INTERFACE_ELEMENT_ALL,
                                                                        
BWebView* webView = NULL);
@@ -249,6 +251,8 @@ private:
                        bigtime_t                       fLastMouseMovedTime;
                        BPoint                          fLastMousePos;
 
+                       BUrlContext*            fContext;
+
                        // cached settings
                        SettingsMessage*        fAppSettings;
                        bool                            fZoomTextOnly;
diff --git a/src/apps/webpositive/Jamfile b/src/apps/webpositive/Jamfile
index 849ca11..ea555ff 100644
--- a/src/apps/webpositive/Jamfile
+++ b/src/apps/webpositive/Jamfile
@@ -72,7 +72,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
                        [ BuildFeatureAttribute webkit : libraries ]
                        $(TARGET_LIBSTDC++) localestub
                        [ MultiArchDefaultGristFiles libshared.a ]
-                       be network tracker translation
+                       be network bnetapi tracker translation
                        :
                        WebPositive.rdef
                        ;
diff --git a/src/kits/network/libnetapi/NetworkCookieJar.cpp 
b/src/kits/network/libnetapi/NetworkCookieJar.cpp
index ee0c4de..566dff2 100644
--- a/src/kits/network/libnetapi/NetworkCookieJar.cpp
+++ b/src/kits/network/libnetapi/NetworkCookieJar.cpp
@@ -29,11 +29,11 @@ BNetworkCookieJar::BNetworkCookieJar()
 }
 
 
-BNetworkCookieJar::BNetworkCookieJar(const BNetworkCookieJar&)
+BNetworkCookieJar::BNetworkCookieJar(const BNetworkCookieJar& other)
        :
        fCookieHashMap(new PrivateHashMap())
 {
-       // TODO
+       *this = other;
 }
 
 


Other related posts: