The Cookie Module: Initial Version
git-svn-id: svn://10.0.0.236/trunk@34668 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
21ad463edf
commit
15bff55a66
54
mozilla/extensions/cookie/Makefile.in
Normal file
54
mozilla/extensions/cookie/Makefile.in
Normal file
@ -0,0 +1,54 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = cookie
|
||||
|
||||
CSRCS = \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsCookieService.cpp \
|
||||
nsCookie.cpp \
|
||||
nsCookieHTTPNotify.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = cookie
|
||||
|
||||
REQUIRES = js netlib xpcom xppref32 nspr
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
# we don't want the shared lib
|
||||
NO_SHARED_LIB=1
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
377
mozilla/extensions/cookie/htmldlgs.h
Normal file
377
mozilla/extensions/cookie/htmldlgs.h
Normal file
@ -0,0 +1,377 @@
|
||||
#define XP_STRSTR strstr
|
||||
#define XP_STRTOUL strtoul
|
||||
|
||||
#include "platform.h"
|
||||
#include "xp_core.h"
|
||||
#include "xp_mem.h"
|
||||
#include "xp_str.h"
|
||||
#include "xp_list.h"
|
||||
#include "prprf.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "xp_file.h"
|
||||
#include "jsotypes.h"
|
||||
#include "plstr.h"
|
||||
#include "seccomon.h"
|
||||
#include "xpgetstr.h"
|
||||
|
||||
#define PORT_Strlen(s) strlen(s)
|
||||
|
||||
#define HTML_DLGS_URL "file:///y|/htmldlgs.html"
|
||||
#define XP_DIALOG_CANCEL_BUTTON (1<<0)
|
||||
#define XP_DIALOG_OK_BUTTON (1<<2)
|
||||
#define XP_STRINGS_CHUNKSIZE 512
|
||||
typedef struct _XPDialogState XPDialogState;
|
||||
typedef struct _XPDialogInfo XPDialogInfo;
|
||||
typedef struct _XPDialogStrings XPDialogStrings;
|
||||
typedef PRBool (* XP_HTMLDialogHandler)
|
||||
(XPDialogState *state, char **argv, int argc, unsigned int button);
|
||||
|
||||
/* SACopy and SACat should really be defined elsewhere */
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#define LocalStrAllocCopy(dest, src) Local_SACopy (&(dest), src)
|
||||
#define LocalStrAllocCat(dest, src) Local_SACat (&(dest), src)
|
||||
|
||||
struct _XPDialogState {
|
||||
PRArenaPool *arena;
|
||||
void *window;
|
||||
void *proto_win;
|
||||
XPDialogInfo *dialogInfo;
|
||||
void *arg;
|
||||
void (* deleteCallback)(void *arg);
|
||||
void *cbarg;
|
||||
PRBool deleted;
|
||||
};
|
||||
|
||||
struct _XPDialogInfo {
|
||||
unsigned int buttonFlags;
|
||||
XP_HTMLDialogHandler handler;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
struct _XPDialogStrings
|
||||
{
|
||||
PRArenaPool *arena;
|
||||
int basestringnum;
|
||||
int nargs;
|
||||
char **args;
|
||||
char *contents;
|
||||
};
|
||||
|
||||
#ifdef InSingleSignon
|
||||
|
||||
char *
|
||||
Local_SACopy(char **destination, const char *source);
|
||||
|
||||
char *
|
||||
Local_SACat(char **destination, const char *source);
|
||||
|
||||
XPDialogState *
|
||||
XP_MakeHTMLDialog(
|
||||
void *proto_win,
|
||||
XPDialogInfo *dialogInfo,
|
||||
int titlenum,
|
||||
XPDialogStrings *strings,
|
||||
void *arg,
|
||||
PRBool utf8CharSet);
|
||||
|
||||
void
|
||||
XP_MakeHTMLDialog2(XPDialogInfo *dialogInfo);
|
||||
|
||||
XPDialogStrings *
|
||||
XP_GetDialogStrings(int stringnum);
|
||||
|
||||
void
|
||||
XP_SetDialogString(XPDialogStrings *strings, int argNum, char *string);
|
||||
|
||||
void
|
||||
XP_CopyDialogString(XPDialogStrings *strings, int argNum, const char *string);
|
||||
|
||||
char *
|
||||
XP_FindValueInArgs(const char *name, char **av, int ac);
|
||||
|
||||
#else
|
||||
|
||||
char *
|
||||
Local_SACopy(char **destination, const char *source)
|
||||
{
|
||||
if(*destination) {
|
||||
PL_strfree(*destination);
|
||||
*destination = 0;
|
||||
}
|
||||
*destination = PL_strdup(source);
|
||||
return *destination;
|
||||
}
|
||||
|
||||
char *
|
||||
Local_SACat(char **destination, const char *source)
|
||||
{
|
||||
if (source && *source) {
|
||||
if (*destination) {
|
||||
int length = PL_strlen (*destination);
|
||||
*destination = (char *) PR_Realloc(*destination, length + PL_strlen(source) + 1);
|
||||
if (*destination == NULL) {
|
||||
return(NULL);
|
||||
}
|
||||
PL_strcpy (*destination + length, source);
|
||||
} else {
|
||||
*destination = PL_strdup(source);
|
||||
}
|
||||
}
|
||||
return *destination;
|
||||
}
|
||||
|
||||
XPDialogState *
|
||||
XP_MakeHTMLDialog(
|
||||
void *proto_win,
|
||||
XPDialogInfo *dialogInfo,
|
||||
int titlenum,
|
||||
XPDialogStrings *strings,
|
||||
void *arg,
|
||||
PRBool utf8CharSet)
|
||||
{
|
||||
/* write out html dialog to /htmldlgs.htm */
|
||||
XP_File f = fopen("/htmldlgs.htm","w");
|
||||
int i;
|
||||
for (i=0; i<strings->nargs; i++) {
|
||||
if (strings->args[i]) {
|
||||
fprintf(f, "%s", (char *)(strings->args[i]));
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
fflush(f);
|
||||
|
||||
/* write out dialog info to /index.htm */
|
||||
f = fopen("/index.htm","w");
|
||||
fprintf(f, "<HTML> \n");
|
||||
fprintf(f, " <BODY \n");
|
||||
fprintf(f, " onload=\"msgWindow=window.open(\n");
|
||||
fprintf(f, " 'htmldlgs.htm', \n");
|
||||
fprintf(f, " 'window2', \n");
|
||||
fprintf(f, " 'resizable=no, titlebar=no, width=%d, height=%d')\">\n",
|
||||
dialogInfo->width, dialogInfo->height);
|
||||
fprintf(f, " </BODY> \n");
|
||||
fprintf(f, "</HTML> \n");
|
||||
fclose(f);
|
||||
fflush(f);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef junk
|
||||
void
|
||||
XP_MakeHTMLDialog2(XPDialogInfo *dialogInfo) {
|
||||
char* argv[] = {NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
int argc = 0;
|
||||
char* button = NULL;
|
||||
|
||||
nsAutoString * nsCookie = new nsAutoString("");
|
||||
nsIURL* url;
|
||||
char* separator;
|
||||
|
||||
nsINetService *netservice;
|
||||
nsresult res;
|
||||
res = nsServiceManager::GetService(kNetServiceCID,
|
||||
kINetServiceIID,
|
||||
(nsISupports **)&netservice);
|
||||
if ((NS_OK == res) && (nsnull != netservice)) {
|
||||
const nsAutoString html_dlgs = nsAutoString(HTML_DLGS_URL);
|
||||
if (!NS_FAILED(NS_NewURL(&url, html_dlgs))) {
|
||||
res = netservice->GetCookieString(url, *nsCookie);
|
||||
|
||||
/* convert cookie to a C string */
|
||||
|
||||
char *cookies = nsCookie->ToNewCString();
|
||||
char *cookie = PL_strstr(cookies, "htmldlgs=|"); /* get to htmldlgs=| */
|
||||
if (cookie) {
|
||||
cookie = cookie + PL_strlen("htmldlgs=|"); /* get passed htmldlgs=| */
|
||||
|
||||
/* button name is first item in cookie (up to next verical bar) */
|
||||
|
||||
separator = strchr(cookie, '|');
|
||||
*separator = '\0';
|
||||
LocalStrAllocCopy(button, cookie);
|
||||
cookie = separator+1;
|
||||
*separator = '|';
|
||||
|
||||
/* remainder of cookie string are the args, separated by vertical bars */
|
||||
for (int i=0; ((*cookie != '\0') && (*cookie != ';')); i++) {
|
||||
separator = strchr(cookie, '|');
|
||||
*separator = '\0';
|
||||
LocalStrAllocCopy(argv[i], cookie);
|
||||
cookie = separator+1;
|
||||
*separator = '|';
|
||||
argc++;
|
||||
}
|
||||
|
||||
/* call the callback routine */
|
||||
if (!PORT_Strcmp(button,"OK")) {
|
||||
(dialogInfo->handler)(NULL, argv, argc, XP_DIALOG_OK_BUTTON);
|
||||
} else {
|
||||
(dialogInfo->handler)(NULL, argv, argc, XP_DIALOG_CANCEL_BUTTON);
|
||||
}
|
||||
|
||||
/* free up the allocated strings */
|
||||
XP_FREE(button);
|
||||
for (int j=0; j<argc; j++) {
|
||||
XP_FREE(argv[j]);
|
||||
}
|
||||
}
|
||||
delete[] cookies;
|
||||
}
|
||||
NS_RELEASE(netservice);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
XPDialogStrings *
|
||||
XP_GetDialogStrings(int stringnum)
|
||||
{
|
||||
XPDialogStrings *header = NULL;
|
||||
PRArenaPool *arena = NULL;
|
||||
char *dst, *src;
|
||||
int n, size, len, done = 0;
|
||||
|
||||
/* get a new arena */
|
||||
arena = PORT_NewArena(XP_STRINGS_CHUNKSIZE);
|
||||
if ( arena == NULL ) {
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* allocate the header structure */
|
||||
header = (XPDialogStrings *)PORT_ArenaAlloc(arena, sizeof(XPDialogStrings));
|
||||
if ( header == NULL ) {
|
||||
goto loser;
|
||||
}
|
||||
|
||||
/* init the header */
|
||||
header->arena = arena;
|
||||
header->basestringnum = stringnum;
|
||||
|
||||
#ifdef XP_MAC
|
||||
goto loser;
|
||||
#else
|
||||
src = XP_GetString(stringnum);
|
||||
|
||||
#endif
|
||||
len = PORT_Strlen(src);
|
||||
size = len + 1;
|
||||
dst = header->contents =
|
||||
(char *)PORT_ArenaAlloc(arena, sizeof(char) * size);
|
||||
if (dst == NULL) {
|
||||
goto loser;
|
||||
}
|
||||
|
||||
while (!done) { /* Concatenate pieces to form message */
|
||||
PORT_Memcpy(dst, src, len+1);
|
||||
done = 1;
|
||||
if (XP_STRSTR(src, "%-cont-%")) { /* Continuation */
|
||||
src = XP_GetString(++stringnum);
|
||||
len = PORT_Strlen(src);
|
||||
header->contents =
|
||||
(char *)PORT_ArenaGrow(arena,
|
||||
header->contents, size, size + len);
|
||||
if (header->contents == NULL) {
|
||||
goto loser;
|
||||
}
|
||||
dst = header->contents + size - 1;
|
||||
size += len;
|
||||
done = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* At this point we should have the complete message in
|
||||
header->contents, including like %-cont-%, which will be
|
||||
ignored later. */
|
||||
|
||||
/* Count the arguments in the message */
|
||||
header->nargs = -1; /* Support %0% as lowest token */
|
||||
src = header->contents;
|
||||
while ((src = PORT_Strchr(src, '%'))) {
|
||||
src++;
|
||||
n = (int)XP_STRTOUL(src, &dst, 10);
|
||||
if (dst == src) { /* Integer not found... */
|
||||
src = PORT_Strchr(src, '%') + 1; /* so skip this %..% */
|
||||
PORT_Assert(NULL != src-1); /* Unclosed %..% ? */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (header->nargs < n) {
|
||||
header->nargs = n;
|
||||
}
|
||||
src = dst + 1;
|
||||
}
|
||||
|
||||
if (++(header->nargs) > 0) { /* Allocate space for arguments */
|
||||
header->args =
|
||||
(char **)PORT_ArenaZAlloc(arena, sizeof(char *) * header->nargs);
|
||||
}
|
||||
|
||||
return(header);
|
||||
|
||||
loser:
|
||||
PORT_FreeArena(arena, PR_FALSE);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
XP_SetDialogString(XPDialogStrings *strings, int argNum, char *string)
|
||||
{
|
||||
/* make sure we are doing it right */
|
||||
PORT_Assert(argNum < strings->nargs);
|
||||
PORT_Assert(argNum >= 0);
|
||||
PORT_Assert(strings->args[argNum] == NULL);
|
||||
|
||||
/* set the string */
|
||||
strings->args[argNum] = string;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XP_CopyDialogString(XPDialogStrings *strings, int argNum, const char *string)
|
||||
{
|
||||
int len;
|
||||
|
||||
/* make sure we are doing it right */
|
||||
PORT_Assert(argNum < strings->nargs);
|
||||
PORT_Assert(argNum >= 0);
|
||||
PORT_Assert(strings->args[argNum] == NULL);
|
||||
|
||||
/* copy the string */
|
||||
len = PORT_Strlen(string) + 1;
|
||||
strings->args[argNum] = (char *)PORT_ArenaAlloc(strings->arena, len);
|
||||
if ( strings->args[argNum] != NULL ) {
|
||||
PORT_Memcpy(strings->args[argNum], string, len);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
XP_FindValueInArgs(const char *name, char **av, int ac)
|
||||
{
|
||||
for( ;ac > 0; ac -= 2, av += 2 ) {
|
||||
if ( PORT_Strcmp(name, av[0]) == 0 ) {
|
||||
return(av[1]);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define BUFLEN 5000
|
||||
|
||||
#define FLUSH_BUFFER \
|
||||
if (buffer) { \
|
||||
LocalStrAllocCat(buffer2, buffer); \
|
||||
buffer[0] = '\0'; \
|
||||
g = 0; \
|
||||
}
|
||||
|
||||
extern int XP_EMPTY_STRINGS;
|
||||
78
mozilla/extensions/cookie/makefile.win
Normal file
78
mozilla/extensions/cookie/makefile.win
Normal file
@ -0,0 +1,78 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
DEFINES=-D_IMPL_NS_COOKIE -DWIN32_LEAN_AND_MEAN
|
||||
MODULE=cookie
|
||||
|
||||
EXPORTS = nsICookieService.h nsCookieHTTPNotify.h nsCookie.h
|
||||
|
||||
|
||||
CSRCS= \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS= \
|
||||
nsCookieService.cpp \
|
||||
nsCookie.cpp \
|
||||
nsCookieHTTPNotify.cpp \
|
||||
$(NULL)
|
||||
|
||||
C_OBJS= \
|
||||
$(NULL)
|
||||
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsCookieService.obj \
|
||||
.\$(OBJDIR)\nsCookie.obj \
|
||||
.\$(OBJDIR)\nsCookieHTTPNotify.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS = -I$(DEPTH)\include \
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = cookie
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
# These are the libraries we need to link with to create the dll
|
||||
LLIBS = \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\js$(MOZ_BITS)$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\xplib.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\netwerk.lib \
|
||||
$(DIST)\lib\xppref32.lib \
|
||||
$(DIST)\lib\secfreenav32.lib \
|
||||
$(HASHLIBS)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\components\$(DLLNAME).dll
|
||||
rm -f $(DIST)\lib\$(DLLNAME).lib
|
||||
3422
mozilla/extensions/cookie/nsCookie.cpp
Normal file
3422
mozilla/extensions/cookie/nsCookie.cpp
Normal file
File diff suppressed because it is too large
Load Diff
82
mozilla/extensions/cookie/nsCookie.h
Normal file
82
mozilla/extensions/cookie/nsCookie.h
Normal file
@ -0,0 +1,82 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef COOKIES_H
|
||||
#define COOKIES_H
|
||||
|
||||
#include "mkgeturl.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsError.h"
|
||||
|
||||
#ifdef _IMPL_NS_COOKIE
|
||||
#define NS_COOKIE NS_EXPORT
|
||||
#else
|
||||
#define NS_COOKIE NS_IMPORT
|
||||
#endif
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/* removes all cookies structs from the cookie list */
|
||||
extern void
|
||||
NET_RemoveAllCookies(void);
|
||||
|
||||
/*
|
||||
extern char *
|
||||
NET_GetCookie(MWContext * context, char * address);
|
||||
*/
|
||||
|
||||
extern char *
|
||||
NET_GetCookie(char * address);
|
||||
|
||||
extern void
|
||||
NET_SetCookieString(MWContext * context,
|
||||
char * cur_url,
|
||||
char * set_cookie_header);
|
||||
|
||||
/* saves out the HTTP cookies to disk
|
||||
*
|
||||
* on entry pass in the name of the file to save
|
||||
*
|
||||
* returns 0 on success -1 on failure.
|
||||
*
|
||||
*/
|
||||
extern int NET_SaveCookies(char * filename);
|
||||
|
||||
/* reads HTTP cookies from disk
|
||||
*
|
||||
* on entry pass in the name of the file to read
|
||||
*
|
||||
* returns 0 on success -1 on failure.
|
||||
*
|
||||
*/
|
||||
extern int NET_ReadCookies(char * filename);
|
||||
|
||||
/* wrapper of NET_SetCookieString for netlib use. We need outformat and url_struct to determine
|
||||
* whether we're dealing with inline cookies
|
||||
*/
|
||||
extern void
|
||||
NET_SetCookieStringFromHttp(FO_Present_Types outputFormat,
|
||||
URL_Struct * URL_s,
|
||||
MWContext * context,
|
||||
char * cur_url,
|
||||
char * set_cookie_header);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* COOKIES_H */
|
||||
183
mozilla/extensions/cookie/nsCookieHTTPNotify.cpp
Normal file
183
mozilla/extensions/cookie/nsCookieHTTPNotify.cpp
Normal file
@ -0,0 +1,183 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsCookieHTTPNotify.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsCookie.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// nsISupports
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsCookieHTTPNotify, nsIHTTPNotify::GetIID());
|
||||
|
||||
///////////////////////////////////
|
||||
// nsCookieHTTPNotify Implementation
|
||||
|
||||
NS_COOKIE nsresult NS_NewCookieHTTPNotify(nsIHTTPNotify** aHTTPNotify)
|
||||
{
|
||||
if (aHTTPNotify == NULL)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsCookieHTTPNotify* it = new nsCookieHTTPNotify();
|
||||
|
||||
if (it == 0) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(nsIHTTPNotify::GetIID(), (void **) aHTTPNotify);
|
||||
}
|
||||
|
||||
nsCookieHTTPNotify::nsCookieHTTPNotify()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsCookieHTTPNotify::~nsCookieHTTPNotify()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
// nsIHTTPNotify
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::ModifyRequest(nsISupports *aContext)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIHTTPChannel* pHTTPConnection= nsnull;
|
||||
|
||||
if (aContext) {
|
||||
rv = aContext->QueryInterface(nsIHTTPChannel::GetIID(),
|
||||
(void**)pHTTPConnection);
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
const char* cookie = "testCookieVal";
|
||||
rv = pHTTPConnection->SetRequestHeader("Cookie", cookie);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(pHTTPConnection);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_RELEASE(pHTTPConnection);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::AsyncExamineResponse(nsISupports *aContext)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIHTTPChannel* pHTTPConnection= nsnull;
|
||||
|
||||
if (aContext) {
|
||||
rv = aContext->QueryInterface(nsIHTTPChannel::GetIID(),
|
||||
(void**)pHTTPConnection);
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
||||
char* cookie = "testCookieVal";
|
||||
rv = pHTTPConnection->GetResponseHeader("Set-Cookie", &cookie);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(pHTTPConnection);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (cookie) {
|
||||
printf("\nRecieving ... %s\n", cookie);
|
||||
nsCRT::free(cookie);
|
||||
}
|
||||
|
||||
NS_RELEASE(pHTTPConnection);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsCookieHTTPFactory Implementation
|
||||
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_IMPL_ISUPPORTS(nsCookieHTTPNotifyFactory, kIFactoryIID);
|
||||
|
||||
nsCookieHTTPNotifyFactory::nsCookieHTTPNotifyFactory(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsCookieHTTPNotifyFactory::~nsCookieHTTPNotifyFactory(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCookieHTTPNotifyFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsIHTTPNotify* inst = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewCookieHTTPNotify(&inst)))
|
||||
return rv;
|
||||
|
||||
if (!inst)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = NULL;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCookieHTTPNotifyFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
73
mozilla/extensions/cookie/nsCookieHTTPNotify.h
Normal file
73
mozilla/extensions/cookie/nsCookieHTTPNotify.h
Normal file
@ -0,0 +1,73 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsCookieHTTPNotify_h___
|
||||
#define nsCookieHTTPNotify_h___
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIHttpNotify.h"
|
||||
|
||||
// {6BC1F522-1F45-11d3-8AD4-00105A1B8860}
|
||||
#define NS_COOKIEHTTPNOTIFY_CID \
|
||||
{ 0x6bc1f522, 0x1f45, 0x11d3, { 0x8a, 0xd4, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } };
|
||||
|
||||
|
||||
class nsCookieHTTPNotify : public nsIHTTPNotify
|
||||
{
|
||||
public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIHttpNotify methods:
|
||||
NS_IMETHOD ModifyRequest(nsISupports *aContext);
|
||||
NS_IMETHOD AsyncExamineResponse(nsISupports *aContext);
|
||||
|
||||
|
||||
// nsCookieHTTPNotify methods:
|
||||
nsCookieHTTPNotify();
|
||||
virtual ~nsCookieHTTPNotify();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
class nsCookieHTTPNotifyFactory : public nsIFactory {
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFactory methods:
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
// nsCookieHTTPNotifyFactory methods:
|
||||
|
||||
nsCookieHTTPNotifyFactory(void);
|
||||
virtual ~nsCookieHTTPNotifyFactory(void);
|
||||
|
||||
};
|
||||
|
||||
extern NS_EXPORT nsresult NS_NewCookieHTTPNotify(nsIHTTPNotify** aHTTPNotify);
|
||||
|
||||
|
||||
#endif /* nsCookieHTTPNotify_h___ */
|
||||
266
mozilla/extensions/cookie/nsCookieService.cpp
Normal file
266
mozilla/extensions/cookie/nsCookieService.cpp
Normal file
@ -0,0 +1,266 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#define NS_IMPL_IDS
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsCookieHTTPNotify.h"
|
||||
#include "nsINetModuleMgr.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kICookieServiceIID, NS_ICOOKIESERVICE_IID);
|
||||
|
||||
static NS_DEFINE_CID(kNetModuleMgrCID, NS_NETMODULEMGR_CID);
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_IID(kCookieHTTPNotifyCID, NS_COOKIEHTTPNOTIFY_CID);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsCookieService : public nsICookieService {
|
||||
public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsICookieService
|
||||
static nsresult GetCookieService(nsICookieService** aCookieService);
|
||||
NS_IMETHOD Init();
|
||||
|
||||
nsCookieService();
|
||||
virtual ~nsCookieService(void);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsIHTTPNotify *mCookieHTTPNotify;
|
||||
|
||||
|
||||
};
|
||||
|
||||
static nsCookieService* gCookieService = nsnull; // The one-and-only CookieService
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsCookieServiceFactory : public nsIFactory {
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFactory methods:
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
// nsCookieService methods:
|
||||
|
||||
nsCookieServiceFactory(void);
|
||||
virtual ~nsCookieServiceFactory(void);
|
||||
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsCookieService Implementation
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsCookieService, kICookieServiceIID);
|
||||
|
||||
NS_EXPORT nsresult NS_NewCookieService(nsICookieService** aCookieService)
|
||||
{
|
||||
return nsCookieService::GetCookieService(aCookieService);
|
||||
}
|
||||
|
||||
nsCookieService::nsCookieService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mCookieHTTPNotify = nsnull;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
nsCookieService::~nsCookieService(void)
|
||||
{
|
||||
gCookieService = nsnull;
|
||||
}
|
||||
|
||||
nsresult nsCookieService::GetCookieService(nsICookieService** aCookieService)
|
||||
{
|
||||
if (! gCookieService) {
|
||||
nsCookieService* it = new nsCookieService();
|
||||
if (! it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
gCookieService = it;
|
||||
}
|
||||
|
||||
NS_ADDREF(gCookieService);
|
||||
*aCookieService = gCookieService;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsCookieService::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE(nsINetModuleMgr, pNetModuleMgr, kNetModuleMgrCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIEventQueue* eventQ;
|
||||
NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = eventQService->GetThreadEventQueue(PR_CurrentThread(), &eventQ);
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewCookieHTTPNotify(&mCookieHTTPNotify)))
|
||||
return rv;
|
||||
rv = pNetModuleMgr->RegisterModule("http-request", eventQ, mCookieHTTPNotify, &kCookieHTTPNotifyCID);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = pNetModuleMgr->RegisterModule("http-response", eventQ, mCookieHTTPNotify, &kCookieHTTPNotifyCID);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsCookieServiceFactory Implementation
|
||||
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_IMPL_ISUPPORTS(nsCookieServiceFactory, kIFactoryIID);
|
||||
|
||||
nsCookieServiceFactory::nsCookieServiceFactory(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsCookieServiceFactory::~nsCookieServiceFactory(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCookieServiceFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsICookieService* inst = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewCookieService(&inst)))
|
||||
return rv;
|
||||
|
||||
if (!inst)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = NULL;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCookieServiceFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// DLL Entry Points:
|
||||
|
||||
static NS_DEFINE_IID(kCookieServiceCID, NS_COOKIESERVICE_CID);
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSGetFactory(nsISupports* servMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if (! aFactory)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aClass.Equals(kCookieServiceCID)) {
|
||||
nsCookieServiceFactory *factory = new nsCookieServiceFactory();
|
||||
|
||||
if (factory == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(factory);
|
||||
*aFactory = factory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT PRBool
|
||||
NSCanUnload(nsISupports* serviceMgr)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSRegisterSelf(nsISupports* serviceMgr, const char* aPath)
|
||||
{
|
||||
return nsComponentManager::RegisterComponent(kCookieServiceCID,
|
||||
"CookieService",
|
||||
NS_COOKIESERVICE_PROGID,
|
||||
aPath,PR_TRUE, PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSUnregisterSelf(nsISupports* serviceMgr, const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = nsComponentManager::UnregisterComponent(kCookieServiceCID, aPath);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
45
mozilla/extensions/cookie/nsICookieService.h
Normal file
45
mozilla/extensions/cookie/nsICookieService.h
Normal file
@ -0,0 +1,45 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsICookieService_h__
|
||||
#define nsICookieService_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {AB397772-12D3-11d3-8AD1-00105A1B8860}
|
||||
#define NS_ICOOKIESERVICE_IID \
|
||||
{ 0xab397772, 0x12d3, 0x11d3, { 0x8a, 0xd1, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } };
|
||||
|
||||
|
||||
// {AB397774-12D3-11d3-8AD1-00105A1B8860}
|
||||
#define NS_COOKIESERVICE_CID \
|
||||
{ 0xab397774, 0x12d3, 0x11d3, { 0x8a, 0xd1, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } };
|
||||
|
||||
|
||||
class nsICookieService : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD Init() = 0;
|
||||
};
|
||||
|
||||
|
||||
/* ProgID prefixes for Cookie DLL registration. */
|
||||
#define NS_COOKIESERVICE_PROGID "component:||netscape|cookie"
|
||||
|
||||
|
||||
#endif /* nsICookieService_h__ */
|
||||
41
mozilla/extensions/cookie/tests/Makefile.in
Normal file
41
mozilla/extensions/cookie/tests/Makefile.in
Normal file
@ -0,0 +1,41 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
CPPSRCS = TestCookie.cpp
|
||||
|
||||
LOCAL_INCLUDES =
|
||||
|
||||
REQUIRES = js cookie pref xpcom include
|
||||
|
||||
LIBS = \
|
||||
-lxpcom \
|
||||
-lreg \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
PROGRAM = testCookie
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
29
mozilla/extensions/cookie/tests/TestCookie.cpp
Normal file
29
mozilla/extensions/cookie/tests/TestCookie.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#define NS_IMPL_IDS
|
||||
#include "nsISupports.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICookieService.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kICookieServiceIID, NS_ICOOKIESERVICE_IID);
|
||||
static NS_DEFINE_IID(kCookieServiceCID, NS_COOKIESERVICE_CID);
|
||||
|
||||
|
||||
|
||||
PRInt32 main(PRInt32 argc, char *argv[])
|
||||
{
|
||||
|
||||
nsICookieService *cookieService = NULL;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kCookieServiceCID,
|
||||
kICookieServiceIID,
|
||||
(nsISupports **)&cookieService);
|
||||
|
||||
if (rv == NS_OK) {
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
53
mozilla/extensions/cookie/tests/makefile.win
Normal file
53
mozilla/extensions/cookie/tests/makefile.win
Normal file
@ -0,0 +1,53 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
DEPTH = ..\..\..
|
||||
DEFINES=-D_IMPL_NS_COOKIE -DWIN32_LEAN_AND_MEAN
|
||||
MODULE=cookie
|
||||
|
||||
MAKE_OBJ_TYPE = EXE
|
||||
|
||||
LCFLAGS=-DUSE_NSREG
|
||||
|
||||
EXENAME=TestCookie
|
||||
PDBFILE=TestCookie.pdb
|
||||
MAPFILE=TestCookie.map
|
||||
|
||||
PROGRAM=.\$(OBJDIR)\$(EXENAME).exe
|
||||
|
||||
OBJS=.\$(OBJDIR)\TestCookie.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LINCS = -I$(DEPTH)\include \
|
||||
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\cookie.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\netwerk.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(LIBNSPR) \
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(PROGRAM)
|
||||
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\TestCookie.exe
|
||||
Loading…
x
Reference in New Issue
Block a user