svnno****@sourc*****
svnno****@sourc*****
Sat Jan 5 12:58:08 JST 2008
Revision: 3328 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3328 Author: kous Date: 2008-01-05 12:58:07 +0900 (Sat, 05 Jan 2008) Log Message: ----------- * module/embed/gecko/kz-mozutils.h, module/embed/gecko/kz-mozhistorysearch.cpp: used nsNetUtil.h. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp kazehakase/trunk/module/embed/gecko/kz-mozhistorysearch.cpp kazehakase/trunk/module/embed/gecko/kz-mozutils.h Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2008-01-05 02:41:53 UTC (rev 3327) +++ kazehakase/trunk/ChangeLog 2008-01-05 03:58:07 UTC (rev 3328) @@ -1,5 +1,10 @@ 2008-01-05 Kouhei Sutou <kou****@cozmi*****> + * module/embed/gecko/kz-mozutils.h: used nsNetUtil.h. + + * module/embed/gecko/kz-gecko-embed.cpp: improved nsIPassword.h + detection. + * module/embed/gecko/kz-gecko-embed.cpp: added missing #include. * module/embed/gecko/kz-gecko-embed.cpp: don't use LL_DIV and Modified: kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp 2008-01-05 02:41:53 UTC (rev 3327) +++ kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp 2008-01-05 03:58:07 UTC (rev 3328) @@ -3513,6 +3513,7 @@ result = passwordManager->GetEnumerator(getter_AddRefs(passwordEnumerator)); if (NS_FAILED(result)) return FALSE; +#ifdef HAVE_NSIPASSWORD_H PRBool enumResult; for (passwordEnumerator->HasMoreElements(&enumResult) ; enumResult == PR_TRUE ; @@ -3541,6 +3542,7 @@ } *passwords = g_list_reverse (*passwords); +#endif return TRUE; } Modified: kazehakase/trunk/module/embed/gecko/kz-mozhistorysearch.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozhistorysearch.cpp 2008-01-05 02:41:53 UTC (rev 3327) +++ kazehakase/trunk/module/embed/gecko/kz-mozhistorysearch.cpp 2008-01-05 03:58:07 UTC (rev 3328) @@ -165,13 +165,7 @@ rv = NS_NewFileURI(getter_AddRefs(cssURI), cssFile); if (NS_FAILED(rv)) return rv; - nsCOMPtr<nsIInputStream> iStream; - rv = NS_OpenURI(getter_AddRefs(iStream), cssURI); - if (NS_FAILED(rv)) return rv; - - rv = NS_NewInputStreamChannel(result, uri, - iStream, nsEmbedCString("text/css"), - nsnull); + rv = NS_NewChannel(result, uri, nsEmbedCString("text/css"), nsnull); return rv; } @@ -197,13 +191,7 @@ rv = NS_NewFileURI(getter_AddRefs(cssURI), cssFile); if (NS_FAILED(rv)) return rv; - nsCOMPtr<nsIInputStream> iStream; - rv = NS_OpenURI(getter_AddRefs(iStream), cssURI); - if (NS_FAILED(rv)) return rv; - - rv = NS_NewInputStreamChannel(result, uri, - iStream, nsEmbedCString("image/png"), - nsnull); + rv = NS_NewChannel(result, uri, nsEmbedCString("image/png"), nsnull); return rv; } @@ -252,13 +240,8 @@ stream->Write (html, strlen(html), &bytesWritten); g_free(html); } - nsCOMPtr<nsIInputStream> iStream; - rv = sStream->NewInputStream(0, getter_AddRefs(iStream)); - if (NS_FAILED(rv)) return rv; - rv = NS_NewInputStreamChannel(result, uri, - iStream, nsEmbedCString("text/html"), - nsnull); + rv = NS_NewChannel(result, uri, nsEmbedCString("text/html"), nsnull); if (NS_FAILED(rv)) return rv; return rv; Modified: kazehakase/trunk/module/embed/gecko/kz-mozutils.h =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozutils.h 2008-01-05 02:41:53 UTC (rev 3327) +++ kazehakase/trunk/module/embed/gecko/kz-mozutils.h 2008-01-05 03:58:07 UTC (rev 3328) @@ -36,6 +36,7 @@ #include <nsIRequestObserver.h> #include <nsILoadGroup.h> #include <nsNetCID.h> +#include <nsNetUtil.h> #include <nsCRT.h> #include <nsCOMPtr.h> #define MOZILLA_STRICT_API @@ -94,25 +95,20 @@ } inline nsresult -NS_NewInputStreamChannel(nsIChannel **result, - nsIURI *uri, - nsIInputStream *stream, - const nsACString &contentType, - const nsACString *contentCharset) +NS_NewChannel(nsIChannel **result, + nsIURI *uri, + const nsACString &contentType, + const nsACString *contentCharset) { nsresult rv; - static NS_DEFINE_CID(kInputStreamChannelCID, NS_INPUTSTREAMCHANNEL_CID); - nsCOMPtr<nsIInputStreamChannel> channel = - do_CreateInstance(kInputStreamChannelCID, &rv); + + rv = NS_NewChannel(result, uri); if (NS_SUCCEEDED(rv)) { - rv |= channel->SetURI(uri); - rv |= channel->SetContentStream(stream); - rv |= channel->SetContentType(contentType); - if (contentCharset && contentCharset->Length()) { - rv |= channel->SetContentCharset(*contentCharset); - } - if (NS_SUCCEEDED(rv)) - NS_ADDREF(*result = channel); + nsIChannel *channel = *result; + rv |= channel->SetContentType(contentType); + if (contentCharset && contentCharset->Length()) { + rv |= channel->SetContentCharset(*contentCharset); + } } return rv; } @@ -147,65 +143,6 @@ return rv; } -// Use this function with CAUTION. It creates a stream that blocks when you -// Read() from it and blocking the UI thread is a bad idea. If you don't want -// to implement a full blown asynchronous consumer (via nsIStreamListener) look -// at nsIStreamLoader instead. -inline nsresult -NS_OpenURI(nsIInputStream **result, - nsIURI *uri, - nsILoadGroup *loadGroup = nsnull, - nsIInterfaceRequestor *callbacks = nsnull, - PRUint32 loadFlags = nsIRequest::LOAD_NORMAL) -{ - nsresult rv; - nsCOMPtr<nsIChannel> channel; - rv = NS_NewChannel(getter_AddRefs(channel), uri, - loadGroup, callbacks, loadFlags); - if (NS_SUCCEEDED(rv)) { - nsIInputStream *stream; - rv = channel->Open(&stream); - if (NS_SUCCEEDED(rv)) - *result = stream; - } - return rv; -} - -inline nsresult -NS_NewLocalFileOutputStream(nsIOutputStream **aResult, - nsIFile *aFile, - PRInt32 aIOFlags = -1, - PRInt32 aPerm = -1, - PRInt32 aBehaviorFlags = 0) -{ - nsresult rv; - static NS_DEFINE_CID(kLocalFileOutputStreamCID, NS_LOCALFILEOUTPUTSTREAM_CID); - nsCOMPtr<nsIFileOutputStream> out = - do_CreateInstance(kLocalFileOutputStreamCID, &rv); - if (NS_SUCCEEDED(rv)) { - rv = out->Init(aFile, aIOFlags, aPerm, aBehaviorFlags); - if (NS_SUCCEEDED(rv)) - NS_ADDREF(*aResult = out); - } - return rv; -} - -inline nsresult -NS_NewLoadGroup(nsILoadGroup **result, - nsIRequestObserver *obs) -{ - nsresult rv; - static NS_DEFINE_CID(kLoadGroupCID, NS_LOADGROUP_CID); - nsCOMPtr<nsILoadGroup> group = - do_CreateInstance(kLoadGroupCID, &rv); - if (NS_SUCCEEDED(rv)) { - rv = group->SetGroupObserver(obs); - if (NS_SUCCEEDED(rv)) - NS_ADDREF(*result = group); - } - return rv; -} - inline void ToLowerCase (nsAString &aString) {