Compare commits
1 Commits
PARTYTOOL1
...
tags/DISKC
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
226de98a81 |
6
mozilla/netwerk/cache/public/MANIFEST
vendored
Normal file
6
mozilla/netwerk/cache/public/MANIFEST
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
nsICachedNetData.idl
|
||||
nsINetDataCache.idl
|
||||
nsINetDataCacheManager.idl
|
||||
nsINetDataCacheRecord.idl
|
||||
nsINetDataDiskCache.idl
|
||||
nsIStreamAsFile.idl
|
||||
56
mozilla/netwerk/cache/public/Makefile.in
vendored
Normal file
56
mozilla/netwerk/cache/public/Makefile.in
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
MODULE = nkcache
|
||||
XPIDL_MODULE = necko_cache
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsICachedNetData.idl \
|
||||
nsINetDataCacheManager.idl \
|
||||
nsINetDataCache.idl \
|
||||
nsINetDataCacheRecord.idl \
|
||||
nsINetDataDiskCache.idl \
|
||||
nsIStreamAsFile.idl \
|
||||
$(NULL)
|
||||
|
||||
|
||||
ifdef MOZ_NEW_CACHE
|
||||
XPIDLSRCS += \
|
||||
nsICache.idl \
|
||||
nsICacheEntryDescriptor.idl \
|
||||
nsICacheListener.idl \
|
||||
nsICacheService.idl \
|
||||
nsICacheSession.idl \
|
||||
nsICacheVisitor.idl \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
51
mozilla/netwerk/cache/public/Makefile.win
vendored
Executable file
51
mozilla/netwerk/cache/public/Makefile.win
vendored
Executable file
@@ -0,0 +1,51 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
MODULE = necko
|
||||
XPIDL_MODULE = necko_cache
|
||||
|
||||
DEPTH = ..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsICachedNetData.idl \
|
||||
.\nsINetDataCacheManager.idl \
|
||||
.\nsINetDataCache.idl \
|
||||
.\nsINetDataCacheRecord.idl \
|
||||
.\nsINetDataDiskCache.idl \
|
||||
.\nsIStreamAsFile.idl \
|
||||
!ifdef MOZ_NEW_CACHE
|
||||
.\nsICache.idl \
|
||||
.\nsICacheEntryDescriptor.idl \
|
||||
.\nsICacheListener.idl \
|
||||
.\nsICacheService.idl \
|
||||
.\nsICacheSession.idl \
|
||||
.\nsICacheVisitor.idl \
|
||||
!endif
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
|
||||
158
mozilla/netwerk/cache/public/nsICache.idl
vendored
Normal file
158
mozilla/netwerk/cache/public/nsICache.idl
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsICache.idl, released February 23, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
typedef long nsCacheStoragePolicy;
|
||||
typedef long nsCacheAccessMode;
|
||||
|
||||
/**
|
||||
* nsICache is a namespace for various cache constants. It does not represent
|
||||
* an actual object.
|
||||
*/
|
||||
[scriptable, uuid(ec1c0063-197d-44bb-84ba-7525d50fc937)]
|
||||
interface nsICache
|
||||
{
|
||||
/**
|
||||
* Access Modes
|
||||
*
|
||||
*
|
||||
* Mode Requested | Not Cached | Cached
|
||||
* ------------------------------------------------------------------------
|
||||
* READ | KEY_NOT_FOUND | NS_OK
|
||||
* | Mode = NONE | Mode = READ
|
||||
* | No Descriptor | Descriptor
|
||||
* ------------------------------------------------------------------------
|
||||
* WRITE | NS_OK | NS_OK (Cache service
|
||||
* | Mode = WRITE | Mode = WRITE dooms existing
|
||||
* | Descriptor | Descriptor cache entry)
|
||||
* ------------------------------------------------------------------------
|
||||
* READ_WRITE | NS_OK | NS_OK
|
||||
* (1st req.) | Mode = WRITE | Mode = READ_WRITE
|
||||
* | Descriptor | Descriptor
|
||||
* ------------------------------------------------------------------------
|
||||
* READ_WRITE | N/A | NS_OK
|
||||
* (Nth req.) | | Mode = READ
|
||||
* | | Descriptor
|
||||
* ------------------------------------------------------------------------
|
||||
*
|
||||
*
|
||||
* Access Requested:
|
||||
*
|
||||
* READ - I only want to READ, if there isn't an entry just fail
|
||||
* WRITE - I have something new I want to write into the cache, make
|
||||
* me a new entry and doom the old one, if any.
|
||||
* READ_WRITE - I want to READ, but I'm willing to update an existing
|
||||
* entry if necessary, or create a new one if none exists.
|
||||
*
|
||||
*
|
||||
* Access Granted:
|
||||
*
|
||||
* NONE - No descriptor is provided. You get zilch. Nada. Nothing.
|
||||
* READ - You can READ from this descriptor.
|
||||
* WRITE - You must WRITE to this descriptor because the cache entry
|
||||
* was just created for you.
|
||||
* READ_WRITE - You can READ the descriptor to determine if it's valid,
|
||||
* you may WRITE if it needs updating.
|
||||
*
|
||||
*
|
||||
* Comments:
|
||||
*
|
||||
* If you think that you might need to modify cached data or meta data,
|
||||
* then you must open a cache entry requesting WRITE access. Only one
|
||||
* cache entry descriptor, per cache entry, will be granted WRITE access.
|
||||
*
|
||||
* Usually, you will request READ_WRITE access in order to first test the
|
||||
* meta data and informational fields to determine if a write (ie. going
|
||||
* to the net) may actually be necessary. If you determine that it is
|
||||
* not, then you would mark the cache entry as valid (using MarkValid) and
|
||||
* then simply read the data from the cache.
|
||||
*
|
||||
* A descriptor granted WRITE access has exclusive access to the cache
|
||||
* entry up to the point at which it marks it as valid. Once the cache
|
||||
* entry has been "validated", other descriptors with READ access may be
|
||||
* opened to the cache entry.
|
||||
*
|
||||
* If you make a request for READ_WRITE access to a cache entry, the cache
|
||||
* service will downgrade your access to READ if there is already a
|
||||
* cache entry descriptor open with WRITE access.
|
||||
*
|
||||
* If you make a request for only WRITE access to a cache entry and another
|
||||
* descriptor with WRITE access is currently open, then the existing cache
|
||||
* entry will be 'doomed', and you will be given a descriptor (with WRITE
|
||||
* access only) to a new cache entry.
|
||||
*
|
||||
*/
|
||||
const nsCacheAccessMode ACCESS_NONE = 0;
|
||||
const nsCacheAccessMode ACCESS_READ = 1;
|
||||
const nsCacheAccessMode ACCESS_WRITE = 2;
|
||||
const nsCacheAccessMode ACCESS_READ_WRITE = 3;
|
||||
|
||||
/**
|
||||
* Storage Policy
|
||||
*
|
||||
* The storage policy of a cache entry determines the device(s) to which
|
||||
* it belongs. See nsICacheSession and nsICacheEntryDescriptor for more
|
||||
* details.
|
||||
*
|
||||
* STORE_ANYWHERE - Allows the cache entry to be stored in any device.
|
||||
* The cache service decides which cache device to use
|
||||
* based on "some resource management calculation."
|
||||
* STORE_IN_MEMORY - Requires the cache entry to reside in non-persistent
|
||||
* storage (ie. typically in system RAM).
|
||||
* STORE_ON_DISK - Requires the cache entry to reside in persistent
|
||||
* storage (ie. typically on a system's hard disk).
|
||||
* STORE_ON_DISK_AS_DISK - Requires the cache entry to reside in persistent
|
||||
* storage, and in a specific file.
|
||||
*/
|
||||
const nsCacheStoragePolicy STORE_ANYWHERE = 0;
|
||||
const nsCacheStoragePolicy STORE_IN_MEMORY = 1;
|
||||
const nsCacheStoragePolicy STORE_ON_DISK = 2;
|
||||
const nsCacheStoragePolicy STORE_ON_DISK_AS_FILE = 3;
|
||||
|
||||
/**
|
||||
* All entries for a cache session are stored as streams of data or
|
||||
* as objects. These constant my be used to specify the type of entries
|
||||
* when calling nsICacheService::CreateSession().
|
||||
*/
|
||||
const long NOT_STREAM_BASED = 0;
|
||||
const long STREAM_BASED = 1;
|
||||
};
|
||||
|
||||
|
||||
%{C++
|
||||
|
||||
/**
|
||||
* Cache specific nsresult error codes
|
||||
*/
|
||||
#define NS_ERROR_CACHE_KEY_NOT_FOUND NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 60)
|
||||
#define NS_ERROR_CACHE_DATA_IS_STREAM NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 61)
|
||||
#define NS_ERROR_CACHE_DATA_IS_NOT_STREAM NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 62)
|
||||
#define NS_ERROR_CACHE_WAIT_FOR_VALIDATION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 63)
|
||||
#define NS_ERROR_CACHE_ENTRY_DOOMED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 64)
|
||||
#define NS_ERROR_CACHE_READ_ACCESS_DENIED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 65)
|
||||
#define NS_ERROR_CACHE_WRITE_ACCESS_DENIED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 66)
|
||||
|
||||
%}
|
||||
137
mozilla/netwerk/cache/public/nsICacheEntryDescriptor.idl
vendored
Normal file
137
mozilla/netwerk/cache/public/nsICacheEntryDescriptor.idl
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsICacheEntryDescriptor.idl, released
|
||||
* February 10, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsICacheVisitor.idl"
|
||||
#include "nsICache.idl"
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsICacheListener;
|
||||
interface nsITransport;
|
||||
interface nsIFile;
|
||||
interface nsICacheMetaDataVisitor;
|
||||
|
||||
|
||||
[scriptable, uuid(49c1a11d-f5d2-4f09-8262-551e64908ada)]
|
||||
interface nsICacheEntryDescriptor : nsICacheEntryInfo
|
||||
{
|
||||
/**
|
||||
* Set the time at which the cache entry should be considered invalid (in
|
||||
* seconds since the Epoch).
|
||||
*/
|
||||
void setExpirationTime(in PRUint32 expirationTime);
|
||||
|
||||
/**
|
||||
* Set the cache entry data size. This will fail if the cache entry
|
||||
* IS stream based.
|
||||
*/
|
||||
void setDataSize(in unsigned long size);
|
||||
|
||||
/**
|
||||
* Get a transport to the cache data. This will fail if the cache entry
|
||||
* IS NOT stream based.
|
||||
*/
|
||||
readonly attribute nsITransport transport;
|
||||
|
||||
/**
|
||||
* Get/set the cache data element. This will fail if the cache entry
|
||||
* IS stream based. The cache entry holds a strong reference to this
|
||||
* object. The object will be released when the cache entry is destroyed.
|
||||
*/
|
||||
attribute nsISupports cacheElement;
|
||||
|
||||
/**
|
||||
* Get the access granted to this descriptor. See nsICache.idl for the
|
||||
* definitions of the access modes and a thorough description of their
|
||||
* corresponding meanings.
|
||||
*/
|
||||
readonly attribute nsCacheAccessMode accessGranted;
|
||||
|
||||
/**
|
||||
* Get/set the storage policy of the cache entry. See nsICache.idl for
|
||||
* the definitions of the storage policies.
|
||||
*/
|
||||
attribute nsCacheStoragePolicy storagePolicy;
|
||||
|
||||
/**
|
||||
* Get the disk file associated with the cache entry.
|
||||
*/
|
||||
readonly attribute nsIFile file;
|
||||
|
||||
/**
|
||||
* Get/set security info on the cache entry for this descriptor. This fails
|
||||
* if the storage policy is not STORE_IN_MEMORY.
|
||||
*/
|
||||
attribute nsISupports securityInfo;
|
||||
|
||||
/**
|
||||
* Doom the cache entry this descriptor references in order to slate it for
|
||||
* removal. Once doomed a cache entry cannot be undoomed.
|
||||
*
|
||||
* A descriptor with WRITE access can doom the cache entry and choose to
|
||||
* fail pending requests. This means that pending requests will not get
|
||||
* a cache descriptor. This is meant as a tool for clients that wish to
|
||||
* instruct pending requests to skip the cache.
|
||||
*/
|
||||
void doom();
|
||||
void doomAndFailPendingRequests(in nsresult status);
|
||||
|
||||
/**
|
||||
* A writer must validate this cache object before any readers are given
|
||||
* a descriptor to the object.
|
||||
*/
|
||||
void markValid();
|
||||
|
||||
/**
|
||||
* Explicitly close the descriptor (optional).
|
||||
*/
|
||||
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Methods for accessing meta data. Meta data is a table of key/value
|
||||
* string pairs. The strings do not have to conform to any particular
|
||||
* charset, but they must be null terminated.
|
||||
*/
|
||||
string getMetaDataElement(in string key);
|
||||
void setMetaDataElement(in string key, in string value);
|
||||
|
||||
/**
|
||||
* Visitor will be called with key/value pair for each meta data element.
|
||||
*/
|
||||
void visitMetaData(in nsICacheMetaDataVisitor visitor);
|
||||
};
|
||||
|
||||
|
||||
|
||||
[scriptable, uuid(22f9a49c-3cf8-4c23-8006-54efb11ac562)]
|
||||
interface nsICacheMetaDataVisitor : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called for each key/value pair in the meta data for a cache entry
|
||||
*/
|
||||
boolean visitMetaDataElement(in string key,
|
||||
in string value);
|
||||
};
|
||||
44
mozilla/netwerk/cache/public/nsICacheListener.idl
vendored
Normal file
44
mozilla/netwerk/cache/public/nsICacheListener.idl
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsICacheListener.idl, released January 19, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsICache.idl"
|
||||
|
||||
|
||||
interface nsICacheEntryDescriptor;
|
||||
|
||||
[scriptable, uuid(638c3848-778b-4851-8ff3-9400f65b8773)]
|
||||
interface nsICacheListener : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called when the requested access (or appropriate subset) is
|
||||
* acquired. The status parameter equals NS_OK on success.
|
||||
* See nsICacheService.idl for accessGranted values.
|
||||
*/
|
||||
void onCacheEntryAvailable(in nsICacheEntryDescriptor descriptor,
|
||||
in nsCacheAccessMode accessGranted,
|
||||
in nsresult status);
|
||||
};
|
||||
80
mozilla/netwerk/cache/public/nsICacheService.idl
vendored
Normal file
80
mozilla/netwerk/cache/public/nsICacheService.idl
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsICacheService.idl, released February 10, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsICache.idl"
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsICacheListener;
|
||||
interface nsICacheSession;
|
||||
interface nsICacheVisitor;
|
||||
|
||||
[scriptable, uuid(0ebec4c7-742f-4f27-8e7b-7c8a0cc76348)]
|
||||
interface nsICacheService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Initialize the cache service.
|
||||
*/
|
||||
void init();
|
||||
|
||||
/**
|
||||
* Shutdown the cache service.
|
||||
*/
|
||||
void shutdown();
|
||||
|
||||
/**
|
||||
* Create a cache session
|
||||
*
|
||||
* A cache session represents a client's access into the cache. The cache
|
||||
* session is not "owned" by the cache service. Hence, it is possible to
|
||||
* create duplicate cache sessions. Entries created by a cache session
|
||||
* are invisible to other cache sessions, unless the cache sessions are
|
||||
* equivalent.
|
||||
*
|
||||
* @param clientID - Specifies the name of the client using the cache.
|
||||
* @param storagePolicy - Limits the storage policy for all entries
|
||||
* accessed via the returned session. As a result, devices excluded
|
||||
* by the storage policy will not be searched when opening entries
|
||||
* from the returned session.
|
||||
* @param streamBased - Indicates whether or not the data being cached
|
||||
* can be represented as a stream. The storagePolicy must be
|
||||
* consistent with the value of this field. For example, a non-stream-
|
||||
* based cache entry can only have a storage policy of STORE_IN_MEMORY.
|
||||
* @return new cache session.
|
||||
*/
|
||||
nsICacheSession createSession(in string clientID,
|
||||
in nsCacheStoragePolicy storagePolicy,
|
||||
in boolean streamBased);
|
||||
|
||||
/**
|
||||
* Visit entries stored in the cache. Used to implement about:cache.
|
||||
*/
|
||||
void visitEntries(in nsICacheVisitor visitor);
|
||||
|
||||
/**
|
||||
* Evicts all entries in all devices implied by the storage policy.
|
||||
*/
|
||||
void evictEntries(in nsCacheStoragePolicy storagePolicy);
|
||||
};
|
||||
71
mozilla/netwerk/cache/public/nsICacheSession.idl
vendored
Normal file
71
mozilla/netwerk/cache/public/nsICacheSession.idl
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsICacheSession.idl, released February 23, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsICache.idl"
|
||||
|
||||
interface nsICacheEntryDescriptor;
|
||||
interface nsICacheListener;
|
||||
|
||||
[scriptable, uuid(b4b419ad-28b7-4d25-9988-20fa98505a19)]
|
||||
interface nsICacheSession : nsISupports
|
||||
{
|
||||
/**
|
||||
* Expired entries will be doomed or evicted if this attribute is set to
|
||||
* true. If false, expired entries will be returned (useful for offline-
|
||||
* mode and clients, such as HTTP, that can update the valid lifetime of
|
||||
* cached content). This attribute defaults to true.
|
||||
*/
|
||||
attribute PRBool doomEntriesIfExpired;
|
||||
|
||||
/**
|
||||
* A cache session can only give out one descriptor with WRITE access
|
||||
* to a given cache entry at a time. Until the client calls MarkValid on
|
||||
* its descriptor, other attempts to open the same cache entry will block.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Synchronous cache access. This returns a unique descriptor each
|
||||
* time it is called, even if the same key is specified. When
|
||||
* called by multiple threads for write access, only one writable
|
||||
* descriptor will be granted.
|
||||
*/
|
||||
nsICacheEntryDescriptor openCacheEntry(in string key,
|
||||
in nsCacheAccessMode accessRequested);
|
||||
|
||||
/**
|
||||
* Asynchronous cache access. Does not block the calling thread.
|
||||
* Instead, the listener will be notified when the descriptor is
|
||||
* available.
|
||||
*/
|
||||
void asyncOpenCacheEntry(in string key,
|
||||
in nsCacheAccessMode accessRequested,
|
||||
in nsICacheListener listener);
|
||||
|
||||
/**
|
||||
* Evict all entries for this session's clientID according to its storagePolicy.
|
||||
*/
|
||||
void evictEntries();
|
||||
};
|
||||
137
mozilla/netwerk/cache/public/nsICacheVisitor.idl
vendored
Normal file
137
mozilla/netwerk/cache/public/nsICacheVisitor.idl
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsICacheVisitor.idl, released February 23, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/* XXX we should define device and entry info as well (stats, etc) */
|
||||
|
||||
interface nsICacheDeviceInfo;
|
||||
interface nsICacheEntryInfo;
|
||||
|
||||
|
||||
[scriptable, uuid(f8c08c4b-d778-49d1-a59b-866fdc500d95)]
|
||||
interface nsICacheVisitor : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called to provide information about a cache device.
|
||||
*
|
||||
* @param deviceID - specifies the device being visited.
|
||||
* @param deviceInfo - specifies information about this device.
|
||||
*
|
||||
* @return true to start visiting all entries for this device.
|
||||
* @return false to advance to the next device.
|
||||
*/
|
||||
boolean visitDevice(in string deviceID,
|
||||
in nsICacheDeviceInfo deviceInfo);
|
||||
|
||||
/**
|
||||
* Called to provide information about a cache entry.
|
||||
*
|
||||
* @param deviceID - specifies the device being visited.
|
||||
* @param entryInfo - specifies information about this entry.
|
||||
*
|
||||
* @return true to visit the next entry on the current device, or if the
|
||||
* end of the device has been reached, advance to the next device.
|
||||
* @return false to advance to the next device.
|
||||
*/
|
||||
boolean visitEntry(in string deviceID,
|
||||
in nsICacheEntryInfo entryInfo);
|
||||
};
|
||||
|
||||
|
||||
[scriptable, uuid(31d1c294-1dd2-11b2-be3a-c79230dca297)]
|
||||
interface nsICacheDeviceInfo : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get a human readable description of the cache device.
|
||||
*/
|
||||
readonly attribute string description;
|
||||
|
||||
/**
|
||||
* Get a usage report, statistics, miscellaneous data about
|
||||
* the cache device.
|
||||
*/
|
||||
readonly attribute string usageReport;
|
||||
|
||||
/**
|
||||
* Get the number of stored cache entries.
|
||||
*/
|
||||
readonly attribute unsigned long entryCount;
|
||||
|
||||
/**
|
||||
* Get the total size of the stored cache entries.
|
||||
*/
|
||||
readonly attribute unsigned long totalSize;
|
||||
|
||||
/**
|
||||
* Get the upper limit of the size of the data the cache can store.
|
||||
*/
|
||||
readonly attribute unsigned long maximumSize;
|
||||
};
|
||||
|
||||
|
||||
[scriptable, uuid(72c64022-1dd2-11b2-b3a5-b8b859e0a1b2)]
|
||||
interface nsICacheEntryInfo : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get the client id associated with this cache entry.
|
||||
*/
|
||||
readonly attribute string clientID;
|
||||
|
||||
/**
|
||||
* Get the key identifying the cache entry.
|
||||
*/
|
||||
readonly attribute string key;
|
||||
|
||||
/**
|
||||
* Get the number of times the cache entry has been opened.
|
||||
*/
|
||||
readonly attribute long fetchCount;
|
||||
|
||||
/**
|
||||
* Get the last time the cache entry was opened (in seconds since the Epoch).
|
||||
*/
|
||||
readonly attribute PRUint32 lastFetched;
|
||||
|
||||
/**
|
||||
* Get the last time the cache entry was modified (in seconds since the Epoch).
|
||||
*/
|
||||
readonly attribute PRUint32 lastModified;
|
||||
|
||||
/**
|
||||
* Get the expiration time of the cache entry (in seconds since the Epoch).
|
||||
*/
|
||||
readonly attribute PRUint32 expirationTime;
|
||||
|
||||
/**
|
||||
* Get the cache entry data size.
|
||||
*/
|
||||
readonly attribute unsigned long dataSize;
|
||||
|
||||
/**
|
||||
* Find out whether or not the cache entry is stream based.
|
||||
*/
|
||||
boolean isStreamBased();
|
||||
};
|
||||
240
mozilla/netwerk/cache/public/nsICachedNetData.idl
vendored
Normal file
240
mozilla/netwerk/cache/public/nsICachedNetData.idl
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsrootidl.idl"
|
||||
#include "nsISupports.idl"
|
||||
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIObserver;
|
||||
interface nsIChannel;
|
||||
interface nsINetDataCache;
|
||||
interface nsINetDataCacheRecord;
|
||||
interface nsILoadGroup;
|
||||
interface nsIStreamListener;
|
||||
|
||||
/**
|
||||
* The nsICachedNetData interface represents a single entry in a database that
|
||||
* caches data retrieved from the network. This interface is implemented by the
|
||||
* cache manager on top of the low-level nsINetDataCacheRecord and
|
||||
* nsINetDataCache interfaces that are implemented by the database.
|
||||
*
|
||||
* Each cache record may contain both content and metadata. The content may
|
||||
* be, for example, GIF image data or HTML, and it is accessed through
|
||||
* nsIChannel's streaming API. The opaque metadata, which may contain HTTP
|
||||
* headers among other things, is stored as a byte array. Each entry in the
|
||||
* cache is indexed by two different keys: a record id number and a key created
|
||||
* by combining the URI with a "secondary key", e.g. HTTP post data.
|
||||
*
|
||||
* @See nsINetDataCacheRecord
|
||||
* @See nsINetDataCache
|
||||
* @See nsINetDataDiskCache
|
||||
* @See nsINetDataCacheManager
|
||||
*/
|
||||
[scriptable, uuid(6aeb2a40-6d43-11d3-90c8-000064657374)]
|
||||
interface nsICachedNetData : nsISupports
|
||||
{
|
||||
/**
|
||||
* String form of the URI provided as an argument to the call to
|
||||
* nsINetDataCacheManager::GetCachedNetData() that created this record.
|
||||
*/
|
||||
readonly attribute string uriSpec;
|
||||
|
||||
/**
|
||||
* Getter for the opaque secondary database key provided as an argument to
|
||||
* the call to nsINetDataCacheManager::GetCachedNetData() that created this
|
||||
* record.
|
||||
*/
|
||||
void getSecondaryKey(out unsigned long length,
|
||||
[retval, size_is(length)] out string secondaryKey);
|
||||
|
||||
/**
|
||||
* This flag may be set by a protocol handler to indicate that it supports
|
||||
* partial fetching of data. In that case, the cache manager is permitted
|
||||
* to truncate the entry's content to accommodate incoming data for other
|
||||
* cache entries rather than deleting it wholesale.
|
||||
*/
|
||||
attribute boolean allowPartial;
|
||||
|
||||
/**
|
||||
* This flag indicates that the write stream supplying content data for the
|
||||
* cache did not complete normally and, therefore, the content may be
|
||||
* truncated.
|
||||
*/
|
||||
readonly attribute boolean partialFlag;
|
||||
|
||||
/**
|
||||
* This flag can be set and cleared by a protocol handler as a form of
|
||||
* self-notification, so as to avoid race conditions in which a protocol
|
||||
* handler issues two identical network requests to fill the same cache
|
||||
* entry. The cache manager itself largely ignores this flag.
|
||||
*/
|
||||
attribute boolean updateInProgress;
|
||||
|
||||
/**
|
||||
* inUse is set if any existing channels are associated with this cache
|
||||
* entry or if the updateInProgess flag is set. This can be used to
|
||||
* prevent writing to a cache entry by a protocol handler if it's being
|
||||
* read or written elsewhere.
|
||||
*/
|
||||
readonly attribute boolean inUse;
|
||||
|
||||
/**
|
||||
* Date/time that the document was last stored on the origin server, as
|
||||
* supplied by the protocol handler. This value is used as input to the
|
||||
* cache replacement policy, i.e. it is not used for validation. If the
|
||||
* protocol can't supply a last-modified time, this attribute should remain
|
||||
* unset. When unset, the value of this attribute is zero.
|
||||
*
|
||||
* FIXME: Should use nsIDateTime interface, once it's created
|
||||
* instead of PRTime, for improved scriptability ?
|
||||
*/
|
||||
attribute PRTime lastModifiedTime;
|
||||
|
||||
/**
|
||||
* Supplied by the protocol handler, the expirationTime attribute specifies
|
||||
* the time until which the document is guaranteed fresh, i.e. the document
|
||||
* does not have to be validated with the server and, therefore, any data
|
||||
* in cache is definitely usable. The value of this attribute serves as a
|
||||
* hint to the cache replacement policy. Only one of either staleTime or
|
||||
* expirationTime may be set for a single cache record. When unset, the
|
||||
* value of this attribute is zero.
|
||||
*/
|
||||
attribute PRTime expirationTime;
|
||||
|
||||
/**
|
||||
* Date/time supplied by the protocol handler, at which point the content
|
||||
* is *likely* to be stale, i.e. the data in the cache may be out-of-date
|
||||
* with respect to the data on the server. This heuristic date does not
|
||||
* necessarily correspond to the HTTP Expires header, as it does not
|
||||
* determine when cached network data must be validated with the origin
|
||||
* server, but only serves as a hint to the cache replacement policy. Only
|
||||
* one of either staleTime or expirationTime may be set for a single cache
|
||||
* record. When unset, the value of this attribute is zero.
|
||||
*/
|
||||
attribute PRTime staleTime;
|
||||
|
||||
/**
|
||||
* Date/time of last access of the data in this cache record, as determined
|
||||
* by the cache manager.
|
||||
*/
|
||||
readonly attribute PRTime lastAccessTime;
|
||||
|
||||
readonly attribute PRTime lastUpdateTime;
|
||||
|
||||
/**
|
||||
* Number of times this record has been accessed since it was first stored.
|
||||
*/
|
||||
readonly attribute PRUint16 numberAccesses;
|
||||
|
||||
/**
|
||||
* Accessor methods for opaque meta-data which can be read and updated
|
||||
* independently of the content data.
|
||||
*
|
||||
* The aTag argument can be used to accommodate multiple clients of the
|
||||
* cache API, each of which wants to store its own private meta-data into
|
||||
* the cache. For example, there could be a "headers" tag that the HTTP
|
||||
* protocol handler uses to store http response headers and a "image size"
|
||||
* tag used to store the image dimensions of a GIF file. The aData
|
||||
* argument refers to an opaque blob of arbitrary bytes.
|
||||
*
|
||||
* IMPORTANT: If aData does not contain byte-oriented data, i.e. it's not a
|
||||
* string, the contents of aData must be byte-swapped by the,
|
||||
* caller, so as to make the cache files endian-independent.
|
||||
*/
|
||||
void getAnnotation(in string aTag,
|
||||
out PRUint32 aLength, [size_is(aLength), retval] out string aData);
|
||||
void setAnnotation(in string aTag,
|
||||
in PRUint32 aLength, [size_is(aLength)] in string aData);
|
||||
|
||||
/**
|
||||
* As a getter, return the number of content bytes stored in the cache,
|
||||
* i.e. via the nsIChannel streaming APIs. This may be less than the
|
||||
* complete content length if a partial cache fill occurred. The cached
|
||||
* content can be truncated by setting the value of this attribute. The
|
||||
* value of the attribute represents a logical, not a physical, length. If
|
||||
* compression has been used, the content may consume less storage than
|
||||
* indicated by this attribute.
|
||||
*
|
||||
* When this attribute is set to zero the associated cache disk file, if
|
||||
* any, should be deleted.
|
||||
*/
|
||||
attribute PRUint32 storedContentLength;
|
||||
|
||||
/**
|
||||
* Length of stored content, which may be less than storage consumed if
|
||||
* compression is used
|
||||
*/
|
||||
readonly attribute PRUint32 logicalLength;
|
||||
|
||||
/**
|
||||
* Opaque security info associated with the cache entry; it can't be serialized
|
||||
* to disk, so it'll only make sense with memory cache
|
||||
*/
|
||||
attribute nsISupports securityInfo;
|
||||
|
||||
/**
|
||||
* Notify any observers associated with this cache entry of the deletion
|
||||
* request. If all observers drop their reference to the cache entry,
|
||||
* proceed to delete the underlying cache database record and associated
|
||||
* content storage.
|
||||
*/
|
||||
void delete();
|
||||
|
||||
/**
|
||||
* Flush any changes in this entry's data to the cache database. This
|
||||
* method will automatically be called when the last reference to the cache
|
||||
* is dropped, but it can also be called explicitly for a synchronous
|
||||
* effect.
|
||||
*/
|
||||
void commit();
|
||||
|
||||
/**
|
||||
* Parent container cache for this entry.
|
||||
*/
|
||||
readonly attribute nsINetDataCache cache;
|
||||
|
||||
/**
|
||||
* Create a channel for reading or writing a stream of content into the
|
||||
* entry. It is expected that many of the nsIChannel methods return
|
||||
* NS_NOT_IMPLEMENTED, including:
|
||||
*
|
||||
* + GetURI()
|
||||
* + GetContentType()
|
||||
* + GetContentLength()
|
||||
*
|
||||
* Though nsIChannel provides for both async and synchronous I/O APIs, both
|
||||
* may not be implemented. Only AsyncRead() and OpenOutputStream() is
|
||||
* required.
|
||||
*/
|
||||
nsIChannel newChannel(in nsILoadGroup aLoadGroup);
|
||||
|
||||
/**
|
||||
* This method can be used by a caching protocol handler to store data in
|
||||
* the cache by forking an asynchronous read stream so that it is
|
||||
* simultaneously sent to a requester and written into the cache. This
|
||||
* method implicitly sets the updateInProgress flag, if it has not already
|
||||
* been set.
|
||||
*/
|
||||
nsIStreamListener interceptAsyncRead(in nsIStreamListener aOriginalListener,
|
||||
in PRUint32 aStartOffset);
|
||||
};
|
||||
142
mozilla/netwerk/cache/public/nsINetDataCache.idl
vendored
Normal file
142
mozilla/netwerk/cache/public/nsINetDataCache.idl
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsINetDataCacheRecord;
|
||||
interface nsISimpleEnumerator;
|
||||
|
||||
/**
|
||||
* The nsINetDataCache defines the low-level API for a network-data
|
||||
* cache, used to cache the responses to network retrieval commands.
|
||||
* This interface, along with nsINetDataCacheRecord, is implemented by
|
||||
* the memory cache, the file cache and, optionally, by some extension
|
||||
* caches. This interface is essentially a pseudo-private API for the
|
||||
* cache manager. Other clients should never use this interface.
|
||||
*
|
||||
* Each cache entry may contain both content, e.g. GIF image data, and
|
||||
* associated metadata, e.g. HTTP headers. Each entry is indexed by two
|
||||
* different keys: a record id number and a key created by combining the URI
|
||||
* with a "secondary key", e.g. HTTP post data.
|
||||
*
|
||||
* The nsINetDataCache interface is agnostic as to where the data is
|
||||
* stored and whether the storage is volatile or persistent. The
|
||||
* memory cache, any disk caches and any extension caches must all
|
||||
* implement this interface.
|
||||
*
|
||||
*/
|
||||
[scriptable, uuid(ccfc58c0-6dde-11d3-90c8-000064657374)]
|
||||
interface nsINetDataCache : nsISupports
|
||||
{
|
||||
/**
|
||||
* Human-readable description of the cache module, e.g. "Disk Cache"
|
||||
*/
|
||||
readonly attribute wstring description;
|
||||
|
||||
/**
|
||||
* Returns true if cached data is available for the given opaque key,
|
||||
* even if only partial data is stored.
|
||||
*/
|
||||
boolean contains([size_is(length)] in string key, in PRUint32 length);
|
||||
|
||||
/**
|
||||
* Fetch the cache entry record for the given opaque key. If one does not
|
||||
* exist, create a new, empty record.
|
||||
*/
|
||||
nsINetDataCacheRecord getCachedNetData([size_is(length)] in string key,
|
||||
in PRUint32 length);
|
||||
|
||||
/**
|
||||
* Fetch the cache entry record for the given URI using the record ID as a key.
|
||||
*/
|
||||
nsINetDataCacheRecord getCachedNetDataByID(in PRInt32 RecordID);
|
||||
|
||||
/**
|
||||
* False indicates that this cache is entirely bypassed.
|
||||
*/
|
||||
attribute boolean enabled;
|
||||
|
||||
/**
|
||||
* Constants for flags attribute, below
|
||||
*/
|
||||
|
||||
// Used for extension caches, e.g. a CD-ROM cache
|
||||
const long READ_ONLY = 1 << 0;
|
||||
|
||||
// One of these bits must be set
|
||||
const long MEMORY_CACHE = 1 << 1;
|
||||
const long FLAT_FILE_CACHE = 1 << 2;
|
||||
const long FILE_PER_URL_CACHE = 1 << 3;
|
||||
|
||||
/**
|
||||
* See constants defined above.
|
||||
*/
|
||||
readonly attribute PRUint32 flags;
|
||||
|
||||
/**
|
||||
* Total number of URI entries stored in the cache.
|
||||
*/
|
||||
readonly attribute PRUint32 numEntries;
|
||||
|
||||
/**
|
||||
* Maximum number of URI entries that may be stored in the cache.
|
||||
*/
|
||||
readonly attribute PRUint32 maxEntries;
|
||||
|
||||
/**
|
||||
* Enumerate the URI entries stored in the cache.
|
||||
*/
|
||||
nsISimpleEnumerator newCacheEntryIterator();
|
||||
|
||||
/**
|
||||
* Contains a reference to the next cache in search order. For the memory
|
||||
* cache, this attribute always references the disk cache. For the disk
|
||||
* cache, it contains a reference to the first extension cache.
|
||||
*/
|
||||
attribute nsINetDataCache nextCache;
|
||||
|
||||
/**
|
||||
* An estimate of the amount of storage occupied by the cache, in kB.
|
||||
* Actual use may be slightly higher than reported due to cache overhead
|
||||
* and heap fragmentation (in the memory cache) or block quantization (in
|
||||
* the disk cache).
|
||||
*/
|
||||
readonly attribute PRUint32 storageInUse;
|
||||
|
||||
/**
|
||||
* Remove all entries from a writable cache. This could be used, for
|
||||
* example, after a guest ends a browser session. This is equivalent to
|
||||
* setting the cache's Capacity to zero, except that all cache entries,
|
||||
* even those in active use, will be deleted. Also, any global cache
|
||||
* database files will be deleted.
|
||||
*/
|
||||
void removeAll();
|
||||
};
|
||||
|
||||
%{ C++
|
||||
// ContractID prefix for Components that implement this interface
|
||||
#define NS_NETWORK_CACHE_CONTRACTID "@mozilla.org/network/cache;1"
|
||||
#define NS_NETWORK_MEMORY_CACHE_CONTRACTID NS_NETWORK_CACHE_CONTRACTID "?name=memory-cache"
|
||||
#define NS_NETWORK_FLAT_CACHE_CONTRACTID NS_NETWORK_CACHE_CONTRACTID "?name=flat-cache"
|
||||
#define NS_NETWORK_FILE_CACHE_CONTRACTID NS_NETWORK_CACHE_CONTRACTID "?name=file-cache"
|
||||
%}
|
||||
169
mozilla/netwerk/cache/public/nsINetDataCacheManager.idl
vendored
Normal file
169
mozilla/netwerk/cache/public/nsINetDataCacheManager.idl
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsINetDataCache.idl"
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsICachedNetData;
|
||||
interface nsINetDataDiskCache;
|
||||
interface nsIURI;
|
||||
|
||||
/**
|
||||
* The network-response cache manager is partly responsible for the caching of
|
||||
* content and associated metadata that has been retrieved via the network.
|
||||
* (The remaining responsibility for caching lies with individual network
|
||||
* protocol handlers.)
|
||||
*
|
||||
* The cache manager supervises the actions of individual cache components,
|
||||
* such as the memory cache, the disk cache and any extension caches, e.g. a
|
||||
* read-only CD-ROM cache.
|
||||
*
|
||||
* @See nsINetDataCache
|
||||
* @See nsICachedNetData
|
||||
*/
|
||||
[scriptable, uuid(71c8ab00-6d5c-11d3-90c8-000064657374)]
|
||||
interface nsINetDataCacheManager : nsISupports
|
||||
{
|
||||
/**
|
||||
* Flag for the GetCachedNetData() method: If set, the memory cache is
|
||||
* neither searched nor will any data be stored into it. This might be
|
||||
* appropriate, for example, with images, because they have their own
|
||||
* cache for storing *decoded* images.
|
||||
*/
|
||||
const unsigned long BYPASS_MEMORY_CACHE = 1 << 0;
|
||||
|
||||
/**
|
||||
* Flag for the GetCachedNetData() method: If set, the disk cache
|
||||
* is neither searched nor will any be data stored into it.
|
||||
* However, read-only extension caches may be searched. This
|
||||
* might be used to avoid leaving persistent records of secure
|
||||
* data.
|
||||
*/
|
||||
const unsigned long BYPASS_PERSISTENT_CACHE = 1 << 1;
|
||||
|
||||
/**
|
||||
* Flag for the GetCachedNetData() method: If set, any stream
|
||||
* content is stored in the cache as a single disk file. Content
|
||||
* will not be cached in the memory cache nor is it cached in a
|
||||
* flat-file cache database. This is used to implement the jar
|
||||
* protocol handler and to provide the stream-as-file semantics
|
||||
* required by the classic bowser plugin API.
|
||||
*/
|
||||
const unsigned long CACHE_AS_FILE = 1 << 2;
|
||||
|
||||
/**
|
||||
These enum's are used for the ClearCache calls.
|
||||
*/
|
||||
const unsigned long ALL_CACHES = 1;
|
||||
const unsigned long MEM_CACHE = 1<<1;
|
||||
const unsigned long FILE_CACHE = 1<<2;
|
||||
const unsigned long FLAT_CACHE = 1<<3;
|
||||
/**
|
||||
* Fetch the cache entry record for the given URI. If one does not exist,
|
||||
* create a new, empty record. The normal search order for caches is:
|
||||
* + Memory cache
|
||||
* + Disk cache
|
||||
* + File cache (stream-as-file cache)
|
||||
* + All extension caches
|
||||
*
|
||||
* When writing, data is typically stored in both the memory cache and the
|
||||
* disk cache. Both the search order and this write policy can be modified by
|
||||
* setting one or more of the flag argument bits, as defined above.
|
||||
*
|
||||
* The optionally-NULL secondaryKey argument can be used, e.g. for form
|
||||
* post data or for HTTP headers in the case of HTTP.
|
||||
*/
|
||||
nsICachedNetData getCachedNetData(in string uri,
|
||||
[size_is(secondaryKeyLength)] in string secondaryKey,
|
||||
in PRUint32 secondaryKeyLength,
|
||||
in PRUint32 flags);
|
||||
|
||||
/**
|
||||
* Returns true if cached content is available for the given URI, even if
|
||||
* only partial data is stored. The flags argument behaves the same as for
|
||||
* the GetCachedNetData() method, above.
|
||||
*/
|
||||
boolean contains(in string uri,
|
||||
[size_is(secondaryKeyLength)] in string secondaryKey,
|
||||
in PRUint32 secondaryKeyLength,
|
||||
in PRUint32 flags);
|
||||
|
||||
/**
|
||||
* Total number of unexpired URI entries stored in all caches. This number
|
||||
* does not take into account duplicate URIs, e.g. because the memory cache
|
||||
* and the disk cache might each contain an entry for the same URI.
|
||||
*/
|
||||
readonly attribute PRUint32 numEntries;
|
||||
|
||||
/**
|
||||
* Enumerate the unexpired URI entries stored in all caches. Some URIs may
|
||||
* be enumerated more than once, e.g. because the the memory cache and the
|
||||
* disk cache might each contain an entry for the same URI.
|
||||
*/
|
||||
nsISimpleEnumerator newCacheEntryIterator();
|
||||
|
||||
/*
|
||||
* Enumerate all the loaded nsINetDataCache-implementing cache modules.
|
||||
* The first module enumerated will be the memory cache, the second will be
|
||||
* the disk cache, then the file cache, followed by all the extension
|
||||
* caches, in search order.
|
||||
*/
|
||||
nsISimpleEnumerator newCacheModuleIterator();
|
||||
|
||||
/**
|
||||
* Remove all entries from all writable caches. This could be used, for
|
||||
* example, after a guest ends a browser session. This is equivalent to
|
||||
* setting the DiskCacheCapacity to zero, except that all cache entries,
|
||||
* even those in active use, will be deleted. Also, any global cache
|
||||
* database files will be deleted.
|
||||
*/
|
||||
void removeAll();
|
||||
|
||||
/**
|
||||
* Clears the specified cache
|
||||
*/
|
||||
void clear( in PRUint32 aCacheToClear );
|
||||
|
||||
/**
|
||||
* The disk cache is made up of the file cache (for stream-as-file
|
||||
* requests) and a (possibly independent) persistent cache that handles all
|
||||
* other cache requests. This attribute sets/gets the combined capacity of
|
||||
* these caches, measured in KBytes. Setting the capacity lower than the
|
||||
* current amount of space currently in use may cause cache entries to be
|
||||
* evicted from the cache to accomodate the requested capacity.
|
||||
*/
|
||||
attribute PRUint32 diskCacheCapacity;
|
||||
|
||||
/**
|
||||
* This attribute sets/gets the capacity of the memory cache, measured in
|
||||
* KBytes. Setting the capacity lower than the current amount of space
|
||||
* currently in use may cause cache entries to be evicted from the cache to
|
||||
* accomodate the requested capacity.
|
||||
*/
|
||||
attribute PRUint32 memCacheCapacity;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
// ContractID prefix for Components that implement this interface
|
||||
#define NS_NETWORK_CACHE_MANAGER_CONTRACTID NS_NETWORK_CACHE_CONTRACTID "?name=manager"
|
||||
%}
|
||||
131
mozilla/netwerk/cache/public/nsINetDataCacheRecord.idl
vendored
Normal file
131
mozilla/netwerk/cache/public/nsINetDataCacheRecord.idl
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsrootidl.idl"
|
||||
|
||||
interface nsIFile;
|
||||
interface nsIChannel;
|
||||
interface nsINetDataCache;
|
||||
|
||||
/**
|
||||
* The nsINetDataCacheRecord represents a single entry in a database that
|
||||
* caches data retrieved from the network. On top of this low-level interface
|
||||
* to the raw record data, the cache manager implements a higher-level record
|
||||
* interface, nsICachedNetData. Each instance of nsINetDataCacheRecord is
|
||||
* (internally) associated with a parent database, an instance of the
|
||||
* nsINetDataCache interface. This interface is essentially a pseudo-private
|
||||
* API for the cache manager. Other clients should never use this interface.
|
||||
*
|
||||
* Each cache record may contain both content and metadata. The content may
|
||||
* be, for example, GIF image data or HTML, and it is accessed through
|
||||
* nsIChannel's streaming API. The opaque metadata, which may contain HTTP
|
||||
* headers among other things, is accessed as a contiguous byte array. Each
|
||||
* entry in the cache is indexed by two different keys: a unique record id
|
||||
* number, generated by the cache, and an opaque string. The latter contains
|
||||
* the URI and other secondary key information, e.g. HTTP form post key/value
|
||||
* pairs.
|
||||
*
|
||||
* The nsINetDataCacheRecord interface is agnostic as to where the data is
|
||||
* stored and whether the storage is volatile or persistent. The memory cache,
|
||||
* the disk cache, a flat-file cache and any read-only extension caches must
|
||||
* all implement this interface.
|
||||
*
|
||||
* @See nsICachedNetData
|
||||
* @See nsINetDataCache
|
||||
* @See nsINetDataDiskCache
|
||||
* @See nsINetDataCacheManager
|
||||
*/
|
||||
|
||||
interface nsILoadGroup;
|
||||
|
||||
[scriptable, uuid(fdcdd6a0-7461-11d3-90ca-0040056a906e)]
|
||||
interface nsINetDataCacheRecord : nsISupports
|
||||
{
|
||||
/**
|
||||
* As far as the nsINetDataCacheRecord implementation is concerned, the
|
||||
* cache entry database key is an opaque blob, but it's intended to contain
|
||||
* both the URI and any secondary keys, such as HTTP post data.
|
||||
*/
|
||||
void getKey(out unsigned long length, [size_is(length), retval] out string key);
|
||||
|
||||
/**
|
||||
* A persistent record number assigned by the cache which must be unique
|
||||
* among all entries stored within the same cache. The record ID serves as
|
||||
* an alternate key to the cache record. Providing that they satisfy the
|
||||
* afforementioned uniqueness requirement, record IDs can be assigned any
|
||||
* value by the database except that they may never be zero.
|
||||
*/
|
||||
readonly attribute PRInt32 recordID;
|
||||
|
||||
/**
|
||||
* Opaque data which can be updated for each cache entry independently of
|
||||
* the content data. This data is a combination of protocol-independent
|
||||
* data provided by the cache manager and protocol-specific meta-data,
|
||||
* e.g. HTTP headers.
|
||||
*/
|
||||
void getMetaData(out PRUint32 length, [size_is(length), retval] out string metaData);
|
||||
void setMetaData(in PRUint32 length, [size_is(length)] in string data);
|
||||
|
||||
/**
|
||||
* Number of content bytes stored in the cache, i.e. via the nsIChannel
|
||||
* streaming APIs. This may be less than the complete content length if a
|
||||
* partial cache fill occurred. Additionally, the cached content can be
|
||||
* truncated by reducing the value of this attribute. When this attribute
|
||||
* is set to zero the associated cache disk file, if any, should be
|
||||
* deleted.
|
||||
*/
|
||||
attribute PRUint32 storedContentLength;
|
||||
|
||||
/**
|
||||
* Opaque security info associated with the cache entry; it can't be serialized
|
||||
* to disk, so it'll only make sense with memory cache
|
||||
*/
|
||||
attribute nsISupports securityInfo;
|
||||
|
||||
/**
|
||||
* Delete this cache entry and its associated content.
|
||||
*/
|
||||
void delete();
|
||||
|
||||
/**
|
||||
* Create a channel for reading or writing a stream of content into the
|
||||
* entry. However, many of the nsIChannel methods may return
|
||||
* NS_NOT_IMPLEMENTED, including:
|
||||
*
|
||||
* + GetURI()
|
||||
* + GetContentType()
|
||||
* + GetContentLength()
|
||||
*/
|
||||
nsIChannel newChannel(in nsILoadGroup loadGroup);
|
||||
|
||||
/**
|
||||
* If a cache is implemented such that it stores each URI's content in an
|
||||
* individual disk file, this method will identify the file corresponding
|
||||
* to this record. This may be used to implement the "stream-as-file"
|
||||
* semantics required by some plugins and by the 'jar:' protocol handler.
|
||||
* However, not all cache implementations are *required* to store the data
|
||||
* from each URI in an individual file, so it is acceptable for an
|
||||
* implementation of this method to signal NS_NOT_IMPLEMENTED.
|
||||
*/
|
||||
readonly attribute nsIFile file;
|
||||
};
|
||||
41
mozilla/netwerk/cache/public/nsINetDataDiskCache.idl
vendored
Normal file
41
mozilla/netwerk/cache/public/nsINetDataDiskCache.idl
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsINetDataCache.idl"
|
||||
|
||||
interface nsIFile;
|
||||
|
||||
/**
|
||||
* A network-data disk cache is used to persistently cache the responses to
|
||||
* network retrieval commands. Each cache entry may contain both content,
|
||||
* e.g. GIF image data, and associated metadata, e.g. HTTP headers.
|
||||
*/
|
||||
[scriptable, uuid(6408e390-6f13-11d3-90c8-000064657374)]
|
||||
interface nsINetDataDiskCache : nsINetDataCache
|
||||
{
|
||||
/**
|
||||
* This attribute must be set before calling any other methods of this
|
||||
* interface.
|
||||
*/
|
||||
attribute nsIFile diskCacheFolder;
|
||||
};
|
||||
|
||||
106
mozilla/netwerk/cache/public/nsIStreamAsFile.idl
vendored
Normal file
106
mozilla/netwerk/cache/public/nsIStreamAsFile.idl
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Scott Furman, fur@netscape.com
|
||||
*/
|
||||
#include "nsrootidl.idl"
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIFile;
|
||||
interface nsIStreamAsFileObserver;
|
||||
|
||||
/**
|
||||
* In addition to enhancing effective network response time via caching, the
|
||||
* cache manager serves a second purpose by providing the stream-as-file
|
||||
* service required by traditional browser plugins and the jar: protocol
|
||||
* handler. The interface below provides a means for a client to determine the
|
||||
* filename associated with a stream and to detect modification/deletion of
|
||||
* that file.
|
||||
*/
|
||||
[scriptable, uuid(0eedbbf0-92d9-11d3-90d3-0040056a906e)]
|
||||
interface nsIStreamAsFile : nsISupports
|
||||
{
|
||||
/**
|
||||
* Filename containing stream-as-file
|
||||
*/
|
||||
readonly attribute nsIFile file;
|
||||
|
||||
/**
|
||||
* Add an observer for this cache record. When the cache wants to delete
|
||||
* or truncate a record, so as to make space for another cache entry's
|
||||
* content data, it will call <code>aObserver</code>'s Observe() method,
|
||||
* passing the nsIStreamAsFile instance as the <code>aSubject</code>
|
||||
* argument and an appropriate message. If the observer does not wish to
|
||||
* inhibit deletion/truncation, it should Release() any references it has to the
|
||||
* cache record.
|
||||
*
|
||||
* @See nsIStreamAsFileObserver
|
||||
*/
|
||||
void addObserver(in nsIStreamAsFileObserver aObserver);
|
||||
|
||||
/**
|
||||
* Delete an observer that was added by the AddObserver() method.
|
||||
*/
|
||||
void removeObserver(in nsIStreamAsFileObserver aObserver);
|
||||
};
|
||||
|
||||
/**
|
||||
* This interface can be implemented by a client to receive notifications of
|
||||
* either modification or deletion of a file created by the cache manager using
|
||||
* the stream-as-file semantics.
|
||||
*/
|
||||
[scriptable, uuid(a26e27c0-92da-11d3-90d3-0040056a906e)]
|
||||
interface nsIStreamAsFileObserver : nsISupports
|
||||
{
|
||||
/**
|
||||
* Flag bits for argument to observeStreamAsFile() method.
|
||||
*/
|
||||
const long NOTIFY_AVAILABLE = 1 << 0; // Stream-as-file now available for reading
|
||||
const long NOTIFY_ERROR = 1 << 1; // Error while loading stream / creating file
|
||||
const long REQUEST_DELETION = 1 << 2; // Cache manager wishes to delete/truncate file
|
||||
const long INVALIDATE = 1 << 3; // File is out-of-date
|
||||
|
||||
// Convenience value
|
||||
const long MAKE_UNAVAILABLE = REQUEST_DELETION | INVALIDATE;
|
||||
|
||||
/**
|
||||
* Receive either a notification or a request concerning a file that has
|
||||
* been opened using stream-as-file. The aMessage and aError arguments
|
||||
* have varying values depending on the nature of the notification.
|
||||
* aMessage is set to NOTIFY_AVAILABLE when a complete stream has been read
|
||||
* and stored on disk in a file. At that point, and no sooner, may the
|
||||
* filename attribute of the associated nsIStreamAsFile be accessed via the
|
||||
* associated nsIStreamAsFile interface. If the aMessage argument is
|
||||
* NOTIFY_ERROR, the aError argument contains the relevant error code. If
|
||||
* the aMessage argument is either REQUEST_DELETION or REQUEST_TRUNCATION,
|
||||
* the callee should immediately Release() all references to the
|
||||
* nsIStreamAsFile (and any references to its associated nsICachedNetData
|
||||
* instances), unless it wishes to inhibit the requested file modification.
|
||||
* If the aMessage argument is INVALIDATE, the cache manager is replacing
|
||||
* the file with a more recent version. If a client wants to continue
|
||||
* using the (now out-of-date) file, it must delete it when it has finished,
|
||||
* as the cache manager will effectively relinquished ownership of the
|
||||
* file.
|
||||
*/
|
||||
void observeStreamAsFile(in nsIStreamAsFile aStreamAsFile,
|
||||
in PRUint32 aMessage,
|
||||
in nsresult aError);
|
||||
};
|
||||
70
mozilla/netwerk/cache/src/Makefile.in
vendored
Normal file
70
mozilla/netwerk/cache/src/Makefile.in
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = nkcache
|
||||
LIBRARY_NAME = nkcache
|
||||
SHORT_LIBNAME = nkcache
|
||||
IS_COMPONENT = 1
|
||||
REQUIRES = xpcom string necko pref
|
||||
|
||||
EXPORTS = \
|
||||
nsCacheService.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsANSIFileStreams.cpp \
|
||||
nsCache.cpp \
|
||||
nsCacheEntry.cpp \
|
||||
nsCacheEntryDescriptor.cpp \
|
||||
nsCacheMetaData.cpp \
|
||||
nsCacheModule.cpp \
|
||||
nsCacheService.cpp \
|
||||
nsCacheSession.cpp \
|
||||
nsDiskCacheDevice.cpp \
|
||||
nsDiskCacheEntry.cpp \
|
||||
nsDiskCacheMap.cpp \
|
||||
nsMemoryCacheDevice.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
EXTRA_LIBS += \
|
||||
$(XPCOM_LIBS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
#EXTRA_LIBS = $(NSPR_LIBS)
|
||||
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
#override NO_SHARED_LIB=1
|
||||
#override NO_STATIC_LIB=
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
68
mozilla/netwerk/cache/src/makefile.win
vendored
Executable file
68
mozilla/netwerk/cache/src/makefile.win
vendored
Executable file
@@ -0,0 +1,68 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
MODULE = nkcache
|
||||
DLLNAME=nkcache
|
||||
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
|
||||
LCFLAGS = -DWIN32_LEAN_AND_MEAN -D_IMPL_NS_NET
|
||||
|
||||
EXPORTS = \
|
||||
nsCacheService.h \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsCache.obj \
|
||||
.\$(OBJDIR)\nsCacheEntry.obj \
|
||||
.\$(OBJDIR)\nsCacheEntryDescriptor.obj \
|
||||
.\$(OBJDIR)\nsCacheMetaData.obj \
|
||||
.\$(OBJDIR)\nsCacheModule.obj \
|
||||
.\$(OBJDIR)\nsCacheService.obj \
|
||||
.\$(OBJDIR)\nsCacheSession.obj \
|
||||
.\$(OBJDIR)\nsDiskCacheDevice.obj \
|
||||
.\$(OBJDIR)\nsDiskCacheEntry.obj \
|
||||
.\$(OBJDIR)\nsDiskCacheMap.obj \
|
||||
.\$(OBJDIR)\nsANSIFileStreams.obj \
|
||||
.\$(OBJDIR)\nsMemoryCacheDevice.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LLIBS = \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
|
||||
|
||||
clobber::
|
||||
$(RM) $(DIST)\bin\components\$(DLLNAME).dll
|
||||
$(RM) $(DIST)\lib\$(DLLNAME).lib
|
||||
388
mozilla/netwerk/cache/src/nsANSIFileStreams.cpp
vendored
Normal file
388
mozilla/netwerk/cache/src/nsANSIFileStreams.cpp
vendored
Normal file
@@ -0,0 +1,388 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsANSIFileStreams.cpp, released March 23, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsANSIFileStreams.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsANSIInputStream, nsIInputStream, nsISeekableStream);
|
||||
|
||||
nsANSIInputStream::nsANSIInputStream() : mFile(nsnull), mSize(0)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsANSIInputStream::~nsANSIInputStream()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
nsresult nsANSIInputStream::Open(nsILocalFile* file)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = file->OpenANSIFileDesc("rb", &mFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (::fseek(mFile, 0, SEEK_END) != 0) return NS_ERROR_FAILURE;
|
||||
mSize = ::ftell(mFile);
|
||||
::fseek(mFile, 0, SEEK_SET);
|
||||
rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIInputStream::Close()
|
||||
{
|
||||
if (mFile) {
|
||||
::fclose(mFile);
|
||||
mFile = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIInputStream::Available(PRUint32 * result)
|
||||
{
|
||||
if (mFile) {
|
||||
*result = (mSize - ::ftell(mFile));
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIInputStream::Read(char * buf, PRUint32 count, PRUint32 *result)
|
||||
{
|
||||
if (mFile) {
|
||||
*result = ::fread(buf, 1, count, mFile);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIInputStream::ReadSegments(nsWriteSegmentFun writer, void * closure, PRUint32 count, PRUint32 *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIInputStream::GetNonBlocking(PRBool *aNonBlocking)
|
||||
{
|
||||
*aNonBlocking = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIInputStream::GetObserver(nsIInputStreamObserver * *aObserver)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIInputStream::SetObserver(nsIInputStreamObserver * aObserver)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIInputStream::Seek(PRInt32 whence, PRInt32 offset)
|
||||
{
|
||||
if (mFile) {
|
||||
::fseek(mFile, offset, whence);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIInputStream::Tell(PRUint32 * result)
|
||||
{
|
||||
if (mFile) {
|
||||
*result = ::ftell(mFile);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsANSIOutputStream, nsIOutputStream, nsISeekableStream);
|
||||
|
||||
nsANSIOutputStream::nsANSIOutputStream() : mFile(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsANSIOutputStream::~nsANSIOutputStream()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
nsresult nsANSIOutputStream::Open(nsILocalFile* file)
|
||||
{
|
||||
nsresult rv = file->OpenANSIFileDesc("wb", &mFile);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIOutputStream::Close()
|
||||
{
|
||||
if (mFile) {
|
||||
::fclose(mFile);
|
||||
mFile = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIOutputStream::Flush()
|
||||
{
|
||||
if (mFile) {
|
||||
::fflush(mFile);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIOutputStream::Write(const char *buffer, PRUint32 count, PRUint32 *result)
|
||||
{
|
||||
if (mFile) {
|
||||
*result = ::fwrite(buffer, 1, count, mFile);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIOutputStream::WriteFrom(nsIInputStream *input, PRUint32 count, PRUint32 *actualCount)
|
||||
{
|
||||
nsresult rv;
|
||||
char buffer[BUFSIZ];
|
||||
PRUint32 totalCount = count;
|
||||
*actualCount = 0;
|
||||
while (totalCount > 0) {
|
||||
count = (totalCount < BUFSIZ ? totalCount : BUFSIZ);
|
||||
rv = input->Read(buffer, count, &count);
|
||||
if (NS_FAILED(rv)) break;
|
||||
rv = Write(buffer, count, &count);
|
||||
if (NS_FAILED(rv)) break;
|
||||
totalCount -= count;
|
||||
*actualCount += count;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIOutputStream::WriteSegments(nsReadSegmentFun reader, void * closure, PRUint32 count, PRUint32 *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIOutputStream::GetNonBlocking(PRBool *aNonBlocking)
|
||||
{
|
||||
*aNonBlocking = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsANSIOutputStream::SetNonBlocking(PRBool aNonBlocking)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIOutputStream::GetObserver(nsIOutputStreamObserver * *aObserver)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHODIMP nsANSIOutputStream::SetObserver(nsIOutputStreamObserver * aObserver)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIOutputStream::Seek(PRInt32 whence, PRInt32 offset)
|
||||
{
|
||||
if (mFile) {
|
||||
::fseek(mFile, offset, whence);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIOutputStream::Tell(PRUint32 * result)
|
||||
{
|
||||
if (mFile) {
|
||||
*result = ::ftell(mFile);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
///////
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsANSIFileStream, nsIInputStream, nsIOutputStream, nsISeekableStream);
|
||||
|
||||
nsANSIFileStream::nsANSIFileStream() : mFile(nsnull), mSize(0)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsANSIFileStream::~nsANSIFileStream()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
nsresult nsANSIFileStream::Open(nsILocalFile* file)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = file->OpenANSIFileDesc("rb+", &mFile);
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = rv = file->OpenANSIFileDesc("wb+", &mFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// compute size of file.
|
||||
if (::fseek(mFile, 0, SEEK_END) != 0) return NS_ERROR_FAILURE;
|
||||
mSize = ::ftell(mFile);
|
||||
::fseek(mFile, 0, SEEK_SET);
|
||||
rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::Close()
|
||||
{
|
||||
if (mFile) {
|
||||
::fclose(mFile);
|
||||
mFile = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::Available(PRUint32 * result)
|
||||
{
|
||||
if (mFile) {
|
||||
*result = (mSize - ::ftell(mFile));
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::Read(char * buf, PRUint32 count, PRUint32 *result)
|
||||
{
|
||||
if (mFile) {
|
||||
*result = ::fread(buf, 1, count, mFile);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::ReadSegments(nsWriteSegmentFun writer, void * closure, PRUint32 count, PRUint32 *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::GetNonBlocking(PRBool *aNonBlocking)
|
||||
{
|
||||
*aNonBlocking = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::GetObserver(nsIInputStreamObserver * *aObserver)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::SetObserver(nsIInputStreamObserver * aObserver)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::Flush()
|
||||
{
|
||||
if (mFile) {
|
||||
::fflush(mFile);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::Write(const char *buffer, PRUint32 count, PRUint32 *result)
|
||||
{
|
||||
if (mFile) {
|
||||
*result = ::fwrite(buffer, 1, count, mFile);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::WriteFrom(nsIInputStream *input, PRUint32 count, PRUint32 *actualCount)
|
||||
{
|
||||
char buffer[BUFSIZ];
|
||||
PRUint32 totalCount = count;
|
||||
*actualCount = 0;
|
||||
while (totalCount > 0) {
|
||||
count = (totalCount < BUFSIZ ? totalCount : BUFSIZ);
|
||||
nsresult rv = input->Read(buffer, count, &count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = Write(buffer, count, &count);
|
||||
totalCount -= count;
|
||||
*actualCount += count;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::WriteSegments(nsReadSegmentFun reader, void * closure, PRUint32 count, PRUint32 *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::SetNonBlocking(PRBool aNonBlocking)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::GetObserver(nsIOutputStreamObserver * *aObserver)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::SetObserver(nsIOutputStreamObserver * aObserver)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::Seek(PRInt32 whence, PRInt32 offset)
|
||||
{
|
||||
if (mFile) {
|
||||
::fseek(mFile, offset, whence);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsANSIFileStream::Tell(PRUint32 * result)
|
||||
{
|
||||
if (mFile) {
|
||||
*result = ::ftell(mFile);
|
||||
nsresult rv = (ferror(mFile) ? NS_ERROR_FAILURE : NS_OK);
|
||||
return rv;
|
||||
}
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
80
mozilla/netwerk/cache/src/nsANSIFileStreams.h
vendored
Normal file
80
mozilla/netwerk/cache/src/nsANSIFileStreams.h
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsANSIFileStreams.h, released March 23, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _nsANSIFileStreams_h_
|
||||
#define _nsANSIFileStreams_h_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "nsIFileStreams.h"
|
||||
|
||||
class nsANSIInputStream : public nsIInputStream, public nsISeekableStream {
|
||||
FILE* mFile;
|
||||
PRUint32 mSize;
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
NS_DECL_NSISEEKABLESTREAM
|
||||
|
||||
nsANSIInputStream();
|
||||
virtual ~nsANSIInputStream();
|
||||
nsresult Open(nsILocalFile* file);
|
||||
};
|
||||
|
||||
class nsANSIOutputStream : public nsIOutputStream, public nsISeekableStream {
|
||||
FILE* mFile;
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOUTPUTSTREAM
|
||||
NS_DECL_NSISEEKABLESTREAM
|
||||
|
||||
nsANSIOutputStream();
|
||||
virtual ~nsANSIOutputStream();
|
||||
nsresult Open(nsILocalFile* file);
|
||||
};
|
||||
|
||||
class nsANSIFileStream : public nsIInputStream, public nsIOutputStream, public nsISeekableStream {
|
||||
FILE* mFile;
|
||||
PRUint32 mSize;
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
|
||||
// NS_DECL_NSIOUTPUTSTREAM
|
||||
// XXX must only declare additional methods introduced by nsIOutputStream.
|
||||
NS_IMETHOD Flush(void);
|
||||
NS_IMETHOD Write(const char *buf, PRUint32 count, PRUint32 *_retval);
|
||||
NS_IMETHOD WriteFrom(nsIInputStream *inStr, PRUint32 count, PRUint32 *_retval);
|
||||
NS_IMETHOD WriteSegments(nsReadSegmentFun reader, void * closure, PRUint32 count, PRUint32 *_retval);
|
||||
NS_IMETHOD SetNonBlocking(PRBool aNonBlocking);
|
||||
NS_IMETHOD GetObserver(nsIOutputStreamObserver * *aObserver);
|
||||
NS_IMETHOD SetObserver(nsIOutputStreamObserver * aObserver);
|
||||
|
||||
NS_DECL_NSISEEKABLESTREAM
|
||||
|
||||
nsANSIFileStream();
|
||||
virtual ~nsANSIFileStream();
|
||||
nsresult Open(nsILocalFile* file);
|
||||
};
|
||||
|
||||
#endif // _nsANSIFileStreams_h_
|
||||
119
mozilla/netwerk/cache/src/nsCache.cpp
vendored
Normal file
119
mozilla/netwerk/cache/src/nsCache.cpp
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCache.cpp, released March 18, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsCache.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
|
||||
/**
|
||||
* Cache Service Utility Functions
|
||||
*/
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
PRLogModuleInfo * gCacheLog = nsnull;
|
||||
|
||||
void
|
||||
CacheLogInit()
|
||||
{
|
||||
if (gCacheLog) return;
|
||||
gCacheLog = PR_NewLogModule("cache");
|
||||
NS_ASSERTION(gCacheLog, "\n### failed to allocate cache log.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
PRUint32
|
||||
SecondsFromPRTime(PRTime prTime)
|
||||
{
|
||||
PRInt64 microSecondsPerSecond, intermediateResult;
|
||||
PRUint32 seconds;
|
||||
|
||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||
LL_DIV(intermediateResult, prTime, microSecondsPerSecond);
|
||||
LL_L2UI(seconds, intermediateResult);
|
||||
return seconds;
|
||||
}
|
||||
|
||||
|
||||
PRTime
|
||||
PRTimeFromSeconds(PRUint32 seconds)
|
||||
{
|
||||
PRInt64 microSecondsPerSecond, intermediateResult;
|
||||
PRTime prTime;
|
||||
|
||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||
LL_UI2L(intermediateResult, seconds);
|
||||
LL_MUL(prTime, intermediateResult, microSecondsPerSecond);
|
||||
return prTime;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
ClientIDFromCacheKey(const nsAReadableCString& key, char ** result)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
*result = nsnull;
|
||||
|
||||
nsReadingIterator<char> colon;
|
||||
key.BeginReading(colon);
|
||||
|
||||
nsReadingIterator<char> start;
|
||||
key.BeginReading(start);
|
||||
|
||||
nsReadingIterator<char> end;
|
||||
key.EndReading(end);
|
||||
|
||||
if (FindCharInReadable(':', colon, end)) {
|
||||
*result = ToNewCString( Substring(start, colon));
|
||||
if (!*result) rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
NS_ASSERTION(PR_FALSE, "FindCharInRead failed to find ':'");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
ClientKeyFromCacheKey(const nsAReadableCString& key, char ** result)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
*result = nsnull;
|
||||
|
||||
nsReadingIterator<char> start;
|
||||
key.BeginReading(start);
|
||||
|
||||
nsReadingIterator<char> end;
|
||||
key.EndReading(end);
|
||||
|
||||
if (FindCharInReadable(':', start, end)) {
|
||||
++start; // advance past clientID ':' delimiter
|
||||
*result = ToNewCString( Substring(start, end));
|
||||
if (!*result) rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
NS_ASSERTION(PR_FALSE, "FindCharInRead failed to find ':'");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
63
mozilla/netwerk/cache/src/nsCache.h
vendored
Normal file
63
mozilla/netwerk/cache/src/nsCache.h
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCache.h, released March 18, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Cache Service Utility Functions
|
||||
*/
|
||||
|
||||
#ifndef _nsCache_h_
|
||||
#define _nsCache_h_
|
||||
|
||||
#include "nsAReadableString.h"
|
||||
#include "prtime.h"
|
||||
#include "nsError.h"
|
||||
#include "prlog.h"
|
||||
|
||||
// PR_LOG args = "format string", arg, arg, ...
|
||||
#if defined(PR_LOGGING)
|
||||
extern PRLogModuleInfo * gCacheLog;
|
||||
void CacheLogInit();
|
||||
#define CACHE_LOG_INIT() CacheLogInit()
|
||||
#define CACHE_LOG_ALWAYS(args) PR_LOG(gCacheLog, PR_LOG_ALWAYS, args)
|
||||
#define CACHE_LOG_ERROR(args) PR_LOG(gCacheLog, PR_LOG_ERROR, args)
|
||||
#define CACHE_LOG_WARNING(args) PR_LOG(gCacheLog, PR_LOG_WARNING, args)
|
||||
#define CACHE_LOG_DEBUG(args) PR_LOG(gCacheLog, PR_LOG_DEBUG, args)
|
||||
#else
|
||||
#define CACHE_LOG_INIT() {}
|
||||
#define CACHE_LOG_ALWAYS(args) {}
|
||||
#define CACHE_LOG_ERROR(args) {}
|
||||
#define CACHE_LOG_WARNING(args) {}
|
||||
#define CACHE_LOG_DEBUG(args) {}
|
||||
#endif
|
||||
|
||||
|
||||
extern PRUint32 SecondsFromPRTime(PRTime prTime);
|
||||
extern PRTime PRTimeFromSeconds(PRUint32 seconds);
|
||||
|
||||
|
||||
extern nsresult ClientIDFromCacheKey(const nsAReadableCString& key, char ** result);
|
||||
extern nsresult ClientKeyFromCacheKey(const nsAReadableCString& key, char ** result);
|
||||
|
||||
#endif // _nsCache_h
|
||||
72
mozilla/netwerk/cache/src/nsCacheDevice.h
vendored
Normal file
72
mozilla/netwerk/cache/src/nsCacheDevice.h
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheDevice.h, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan, 22-February-2001
|
||||
*/
|
||||
|
||||
#ifndef _nsCacheDevice_h_
|
||||
#define _nsCacheDevice_h_
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsError.h"
|
||||
#include "nsICache.h"
|
||||
|
||||
class nsIFile;
|
||||
class nsCString;
|
||||
class nsCacheEntry;
|
||||
class nsICacheVisitor;
|
||||
class nsITransport;
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheDevice
|
||||
*******************************************************************************/
|
||||
class nsCacheDevice {
|
||||
public:
|
||||
virtual ~nsCacheDevice() {}
|
||||
|
||||
virtual nsresult Init() = 0;
|
||||
virtual nsresult Shutdown() = 0;
|
||||
|
||||
virtual const char * GetDeviceID(void) = 0;
|
||||
virtual nsCacheEntry * FindEntry( nsCString * key ) = 0;
|
||||
|
||||
virtual nsresult DeactivateEntry( nsCacheEntry * entry ) = 0;
|
||||
virtual nsresult BindEntry( nsCacheEntry * entry ) = 0;
|
||||
virtual void DoomEntry( nsCacheEntry * entry ) = 0;
|
||||
|
||||
virtual nsresult GetTransportForEntry( nsCacheEntry * entry,
|
||||
nsCacheAccessMode mode,
|
||||
nsITransport **result ) = 0;
|
||||
|
||||
virtual nsresult GetFileForEntry( nsCacheEntry * entry,
|
||||
nsIFile ** result ) = 0;
|
||||
|
||||
virtual nsresult OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize ) = 0;
|
||||
|
||||
virtual nsresult Visit(nsICacheVisitor * visitor) = 0;
|
||||
|
||||
/**
|
||||
* Device must evict entries associated with clientID. If clientID == nsnull, all
|
||||
* entries must be evicted. Active entries must be doomed, rather than evicted.
|
||||
*/
|
||||
virtual nsresult EvictEntries(const char * clientID) = 0;
|
||||
};
|
||||
|
||||
#endif // _nsCacheDevice_h_
|
||||
579
mozilla/netwerk/cache/src/nsCacheEntry.cpp
vendored
Normal file
579
mozilla/netwerk/cache/src/nsCacheEntry.cpp
vendored
Normal file
@@ -0,0 +1,579 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheEntry.cpp, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan, 22-February-2001
|
||||
*/
|
||||
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsCacheEntry.h"
|
||||
#include "nsCacheEntryDescriptor.h"
|
||||
#include "nsCacheMetaData.h"
|
||||
#include "nsCacheRequest.h"
|
||||
#include "nsError.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsCache.h"
|
||||
|
||||
|
||||
nsCacheEntry::nsCacheEntry(nsCString * key,
|
||||
PRBool streamBased,
|
||||
nsCacheStoragePolicy storagePolicy)
|
||||
: mKey(key),
|
||||
mFetchCount(0),
|
||||
mLastFetched(0),
|
||||
mExpirationTime(0),
|
||||
mFlags(0),
|
||||
mDataSize(0),
|
||||
mMetaSize(0),
|
||||
mCacheDevice(nsnull),
|
||||
mData(nsnull),
|
||||
mMetaData(nsnull)
|
||||
{
|
||||
PR_INIT_CLIST(this);
|
||||
PR_INIT_CLIST(&mRequestQ);
|
||||
PR_INIT_CLIST(&mDescriptorQ);
|
||||
|
||||
if (streamBased) MarkStreamBased();
|
||||
SetStoragePolicy(storagePolicy);
|
||||
}
|
||||
|
||||
|
||||
nsCacheEntry::~nsCacheEntry()
|
||||
{
|
||||
delete mKey;
|
||||
delete mMetaData;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsCacheEntry::Fetched()
|
||||
{
|
||||
mLastFetched = SecondsFromPRTime(PR_Now());
|
||||
++mFetchCount;
|
||||
MarkEntryDirty();
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntry::GetData(nsISupports **result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
NS_IF_ADDREF(*result = mData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsCacheEntry::TouchData()
|
||||
{
|
||||
mLastModified = SecondsFromPRTime(PR_Now());
|
||||
MarkDataDirty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntry::GetMetaDataElement( const nsAReadableCString& key,
|
||||
nsAReadableCString ** value)
|
||||
{
|
||||
*value = mMetaData ? mMetaData->GetElement(&key) : nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntry::SetMetaDataElement( const nsAReadableCString& key,
|
||||
const nsAReadableCString& value)
|
||||
{
|
||||
if (!mMetaData) {
|
||||
mMetaData = nsCacheMetaData::Create();
|
||||
if (!mMetaData)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult rv = mMetaData->SetElement(key, value);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mMetaSize = mMetaData->Size(); // calc new meta data size
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntry::VisitMetaDataElements( nsICacheMetaDataVisitor * visitor)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(visitor);
|
||||
|
||||
if (mMetaData)
|
||||
mMetaData->VisitElements(visitor);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntry::FlattenMetaData(char ** data, PRUint32 * size)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(size);
|
||||
|
||||
if (mMetaData)
|
||||
return mMetaData->FlattenMetaData(data, size);
|
||||
|
||||
if (data) *data = nsnull;
|
||||
*size = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCacheEntry::UnflattenMetaData(char * data, PRUint32 size)
|
||||
{
|
||||
delete mMetaData;
|
||||
mMetaData = nsCacheMetaData::Create();
|
||||
if (!mMetaData)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsresult rv = mMetaData->UnflattenMetaData(data, size);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mMetaSize = mMetaData->Size();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsCacheEntry::TouchMetaData()
|
||||
{
|
||||
mLastModified = SecondsFromPRTime(PR_Now());
|
||||
MarkMetaDataDirty();
|
||||
}
|
||||
|
||||
#if 0
|
||||
nsresult
|
||||
nsCacheEntry::GetKeyValueArray(nsCacheMetaDataKeyValuePair ** array,
|
||||
PRUint32 * count)
|
||||
{
|
||||
if (!array || !count) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!mMetaData) {
|
||||
*array = nsnull;
|
||||
*count = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
return mMetaData->GetKeyValueArray(array, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntry::GetSecurityInfo( nsISupports ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
NS_IF_ADDREF(*result = mSecurityInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* cache entry states
|
||||
* 0 descriptors (new entry)
|
||||
* 0 descriptors (existing, bound entry)
|
||||
* n descriptors (existing, bound entry) valid
|
||||
* n descriptors (existing, bound entry) not valid (wait until valid or doomed)
|
||||
*/
|
||||
|
||||
nsresult
|
||||
nsCacheEntry::RequestAccess(nsCacheRequest * request, nsCacheAccessMode *accessGranted)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!IsInitialized()) {
|
||||
// brand new, unbound entry
|
||||
request->mKey = nsnull; // steal ownership of the key string
|
||||
if (request->IsStreamBased()) MarkStreamBased();
|
||||
MarkInitialized();
|
||||
|
||||
*accessGranted = request->AccessRequested() & nsICache::ACCESS_WRITE;
|
||||
NS_ASSERTION(*accessGranted, "new cache entry for READ-ONLY request");
|
||||
PR_APPEND_LINK(request, &mRequestQ);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (IsDoomed()) return NS_ERROR_CACHE_ENTRY_DOOMED;
|
||||
|
||||
if (IsStreamData() != request->IsStreamBased()) {
|
||||
*accessGranted = nsICache::ACCESS_NONE;
|
||||
return request->IsStreamBased() ?
|
||||
NS_ERROR_CACHE_DATA_IS_NOT_STREAM : NS_ERROR_CACHE_DATA_IS_STREAM;
|
||||
}
|
||||
|
||||
if (PR_CLIST_IS_EMPTY(&mDescriptorQ)) {
|
||||
// 1st descriptor for existing bound entry
|
||||
*accessGranted = request->AccessRequested();
|
||||
if (*accessGranted & nsICache::ACCESS_WRITE) {
|
||||
MarkInvalid();
|
||||
} else {
|
||||
MarkValid();
|
||||
}
|
||||
} else {
|
||||
// nth request for existing, bound entry
|
||||
*accessGranted = request->AccessRequested() & ~nsICache::ACCESS_WRITE;
|
||||
if (!IsValid())
|
||||
rv = NS_ERROR_CACHE_WAIT_FOR_VALIDATION;
|
||||
}
|
||||
PR_APPEND_LINK(request,&mRequestQ);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntry::CreateDescriptor(nsCacheRequest * request,
|
||||
nsCacheAccessMode accessGranted,
|
||||
nsICacheEntryDescriptor ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(request && result);
|
||||
|
||||
nsCacheEntryDescriptor * descriptor =
|
||||
new nsCacheEntryDescriptor(this, accessGranted);
|
||||
|
||||
// XXX check request is on q
|
||||
PR_REMOVE_AND_INIT_LINK(request); // remove request regardless of success
|
||||
|
||||
if (descriptor == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PR_APPEND_LINK(descriptor, &mDescriptorQ);
|
||||
|
||||
NS_ADDREF(*result = descriptor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsCacheEntry::RemoveRequest(nsCacheRequest * request)
|
||||
{
|
||||
// XXX if debug: verify this request belongs to this entry
|
||||
PR_REMOVE_AND_INIT_LINK(request);
|
||||
|
||||
// return true if this entry should stay active
|
||||
return !((PR_CLIST_IS_EMPTY(&mRequestQ)) &&
|
||||
(PR_CLIST_IS_EMPTY(&mDescriptorQ)));
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsCacheEntry::RemoveDescriptor(nsCacheEntryDescriptor * descriptor)
|
||||
{
|
||||
// XXX if debug: verify this descriptor belongs to this entry
|
||||
PR_REMOVE_AND_INIT_LINK(descriptor);
|
||||
|
||||
if (!PR_CLIST_IS_EMPTY(&mDescriptorQ))
|
||||
return PR_TRUE; // stay active if we still have open descriptors
|
||||
|
||||
if (PR_CLIST_IS_EMPTY(&mRequestQ))
|
||||
return PR_FALSE; // no descriptors or requests, we can deactivate
|
||||
|
||||
return PR_TRUE; // find next best request to give a descriptor to
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsCacheEntry::DetachDescriptors(void)
|
||||
{
|
||||
nsCacheEntryDescriptor * descriptor =
|
||||
(nsCacheEntryDescriptor *)PR_LIST_HEAD(&mDescriptorQ);
|
||||
|
||||
while (descriptor != &mDescriptorQ) {
|
||||
nsCacheEntryDescriptor * nextDescriptor =
|
||||
(nsCacheEntryDescriptor *)PR_NEXT_LINK(descriptor);
|
||||
|
||||
descriptor->ClearCacheEntry();
|
||||
PR_REMOVE_AND_INIT_LINK(descriptor);
|
||||
descriptor = nextDescriptor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheEntryInfo - for implementing about:cache
|
||||
*****************************************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCacheEntryInfo, nsICacheEntryInfo);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryInfo::GetClientID(char ** clientID)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(clientID);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return ClientIDFromCacheKey(*mCacheEntry->Key(), clientID);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryInfo::GetKey(char ** key)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(key);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return ClientKeyFromCacheKey(*mCacheEntry->Key(), key);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryInfo::GetFetchCount(PRInt32 * fetchCount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(fetchCount);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*fetchCount = mCacheEntry->FetchCount();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryInfo::GetLastFetched(PRUint32 * lastFetched)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(lastFetched);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*lastFetched = mCacheEntry->LastFetched();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryInfo::GetLastModified(PRUint32 * lastModified)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(lastModified);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*lastModified = mCacheEntry->LastModified();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryInfo::GetExpirationTime(PRUint32 * expirationTime)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(expirationTime);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*expirationTime = mCacheEntry->ExpirationTime();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryInfo::GetDataSize(PRUint32 * dataSize)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(dataSize);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*dataSize = mCacheEntry->DataSize();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryInfo::IsStreamBased(PRBool * result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->IsStreamData();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheEntryHashTable
|
||||
*****************************************************************************/
|
||||
|
||||
PLDHashTableOps
|
||||
nsCacheEntryHashTable::ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
GetKey,
|
||||
HashKey,
|
||||
MatchEntry,
|
||||
MoveEntry,
|
||||
ClearEntry,
|
||||
Finalize
|
||||
};
|
||||
|
||||
|
||||
nsCacheEntryHashTable::nsCacheEntryHashTable()
|
||||
: initialized(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsCacheEntryHashTable::~nsCacheEntryHashTable()
|
||||
{
|
||||
if (initialized)
|
||||
PL_DHashTableFinish(&table);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntryHashTable::Init()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
initialized = PL_DHashTableInit(&table, &ops, nsnull,
|
||||
sizeof(nsCacheEntryHashTableEntry), 512);
|
||||
|
||||
if (!initialized) rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsCacheEntry *
|
||||
nsCacheEntryHashTable::GetEntry( const nsCString * key)
|
||||
{
|
||||
PLDHashEntryHdr *hashEntry;
|
||||
nsCacheEntry *result = nsnull;
|
||||
|
||||
NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
|
||||
hashEntry = PL_DHashTableOperate(&table, key, PL_DHASH_LOOKUP);
|
||||
if (PL_DHASH_ENTRY_IS_BUSY(hashEntry)) {
|
||||
result = ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntryHashTable::AddEntry( nsCacheEntry *cacheEntry)
|
||||
{
|
||||
PLDHashEntryHdr *hashEntry;
|
||||
|
||||
NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
|
||||
if (!cacheEntry) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
hashEntry = PL_DHashTableOperate(&table, cacheEntry->mKey, PL_DHASH_ADD);
|
||||
#ifndef DEBUG_dougt
|
||||
NS_ASSERTION(((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry == 0,
|
||||
"### nsCacheEntryHashTable::AddEntry - entry already used");
|
||||
#endif
|
||||
((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry = cacheEntry;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsCacheEntryHashTable::RemoveEntry( nsCacheEntry *cacheEntry)
|
||||
{
|
||||
NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
|
||||
NS_ASSERTION(cacheEntry, "### cacheEntry == nsnull");
|
||||
|
||||
#if DEBUG
|
||||
// XXX debug code to make sure we have the entry we're trying to remove
|
||||
nsCacheEntry *check = GetEntry(cacheEntry->mKey);
|
||||
NS_ASSERTION(check == cacheEntry, "### Attempting to remove unknown cache entry!!!");
|
||||
#endif
|
||||
(void) PL_DHashTableOperate(&table, cacheEntry->mKey, PL_DHASH_REMOVE);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsCacheEntryHashTable::VisitEntries( nsCacheEntryHashTable::Visitor *visitor)
|
||||
{
|
||||
PL_DHashTableEnumerate(&table, VisitEntry, visitor);
|
||||
}
|
||||
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
nsCacheEntryHashTable::VisitEntry(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hashEntry,
|
||||
PRUint32 number,
|
||||
void *arg)
|
||||
{
|
||||
nsCacheEntry *cacheEntry = ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry;
|
||||
nsCacheEntryHashTable::Visitor *visitor = (nsCacheEntryHashTable::Visitor*) arg;
|
||||
return (visitor->VisitEntry(cacheEntry) ? PL_DHASH_NEXT : PL_DHASH_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* hash table operation callback functions
|
||||
*/
|
||||
const void * PR_CALLBACK
|
||||
nsCacheEntryHashTable::GetKey( PLDHashTable * /*table*/, PLDHashEntryHdr *hashEntry)
|
||||
{
|
||||
nsCacheEntry *cacheEntry = ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry;
|
||||
return cacheEntry->mKey;
|
||||
}
|
||||
|
||||
|
||||
PLDHashNumber PR_CALLBACK
|
||||
nsCacheEntryHashTable::HashKey( PLDHashTable *table, const void *key)
|
||||
{
|
||||
return PL_DHashStringKey(table,((nsCString *)key)->get());
|
||||
}
|
||||
|
||||
PRBool PR_CALLBACK
|
||||
nsCacheEntryHashTable::MatchEntry(PLDHashTable * /* table */,
|
||||
const PLDHashEntryHdr * hashEntry,
|
||||
const void * key)
|
||||
{
|
||||
NS_ASSERTION(key != nsnull, "### nsCacheEntryHashTable::MatchEntry : null key");
|
||||
nsCacheEntry *cacheEntry = ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry;
|
||||
|
||||
return nsStr::StrCompare(*cacheEntry->mKey, *(nsCString *)key, -1, PR_FALSE) == 0;
|
||||
}
|
||||
|
||||
|
||||
void PR_CALLBACK
|
||||
nsCacheEntryHashTable::MoveEntry(PLDHashTable * /* table */,
|
||||
const PLDHashEntryHdr *from,
|
||||
PLDHashEntryHdr *to)
|
||||
{
|
||||
((nsCacheEntryHashTableEntry *)to)->cacheEntry =
|
||||
((nsCacheEntryHashTableEntry *)from)->cacheEntry;
|
||||
}
|
||||
|
||||
|
||||
void PR_CALLBACK
|
||||
nsCacheEntryHashTable::ClearEntry(PLDHashTable * /* table */,
|
||||
PLDHashEntryHdr * hashEntry)
|
||||
{
|
||||
((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsCacheEntryHashTable::Finalize(PLDHashTable * table)
|
||||
{
|
||||
(void) PL_DHashTableEnumerate(table, FreeCacheEntries, nsnull);
|
||||
}
|
||||
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
nsCacheEntryHashTable::FreeCacheEntries(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hdr,
|
||||
PRUint32 number,
|
||||
void *arg)
|
||||
{
|
||||
nsCacheEntryHashTableEntry *entry = (nsCacheEntryHashTableEntry *)hdr;
|
||||
delete entry->cacheEntry;
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
319
mozilla/netwerk/cache/src/nsCacheEntry.h
vendored
Normal file
319
mozilla/netwerk/cache/src/nsCacheEntry.h
vendored
Normal file
@@ -0,0 +1,319 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheEntry.h, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan, 22-February-2001
|
||||
*/
|
||||
|
||||
#ifndef _nsCacheEntry_h_
|
||||
#define _nsCacheEntry_h_
|
||||
|
||||
#include "nspr.h"
|
||||
#include "pldhash.h"
|
||||
#include "nscore.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAReadableString.h"
|
||||
|
||||
#include "nsICache.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
#include "nsCacheMetaData.h"
|
||||
|
||||
|
||||
class nsCacheDevice;
|
||||
class nsCacheMetaData;
|
||||
class nsCacheRequest;
|
||||
class nsCacheEntryDescriptor;
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheEntry
|
||||
*******************************************************************************/
|
||||
class nsCacheEntry : public PRCList
|
||||
{
|
||||
public:
|
||||
|
||||
nsCacheEntry(nsCString * key,
|
||||
PRBool streamBased,
|
||||
nsCacheStoragePolicy storagePolicy);
|
||||
~nsCacheEntry();
|
||||
|
||||
|
||||
nsCString * Key() { return mKey; }
|
||||
|
||||
PRInt32 FetchCount() { return mFetchCount;}
|
||||
void SetFetchCount( PRInt32 count) { mFetchCount = count;}
|
||||
void Fetched();
|
||||
|
||||
PRUint32 LastFetched() { return mLastFetched;}
|
||||
void SetLastFetched( PRUint32 lastFetched) { mLastFetched = lastFetched;}
|
||||
|
||||
PRUint32 LastModified() { return mLastModified;}
|
||||
void SetLastModified( PRUint32 lastModified) { mLastModified = lastModified;}
|
||||
|
||||
PRUint32 ExpirationTime() { return mExpirationTime;}
|
||||
void SetExpirationTime( PRUint32 expires) { mExpirationTime = expires;}
|
||||
|
||||
PRUint32 Size() { return mDataSize + mMetaSize; }
|
||||
|
||||
nsCacheDevice * CacheDevice() { return mCacheDevice;}
|
||||
void SetCacheDevice( nsCacheDevice * device) { mCacheDevice = device;}
|
||||
|
||||
|
||||
/**
|
||||
* Data accessors
|
||||
*/
|
||||
nsresult GetData( nsISupports ** result);
|
||||
void SetData( nsISupports * data) { mData = data; }
|
||||
|
||||
PRUint32 DataSize() { return mDataSize;}
|
||||
void SetDataSize( PRUint32 size) { mDataSize = size;}
|
||||
|
||||
void TouchData();
|
||||
|
||||
|
||||
/**
|
||||
* Meta data accessors
|
||||
*/
|
||||
nsresult GetMetaDataElement( const nsAReadableCString& key,
|
||||
nsAReadableCString ** value);
|
||||
nsresult SetMetaDataElement( const nsAReadableCString& key,
|
||||
const nsAReadableCString& value);
|
||||
|
||||
nsresult VisitMetaDataElements( nsICacheMetaDataVisitor * visitor);
|
||||
|
||||
nsresult FlattenMetaData( char ** data, PRUint32 * size);
|
||||
nsresult UnflattenMetaData( char * data, PRUint32 size);
|
||||
|
||||
PRUint32 MetaDataSize() { return mMetaSize;}
|
||||
|
||||
void TouchMetaData();
|
||||
|
||||
|
||||
/**
|
||||
* Security Info accessors
|
||||
*/
|
||||
nsresult GetSecurityInfo( nsISupports ** result);
|
||||
void SetSecurityInfo( nsISupports * info) { mSecurityInfo = info; }
|
||||
|
||||
|
||||
// XXX enumerate MetaData method
|
||||
|
||||
|
||||
enum CacheEntryFlags {
|
||||
eStoragePolicyMask = 0x000000FF,
|
||||
eDoomedMask = 0x00000100,
|
||||
eEntryDirtyMask = 0x00000200,
|
||||
eDataDirtyMask = 0x00000400,
|
||||
eMetaDataDirtyMask = 0x00000800,
|
||||
eStreamDataMask = 0x00001000,
|
||||
eActiveMask = 0x00002000,
|
||||
eInitializedMask = 0x00004000,
|
||||
eValidMask = 0x00008000,
|
||||
eBindingMask = 0x00010000
|
||||
};
|
||||
|
||||
void MarkBinding() { mFlags |= eBindingMask; }
|
||||
void ClearBinding() { mFlags &= ~eBindingMask; }
|
||||
PRBool IsBinding() { return (mFlags & eBindingMask) != 0; }
|
||||
|
||||
void MarkEntryDirty() { mFlags |= eEntryDirtyMask; }
|
||||
void MarkEntryClean() { mFlags &= ~eEntryDirtyMask; }
|
||||
void MarkDataDirty() { mFlags |= eDataDirtyMask; }
|
||||
void MarkDataClean() { mFlags &= ~eDataDirtyMask; }
|
||||
void MarkMetaDataDirty() { mFlags |= eMetaDataDirtyMask; }
|
||||
void MarkMetaDataClean() { mFlags &= ~eMetaDataDirtyMask; }
|
||||
void MarkStreamData() { mFlags |= eStreamDataMask; }
|
||||
void MarkValid() { mFlags |= eValidMask; }
|
||||
void MarkInvalid() { mFlags &= ~eValidMask; }
|
||||
// void MarkAllowedInMemory() { mFlags |= eAllowedInMemoryMask; }
|
||||
// void MarkAllowedOnDisk() { mFlags |= eAllowedOnDiskMask; }
|
||||
|
||||
PRBool IsDoomed() { return (mFlags & eDoomedMask) != 0; }
|
||||
PRBool IsEntryDirty() { return (mFlags & eEntryDirtyMask) != 0; }
|
||||
PRBool IsDataDirty() { return (mFlags & eDataDirtyMask) != 0; }
|
||||
PRBool IsMetaDataDirty() { return (mFlags & eMetaDataDirtyMask) != 0; }
|
||||
PRBool IsStreamData() { return (mFlags & eStreamDataMask) != 0; }
|
||||
PRBool IsActive() { return (mFlags & eActiveMask) != 0; }
|
||||
PRBool IsInitialized() { return (mFlags & eInitializedMask) != 0; }
|
||||
PRBool IsValid() { return (mFlags & eValidMask) != 0; }
|
||||
PRBool IsInvalid() { return (mFlags & eValidMask) == 0; }
|
||||
PRBool IsInUse() { return !(PR_CLIST_IS_EMPTY(&mRequestQ) &&
|
||||
PR_CLIST_IS_EMPTY(&mDescriptorQ)); }
|
||||
PRBool IsNotInUse() { return (PR_CLIST_IS_EMPTY(&mRequestQ) &&
|
||||
PR_CLIST_IS_EMPTY(&mDescriptorQ)); }
|
||||
|
||||
|
||||
PRBool IsAllowedInMemory()
|
||||
{
|
||||
return (StoragePolicy() == nsICache::STORE_ANYWHERE) ||
|
||||
(StoragePolicy() == nsICache::STORE_IN_MEMORY);
|
||||
}
|
||||
|
||||
PRBool IsAllowedOnDisk()
|
||||
{
|
||||
return (StoragePolicy() == nsICache::STORE_ANYWHERE) ||
|
||||
(StoragePolicy() == nsICache::STORE_ON_DISK) ||
|
||||
(StoragePolicy() == nsICache::STORE_ON_DISK_AS_FILE);
|
||||
}
|
||||
|
||||
nsCacheStoragePolicy StoragePolicy()
|
||||
{
|
||||
return (nsCacheStoragePolicy)(mFlags & eStoragePolicyMask);
|
||||
}
|
||||
|
||||
void SetStoragePolicy(nsCacheStoragePolicy policy)
|
||||
{
|
||||
NS_ASSERTION(policy <= 0xFF, "too many bits in nsCacheStoragePolicy");
|
||||
mFlags &= ~eStoragePolicyMask; // clear storage policy bits
|
||||
mFlags |= policy;
|
||||
}
|
||||
|
||||
|
||||
// methods for nsCacheService
|
||||
nsresult RequestAccess( nsCacheRequest * request, nsCacheAccessMode *accessGranted);
|
||||
nsresult CreateDescriptor( nsCacheRequest * request,
|
||||
nsCacheAccessMode accessGranted,
|
||||
nsICacheEntryDescriptor ** result);
|
||||
|
||||
// nsresult Open(nsCacheRequest *request, nsICacheEntryDescriptor ** result);
|
||||
// nsresult AsyncOpen(nsCacheRequest *request);
|
||||
PRBool RemoveRequest( nsCacheRequest * request);
|
||||
PRBool RemoveDescriptor( nsCacheEntryDescriptor * descriptor);
|
||||
|
||||
private:
|
||||
friend class nsCacheEntryHashTable;
|
||||
friend class nsCacheService;
|
||||
|
||||
void DetachDescriptors(void);
|
||||
|
||||
// internal methods
|
||||
void MarkDoomed() { mFlags |= eDoomedMask; }
|
||||
void MarkStreamBased() { mFlags |= eStreamDataMask; }
|
||||
void MarkInitialized() { mFlags |= eInitializedMask; }
|
||||
void MarkActive() { mFlags |= eActiveMask; }
|
||||
void MarkInactive() { mFlags &= ~eActiveMask; }
|
||||
|
||||
nsCString * mKey; // 4 // XXX ask scc about const'ness
|
||||
PRUint32 mFetchCount; // 4
|
||||
PRUint32 mLastFetched; // 4
|
||||
PRUint32 mLastModified; // 4
|
||||
PRUint32 mLastValidated; // 4
|
||||
PRUint32 mExpirationTime; // 4
|
||||
PRUint32 mFlags; // 4
|
||||
PRUint32 mDataSize; // 4
|
||||
PRUint32 mMetaSize; // 4
|
||||
nsCacheDevice * mCacheDevice; // 4
|
||||
nsCOMPtr<nsISupports> mSecurityInfo; //
|
||||
nsCOMPtr<nsISupports> mData; //
|
||||
nsCacheMetaData * mMetaData; // 4
|
||||
PRCList mRequestQ; // 8
|
||||
PRCList mDescriptorQ; // 8
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheEntryInfo
|
||||
*******************************************************************************/
|
||||
class nsCacheEntryInfo : public nsICacheEntryInfo {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICACHEENTRYINFO
|
||||
|
||||
nsCacheEntryInfo(nsCacheEntry* entry)
|
||||
: mCacheEntry(entry)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
virtual ~nsCacheEntryInfo() {}
|
||||
void DetachEntry() { mCacheEntry = nsnull; }
|
||||
|
||||
private:
|
||||
nsCacheEntry * mCacheEntry;
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheEntryHashTable
|
||||
*******************************************************************************/
|
||||
typedef struct {
|
||||
PLDHashNumber keyHash;
|
||||
nsCacheEntry *cacheEntry;
|
||||
} nsCacheEntryHashTableEntry;
|
||||
|
||||
|
||||
class nsCacheEntryHashTable
|
||||
{
|
||||
public:
|
||||
nsCacheEntryHashTable();
|
||||
~nsCacheEntryHashTable();
|
||||
|
||||
nsresult Init();
|
||||
|
||||
nsCacheEntry *GetEntry( const nsCString * key);
|
||||
nsresult AddEntry( nsCacheEntry *entry);
|
||||
void RemoveEntry( nsCacheEntry *entry);
|
||||
|
||||
// XXX enumerate entries?
|
||||
class Visitor {
|
||||
public:
|
||||
virtual PRBool VisitEntry( nsCacheEntry *entry) = 0;
|
||||
};
|
||||
|
||||
void VisitEntries( Visitor *visitor);
|
||||
|
||||
private:
|
||||
friend class nsCacheService; // XXX redefine interface so this isn't necessary
|
||||
|
||||
// PLDHashTable operation callbacks
|
||||
static const void * PR_CALLBACK GetKey( PLDHashTable *table, PLDHashEntryHdr *entry);
|
||||
|
||||
static PLDHashNumber PR_CALLBACK HashKey( PLDHashTable *table, const void *key);
|
||||
|
||||
static PRBool PR_CALLBACK MatchEntry( PLDHashTable * table,
|
||||
const PLDHashEntryHdr * entry,
|
||||
const void * key);
|
||||
|
||||
static void PR_CALLBACK MoveEntry( PLDHashTable *table,
|
||||
const PLDHashEntryHdr *from,
|
||||
PLDHashEntryHdr *to);
|
||||
|
||||
static void PR_CALLBACK ClearEntry( PLDHashTable *table, PLDHashEntryHdr *entry);
|
||||
|
||||
static void PR_CALLBACK Finalize( PLDHashTable *table);
|
||||
|
||||
static
|
||||
PLDHashOperator PR_CALLBACK FreeCacheEntries(PLDHashTable * table,
|
||||
PLDHashEntryHdr * hdr,
|
||||
PRUint32 number,
|
||||
void * arg);
|
||||
static
|
||||
PLDHashOperator PR_CALLBACK VisitEntry(PLDHashTable * table,
|
||||
PLDHashEntryHdr * hdr,
|
||||
PRUint32 number,
|
||||
void * arg);
|
||||
|
||||
// member variables
|
||||
static PLDHashTableOps ops;
|
||||
PLDHashTable table;
|
||||
PRBool initialized;
|
||||
};
|
||||
|
||||
#endif // _nsCacheEntry_h_
|
||||
|
||||
654
mozilla/netwerk/cache/src/nsCacheEntryDescriptor.cpp
vendored
Normal file
654
mozilla/netwerk/cache/src/nsCacheEntryDescriptor.cpp
vendored
Normal file
@@ -0,0 +1,654 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheEntryDescriptor.cpp, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan, 22-February-2001
|
||||
*/
|
||||
|
||||
#include "nsICache.h"
|
||||
#include "nsCache.h"
|
||||
#include "nsCacheService.h"
|
||||
#include "nsCacheEntryDescriptor.h"
|
||||
#include "nsCacheEntry.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIOutputStream.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCacheEntryDescriptor, nsICacheEntryDescriptor)
|
||||
|
||||
|
||||
nsCacheEntryDescriptor::nsCacheEntryDescriptor(nsCacheEntry * entry,
|
||||
nsCacheAccessMode accessGranted)
|
||||
: mCacheEntry(entry),
|
||||
mAccessGranted(accessGranted)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
PR_INIT_CLIST(this);
|
||||
}
|
||||
|
||||
|
||||
nsCacheEntryDescriptor::~nsCacheEntryDescriptor()
|
||||
{
|
||||
if (mCacheEntry)
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntryDescriptor::Create(nsCacheEntry * entry, nsCacheAccessMode accessGranted,
|
||||
nsICacheEntryDescriptor ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCacheEntryDescriptor * descriptor =
|
||||
new nsCacheEntryDescriptor(entry, accessGranted);
|
||||
|
||||
if (descriptor == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(descriptor);
|
||||
rv = descriptor->QueryInterface(NS_GET_IID(nsICacheEntryDescriptor), (void**)result);
|
||||
NS_RELEASE(descriptor);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetClientID(char ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return ClientIDFromCacheKey(*(mCacheEntry->Key()), result);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetKey(char ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return ClientKeyFromCacheKey(*(mCacheEntry->Key()), result);
|
||||
|
||||
#if 0
|
||||
nsCString * key;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
*result = nsnull;
|
||||
key = mCacheEntry->Key();
|
||||
|
||||
nsReadingIterator<char> start;
|
||||
key->BeginReading(start);
|
||||
|
||||
nsReadingIterator<char> end;
|
||||
key->EndReading(end);
|
||||
|
||||
if (FindCharInReadable(':', start, end)) {
|
||||
++start; // advance past clientID ':' delimiter
|
||||
*result = ToNewCString( Substring(start, end));
|
||||
if (!*result) rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
NS_ASSERTION(PR_FALSE, "FindCharInRead failed to find ':'");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetFetchCount(PRInt32 *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->FetchCount();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetLastFetched(PRUint32 *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->LastFetched();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetLastModified(PRUint32 *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->LastModified();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetExpirationTime(PRUint32 *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->ExpirationTime();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::SetExpirationTime(PRUint32 expirationTime)
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
mCacheEntry->SetExpirationTime(expirationTime);
|
||||
mCacheEntry->MarkEntryDirty();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::IsStreamBased(PRBool *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->IsStreamData(); // XXX which name is better?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::GetDataSize(PRUint32 *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = mCacheEntry->DataSize();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntryDescriptor::RequestDataSizeChange(PRInt32 deltaSize)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsCacheService::GlobalInstance()->OnDataSizeChange(mCacheEntry, deltaSize);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// XXX review for signed/unsigned math errors
|
||||
PRUint32 newDataSize = mCacheEntry->DataSize() + deltaSize;
|
||||
mCacheEntry->SetDataSize(newDataSize);
|
||||
mCacheEntry->TouchData();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::SetDataSize(PRUint32 dataSize)
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
// XXX review for signed/unsigned math errors
|
||||
PRInt32 deltaSize = dataSize - mCacheEntry->DataSize();
|
||||
|
||||
// this had better be NS_OK, this call instance is advisory
|
||||
nsresult rv = RequestDataSizeChange(deltaSize);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed SetDataSize() on memory cache object!");
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetTransport(nsITransport ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
if (!mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_NOT_STREAM;
|
||||
|
||||
NS_ADDREF(*result = &mTransportWrapper);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetCacheElement(nsISupports ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
if (mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_STREAM;
|
||||
|
||||
return mCacheEntry->GetData(result);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::SetCacheElement(nsISupports * cacheElement)
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
if (mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_STREAM;
|
||||
|
||||
mCacheEntry->SetData(cacheElement);
|
||||
mCacheEntry->TouchData();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetAccessGranted(nsCacheAccessMode *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
*result = mAccessGranted;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetStoragePolicy(nsCacheStoragePolicy *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return mCacheEntry->StoragePolicy();
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::SetStoragePolicy(nsCacheStoragePolicy policy)
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
// XXX validate policy against session?
|
||||
mCacheEntry->SetStoragePolicy(policy);
|
||||
mCacheEntry->MarkEntryDirty();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetFile(nsIFile ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return nsCacheService::GlobalInstance()->GetFileForEntry(mCacheEntry, result);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetSecurityInfo(nsISupports ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return mCacheEntry->GetSecurityInfo(result);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::SetSecurityInfo(nsISupports * securityInfo)
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
mCacheEntry->SetSecurityInfo(securityInfo);
|
||||
mCacheEntry->MarkEntryDirty();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::Doom()
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return nsCacheService::GlobalInstance()->DoomEntry(mCacheEntry);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::DoomAndFailPendingRequests(nsresult status)
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::MarkValid()
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
nsresult rv;
|
||||
rv = nsCacheService::GlobalInstance()->ValidateEntry(mCacheEntry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::Close()
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
// tell nsCacheService we're going away
|
||||
nsCacheService::GlobalInstance()->CloseDescriptor(this);
|
||||
mCacheEntry = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::GetMetaDataElement(const char *key, char ** result)
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
if (!key | !result) return NS_ERROR_NULL_POINTER;
|
||||
nsAReadableCString *value;
|
||||
*result = nsnull;
|
||||
|
||||
// XXX not thread safe
|
||||
nsresult rv = mCacheEntry->GetMetaDataElement(nsLiteralCString(key), &value);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!value) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*result = ToNewCString(*value);
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::SetMetaDataElement(const char *key, const char *value)
|
||||
{
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
if (!key) return NS_ERROR_NULL_POINTER;
|
||||
// XXX not thread safe
|
||||
// XXX allow null value, for clearing key?
|
||||
nsresult rv = mCacheEntry->SetMetaDataElement(nsLiteralCString(key),
|
||||
nsLiteralCString(value));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mCacheEntry->TouchMetaData();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheEntryDescriptor::VisitMetaData(nsICacheMetaDataVisitor * visitor)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(visitor);
|
||||
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return mCacheEntry->VisitMetaDataElements(visitor);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheTransportWrapper
|
||||
******************************************************************************/
|
||||
|
||||
// XXX NS_IMPL_ISUPPORTS1(nsCacheEntryDescriptor::nsTransportWrapper, nsITransport);
|
||||
NS_IMPL_QUERY_INTERFACE1(nsCacheEntryDescriptor::nsTransportWrapper, nsITransport)
|
||||
|
||||
|
||||
// special AddRef and Release, because we are part of the descriptor
|
||||
#define GET_DESCRIPTOR_FROM_TRANSPORT_WRAPPER(_this) \
|
||||
((nsCacheEntryDescriptor*)((char*)(_this) - \
|
||||
offsetof(nsCacheEntryDescriptor, mTransportWrapper)))
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt) nsCacheEntryDescriptor::
|
||||
nsTransportWrapper::AddRef(void)
|
||||
{
|
||||
return GET_DESCRIPTOR_FROM_TRANSPORT_WRAPPER(this)->AddRef();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt) nsCacheEntryDescriptor::
|
||||
nsTransportWrapper::Release(void)
|
||||
{
|
||||
return GET_DESCRIPTOR_FROM_TRANSPORT_WRAPPER(this)->Release();
|
||||
}
|
||||
|
||||
|
||||
nsresult nsCacheEntryDescriptor::
|
||||
nsTransportWrapper::EnsureTransportWithAccess(nsCacheAccessMode mode)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCacheEntryDescriptor * descriptor = GET_DESCRIPTOR_FROM_TRANSPORT_WRAPPER(this);
|
||||
if (!descriptor->mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
if (!descriptor->mAccessGranted & mode) {
|
||||
rv = (mode == nsICache::ACCESS_READ) ?
|
||||
NS_ERROR_CACHE_READ_ACCESS_DENIED : NS_ERROR_CACHE_WRITE_ACCESS_DENIED;
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!mTransport) {
|
||||
rv = nsCacheService::GlobalInstance()->
|
||||
GetTransportForEntry(descriptor->mCacheEntry,
|
||||
descriptor->mAccessGranted,
|
||||
getter_AddRefs(mTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheEntryDescriptor::NewOutputStreamWrapper(nsIOutputStream ** result,
|
||||
nsCacheEntryDescriptor * descriptor,
|
||||
nsIOutputStream * output)
|
||||
{
|
||||
nsOutputStreamWrapper* cacheOutput =
|
||||
new nsOutputStreamWrapper(descriptor, output);
|
||||
if (!cacheOutput) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsISupports> ref(cacheOutput);
|
||||
nsresult rv = cacheOutput->Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ADDREF(*result = cacheOutput);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||
nsTransportWrapper::GetSecurityInfo(nsISupports ** securityInfo)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||
nsTransportWrapper::GetNotificationCallbacks(nsIInterfaceRequestor **result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
// if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||
nsTransportWrapper::SetNotificationCallbacks(nsIInterfaceRequestor *requestor,
|
||||
PRBool isBackground)
|
||||
{
|
||||
// if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||
nsTransportWrapper::OpenInputStream(PRUint32 offset,
|
||||
PRUint32 count,
|
||||
PRUint32 flags,
|
||||
nsIInputStream ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
|
||||
nsresult rv = EnsureTransportWithAccess(nsICache::ACCESS_READ);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mTransport->OpenInputStream(offset, count, flags, result);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||
nsTransportWrapper::OpenOutputStream(PRUint32 offset,
|
||||
PRUint32 count,
|
||||
PRUint32 flags,
|
||||
nsIOutputStream ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
|
||||
nsresult rv = EnsureTransportWithAccess(nsICache::ACCESS_WRITE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// XXX allow more than one output stream at a time on a descriptor? Why?
|
||||
|
||||
// Create the underlying output stream using the wrapped transport.
|
||||
nsCOMPtr<nsIOutputStream> output;
|
||||
rv = mTransport->OpenOutputStream(offset, count, flags, getter_AddRefs(output));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Wrap this output stream, with a stream that monitors how much data gets written,
|
||||
// to maintain the cache entry's size, and to inform the cache device. Eventually,
|
||||
// this mechanism will provide a way for the cache device to enforce space limits,
|
||||
// and to drive cache entry eviction.
|
||||
nsCacheEntryDescriptor * descriptor = GET_DESCRIPTOR_FROM_TRANSPORT_WRAPPER(this);
|
||||
return NewOutputStreamWrapper(result, descriptor, output);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||
nsTransportWrapper::AsyncRead(nsIStreamListener * listener,
|
||||
nsISupports * ctxt,
|
||||
PRUint32 offset,
|
||||
PRUint32 count,
|
||||
PRUint32 flags,
|
||||
nsIRequest ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
|
||||
nsresult rv = EnsureTransportWithAccess(nsICache::ACCESS_READ);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mTransport->AsyncRead(listener, ctxt, offset, count, flags, result);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||
nsTransportWrapper::AsyncWrite(nsIStreamProvider * provider,
|
||||
nsISupports * ctxt,
|
||||
PRUint32 offset,
|
||||
PRUint32 count,
|
||||
PRUint32 flags,
|
||||
nsIRequest ** result)
|
||||
{
|
||||
// we're not planning on implementing this
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
#if 0
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
|
||||
nsresult rv = EnsureTransportWithAccess(nsICache::ACCESS_WRITE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mTransport->AsyncWrite(provider, ctxt, offset, count, flags, result);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheOutputStream - a wrapper for nsIOutputstream to track the amount of
|
||||
* data written to a cache entry.
|
||||
******************************************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCacheEntryDescriptor::nsOutputStreamWrapper, nsIOutputStream);
|
||||
|
||||
nsresult nsCacheEntryDescriptor::
|
||||
nsOutputStreamWrapper::Init()
|
||||
{
|
||||
nsCacheAccessMode mode;
|
||||
nsresult rv = mDescriptor->GetAccessGranted(&mode);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (mode == nsICache::ACCESS_WRITE) {
|
||||
nsCacheEntry* cacheEntry = mDescriptor->CacheEntry();
|
||||
if (!cacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
nsCacheDevice* device = cacheEntry->CacheDevice();
|
||||
if (!device) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
// the entry has been truncated to zero bytes, inform the device.
|
||||
PRInt32 delta = -cacheEntry->DataSize();
|
||||
rv = device->OnDataSizeChange(cacheEntry, delta);
|
||||
cacheEntry->SetDataSize(0);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||
nsOutputStreamWrapper::Write(const char * buf,
|
||||
PRUint32 count,
|
||||
PRUint32 * result)
|
||||
{
|
||||
nsresult rv = OnWrite(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return mOutput->Write(buf, count, result);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||
nsOutputStreamWrapper::WriteFrom(nsIInputStream * inStr,
|
||||
PRUint32 count,
|
||||
PRUint32 * result)
|
||||
{
|
||||
nsresult rv = OnWrite(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return mOutput->WriteFrom(inStr, count, result);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheEntryDescriptor::
|
||||
nsOutputStreamWrapper::WriteSegments(nsReadSegmentFun reader,
|
||||
void * closure,
|
||||
PRUint32 count,
|
||||
PRUint32 * result)
|
||||
{
|
||||
nsresult rv = OnWrite(count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return mOutput->WriteSegments(reader, closure, count, result);
|
||||
}
|
||||
|
||||
|
||||
nsresult nsCacheEntryDescriptor::
|
||||
nsOutputStreamWrapper::OnWrite(PRUint32 count)
|
||||
{
|
||||
// XXX if count > 2^31 error_write_too_big
|
||||
return mDescriptor->RequestDataSizeChange((PRInt32)count);
|
||||
}
|
||||
|
||||
|
||||
167
mozilla/netwerk/cache/src/nsCacheEntryDescriptor.h
vendored
Normal file
167
mozilla/netwerk/cache/src/nsCacheEntryDescriptor.h
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheEntryDescriptor.h, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan, 22-February-2001
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _nsCacheEntryDescriptor_h_
|
||||
#define _nsCacheEntryDescriptor_h_
|
||||
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
#include "nsCacheEntry.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsITransport.h"
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheEntryDescriptor
|
||||
*******************************************************************************/
|
||||
class nsCacheEntryDescriptor :
|
||||
public PRCList,
|
||||
public nsICacheEntryDescriptor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICACHEENTRYDESCRIPTOR
|
||||
NS_DECL_NSICACHEENTRYINFO
|
||||
|
||||
nsCacheEntryDescriptor(nsCacheEntry * entry, nsCacheAccessMode mode);
|
||||
virtual ~nsCacheEntryDescriptor();
|
||||
|
||||
static nsresult Create(nsCacheEntry * entry, nsCacheAccessMode accessGranted,
|
||||
nsICacheEntryDescriptor ** result);
|
||||
|
||||
|
||||
/**
|
||||
* utility method to attempt changing data size of associated entry
|
||||
*/
|
||||
nsresult RequestDataSizeChange(PRInt32 deltaSize);
|
||||
|
||||
/**
|
||||
* methods callbacks for nsCacheService
|
||||
*/
|
||||
nsCacheEntry * CacheEntry(void) { return mCacheEntry; }
|
||||
void ClearCacheEntry(void) { mCacheEntry = nsnull; }
|
||||
|
||||
private:
|
||||
|
||||
/*************************************************************************
|
||||
* transport wrapper class -
|
||||
*
|
||||
* we want the transport wrapper to have the same lifetime as the
|
||||
* descriptor, but since they each need to reference the other, we have the
|
||||
* descriptor include the transport wrapper as a member, rather than just
|
||||
* pointing to it, which avoids circular AddRefs.
|
||||
*************************************************************************/
|
||||
class nsTransportWrapper : public nsITransport
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSITRANSPORT
|
||||
|
||||
nsTransportWrapper() : mTransport(nsnull) {}
|
||||
virtual ~nsTransportWrapper() {}
|
||||
|
||||
nsresult EnsureTransportWithAccess(nsCacheAccessMode mode);
|
||||
|
||||
nsCOMPtr<nsITransport> mTransport;
|
||||
}; // end of class nsTransportWrapper
|
||||
friend class nsTransportWrapper;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* output stream wrapper class -
|
||||
*
|
||||
* The output stream wrapper references the descriptor, but the descriptor
|
||||
* doesn't need any references to the stream wrapper, so we don't need the
|
||||
* same kind of tricks that we're using for the transport wrapper.
|
||||
*************************************************************************/
|
||||
class nsOutputStreamWrapper : public nsIOutputStream {
|
||||
private:
|
||||
nsCacheEntryDescriptor * mDescriptor;
|
||||
nsCOMPtr<nsIOutputStream> mOutput;
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
// NS_DECL_NSIOUTPUTSTREAM
|
||||
NS_IMETHOD Close(void) { return mOutput->Close(); }
|
||||
NS_IMETHOD Flush(void) { return mOutput->Flush(); }
|
||||
|
||||
NS_IMETHOD Write(const char * buf,
|
||||
PRUint32 count,
|
||||
PRUint32 * result);
|
||||
|
||||
NS_IMETHOD WriteFrom(nsIInputStream * inStr,
|
||||
PRUint32 count,
|
||||
PRUint32 * result);
|
||||
|
||||
NS_IMETHOD WriteSegments(nsReadSegmentFun reader,
|
||||
void * closure,
|
||||
PRUint32 count,
|
||||
PRUint32 * result);
|
||||
|
||||
NS_IMETHOD GetNonBlocking(PRBool * nonBlocking)
|
||||
{ return mOutput->GetNonBlocking(nonBlocking); }
|
||||
|
||||
NS_IMETHOD SetNonBlocking(PRBool nonBlocking)
|
||||
{ return mOutput->SetNonBlocking(nonBlocking); }
|
||||
|
||||
NS_IMETHOD GetObserver(nsIOutputStreamObserver ** observer)
|
||||
{ return mOutput->GetObserver(observer); }
|
||||
|
||||
NS_IMETHOD SetObserver(nsIOutputStreamObserver * observer)
|
||||
{ return mOutput->SetObserver(observer); }
|
||||
|
||||
nsOutputStreamWrapper(nsCacheEntryDescriptor * descriptor,
|
||||
nsIOutputStream * output)
|
||||
: mDescriptor(nsnull), mOutput(output)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
NS_ADDREF(mDescriptor = descriptor);
|
||||
}
|
||||
|
||||
virtual ~nsOutputStreamWrapper()
|
||||
{
|
||||
NS_RELEASE(mDescriptor);
|
||||
}
|
||||
|
||||
nsresult Init();
|
||||
|
||||
|
||||
private:
|
||||
nsresult OnWrite(PRUint32 count);
|
||||
}; // end of class nsOutputStreamWrapper
|
||||
friend class nsOutputStreamWrapper;
|
||||
|
||||
|
||||
|
||||
static nsresult NewOutputStreamWrapper(nsIOutputStream ** result,
|
||||
nsCacheEntryDescriptor * descriptor,
|
||||
nsIOutputStream * output);
|
||||
private:
|
||||
/**
|
||||
* nsCacheEntryDescriptor data members
|
||||
*/
|
||||
nsCacheEntry * mCacheEntry; // we are a child of the entry
|
||||
nsCacheAccessMode mAccessGranted;
|
||||
nsTransportWrapper mTransportWrapper;
|
||||
};
|
||||
|
||||
|
||||
#endif // _nsCacheEntryDescriptor_h_
|
||||
327
mozilla/netwerk/cache/src/nsCacheMetaData.cpp
vendored
Normal file
327
mozilla/netwerk/cache/src/nsCacheMetaData.cpp
vendored
Normal file
@@ -0,0 +1,327 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheMetaData.cpp, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan, 22-February-2001
|
||||
*/
|
||||
|
||||
#include "nsCacheMetaData.h"
|
||||
#include "nsString.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
|
||||
|
||||
/*
|
||||
* nsCacheClientHashTable
|
||||
*/
|
||||
|
||||
PLDHashTableOps
|
||||
nsCacheMetaData::ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
GetKey,
|
||||
HashKey,
|
||||
MatchEntry,
|
||||
MoveEntry,
|
||||
ClearEntry,
|
||||
Finalize
|
||||
};
|
||||
|
||||
|
||||
nsCacheMetaData::nsCacheMetaData()
|
||||
: initialized(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
nsCacheMetaData::~nsCacheMetaData()
|
||||
{
|
||||
if (initialized)
|
||||
PL_DHashTableFinish(&table);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheMetaData::Init()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
initialized = PL_DHashTableInit(&table, &ops, nsnull,
|
||||
sizeof(nsCacheMetaDataHashTableEntry), 16);
|
||||
|
||||
if (!initialized) rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsCacheMetaData *
|
||||
nsCacheMetaData::Create()
|
||||
{
|
||||
nsCacheMetaData * metaData = new nsCacheMetaData();
|
||||
if (!metaData)
|
||||
return nsnull;
|
||||
|
||||
nsresult rv = metaData->Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
delete metaData;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return metaData;
|
||||
}
|
||||
|
||||
|
||||
nsAReadableCString *
|
||||
nsCacheMetaData::GetElement(const nsAReadableCString * key)
|
||||
{
|
||||
PLDHashEntryHdr * hashEntry;
|
||||
nsCString * result = nsnull;
|
||||
|
||||
// XXX need to copy string until we have scc's new flat string abstract class
|
||||
// XXX see nsCacheMetaData::HashKey below (bug 70075)
|
||||
nsCString * tempKey = new nsCString(*key);
|
||||
if (!tempKey) return result;
|
||||
|
||||
NS_ASSERTION(initialized, "nsCacheMetaDataHashTable not initialized");
|
||||
hashEntry = PL_DHashTableOperate(&table, tempKey, PL_DHASH_LOOKUP);
|
||||
if (PL_DHASH_ENTRY_IS_BUSY(hashEntry)) {
|
||||
result = ((nsCacheMetaDataHashTableEntry *)hashEntry)->value;
|
||||
}
|
||||
|
||||
delete tempKey;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheMetaData::SetElement(const nsAReadableCString& key,
|
||||
const nsAReadableCString& value)
|
||||
{
|
||||
nsCacheMetaDataHashTableEntry * metaEntry;
|
||||
nsresult rv = NS_ERROR_OUT_OF_MEMORY; // presume the worst
|
||||
|
||||
NS_ASSERTION(initialized, "nsCacheMetaDataHashTable not initialized");
|
||||
|
||||
// XXX need to copy string until we have scc's new flat string abstract class
|
||||
// XXX see nsCacheMetaData::HashKey below (bug 70075)
|
||||
nsCString * tempKey = new nsCString(key);
|
||||
if (!tempKey) return rv;
|
||||
|
||||
// XXX should empty value remove the key?
|
||||
|
||||
metaEntry = (nsCacheMetaDataHashTableEntry *)
|
||||
PL_DHashTableOperate(&table, tempKey, PL_DHASH_ADD);
|
||||
if (!metaEntry) goto error_exit;
|
||||
|
||||
|
||||
if (metaEntry->key == nsnull) {
|
||||
metaEntry->key = new nsCString(key);
|
||||
if (metaEntry->key == nsnull) {
|
||||
goto error_exit;
|
||||
}
|
||||
}
|
||||
if (metaEntry->value != nsnull)
|
||||
delete metaEntry->value; // clear the old value
|
||||
|
||||
metaEntry->value = new nsCString(value);
|
||||
if (metaEntry->value == nsnull) {
|
||||
// XXX remove key?
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
rv = NS_OK;
|
||||
error_exit:
|
||||
delete tempKey;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
PRUint32
|
||||
nsCacheMetaData::Size(void)
|
||||
{
|
||||
PRUint32 size = 0;
|
||||
(void) PL_DHashTableEnumerate(&table, CalculateSize, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheMetaData::FlattenMetaData(char ** data, PRUint32 * size)
|
||||
{
|
||||
*size = 0;
|
||||
|
||||
if (PL_DHashTableEnumerate(&table, CalculateSize, size) != 0 && data) {
|
||||
*data = new char[*size];
|
||||
if (*data == nsnull) return NS_ERROR_OUT_OF_MEMORY;
|
||||
char* state = *data;
|
||||
PL_DHashTableEnumerate(&table, AccumulateElement, &state);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCacheMetaData::UnflattenMetaData(char * data, PRUint32 size)
|
||||
{
|
||||
nsresult rv = NS_ERROR_UNEXPECTED;
|
||||
char* limit = data + size;
|
||||
while (data < limit) {
|
||||
const char* name = data;
|
||||
PRUint32 nameSize = nsCRT::strlen(name);
|
||||
data += 1 + nameSize;
|
||||
if (data < limit) {
|
||||
const char* value = data;
|
||||
PRUint32 valueSize = nsCRT::strlen(value);
|
||||
data += 1 + valueSize;
|
||||
rv = SetElement(nsLocalCString(name, nameSize),
|
||||
nsLocalCString(value, valueSize));
|
||||
if (NS_FAILED(rv)) break;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCacheMetaData::VisitElements(nsICacheMetaDataVisitor * visitor)
|
||||
{
|
||||
(void) PL_DHashTableEnumerate(&table, VisitElement, visitor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* hash table operation callback functions
|
||||
*/
|
||||
|
||||
const void * PR_CALLBACK
|
||||
nsCacheMetaData::GetKey( PLDHashTable * /* table */, PLDHashEntryHdr *hashEntry)
|
||||
{
|
||||
return ((nsCacheMetaDataHashTableEntry *)hashEntry)->key;
|
||||
}
|
||||
|
||||
|
||||
PLDHashNumber PR_CALLBACK
|
||||
nsCacheMetaData::HashKey( PLDHashTable * table, const void *key)
|
||||
{
|
||||
// XXX need scc's new flat string abstract class here (bug 70075)
|
||||
return PL_DHashStringKey(table, ((nsCString *)key)->get());
|
||||
}
|
||||
|
||||
|
||||
PRBool PR_CALLBACK
|
||||
nsCacheMetaData::MatchEntry(PLDHashTable * /* table */,
|
||||
const PLDHashEntryHdr * hashEntry,
|
||||
const void * key)
|
||||
{
|
||||
NS_ASSERTION(key != nsnull, "### nsCacheMetaDataHashTable::MatchEntry : null key");
|
||||
nsCString * entryKey = ((nsCacheMetaDataHashTableEntry *)hashEntry)->key;
|
||||
NS_ASSERTION(entryKey, "### hashEntry->key == nsnull");
|
||||
|
||||
return entryKey->Equals(*NS_STATIC_CAST(const nsAReadableCString*,key));
|
||||
}
|
||||
|
||||
|
||||
void PR_CALLBACK
|
||||
nsCacheMetaData::MoveEntry(PLDHashTable * /* table */,
|
||||
const PLDHashEntryHdr *from,
|
||||
PLDHashEntryHdr *to)
|
||||
{
|
||||
((nsCacheMetaDataHashTableEntry *)to)->key =
|
||||
((nsCacheMetaDataHashTableEntry *)from)->key;
|
||||
((nsCacheMetaDataHashTableEntry *)to)->value =
|
||||
((nsCacheMetaDataHashTableEntry *)from)->value;
|
||||
}
|
||||
|
||||
|
||||
void PR_CALLBACK
|
||||
nsCacheMetaData::ClearEntry(PLDHashTable * /* table */,
|
||||
PLDHashEntryHdr * hashEntry)
|
||||
{
|
||||
((nsCacheMetaDataHashTableEntry *)hashEntry)->key = 0;
|
||||
((nsCacheMetaDataHashTableEntry *)hashEntry)->value = 0;
|
||||
}
|
||||
|
||||
|
||||
void PR_CALLBACK
|
||||
nsCacheMetaData::Finalize(PLDHashTable * table)
|
||||
{
|
||||
(void) PL_DHashTableEnumerate(table, FreeElement, nsnull);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hash table enumeration callback functions
|
||||
*/
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
nsCacheMetaData::CalculateSize(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hdr,
|
||||
PRUint32 number,
|
||||
void *arg)
|
||||
{
|
||||
nsCacheMetaDataHashTableEntry* hashEntry = (nsCacheMetaDataHashTableEntry *)hdr;
|
||||
*(PRUint32*)arg += (2 + hashEntry->key->Length() + hashEntry->value->Length());
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
nsCacheMetaData::AccumulateElement(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hdr,
|
||||
PRUint32 number,
|
||||
void *arg)
|
||||
{
|
||||
char** bufferPtr = (char**) arg;
|
||||
nsCacheMetaDataHashTableEntry* hashEntry = (nsCacheMetaDataHashTableEntry *)hdr;
|
||||
PRUint32 size = 1 + hashEntry->key->Length();
|
||||
nsCRT::memcpy(*bufferPtr, hashEntry->key->get(), size);
|
||||
*bufferPtr += size;
|
||||
size = 1 + hashEntry->value->Length();
|
||||
nsCRT::memcpy(*bufferPtr, hashEntry->value->get(), size);
|
||||
*bufferPtr += size;
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
nsCacheMetaData::FreeElement(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hdr,
|
||||
PRUint32 number,
|
||||
void *arg)
|
||||
{
|
||||
nsCacheMetaDataHashTableEntry *entry = (nsCacheMetaDataHashTableEntry *)hdr;
|
||||
delete entry->key;
|
||||
delete entry->value;
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
nsCacheMetaData::VisitElement(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hdr,
|
||||
PRUint32 number,
|
||||
void *arg)
|
||||
{
|
||||
nsCacheMetaDataHashTableEntry *entry = (nsCacheMetaDataHashTableEntry *)hdr;
|
||||
nsICacheMetaDataVisitor *visitor = (nsICacheMetaDataVisitor *)arg;
|
||||
const char * key = entry->key ? entry->key->get() : nsnull;
|
||||
const char * value = entry->value ? entry->value->get() : nsnull;
|
||||
|
||||
PRBool keepGoing;
|
||||
nsresult rv = visitor->VisitMetaDataElement(key, value, &keepGoing);
|
||||
|
||||
return NS_SUCCEEDED(rv) && keepGoing ? PL_DHASH_NEXT : PL_DHASH_STOP;
|
||||
}
|
||||
119
mozilla/netwerk/cache/src/nsCacheMetaData.h
vendored
Normal file
119
mozilla/netwerk/cache/src/nsCacheMetaData.h
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheMetaData.h, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan, 22-February-2001
|
||||
*/
|
||||
|
||||
#ifndef _nsCacheMetaData_h_
|
||||
#define _nsCacheMetaData_h_
|
||||
|
||||
#include "nspr.h"
|
||||
#include "pldhash.h"
|
||||
#include "nscore.h"
|
||||
// #include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
// #include "nsAReadableString.h"
|
||||
|
||||
class nsICacheMetaDataVisitor;
|
||||
|
||||
typedef struct {
|
||||
nsCString * key;
|
||||
nsCString * value;
|
||||
} nsCacheMetaDataKeyValuePair;
|
||||
|
||||
|
||||
typedef struct {
|
||||
PLDHashNumber keyHash;
|
||||
nsCString * key;
|
||||
nsCString * value;
|
||||
} nsCacheMetaDataHashTableEntry;
|
||||
|
||||
|
||||
class nsCacheMetaData {
|
||||
public:
|
||||
nsCacheMetaData();
|
||||
~nsCacheMetaData();
|
||||
|
||||
static
|
||||
nsCacheMetaData * Create(void);
|
||||
|
||||
nsresult Init(void);
|
||||
|
||||
nsAReadableCString * GetElement(const nsAReadableCString * key);
|
||||
|
||||
nsresult SetElement(const nsAReadableCString& key,
|
||||
const nsAReadableCString& value);
|
||||
|
||||
PRUint32 Size(void);
|
||||
|
||||
nsresult FlattenMetaData(char ** data, PRUint32 * size);
|
||||
|
||||
nsresult UnflattenMetaData(char * data, PRUint32 size);
|
||||
|
||||
nsresult VisitElements(nsICacheMetaDataVisitor * visitor);
|
||||
|
||||
private:
|
||||
// PLDHashTable operation callbacks
|
||||
static const void * PR_CALLBACK GetKey( PLDHashTable *table, PLDHashEntryHdr *entry);
|
||||
|
||||
static PLDHashNumber PR_CALLBACK HashKey( PLDHashTable *table, const void *key);
|
||||
|
||||
static PRBool PR_CALLBACK MatchEntry( PLDHashTable * table,
|
||||
const PLDHashEntryHdr * entry,
|
||||
const void * key);
|
||||
|
||||
static void PR_CALLBACK MoveEntry( PLDHashTable *table,
|
||||
const PLDHashEntryHdr *from,
|
||||
PLDHashEntryHdr *to);
|
||||
|
||||
static void PR_CALLBACK ClearEntry( PLDHashTable *table, PLDHashEntryHdr *entry);
|
||||
|
||||
static void PR_CALLBACK Finalize( PLDHashTable *table);
|
||||
|
||||
static
|
||||
PLDHashOperator PR_CALLBACK CalculateSize(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hdr,
|
||||
PRUint32 number,
|
||||
void *arg);
|
||||
|
||||
static
|
||||
PLDHashOperator PR_CALLBACK AccumulateElement(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hdr,
|
||||
PRUint32 number,
|
||||
void *arg);
|
||||
|
||||
static
|
||||
PLDHashOperator PR_CALLBACK FreeElement(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hdr,
|
||||
PRUint32 number,
|
||||
void *arg);
|
||||
static
|
||||
PLDHashOperator PR_CALLBACK VisitElement(PLDHashTable *table,
|
||||
PLDHashEntryHdr *hdr,
|
||||
PRUint32 number,
|
||||
void *arg);
|
||||
|
||||
// member variables
|
||||
static PLDHashTableOps ops;
|
||||
PLDHashTable table;
|
||||
PRBool initialized;
|
||||
};
|
||||
|
||||
#endif // _nsCacheMetaData_h
|
||||
41
mozilla/netwerk/cache/src/nsCacheModule.cpp
vendored
Normal file
41
mozilla/netwerk/cache/src/nsCacheModule.cpp
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheModule.cpp, released February 23, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsCacheService.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
// nsCacheService
|
||||
//
|
||||
|
||||
static nsModuleComponentInfo gResComponents[] = {
|
||||
{
|
||||
NS_CACHESERVICE_CLASSNAME,
|
||||
NS_CACHESERVICE_CID,
|
||||
NS_CACHESERVICE_CONTRACTID,
|
||||
nsCacheService::Create
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(cacheservice, gResComponents)
|
||||
171
mozilla/netwerk/cache/src/nsCacheRequest.h
vendored
Normal file
171
mozilla/netwerk/cache/src/nsCacheRequest.h
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheRequest.h, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan, 22-February-2001
|
||||
*/
|
||||
|
||||
#ifndef _nsCacheRequest_h_
|
||||
#define _nsCacheRequest_h_
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICache.h"
|
||||
#include "nsICacheListener.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsCacheSession.h"
|
||||
|
||||
|
||||
class nsCacheRequest : public PRCList
|
||||
{
|
||||
private:
|
||||
friend class nsCacheService;
|
||||
friend class nsCacheEntry;
|
||||
|
||||
nsCacheRequest( nsCString * key,
|
||||
nsICacheListener * listener,
|
||||
nsCacheAccessMode accessRequested,
|
||||
nsCacheSession * session)
|
||||
: mKey(key),
|
||||
mInfo(0),
|
||||
mListener(listener),
|
||||
mEventQ(nsnull),
|
||||
mLock(nsnull),
|
||||
mCondVar(nsnull)
|
||||
{
|
||||
PR_INIT_CLIST(this);
|
||||
SetAccessRequested(accessRequested);
|
||||
SetStoragePolicy(session->StoragePolicy());
|
||||
if (session->IsStreamBased()) MarkStreamBased();
|
||||
if (session->WillDoomEntriesIfExpired()) MarkDoomEntriesIfExpired();
|
||||
MarkWaitingForValidation();
|
||||
}
|
||||
|
||||
~nsCacheRequest()
|
||||
{
|
||||
delete mKey;
|
||||
if (mLock) PR_DestroyLock(mLock);
|
||||
if (mCondVar) PR_DestroyCondVar(mCondVar);
|
||||
NS_ASSERTION(PR_CLIST_IS_EMPTY(this), "request still on a list");
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple Accessors
|
||||
*/
|
||||
enum CacheRequestInfo {
|
||||
eStoragePolicyMask = 0x000000FF,
|
||||
eStreamBasedMask = 0x00000100,
|
||||
eDoomEntriesIfExpiredMask = 0x00001000,
|
||||
eWaitingForValidationMask = 0x00010000,
|
||||
eAccessRequestedMask = 0xFF000000
|
||||
};
|
||||
|
||||
void SetAccessRequested(nsCacheAccessMode mode)
|
||||
{
|
||||
NS_ASSERTION(mode <= 0xFF, "too many bits in nsCacheAccessMode");
|
||||
mInfo &= ~eAccessRequestedMask;
|
||||
mInfo |= mode << 24;
|
||||
}
|
||||
|
||||
nsCacheAccessMode AccessRequested()
|
||||
{
|
||||
return (nsCacheAccessMode)((mInfo >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
void MarkStreamBased() { mInfo |= eStreamBasedMask; }
|
||||
PRBool IsStreamBased() { return (mInfo & eStreamBasedMask) != 0; }
|
||||
|
||||
|
||||
void MarkDoomEntriesIfExpired() { mInfo |= eDoomEntriesIfExpiredMask; }
|
||||
PRBool WillDoomEntriesIfExpired() { return (mInfo & eDoomEntriesIfExpiredMask); }
|
||||
|
||||
void SetStoragePolicy(nsCacheStoragePolicy policy)
|
||||
{
|
||||
NS_ASSERTION(policy <= 0xFF, "too many bits in nsCacheStoragePolicy");
|
||||
mInfo &= ~eStoragePolicyMask; // clear storage policy bits
|
||||
mInfo |= policy; // or in new bits
|
||||
}
|
||||
|
||||
nsCacheStoragePolicy StoragePolicy()
|
||||
{
|
||||
return (nsCacheStoragePolicy)(mInfo & 0xFF);
|
||||
}
|
||||
|
||||
void MarkWaitingForValidation() { mInfo |= eWaitingForValidationMask; }
|
||||
void DoneWaitingForValidation() { mInfo &= ~eWaitingForValidationMask; }
|
||||
PRBool WaitingForValidation()
|
||||
{
|
||||
return (mInfo & eWaitingForValidationMask) != 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WaitForValidation(void)
|
||||
{
|
||||
if (!WaitingForValidation()) { // flag already cleared
|
||||
MarkWaitingForValidation(); // set up for next time
|
||||
return NS_OK; // early exit;
|
||||
}
|
||||
|
||||
if (!mLock) {
|
||||
mLock = PR_NewLock();
|
||||
if (!mLock) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ASSERTION(!mCondVar,"we have mCondVar, but didn't have mLock?");
|
||||
mCondVar = PR_NewCondVar(mLock);
|
||||
if (!mCondVar) {
|
||||
PR_DestroyLock(mLock);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
PRStatus status;
|
||||
PR_Lock(mLock);
|
||||
while (WaitingForValidation() && (status == PR_SUCCESS) ) {
|
||||
status = PR_WaitCondVar(mCondVar, PR_INTERVAL_NO_TIMEOUT);
|
||||
}
|
||||
MarkWaitingForValidation(); // set up for next time
|
||||
PR_Unlock(mLock);
|
||||
|
||||
NS_ASSERTION(status == PR_SUCCESS, "PR_WaitCondVar() returned PR_FAILURE?");
|
||||
if (status == PR_FAILURE)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void WakeUp(void) {
|
||||
DoneWaitingForValidation();
|
||||
if (mLock) {
|
||||
PR_Lock(mLock);
|
||||
PR_NotifyCondVar(mCondVar);
|
||||
PR_Unlock(mLock);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data members
|
||||
*/
|
||||
nsCString * mKey;
|
||||
PRUint32 mInfo;
|
||||
nsCOMPtr<nsICacheListener> mListener;
|
||||
nsCOMPtr<nsIEventQueue> mEventQ;
|
||||
PRLock * mLock;
|
||||
PRCondVar * mCondVar;
|
||||
};
|
||||
|
||||
#endif // _nsCacheRequest_h_
|
||||
1074
mozilla/netwerk/cache/src/nsCacheService.cpp
vendored
Normal file
1074
mozilla/netwerk/cache/src/nsCacheService.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
184
mozilla/netwerk/cache/src/nsCacheService.h
vendored
Normal file
184
mozilla/netwerk/cache/src/nsCacheService.h
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheService.h, released February 10, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _nsCacheService_h_
|
||||
#define _nsCacheService_h_
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsCacheSession.h"
|
||||
#include "nsCacheDevice.h"
|
||||
#include "nsCacheEntry.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsCacheRequest;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheService
|
||||
******************************************************************************/
|
||||
|
||||
class nsCacheService : public nsICacheService, public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICACHESERVICE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
nsCacheService();
|
||||
virtual ~nsCacheService();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* outer, const nsIID& iid, void* *result);
|
||||
|
||||
|
||||
/**
|
||||
* Methods called by nsCacheSession
|
||||
*/
|
||||
nsresult OpenCacheEntry(nsCacheSession * session,
|
||||
const char * key,
|
||||
nsCacheAccessMode accessRequested,
|
||||
nsICacheListener * listener,
|
||||
nsICacheEntryDescriptor ** result);
|
||||
|
||||
/**
|
||||
* Methods called by nsCacheEntryDescriptor
|
||||
*/
|
||||
|
||||
nsresult OnDataSizeChange(nsCacheEntry * entry, PRInt32 deltaSize);
|
||||
|
||||
nsresult ValidateEntry(nsCacheEntry * entry);
|
||||
|
||||
nsresult GetTransportForEntry(nsCacheEntry * entry,
|
||||
nsCacheAccessMode mode,
|
||||
nsITransport ** result);
|
||||
|
||||
void CloseDescriptor(nsCacheEntryDescriptor * descriptor);
|
||||
|
||||
nsresult GetFileForEntry(nsCacheEntry * entry,
|
||||
nsIFile ** result);
|
||||
|
||||
/**
|
||||
* Methods called by any cache classes
|
||||
*/
|
||||
|
||||
static
|
||||
nsCacheService * GlobalInstance(void) { return gService; };
|
||||
|
||||
nsresult DoomEntry(nsCacheEntry * entry);
|
||||
|
||||
nsresult DoomEntry_Locked(nsCacheEntry * entry);
|
||||
|
||||
/**
|
||||
* Methods called by nsCachePrefObserver
|
||||
*/
|
||||
void SetCacheDevicesEnabled(PRBool disk, PRBool memory);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Internal Methods
|
||||
*/
|
||||
|
||||
nsresult CreateDiskDevice();
|
||||
nsresult CreateMemoryDevice();
|
||||
|
||||
nsresult CreateRequest(nsCacheSession * session,
|
||||
const char * clientKey,
|
||||
nsCacheAccessMode accessRequested,
|
||||
nsICacheListener * listener,
|
||||
nsCacheRequest ** request);
|
||||
|
||||
nsresult NotifyListener(nsCacheRequest * request,
|
||||
nsICacheEntryDescriptor * descriptor,
|
||||
nsCacheAccessMode accessGranted,
|
||||
nsresult error);
|
||||
|
||||
nsresult ActivateEntry(nsCacheRequest * request, nsCacheEntry ** entry);
|
||||
|
||||
nsCacheDevice * EnsureEntryHasDevice(nsCacheEntry * entry);
|
||||
|
||||
nsCacheEntry * SearchCacheDevices(nsCString * key, nsCacheStoragePolicy policy);
|
||||
|
||||
void DeactivateEntry(nsCacheEntry * entry);
|
||||
|
||||
nsresult ProcessRequest(nsCacheRequest * request,
|
||||
nsICacheEntryDescriptor ** result);
|
||||
|
||||
nsresult ProcessPendingRequests(nsCacheEntry * entry);
|
||||
|
||||
void ClearPendingRequests(nsCacheEntry * entry);
|
||||
void ClearDoomList(void);
|
||||
void ClearActiveEntries(void);
|
||||
|
||||
static
|
||||
PLDHashOperator PR_CALLBACK DeactivateAndClearEntry(PLDHashTable * table,
|
||||
PLDHashEntryHdr * hdr,
|
||||
PRUint32 number,
|
||||
void * arg);
|
||||
#if defined(PR_LOGGING)
|
||||
void LogCacheStatistics();
|
||||
#endif
|
||||
/**
|
||||
* Data Members
|
||||
*/
|
||||
|
||||
enum {
|
||||
cacheServiceActiveMask = 1
|
||||
};
|
||||
|
||||
static nsCacheService * gService; // there can be only one...
|
||||
|
||||
PRLock* mCacheServiceLock;
|
||||
|
||||
PRBool mEnableMemoryDevice;
|
||||
PRBool mEnableDiskDevice;
|
||||
|
||||
nsCacheDevice * mMemoryDevice;
|
||||
nsCacheDevice * mDiskDevice;
|
||||
|
||||
// nsCacheClientHashTable mClientIDs;
|
||||
nsCacheEntryHashTable mActiveEntries;
|
||||
PRCList mDoomedEntries;
|
||||
|
||||
// stats
|
||||
|
||||
PRUint32 mTotalEntries;
|
||||
PRUint32 mCacheHits;
|
||||
PRUint32 mCacheMisses;
|
||||
PRUint32 mMaxKeyLength;
|
||||
PRUint32 mMaxDataSize;
|
||||
PRUint32 mMaxMetaSize;
|
||||
|
||||
// Unexpected error totals
|
||||
PRUint32 mDeactivateFailures;
|
||||
PRUint32 mDeactivatedUnboundEntries;
|
||||
};
|
||||
|
||||
|
||||
#endif // _nsCacheService_h_
|
||||
101
mozilla/netwerk/cache/src/nsCacheSession.cpp
vendored
Normal file
101
mozilla/netwerk/cache/src/nsCacheSession.cpp
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheSession.h, released February 23, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsCacheSession.h"
|
||||
#include "nsCacheService.h"
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCacheSession, nsICacheSession)
|
||||
|
||||
nsCacheSession::nsCacheSession(const char * clientID,
|
||||
nsCacheStoragePolicy storagePolicy,
|
||||
PRBool streamBased)
|
||||
: mClientID(clientID),
|
||||
mInfo(0)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
SetStoragePolicy(storagePolicy);
|
||||
|
||||
if (streamBased) MarkStreamBased();
|
||||
else SetStoragePolicy(nsICache::STORE_IN_MEMORY);
|
||||
}
|
||||
|
||||
nsCacheSession::~nsCacheSession()
|
||||
{
|
||||
/* destructor code */
|
||||
// notify service we are going away?
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheSession::GetDoomEntriesIfExpired(PRBool *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
*result = WillDoomEntriesIfExpired();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheSession::SetDoomEntriesIfExpired(PRBool doomEntriesIfExpired)
|
||||
{
|
||||
if (doomEntriesIfExpired) MarkDoomEntriesIfExpired();
|
||||
else ClearDoomEntriesIfExpired();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheSession::OpenCacheEntry(const char * key,
|
||||
nsCacheAccessMode accessRequested,
|
||||
nsICacheEntryDescriptor ** result)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsCacheService::GlobalInstance()->OpenCacheEntry(this,
|
||||
key,
|
||||
accessRequested,
|
||||
nsnull, // no listener
|
||||
result);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCacheSession::AsyncOpenCacheEntry(const char *key,
|
||||
nsCacheAccessMode accessRequested,
|
||||
nsICacheListener *listener)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = nsCacheService::GlobalInstance()->OpenCacheEntry(this,
|
||||
key,
|
||||
accessRequested,
|
||||
listener,
|
||||
nsnull); // no result
|
||||
|
||||
if (rv == NS_ERROR_CACHE_WAIT_FOR_VALIDATION) rv = NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCacheSession::EvictEntries()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
76
mozilla/netwerk/cache/src/nsCacheSession.h
vendored
Normal file
76
mozilla/netwerk/cache/src/nsCacheSession.h
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheSession.h, released February 23, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick Beard <beard@netscape.com>
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _nsCacheSession_h_
|
||||
#define _nsCacheSession_h_
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsError.h"
|
||||
#include "nsICacheSession.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsCacheSession : public nsICacheSession
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICACHESESSION
|
||||
|
||||
nsCacheSession(const char * clientID, nsCacheStoragePolicy storagePolicy, PRBool streamBased);
|
||||
virtual ~nsCacheSession();
|
||||
|
||||
nsCString * ClientID() { return &mClientID; }
|
||||
|
||||
enum SessionInfo {
|
||||
eStoragePolicyMask = 0x000000FF,
|
||||
eStreamBasedMask = 0x00000100,
|
||||
eDoomEntriesIfExpiredMask = 0x00001000
|
||||
};
|
||||
|
||||
void MarkStreamBased() { mInfo |= eStreamBasedMask; }
|
||||
void ClearStreamBased() { mInfo &= ~eStreamBasedMask; }
|
||||
PRBool IsStreamBased() { return (mInfo & eStreamBasedMask) != 0; }
|
||||
|
||||
void MarkDoomEntriesIfExpired() { mInfo |= eDoomEntriesIfExpiredMask; }
|
||||
void ClearDoomEntriesIfExpired() { mInfo &= ~eDoomEntriesIfExpiredMask; }
|
||||
PRBool WillDoomEntriesIfExpired() { return (mInfo & eDoomEntriesIfExpiredMask); }
|
||||
|
||||
nsCacheStoragePolicy StoragePolicy()
|
||||
{
|
||||
return (nsCacheStoragePolicy)(mInfo & eStoragePolicyMask);
|
||||
}
|
||||
|
||||
void SetStoragePolicy(nsCacheStoragePolicy policy)
|
||||
{
|
||||
NS_ASSERTION(policy <= 0xFF, "too many bits in nsCacheStoragePolicy");
|
||||
mInfo &= ~eStoragePolicyMask; // clear storage policy bits
|
||||
mInfo |= policy;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCString mClientID;
|
||||
PRUint32 mInfo;
|
||||
};
|
||||
|
||||
#endif // _nsCacheSession_h_
|
||||
199
mozilla/netwerk/cache/src/nsDiskCache.h
vendored
Normal file
199
mozilla/netwerk/cache/src/nsDiskCache.h
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsCacheDevice.h, released March 9, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick Beard <beard@netscape.com>
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _nsDiskCache_h_
|
||||
#define _nsDiskCache_h_
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "prnetdb.h"
|
||||
#include "nsDebug.h"
|
||||
|
||||
class nsDiskCacheRecord {
|
||||
enum {
|
||||
eEvictionRankMask = 0xFF000000,
|
||||
eLocationSelectorMask = 0x00C00000,
|
||||
|
||||
eExtraBlocksMask = 0x00300000,
|
||||
eBlockNumberMask = 0x000FFFFF,
|
||||
|
||||
eFileReservedMask = 0x003F0000,
|
||||
eFileGenerationMask = 0x0000FFFF
|
||||
};
|
||||
|
||||
public:
|
||||
nsDiskCacheRecord()
|
||||
: mHashNumber(0), mEvictionRank(0), mLocation(0), mUnused(0)
|
||||
{
|
||||
}
|
||||
|
||||
PRUint32 HashNumber() const
|
||||
{
|
||||
return mHashNumber;
|
||||
}
|
||||
|
||||
void SetHashNumber(PRUint32 hashNumber)
|
||||
{
|
||||
mHashNumber = hashNumber;
|
||||
}
|
||||
|
||||
PRUint32 EvictionRank() const
|
||||
{
|
||||
return mEvictionRank;
|
||||
}
|
||||
|
||||
void SetEvictionRank(PRUint32 rank)
|
||||
{
|
||||
mEvictionRank = rank;
|
||||
}
|
||||
|
||||
PRUint32 LocationSelector() const
|
||||
{
|
||||
return (PRUint32)(mLocation & eLocationSelectorMask) >> 22;
|
||||
}
|
||||
|
||||
void SetLocationSelector(PRUint32 selector)
|
||||
{
|
||||
mLocation &= ~eLocationSelectorMask; // clear location selector bits
|
||||
mLocation |= (selector & eLocationSelectorMask) << 22;
|
||||
}
|
||||
|
||||
PRUint32 BlockCount() const
|
||||
{
|
||||
return (PRUint32)((mLocation & eExtraBlocksMask) >> 20) + 1;
|
||||
}
|
||||
|
||||
void SetBlockCount(PRUint32 count)
|
||||
{
|
||||
NS_ASSERTION( (count>=1) && (count<=4),"invalid block count");
|
||||
count = --count;
|
||||
mLocation &= ~eExtraBlocksMask; // clear extra blocks bits
|
||||
mLocation |= (count & eExtraBlocksMask) << 20;
|
||||
}
|
||||
|
||||
PRUint32 BlockNumber() const
|
||||
{
|
||||
return (mLocation & eBlockNumberMask);
|
||||
}
|
||||
|
||||
void SetBlockNumber(PRUint32 blockNumber)
|
||||
{
|
||||
mLocation &= ~eBlockNumberMask; // clear block number bits
|
||||
mLocation |= blockNumber & eBlockNumberMask;
|
||||
}
|
||||
|
||||
PRUint16 FileGeneration() const
|
||||
{
|
||||
return (mLocation & eFileGenerationMask);
|
||||
}
|
||||
|
||||
void SetFileGeneration(PRUint16 generation)
|
||||
{
|
||||
mLocation &= ~eFileGenerationMask; // clear file generation bits
|
||||
mLocation |= generation & eFileGenerationMask;
|
||||
}
|
||||
|
||||
void Swap()
|
||||
{
|
||||
mHashNumber = ::PR_htonl(mHashNumber);
|
||||
mEvictionRank = ::PR_htonl(mEvictionRank);
|
||||
mLocation = ::PR_htonl(mLocation);
|
||||
mUnused = ::PR_htonl(mUnused);
|
||||
}
|
||||
|
||||
void Unswap()
|
||||
{
|
||||
mHashNumber = ::PR_ntohl(mHashNumber);
|
||||
mEvictionRank = ::PR_ntohl(mEvictionRank);
|
||||
mLocation = ::PR_ntohl(mLocation);
|
||||
mUnused = ::PR_ntohl(mUnused);
|
||||
}
|
||||
|
||||
private:
|
||||
PRUint32 mHashNumber;
|
||||
PRUint32 mEvictionRank;
|
||||
PRUint32 mLocation;
|
||||
PRUint32 mUnused;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Cache Extent Table
|
||||
|
||||
|
||||
1111 1111 0000 0000 0000 0000 0000 0000 : eEvictionRankMask
|
||||
0000 0000 1100 0000 0000 0000 0000 0000 : eLocationSelectorMask (0-3)
|
||||
0000 0000 0011 0000 0000 0000 0000 0000 : number of extra contiguous blocks 1-4
|
||||
0000 0000 0000 1111 1111 1111 1111 1111 : block# 0-1,048,575
|
||||
|
||||
0000 0000 0011 1111 0000 0000 0000 0000 : eFileReservedMask
|
||||
0000 0000 0000 0000 1111 1111 1111 1111 : eFileGenerationMask
|
||||
|
||||
0 file
|
||||
1 256 bytes
|
||||
2 1024
|
||||
3 4096
|
||||
|
||||
|
||||
log2 of seconds = 5 bits
|
||||
|
||||
log2 minutes hours days years
|
||||
00000 1
|
||||
00001 2
|
||||
00010 4
|
||||
00011 8
|
||||
00100 16
|
||||
00101 32
|
||||
00110 64 1
|
||||
00111 128 2
|
||||
01000 256 4
|
||||
01001 512 8.5
|
||||
01010 1024 17
|
||||
01011 2048 34
|
||||
01100 68
|
||||
01101 136
|
||||
01110 273 11
|
||||
01111 22
|
||||
10000 45.5
|
||||
10001 91
|
||||
10010 182
|
||||
10011 364 1
|
||||
10100 2
|
||||
10101 3
|
||||
10110 4
|
||||
10111
|
||||
11000
|
||||
11001
|
||||
11010
|
||||
11011
|
||||
11100
|
||||
11101
|
||||
11110
|
||||
11111
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#endif // _nsDiskCache_h_
|
||||
1712
mozilla/netwerk/cache/src/nsDiskCacheDevice.cpp
vendored
Normal file
1712
mozilla/netwerk/cache/src/nsDiskCacheDevice.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
121
mozilla/netwerk/cache/src/nsDiskCacheDevice.h
vendored
Normal file
121
mozilla/netwerk/cache/src/nsDiskCacheDevice.h
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsDiskCacheDevice.h, released February 20, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan <gordon@netscape.com>
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _nsDiskCacheDevice_h_
|
||||
#define _nsDiskCacheDevice_h_
|
||||
|
||||
#include "nsCacheDevice.h"
|
||||
#include "nsDiskCacheEntry.h"
|
||||
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
class nsDiskCacheEntry;
|
||||
class nsDiskCacheMap;
|
||||
class nsDiskCacheRecord;
|
||||
|
||||
class nsISupportsArray;
|
||||
class nsIInputStream;
|
||||
class nsIOutputStream;
|
||||
class nsANSIFileStream;
|
||||
|
||||
class nsDiskCacheDevice : public nsCacheDevice {
|
||||
public:
|
||||
nsDiskCacheDevice();
|
||||
virtual ~nsDiskCacheDevice();
|
||||
|
||||
static nsresult Create(nsCacheDevice **result);
|
||||
|
||||
virtual nsresult Init();
|
||||
virtual nsresult Shutdown();
|
||||
|
||||
virtual const char * GetDeviceID(void);
|
||||
virtual nsCacheEntry * FindEntry(nsCString * key);
|
||||
virtual nsresult DeactivateEntry(nsCacheEntry * entry);
|
||||
virtual nsresult BindEntry(nsCacheEntry * entry);
|
||||
virtual void DoomEntry( nsCacheEntry * entry );
|
||||
|
||||
virtual nsresult GetTransportForEntry(nsCacheEntry * entry,
|
||||
nsCacheAccessMode mode,
|
||||
nsITransport ** result);
|
||||
|
||||
virtual nsresult GetFileForEntry(nsCacheEntry * entry,
|
||||
nsIFile ** result);
|
||||
|
||||
virtual nsresult OnDataSizeChange(nsCacheEntry * entry, PRInt32 deltaSize);
|
||||
|
||||
virtual nsresult Visit(nsICacheVisitor * visitor);
|
||||
|
||||
virtual nsresult EvictEntries(const char * clientID);
|
||||
|
||||
/* private: */
|
||||
void setPrefsObserver(nsIObserver* observer);
|
||||
void getPrefsObserver(nsIObserver ** result);
|
||||
void setCacheDirectory(nsILocalFile* directory);
|
||||
void setCacheCapacity(PRUint32 capacity);
|
||||
PRUint32 getCacheCapacity();
|
||||
PRUint32 getCacheSize();
|
||||
PRUint32 getEntryCount();
|
||||
|
||||
nsresult getFileForHashNumber(PLDHashNumber hashNumber, PRBool meta, PRUint32 generation, nsIFile ** result);
|
||||
nsresult getFileForKey(const char* key, PRBool meta, PRUint32 generation, nsIFile ** result);
|
||||
nsresult getFileForDiskCacheEntry(nsDiskCacheEntry * diskEntry, PRBool meta, nsIFile ** result);
|
||||
|
||||
static nsresult getTransportForFile(nsIFile* file, nsCacheAccessMode mode, nsITransport ** result);
|
||||
static nsresult openInputStream(nsIFile* file, nsIInputStream ** result);
|
||||
static nsresult openOutputStream(nsIFile* file, nsIOutputStream ** result);
|
||||
|
||||
nsresult visitEntries(nsICacheVisitor * visitory);
|
||||
|
||||
nsresult readDiskCacheEntry(const char * key, nsDiskCacheEntry ** diskEntry);
|
||||
|
||||
nsresult updateDiskCacheEntries();
|
||||
nsresult updateDiskCacheEntry(nsDiskCacheEntry * diskEntry);
|
||||
nsresult deleteDiskCacheEntry(nsDiskCacheEntry * diskEntry);
|
||||
|
||||
nsresult scavengeDiskCacheEntries(nsDiskCacheEntry * diskEntry);
|
||||
|
||||
nsresult scanDiskCacheEntries(nsISupportsArray ** result);
|
||||
nsresult evictDiskCacheEntries();
|
||||
|
||||
nsresult clobberDiskCache();
|
||||
|
||||
nsresult openCacheMap();
|
||||
nsresult readCacheMap();
|
||||
nsresult writeCacheMap();
|
||||
|
||||
nsresult updateCacheMap(nsDiskCacheEntry * diskEntry);
|
||||
nsresult evictDiskCacheRecord(nsDiskCacheRecord * record);
|
||||
|
||||
private:
|
||||
PRBool mInitialized;
|
||||
nsCOMPtr<nsIObserver> mPrefsObserver;
|
||||
nsCOMPtr<nsILocalFile> mCacheDirectory;
|
||||
nsDiskCacheEntryHashTable mBoundEntries;
|
||||
PRUint32 mCacheCapacity;
|
||||
nsDiskCacheMap* mCacheMap;
|
||||
nsANSIFileStream* mCacheStream;
|
||||
};
|
||||
|
||||
#endif // _nsDiskCacheDevice_h_
|
||||
213
mozilla/netwerk/cache/src/nsDiskCacheEntry.cpp
vendored
Normal file
213
mozilla/netwerk/cache/src/nsDiskCacheEntry.cpp
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsMemoryCacheDevice.cpp, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "nsDiskCacheEntry.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS0(nsDiskCacheEntry);
|
||||
|
||||
PLDHashNumber
|
||||
nsDiskCacheEntry::Hash(const char* key)
|
||||
{
|
||||
PLDHashNumber h = 0;
|
||||
for (const PRUint8* s = (PRUint8*) key; *s != '\0'; ++s)
|
||||
h = (h >> (PL_DHASH_BITS - 4)) ^ (h << 4) ^ *s;
|
||||
return (h == 0 ? ULONG_MAX : h);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* nsCacheEntryHashTable
|
||||
*****************************************************************************/
|
||||
|
||||
PLDHashTableOps nsDiskCacheEntryHashTable::ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
GetKey,
|
||||
HashKey,
|
||||
MatchEntry,
|
||||
MoveEntry,
|
||||
ClearEntry,
|
||||
Finalize
|
||||
};
|
||||
|
||||
nsDiskCacheEntryHashTable::nsDiskCacheEntryHashTable()
|
||||
: initialized(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsDiskCacheEntryHashTable::~nsDiskCacheEntryHashTable()
|
||||
{
|
||||
if (initialized)
|
||||
PL_DHashTableFinish(&table);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsDiskCacheEntryHashTable::Init()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
initialized = PL_DHashTableInit(&table, &ops, nsnull,
|
||||
sizeof(HashTableEntry), 512);
|
||||
|
||||
if (!initialized) rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsDiskCacheEntry *
|
||||
nsDiskCacheEntryHashTable::GetEntry(const char * key)
|
||||
{
|
||||
return GetEntry(nsDiskCacheEntry::Hash(key));
|
||||
}
|
||||
|
||||
|
||||
nsDiskCacheEntry *
|
||||
nsDiskCacheEntryHashTable::GetEntry(PLDHashNumber key)
|
||||
{
|
||||
nsDiskCacheEntry * result = nsnull;
|
||||
NS_ASSERTION(initialized, "nsDiskCacheEntryHashTable not initialized");
|
||||
HashTableEntry * hashEntry;
|
||||
hashEntry = (HashTableEntry*) PL_DHashTableOperate(&table, (void*) key, PL_DHASH_LOOKUP);
|
||||
if (PL_DHASH_ENTRY_IS_BUSY(hashEntry)) {
|
||||
result = hashEntry->mDiskCacheEntry;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsDiskCacheEntryHashTable::AddEntry(nsDiskCacheEntry * entry)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(entry);
|
||||
NS_ASSERTION(initialized, "nsDiskCacheEntryHashTable not initialized");
|
||||
|
||||
HashTableEntry * hashEntry;
|
||||
hashEntry = (HashTableEntry *) PL_DHashTableOperate(&table,
|
||||
(void*) entry->getHashNumber(),
|
||||
PL_DHASH_ADD);
|
||||
if (!hashEntry) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(hashEntry->mDiskCacheEntry = entry);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsDiskCacheEntryHashTable::RemoveEntry(nsDiskCacheEntry * entry)
|
||||
{
|
||||
NS_ASSERTION(initialized, "nsDiskCacheEntryHashTable not initialized");
|
||||
NS_ASSERTION(entry, "### cacheEntry == nsnull");
|
||||
|
||||
(void) PL_DHashTableOperate(&table, (void*) entry->getHashNumber(), PL_DHASH_REMOVE);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsDiskCacheEntryHashTable::VisitEntries(Visitor *visitor)
|
||||
{
|
||||
PL_DHashTableEnumerate(&table, VisitEntry, visitor);
|
||||
}
|
||||
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
nsDiskCacheEntryHashTable::VisitEntry(PLDHashTable * table,
|
||||
PLDHashEntryHdr * header,
|
||||
PRUint32 number,
|
||||
void * arg)
|
||||
{
|
||||
HashTableEntry* hashEntry = (HashTableEntry *) header;
|
||||
Visitor *visitor = (Visitor*) arg;
|
||||
return (visitor->VisitEntry(hashEntry->mDiskCacheEntry) ? PL_DHASH_NEXT : PL_DHASH_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* hash table operation callback functions
|
||||
*/
|
||||
const void * PR_CALLBACK
|
||||
nsDiskCacheEntryHashTable::GetKey(PLDHashTable * /*table*/, PLDHashEntryHdr * header)
|
||||
{
|
||||
HashTableEntry * hashEntry = (HashTableEntry *) header;
|
||||
return (void*) hashEntry->mDiskCacheEntry->getHashNumber();
|
||||
}
|
||||
|
||||
|
||||
PLDHashNumber PR_CALLBACK
|
||||
nsDiskCacheEntryHashTable::HashKey( PLDHashTable *table, const void *key)
|
||||
{
|
||||
return (PLDHashNumber) key;
|
||||
}
|
||||
|
||||
PRBool PR_CALLBACK
|
||||
nsDiskCacheEntryHashTable::MatchEntry(PLDHashTable * /* table */,
|
||||
const PLDHashEntryHdr * header,
|
||||
const void * key)
|
||||
{
|
||||
HashTableEntry * hashEntry = (HashTableEntry *) header;
|
||||
return (hashEntry->mDiskCacheEntry->getHashNumber() == (PLDHashNumber) key);
|
||||
}
|
||||
|
||||
void PR_CALLBACK
|
||||
nsDiskCacheEntryHashTable::MoveEntry(PLDHashTable * /* table */,
|
||||
const PLDHashEntryHdr * fromHeader,
|
||||
PLDHashEntryHdr * toHeader)
|
||||
{
|
||||
HashTableEntry * fromEntry = (HashTableEntry *) fromHeader;
|
||||
HashTableEntry * toEntry = (HashTableEntry *) toHeader;
|
||||
toEntry->keyHash = fromEntry->keyHash;
|
||||
toEntry->mDiskCacheEntry = fromEntry->mDiskCacheEntry;
|
||||
fromEntry->mDiskCacheEntry = nsnull;
|
||||
}
|
||||
|
||||
|
||||
void PR_CALLBACK
|
||||
nsDiskCacheEntryHashTable::ClearEntry(PLDHashTable * /* table */,
|
||||
PLDHashEntryHdr * header)
|
||||
{
|
||||
HashTableEntry* hashEntry = (HashTableEntry *) header;
|
||||
hashEntry->keyHash = 0;
|
||||
NS_IF_RELEASE(hashEntry->mDiskCacheEntry);
|
||||
}
|
||||
|
||||
|
||||
void PR_CALLBACK
|
||||
nsDiskCacheEntryHashTable::Finalize(PLDHashTable * table)
|
||||
{
|
||||
(void) PL_DHashTableEnumerate(table, FreeCacheEntries, nsnull);
|
||||
}
|
||||
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
nsDiskCacheEntryHashTable::FreeCacheEntries(PLDHashTable * /* table */,
|
||||
PLDHashEntryHdr * header,
|
||||
PRUint32 number,
|
||||
void * arg)
|
||||
{
|
||||
HashTableEntry *entry = (HashTableEntry *) header;
|
||||
NS_IF_RELEASE(entry->mDiskCacheEntry);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
164
mozilla/netwerk/cache/src/nsDiskCacheEntry.h
vendored
Normal file
164
mozilla/netwerk/cache/src/nsDiskCacheEntry.h
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsMemoryCacheDevice.cpp, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _nsDiskCacheEntry_h_
|
||||
#define _nsDiskCacheEntry_h_
|
||||
|
||||
#include "nspr.h"
|
||||
#include "pldhash.h"
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCacheEntry.h"
|
||||
|
||||
#ifdef MOZ_NEW_CACHE_REUSE_TRANSPORTS
|
||||
#include "nsITransport.h"
|
||||
#endif
|
||||
|
||||
class nsDiskCacheEntry : public nsISupports, public PRCList {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsDiskCacheEntry(nsCacheEntry* entry)
|
||||
: mCacheEntry(entry),
|
||||
mGeneration(0)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
PR_INIT_CLIST(this);
|
||||
mHashNumber = Hash(entry->Key()->get());
|
||||
}
|
||||
|
||||
virtual ~nsDiskCacheEntry()
|
||||
{
|
||||
PR_REMOVE_LINK(this);
|
||||
}
|
||||
|
||||
#ifdef MOZ_NEW_CACHE_REUSE_TRANSPORTS
|
||||
/**
|
||||
* Maps a cache access mode to a cached nsITransport for that access
|
||||
* mode. We keep these cached to avoid repeated trips to the
|
||||
* file transport service.
|
||||
*/
|
||||
nsCOMPtr<nsITransport>& getTransport(nsCacheAccessMode mode)
|
||||
{
|
||||
return mTransports[mode - 1];
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCacheEntry* getCacheEntry()
|
||||
{
|
||||
return mCacheEntry;
|
||||
}
|
||||
|
||||
PRUint32 getGeneration()
|
||||
{
|
||||
return mGeneration;
|
||||
}
|
||||
|
||||
void setGeneration(PRUint32 generation)
|
||||
{
|
||||
mGeneration = generation;
|
||||
}
|
||||
|
||||
PLDHashNumber getHashNumber()
|
||||
{
|
||||
return mHashNumber;
|
||||
}
|
||||
|
||||
nsrefcnt getRefCount()
|
||||
{
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
static PLDHashNumber Hash(const char* key);
|
||||
|
||||
private:
|
||||
#ifdef MOZ_NEW_CACHE_REUSE_TRANSPORTS
|
||||
nsCOMPtr<nsITransport> mTransports[3];
|
||||
#endif
|
||||
nsCacheEntry* mCacheEntry;
|
||||
PRUint32 mGeneration;
|
||||
PLDHashNumber mHashNumber;
|
||||
};
|
||||
|
||||
class nsDiskCacheEntryHashTable {
|
||||
public:
|
||||
nsDiskCacheEntryHashTable();
|
||||
~nsDiskCacheEntryHashTable();
|
||||
|
||||
nsresult Init();
|
||||
|
||||
nsDiskCacheEntry * GetEntry(const char * key);
|
||||
nsDiskCacheEntry * GetEntry(PLDHashNumber key);
|
||||
nsresult AddEntry(nsDiskCacheEntry * entry);
|
||||
void RemoveEntry(nsDiskCacheEntry * entry);
|
||||
|
||||
class Visitor {
|
||||
public:
|
||||
virtual PRBool VisitEntry(nsDiskCacheEntry * entry) = 0;
|
||||
};
|
||||
|
||||
void VisitEntries(Visitor * visitor);
|
||||
|
||||
private:
|
||||
struct HashTableEntry : PLDHashEntryHdr {
|
||||
nsDiskCacheEntry * mDiskCacheEntry; // STRONG ref?
|
||||
};
|
||||
|
||||
// PLDHashTable operation callbacks
|
||||
static const void * PR_CALLBACK GetKey(PLDHashTable * table,
|
||||
PLDHashEntryHdr * entry);
|
||||
|
||||
static PLDHashNumber PR_CALLBACK HashKey(PLDHashTable * table,
|
||||
const void * key);
|
||||
|
||||
static PRBool PR_CALLBACK MatchEntry(PLDHashTable * table,
|
||||
const PLDHashEntryHdr * entry,
|
||||
const void * key);
|
||||
|
||||
static void PR_CALLBACK MoveEntry(PLDHashTable * table,
|
||||
const PLDHashEntryHdr * from,
|
||||
PLDHashEntryHdr * to);
|
||||
|
||||
static void PR_CALLBACK ClearEntry(PLDHashTable * table,
|
||||
PLDHashEntryHdr * entry);
|
||||
|
||||
static void PR_CALLBACK Finalize(PLDHashTable *table);
|
||||
|
||||
static
|
||||
PLDHashOperator PR_CALLBACK FreeCacheEntries(PLDHashTable * table,
|
||||
PLDHashEntryHdr * hdr,
|
||||
PRUint32 number,
|
||||
void * arg);
|
||||
static
|
||||
PLDHashOperator PR_CALLBACK VisitEntry(PLDHashTable * table,
|
||||
PLDHashEntryHdr * hdr,
|
||||
PRUint32 number,
|
||||
void * arg);
|
||||
|
||||
// member variables
|
||||
static PLDHashTableOps ops;
|
||||
PLDHashTable table;
|
||||
PRBool initialized;
|
||||
};
|
||||
|
||||
#endif /* _nsDiskCacheEntry_h_ */
|
||||
263
mozilla/netwerk/cache/src/nsDiskCacheMap.cpp
vendored
Normal file
263
mozilla/netwerk/cache/src/nsDiskCacheMap.cpp
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsDiskCacheMap.cpp, released March 23, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsDiskCacheMap.h"
|
||||
#include "nsIFileStreams.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
nsDiskCacheMap::nsDiskCacheMap()
|
||||
{
|
||||
}
|
||||
|
||||
nsDiskCacheMap::~nsDiskCacheMap()
|
||||
{
|
||||
}
|
||||
|
||||
void nsDiskCacheMap::Reset()
|
||||
{
|
||||
mHeader.mDataSize = 0;
|
||||
mHeader.mEntryCount = 0;
|
||||
mHeader.mIsDirty = PR_TRUE;
|
||||
|
||||
for (PRUint32 b = 0; b < kBucketsPerTable; ++b) {
|
||||
nsDiskCacheBucket& bucket = mBuckets[b];
|
||||
::memset(&bucket, 0, sizeof(nsDiskCacheBucket));
|
||||
}
|
||||
}
|
||||
|
||||
nsDiskCacheRecord* nsDiskCacheMap::GetRecord(PRUint32 hashNumber)
|
||||
{
|
||||
nsDiskCacheBucket& bucket = mBuckets[GetBucketIndex(hashNumber)];
|
||||
nsDiskCacheRecord* oldestRecord = &bucket.mRecords[0];
|
||||
|
||||
for (int r = 0; r < kRecordsPerBucket; ++r) {
|
||||
nsDiskCacheRecord* record = &bucket.mRecords[r];
|
||||
if (record->HashNumber() == 0 || record->HashNumber() == hashNumber)
|
||||
return record;
|
||||
if (record->EvictionRank() < oldestRecord->EvictionRank())
|
||||
oldestRecord = record;
|
||||
}
|
||||
// if we don't find an empty record, return the oldest record for eviction.
|
||||
return oldestRecord;
|
||||
}
|
||||
|
||||
|
||||
void nsDiskCacheMap::DeleteRecord(nsDiskCacheRecord* deletedRecord)
|
||||
{
|
||||
PRUint32 hashNumber = deletedRecord->HashNumber();
|
||||
nsDiskCacheBucket& bucket = mBuckets[GetBucketIndex(hashNumber)];
|
||||
NS_ASSERTION(deletedRecord >= &bucket.mRecords[0] &&
|
||||
deletedRecord < &bucket.mRecords[kRecordsPerBucket],
|
||||
"invalid record to delete.");
|
||||
nsDiskCacheRecord* limit = &bucket.mRecords[kRecordsPerBucket];
|
||||
nsDiskCacheRecord* lastRecord = nsnull;
|
||||
// XXX use binary search to find the end, much quicker.
|
||||
// find the last record, to fill in the deleted record.
|
||||
for (nsDiskCacheRecord* record = deletedRecord + 1; record < limit; ++record) {
|
||||
if (record->HashNumber() == 0) {
|
||||
lastRecord = record - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// copy the last record, to the newly deleted record.
|
||||
if (lastRecord && deletedRecord != lastRecord) {
|
||||
*deletedRecord = *lastRecord;
|
||||
deletedRecord = lastRecord;
|
||||
}
|
||||
// mark record as free.
|
||||
deletedRecord->SetHashNumber(0);
|
||||
// reduce the number of entries.
|
||||
mHeader.mEntryCount--;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsDiskCacheMap::Read(nsIInputStream* input)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 count;
|
||||
|
||||
// seek to beginning of the file.
|
||||
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(input, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// read the header.
|
||||
nsDiskCacheHeader header;
|
||||
rv = input->Read((char*)&header, sizeof(header), &count);
|
||||
if (count != sizeof(header)) return NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
header.Unswap();
|
||||
|
||||
// validate the version.
|
||||
if (header.mVersion != nsDiskCacheHeader::kCurrentVersion) return NS_ERROR_FAILURE;
|
||||
mHeader = header;
|
||||
|
||||
// seek to beginning of first bucket.
|
||||
rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, sizeof(nsDiskCacheBucket));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// read the buckets.
|
||||
rv = input->Read((char*)&mBuckets, sizeof(mBuckets), &count);
|
||||
if (count != sizeof(mBuckets)) return NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// unswap all of the active records.
|
||||
for (int b = 0; b < kBucketsPerTable; ++b) {
|
||||
nsDiskCacheBucket& bucket = mBuckets[b];
|
||||
for (int r = 0; r < kRecordsPerBucket; ++r) {
|
||||
nsDiskCacheRecord* record = &bucket.mRecords[r];
|
||||
if (record->HashNumber() == 0)
|
||||
break;
|
||||
record->Unswap();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDiskCacheMap::Write(nsIOutputStream* output)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 count;
|
||||
|
||||
// seek to beginning of the file.
|
||||
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(output, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// write the header.
|
||||
nsDiskCacheHeader header = mHeader;
|
||||
header.Swap();
|
||||
rv = output->Write((char*)&header, sizeof(header), &count);
|
||||
if (count != sizeof(header)) return NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// pad the rest of the header to sizeof(nsDiskCacheBucket).
|
||||
char padding[sizeof(nsDiskCacheBucket) - sizeof(nsDiskCacheHeader)];
|
||||
::memset(padding, 0, sizeof(padding));
|
||||
rv = output->Write(padding, sizeof(padding), &count);
|
||||
if (count != sizeof(padding)) return NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// swap all of the active records.
|
||||
{
|
||||
for (int b = 0; b < kBucketsPerTable; ++b) {
|
||||
nsDiskCacheBucket& bucket = mBuckets[b];
|
||||
for (int r = 0; r < kRecordsPerBucket; ++r) {
|
||||
nsDiskCacheRecord* record = &bucket.mRecords[r];
|
||||
if (record->HashNumber() == 0)
|
||||
break;
|
||||
record->Swap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write the buckets.
|
||||
rv = output->Write((char*)&mBuckets, sizeof(mBuckets), &count);
|
||||
output->Flush();
|
||||
|
||||
// unswap all of the active records.
|
||||
{
|
||||
for (int b = 0; b < kBucketsPerTable; ++b) {
|
||||
nsDiskCacheBucket& bucket = mBuckets[b];
|
||||
for (int r = 0; r < kRecordsPerBucket; ++r) {
|
||||
nsDiskCacheRecord* record = &bucket.mRecords[r];
|
||||
if (record->HashNumber() == 0)
|
||||
break;
|
||||
record->Unswap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count != sizeof(mBuckets)) return NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsDiskCacheMap::WriteBucket(nsIOutputStream* output, PRUint32 index)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// can only do this if the stream is seekable.
|
||||
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(output, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// seek to the offset of this bucket, (index + 1) to skip the header.
|
||||
rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, (index + 1) * sizeof(nsDiskCacheBucket));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsDiskCacheBucket& bucket = mBuckets[index];
|
||||
|
||||
// swap all of the active records.
|
||||
{
|
||||
for (int r = 0; r < kRecordsPerBucket; ++r) {
|
||||
nsDiskCacheRecord* record = &bucket.mRecords[r];
|
||||
if (record->HashNumber() == 0)
|
||||
break;
|
||||
record->Swap();
|
||||
}
|
||||
}
|
||||
|
||||
PRUint32 count;
|
||||
rv = output->Write((char*)&bucket, sizeof(nsDiskCacheBucket), &count);
|
||||
output->Flush();
|
||||
|
||||
// unswap all of the active records.
|
||||
{
|
||||
for (int r = 0; r < kRecordsPerBucket; ++r) {
|
||||
nsDiskCacheRecord* record = &bucket.mRecords[r];
|
||||
if (record->HashNumber() == 0)
|
||||
break;
|
||||
record->Unswap();
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(count == sizeof(nsDiskCacheBucket), "nsDiskCacheMap::WriteBucket failed");
|
||||
if (count != sizeof(nsDiskCacheBucket)) return NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsDiskCacheMap::WriteHeader(nsIOutputStream* output)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 count;
|
||||
|
||||
// can only do this if the stream is seekable.
|
||||
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(output, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// write the header.
|
||||
nsDiskCacheHeader header = mHeader;
|
||||
header.Swap();
|
||||
rv = output->Write((char*)&header, sizeof(header), &count);
|
||||
output->Flush();
|
||||
if (count != sizeof(header)) return NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
117
mozilla/netwerk/cache/src/nsDiskCacheMap.h
vendored
Normal file
117
mozilla/netwerk/cache/src/nsDiskCacheMap.h
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsDiskCacheMap.h, released March 23, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _nsDiskCacheMap_h_
|
||||
|
||||
#include "nsDiskCache.h"
|
||||
#include "nsError.h"
|
||||
|
||||
class nsIInputStream;
|
||||
class nsIOutputStream;
|
||||
|
||||
struct nsDiskCacheHeader {
|
||||
enum { kCurrentVersion = 0x00010002 };
|
||||
|
||||
PRUint32 mVersion; // cache version.
|
||||
PRUint32 mDataSize; // size of cache in bytes.
|
||||
PRUint32 mEntryCount; // number of entries stored in cache.
|
||||
PRUint32 mIsDirty; // dirty flag.
|
||||
// XXX need a bitmap?
|
||||
|
||||
nsDiskCacheHeader()
|
||||
: mVersion(kCurrentVersion), mDataSize(0),
|
||||
mEntryCount(0), mIsDirty(PR_TRUE)
|
||||
{
|
||||
}
|
||||
|
||||
void Swap()
|
||||
{
|
||||
mVersion = ::PR_htonl(mVersion);
|
||||
mDataSize = ::PR_htonl(mDataSize);
|
||||
mEntryCount = ::PR_htonl(mEntryCount);
|
||||
mIsDirty = ::PR_htonl(mIsDirty);
|
||||
}
|
||||
|
||||
void Unswap()
|
||||
{
|
||||
mVersion = ::PR_ntohl(mVersion);
|
||||
mDataSize = ::PR_ntohl(mDataSize);
|
||||
mEntryCount = ::PR_ntohl(mEntryCount);
|
||||
mIsDirty = ::PR_ntohl(mIsDirty);
|
||||
}
|
||||
};
|
||||
|
||||
// XXX initial capacity, enough for 8192 distinct entries.
|
||||
class nsDiskCacheMap {
|
||||
public:
|
||||
nsDiskCacheMap();
|
||||
~nsDiskCacheMap();
|
||||
|
||||
void Reset();
|
||||
|
||||
PRUint32& DataSize() { return mHeader.mDataSize; }
|
||||
PRUint32& EntryCount() { return mHeader.mEntryCount; }
|
||||
PRUint32& IsDirty() { return mHeader.mIsDirty; }
|
||||
|
||||
nsDiskCacheRecord* GetRecord(PRUint32 hashNumber);
|
||||
void DeleteRecord(nsDiskCacheRecord* record);
|
||||
|
||||
enum {
|
||||
kRecordsPerBucket = 256,
|
||||
kBucketsPerTable = (1 << 5) // must be a power of 2!
|
||||
};
|
||||
|
||||
nsDiskCacheRecord* GetBucket(PRUint32 index)
|
||||
{
|
||||
return mBuckets[index].mRecords;
|
||||
}
|
||||
|
||||
PRUint32 GetBucketIndex(PRUint32 hashNumber)
|
||||
{
|
||||
return (hashNumber & (kBucketsPerTable - 1));
|
||||
}
|
||||
|
||||
PRUint32 GetBucketIndex(nsDiskCacheRecord* record)
|
||||
{
|
||||
return GetBucketIndex(record->HashNumber());
|
||||
}
|
||||
|
||||
nsresult Read(nsIInputStream* input);
|
||||
nsresult Write(nsIOutputStream* output);
|
||||
|
||||
nsresult ReadBucket(nsIInputStream* input, PRUint32 index);
|
||||
nsresult WriteBucket(nsIOutputStream* output, PRUint32 index);
|
||||
|
||||
nsresult ReadHeader(nsIInputStream* input);
|
||||
nsresult WriteHeader(nsIOutputStream* output);
|
||||
|
||||
private:
|
||||
struct nsDiskCacheBucket {
|
||||
nsDiskCacheRecord mRecords[kRecordsPerBucket];
|
||||
};
|
||||
|
||||
nsDiskCacheHeader mHeader;
|
||||
nsDiskCacheBucket mBuckets[kBucketsPerTable];
|
||||
};
|
||||
|
||||
#endif // _nsDiskCacheMap_h_
|
||||
442
mozilla/netwerk/cache/src/nsMemoryCacheDevice.cpp
vendored
Normal file
442
mozilla/netwerk/cache/src/nsMemoryCacheDevice.cpp
vendored
Normal file
@@ -0,0 +1,442 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsMemoryCacheDevice.cpp, released February 22, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan, <gordon@netscape.com>
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsMemoryCacheDevice.h"
|
||||
#include "nsCacheService.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsICacheVisitor.h"
|
||||
#include "nsITransport.h"
|
||||
#include "signal.h"
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kStorageTransportCID, NS_STORAGETRANSPORT_CID);
|
||||
|
||||
const char *gMemoryDeviceID = "memory";
|
||||
const char *gMemoryCacheSizePref = "browser.cache.memory_cache_size";
|
||||
|
||||
|
||||
nsMemoryCacheDevice::nsMemoryCacheDevice()
|
||||
: mHardLimit(0),
|
||||
mSoftLimit(0),
|
||||
mTotalSize(0),
|
||||
mInactiveSize(0),
|
||||
mEntryCount(0),
|
||||
mMaxEntryCount(0)
|
||||
{
|
||||
PR_INIT_CLIST(&mEvictionList);
|
||||
}
|
||||
|
||||
nsMemoryCacheDevice::~nsMemoryCacheDevice()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("### starting ~nsMemoryCacheDevice()\n");
|
||||
#endif
|
||||
// XXX dealloc all memory
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
prefs->UnregisterCallback(gMemoryCacheSizePref, MemoryCacheSizeChanged, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int PR_CALLBACK
|
||||
nsMemoryCacheDevice::MemoryCacheSizeChanged(const char * pref, void * closure)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 softLimit = 0;
|
||||
nsMemoryCacheDevice * device = (nsMemoryCacheDevice *)closure;
|
||||
|
||||
NS_WITH_SERVICE(nsIPref, prefs, NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = prefs->GetIntPref(gMemoryCacheSizePref, (PRInt32 *)&softLimit);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
softLimit *= 1024; // convert k into bytes
|
||||
PRUint32 hardLimit = softLimit + 1024*1024*2; // XXX find better limit than +2Meg
|
||||
device->AdjustMemoryLimits(softLimit, hardLimit);
|
||||
|
||||
return 0; // XXX what are we supposed to return?
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMemoryCacheDevice::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = mMemCacheEntries.Init();
|
||||
|
||||
// set some default memory limits, in case prefs aren't available
|
||||
mSoftLimit = 1024 * 1024 * 3;
|
||||
mHardLimit = mSoftLimit + 1024 *1024 * 2;
|
||||
|
||||
// read user prefs for memory cache limits
|
||||
NS_WITH_SERVICE(nsIPref, prefs, NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
||||
rv = prefs->RegisterCallback(gMemoryCacheSizePref, MemoryCacheSizeChanged, this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Initialize the pref
|
||||
MemoryCacheSizeChanged(gMemoryCacheSizePref, this);
|
||||
}
|
||||
|
||||
// Register as a memory pressure observer
|
||||
NS_WITH_SERVICE(nsIObserverService,
|
||||
observerService,
|
||||
NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// XXX rv = observerServcie->AddObserver(this, NS_MEMORY_PRESSURE_TOPIC);
|
||||
}
|
||||
// Ignore failure of memory pressure registration
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMemoryCacheDevice::Shutdown()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const char *
|
||||
nsMemoryCacheDevice::GetDeviceID()
|
||||
{
|
||||
return gMemoryDeviceID;
|
||||
}
|
||||
|
||||
|
||||
nsCacheEntry *
|
||||
nsMemoryCacheDevice::FindEntry(nsCString * key)
|
||||
{
|
||||
nsCacheEntry * entry = mMemCacheEntries.GetEntry(key);
|
||||
if (!entry) return nsnull;
|
||||
|
||||
// move entry to the tail of the eviction list
|
||||
PR_REMOVE_AND_INIT_LINK(entry);
|
||||
PR_APPEND_LINK(entry, &mEvictionList);
|
||||
|
||||
mInactiveSize -= entry->Size();
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMemoryCacheDevice::DeactivateEntry(nsCacheEntry * entry)
|
||||
{
|
||||
if (entry->IsDoomed()) {
|
||||
#if debug
|
||||
// XXX verify we've removed it from mMemCacheEntries & eviction list
|
||||
#endif
|
||||
// update statistics
|
||||
mTotalSize -= entry->Size();
|
||||
--mEntryCount;
|
||||
|
||||
delete entry;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCacheEntry * ourEntry = mMemCacheEntries.GetEntry(entry->Key());
|
||||
NS_ASSERTION(ourEntry, "DeactivateEntry called for an entry we don't have!");
|
||||
NS_ASSERTION(entry == ourEntry, "entry doesn't match ourEntry");
|
||||
if (ourEntry != entry)
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
|
||||
mInactiveSize += entry->Size();
|
||||
EvictEntriesIfNecessary();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMemoryCacheDevice::BindEntry(nsCacheEntry * entry)
|
||||
{
|
||||
NS_ASSERTION(PR_CLIST_IS_EMPTY(entry),"entry is already on a list!");
|
||||
|
||||
if (!entry->IsDoomed()) {
|
||||
// append entry to the eviction list
|
||||
PR_APPEND_LINK(entry, &mEvictionList);
|
||||
|
||||
// add entry to hashtable of mem cache entries
|
||||
nsresult rv = mMemCacheEntries.AddEntry(entry);
|
||||
if (NS_FAILED(rv)) {
|
||||
PR_REMOVE_AND_INIT_LINK(entry);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// add size of entry to memory totals
|
||||
++mEntryCount;
|
||||
if (mMaxEntryCount < mEntryCount) mMaxEntryCount = mEntryCount;
|
||||
|
||||
mTotalSize += entry->Size();
|
||||
EvictEntriesIfNecessary();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsMemoryCacheDevice::DoomEntry(nsCacheEntry * entry)
|
||||
{
|
||||
// XXX debug code to verify we have entry
|
||||
mMemCacheEntries.RemoveEntry(entry);
|
||||
|
||||
// remove entry from our eviction list
|
||||
PR_REMOVE_AND_INIT_LINK(entry);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMemoryCacheDevice::GetTransportForEntry( nsCacheEntry * entry,
|
||||
nsCacheAccessMode mode,
|
||||
nsITransport ** transport )
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(entry);
|
||||
NS_ENSURE_ARG_POINTER(transport);
|
||||
|
||||
nsCOMPtr<nsISupports> data;
|
||||
|
||||
nsresult rv = entry->GetData(getter_AddRefs(data));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (data)
|
||||
return CallQueryInterface(data, transport);
|
||||
else {
|
||||
// create a new transport for this entry
|
||||
rv = nsComponentManager::CreateInstance(kStorageTransportCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsITransport),
|
||||
(void **) transport);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
entry->SetData(*transport);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMemoryCacheDevice::GetFileForEntry( nsCacheEntry * entry,
|
||||
nsIFile ** result )
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMemoryCacheDevice::OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize)
|
||||
{
|
||||
if (entry->IsStreamData()) {
|
||||
// we have the right to refuse or pre-evict
|
||||
}
|
||||
|
||||
// adjust our totals
|
||||
mTotalSize += deltaSize;
|
||||
|
||||
EvictEntriesIfNecessary();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsMemoryCacheDevice::AdjustMemoryLimits(PRUint32 softLimit, PRUint32 hardLimit)
|
||||
{
|
||||
mSoftLimit = softLimit;
|
||||
mHardLimit = hardLimit;
|
||||
EvictEntriesIfNecessary();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsMemoryCacheDevice::EvictEntry(nsCacheEntry * entry)
|
||||
{
|
||||
// remove entry from our hashtable
|
||||
mMemCacheEntries.RemoveEntry(entry);
|
||||
|
||||
// remove entry from the eviction list
|
||||
PR_REMOVE_AND_INIT_LINK(entry);
|
||||
|
||||
// update statistics
|
||||
PRUint32 memoryRecovered = entry->Size();
|
||||
mTotalSize -= memoryRecovered;
|
||||
mInactiveSize -= memoryRecovered;
|
||||
--mEntryCount;
|
||||
|
||||
delete entry;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsMemoryCacheDevice::EvictEntriesIfNecessary(void)
|
||||
{
|
||||
nsCacheEntry * entry, * next;
|
||||
|
||||
if ((mTotalSize < mHardLimit) && (mInactiveSize < mSoftLimit))
|
||||
return;
|
||||
|
||||
// XXX implement more sophisticated eviction ordering
|
||||
|
||||
entry = (nsCacheEntry *)PR_LIST_HEAD(&mEvictionList);
|
||||
while (entry != &mEvictionList) {
|
||||
if (entry->IsInUse()) {
|
||||
entry = (nsCacheEntry *)PR_NEXT_LINK(entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
next = (nsCacheEntry *)PR_NEXT_LINK(entry);
|
||||
EvictEntry(entry);
|
||||
entry = next;
|
||||
|
||||
if ((mTotalSize < mHardLimit) && (mInactiveSize < mSoftLimit))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMemoryCacheDevice::Visit(nsICacheVisitor * visitor)
|
||||
{
|
||||
nsMemoryCacheDeviceInfo * deviceInfo = new nsMemoryCacheDeviceInfo(this);
|
||||
nsCOMPtr<nsICacheDeviceInfo> deviceRef(deviceInfo);
|
||||
if (!deviceInfo) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PRBool keepGoing;
|
||||
nsresult rv = visitor->VisitDevice(gMemoryDeviceID, deviceInfo, &keepGoing);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!keepGoing)
|
||||
return NS_OK;
|
||||
|
||||
nsCacheEntry * entry;
|
||||
nsCOMPtr<nsICacheEntryInfo> entryRef;
|
||||
|
||||
entry = (nsCacheEntry *)PR_LIST_HEAD(&mEvictionList);
|
||||
while (entry != &mEvictionList) {
|
||||
nsCacheEntryInfo * entryInfo = new nsCacheEntryInfo(entry);
|
||||
if (!entryInfo) return NS_ERROR_OUT_OF_MEMORY;
|
||||
entryRef = entryInfo;
|
||||
|
||||
rv = visitor->VisitEntry(gMemoryDeviceID, entryInfo, &keepGoing);
|
||||
entryInfo->DetachEntry();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!keepGoing) break;
|
||||
|
||||
entry = (nsCacheEntry *)PR_NEXT_LINK(entry);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMemoryCacheDevice::EvictEntries(const char * clientID)
|
||||
{
|
||||
nsCacheEntry * entry;
|
||||
PRUint32 prefixLength = nsCRT::strlen(clientID);
|
||||
|
||||
PRCList * elem = PR_LIST_HEAD(&mEvictionList);
|
||||
while (elem != &mEvictionList) {
|
||||
entry = (nsCacheEntry *)elem;
|
||||
elem = PR_NEXT_LINK(elem);
|
||||
|
||||
const char * key = entry->Key()->get();
|
||||
if (clientID && nsCRT::strncmp(clientID, key, prefixLength) != 0)
|
||||
continue;
|
||||
|
||||
if (entry->IsInUse()) {
|
||||
nsresult rv = nsCacheService::GlobalInstance()->DoomEntry_Locked(entry);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} else {
|
||||
EvictEntry(entry);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* nsMemoryCacheDeviceInfo - for implementing about:cache
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMemoryCacheDeviceInfo, nsICacheDeviceInfo);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryCacheDeviceInfo::GetDescription(char ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
*result = nsCRT::strdup("Memory cache device");
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryCacheDeviceInfo::GetUsageReport(char ** result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
*result = nsCRT::strdup("Memory cache usage report:");
|
||||
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryCacheDeviceInfo::GetEntryCount(PRUint32 * result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
// XXX compare calculated count vs. mEntryCount
|
||||
*result = mDevice->mEntryCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryCacheDeviceInfo::GetTotalSize(PRUint32 * result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
*result = mDevice->mTotalSize;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryCacheDeviceInfo::GetMaximumSize(PRUint32 * result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
*result = mDevice->mHardLimit;
|
||||
return NS_OK;
|
||||
}
|
||||
111
mozilla/netwerk/cache/src/nsMemoryCacheDevice.h
vendored
Normal file
111
mozilla/netwerk/cache/src/nsMemoryCacheDevice.h
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is nsMemoryCacheDevice.h, released February 20, 2001.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gordon Sheridan, 20-February-2001
|
||||
*/
|
||||
|
||||
#ifndef _nsMemoryCacheDevice_h_
|
||||
#define _nsMemoryCacheDevice_h_
|
||||
|
||||
#include "nsCacheDevice.h"
|
||||
#include "pldhash.h"
|
||||
#include "nsCacheEntry.h"
|
||||
|
||||
|
||||
class nsMemoryCacheDeviceInfo;
|
||||
|
||||
/******************************************************************************
|
||||
* nsMemoryCacheDevice
|
||||
******************************************************************************/
|
||||
class nsMemoryCacheDevice : public nsCacheDevice
|
||||
{
|
||||
public:
|
||||
nsMemoryCacheDevice();
|
||||
virtual ~nsMemoryCacheDevice();
|
||||
|
||||
virtual nsresult Init();
|
||||
virtual nsresult Shutdown();
|
||||
|
||||
virtual const char * GetDeviceID(void);
|
||||
|
||||
virtual nsresult BindEntry( nsCacheEntry * entry );
|
||||
virtual nsCacheEntry * FindEntry( nsCString * key );
|
||||
virtual void DoomEntry( nsCacheEntry * entry );
|
||||
virtual nsresult DeactivateEntry( nsCacheEntry * entry );
|
||||
|
||||
virtual nsresult GetTransportForEntry( nsCacheEntry * entry,
|
||||
nsCacheAccessMode mode,
|
||||
nsITransport **transport );
|
||||
|
||||
virtual nsresult GetFileForEntry( nsCacheEntry * entry,
|
||||
nsIFile ** result );
|
||||
|
||||
virtual nsresult OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize );
|
||||
|
||||
virtual nsresult Visit( nsICacheVisitor * visitor );
|
||||
|
||||
virtual nsresult EvictEntries(const char * clientID);
|
||||
|
||||
static int PR_CALLBACK MemoryCacheSizeChanged(const char * pref, void * closure);
|
||||
|
||||
private:
|
||||
friend class nsMemoryCacheDeviceInfo;
|
||||
void AdjustMemoryLimits( PRUint32 softLimit, PRUint32 hardLimit);
|
||||
void EvictEntry( nsCacheEntry * entry );
|
||||
void EvictEntriesIfNecessary();
|
||||
|
||||
nsCacheEntryHashTable mMemCacheEntries;
|
||||
PRCList mEvictionList;
|
||||
|
||||
PRUint32 mHardLimit;
|
||||
PRUint32 mSoftLimit;
|
||||
|
||||
PRUint32 mTotalSize;
|
||||
PRUint32 mInactiveSize;
|
||||
|
||||
PRUint32 mEntryCount;
|
||||
|
||||
PRUint32 mMaxEntryCount;
|
||||
// XXX what other stats do we want to keep?
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* nsMemoryCacheDeviceInfo - used to call nsIVisitor for about:cache
|
||||
******************************************************************************/
|
||||
class nsMemoryCacheDeviceInfo : public nsICacheDeviceInfo {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICACHEDEVICEINFO
|
||||
|
||||
nsMemoryCacheDeviceInfo(nsMemoryCacheDevice* device)
|
||||
: mDevice(device)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
virtual ~nsMemoryCacheDeviceInfo() {}
|
||||
|
||||
private:
|
||||
nsMemoryCacheDevice* mDevice;
|
||||
};
|
||||
|
||||
|
||||
#endif // _nsMemoryCacheDevice_h_
|
||||
231
mozilla/netwerk/cache/src/win32.order
vendored
Normal file
231
mozilla/netwerk/cache/src/win32.order
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
?AddRef@nsCacheEntryDescriptor@@UAGKXZ ; 35743
|
||||
?HashKey@nsCacheEntryHashTable@@CAIPAUPLDHashTable@@PBX@Z ; 29743
|
||||
?Release@nsCacheEntryDescriptor@@UAGKXZ ; 21199
|
||||
??_EnsCString@@UAEPAXI@Z ; 19905
|
||||
?AddRef@nsCacheSession@@UAGKXZ ; 17435
|
||||
?GetEntry@nsCacheEntryHashTable@@QAEPAVnsCacheEntry@@PBVnsCString@@@Z ; 17433
|
||||
?SecondsFromPRTime@@YAI_J@Z ; 14263
|
||||
?CalculateSize@nsCacheMetaData@@CA?AW4PLDHashOperator@@PAUPLDHashTable@@PAUPLDHashEntryHdr@@IPAX@Z ; 14243
|
||||
?Release@nsCacheEntryInfo@@UAGKXZ ; 10964
|
||||
?GetLastModified@nsDiskCacheEntryInfo@@UAGIPAI@Z ; 9800
|
||||
?Release@nsANSIOutputStream@@UAGKXZ ; 9758
|
||||
?MatchEntry@nsCacheEntryHashTable@@CAHPAUPLDHashTable@@PBUPLDHashEntryHdr@@PBX@Z ; 9663
|
||||
?QueryInterface@nsCacheEntryInfo@@UAGIABUnsID@@PAPAX@Z ; 8638
|
||||
??Rdo_QueryElementAt@@UBEIABUnsID@@PAPAX@Z ; 8638
|
||||
?assign_assuming_AddRef@nsCOMPtr_base@@IAEXPAVnsISupports@@@Z ; 8259
|
||||
??0nsDiskCacheRecord@@QAE@XZ ; 8192
|
||||
?EnsureEntryHasDevice@nsCacheService@@AAEPAVnsCacheDevice@@PAVnsCacheEntry@@@Z ; 7918
|
||||
?MoveEntry@nsCacheEntryHashTable@@CAXPAUPLDHashTable@@PBUPLDHashEntryHdr@@PAU3@@Z ; 7653
|
||||
?GetKey@nsCacheEntryHashTable@@CAPBXPAUPLDHashTable@@PAUPLDHashEntryHdr@@@Z ; 7653
|
||||
?Close@nsANSIOutputStream@@UAGIXZ ; 7092
|
||||
?Write@nsANSIOutputStream@@UAGIPBDIPAI@Z ; 7067
|
||||
?AccumulateElements@nsCacheMetaData@@CA?AW4PLDHashOperator@@PAUPLDHashTable@@PAUPLDHashEntryHdr@@IPAX@Z ; 7063
|
||||
?Release@nsDiskCacheDeviceInfo@@UAGKXZ ; 6471
|
||||
?CreateRequest@nsCacheService@@AAEIPAVnsCacheSession@@PBDHPAVnsICacheListener@@PAPAVnsCacheRequest@@@Z ; 6468
|
||||
?ActivateEntry@nsCacheService@@AAEIPAVnsCacheRequest@@PAPAVnsCacheEntry@@@Z ; 6468
|
||||
?ProcessRequest@nsCacheService@@AAEIPAVnsCacheRequest@@PAPAVnsICacheEntryDescriptor@@@Z ; 6468
|
||||
??1nsCacheRequest@@AAE@XZ ; 6468
|
||||
?OpenCacheEntry@nsCacheService@@QAEIPAVnsCacheSession@@PBDHPAVnsICacheListener@@PAPAVnsICacheEntryDescriptor@@@Z ; 6468
|
||||
??0nsCacheRequest@@AAE@PAVnsCString@@PAVnsICacheListener@@HPAVnsCacheSession@@@Z ; 6468
|
||||
?Hash@nsDiskCacheEntry@@SAIPBD@Z ; 6166
|
||||
?HashKey@nsDiskCacheEntryHashTable@@CAIPAUPLDHashTable@@PBX@Z ; 6037
|
||||
?EvictEntriesIfNecessary@nsMemoryCacheDevice@@AAEXXZ ; 5780
|
||||
?TouchData@nsCacheEntry@@QAEXXZ ; 5503
|
||||
?OpenCacheEntry@nsCacheSession@@UAGIPBDHPAPAVnsICacheEntryDescriptor@@@Z ; 5165
|
||||
?RequestAccess@nsCacheEntry@@QAEIPAVnsCacheRequest@@PAH@Z ; 5099
|
||||
?Fetched@nsCacheEntry@@QAEXXZ ; 5094
|
||||
??0nsTransportWrapper@nsCacheEntryDescriptor@@QAE@XZ ; 5092
|
||||
?CreateDescriptor@nsCacheEntry@@QAEIPAVnsCacheRequest@@HPAPAVnsICacheEntryDescriptor@@@Z ; 5092
|
||||
??0nsCacheEntryDescriptor@@QAE@PAVnsCacheEntry@@H@Z ; 5092
|
||||
?RemoveDescriptor@nsCacheEntry@@QAEHPAVnsCacheEntryDescriptor@@@Z ; 5090
|
||||
?CloseDescriptor@nsCacheService@@QAEXPAVnsCacheEntryDescriptor@@@Z ; 5090
|
||||
?Close@nsCacheEntryDescriptor@@UAGIXZ ; 5090
|
||||
??_GnsCacheEntryDescriptor@@UAEPAXI@Z ; 5090
|
||||
??1nsCacheEntryDescriptor@@UAE@XZ ; 5090
|
||||
?SearchCacheDevices@nsCacheService@@AAEPAVnsCacheEntry@@PAVnsCString@@H@Z ; 4993
|
||||
?AddEntry@nsCacheEntryHashTable@@QAEIPAVnsCacheEntry@@@Z ; 4993
|
||||
?FindEntry@nsMemoryCacheDevice@@UAEPAVnsCacheEntry@@PAVnsCString@@@Z ; 4993
|
||||
?ClearEntry@nsCacheEntryHashTable@@CAXPAUPLDHashTable@@PAUPLDHashEntryHdr@@@Z ; 4993
|
||||
?RemoveEntry@nsCacheEntryHashTable@@QAEXPAVnsCacheEntry@@@Z ; 4921
|
||||
?GetData@nsCacheEntry@@QAEIPAPAVnsISupports@@@Z ; 4811
|
||||
?Release@nsDiskCacheEntry@@UAGKXZ ; 4784
|
||||
?RequestDataSizeChange@nsCacheEntryDescriptor@@QAEIH@Z ; 4127
|
||||
?OnDataSizeChange@nsCacheService@@QAEIPAVnsCacheEntry@@H@Z ; 4127
|
||||
?SetElement@nsCacheMetaData@@QAEIABVnsACString@@0@Z ; 3682
|
||||
?ClearEntry@nsCacheMetaData@@CAXPAUPLDHashTable@@PAUPLDHashEntryHdr@@@Z ; 3681
|
||||
?FreeElements@nsCacheMetaData@@CA?AW4PLDHashOperator@@PAUPLDHashTable@@PAUPLDHashEntryHdr@@IPAX@Z ; 3681
|
||||
?GetEntry@nsDiskCacheEntryHashTable@@QAEPAVnsDiskCacheEntry@@PBD@Z ; 3651
|
||||
?GetRecord@nsDiskCacheMap@@QAEPAVnsDiskCacheRecord@@I@Z ; 3650
|
||||
?Size@nsCacheMetaData@@QAEIXZ ; 3628
|
||||
?DeactivateEntry@nsCacheService@@AAEXPAVnsCacheEntry@@@Z ; 3619
|
||||
?TouchMetaData@nsCacheEntry@@QAEXXZ ; 3601
|
||||
?SetMetaDataElement@nsCacheEntryDescriptor@@UAGIPBD0@Z ; 3601
|
||||
?SetMetaDataElement@nsCacheEntry@@QAEIABVnsACString@@0@Z ; 3601
|
||||
?getFileForHashNumber@nsDiskCacheDevice@@QAEIIHIPAPAVnsIFile@@@Z ; 3587
|
||||
?Read@nsANSIInputStream@@UAGIPADIPAI@Z ; 3570
|
||||
?getFileForDiskCacheEntry@nsDiskCacheDevice@@QAEIPAVnsDiskCacheEntry@@HPAPAVnsIFile@@@Z ; 3560
|
||||
?Unswap@MetaDataHeader@@QAEXXZ ; 3545
|
||||
??1MetaDataFile@@QAE@XZ ; 3545
|
||||
?OnDataSizeChange@nsDiskCacheDevice@@UAEIPAVnsCacheEntry@@H@Z ; 3210
|
||||
?ProcessPendingRequests@nsCacheService@@AAEIPAVnsCacheEntry@@@Z ; 2800
|
||||
??0nsCacheEntry@@QAE@PAVnsCString@@HH@Z ; 2673
|
||||
??1nsCacheEntry@@QAE@XZ ; 2673
|
||||
?MarkValid@nsCacheEntryDescriptor@@UAGIXZ ; 2592
|
||||
?ValidateEntry@nsCacheService@@QAEIPAVnsCacheEntry@@@Z ; 2592
|
||||
?GetCacheElement@nsCacheEntryDescriptor@@UAGIPAPAVnsISupports@@@Z ; 2413
|
||||
?MatchEntry@nsDiskCacheEntryHashTable@@CAHPAUPLDHashTable@@PBUPLDHashEntryHdr@@PBX@Z ; 2383
|
||||
?Release@nsANSIInputStream@@UAGKXZ ; 2380
|
||||
?AddRef@nsANSIInputStream@@UAGKXZ ; 2380
|
||||
?MatchEntry@nsCacheMetaData@@CAHPAUPLDHashTable@@PBUPLDHashEntryHdr@@PBX@Z ; 2365
|
||||
?GetMetaDataElement@nsCacheEntry@@QAEIABVnsACString@@PAPBV2@@Z ; 2365
|
||||
?GetElement@nsCacheMetaData@@QAEPBVnsACString@@PBV2@@Z ; 2365
|
||||
?GetMetaDataElement@nsCacheEntryDescriptor@@UAGIPBDPAPAD@Z ; 2365
|
||||
?openOutputStream@nsDiskCacheDevice@@SAIPAVnsIFile@@PAPAVnsIOutputStream@@@Z ; 2356
|
||||
?updateDiskCacheEntry@nsDiskCacheDevice@@QAEIPAVnsDiskCacheEntry@@@Z ; 2356
|
||||
??0nsANSIOutputStream@@QAE@PAU_iobuf@@@Z ; 2356
|
||||
??_EnsANSIOutputStream@@UAEPAXI@Z ; 2356
|
||||
??1nsANSIOutputStream@@UAE@XZ ; 2356
|
||||
?Swap@MetaDataHeader@@QAEXXZ ; 2355
|
||||
?FlattenMetaData@nsCacheMetaData@@QAEIPAPADPAI@Z ; 2355
|
||||
?Init@MetaDataFile@@QAEIPAVnsCacheEntry@@@Z ; 2355
|
||||
?updateCacheMap@nsDiskCacheDevice@@QAEIPAVnsDiskCacheEntry@@@Z ; 2355
|
||||
??0MetaDataHeader@@QAE@PAVnsCacheEntry@@@Z ; 2355
|
||||
?Write@MetaDataFile@@QAEIPAVnsIOutputStream@@@Z ; 2355
|
||||
?FlattenMetaData@nsCacheEntry@@QAEIPAPADPAI@Z ; 2355
|
||||
?DeactivateEntry@nsMemoryCacheDevice@@UAEIPAVnsCacheEntry@@@Z ; 2322
|
||||
?SetExpirationTime@nsCacheEntryDescriptor@@UAGII@Z ; 2259
|
||||
?QueryInterface@nsCacheEntryDescriptor@@UAGIABUnsID@@PAPAX@Z ; 2186
|
||||
?GetDataSize@nsCacheEntryDescriptor@@UAGIPAI@Z ; 2107
|
||||
?OnDataSizeChange@nsMemoryCacheDevice@@UAEIPAVnsCacheEntry@@H@Z ; 2082
|
||||
?SetDataSize@nsCacheEntryDescriptor@@UAGII@Z ; 2082
|
||||
?Write@nsOutputStreamWrapper@nsCacheEntryDescriptor@@UAGIPBDIPAI@Z ; 2045
|
||||
?OnWrite@nsOutputStreamWrapper@nsCacheEntryDescriptor@@AAEII@Z ; 2045
|
||||
?GetNonBlocking@nsOutputStreamWrapper@nsCacheEntryDescriptor@@UAGIPAH@Z ; 1550
|
||||
?SetCacheElement@nsCacheEntryDescriptor@@UAGIPAVnsISupports@@@Z ; 1376
|
||||
?BindEntry@nsMemoryCacheDevice@@UAEIPAVnsCacheEntry@@@Z ; 1376
|
||||
?AsyncOpenCacheEntry@nsCacheSession@@UAGIPBDHPAVnsICacheListener@@@Z ; 1303
|
||||
?NotifyListener@nsCacheService@@AAEIPAVnsCacheRequest@@PAVnsICacheEntryDescriptor@@HI@Z ; 1303
|
||||
??0nsCacheMetaData@@QAE@XZ ; 1298
|
||||
??1nsCacheMetaData@@QAE@XZ ; 1298
|
||||
?FindEntry@nsDiskCacheDevice@@UAEPAVnsCacheEntry@@PAVnsCString@@@Z ; 1295
|
||||
?Init@nsCacheMetaData@@QAEIXZ ; 1295
|
||||
?Finalize@nsCacheMetaData@@CAXPAUPLDHashTable@@@Z ; 1295
|
||||
?Create@nsCacheMetaData@@SAPAV1@XZ ; 1295
|
||||
?getTransportForFile@nsDiskCacheDevice@@SAIPAVnsIFile@@HPAPAVnsITransport@@@Z ; 1199
|
||||
?GetTransportForEntry@nsDiskCacheDevice@@UAEIPAVnsCacheEntry@@HPAPAVnsITransport@@@Z ; 1198
|
||||
?AddRef@nsTransportWrapper@nsCacheEntryDescriptor@@UAGKXZ ; 1198
|
||||
?EnsureTransportWithAccess@nsTransportWrapper@nsCacheEntryDescriptor@@QAEIH@Z ; 1198
|
||||
?GetTransport@nsCacheEntryDescriptor@@UAGIPAPAVnsITransport@@@Z ; 1198
|
||||
?GetTransportForEntry@nsCacheService@@QAEIPAVnsCacheEntry@@HPAPAVnsITransport@@@Z ; 1198
|
||||
?Release@nsTransportWrapper@nsCacheEntryDescriptor@@UAGKXZ ; 1198
|
||||
?GetSecurityInfo@nsCacheEntryDescriptor@@UAGIPAPAVnsISupports@@@Z ; 1195
|
||||
?GetSecurityInfo@nsCacheEntry@@QAEIPAPAVnsISupports@@@Z ; 1195
|
||||
??1nsDiskCacheEntry@@UAE@XZ ; 1193
|
||||
??0nsDiskCacheEntry@@QAE@PAVnsCacheEntry@@@Z ; 1193
|
||||
??_EnsDiskCacheEntry@@UAEPAXI@Z ; 1193
|
||||
?DeactivateEntry@nsDiskCacheDevice@@UAEIPAVnsCacheEntry@@@Z ; 1193
|
||||
?AddEntry@nsDiskCacheEntryHashTable@@QAEIPAVnsDiskCacheEntry@@@Z ; 1193
|
||||
?ClearEntry@nsDiskCacheEntryHashTable@@CAXPAUPLDHashTable@@PAUPLDHashEntryHdr@@@Z ; 1193
|
||||
?RemoveEntry@nsDiskCacheEntryHashTable@@QAEXPAVnsDiskCacheEntry@@@Z ; 1193
|
||||
?openInputStream@nsDiskCacheDevice@@SAIPAVnsIFile@@PAPAVnsIInputStream@@@Z ; 1191
|
||||
??1nsANSIInputStream@@UAE@XZ ; 1190
|
||||
?Read@MetaDataFile@@QAEIPAVnsIInputStream@@@Z ; 1190
|
||||
??0nsANSIInputStream@@QAE@PAU_iobuf@@@Z ; 1190
|
||||
??_EnsANSIInputStream@@UAEPAXI@Z ; 1190
|
||||
??0MetaDataHeader@@QAE@XZ ; 1190
|
||||
?OpenOutputStream@nsTransportWrapper@nsCacheEntryDescriptor@@UAGIIIIPAPAVnsIOutputStream@@@Z ; 1166
|
||||
?BindEntry@nsDiskCacheDevice@@UAEIPAVnsCacheEntry@@@Z ; 1166
|
||||
?IsAllowedOnDisk@nsCacheEntry@@QAEHXZ ; 1166
|
||||
??1nsOutputStreamWrapper@nsCacheEntryDescriptor@@UAE@XZ ; 1165
|
||||
?NewOutputStreamWrapper@nsCacheEntryDescriptor@@CAIPAPAVnsIOutputStream@@PAV1@PAV2@@Z ; 1165
|
||||
?GetAccessGranted@nsCacheEntryDescriptor@@UAGIPAH@Z ; 1165
|
||||
??0nsOutputStreamWrapper@nsCacheEntryDescriptor@@QAE@PAV1@PAVnsIOutputStream@@@Z ; 1165
|
||||
?Init@nsOutputStreamWrapper@nsCacheEntryDescriptor@@QAEIXZ ; 1165
|
||||
??_GnsOutputStreamWrapper@nsCacheEntryDescriptor@@UAEPAXI@Z ; 1165
|
||||
??0MetaDataFile@@QAE@XZ ; 1163
|
||||
?GetDataSize@nsDiskCacheEntryInfo@@UAGIPAI@Z ; 1163
|
||||
??_GnsDiskCacheEntryInfo@@UAEPAXI@Z ; 1163
|
||||
?Swap@nsDiskCacheRecord@@QAEXXZ ; 1123
|
||||
?Unswap@nsDiskCacheRecord@@QAEXXZ ; 1123
|
||||
?GetExpirationTime@nsCacheEntryDescriptor@@UAGIPAI@Z ; 1118
|
||||
?GetKey@nsDiskCacheEntryHashTable@@CAPBXPAUPLDHashTable@@PAUPLDHashEntryHdr@@@Z ; 395
|
||||
?MoveEntry@nsDiskCacheEntryHashTable@@CAXPAUPLDHashTable@@PBUPLDHashEntryHdr@@PAU3@@Z ; 395
|
||||
?DoomEntry_Locked@nsCacheService@@QAEIPAVnsCacheEntry@@@Z ; 106
|
||||
?DoomEntry@nsCacheService@@QAEIPAVnsCacheEntry@@@Z ; 104
|
||||
?Doom@nsCacheEntryDescriptor@@UAGIXZ ; 104
|
||||
?FreeCacheEntries@nsCacheEntryHashTable@@CA?AW4PLDHashOperator@@PAUPLDHashTable@@PAUPLDHashEntryHdr@@IPAX@Z ; 72
|
||||
?AsyncRead@nsTransportWrapper@nsCacheEntryDescriptor@@UAGIPAVnsIStreamListener@@PAVnsISupports@@IIIPAPAVnsIRequest@@@Z ; 32
|
||||
??_H@YGXPAXIHP6EX0@Z@Z ; 32
|
||||
?getFileForKey@nsDiskCacheDevice@@QAEIPBDHIPAPAVnsIFile@@@Z ; 27
|
||||
?UnflattenMetaData@nsCacheMetaData@@QAEIPADI@Z ; 27
|
||||
?UnflattenMetaData@nsCacheEntry@@QAEIPADI@Z ; 27
|
||||
?readDiskCacheEntry@nsDiskCacheDevice@@QAEIPBDPAPAVnsDiskCacheEntry@@@Z ; 27
|
||||
?GetLastModified@nsCacheEntryDescriptor@@UAGIPAI@Z ; 25
|
||||
?AddRef@nsDiskCacheObserver@@UAGKXZ ; 12
|
||||
?Release@nsDiskCacheObserver@@UAGKXZ ; 12
|
||||
?AddRef@nsCacheService@@UAGKXZ ; 9
|
||||
?Release@nsCacheService@@UAGKXZ ; 9
|
||||
?QueryInterface@nsDiskCacheObserver@@UAGIABUnsID@@PAPAX@Z ; 6
|
||||
?QueryInterface@nsCacheService@@UAGIABUnsID@@PAPAX@Z ; 6
|
||||
?do_GetService@@YA?BVnsGetServiceByContractID@@PBDPAI@Z ; 5
|
||||
?DeleteRecord@nsDiskCacheMap@@QAEXI@Z ; 3
|
||||
??0nsCacheSession@@QAE@PBDHH@Z ; 3
|
||||
??1nsCacheSession@@UAE@XZ ; 3
|
||||
??_EnsCacheSession@@UAEPAXI@Z ; 3
|
||||
?deleteDiskCacheEntry@nsDiskCacheDevice@@QAEIPAVnsDiskCacheEntry@@@Z ; 3
|
||||
?DoomEntry@nsDiskCacheDevice@@UAEXPAVnsCacheEntry@@@Z ; 3
|
||||
?CreateSession@nsCacheService@@UAGIPBDHHPAPAVnsICacheSession@@@Z ; 3
|
||||
?setPrefsObserver@nsDiskCacheDevice@@QAEXPAVnsIObserver@@@Z ; 2
|
||||
?VisitEntries@nsDiskCacheEntryHashTable@@QAEXPAVVisitor@1@@Z ; 2
|
||||
?DetachDescriptors@nsCacheEntry@@AAEXXZ ; 2
|
||||
?ClearPendingRequests@nsCacheService@@AAEXPAVnsCacheEntry@@@Z ; 2
|
||||
?SetDoomEntriesIfExpired@nsCacheSession@@UAGIH@Z ; 2
|
||||
?Finalize@nsCacheEntryHashTable@@CAXPAUPLDHashTable@@@Z ; 2
|
||||
?DeactivateAndClearEntry@nsCacheService@@CA?AW4PLDHashOperator@@PAUPLDHashTable@@PAUPLDHashEntryHdr@@IPAX@Z ; 2
|
||||
?Init@nsCacheEntryHashTable@@QAEIXZ ; 2
|
||||
?updateDiskCacheEntries@nsDiskCacheDevice@@QAEIXZ ; 2
|
||||
?scanDiskCacheEntries@nsDiskCacheDevice@@QAEIPAPAVnsISupportsArray@@@Z ; 2
|
||||
?AdjustMemoryLimits@nsMemoryCacheDevice@@AAEXII@Z ; 1
|
||||
_NSGetModule ; 1
|
||||
?Finalize@nsDiskCacheEntryHashTable@@CAXPAUPLDHashTable@@@Z ; 1
|
||||
??0nsMemoryCacheDevice@@QAE@XZ ; 1
|
||||
?evictDiskCacheEntries@nsDiskCacheDevice@@QAEIXZ ; 1
|
||||
??0nsDiskCacheMap@@QAE@XZ ; 1
|
||||
?ClearActiveEntries@nsCacheService@@AAEXXZ ; 1
|
||||
?setCacheCapacity@nsDiskCacheDevice@@QAEXI@Z ; 1
|
||||
?Init@nsDiskCacheEntryHashTable@@QAEIXZ ; 1
|
||||
?DoomEntry@nsMemoryCacheDevice@@UAEXPAVnsCacheEntry@@@Z ; 1
|
||||
?getPrefsObserver@nsDiskCacheDevice@@QAEXPAPAVnsIObserver@@@Z ; 1
|
||||
??_EnsMemoryCacheDevice@@UAEPAXI@Z ; 1
|
||||
?setCacheDirectory@nsDiskCacheDevice@@QAEXPAVnsILocalFile@@@Z ; 1
|
||||
?Shutdown@nsCacheService@@UAGIXZ ; 1
|
||||
??_GnsCacheService@@UAEPAXI@Z ; 1
|
||||
?ClearDoomList@nsCacheService@@AAEXXZ ; 1
|
||||
?QueryInterface@nsANSIOutputStream@@UAGIABUnsID@@PAPAX@Z ; 1
|
||||
?Init@nsCacheService@@UAGIXZ ; 1
|
||||
??0nsDiskCacheDevice@@QAE@XZ ; 1
|
||||
?Swap@nsDiskCacheHeader@@QAEXXZ ; 1
|
||||
?GetFileForEntry@nsCacheService@@QAEIPAVnsCacheEntry@@PAPAVnsIFile@@@Z ; 1
|
||||
??_GnsDiskCacheDevice@@UAEPAXI@Z ; 1
|
||||
??1nsCacheService@@UAE@XZ ; 1
|
||||
?GetFileForEntry@nsDiskCacheDevice@@UAEIPAVnsCacheEntry@@PAPAVnsIFile@@@Z ; 1
|
||||
?Init@nsMemoryCacheDevice@@UAEIXZ ; 1
|
||||
?GetFile@nsCacheEntryDescriptor@@UAGIPAPAVnsIFile@@@Z ; 1
|
||||
?Seek@nsANSIOutputStream@@UAGIHH@Z ; 1
|
||||
?MemoryCacheSizeChanged@nsMemoryCacheDevice@@SAHPBDPAX@Z ; 1
|
||||
?SetStoragePolicy@nsCacheEntryDescriptor@@UAGIH@Z ; 1
|
||||
??0nsCacheService@@QAE@XZ ; 1
|
||||
?Observe@nsCacheService@@UAGIPAVnsISupports@@PBG1@Z ; 1
|
||||
?writeCacheMap@nsDiskCacheDevice@@QAEIXZ ; 1
|
||||
?Init@nsDiskCacheDevice@@UAEIXZ ; 1
|
||||
?Create@nsCacheService@@SGIPAVnsISupports@@ABUnsID@@PAPAX@Z ; 1
|
||||
?NS_GetSpecialDirectory@@YAIPBDPAPAVnsIFile@@@Z ; 1
|
||||
??1nsDiskCacheDevice@@UAE@XZ ; 1
|
||||
?readCacheMap@nsDiskCacheDevice@@QAEIXZ ; 1
|
||||
??1nsDiskCacheMap@@QAE@XZ ; 1
|
||||
??_EnsDiskCacheObserver@@UAEPAXI@Z ; 1
|
||||
?Unswap@nsDiskCacheHeader@@QAEXXZ ; 1
|
||||
?CreateDiskDevice@nsCacheService@@AAEIXZ ; 1
|
||||
??1nsMemoryCacheDevice@@UAE@XZ ; 1
|
||||
?Shutdown@nsDiskCacheDevice@@UAEIXZ ; 1
|
||||
?Write@nsDiskCacheMap@@QAEIPAVnsIOutputStream@@@Z ; 1
|
||||
@@ -1,5 +0,0 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ webroot/ [L]
|
||||
RewriteRule (.*) webroot/$1 [L]
|
||||
</IfModule>
|
||||
@@ -1,25 +0,0 @@
|
||||
SERVER REQUIREMENTS
|
||||
- Apache 1.3 or higher with mod_rewrite enabled
|
||||
- PHP 4.3.2 or higher
|
||||
- CakePHP 1.1.7.3363 or higher
|
||||
- MySQL (preferred) or PostgreSQL
|
||||
|
||||
INSTALLATION:
|
||||
- All files accompanying this README should be placed into the /app directory of
|
||||
your CakePHP install. Once complete, you should have a directory structure similar
|
||||
to the following where (/) is the base of your domain:
|
||||
/
|
||||
app/
|
||||
config/
|
||||
controllers/
|
||||
models/
|
||||
webroot/
|
||||
...
|
||||
cake/
|
||||
vendors/
|
||||
|
||||
- Import the database schema (/app/config/dist.sql) into your database
|
||||
- Rename database.dist.php to database.php and edit the file to reflect your
|
||||
database configuration
|
||||
- Rename bootstrap.dist.php to bootstrap.php and follow the editing instructions
|
||||
within. All fields except APP_* and MAX_YEAR are optional.
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
class AppController extends Controller {
|
||||
}
|
||||
?>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
class AppModel extends Model {
|
||||
}
|
||||
?>
|
||||
@@ -1,76 +0,0 @@
|
||||
;<?php die() ?>
|
||||
; SVN FILE: $Id: acl.ini.php,v 1.3 2006-10-08 03:39:21 reed%reedloden.com Exp $
|
||||
;/**
|
||||
; * Short description for file.
|
||||
; *
|
||||
; *
|
||||
; * PHP versions 4 and 5
|
||||
; *
|
||||
; * CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
; * Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
; * 1785 E. Sahara Avenue, Suite 490-204
|
||||
; * Las Vegas, Nevada 89104
|
||||
; *
|
||||
; * Licensed under The MIT License
|
||||
; * Redistributions of files must retain the above copyright notice.
|
||||
; *
|
||||
; * @filesource
|
||||
; * @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
; * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
; * @package cake
|
||||
; * @subpackage cake.app.config
|
||||
; * @since CakePHP v 0.10.0.1076
|
||||
; * @version $Revision: 1.3 $
|
||||
; * @modifiedby $LastChangedBy: phpnut $
|
||||
; * @lastmodified $Date: 2006-10-08 03:39:21 $
|
||||
; * @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
; */
|
||||
|
||||
; acl.ini.php - Cake ACL Configuration
|
||||
; ---------------------------------------------------------------------
|
||||
; Use this file to specify user permissions.
|
||||
; aco = access control object (something in your application)
|
||||
; aro = access request object (something requesting access)
|
||||
;
|
||||
; User records are added as follows:
|
||||
;
|
||||
; [uid]
|
||||
; groups = group1, group2, group3
|
||||
; allow = aco1, aco2, aco3
|
||||
; deny = aco4, aco5, aco6
|
||||
;
|
||||
; Group records are added in a similar manner:
|
||||
;
|
||||
; [gid]
|
||||
; allow = aco1, aco2, aco3
|
||||
; deny = aco4, aco5, aco6
|
||||
;
|
||||
; The allow, deny, and groups sections are all optional.
|
||||
; NOTE: groups names *cannot* ever be the same as usernames!
|
||||
;
|
||||
; ACL permissions are checked in the following order:
|
||||
; 1. Check for user denies (and DENY if specified)
|
||||
; 2. Check for user allows (and ALLOW if specified)
|
||||
; 3. Gather user's groups
|
||||
; 4. Check group denies (and DENY if specified)
|
||||
; 5. Check group allows (and ALLOW if specified)
|
||||
; 6. If no aro, aco, or group information is found, DENY
|
||||
;
|
||||
; ---------------------------------------------------------------------
|
||||
|
||||
;-------------------------------------
|
||||
;Users
|
||||
;-------------------------------------
|
||||
|
||||
[username-goes-here]
|
||||
groups = group1, group2
|
||||
deny = aco1, aco2
|
||||
allow = aco3, aco4
|
||||
|
||||
;-------------------------------------
|
||||
;Groups
|
||||
;-------------------------------------
|
||||
|
||||
[groupname-goes-here]
|
||||
deny = aco5, aco6
|
||||
allow = aco7, aco8
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
/* REQUIRED - APP_NAME is used on all <title>s and mail names/subjects. APP_BASE
|
||||
* should be a FQDN with protocol minus the trailing slash e.g. http://example.tld/party
|
||||
*/
|
||||
define('APP_NAME', '');
|
||||
define('APP_EMAIL', '');
|
||||
define('APP_BASE', '');
|
||||
|
||||
/* You should specify a Google Map API key here. Without it, all mapping features
|
||||
* will be disabled. To obtain a key, visit http://www.google.com/apis/maps/
|
||||
*/
|
||||
define('GMAP_API_KEY', '');
|
||||
|
||||
/* The search API key is used to generate spelling suggestions for locations not
|
||||
* not found during a Geocode operation. You may obtain a key here: http://code.google.com/apis/soapsearch/
|
||||
*/
|
||||
define('GSEARCH_API_KEY', '');
|
||||
|
||||
/* The maximum year shown for party registrations */
|
||||
define('MAX_YEAR', 2007);
|
||||
|
||||
/* The Flickr API is used to show photos of each party on the individual party
|
||||
* pages and home page. See http://flickr.com/services/api/keys/ to obtain a key
|
||||
*/
|
||||
define('FLICKR_API_KEY', '');
|
||||
|
||||
/* The tag prefix is used to limit the results returned to a specific party.
|
||||
* e.g. any photo tagged with FirefoxParty11 will be shown on party 11's page.
|
||||
* Photos tagged with only the prefix are shown on the front page (so choose wisely! ;) ).
|
||||
*/
|
||||
define('FLICKR_TAG_PREFIX', '');
|
||||
?>
|
||||
@@ -1,147 +0,0 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id: core.php,v 1.4 2006-10-08 03:39:21 reed%reedloden.com Exp $ */
|
||||
/**
|
||||
* This is core configuration file.
|
||||
*
|
||||
* Use it to configure core behaviour ofCake.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP v 0.2.9
|
||||
* @version $Revision: 1.4 $
|
||||
* @modifiedby $LastChangedBy: phpnut $
|
||||
* @lastmodified $Date: 2006-10-08 03:39:21 $
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
/**
|
||||
* If you do not have mod rewrite on your system
|
||||
* or if you prefer to use CakePHP pretty urls.
|
||||
* uncomment the line below.
|
||||
* Note: If you do have mod rewrite but prefer the
|
||||
* CakePHP pretty urls, you also have to remove the
|
||||
* .htaccess files
|
||||
* release/.htaccess
|
||||
* release/app/.htaccess
|
||||
* release/app/webroot/.htaccess
|
||||
*/
|
||||
// define ('BASE_URL', env('SCRIPT_NAME'));
|
||||
/**
|
||||
* Set debug level here:
|
||||
* - 0: production
|
||||
* - 1: development
|
||||
* - 2: full debug with sql
|
||||
* - 3: full debug with sql and dump of the current object
|
||||
*
|
||||
* In production, the "flash messages" redirect after a time interval.
|
||||
* With the other debug levels you get to click the "flash message" to continue.
|
||||
*
|
||||
*/
|
||||
define('DEBUG', 0);
|
||||
/**
|
||||
* Turn of caching checking wide.
|
||||
* You must still use the controller var cacheAction inside you controller class.
|
||||
* You can either set it controller wide, or in each controller method.
|
||||
* use var $cacheAction = true; or in the controller method $this->cacheAction = true;
|
||||
*/
|
||||
define('CACHE_CHECK', false);
|
||||
/**
|
||||
* Error constant. Used for differentiating error logging and debugging.
|
||||
* Currently PHP supports LOG_DEBUG
|
||||
*/
|
||||
define('LOG_ERROR', 2);
|
||||
/**
|
||||
* CakePHP includes 3 types of session saves
|
||||
* database or file. Set this to your preferred method.
|
||||
* If you want to use your own save handler place it in
|
||||
* app/config/name.php DO NOT USE file or database as the name.
|
||||
* and use just the name portion below.
|
||||
*
|
||||
* Setting this to cake will save files to /cakedistro/tmp directory
|
||||
* Setting it to php will use the php default save path
|
||||
* Setting it to database will use the database
|
||||
*
|
||||
*
|
||||
*/
|
||||
define('CAKE_SESSION_SAVE', 'database');
|
||||
/**
|
||||
* If using you own table name for storing sessions
|
||||
* set the table name here.
|
||||
* DO NOT INCLUDE PREFIX IF YOU HAVE SET ONE IN database.php
|
||||
*
|
||||
*/
|
||||
define('CAKE_SESSION_TABLE', 'sessions');
|
||||
/**
|
||||
* Set a random string of used in session.
|
||||
*
|
||||
*/
|
||||
define('CAKE_SESSION_STRING', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
|
||||
/**
|
||||
* Set the name of session cookie
|
||||
*
|
||||
*/
|
||||
define('CAKE_SESSION_COOKIE', 'sess');
|
||||
/**
|
||||
* Set level of Cake security.
|
||||
*
|
||||
*/
|
||||
define('CAKE_SECURITY', 'high');
|
||||
/**
|
||||
* Set Cake Session time out.
|
||||
* If CAKE_SECURITY define is set
|
||||
* high: multiplied by 10
|
||||
* medium: is multiplied by 100
|
||||
* low is: multiplied by 300
|
||||
*
|
||||
* Number below is seconds.
|
||||
*/
|
||||
define('CAKE_SESSION_TIMEOUT', '120');
|
||||
/**
|
||||
* Uncomment the define below to use cake built in admin routes.
|
||||
* You can set this value to anything you want.
|
||||
* All methods related to the admin route should be prefixed with the
|
||||
* name you set CAKE_ADMIN to.
|
||||
* For example: admin_index, admin_edit
|
||||
*/
|
||||
// define('CAKE_ADMIN', 'admin');
|
||||
/**
|
||||
* The define below is used to turn cake built webservices
|
||||
* on or off. Default setting is off.
|
||||
*/
|
||||
define('WEBSERVICES', 'off');
|
||||
/**
|
||||
* Compress output CSS (removing comments, whitespace, repeating tags etc.)
|
||||
* This requires a/var/cache directory to be writable by the web server (caching).
|
||||
* To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use Controller::cssTag().
|
||||
*/
|
||||
define('COMPRESS_CSS', false);
|
||||
/**
|
||||
* If set to true, helpers would output data instead of returning it.
|
||||
*/
|
||||
define('AUTO_OUTPUT', false);
|
||||
/**
|
||||
* If set to false, session would not automatically be started.
|
||||
*/
|
||||
define('AUTO_SESSION', true);
|
||||
/**
|
||||
* Set the max size of file to use md5() .
|
||||
*/
|
||||
define('MAX_MD5SIZE', (5 * 1024) * 1024);
|
||||
/**
|
||||
* To use Access Control Lists with Cake...
|
||||
*/
|
||||
define('ACL_CLASSNAME', 'DB_ACL');
|
||||
define('ACL_FILENAME', 'dbacl' . DS . 'db_acl');
|
||||
?>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
class DATABASE_CONFIG {
|
||||
var $default = array('driver' => 'mysql',
|
||||
'connect' => 'mysql_connect',
|
||||
'host' => 'localhost',
|
||||
'login' => '',
|
||||
'password' => '',
|
||||
'database' => '');
|
||||
}
|
||||
?>
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id: inflections.php,v 1.3 2006-10-08 03:39:21 reed%reedloden.com Exp $ */
|
||||
/**
|
||||
* Custom Inflected Words.
|
||||
*
|
||||
* This file is used to hold words that are not matched in the normail Inflector::pluralize() and
|
||||
* Inflector::singularize()
|
||||
*
|
||||
* PHP versions 4 and %
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP v 1.0.0.2312
|
||||
* @version $Revision: 1.3 $
|
||||
* @modifiedby $LastChangedBy: phpnut $
|
||||
* @lastmodified $Date: 2006-10-08 03:39:21 $
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
/**
|
||||
* This is a key => value array of regex used to match words.
|
||||
* If key matches then the value is returned.
|
||||
*
|
||||
* $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice');
|
||||
*/
|
||||
$pluralRules = array();
|
||||
/**
|
||||
* This is a key only array of plural words that should not be inflected.
|
||||
* Notice the last comma
|
||||
*
|
||||
* $uninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox');
|
||||
*/
|
||||
$uninflectedPlural = array();
|
||||
/**
|
||||
* This is a key => value array of plural irregular words.
|
||||
* If key matches then the value is returned.
|
||||
*
|
||||
* $irregularPlural = array('atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers')
|
||||
*/
|
||||
$irregularPlural = array();
|
||||
/**
|
||||
* This is a key => value array of regex used to match words.
|
||||
* If key matches then the value is returned.
|
||||
*
|
||||
* $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i')
|
||||
*/
|
||||
$singularRules = array();
|
||||
/**
|
||||
* This is a key only array of singular words that should not be inflected.
|
||||
* You should not have to change this value below if you do change it use same format
|
||||
* as the $uninflectedPlural above.
|
||||
*/
|
||||
$uninflectedSingular = $uninflectedPlural;
|
||||
/**
|
||||
* This is a key => value array of singular irregular words.
|
||||
* Most of the time this will be a reverse of the above $irregularPlural array
|
||||
* You should not have to change this value below if you do change it use same format
|
||||
*
|
||||
* $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother')
|
||||
*/
|
||||
$irregularSingular = array_flip($irregularPlural);
|
||||
?>
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id: routes.php,v 1.5 2006-10-10 20:18:59 reed%reedloden.com Exp $ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* In this file, you set up routes to your controllers and their actions.
|
||||
* Routes are very important mechanism that allows you to freely connect
|
||||
* different urls to chosen controllers and their actions (functions).
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP v 0.2.9
|
||||
* @version $Revision: 1.5 $
|
||||
* @modifiedby $LastChangedBy: phpnut $
|
||||
* @lastmodified $Date: 2006-10-10 20:18:59 $
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
/**
|
||||
* Here, we are connecting '/' (base path) to controller called 'Pages',
|
||||
* its action called 'display', and we pass a param to select the view file
|
||||
* to use (in this case, /app/views/pages/home.thtml)...
|
||||
*/
|
||||
$Route->connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
||||
/**
|
||||
* ...and connect the rest of 'Pages' controller's urls.
|
||||
*/
|
||||
$Route->connect('/pages/edit', array('controller' => 'pages', 'action' => 'edit'));
|
||||
$Route->connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
|
||||
$Route->connect('/privacy-policy', array('controller' => 'pages', 'action' => 'privacy'));
|
||||
?>
|
||||
@@ -1,80 +0,0 @@
|
||||
CREATE TABLE `comments` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`assoc` int(10) NOT NULL default '0',
|
||||
`owner` int(10) NOT NULL default '0',
|
||||
`time` int(15) NOT NULL default '0',
|
||||
`text` text collate utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE `guests` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`pid` int(10) NOT NULL default '0',
|
||||
`uid` int(10) NOT NULL default '0',
|
||||
`invited` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `pid` (`pid`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE `pages` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`text` text collate utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
INSERT INTO `pages` (`id`, `text`) VALUES (1, '<h2>Join the Fun!</h2>\n<p>All over the world, we're celebrating the launch of Firefox 2. Join the fun by hosting or attending a party. We're targeting the weekend of October 27th for the shared celebration, but if you're hosting, you make the call.</p>\n\n<p>To join the fun, <a href="/users/register">register</a> for a Firefox Party account, and sign up to host or attend.</p>\n\n<p style="border: 1px solid #555; background: #faffd4; padding: 5px; font-weight: bold">Be one of the first 50 party hosts registered and get three extra launch exclusive t-shirts with your purchase of the <a href="">Firefox 2 Party Pack</a>. We're selling the party packs and shirts at cost, so it's a great deal, and for parties with unusually large attendance, we'll be sending out additional swag for door prizes and other give-aways. Stay tuned for updates!</p>');
|
||||
INSERT INTO `pages` (`id`, `text`) VALUES (2, '1162007940');
|
||||
|
||||
CREATE TABLE `parties` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`owner` int(10) NOT NULL default '0',
|
||||
`name` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`vname` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`address` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`tz` int(2) NOT NULL default '0',
|
||||
`website` text collate utf8_unicode_ci NOT NULL,
|
||||
`notes` text collate utf8_unicode_ci NOT NULL,
|
||||
`date` int(10) NOT NULL default '0',
|
||||
`duration` tinyint(2) NOT NULL default '2',
|
||||
`confirmed` tinyint(1) NOT NULL default '1',
|
||||
`canceled` tinyint(1) NOT NULL default '0',
|
||||
`guestcomments` tinyint(1) NOT NULL default '0',
|
||||
`inviteonly` tinyint(1) NOT NULL default '0',
|
||||
`invitecode` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`lat` float NOT NULL default '0',
|
||||
`long` float NOT NULL default '0',
|
||||
`zoom` tinyint(2) NOT NULL default '1',
|
||||
`useflickr` tinyint(1) NOT NULL default '0',
|
||||
`flickrperms` tinyint(1) NOT NULL default '0',
|
||||
`flickrid` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`flickrusr` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE `sessions` (
|
||||
`id` varchar(255) character set latin1 NOT NULL default '',
|
||||
`data` text character set latin1,
|
||||
`expires` int(11) default NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE `users` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`role` tinyint(1) NOT NULL default '0',
|
||||
`email` varchar(255) collate utf8_unicode_ci NOT NULL,
|
||||
`active` varchar(10) collate utf8_unicode_ci NOT NULL default '0',
|
||||
`password` varchar(75) collate utf8_unicode_ci NOT NULL default '',
|
||||
`salt` varchar(9) collate utf8_unicode_ci NOT NULL default '',
|
||||
`name` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`location` tinytext collate utf8_unicode_ci NOT NULL,
|
||||
`tz` tinyint(2) NOT NULL default '0',
|
||||
`website` text collate utf8_unicode_ci NOT NULL,
|
||||
`lat` float NOT NULL default '0',
|
||||
`long` float NOT NULL default '0',
|
||||
`zoom` tinyint(2) NOT NULL default '1',
|
||||
`showemail` tinyint(1) NOT NULL default '0',
|
||||
`showloc` tinyint(1) NOT NULL default '1',
|
||||
`showmap` tinyint(1) NOT NULL default '1',
|
||||
UNIQUE KEY `email` (`email`),
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
@@ -1,163 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
uses('sanitize');
|
||||
class AdminController extends AppController {
|
||||
var $name = 'Admin';
|
||||
var $uses = array('Party', 'User', 'Comment');
|
||||
var $components = array('Unicode');
|
||||
|
||||
function beforeFilter() {
|
||||
if (empty($_SESSION['User']) || $_SESSION['User']['role'] != 1) {
|
||||
$this->redirect('/');
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
function index() {
|
||||
$this->set('parties', $this->Party->findAll(null, null, "id ASC"));
|
||||
}
|
||||
|
||||
function users() {
|
||||
$this->set('users', $this->User->findAll(null, null, "id ASC"));
|
||||
}
|
||||
|
||||
function comments() {
|
||||
$this->set('comments', $this->Comment->findAll(null, null, "id ASC"));
|
||||
}
|
||||
|
||||
function edit($type, $id) {
|
||||
if (empty($this->data)) {
|
||||
switch($type) {
|
||||
case 'user':
|
||||
$this->User->id = $id;
|
||||
$user = $this->User->read();
|
||||
$this->set('user', $user);
|
||||
$this->data = $user;
|
||||
break;
|
||||
|
||||
case 'party':
|
||||
$this->Party->id = $id;
|
||||
$party = $this->Party->read();
|
||||
$this->set('party', $party);
|
||||
$this->data = $party;
|
||||
$this->data['Party']['name'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['name']));
|
||||
$this->data['Party']['vname'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['vname']));
|
||||
$this->data['Party']['website'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['website']));
|
||||
$this->data['Party']['address'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['address']));
|
||||
$this->data['Party']['notes'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['notes']));
|
||||
$this->data['Party']['flickrusr'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['flickrusr']));
|
||||
break;
|
||||
|
||||
case 'comment':
|
||||
$this->Comment->id = $id;
|
||||
$comment = $this->Comment->read();
|
||||
$this->set('comment', $comment);
|
||||
|
||||
$uid = $this->User->findById($comment['Comment']['owner']);
|
||||
$this->set('owner', $uid['User']['name']);
|
||||
|
||||
$this->data = $comment;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
switch($type) {
|
||||
case 'user':
|
||||
$this->User->id = $id;
|
||||
$this->User->save($this->data);
|
||||
break;
|
||||
|
||||
case 'party':
|
||||
$this->Party->id = $id;
|
||||
$clean = new Sanitize();
|
||||
$clean->cleanArray($this->data);
|
||||
$this->Party->save($this->data);
|
||||
break;
|
||||
|
||||
case 'comment':
|
||||
$this->Comment->id = $id;
|
||||
$this->Comment->save($this->data);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($type != 'party')
|
||||
$this->redirect('/admin/'.$type.'s');
|
||||
|
||||
else
|
||||
$this->redirect('/admin/');
|
||||
}
|
||||
}
|
||||
|
||||
function delete($type, $id) {
|
||||
switch($type) {
|
||||
case 'user':
|
||||
$this->User->del($id);
|
||||
$this->User->query("DELETE FROM guests WHERE uid = $id");
|
||||
break;
|
||||
|
||||
case 'party':
|
||||
$this->Party->del($id);
|
||||
$this->Party->query("DELETE FROM guests WHERE pid = $id");
|
||||
$this->Party->query("DELETE FROM comments WHERE assoc = $id");
|
||||
break;
|
||||
|
||||
case 'comment':
|
||||
$this->Comment->del($id);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($type != 'party')
|
||||
$this->redirect('/admin/'.$type.'s');
|
||||
|
||||
else
|
||||
$this->redirect('/admin/');
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
uses('sanitize');
|
||||
|
||||
class CommentsController extends AppController {
|
||||
var $name = 'Comments';
|
||||
var $components = array('Security');
|
||||
|
||||
function beforeFilter() {
|
||||
$this->Security->requirePost('add');
|
||||
}
|
||||
|
||||
function add($pid, $uid) {
|
||||
if (!$this->Session->check('User') || $uid != $_SESSION['User']['id'])
|
||||
$this->redirect('/');
|
||||
|
||||
if (!empty($this->data) && $this->Comment->canComment($pid, $uid)) {
|
||||
// Explictly destroy the last model to avoid an edit instead of an insert
|
||||
$this->Comment->create();
|
||||
|
||||
$clean = new Sanitize();
|
||||
$text = $clean->html($this->data['Comment']['text']);
|
||||
$this->data['Comment']['text'] = nl2br($text);
|
||||
$this->data['Comment']['owner'] = $uid;
|
||||
$this->data['Comment']['assoc'] = $pid;
|
||||
$this->data['Comment']['time'] = mktime();
|
||||
|
||||
if ($this->Comment->save($this->data)) {
|
||||
$this->redirect('/parties/view/'.$pid.'#c'.$this->Comment->getLastInsertID());
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
$this->redirect('/parties/view/'.$pid);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class HashComponent extends Object {
|
||||
|
||||
function password($pass, $data) {
|
||||
$string = $pass.uniqid(rand(), true).$data;
|
||||
$salt = substr(md5($string), 0, 9);
|
||||
$p = sha1($pass.$salt);
|
||||
$rv = array('pass' => $p, 'salt' => $salt);
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function keygen($chars) {
|
||||
$key = null;
|
||||
$pool = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
for ($i = 0; $i < $chars; $i++)
|
||||
$key .= $pool{rand(0,61)};
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
class MailComponent extends Object {
|
||||
var $from;
|
||||
var $to;
|
||||
var $reply;
|
||||
var $subject;
|
||||
var $message;
|
||||
var $envelope;
|
||||
var $head = "<strong>Firefox Party!</strong><br/>";
|
||||
var $foot;
|
||||
|
||||
|
||||
function mail($params) {
|
||||
if (array_key_exists('from', $params))
|
||||
$this->from = $params['from'];
|
||||
|
||||
if (array_key_exists('to', $params))
|
||||
$this->to = $params['to'];
|
||||
|
||||
if (array_key_exists('reply', $params))
|
||||
$this->reply = $params['reply'];
|
||||
|
||||
if (array_key_exists('subject', $params))
|
||||
$this->subject = $params['subject'];
|
||||
|
||||
if (array_key_exists('message', $params))
|
||||
$this->message = $params['message'];
|
||||
|
||||
if (array_key_exists('envelope', $params))
|
||||
$this->envelope = $params['envelope'];
|
||||
|
||||
if (array_key_exists('type', $params)) {
|
||||
switch($params['type']) {
|
||||
case 'act':
|
||||
$this->message = $this->head."<br/>\nThank you for registering! To activate your account, <a href=\"".$params['link']."\">click here</a> or paste the link below into your browser:<br/> ".$params['link'].$this->foot;
|
||||
break;
|
||||
|
||||
case 'prec':
|
||||
$this->message = $this->head."<br/>\nTo reset your password, <a href=\"".$params['link']."\">click here</a> or paste the link below into your browser:<br/> ".$params['link'].$this->foot;
|
||||
break;
|
||||
|
||||
case 'invite':
|
||||
$this->message = $this->head."<br/>\nYou've been invited by a friend to join them in celebrating the release of Firefox 2. Simply <a href=\"".$params['link']."\">click here</a> to confirm or cancel this invitation. If you don't already have an account, you'll need to create one.\n
|
||||
If you're unable to use the link above, simply paste the following URL into your browser: ".$params['link'].$this->foot;
|
||||
break;
|
||||
|
||||
case 'cancel':
|
||||
$this->message = $this->head."<br/>\nThe party you were attending has been canceled. For more information, please <a href=\"".$params['link']."\">click here</a>, or see the link below.\n ".$params['link'].$this->foot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function make_headers($type='html') {
|
||||
$headers = '';
|
||||
|
||||
switch($type) {
|
||||
case 'html':
|
||||
$headers .= 'MIME-Version: 1.0' . "\r\n";
|
||||
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($this->from)) {
|
||||
$headers .= "From: {$this->from}\r\n";
|
||||
|
||||
if (!empty($this->reply))
|
||||
$headers .= "Reply-To: {$this->reply}\r\n";
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
|
||||
function make_additional_parameters() {
|
||||
if (!empty($this->envelope)) {
|
||||
return '-f'.$this->envelope;
|
||||
}
|
||||
}
|
||||
|
||||
function send() {
|
||||
mail($this->to, $this->subject, $this->message, $this->make_headers(), $this->make_additional_parameters());
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class UnicodeComponent extends Object {
|
||||
/**
|
||||
* Unicode utilities. Converts and encodes characters up to 0xFFFF (65535)
|
||||
*/
|
||||
function unicode2utf($char) {
|
||||
if ($char < 128) {
|
||||
$rv = chr($char);
|
||||
}
|
||||
|
||||
else if ($char < 2048) {
|
||||
$rv = chr(192 + (($char - ($char % 64)) / 64));
|
||||
$rv .= chr(128 + ($char % 64));
|
||||
}
|
||||
|
||||
else {
|
||||
$rv = chr(224 + (($char - ($char % 4096)) / 4096));
|
||||
$rv .= chr(128 + ((($char % 4096) - ($char % 64)) / 64));
|
||||
$rv .= chr(128 + ($char % 64));
|
||||
}
|
||||
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function utf2unicode($char) {
|
||||
if (ord($char{0}) < 128)
|
||||
$rv = ord($char);
|
||||
|
||||
else if (ord($char{0}) < 224)
|
||||
$rv = ((ord($char{0}) - 192) * 64) + (ord($char{1}) - 128);
|
||||
|
||||
else if (ord($char{0}) < 240)
|
||||
$rv = ((ord($char{0}) - 224) * 4096) + ((ord($char{1}) - 128) * 64 + (ord($char{2}) - 128));
|
||||
|
||||
else
|
||||
$rv = ((ord($char{0}) - 240) * 262144) + ((ord($char{1}) - 128) * 4096) + ((ord($char{2}) - 128) * 64) + (ord($char{3}) - 128);
|
||||
|
||||
return $rv;
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
vendor('webServices');
|
||||
class FeedsController extends AppController {
|
||||
var $name = 'Feeds';
|
||||
var $components = array('Unicode');
|
||||
|
||||
function index() {
|
||||
header('Content-type: application/rss+xml');
|
||||
$this->layout = 'ajax';
|
||||
$this->set('count', $this->Feed->findCount());
|
||||
}
|
||||
|
||||
function latest() {
|
||||
header('Content-type: application/rss+xml');
|
||||
$this->layout = 'ajax';
|
||||
$this->set('latest', $this->Feed->findAll('', '', 'id DESC', 10, 1));
|
||||
}
|
||||
|
||||
function users() {
|
||||
header('Content-type: application/rss+xml');
|
||||
$this->layout = 'ajax';
|
||||
$this->set('count', $this->Feed->getUserCount());
|
||||
}
|
||||
|
||||
function comments($id = null) {
|
||||
$this->layout = 'ajax';
|
||||
header('Content-type: application/rss+xml');
|
||||
if (!is_numeric($id))
|
||||
return;
|
||||
|
||||
$this->set('comments', $this->Feed->getComments($id));
|
||||
$this->set('pid', $id);
|
||||
}
|
||||
|
||||
function photos($id = null) {
|
||||
$this->layout = 'ajax';
|
||||
header('Content-type: application/atom+xml');
|
||||
if (!is_numeric($id))
|
||||
return;
|
||||
|
||||
$party = $this->Feed->findById($id);
|
||||
$this->set('party', $party);
|
||||
|
||||
if (FLICKR_API_KEY != null && !$party['Feeds']['canceled']) {
|
||||
if ($party['Feeds']['useflickr'] == 1) {
|
||||
$data = array('type' => 'flickr', 'userid' => $party['Feeds']['flickrid'], 'randomize' => false);
|
||||
$flickr = new webServices($data);
|
||||
$photoset = $flickr->fetchPhotos(FLICKR_TAG_PREFIX.$id, 30, !$party['Feeds']['flickrperms']);
|
||||
$this->set('flickr', $photoset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function upcoming($limit = null) {
|
||||
$this->layout = 'ajax';
|
||||
header('Content-type: application/rss+xml');
|
||||
|
||||
($limit == null) ? $limit = 25 : $limit = intval($limit);
|
||||
|
||||
$this->set('latest', $this->Feed->findAll('WHERE date > '. time(), '', 'date ASC', $limit, 1));
|
||||
}
|
||||
|
||||
function ical() {
|
||||
$this->layout = 'ajax';
|
||||
header('Content-type: text/calendar');
|
||||
header("Content-Disposition: inline; filename=partylist.ics");
|
||||
$back = time() - 172800;
|
||||
$events = $this->Feed->findAll('WHERE date > '. $back, '', 'date ASC', null, 1);
|
||||
|
||||
$cal = array();
|
||||
|
||||
foreach($events as $event) {
|
||||
$event['Feeds']['name'] =
|
||||
preg_replace(array("/&#(\d{2,5});/e", "/(\n|\r|\f)/", "/\,/"),
|
||||
array('$this->Unicode->unicode2utf(${1})', ' ', '\,'),
|
||||
html_entity_decode($event['Feeds']['name']));
|
||||
$event['Feeds']['address'] =
|
||||
preg_replace(array("/&#(\d{2,5});/e", "/(\n|\r|\f)/", "/\,/"),
|
||||
array('$this->Unicode->unicode2utf(${1})', ' ', '\,'),
|
||||
html_entity_decode($event['Feeds']['address']));
|
||||
$event['Feeds']['notes'] =
|
||||
preg_replace(array("/&#(\d{2,5});/e", "/(\n|\r|\f)/", "/\,/"),
|
||||
array('$this->Unicode->unicode2utf(${1})', ' ', '\,'),
|
||||
html_entity_decode($event['Feeds']['notes']));
|
||||
array_push($cal, $event);
|
||||
}
|
||||
$this->set('events', $cal);
|
||||
}
|
||||
|
||||
function topguests($limit = null) {
|
||||
$this->layout = 'ajax';
|
||||
header('Content-type: application/rss+xml');
|
||||
|
||||
($limit == null) ? $limit = 25 : $limit = intval($limit);
|
||||
|
||||
$rv = $this->Feed->query("SELECT parties.name AS name,
|
||||
guests.pid AS id,
|
||||
COUNT(guests.pid) AS count
|
||||
FROM guests
|
||||
LEFT JOIN parties
|
||||
ON guests.pid = parties.id
|
||||
GROUP BY guests.pid
|
||||
ORDER BY count DESC
|
||||
LIMIT $limit");
|
||||
$this->set('items', $rv);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
uses('sanitize');
|
||||
class PagesController extends AppController {
|
||||
var $name = 'Pages';
|
||||
var $components = array('Unicode');
|
||||
|
||||
function display() {
|
||||
$this->pageTitle = 'Home';
|
||||
$this->set('current', 'home');
|
||||
$this->set('pcount', $this->Page->findCount());
|
||||
$this->set('ucount', $this->Page->getUsers());
|
||||
$text = $this->Page->query('SELECT text FROM pages WHERE id = 1');
|
||||
$time = $this->Page->query('SELECT text FROM pages WHERE id = 2');
|
||||
$this->set('time', $time[0]['pages']['text']);
|
||||
$this->set('front_text', preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($text[0]['pages']['text'])));
|
||||
}
|
||||
|
||||
function privacy() {
|
||||
$this->pageTitle = 'Privacy Policy';
|
||||
}
|
||||
|
||||
function edit() {
|
||||
if (isset($_SESSION['User']['id']) && $_SESSION['User']['role'] == 1) {
|
||||
if (empty($this->data)) {
|
||||
$text = $this->Page->query('SELECT text FROM pages WHERE id = 1');
|
||||
$time = $this->Page->query('SELECT text FROM pages WHERE id = 2');
|
||||
$this->data['Pages']['text'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($text[0]['pages']['text']));
|
||||
$this->set('selected', date('Y-m-d H:i:s', $time[0]['pages']['text']));
|
||||
}
|
||||
|
||||
else {
|
||||
// Paranoid? Nah...
|
||||
if ($_SESSION['User']['role'] == 1) {
|
||||
$clean = new Sanitize();
|
||||
$clean->cleanArray($this->data);
|
||||
$date = mktime($this->data['Pages']['date_hour'],
|
||||
$this->data['Pages']['date_min'],
|
||||
0,
|
||||
$this->data['Pages']['date_month'],
|
||||
$this->data['Pages']['date_day'],
|
||||
$this->data['Pages']['date_year']);
|
||||
|
||||
$this->Page->execute('UPDATE pages SET text = "'.$this->data['Pages']['text'].'" WHERE pages.id = 1');
|
||||
$this->Page->execute('UPDATE pages SET text = "'.$date.'" WHERE pages.id = 2');
|
||||
$this->redirect('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
die();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,472 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
uses('sanitize');
|
||||
vendor('webServices');
|
||||
class PartiesController extends AppController {
|
||||
var $name = 'Parties';
|
||||
var $uses = array('Party', 'Comment');
|
||||
var $helpers = array('Html', 'Form');
|
||||
var $components = array('Hash', 'Mail', 'Unicode');
|
||||
|
||||
function index() {
|
||||
$this->pageTitle = 'Party Map';
|
||||
$this->set('current', 'map');
|
||||
|
||||
if (!empty($this->data)) {
|
||||
$gcoder = new webServices(array('type' => 'geocode'));
|
||||
$loc = $gcoder->geocode($this->data['Party']['mloc']);
|
||||
|
||||
if ($loc)
|
||||
$this->set('map', 'initMashUp('.$loc['lat'].', '.$loc['lng'].');');
|
||||
|
||||
else
|
||||
$this->set('map', 'initMashUp();');
|
||||
}
|
||||
|
||||
else
|
||||
$this->set('map', 'initMashUp();');
|
||||
}
|
||||
|
||||
function add() {
|
||||
if (!$this->Session->check('User'))
|
||||
$this->redirect('/users/login');
|
||||
|
||||
$this->pageTitle = 'Create Party';
|
||||
$this->set('current', 'create');
|
||||
$this->set('map', 'mapInit()');
|
||||
|
||||
if(empty($this->data)) {
|
||||
$this->set('utz', $_SESSION['User']['tz']);
|
||||
$this->render();
|
||||
}
|
||||
|
||||
else {
|
||||
$temp = array('lat' => $this->data['Party']['lat'],
|
||||
'long' => $this->data['Party']['long'],
|
||||
'tz' => $this->data['Party']['tz']);
|
||||
|
||||
$clean = new Sanitize();
|
||||
$clean->cleanArray($this->data);
|
||||
|
||||
$this->data['Party']['lat'] = floatval($temp['lat']);
|
||||
$this->data['Party']['long'] = floatval($temp['long']);
|
||||
$this->data['Party']['tz'] = intval($temp['tz']);
|
||||
$this->set('utz', $this->data['Party']['tz']);
|
||||
|
||||
// Convert the selected time to GMT
|
||||
$secoffset = ($this->data['Party']['tz'] * 60 * 60);
|
||||
$offsetdate = gmmktime($this->data['Party']['hour_hour'],
|
||||
$this->data['Party']['minute_min'],
|
||||
0,
|
||||
$this->data['Party']['month_hour'],
|
||||
$this->data['Party']['day_day'],
|
||||
$this->data['Party']['year_year']);
|
||||
$this->data['Party']['date'] = ($offsetdate + $secoffset);
|
||||
$this->data['Party']['duration'] = intval($this->data['Party']['duration']);
|
||||
|
||||
$this->data['Party']['invitecode'] = $this->Hash->keygen(10);
|
||||
$this->data['Party']['owner'] = $_SESSION['User']['id'];
|
||||
|
||||
if (!preg_match("/^(http|https)\:\/\//i", $this->data['Party']['website']) &&
|
||||
!empty($this->data['Party']['website']))
|
||||
$this->Party->invalidate('website');
|
||||
|
||||
if ($this->Party->validates($this->data)) {
|
||||
if($this->Party->save($this->data)) {
|
||||
$this->Session->setFlash('Your party has been created!', 'infoFlash');
|
||||
$this->redirect('/parties/view/'.$this->Party->getLastInsertId());
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Session->setFlash('Please correct the errors below.', 'errorFlash');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function edit($id) {
|
||||
$this->Party->id = $id;
|
||||
$party = $this->Party->read();
|
||||
$this->set('party', $party);
|
||||
$this->pageTitle = 'Edit Party';
|
||||
$this->set('current', 'create');
|
||||
|
||||
if (empty($_SESSION['User']['id']))
|
||||
$this->redirect('/users/login/');
|
||||
|
||||
if ($party['Party']['owner'] != $_SESSION['User']['id'])
|
||||
$this->redirect('/parties/view/'.$id);
|
||||
|
||||
else {
|
||||
if (empty($this->data)) {
|
||||
$this->data = $party;
|
||||
|
||||
$date = array('hour' => intval(date('h', $party['Party']['date'])),
|
||||
'min' => intval(date('i', $party['Party']['date'])),
|
||||
'mon' => intval(date('m', $party['Party']['date'])),
|
||||
'day' => intval(date('d', $party['Party']['date'])),
|
||||
'year' => intval(date('Y', $party['Party']['date'])),
|
||||
'tz' => $party['Party']['tz']);
|
||||
|
||||
$this->set('date', $date);
|
||||
$this->data['Party']['name'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['name']));
|
||||
$this->data['Party']['vname'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['vname']));
|
||||
$this->data['Party']['website'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['website']));
|
||||
$this->data['Party']['address'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['address']));
|
||||
$this->data['Party']['notes'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['notes']));
|
||||
$this->data['Party']['flickrusr'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['Party']['flickrusr']));
|
||||
|
||||
if (GMAP_API_KEY != null) {
|
||||
if ($this->data['Party']['lat'])
|
||||
$this->set('map', 'mapInit('.$this->data['Party']['lat'].','.$this->data['Party']['long'].','.$this->data['Party']['zoom'].')');
|
||||
else
|
||||
$this->set('map', 'mapInit()');
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$clean = new Sanitize();
|
||||
$temp = array('lat' => $clean->sql($this->data['Party']['lat']),
|
||||
'long' => $clean->sql($this->data['Party']['long']),
|
||||
'tz' => $clean->sql($this->data['Party']['tz']));
|
||||
|
||||
$clean->cleanArray($this->data);
|
||||
|
||||
$this->data['Party']['lat'] = floatval($temp['lat']);
|
||||
$this->data['Party']['long'] = floatval($temp['long']);
|
||||
$this->data['Party']['tz'] = intval($temp['tz']);
|
||||
|
||||
$secoffset = ($this->data['Party']['tz'] * 60 * 60);
|
||||
|
||||
$offsetdate = gmmktime($this->data['Party']['hour_hour'],
|
||||
$this->data['Party']['minute_min'],
|
||||
0,
|
||||
$this->data['Party']['month_hour'],
|
||||
$this->data['Party']['day_day'],
|
||||
$this->data['Party']['year_year']);
|
||||
|
||||
$this->data['Party']['date'] = ($offsetdate - $secoffset);
|
||||
$this->data['Party']['owner'] = $party['Party']['owner'];
|
||||
$this->data['Party']['duration'] = intval($this->data['Party']['duration']);
|
||||
|
||||
$date = array('hour' => intval(date('h', $party['Party']['date'])),
|
||||
'min' => intval(date('i', $party['Party']['date'])),
|
||||
'mon' => intval(date('m', $party['Party']['date'])),
|
||||
'day' => intval(date('d', $party['Party']['date'])),
|
||||
'year' => intval(date('Y', $party['Party']['date'])),
|
||||
'tz' => $party['Party']['tz']);
|
||||
$this->set('date', $date);
|
||||
|
||||
if (!preg_match("/^(http|https)\:\/\//i", $this->data['Party']['website']) &&
|
||||
!empty($this->data['Party']['website']))
|
||||
$this->Party->invalidate('website');
|
||||
|
||||
if ($this->data['Party']['flickrusr'] != $party['Party']['flickrusr']) {
|
||||
$params = array('type' => 'flickr', 'username' => $this->data['Party']['flickrusr']);
|
||||
$flick = new webServices($params);
|
||||
$this->data['Party']['flickrid'] = $flick->getFlickrId();
|
||||
}
|
||||
|
||||
if ($this->Party->validates($this->data)) {
|
||||
if ($this->Party->save($this->data)) {
|
||||
$this->Session->setFlash('Party edited successfully.', 'infoFlash');
|
||||
$this->redirect('parties/view/'.$id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function view($id = null, $page = null) {
|
||||
if ($id == 'all') {
|
||||
$this->pageTitle = 'All Parties';
|
||||
$this->set('current', 'parties');
|
||||
|
||||
//Paginate!
|
||||
$count = $this->Party->findCount();
|
||||
$pages = ceil($count/100);
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
if ($page > 1)
|
||||
$this->set('prev', $page - 1);
|
||||
if ($page < $pages)
|
||||
$this->set('next', $page + 1);
|
||||
|
||||
$deck = $this->Party->findAll(null, null, "id ASC", 100, $page);
|
||||
shuffle($deck);
|
||||
$this->set('parties', $deck);
|
||||
}
|
||||
|
||||
else if (is_numeric($id)) {
|
||||
$party = $this->Party->findById($id);
|
||||
if (empty($party['Party']['id']))
|
||||
$this->redirect('/parties/view/all');
|
||||
|
||||
$this->set('current', 'parties');
|
||||
$this->set('host', $this->Party->getHost($party['Party']['owner']));
|
||||
$this->set('party', $party);
|
||||
$this->set('isguest', $this->Party->isGuest($id, @$_SESSION['User']['id']));
|
||||
$this->pageTitle = $party['Party']['name'];
|
||||
$this->set('map', 'mapInit('.$party['Party']['lat'].','.$party['Party']['long'].
|
||||
','.$party['Party']['zoom'].',\'stationary\')');
|
||||
$this->set('guests', $this->Party->getGuests($party['Party']['id']));
|
||||
$this->set('comments', $this->Party->getComments($id));
|
||||
|
||||
if (FLICKR_API_KEY != null) {
|
||||
if ($party['Party']['useflickr'] == 1) {
|
||||
$data = array('type' => 'flickr', 'userid' => $party['Party']['flickrid'], 'randomize' => true);
|
||||
$flickr = new webServices($data);
|
||||
$photoset = $flickr->fetchPhotos(FLICKR_TAG_PREFIX.$party['Party']['id'], 15, (($party['Party']['flickrperms']) ? false : true));
|
||||
$this->set('flickr', array_slice($photoset, 0, 9));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
$this->redirect('/parties/view/all');
|
||||
}
|
||||
|
||||
function invite($id = null) {
|
||||
$this->pageTitle = "Invite a Guest";
|
||||
if (is_numeric($id)) {
|
||||
$party = $this->Party->findById($id);
|
||||
if (empty($party['Party']['id']) ||
|
||||
$party['Party']['owner'] != $_SESSION['User']['id'] ||
|
||||
$party['Party']['canceled'] == 1)
|
||||
$this->redirect('/parties/view/all');
|
||||
|
||||
else {
|
||||
$this->set('partyid', $party['Party']['id']);
|
||||
$this->set('inviteurl', APP_BASE.'/parties/invited/'.$party['Party']['invitecode']);
|
||||
|
||||
$clean = new Sanitize();
|
||||
$uid = $clean->sql($_SESSION['User']['id']);
|
||||
$email = $this->Party->query("SELECT email FROM users WHERE id = ".$uid);
|
||||
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Party->validates($this->data)) {
|
||||
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
|
||||
'envelope' => APP_EMAIL,
|
||||
'to' => $this->data['Party']['einvite'],
|
||||
'reply' => $email[0]['users']['email'],
|
||||
'subject' => 'You\'ve been invited to '.APP_NAME.'!',
|
||||
'link' => APP_BASE.'/parties/invited/'.$party['Party']['invitecode'],
|
||||
'type' => 'invite');
|
||||
|
||||
$this->Mail->mail($message);
|
||||
$this->Mail->send();
|
||||
|
||||
$this->Session->setFlash($this->data['Party']['einvite'].' has been
|
||||
invited. You can invite another guest below or <a href="'.APP_BASE.'/parties/view/'.$id.'/">click here</a>
|
||||
to return to your party.', 'infoFlash');
|
||||
$this->data['Party']['einvite'] = null;
|
||||
}
|
||||
else {
|
||||
$this->validateErrors($this->Party);
|
||||
$this->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function invited($icode = null, $conf = null) {
|
||||
$this->pageTitle = "Confirm Invite";
|
||||
if ($icode == 'cancel') {
|
||||
$this->Session->delete('invite');
|
||||
$this->Session->delete('invitestep');
|
||||
$this->redirect('/');
|
||||
}
|
||||
|
||||
else {
|
||||
$clean = new Sanitize();
|
||||
$icode = $clean->sql($icode);
|
||||
$party = $this->Party->findByInvitecode($icode);
|
||||
|
||||
if (empty($party['Party']['id'])) {
|
||||
$this->Session->setFlash('Could not find a party matching that invite code, please check it and try again.', 'errorFlash');
|
||||
}
|
||||
|
||||
else {
|
||||
if (!empty($_SESSION['User']['id']) && !empty($_SESSION['invitestep']) && $conf == 'confirm') {
|
||||
$this->Party->addGuest($_SESSION['User']['id'], $_SESSION['invite']);
|
||||
$this->Session->setFlash('You have been successfully added to this party.', 'infoFlash');
|
||||
$this->redirect('/parties/view/'.$party['Party']['id']);
|
||||
}
|
||||
|
||||
else if (!empty($_SESSION['User']['id'])) {
|
||||
$this->set('confirm_only', true);
|
||||
$this->set('party', $party);
|
||||
$this->set('icode', $icode);
|
||||
$this->Session->write('invitestep', 'true');
|
||||
$this->Session->write('invite', $icode);
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Session->write('invite', $icode);
|
||||
$this->set('party', $party);
|
||||
$this->set('icode', $icode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function rsvp($pid) {
|
||||
if (is_numeric($pid) && isset($_SESSION['User']['id'])) {
|
||||
$party = $this->Party->findById($pid);
|
||||
if (empty($party['Party']['id'])) {
|
||||
$this->Session->setFlash('Invalid party id.', 'errorFlash');
|
||||
$this->redirect('/parties/view/all');
|
||||
}
|
||||
|
||||
else {
|
||||
if ($party['Party']['inviteonly']) {
|
||||
$this->Session->setFlash('This party invite only, you\'ll need an
|
||||
invitation from the host to join in', 'errorFlash');
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Party->rsvp($pid, $_SESSION['User']['id']);
|
||||
$this->Session->setFlash('You have been successfully added to this party.', 'infoFlash');
|
||||
$this->redirect('/parties/view/'.$pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
$this->redirect('/parties/view/all');
|
||||
}
|
||||
|
||||
function unrsvp($pid) {
|
||||
if (is_numeric($pid) && isset($_SESSION['User']['id'])) {
|
||||
$party = $this->Party->findById($pid);
|
||||
if (empty($party['Party']['id'])) {
|
||||
$this->Session->setFlash('Invalid party id.', 'errorFlash');
|
||||
$this->redirect('/parties/view/all');
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Party->unrsvp($pid, $_SESSION['User']['id']);
|
||||
$this->Session->setFlash('You have been successfully removed from this party.', 'infoFlash');
|
||||
$this->redirect('/parties/view/'.$pid);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
$this->redirect('/parties/view/all');
|
||||
}
|
||||
|
||||
function cancel($pid) {
|
||||
$this->pageTitle = "Cancel Party";
|
||||
if (!is_numeric($pid) || !isset($_SESSION['User']['id']))
|
||||
$this->redirect('/');
|
||||
|
||||
else
|
||||
$this->set('pid', $pid);
|
||||
|
||||
$party = $this->Party->findById($pid);
|
||||
if ($_SESSION['User']['id'] != $party['Party']['owner'])
|
||||
die();
|
||||
|
||||
if (!empty($this->data) && $_SESSION['User']['id'] == $party['Party']['owner']) {
|
||||
if ($this->data['Party']['confcancel'] == 1) {
|
||||
$guests = $this->Party->getGuests($pid);
|
||||
$guest_count = count($guests);
|
||||
|
||||
foreach($guests as $guest) {
|
||||
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
|
||||
'envelope' => APP_EMAIL,
|
||||
'to' => $guest['users']['email'],
|
||||
'reply' => $_SESSION['User']['email'],
|
||||
'subject' => 'Party Cancellation Notice',
|
||||
'link' => APP_BASE.'/parties/view/'.$pid,
|
||||
'type' => 'cancel');
|
||||
|
||||
$this->Mail->mail($message);
|
||||
$this->Mail->send();
|
||||
}
|
||||
|
||||
$this->Party->query("DELETE FROM guests WHERE pid = $pid LIMIT $guest_count");
|
||||
$this->Party->query("UPDATE parties SET canceled = '1', invitecode = '0' WHERE parties.id = $pid LIMIT 1");
|
||||
|
||||
$this->redirect('/parties/view/'.$pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function uncancel($pid) {
|
||||
if (!is_numeric($pid) || !isset($_SESSION['User']['id']))
|
||||
$this->redirect('/');
|
||||
|
||||
$party = $this->Party->findById($pid);
|
||||
if ($_SESSION['User']['id'] != $party['Party']['owner'])
|
||||
die();
|
||||
|
||||
$key = $this->Hash->keygen(10);
|
||||
$this->Party->query("UPDATE parties SET canceled = '0', invitecode = '$key' WHERE parties.id = $pid LIMIT 1");
|
||||
$this->redirect('/parties/view/'.$pid);
|
||||
}
|
||||
|
||||
function js($type = null, $data = null) {
|
||||
$this->layout = 'ajax';
|
||||
|
||||
if ($type == 'html') {
|
||||
header('Content-type: text/plain');
|
||||
$party = $this->Party->findById($data);
|
||||
$this->set('party', $party);
|
||||
}
|
||||
|
||||
else {
|
||||
header('Content-type: text/javascript');
|
||||
$parties = $this->Party->findAll();
|
||||
$this->set('parties', $parties);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,437 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
uses('sanitize');
|
||||
class UsersController extends AppController {
|
||||
var $name = 'Users';
|
||||
var $uses = array('User', 'Party');
|
||||
var $helpers = array('Html', 'Form');
|
||||
var $components = array('Security', 'Hash', 'Mail');
|
||||
|
||||
function index() {
|
||||
if (!isset($_SESSION['User'])) {
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
|
||||
$this->pageTitle = 'My Profile';
|
||||
|
||||
$user = $this->Session->read('User');
|
||||
$this->set('parties', $this->User->memberOf($user['id']));
|
||||
$this->set('hparties', $this->User->hostOf($user['id']));
|
||||
$this->set('iparties', $this->User->invitedTo($user['id']));
|
||||
}
|
||||
|
||||
function register() {
|
||||
$this->pageTitle = 'Register';
|
||||
$this->set('map', 'mapInit()');
|
||||
|
||||
if(empty($this->data)) {
|
||||
$this->set('utz', '0');
|
||||
$this->render();
|
||||
}
|
||||
|
||||
else {
|
||||
if ($this->User->findByEmail($this->data['User']['email']))
|
||||
$this->User->invalidate('email');
|
||||
|
||||
if ($this->data['User']['email'] !== $this->data['User']['confemail'])
|
||||
$this->User->invalidate('confemail');
|
||||
|
||||
if (!preg_match("/^(http|https)\:\/\//i", $this->data['User']['website']) &&
|
||||
!empty($this->data['User']['website']))
|
||||
$this->User->invalidate('website');
|
||||
|
||||
if ($this->data['User']['password'] !== $this->data['User']['confpass'])
|
||||
$this->User->invalidate('confpass');
|
||||
|
||||
if (empty($this->data['User']['password']) || empty($this->data['User']['confpass']))
|
||||
$this->User->invalidate('password');
|
||||
|
||||
// Repopulate the timezone with right value in case there's a validation error
|
||||
$this->set('utz', $this->data['User']['tz']);
|
||||
|
||||
if ($this->User->validates($this->data)) {
|
||||
$clean = new Sanitize();
|
||||
// Generate and set the password, salt and activation key
|
||||
$pass = $this->Hash->password($this->data['User']['password'],
|
||||
$this->data['User']['email']);
|
||||
$this->data['User']['active'] = $this->Hash->keygen(10);
|
||||
$this->data['User']['password'] = $pass['pass'];
|
||||
$this->data['User']['salt'] = $pass['salt'];
|
||||
|
||||
// Save a few fields from the wrath of cleanArray()
|
||||
$temp = array('lat' => $this->data['User']['lat'],
|
||||
'long' => $this->data['User']['long'],
|
||||
'tz' => $this->data['User']['tz'],
|
||||
'email' => $this->data['User']['email']);
|
||||
// Scrub 'a dub
|
||||
$clean->cleanArray($this->data);
|
||||
$this->data['User']['email'] = $temp['email'];
|
||||
$this->data['User']['long'] = floatval($temp['long']);
|
||||
$this->data['User']['lat'] = floatval($temp['lat']);
|
||||
$this->data['User']['tz'] = intval($temp['tz']);
|
||||
$this->data['User']['role'] = 0;
|
||||
|
||||
if($this->User->save($this->data)) {
|
||||
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
|
||||
'envelope' => APP_EMAIL,
|
||||
'to' => $this->data['User']['email'],
|
||||
'subject' => 'Your '.APP_NAME.' Registration',
|
||||
'link' => APP_BASE.'/users/activate/'.$this->data['User']['active'],
|
||||
'type' => 'act');
|
||||
$this->Mail->mail($message);
|
||||
$this->Mail->send();
|
||||
|
||||
if (isset($_SESSION['invite']))
|
||||
$this->Party->addGuest($this->User->getLastInsertId(), $_SESSION['invite']);
|
||||
|
||||
$this->Session->setFlash('Thank you for registering! To login, you\'ll
|
||||
need to activate your account. Please check
|
||||
your email for your activation link.', 'infoFlash');
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
|
||||
else {
|
||||
$this->data['User']['password'] = null;
|
||||
$this->data['User']['confpass'] = null;
|
||||
$this->render();
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$this->data['User']['password'] = null;
|
||||
$this->data['User']['confpass'] = null;
|
||||
$this->Session->setFlash('There was an error in your submission. Please
|
||||
correct the errors shown below and try again.',
|
||||
'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function edit() {
|
||||
if (!isset($_SESSION['User'])) {
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
$this->set('error', false);
|
||||
$this->pageTitle = 'Edit My Account';
|
||||
if (empty($this->data)) {
|
||||
$this->User->id = $_SESSION['User']['id'];
|
||||
$this->data = $this->User->read();
|
||||
$this->data['User']['password'] = "";
|
||||
$this->set('utz', $this->data['User']['tz']);
|
||||
|
||||
$this->data['User']['name'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['User']['name']));
|
||||
$this->data['User']['website'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['User']['website']));
|
||||
$this->data['User']['location'] = preg_replace("/&#(\d{2,5});/e",
|
||||
'$this->Unicode->unicode2utf(${1})',
|
||||
html_entity_decode($this->data['User']['location']));
|
||||
|
||||
if (GMAP_API_KEY != null) {
|
||||
if ($this->data['User']['lat'])
|
||||
$this->set('map', 'mapInit('.$this->data['User']['lat'].','.$this->data['User']['long'].','.$this->data['User']['zoom'].')');
|
||||
else
|
||||
$this->set('map', 'mapInit()');
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$user = $this->User->findById($_SESSION['User']['id']);
|
||||
$this->User->id = $user['User']['id'];
|
||||
$this->set('utz', $user['User']['tz']);
|
||||
|
||||
$clean = new Sanitize();
|
||||
$temp = array('password' => $this->data['User']['password'],
|
||||
'confpassword' => $this->data['User']['confpassword'],
|
||||
'lat' => $clean->sql($this->data['User']['lat']),
|
||||
'long' => $clean->sql($this->data['User']['long']),
|
||||
'tz' => $clean->sql($this->data['User']['tz']));
|
||||
//Nuke everything else
|
||||
$clean->cleanArray($this->data);
|
||||
|
||||
$this->data['User']['email'] = $user['User']['email'];
|
||||
$this->data['User']['password'] = $temp['password'];
|
||||
$this->data['User']['confpassword'] = $temp['confpassword'];
|
||||
$this->data['User']['lat'] = floatval($temp['lat']);
|
||||
$this->data['User']['long'] = floatval($temp['long']);
|
||||
$this->data['User']['tz'] = intval($temp['tz']);
|
||||
$this->data['User']['role'] = $user['User']['role'];
|
||||
|
||||
if (!preg_match("/^(http|https)\:\/\//i", $this->data['User']['website']) &&
|
||||
!empty($this->data['User']['website']))
|
||||
$this->User->invalidate('website');
|
||||
|
||||
if ($this->data['User']['password'] === $this->data['User']['confpassword'] &&
|
||||
!empty($this->data['User']['password'])) {
|
||||
$pass = $this->Hash->password($this->data['User']['password'], $user['User']['email']);
|
||||
$this->data['User']['password'] = $pass['pass'];
|
||||
$this->data['User']['salt'] = $pass['salt'];
|
||||
}
|
||||
|
||||
else if (empty($this->data['User']['password']) && empty($this->data['User']['confpassword'])) {
|
||||
$this->data['User']['password'] = $user['User']['password'];
|
||||
$this->data['User']['salt'] = $user['User']['salt'];
|
||||
}
|
||||
|
||||
else {
|
||||
$this->set('error', true);
|
||||
$this->User->invalidate('password');
|
||||
$this->User->invalidate('confpassword');
|
||||
}
|
||||
|
||||
if ($this->User->validates($this->data)) {
|
||||
if ($this->User->save($this->data)) {
|
||||
$sess = $this->User->findById($user['User']['id']);
|
||||
$this->redirect('/users/');
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$this->validateErrors($this->User);
|
||||
$this->data['User']['password'] = null;
|
||||
$this->data['User']['confpassword'] = null;
|
||||
$this->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function login() {
|
||||
if ($this->Session->Check('User'))
|
||||
$this->redirect('/users');
|
||||
|
||||
$this->pageTitle = 'Login';
|
||||
if (!empty($this->data)) {
|
||||
if (empty($this->data['User']['email']) || empty($this->data['User']['password']))
|
||||
$this->render();
|
||||
|
||||
$user = $this->User->findByEmail($this->data['User']['email']);
|
||||
$pass = sha1($this->data['User']['password'].$user['User']['salt']);
|
||||
|
||||
if ($user['User']['password'] == $pass) {
|
||||
if ($user['User']['active'] != 1) {
|
||||
$this->Session->setFlash('Your account hasn\'t been activated yet. Please
|
||||
check your email (including junk/spam folders)
|
||||
for your activation link, or click <a href="'
|
||||
.APP_BASE.'/users/recover/activate">here</a> to
|
||||
resend your activation details.', 'infoFlash');
|
||||
$this->render();
|
||||
}
|
||||
|
||||
else {
|
||||
if (isset($_SESSION['invite']))
|
||||
$this->Party->addGuest($user['User']['id'], $_SESSION['invite']);
|
||||
|
||||
$this->Session->write('User', $user['User']);
|
||||
$this->redirect('/users/');
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Session->setFlash('The email address and password you supplied do
|
||||
not match. Please try again.', 'errorFlash');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function view($id = null) {
|
||||
if (!is_numeric($id))
|
||||
$this->redirect('/');
|
||||
|
||||
else {
|
||||
$user = $this->User->findById($id);
|
||||
$this->pageTitle = $user['User']['name'];
|
||||
$this->set('user', $user);
|
||||
if (GMAP_API_KEY != null && !empty($user['User']['lat']))
|
||||
$this->set('map', 'mapInit('.$user['User']['lat'].','.$user['User']['long'].','.$user['User']['zoom'].',\'stationary\');');
|
||||
|
||||
$this->Party->unbindModel(array('hasMany' => array('Comment')));
|
||||
$this->set('hparties', $this->User->hostOf($id));
|
||||
$att = $this->User->query('SELECT parties.id, parties.name
|
||||
FROM parties
|
||||
LEFT JOIN guests
|
||||
ON parties.id = guests.pid
|
||||
WHERE guests.uid = '.$id);
|
||||
$this->set('parties', $att);
|
||||
}
|
||||
}
|
||||
|
||||
function logout() {
|
||||
$this->Session->destroy();
|
||||
$this->Session->delete('User');
|
||||
$this->redirect('/');
|
||||
}
|
||||
|
||||
function recover($aType = null, $aCode = null, $aId = null) {
|
||||
switch ($aType) {
|
||||
case "password":
|
||||
$this->pageTitle = "Password Recovery";
|
||||
$this->set('atitle', 'Password Recovery');
|
||||
$this->set('hideInput', false);
|
||||
$this->set('url', 'password');
|
||||
|
||||
if (!empty($this->data)) {
|
||||
$user = $this->User->findByEmail($this->data['User']['email']);
|
||||
|
||||
if (!isset($user['User']['email'])) {
|
||||
$this->Session->setFlash('Could not find a user with that email address. Please check it and try again.', 'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
else {
|
||||
$code = md5($user['User']['salt'].$user['User']['email'].$user['User']['password']);
|
||||
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
|
||||
'envelope' => APP_EMAIL,
|
||||
'to' => $user['User']['email'],
|
||||
'subject' => APP_NAME.' Password Request',
|
||||
'link' => APP_BASE.'/users/recover/password/'.$code.'/'.$user['User']['id'],
|
||||
'type' => 'prec');
|
||||
|
||||
$this->Mail->mail($message);
|
||||
$this->Mail->send();
|
||||
$this->Session->setFlash('An email has been sent to '.$user['User']['email'].' with reset instructions.', 'errorFlash');
|
||||
$this->redirect('users/login');
|
||||
}
|
||||
}
|
||||
|
||||
if ($aCode !== null && $aId !== null) {
|
||||
$this->set('hideInput', true);
|
||||
$this->set('reset', false);
|
||||
$user = $this->User->findById($aId);
|
||||
|
||||
if (!$user) {
|
||||
$this->Session->setFlash('Invalid request. Please check the URL and try again.', 'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
|
||||
if ($aCode == md5($user['User']['salt'].$user['User']['email'].$user['User']['password'])) {
|
||||
$this->set('reset', true);
|
||||
$this->set('code', $aCode."/".$aId);
|
||||
$this->render();
|
||||
}
|
||||
|
||||
else {
|
||||
$this->Session->setFlash('Invalid request. Please check the URL and try again.', 'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "activate":
|
||||
$this->pageTitle = 'Resend Activation Code';
|
||||
$this->set('atitle', 'Resend Activation Code');
|
||||
$this->set('hideInput', false);
|
||||
$this->set('url', 'activate');
|
||||
|
||||
if (!empty($this->data)) {
|
||||
$user = $this->User->findByEmail($this->data['User']['email']);
|
||||
|
||||
if (!$user) {
|
||||
$this->Session->setFlash('Could not find a user with that email address. Please check it and try again.', 'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
|
||||
if ($user['User']['active'] == 1)
|
||||
$this->redirect('/users/login');
|
||||
|
||||
else {
|
||||
$message = array('from' => APP_NAME.' <'.APP_EMAIL.'>',
|
||||
'envelope' => APP_EMAIL,
|
||||
'to' => $this->data['User']['email'],
|
||||
'subject' => 'Your '.APP_NAME.' Registration',
|
||||
'link' => APP_BASE.'/users/activate/'.$user['User']['active'],
|
||||
'type' => 'act');
|
||||
$this->Mail->mail($message);
|
||||
$this->Mail->send();
|
||||
$this->Session->setFlash('Your activation code has been resent.', 'infoFlash');
|
||||
$this->redirect('users/login');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "reset":
|
||||
if ($aCode !== null && $aId !== null) {
|
||||
if (!empty($this->data)) {
|
||||
$user = $this->User->findById($aId);
|
||||
if (!$user) {
|
||||
$this->Session->setFlash('Invalid request. Please check the URL and try again.', 'errorFlash');
|
||||
$this->render();
|
||||
}
|
||||
|
||||
if ($aCode == md5($user['User']['salt'].$user['User']['email'].$user['User']['password'])) {
|
||||
$string = $user['User']['email'] . uniqid(rand(), true) . $this->data['User']['password'];
|
||||
$this->data['User']['salt'] = substr(md5($string), 0, 9);
|
||||
$this->data['User']['password'] = sha1($this->data['User']['password'] . $this->data['User']['salt']);
|
||||
$this->data['User']['id'] = $aId;
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash('Your password has been reset.', 'infoFlash');
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->redirect('/');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function activate($aKey = null) {
|
||||
if ($aKey == null)
|
||||
$this->redirect('/');
|
||||
|
||||
else {
|
||||
$user = $this->User->findByActive($aKey);
|
||||
if (empty($user['User']['id'])) {
|
||||
$this->Session->setFlash('Your account could not be activated. Please make
|
||||
sure the URL entered is correct and try again.', 'errorFlash');
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
|
||||
else {
|
||||
$this->data = $user;
|
||||
$this->data['User']['active'] = 1;
|
||||
|
||||
if ($this->User->save($this->data)) {
|
||||
$this->Session->setFlash('Your account was successfully activated.', 'infoFlash');
|
||||
$this->redirect('/users/login');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id: index.php,v 1.3 2006-10-08 03:39:21 reed%reedloden.com Exp $ */
|
||||
/**
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.app
|
||||
* @since CakePHP v 0.10.0.1076
|
||||
* @version $Revision: 1.3 $
|
||||
* @modifiedby $LastChangedBy: phpnut $
|
||||
* @lastmodified $Date: 2006-10-08 03:39:21 $
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
|
||||
?>
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Admin extends AppModel {
|
||||
var $name = 'Admin';
|
||||
var $useTable = "parties";
|
||||
}
|
||||
?>
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Comment extends AppModel {
|
||||
var $name = 'Comment';
|
||||
|
||||
var $validate = array(
|
||||
'text' => "/^\S/"
|
||||
);
|
||||
|
||||
function canComment($pid, $uid) {
|
||||
$status = $this->query('SELECT owner, guestcomments FROM parties WHERE id = '.$pid);
|
||||
$guest = null;
|
||||
if ($status[0]['parties']['owner'] != $uid)
|
||||
$guest = $this->query('SELECT uid FROM guests WHERE pid = '.$pid.' AND uid = '.$uid);
|
||||
|
||||
if ($status[0]['parties']['guestcomments'] == 1) {
|
||||
if (!empty($guest[0]['guests']['uid']) || $uid == $status[0]['parties']['owner'])
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Feed extends AppModel {
|
||||
var $name = 'Feeds';
|
||||
var $useTable = "parties";
|
||||
|
||||
function getComments($aParty) {
|
||||
$rv = $this->query("SELECT * FROM comments WHERE assoc = ".$aParty." LIMIT 10");
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function getUserCount() {
|
||||
$rv = $this->query("SELECT COUNT(*) FROM users");
|
||||
return $rv[0][0]['COUNT(*)'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Guest extends AppModel {
|
||||
var $name = 'Guest';
|
||||
}
|
||||
?>
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Page extends AppModel {
|
||||
var $name = 'Page';
|
||||
var $useTable = 'parties';
|
||||
|
||||
function getUsers() {
|
||||
$rv = $this->query("SELECT COUNT(*) FROM users");
|
||||
return $rv[0][0]["COUNT(*)"];
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class Party extends AppModel {
|
||||
var $name = 'Party';
|
||||
var $validate = array(
|
||||
'name' => "/^\S/",
|
||||
'einvite' => VALID_EMAIL,
|
||||
'duration' => VALID_NUMBER
|
||||
);
|
||||
|
||||
function getComments($pid) {
|
||||
$rv = $this->query("SELECT users.id AS uid, users.name,
|
||||
comments.id AS cid, comments.time, comments.text
|
||||
FROM users, parties, comments
|
||||
WHERE comments.assoc = ".$pid."
|
||||
AND users.id = comments.owner
|
||||
AND parties.id = ".$pid."
|
||||
ORDER BY cid ASC");
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function getHost($uid) {
|
||||
$rv = $this->query("SELECT name FROM users WHERE id = ".$uid);
|
||||
return @$rv[0]['users']['name'];
|
||||
}
|
||||
|
||||
function isGuest($pid, $uid) {
|
||||
$rv = $this->query('SELECT id FROM guests WHERE uid = '.$uid.' AND pid = '.$pid);
|
||||
if (!empty($rv[0]['guests']['id']))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function getGuests($pid) {
|
||||
$rv = $this->query("SELECT users.id, users.name, users.email, guests.invited
|
||||
FROM users
|
||||
LEFT JOIN guests
|
||||
ON users.id = guests.uid
|
||||
WHERE guests.pid = ".$pid);
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function rsvp($pid, $uid) {
|
||||
$party = $this->findById($pid);
|
||||
if (!empty($party['Party']['id']) && !$this->isGuest($pid, $uid)) {
|
||||
$this->query("INSERT INTO guests (id, pid, uid, invited)
|
||||
VALUES (NULL, ".$party['Party']['id'].", ".$uid.", 0)");
|
||||
}
|
||||
}
|
||||
|
||||
function unrsvp($pid, $uid) {
|
||||
$party = $this->findById($pid);
|
||||
if (!empty($party['Party']['id']) && $this->isGuest($pid, $uid)) {
|
||||
$this->query('DELETE FROM guests WHERE uid = '.$uid.' AND pid = '.$pid);
|
||||
}
|
||||
}
|
||||
|
||||
function addGuest($uid, $icode) {
|
||||
$party = $this->findByInvitecode($icode);
|
||||
if (!empty($party['Party']['id'])) {
|
||||
$check = $this->query('SELECT uid FROM guests WHERE uid = '.$uid.'
|
||||
AND pid = '.$party['Party']['id']);
|
||||
if (empty($check[0]['guests']['uid']) && $uid != $party['Party']['owner']) {
|
||||
$this->query("INSERT INTO guests (id, pid, uid, invited)
|
||||
VALUES (NULL, ".$party['Party']['id'].", ".$uid.", 1)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findByInvitecode($icode) {
|
||||
$rv = $this->query('SELECT * FROM parties AS Party WHERE invitecode = "'.$icode.'" LIMIT 1');
|
||||
return @$rv[0];
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class User extends AppModel {
|
||||
var $name = 'User';
|
||||
var $validate = array(
|
||||
'email' => VALID_EMAIL,
|
||||
'name' => "/^\S/"
|
||||
);
|
||||
|
||||
function memberOf($uid) {
|
||||
$rv = $this->query('SELECT parties.id, parties.name FROM guests, parties WHERE guests.uid = '.$uid.' AND parties.id = guests.pid');
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function hostOf($uid) {
|
||||
$rv = $this->query('SELECT id, name FROM parties WHERE owner = '.$uid);
|
||||
return $rv;
|
||||
}
|
||||
|
||||
function invitedTo($uid) {
|
||||
$rv = $this->query('SELECT parties.id, parties.name FROM guests, parties WHERE guests.uid = '.$uid.' AND parties.id = guests.pid AND guests.invited = 1');
|
||||
return $rv;
|
||||
}
|
||||
}
|
||||
?>
|
||||
199
mozilla/webtools/partytool/vendors/webServices.php
vendored
199
mozilla/webtools/partytool/vendors/webServices.php
vendored
@@ -1,199 +0,0 @@
|
||||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Party Tool
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
class webServices {
|
||||
|
||||
var $userid;
|
||||
var $host;
|
||||
var $randomize;
|
||||
|
||||
function webServices($data) {
|
||||
switch ($data['type']) {
|
||||
case "flickr":
|
||||
$this->host = "api.flickr.com";
|
||||
|
||||
if (array_key_exists('userid', $data))
|
||||
$this->userid = $data['userid'];
|
||||
|
||||
if (array_key_exists('randomize', $data))
|
||||
$this->randomize = $data['randomize'];
|
||||
|
||||
if (array_key_exists('username', $data)) {
|
||||
$head = "GET /services/rest/?method=flickr.people.findByUsername&api_key=".FLICKR_API_KEY."&username=".$data['username']." HTTP/1.1\r\n";
|
||||
$head .= "Host: ".$this->host."\r\n";
|
||||
$head .= "Connection: Close\r\n\r\n";
|
||||
|
||||
if ($results = $this->fetchResults($head)) {
|
||||
preg_match('/nsid=\"(.*)\"/', $results, $matches);
|
||||
if ($matches[1]) {
|
||||
$this->userid = $matches[1];
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "gsuggest":
|
||||
$this->host = "api.google.com";
|
||||
break;
|
||||
|
||||
case "geocode":
|
||||
$this->host = "maps.google.com";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function getFlickrId() {
|
||||
return $this->userid;
|
||||
}
|
||||
|
||||
function fetchPhotos($tags, $num_results, $single_user) {
|
||||
$params = array('api_key' => FLICKR_API_KEY,
|
||||
'method' => 'flickr.photos.search',
|
||||
'format' => 'php_serial',
|
||||
'tags' => $tags,
|
||||
'per_page' => $num_results);
|
||||
|
||||
if ($single_user)
|
||||
$params['user_id'] = $this->userid;
|
||||
|
||||
$encoded_params = array();
|
||||
foreach ($params as $k => $v)
|
||||
$encoded_params[] = urlencode($k).'='.urlencode($v);
|
||||
|
||||
$head = 'GET /services/rest/?'.implode('&', $encoded_params)." HTTP/1.1 \r\n";
|
||||
$head .= 'Host: '.$this->host."\r\n";
|
||||
$head .= "Connection: Close\r\n\r\n";
|
||||
|
||||
if ($results = $this->fetchResults($head)) {
|
||||
$resp = split("\r\n\r\n", $results);
|
||||
$data = unserialize($resp[1]);
|
||||
|
||||
if ($data['stat'] == 'ok') {
|
||||
$arr = array();
|
||||
for ($i = 0; $i < count($data['photos']['photo']); $i++) {
|
||||
$p = $data['photos']['photo'][$i];
|
||||
$arr[$i] = array('id' => $p['id'],
|
||||
'owner' => $p['owner'],
|
||||
'secret' => $p['secret'],
|
||||
'server' => $p['server'],
|
||||
'farm' => $p['farm'],
|
||||
'title' => $p['title']);
|
||||
}
|
||||
|
||||
if ($this->randomize) {
|
||||
// Randomize the results
|
||||
shuffle($arr);
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
function GSuggest($phrase) {
|
||||
$soapy = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>
|
||||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
||||
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
|
||||
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
|
||||
<SOAP-ENV:Body>
|
||||
<doSpellingSuggestion xmlns="urn:GoogleSearch">
|
||||
<key xsi:type="xsd:string">'.GSEARCH_API_KEY.'</key>
|
||||
<phrase xsi:type="xsd:string">'.$phrase.'</phrase>
|
||||
</doSpellingSuggestion>
|
||||
</SOAP-ENV:Body>
|
||||
</SOAP-ENV:Envelope>';
|
||||
|
||||
$head = "POST /search/beta2 HTTP/1.1\r\n";
|
||||
$head .= "Host: api.google.com\r\n";
|
||||
$head .= "MessageType: CALL\r\n";
|
||||
$head .= "Content-type: text/xml\r\n";
|
||||
$head .= "Content-length: ".strlen($soapy)."\r\n";
|
||||
$head .= "Connection: Close\r\n\r\n";
|
||||
$head .= $soapy;
|
||||
|
||||
if ($results = $this->fetchResults($head)) {
|
||||
if (preg_match('/return xsi:type="xsd:string">(.*)</', $results, $matches))
|
||||
return $matches[1];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function geocode($query) {
|
||||
$head = "GET /maps/geo?q=".urlencode($query)."&output=xml&key=".GMAP_API_KEY." HTTP/1.1\r\n";
|
||||
$head .= "Host: maps.google.com\r\n";
|
||||
$head .= "Connection: Close\r\n\r\n";
|
||||
|
||||
if ($results = $this->fetchResults($head)) {
|
||||
if (stristr($results, '<code>200</code>')) {
|
||||
preg_match('/coordinates>(.*)</', $results, $matches);
|
||||
$ll = explode(',', $matches[1]);
|
||||
$rv = array('lat' => $ll[1], 'lng' => $ll[0]);
|
||||
return $rv;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function fetchResults($headers) {
|
||||
$fs = fsockopen($this->host, 80, $errno, $errstr, 30);
|
||||
if (!$fs)
|
||||
return 0;
|
||||
|
||||
else {
|
||||
fwrite($fs, $headers);
|
||||
stream_set_timeout($fs, 2);
|
||||
|
||||
$buffer = null;
|
||||
while (!feof($fs))
|
||||
$buffer .= fgets($fs, 128);
|
||||
|
||||
fclose($fs);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,18 +0,0 @@
|
||||
<h1>Comments</h1>
|
||||
<p>Switch view to: <a href="<?php echo $html->url('/admin/'); ?>">Parties»</a> <a href="<?php echo $html->url('/admin/users'); ?>">Users»</a></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>Text</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach($comments as $comment): ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo $html->url('/parties/view/'.$comment['Comment']['assoc'].'#c'.$comment['Comment']['id']); ?>"><?php echo $comment['Comment']['id']; ?></a></td>
|
||||
<td><?php echo $comment['Comment']['text']; ?></td>
|
||||
<td><a href="<?php echo $html->url('/admin/edit/comment/'.$comment['Comment']['id']); ?>">Edit</a></td>
|
||||
<td><a href="<?php echo $html->url('/admin/delete/comment/'.$comment['Comment']['id']); ?>" onclick="return confirm('Delete comment <?php echo $comment['Comment']['id']; ?>?')">Delete</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
@@ -1,128 +0,0 @@
|
||||
<?php if (isset($user)): ?>
|
||||
<h1><?php echo $user['User']['name'].' (<a href="'.$html->url('/users/view/'.$user['User']['id']).'">'.$user['User']['id']; ?></a>)</h1>
|
||||
<form class="fxform" action="<?php echo $html->url('/admin/edit/user/'.$user['User']['id']); ?>" method="post">
|
||||
<div>
|
||||
<label for="UserName" class="label-large">Name:</label>
|
||||
<?php echo $html->input('User/name', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserRole" class="label-large">Admin privileges:</label>
|
||||
<?php echo $html->checkbox('User/role'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserEmail" class="label-large">Email address:</label>
|
||||
<?php echo $html->input('User/email', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserWebsite" class="label-large">Website:</label>
|
||||
<?php echo $html->input('User/website', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserActive" class="label-large">Activation code:</label>
|
||||
<?php echo $html->input('User/active', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="location" class="label-large">Location:</label>
|
||||
<?php echo $html->input('User/location', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserShowemail" class="label-large">Show email:</label>
|
||||
<?php echo $html->checkbox('User/showemail'); ?><br/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserShowloc" class="label-large">Show location:</label>
|
||||
<?php echo $html->checkbox('User/showloc'); ?><br/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="UserShowmap" class="label-large">Show map:</label>
|
||||
<?php echo $html->checkbox('User/showmap'); ?><br/>
|
||||
</div>
|
||||
<?php echo $html->hidden('User/id', array('value' => $user['User']['id'])).$html->submit('Submit'); ?>
|
||||
</form>
|
||||
|
||||
<?php endif; if (isset($party)): ?>
|
||||
<h1><?php echo $party['Party']['name'].' (<a href="'.$html->url('/parties/view/'.$party['Party']['id']).'">'.$party['Party']['id']; ?></a>)</h1>
|
||||
<form class="fxform" action="<?php echo $html->url('/admin/edit/party/'.$party['Party']['id']); ?>" method="post">
|
||||
<div>
|
||||
<label for="PartyOwner" class="label-large">Party Owner:</label>
|
||||
<?php echo $html->input('Party/owner', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyName" class="label-large">Party Name:</label>
|
||||
<?php echo $html->input('Party/name', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyVname" class="label-large">Venue Name:</label>
|
||||
<?php echo $html->input('Party/vname', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyWebsite" class="label-large">Web site:</label>
|
||||
<?php echo $html->input('Party/website', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyAddress" class="label-large">Address:</label>
|
||||
<?php echo $html->input('Party/address', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyDate" class="label-large">Date:</label>
|
||||
<?php echo $html->input('Party/date', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyNotes" class="label-large">Additional Notes:</label>
|
||||
<?php echo $html->textarea('Party/notes', array('rows' => 10, 'cols' => 50)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyConfirmed" class="label-large">Time:</label>
|
||||
<?php echo $html->radio('Party/confirmed', array(0 => 'Tentative', 1 => 'Confirmed')); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyDuration" class="label-large">Duration (in hours):</label>
|
||||
<?php echo $html->input('Party/duration', array('size' => 5)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyCanceled" class="label-large">Canceled:</label>
|
||||
<?php echo $html->checkbox('Party/canceled'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyUseflickr" class="label-large">Use Flickr:</label>
|
||||
<?php echo $html->checkbox('Party/useflickr'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyFlickrperms" class="label-large">Show:</label>
|
||||
<?php echo $html->radio('Party/flickrperms', array(0 => 'Only my photos', 1 => 'Anyone\'s photos')); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyFlickrusr" class="label-large">Flickr username:</label>
|
||||
<?php echo $html->input('Party/flickrusr', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyFlickrusr" class="label-large">Flickr id:</label>
|
||||
<?php echo $html->input('Party/flickrid', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyInviteonly" class="label-large">Invite only:</label>
|
||||
<?php echo $html->checkbox('Party/inviteonly'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyGuestcomments" class="label-large">Limit comments to party guests only:</label>
|
||||
<?php echo $html->checkbox('Party/guestcomments'); ?>
|
||||
</div>
|
||||
<br/>
|
||||
<?php echo $html->hidden('Party/id', array('value' => $party['Party']['id'])).$html->submit('Submit'); ?>
|
||||
</form>
|
||||
|
||||
<?php endif; if(isset($comment)): ?>
|
||||
<h1>Comment <?php echo '<a href="'.$html->url('/parties/view/'.$comment['Comment']['assoc'].'#c'.$comment['Comment']['id']).'">#'.$comment['Comment']['id']; ?></a> by <?php echo '<a href="'.$html->url('/users/view/'.$comment['Comment']['owner']).'">'.$owner; ?></a></h1>
|
||||
<form class="fxform" action="<?php echo $html->url('/admin/edit/comment/'.$comment['Comment']['id']); ?>" method="post">
|
||||
<div>
|
||||
<label for="CommentAssoc" class="label-large">Party:</label>
|
||||
<?php echo $html->input('Comment/assoc', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="CommentText" class="label-large">Text:</label>
|
||||
<?php echo $html->textarea('Comment/text', array('rows' => 10, 'cols' => 50)); ?>
|
||||
</div>
|
||||
<?php echo $html->hidden('Comment/id', array('value' => $comment['Comment']['id'])).$html->submit('Submit'); ?>
|
||||
</form>
|
||||
|
||||
<?php endif; ?>
|
||||
@@ -1,18 +0,0 @@
|
||||
<h1>Parties</h1>
|
||||
<p>Switch view to: <a href="<?php echo $html->url('/admin/users'); ?>">Users»</a> <a href="<?php echo $html->url('/admin/comments'); ?>">Comments»</a></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>Name</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach($parties as $party): ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo $html->url('/parties/view/'.$party['Party']['id']); ?>"><?php echo $party['Party']['id']; ?></a></td>
|
||||
<td><?php echo $party['Party']['name']; ?></td>
|
||||
<td><a href="<?php echo $html->url('/admin/edit/party/'.$party['Party']['id']); ?>">Edit</a></td>
|
||||
<td><a href="<?php echo $html->url('/admin/delete/party/'.$party['Party']['id']); ?>" onclick="return confirm('Delete party <?php echo $party['Party']['id']; ?>?')">Delete</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
@@ -1,18 +0,0 @@
|
||||
<h1>Users</h1>
|
||||
<p>Switch view to: <a href="<?php echo $html->url('/admin/'); ?>">Parties»</a> <a href="<?php echo $html->url('/admin/comments'); ?>">Comments»</a></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>Name</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach($users as $user): ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo $html->url('/users/view/'.$user['User']['id']); ?>"><?php echo $user['User']['id']; ?></a></td>
|
||||
<td><?php echo $user['User']['name']; ?></td>
|
||||
<td><a href="<?php echo $html->url('/admin/edit/user/'.$user['User']['id']); ?>">Edit</a></td>
|
||||
<td><a href="<?php echo $html->url('/admin/delete/user/'.$user['User']['id']); ?>" onclick="return confirm('Delete user <?php echo $user['User']['id']; ?>?')">Delete</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php if(!isset($_SESSION['User'])): ?>
|
||||
<strong>Welcome, Guest!</strong>
|
||||
<a href="<?php echo $html->url('/users/login'); ?>">Login</a> | <a href="<?php echo $html->url('/users/register'); ?>">Register</a>
|
||||
<?php else: ?>
|
||||
<strong>Welcome, <?php echo $_SESSION['User']['name']; ?>!</strong>
|
||||
<a href="<?php echo $html->url('/users'); ?>">My Account</a> | <a href="<?php echo $html->url('/users/logout'); ?>">Logout</a>
|
||||
<?php endif; ?>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Latest Comments"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/'.$pid); ?></link>
|
||||
<title><?php echo APP_NAME." - Latest Comments"; ?></title>
|
||||
<?php foreach($comments as $comment): ?>
|
||||
<item>
|
||||
<title><![CDATA[<?php echo substr($comment['comments']['text'], 0, 25).'...'; ?>]]></title>
|
||||
<description><?php echo $comment['comments']['text'] ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/'.$comment['comments']['assoc'].'#c'.$comment['comments']['id']); ?></link>
|
||||
</item>
|
||||
<?php endforeach; ?>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,22 +0,0 @@
|
||||
BEGIN:VCALENDAR
|
||||
X-WR-CALNAME:<?php echo APP_NAME."\n"; ?>
|
||||
X-WR-CALDESC:Upcoming Parties
|
||||
PRODID:-//MozillaPartyTool//calendar//EN
|
||||
VERSION:2.0
|
||||
CALSCALE:GREGORIAN
|
||||
METHOD:PUBLISH
|
||||
<?php foreach($events as $event):
|
||||
if ($event['Feeds']['canceled']) continue; ?>
|
||||
BEGIN:VEVENT
|
||||
UID:<?php echo APP_BASE.$html->url('/parties/view/'.$event['Feeds']['id'])."\n"; ?>
|
||||
DTSTAMP:<?php echo gmdate('Ymd\This\Z', $event['Feeds']['date'])."\n"; ?>
|
||||
LOCATION:<?php echo $event['Feeds']['lat'].'\, '.$event['Feeds']['long'].'('.$event['Feeds']['address'].")\n"; ?>
|
||||
SUMMARY:<?php echo $event['Feeds']['name']."\n"; ?>
|
||||
DTSTART:<?php echo gmdate('Ymd\This', $event['Feeds']['date'])."\n"; ?>
|
||||
DURATION:PT<?php echo $event['Feeds']['duration']; ?>H
|
||||
URL:<?php echo APP_BASE.$html->url('/parties/view/'.$event['Feeds']['id'])."\n"; ?>
|
||||
STATUS:<?php echo (($event['Feeds']['confirmed'] == 1) ? "CONFIRMED" : "TENTATIVE")."\n"; ?>
|
||||
DESCRIPTION: <?php echo $event['Feeds']['name'].'\n '.$event['Feeds']['address'].'\n '.date('h:ia', $event['Feeds']['date']).'\n '.$event['Feeds']['notes'].'\n'."\n"; ?>
|
||||
END:VEVENT
|
||||
<?php endforeach; ?>
|
||||
END:VCALENDAR
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Party Count"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/'); ?></link>
|
||||
<title><?php echo APP_NAME." - Party Count"; ?></title>
|
||||
<item>
|
||||
<title><?php echo $count; ?></title>
|
||||
<description>Total Parties</description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/all/'); ?></link>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Latest Parties"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/'); ?></link>
|
||||
<title><?php echo APP_NAME." - Latest Parties"; ?></title>
|
||||
<?php foreach($latest as $party):
|
||||
if ($party['Feeds']['canceled']) continue; ?>
|
||||
<item>
|
||||
<title><?php echo $party['Feeds']['name'] ?></title>
|
||||
<description><?php echo $party['Feeds']['vname'] ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/'.$party['Feeds']['id']); ?></link>
|
||||
</item>
|
||||
<?php endforeach; ?>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; ?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title><?php echo $party['Feeds']['name']; ?></title>
|
||||
<id>tag:<?php echo APP_BASE; ?>,2006:/parties/view/<?php echo $party['Feeds']['id']; ?></id>
|
||||
<subtitle><?php echo APP_NAME; ?> Photostream</subtitle>
|
||||
<updated><?php echo date('Y-m-d\TH:i:s\Z'); ?></updated>
|
||||
<generator uri="http://www.screwedbydesign.com/software/partytool">Mozilla Party Tool</generator>
|
||||
|
||||
<?php foreach ($flickr as $pic): ?>
|
||||
<entry>
|
||||
<title><?php echo $pic['title']; ?></title>
|
||||
<link rel="alternate" type="text/html" href="http://www.flickr.com/photos/<?php echo $pic['owner']."/".$pic['id']."/"; ?>"/>
|
||||
<id>tag:flickr.com,2005:/photo/<?php echo $pic['id']; ?></id>
|
||||
<published><?php echo date('Y-m-d\TH:i:s\Z'); ?></published>
|
||||
<updated><?php echo date('Y-m-d\TH:i:s\Z'); ?></updated>
|
||||
<content type="html"><a href="http://www.flickr.com/photos/<?php echo $pic['owner']."/".$pic['id']."/" ?>"> <img src="http://static.flickr.com/<?php echo $pic['server']."/".$pic['id']."_".$pic['secret']."_m.jpg" ?>" title="<?php echo $pic['title']; ?>"/></a></content>
|
||||
<author>
|
||||
<name><?php echo $pic['owner']; ?></name>
|
||||
<uri>http://www.flickr.com/people/<?php echo $pic['owner']; ?>/</uri>
|
||||
</author>
|
||||
</entry>
|
||||
<?php endforeach; ?>
|
||||
</feed>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Top Guests"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/all'); ?></link>
|
||||
<title><?php echo APP_NAME." - Top Guests"; ?></title>
|
||||
<?php foreach($items as $item):?>
|
||||
<item>
|
||||
<title><?php echo $item['parties']['name'].' ('.$item[0]['count'].')'; ?></title>
|
||||
<description><?php echo $item['parties']['name'].' - '.$item[0]['count'].' guest'.(($item[0]['count'] != 1) ? 's' : ''); ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/'.$item['guests']['id']); ?></link>
|
||||
</item>
|
||||
<?php endforeach; ?>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Upcoming Parties"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/'); ?></link>
|
||||
<title><?php echo APP_NAME." - Upcoming Parties"; ?></title>
|
||||
<?php foreach($latest as $party):
|
||||
if ($party['Feeds']['canceled']) continue; ?>
|
||||
<item>
|
||||
<title><![CDATA[<?php echo $party['Feeds']['name'] ?>]]></title>
|
||||
<description><?php echo date('Y-m-d H:i', $party['Feeds']['date']); ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/parties/view/'.$party['Feeds']['id']); ?></link>
|
||||
</item>
|
||||
<?php endforeach; ?>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; ?>
|
||||
<rss version="0.91">
|
||||
<channel>
|
||||
<pubDate><?php echo date('r'); ?></pubDate>
|
||||
<description><?php echo APP_NAME." - Total Users"; ?></description>
|
||||
<link><?php echo APP_BASE.$html->url('/'); ?></link>
|
||||
<title><?php echo APP_NAME." - Total Users"; ?></title>
|
||||
<item>
|
||||
<title><?php echo $count; ?></title>
|
||||
<description>Total Users</description>
|
||||
<link><?php echo APP_BASE.$html->url('/'); ?></link>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title><?php echo APP_NAME." - ".$title_for_layout?></title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="<?php echo $html->url('/favicon.ico'); ?>"/>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $html->url('/css/main.css'); ?>"/>
|
||||
<link rel="alternate" type="application/rss+xml" href="<?php echo $html->url('/feeds/latest'); ?>"/>
|
||||
</head>
|
||||
<body<?php echo (isset($map)) ? ' onload="'.$map.'" onunload="GUnload()"' : '';?>>
|
||||
<div id="container">
|
||||
<p class="skipLink"><a href="#content" accesskey="2">Skip to main content</a></p>
|
||||
<div id="mozilla-com"><a href="http://www.mozilla.com/">Visit Mozilla.com</a></div>
|
||||
<div id="header">
|
||||
<div id="key-title">
|
||||
<h1><a href="<?php echo $html->url('/'); ?>" title="Return to home page" accesskey="1"><img src="<?php echo $html->url('/img/firefox-title.png'); ?>" width="276" height="54" alt="Firefox Party"/></a></h1>
|
||||
<div id="user"><?php echo $this->renderElement('user_options'); ?></div>
|
||||
</div>
|
||||
<div id="key-menu">
|
||||
<ul id="menu-firefox">
|
||||
<li<?php echo (@$current == 'home') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/'); ?>">Home</a></li>
|
||||
<li<?php echo (@$current == 'map') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/parties/'); ?>">View Map</a></li>
|
||||
<li<?php echo (@$current == 'parties') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/parties/view/all/'); ?>">View Parties</a></li>
|
||||
<li<?php echo (@$current == 'create') ? ' class="current"' : ''?>><a href="<?php echo $html->url('/parties/add/'); ?>">Create Party</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<?php $this->controller->Session->flash(); ?>
|
||||
|
||||
<?php echo $content_for_layout; ?>
|
||||
</div>
|
||||
<div id="footer">
|
||||
Copyright © <?php echo date('Y'); ?> Mozilla<br/>
|
||||
<a href="<?php echo $html->url('/privacy-policy'); ?>">Privacy Policy</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +0,0 @@
|
||||
<div id='flash' class='error'><?php echo $content_for_layout ?></div>
|
||||
@@ -1 +0,0 @@
|
||||
<div id='flash' class='info'><?php echo $content_for_layout ?></div>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
$difference = $time - time();
|
||||
$days_left = floor($difference/60/60/24);
|
||||
?>
|
||||
<div id="f-left">
|
||||
<?php echo $front_text;
|
||||
if (@$_SESSION['User']['role'] == 1): ?>
|
||||
<a href="<?php echo $html->url('/pages/edit'); ?>">Edit</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div id="f-right">
|
||||
<div class="cbox">
|
||||
<span class="ctxt"><?php echo $pcount."</span><br/>".(($pcount == 1) ? ' Party' : ' Parties'); ?>
|
||||
<div class="ifeed">
|
||||
<a style="padding-right: 2px;" title="Party Calendar" href="<?php echo $html->url('/feeds/ical'); ?>"><img src="<?php echo $html->url('/img/ical.png'); ?>" alt="iCAL"/></a><a title="Party Count Feed" href="<?php echo $html->url('/feeds/'); ?>"><img src="<?php echo $html->url('/img/feed16.png'); ?>" alt="RSS"/></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbox">
|
||||
<span class="ctxt"><?php echo $ucount."</span><br/>".(($ucount == 1) ? ' Partygoer' : ' Partygoers'); ?>
|
||||
<div class="cfeed">
|
||||
<a title="User Count Feed" href="<?php echo $html->url('/feeds/users/'); ?>"><img src="<?php echo $html->url('/img/feed16.png'); ?>" alt="RSS"/></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($days_left > 0): ?>
|
||||
<div class="cbox">
|
||||
<span class="ctxt"><?php echo $days_left."</span><br/>".(($days_left == 1) ? ' Day' : ' Days'); ?> until we party!
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
@@ -1,6 +0,0 @@
|
||||
<form action="<?php echo $html->url('/pages/edit'); ?>" method="post">
|
||||
<h1>Front Page Text</h1>
|
||||
<?php echo $html->textarea('Pages/text', array('rows' => 35, 'cols' => 80)); ?>
|
||||
<h1>Countdown Timer</h1>
|
||||
<?php echo $html->dateTimeOptionTag('Pages/date', 'YMD', 24, $selected).'<br/><br/>'.$html->submit('Submit'); ?>
|
||||
</form>
|
||||
@@ -1,42 +0,0 @@
|
||||
<h2>Mozilla Privacy Policy</h2>
|
||||
|
||||
<h3>Website Visitors</h3>
|
||||
|
||||
<p>Except as described below, the Mozilla Foundation and the Mozilla Corporation (collectively "Mozilla") do not collect or require visitors to its Web sites to furnish personally-identifying information such as names, email addresses and phone numbers. Like most Web site operators, Mozilla does collect non-personally-identifying information of the sort that web browsers and servers typically make available, such as the browser type, language preference, referring site, and date and time of each visitor request. Mozilla also collects potentially personally-identifying information like Internet Protocol (IP) addresses, which are non-personally-identifying in and of themselves but could be used in conjunction with other information to personally identify users.</p>
|
||||
|
||||
<p>Mozilla's purpose in collecting this information is to better understand how Mozilla's visitors use its Web sites. To that end, Mozilla may share potentially personally-identifying information with its employees, contractors and affiliated organizations. Mozilla may also release non-personally-identifying information about visitors, e.g. by publishing a report on Web site usage trends. Otherwise, Mozilla will not publicly release potentially personally-identifying information except under the same circumstances as Mozilla releases personally-identifying information. Those circumstances are explained in detail below.</p>
|
||||
|
||||
<h3>Community Members</h3>
|
||||
|
||||
<p>Certain members of the Mozilla community (contributors, customers, etc.) choose to interact with Mozilla in ways that require Mozilla and others to know more about them. The amount and type of information that Mozilla gathers from those members depends on the nature of the interaction. For example, members who wish to post content to certain portions of Mozilla's Web sites are asked to provide usernames that identify that content as having been posted by a particular member. Developers, by comparison, are asked to provide contact information, up to and sometimes including telephone or fax numbers, so that they can be contacted as necessary. Customers of the Mozilla store are asked to provide even more information, including billing and shipping addresses and credit card or similar information. In each case, Mozilla collects personally-identifying information only insofar as is necessary to fulfill the purpose of the community member's interaction with Mozilla.</p>
|
||||
|
||||
<p>Mozilla is an open organization that believes in sharing as much information as possible about its products, its operations and its associations. Accordingly, community members should assume - as should most folks who interact with Mozilla - that any personally-identifying information provided to Mozilla will be made available to the public. There are three broad exceptions to that rule:</p>
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Mozilla does not publicly release information gathered in connection with commercial transactions (i.e., transactions involving money), including transactions conducted through the Mozilla Store.</li>
|
||||
<li>Mozilla does not make publicly available information that is used to authenticate users the publication of which would compromise the security of Mozilla's Web sites (e.g., passwords).</li>
|
||||
<li>Mozilla does not make publicly available information that it specifically promises at the time of collection to maintain in confidence.</li>
|
||||
</ol>
|
||||
|
||||
<p>Outside those three contexts, users should assume that personally-identifying information provided through Mozilla's Web sites will be made available to the public.</p>
|
||||
|
||||
<h3>Interactive Product Features</h3>
|
||||
|
||||
<p>Certain Mozilla products contain features that report, or that permit users to report, the user's usage patterns and problems - whether caused by Mozilla's software, third party software, or third-party Web sites - to Mozilla. The reports generated by these features typically include non-personally-identifying information such as the configuration of the user's computer and the code running at the time the problem occurred. Some of these features give users the option of providing personally-identifying information, though none of these features require it. Some Mozilla software features that do permit users to provide personally-identifying information advise in advance that such information will not be made publicly available. Mozilla analyzes the information provided by these interactive product features to develop a better understanding of how its products are performing and being used. It does not use the information to track the usage of its products by identifiable individuals.</p>
|
||||
|
||||
<h3>Cookies</h3>
|
||||
|
||||
<p>A cookie is a string of information that a Web site stores on a visitor's computer, and that the visitor's browser provides to the Web site each time the visitor returns. Mozilla's Web sites use cookies to help Mozilla identify and track visitors, their usage of Mozilla Web sites, and their Web site access preferences across multiple requests and visits to Mozilla's Web sites. It is possible to link cookies to personally-identifying information, thereby permitting Web site operators to track the online movements of particular individuals. Mozilla, however, does not do so. Instead, it uses the information provided by cookies to develop a better understanding of how Mozilla's visitors use, and to facilitate those visitors' interactions with, Mozilla's Web sites. Mozilla visitors who do not wish to have cookies placed on their computers by Mozilla or its contractors should set their browsers to refuse cookies before linking to Mozilla's Web sites. Certain features of Mozilla's Web sites may not function properly without the aid of cookies.</p>
|
||||
|
||||
<h3>Protection of Certain Personally-Identifying Information</h3>
|
||||
|
||||
<p>Where Mozilla has collected personally-identifying information subject to one of the three exceptions described in the Contributors and Customers section, above, it discloses that information only to those of its employees, contractors and affiliated organizations that need to know that information in order to process it on Mozilla's behalf and that have agreed not to disclose it to others. Some of those employees, contractors and affiliated organizations may be located outside of your home country; by using Mozilla's Web sites, you consent to the transfer of your information to them. Mozilla does not rent or sell such information to anyone. Other than to its employees, contractors and affiliated organizations, as described above, Mozilla discloses such information only when required to do so by law, or when Mozilla believes in good faith that disclosure is reasonably necessary to protect the property or rights of Mozilla, members of the Mozilla community, or the public at large. Mozilla takes all measures reasonably necessary to protect against the unauthorized access, use, alteration or destruction of such information</p>
|
||||
|
||||
<h3>Updating of Personally-Identifying Information</h3>
|
||||
|
||||
<p>Mozilla permits users to freely update and correct their personally-identifying information as maintained by Mozilla. To do so, users need only look for the links and other tools available on Mozilla's Web sites or contact Mozilla by email.</p>
|
||||
|
||||
<h3>Privacy Policy Changes</h3>
|
||||
|
||||
<p>Although changes are likely to be minor, Mozilla may change its Privacy Policy from time to time. Any and all changes will be reflected on this page. Substantive changes will also be announced through the standard mechanisms through which Mozilla communicates with the Mozilla community, including Mozilla's "mozilla-announce" mailing lists.</p>
|
||||
@@ -1,109 +0,0 @@
|
||||
<h1>Create a Party</h1>
|
||||
<form class="fxform" action="<?php echo $html->url('/parties/add'); ?>" method="post">
|
||||
<div>
|
||||
<label for="PartyName" class="label-large">Party Name<span class="required">*</span>:</label>
|
||||
<?php echo $html->input('Party/name', array('size' => 40)); ?>
|
||||
<?php echo $html->tagErrorMsg('Party/name', 'Please enter a party name.')?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyVname" class="label-large">Venue Name:</label>
|
||||
<?php echo $html->input('Party/vname', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyAddress" class="label-large">Address:</label>
|
||||
<?php echo $html->input('Party/address', array('size' => 40, 'id' => 'location', 'onkeypress' => 'capture(event)', 'onblur' => 'update()')); ?>
|
||||
<div id="locerr" class="info" style="display: none">Did you mean: <a id="locerrlink" onclick="geocode_suggest()" href="#"></a>? <a href="#" onclick="shide()"><span style="font-size: x-small">(close)</span></a></div>
|
||||
</div>
|
||||
<p>Enter your party's time and date (in your local time) here. If you're not ready to commit to a specific time or date, select the 'Tentative'
|
||||
radio button. Otherwise select 'Confirmed'.</p>
|
||||
<div>
|
||||
<label for="PartyYear" class="label-large">Date:</label>
|
||||
<?php echo $html->yearOptionTag('Party/year', null, date('Y'), MAX_YEAR, date('Y'), null, null, false); ?>-<?php echo $html->hourOptionTag('Party/month', null, false, date('m')); ?>-<?php echo $html->dayOptionTag('Party/day', null, date('d'), null, false); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyHour" class="label-large">Time:</label>
|
||||
<?php echo $html->hourOptionTag('Party/hour', null, true);?>:<?php echo $html->minuteOptionTag('Party/minute');?>
|
||||
<?php echo $html->radio('Party/confirmed', array(0 => 'Tentative', 1 => 'Confirmed')); ?><br/>
|
||||
</div>
|
||||
<p>The timezone is used to calculate the appropriate GMT time from the local time specified above. This is done to show
|
||||
the party in the local time of the person viewing it.</p>
|
||||
<div>
|
||||
<label for="PartyTz" class="label-large">Timezone<span class="required">*</span>:</label>
|
||||
<?php
|
||||
$tzs = array('-12' => 'GMT-12',
|
||||
'-11' => 'GMT-11',
|
||||
'-10' => 'GMT-10',
|
||||
'-9' => 'GMT-9',
|
||||
'-8' => 'GMT-8',
|
||||
'-7' => 'GMT-7',
|
||||
'-6' => 'GMT-6',
|
||||
'-5' => 'GMT-5',
|
||||
'-4' => 'GMT-4',
|
||||
'-3' => 'GMT-3',
|
||||
'-2' => 'GMT-2',
|
||||
'-1' => 'GMT-1',
|
||||
'0' => 'GMT+0',
|
||||
'1' => 'GMT+1',
|
||||
'2' => 'GMT+2',
|
||||
'3' => 'GMT+3',
|
||||
'4' => 'GMT+4',
|
||||
'5' => 'GMT+5',
|
||||
'6' => 'GMT+6',
|
||||
'7' => 'GMT+7',
|
||||
'8' => 'GMT+8',
|
||||
'9' => 'GMT+9',
|
||||
'10' => 'GMT+10',
|
||||
'11' => 'GMT+11',
|
||||
'12' => 'GMT+12',
|
||||
'13' => 'GMT+13');
|
||||
echo $html->selectTag('Party/tz', $tzs, $utz, null, null, false);
|
||||
?>
|
||||
(this page was loaded at <?php echo gmdate("Y-m-d H:i:s"); ?> GMT)
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyDuration" class="label-large">Duration (in hours):</label>
|
||||
<?php echo $html->input('Party/duration', array('size' => 5)); ?>
|
||||
</div>
|
||||
<p>Enter a website (complete with http://) that guests can visit to learn more about your party. If you don't have one, simply leave it blank.</p>
|
||||
<div>
|
||||
<label for="PartyWebsite" class="label-large">Web site:</label>
|
||||
<?php echo $html->input('Party/website', array('size' => 40)); ?>
|
||||
<?php echo $html->tagErrorMsg('Party/website', 'Invalid URL.')?>
|
||||
</div>
|
||||
<p>If you choose to make your party invite only, you will have to send guests an invite containing a random invite code to allow them to join your party.</p>
|
||||
<div>
|
||||
<label for="PartyInviteonly" class="label-large">Invite only</label>
|
||||
<?php echo $html->checkbox('Party/inviteonly'); ?>
|
||||
</div>
|
||||
<?php if(GMAP_API_KEY != null): ?>
|
||||
<script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo GMAP_API_KEY; ?>"
|
||||
type="text/javascript"></script>
|
||||
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function update() {
|
||||
var loc = document.getElementById("location").value;
|
||||
geocode(loc);
|
||||
}
|
||||
|
||||
function capture(event) {
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
update();
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<p>Drag the map or the marker to specify a location. Set the zoom by using the '+' or '-' buttons on the left.</p>
|
||||
<p id="map" class="med-map-r"></p>
|
||||
<?php echo $html->hidden('Party/lat', array('id' => 'lat'));
|
||||
echo $html->hidden('Party/long', array('id' => 'long'));
|
||||
echo $html->hidden('Party/zoom', array('id' => 'zoom'));
|
||||
echo $html->hidden('Party/geocoded', array('id' => 'geocoded', 'value' => 0)); ?>
|
||||
<?php endif; ?>
|
||||
<div>
|
||||
<label for="PartyNotes" class="label-large">Additional Notes</label>
|
||||
<?php echo $html->textarea('Party/notes', array('rows' => 10, 'cols' => 50)); ?>
|
||||
</div>
|
||||
<?php echo $html->submit('Create Party'); ?>
|
||||
</form>
|
||||
@@ -1,7 +0,0 @@
|
||||
<h1>Cancel Party</h1>
|
||||
<div class="error">Warning! Canceling your party will remove all guests and send them a cancellation notice.</div>
|
||||
<p>If you're sure you want to cancel your party simply hit the button below. Otherwise,
|
||||
<a href="<?php echo $html->url('/parties/view/'.$pid); ?>">click here</a> to return to your party.</p>
|
||||
<form action="<?php echo $html->url('/parties/cancel/'.$pid); ?>" method="post">
|
||||
<?php echo $html->hidden('Party/confcancel', array('value' => 1)).$html->submit('Cancel Party'); ?>
|
||||
</form>
|
||||
@@ -1,131 +0,0 @@
|
||||
<form class="fxform" action="<?php echo $html->url('/parties/edit/'.$party['Party']['id']); ?>" method="post">
|
||||
<?php echo $html->hidden('Party/id'); ?>
|
||||
<h1>Details</h1>
|
||||
<div>
|
||||
<label for="PartyName" class="label-large">Party Name:</label>
|
||||
<?php echo $html->input('Party/name', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyVname" class="label-large">Venue Name:</label>
|
||||
<?php echo $html->input('Party/vname', array('size' => 40)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyWebsite" class="label-large">Web site:</label>
|
||||
<?php echo $html->input('Party/website', array('size' => 40)); ?>
|
||||
<?php echo $html->tagErrorMsg('Party/website', 'Invalid URL.')?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyAddress" class="label-large">Address:</label>
|
||||
<?php echo $html->input('Party/address', array('size' => 40, 'id' => 'location', 'onkeypress' => 'capture(event)', 'onblur' => 'update()')); ?>
|
||||
<div id="suggest" style="display: none">Did you mean <span style="font-style: italic"><a id="suggest2" href="#" onclick=""></a></span>?</div>
|
||||
</div>
|
||||
<?php if(GMAP_API_KEY != null): ?>
|
||||
<script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo GMAP_API_KEY; ?>"
|
||||
type="text/javascript"></script>
|
||||
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
//<![CDATA[
|
||||
function update(aSuggest) {
|
||||
var loc;
|
||||
if (!aSuggest)
|
||||
loc = document.getElementById("location").value;
|
||||
else
|
||||
loc = aSuggest;
|
||||
|
||||
if (loc != "")
|
||||
geocode(loc);
|
||||
}
|
||||
|
||||
function capture(event) {
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
update();
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<p id="map" class="med-map-r"></p>
|
||||
<div>
|
||||
<label for="PartyNotes" class="label-large">Additional Notes:</label>
|
||||
<?php echo $html->textarea('Party/notes', array('rows' => 10, 'cols' => 50)); ?>
|
||||
</div>
|
||||
<h1>Date</h1>
|
||||
<div>
|
||||
<label for="PartyYear" class="label-large">Date:</label>
|
||||
<?php echo $html->yearOptionTag('Party/year', null, date('Y'), MAX_YEAR, $date['year'], null, null, false); ?>-<?php echo $html->hourOptionTag('Party/month', null, false, $date['mon']); ?>-<?php echo $html->dayOptionTag('Party/day', null, $date['day'], null, false); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyHour" class="label-large">Time:</label>
|
||||
<?php echo $html->hourOptionTag('Party/hour', null, true, $date['hour']);?>:<?php echo $html->minuteOptionTag('Party/minute', null, $date['min']);?>
|
||||
<?php echo $html->radio('Party/confirmed', array(0 => 'Tentative', 1 => 'Confirmed')); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyTz" class="label-large">Timezone:</label>
|
||||
<?php
|
||||
$tzs = array('-12' => 'GMT-12',
|
||||
'-11' => 'GMT-11',
|
||||
'-10' => 'GMT-10',
|
||||
'-9' => 'GMT-9',
|
||||
'-8' => 'GMT-8',
|
||||
'-7' => 'GMT-7',
|
||||
'-6' => 'GMT-6',
|
||||
'-5' => 'GMT-5',
|
||||
'-4' => 'GMT-4',
|
||||
'-3' => 'GMT-3',
|
||||
'-2' => 'GMT-2',
|
||||
'-1' => 'GMT-1',
|
||||
'0' => 'GMT+0',
|
||||
'1' => 'GMT+1',
|
||||
'2' => 'GMT+2',
|
||||
'3' => 'GMT+3',
|
||||
'4' => 'GMT+4',
|
||||
'5' => 'GMT+5',
|
||||
'6' => 'GMT+6',
|
||||
'7' => 'GMT+7',
|
||||
'8' => 'GMT+8',
|
||||
'9' => 'GMT+9',
|
||||
'10' => 'GMT+10',
|
||||
'11' => 'GMT+11',
|
||||
'12' => 'GMT+12',
|
||||
'13' => 'GMT+13');
|
||||
|
||||
echo $html->selectTag('Party/tz', $tzs, $date['tz'], null, null, false);?>
|
||||
(current time is <?php echo gmdate("Y-m-d H:i:s"); ?>GMT)
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyDuration" class="label-large">Duration (in hours):</label>
|
||||
<?php echo $html->input('Party/duration', array('size' => 5)); ?>
|
||||
</div>
|
||||
<h1><span style="color: #0063dc">flick</span><span style="color: #ff0084">r<sup style="font-size: 8px">TM</sup></span> Options</h1>
|
||||
<p>To show photos of your party, simply tag them with <strong><?php echo FLICKR_TAG_PREFIX.$party['Party']['id'] ?></strong> and fill out the information below.</p>
|
||||
<div>
|
||||
<label for="PartyUseflickr" class="label-large">Show photostream:</label>
|
||||
<?php echo $html->checkbox('Party/useflickr'); ?>
|
||||
</div>
|
||||
<p>If you choose to show photos from anyone using your party's tag please note that no photos will show until two or more people are using the tag.</p>
|
||||
<div>
|
||||
<label for="PartyFlickrperms" class="label-large">Show:</label>
|
||||
<?php echo $html->radio('Party/flickrperms', array(0 => 'Only my photos', 1 => 'Anyone\'s photos')); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyFlickrusr" class="label-large">Flickr username:</label>
|
||||
<?php echo $html->input('Party/flickrusr', array('size' => 40)); ?>
|
||||
</div>
|
||||
<h1>Privacy</h1>
|
||||
<div>
|
||||
<label for="PartyInviteonly" class="label-large">Invite only:</label>
|
||||
<?php echo $html->checkbox('Party/inviteonly'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label for="PartyGuestcomments" class="label-large">Limit comments to party guests only:</label>
|
||||
<?php echo $html->checkbox('Party/guestcomments'); ?>
|
||||
</div>
|
||||
<br/>
|
||||
<?php echo $html->hidden('Party/lat', array('id' => 'lat'));
|
||||
echo $html->hidden('Party/long', array('id' => 'long'));
|
||||
echo $html->hidden('Party/zoom', array('id' => 'zoom'));
|
||||
echo $html->hidden('Party/geocoded', array('id' => 'geocoded', 'value' => 0)); ?>
|
||||
<?php endif; ?>
|
||||
<?php echo $html->submit('Update'); ?>
|
||||
</form>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php if(GMAP_API_KEY != null): ?>
|
||||
<div style="text-align: center">
|
||||
<form action="<?php echo $html->url('/parties/'); ?>" class="fxform" onsubmit="search(event)" method="post">
|
||||
<label for="PartyMloc"><strong>Find a party:</strong></label>
|
||||
<?php echo $html->input('Party/mloc', array('size' => 60, 'id' => 'location')).' '.$html->submit('Search'); ?>
|
||||
<div id="locerr" class="info" style="display: none">Did you mean: <a id="locerrlink" onclick="geocode_suggest()" href="#"></a>? <a href="#" onclick="shide()"><span style="font-size: x-small">(close)</span></a></div>
|
||||
</form>
|
||||
</div>
|
||||
<br/>
|
||||
<script src="http://maps.google.com/maps?file=api&v=2.67&key=<?php echo GMAP_API_KEY; ?>"
|
||||
type="text/javascript"></script>
|
||||
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
|
||||
<script src="<?php echo $html->url('/parties/js'); ?>" type="text/javascript"></script>
|
||||
<div id="map" class="large-map"></div>
|
||||
<div id="map-load" style="visibility: hidden" class="load">
|
||||
<img src="<?php echo $html->url('/img/throbber.gif'); ?>"/>
|
||||
Loading...
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -1,9 +0,0 @@
|
||||
<h1>Invite a guest</h1>
|
||||
<p>To invite a guest, simply enter their email address into the field below,
|
||||
or hand them a link to
|
||||
<strong><?php echo $inviteurl; ?></strong></p>
|
||||
<form action="<?php echo $html->url('/parties/invite/'.$partyid) ?>" method="post">
|
||||
<label for="PartyEinvite">Guest's email address:</label>
|
||||
<?php echo $html->input('Party/einvite')."\n".$html->submit('Submit')."\n"; ?>
|
||||
<?php echo $html->tagErrorMsg('Party/einvite', 'Invalid email address')?>
|
||||
</form>
|
||||
@@ -1,36 +0,0 @@
|
||||
<h1>Confirm Invite</h1>
|
||||
<?php if (isset($party) && !isset($confirm_only)): ?>
|
||||
<p>You've been invited to attend <a href="<?php echo $html->url('/parties/view/'.$party['Party']['id']); ?>"><?php echo $party['Party']['name']; ?></a>.
|
||||
To join this party please select one of the options below, or <a href="<?php echo $html->url('/parties/invited/cancel/');?>">click here</a> to cancel this invitation.</p>
|
||||
<div style="text-align: center">
|
||||
<div style="width: 50%; float: left;">
|
||||
<h2>New User</h2>
|
||||
<p>Simply register for an account, and you'll be added as a guest as soon as you finish.
|
||||
<a href="<?php echo $html->url('/users/register'); ?>">Create account »</a></p>
|
||||
</div>
|
||||
<div style="width: 50%; float: right">
|
||||
<h2>Existing User</h2>
|
||||
<p>Login to add yourself to the guest list.</p>
|
||||
<form class="fxform" action="<?php echo $html->url('/users/login'); ?>" method="post">
|
||||
<div>
|
||||
<label class="label-large" for="UserEmail">Email Address:</label>
|
||||
<?php echo $html->input('User/email', array('size' => 20)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label-large" for="UserPassword">Password:</label>
|
||||
<?php echo $html->password('User/password', array('size' => 20)).
|
||||
$html->hidden('User/icode', array('value' => $icode));?>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<?php echo $html->submit('Login'); ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<?php endif;
|
||||
if (isset($party) && isset($confirm_only)): ?>
|
||||
<p>You've been invited to attend <a href="<?php echo $html->url('/parties/view/'.$party['Party']['id']); ?>"><?php echo $party['Party']['name']; ?></a>.
|
||||
To join this party, <a href="<?php echo $html->url('/parties/invited/'.$icode.'/confirm');?>">click here</a>, or cancel this invitation by <a href="<?php echo $html->url('/parties/invited/cancel/');?>">clicking here</a>.</p>
|
||||
<?php endif; ?>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php if (isset($party)): ?>
|
||||
<strong><?php echo $party['Party']['name']?></strong><br/><?php echo $party['Party']['vname']; ?><br/><a href="<?php echo $html->url('/parties/view/'.$party['Party']['id'])?>">View Party</a>
|
||||
<?php else: ?>
|
||||
function addParties() {
|
||||
<?php foreach ($parties as $party):
|
||||
if (!empty($party['Party']['lat']) && !empty($party['Party']['long']) && !$party['Party']['canceled']): ?>
|
||||
addParty(<?php echo $party['Party']['lat'];?>, <?php echo $party['Party']['long']?>, <?php echo $party['Party']['id']; ?>);
|
||||
<?php endif; endforeach;?>
|
||||
}
|
||||
//
|
||||
<?php endif; ?>
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
if (isset($party)): ?>
|
||||
<h1><?php echo $party['Party']['name']; ?></h1>
|
||||
<br/>
|
||||
<?php if ($party['Party']['canceled']): ?>
|
||||
<div class="error">This party has been canceled</div>
|
||||
<?php endif; ?>
|
||||
Host: <a href="<?php echo $html->url('/users/view/'.$party['Party']['owner']).'">'.$host; ?></a><br/>
|
||||
<?php
|
||||
if (!empty($party['Party']['address']))
|
||||
echo 'Location: '.$party['Party']['address']."<br/>\n";
|
||||
|
||||
if (!empty($party['Party']['vname']))
|
||||
echo 'Venue: '.$party['Party']['vname']."<br/>\n";
|
||||
|
||||
echo 'Date: '.(($party['Party']['confirmed'] == 1) ? gmdate('Y-m-d h:ia', $party['Party']['date'] + (@$_SESSION['User']['tz'] * 60 * 60))." GMT".@$_SESSION['User']['tz'] : "TBA")."<br/>\n";
|
||||
echo 'Duration: '.$party['Party']['duration'].' hour'.(($party['Party']['duration'] == 1) ? '' : 's')."\n<br/>";
|
||||
|
||||
if (!empty($party['Party']['website']) && preg_match("/^(http|https)\:\/\//i", $party['Party']['website']))
|
||||
echo 'Website: <a href="'.$party['Party']['website'].'" rel="nofollow">'.$party['Party']['website']."</a><br/>\n";
|
||||
|
||||
if (!empty($party['Party']['notes']))
|
||||
echo 'Notes: '.$party['Party']['notes']."<br/>\n";
|
||||
?>
|
||||
<br/>
|
||||
<script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo GMAP_API_KEY; ?>"
|
||||
type="text/javascript"></script>
|
||||
<script src="<?php echo $html->url('/js/maps.js'); ?>" type="text/javascript"></script>
|
||||
<div id="map" class="small-map"></div>
|
||||
<h1>Who's coming</h1>
|
||||
<div>
|
||||
<?php if (!empty($guests)):
|
||||
$i = 0;
|
||||
$c = count($guests) - 1;
|
||||
foreach ($guests as $guest): ?>
|
||||
<a href="<?php echo $html->url('/users/view/'.$guest['users']['id']); ?>"><?php echo $guest['users']['name']; ?></a><?php echo ($i < $c) ? ", " : ""; ?>
|
||||
<?php $i++;
|
||||
endforeach;
|
||||
else:
|
||||
echo "No guests yet, be the first!";
|
||||
endif;
|
||||
|
||||
if (isset($_SESSION['User']['id']) && @$_SESSION['User']['id'] != $party['Party']['owner'] && ($party['Party']['inviteonly'] != 1 || $isguest && !$party['Party']['canceled'])):?>
|
||||
<br/><br/>
|
||||
<form action="<?php
|
||||
echo $html->url('/parties/'.((!$isguest) ? 'rsvp/' : 'unrsvp/').$party['Party']['id']); ?>" method="post">
|
||||
<?php if(!$isguest): ?>
|
||||
<button>Count me in!</button>
|
||||
<?php else: ?>
|
||||
<button>Remove me</button>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<? if ($party['Party']['inviteonly'] == 1 && (!$isguest && @$_SESSION['User']['id'] != $party['Party']['owner'] && !$party['Party']['canceled'])):?>
|
||||
<p>This party is invite only. You'll need an invite code from the host to join in.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if (@$_SESSION['User']['id'] == $party['Party']['owner']):?>
|
||||
<h1>Party options</h1>
|
||||
<a href="<?php echo $html->url('/parties/edit/'.$party['Party']['id']);?>">Edit party</a>
|
||||
<?php if (!$party['Party']['canceled']): ?>| <a href="<?php echo $html->url('/parties/invite/'.$party['Party']['id']);?>">Invite a guest</a>
|
||||
<?php endif; echo (($party['Party']['canceled'] == 1) ? ' | <a href="'.$html->url('/parties/uncancel/'.$party['Party']['id']).'">
|
||||
Reactivate this party</a>' : '| <a href="'.$html->url('/parties/cancel/'.$party['Party']['id']).'" onclick="return confirm(\'Are you sure you want to cancel your party?\')"><span style="color: #bc1313">Cancel this party</span></a>'); ?>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($flickr)): ?>
|
||||
<h1 id="photos">Photos <a title="Photo Feed" href="<?php echo $html->url('/feeds/photos/'.$party['Party']['id']); ?>"><img src="<?php echo $html->url('/img/feed16.png'); ?>" alt="Atom"/></a></h1>
|
||||
<div style="text-align: center">
|
||||
<?php if (empty($flickr)): ?>
|
||||
<p>No photos yet. Tag your flickr pictures with <?php echo FLICKR_TAG_PREFIX.$party['Party']['id']; ?> to display them here.</p>
|
||||
<?php else:
|
||||
foreach ($flickr as $pic): ?>
|
||||
<a href="http://www.flickr.com/photos/<?php echo $pic['owner']."/".$pic['id']."/" ?>"><img src="http://static.flickr.com/<?php echo $pic['server']."/".$pic['id']."_".$pic['secret']."_s.jpg" ?>" title="<?php echo $pic['title']; ?>"/></a>
|
||||
<?php endforeach;
|
||||
endif; ?>
|
||||
<br/>
|
||||
</div>
|
||||
<?php endif;
|
||||
if (!empty($comments)): ?>
|
||||
<h1 id="comments">Comments <a title="Comment Feed" href="<?php echo $html->url('/feeds/comments/'.$party['Party']['id']); ?>"><img src="<?php echo $html->url('/img/feed16.png'); ?>" alt="RSS"/></a></h1>
|
||||
<?php $i = 0;
|
||||
foreach ($comments as $comment):
|
||||
if ($i % 2 == 0)
|
||||
$class = "";
|
||||
else
|
||||
$class = "comment-mod";
|
||||
$i++;?>
|
||||
<div id="c<?php echo $comment['comments']['cid'];?>" class="comment <?php echo $class;?>">
|
||||
<span class="comment-content"><?php echo $comment['comments']['text']; ?></span>
|
||||
<span class="comment-tag"><br/><br/>Posted by <a href="<?php echo $html->url('/users/view/'.$comment['users']['uid']); ?>">
|
||||
<?php echo $comment['users']['name']; ?></a> on <?php echo gmdate('Y-m-d h:ia', $comment['comments']['time'] + (@$_SESSION['User']['tz'] * 60 * 60)); ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<?php endforeach;
|
||||
endif;
|
||||
if (isset($_SESSION['User'])):
|
||||
if (($party['Party']['guestcomments'] && $isguest) || !$party['Party']['guestcomments'] || @$_SESSION['User']['id'] == $party['Party']['owner']): ?>
|
||||
<h1>Add a comment</h1>
|
||||
<form action="<?php echo $html->url('/comments/add/'.$party['Party']['id'].'/'.$_SESSION['User']['id']); ?>" method="post">
|
||||
<div>
|
||||
<?php echo $html->textarea('Comment/text', array('rows' => 10, 'cols' => 50))."<br/>".$html->submit('Submit'); ?>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif;
|
||||
endif;
|
||||
endif; ?>
|
||||
|
||||
<?php if (isset($parties)):
|
||||
if (isset($prev))
|
||||
echo '<a href="'.$html->url('/parties/view/all/'.$prev).'">« Previous Page</a> ';
|
||||
if (isset($prev) && isset($next))
|
||||
echo ' | ';
|
||||
if (isset($next))
|
||||
echo '<a href="'.$html->url('/parties/view/all/'.$next).'">Next Page »</a>';
|
||||
$i = 0;
|
||||
foreach ($parties as $party):
|
||||
if ($party['Party']['canceled'] != 1): ?>
|
||||
<div>
|
||||
<h1><?php echo $party['Party']['name']; ?></h1>
|
||||
<p>
|
||||
<?php
|
||||
if (!empty($party['Party']['address']))
|
||||
echo 'Location: '.$party['Party']['address']."<br/>\n";
|
||||
|
||||
if (!empty($party['Party']['vname']))
|
||||
echo 'Venue: '.$party['Party']['vname']."<br/>\n";
|
||||
|
||||
echo 'Date: '.(($party['Party']['confirmed'] == 1) ? gmdate('Y-m-d h:ia', $party['Party']['date'] + (@$_SESSION['User']['tz'] * 60 * 60))." GMT".@$_SESSION['User']['tz'] : "TBA")."<br/>\n";
|
||||
|
||||
echo '<a href="'.$html->url('/parties/view/'.$party['Party']['id']).'">View Party</a>';
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; endforeach;
|
||||
if (isset($prev))
|
||||
echo '<a href="'.$html->url('/parties/view/all/'.$prev).'">« Previous Page</a> ';
|
||||
if (isset($prev) && isset($next))
|
||||
echo ' | ';
|
||||
if (isset($next))
|
||||
echo '<a href="'.$html->url('/parties/view/all/'.$next).'">Next Page »</a>';
|
||||
endif;?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user