Modified by: bobclark real.com
Date: 5-30-08
Synopsis: Add the ability for common/util to read and write
WebKit
(i.e., Safari) cookies on OS X
Overview:
The APIs for access WebKit cookies are in Cocoa. This means
that there
are extra challenges for building in an otherwise pure C++
environment.
Objective-C++ files traditionally have a .mm extension. Also
the Cocoa
and WebKit frameworks must be linked to the executable
(whether it's a
dynamic library, application, or some other kind of
executable).
Since the linking must be done in the final executable, and
since many
products use the common/util static library, we figured it
was safest
to wrap the Safari cookie code in
HELIX_FEATURE_SAFARI_COOKIES. That
way if the final executable "knows" to link to
Cocoa.framework and
WebKit.framework, it will turn on the feature definition in
the bif
file.
Files Added:
common/util/pub/platform/mac/WebKitPrefs.h
common/util/platform/mac/WebKitPrefs.mm
Files Modified:
common/util/pub/cookies.h
common/util/cookies.cpp
common/util/mac-unix.pcf
Image Size and Heap Use impact (Client -Only): Holding all
WebKit
cookies in the cookies.cpp simple list could add up; my
system
currently has 3000 Safari cookies. Figure a megabyte or
two.
Platforms and Profiles Affected: OS X only
Platforms and Profiles Build Verified: OS X
Platforms and Profiles Functionality verified: Limited
functionality
verified.
Branch: hxclient_3_1_0_atlas
Copyright assignment: I am a RealNetworks employee
--Bob
--
Bob Clark
Lead Software Development Engineer
RealPlayer Mac/Unix
RealNetworks, Inc.
Index: cookies.cpp
============================================================
=======
RCS file: /cvsroot/common/util/cookies.cpp,v
retrieving revision 1.39.2.8
diff -u -w -r1.39.2.8 cookies.cpp
--- cookies.cpp 20 May 2008 00:27:38 -0000 1.39.2.8
+++ cookies.cpp 30 May 2008 23:20:15 -0000
 -87,6
+87,10 
#include "hxver.h" // for HXVER_SDK_PRODUCT
#endif
+#if defined(_MAC_UNIX) &&
defined(HELIX_FEATURE_SAFARI_COOKIES)
+#include "WebKitPrefs.h"
+#endif
+
#if defined(_CARBON)
#include "cfwrappers.h"
#endif
 -154,6
+158,7 
, m_pNSCookies(NULL)
, m_pFFCookies(NULL)
, m_pRMCookies(NULL)
+ , m_pSFCookies(NULL)
, m_pPreferences(NULL)
, m_pCookiesHelper(NULL)
#ifdef _WINDOWS
 -281,10
+286,12 
ResetCookies(m_pNSCookies);
ResetCookies(m_pFFCookies);
ResetCookies(m_pRMCookies);
+ ResetCookies(m_pSFCookies);
HX_DELETE(m_pNSCookies);
HX_DELETE(m_pFFCookies);
HX_DELETE(m_pRMCookies);
+ HX_DELETE(m_pSFCookies);
HX_VECTOR_DELETE(m_pNSCookiesPath);
HX_VECTOR_DELETE(m_pFFCookiesPath);
 -513,6
+520,16 
}
#endif /* _WINDOWS */
+#if defined(_MAC_UNIX) &&
defined(HELIX_FEATURE_SAFARI_COOKIES)
+ if (HX_EXTERNAL_COOKIES_SF & m_ulExternalCookies)
+ {
+ if (!m_bMemoryOnly)
+ {
+ (void)SetWebKitCookieInformation(pNewCookie);
+ }
+ }
+#endif
+
cleanup:
HX_RELEASE(pBuffer);
 -632,7
+649,7 
cHostCopy.MakeLower();
// search for all cookies(Netscape/Firefox only for
now)
- for (l = 0; l < 3; l++)
+ for (l = 0; l < 4; l++)
{
pCookiesList = NULL;
 -657,6
+674,13 
bIsPlayerCookieList = FALSE;
}
break;
+ case 3:
+ if (HX_EXTERNAL_COOKIES_SF &
m_ulExternalCookies)
+ {
+ pCookiesList = m_pSFCookies;
+ bIsPlayerCookieList = FALSE;
+ }
+ break;
default:
break;
}
 -1332,8
+1356,36 
HX_RESULT
HXCookies::_prepareSFCookies(void)
{
- // TBI
+#if defined(_MAC_UNIX) &&
defined(HELIX_FEATURE_SAFARI_COOKIES)
+ HX_RESULT retval = HXR_FAIL;
+ if (!m_pSFCookies)
+ {
+ m_pSFCookies = new CHXSimpleList();
+ void* pWebKitCookiesToken =
InitializeWebKitCookies();
+ if (pWebKitCookiesToken)
+ {
+ int numberOfWebKitCookies =
GetNumberOfWebKitCookies(pWebKitCookiesToken);
+ int whichCookie;
+ for (whichCookie = 0; whichCookie <
numberOfWebKitCookies; whichCookie++)
+ {
+ CookieStruct* pNewCookie = new
CookieStruct;
+ HX_RESULT getInformationResult =
GetWebKitCookieInformation(pWebKitCookiesToken, whichCookie,
pNewCookie);
+ if (SUCCEEDED(getInformationResult))
+ {
+ m_pSFCookies->AddTail(pNewCookie);
+ }
+ else
+ {
+ delete pNewCookie;
+ }
+ }
+ retval = HXR_OK;
+ }
+ }
+ return retval;
+#else
return HXR_NOTIMPL;
+#endif
}
HXBOOL
Index: mac-unix.pcf
============================================================
=======
RCS file: /cvsroot/common/util/mac-unix.pcf,v
retrieving revision 1.8
diff -u -w -r1.8 mac-unix.pcf
--- mac-unix.pcf 6 Jul 2007 20:39:16 -0000 1.8
+++ mac-unix.pcf 30 May 2008 23:20:15 -0000
 -57,6
+57,7 
"platform/mac/hurl.cpp",
"platform/mac/cresload.cpp",
"platform/mac/MoreFilesX.c",
+ "platform/mac/WebKitPrefs.mm"
"platform/mac/fullpathname.cp"
)
Index: pub/cookies.h
============================================================
=======
RCS file: /cvsroot/common/util/pub/cookies.h,v
retrieving revision 1.8.2.5
diff -u -w -r1.8.2.5 cookies.h
--- pub/cookies.h 20 May 2008 00:27:38 -0000 1.8.2.5
+++ pub/cookies.h 30 May 2008 23:20:15 -0000
 -109,6
+109,7 
CHXSimpleList* m_pNSCookies;
CHXSimpleList* m_pFFCookies;
CHXSimpleList* m_pRMCookies;
+ CHXSimpleList* m_pSFCookies;
IHXPreferences* m_pPreferences;
IHXCookiesHelper* m_pCookiesHelper;
_______________________________________________
Common-dev mailing list
Common-dev helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/comm
on-dev
|