pleyo.com

/src/trunk2/BAL/Interfaces/BTCookie.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007 Pleyo.  All rights reserved.
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  *
00008  * 1.  Redistributions of source code must retain the above copyright
00009  *     notice, this list of conditions and the following disclaimer.
00010  * 2.  Redistributions in binary form must reproduce the above copyright
00011  *     notice, this list of conditions and the following disclaimer in the
00012  *     documentation and/or other materials provided with the distribution.
00013  * 3.  Neither the name of Pleyo nor the names of
00014  *     its contributors may be used to endorse or promote products derived
00015  *     from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY PLEYO AND ITS CONTRIBUTORS "AS IS" AND ANY
00018  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00019  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020  * DISCLAIMED. IN NO EVENT SHALL PLEYO OR ITS CONTRIBUTORS BE LIABLE FOR ANY
00021  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023     * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00040 #ifndef BTCOOKIE_H
00041 #define BTCOOKIE_H
00042 
00043 #include "StringHash.h"
00044 #include "wtf/HashMap.h"
00045 #include "PlatformString.h"
00046 
00047 using WebCore::String;
00048 
00054 class BTCookie {
00055 public:
00056     BTCookie() : m_expires(0), m_secure(false) {}
00057     
00058     BTCookie(String& name, String& value, String& /*expires*/, String& /*secure*/) :
00059     m_name(name), m_value(value), m_expires(0), m_secure(false)
00060 {}
00061     ~BTCookie() {}
00062     
00066     const String& name() const { return m_name; }
00067     
00071     const String& value() const { return m_value; }
00072     
00076     const String& path() const { return m_path; }
00077     
00081     const String& domain() const { return m_domain; }
00082     
00086     const double expireDate() const { return m_expires; }
00087     
00091     bool isDomain() const { return !m_domain.isEmpty(); }
00092     
00096     bool isSecure() const { return m_secure; }
00097     
00102     void initFromString(const String& cookie);
00103     
00108     String createBackupStringFromCookie();
00109     
00113     void initCookieFromBackupString(String cookie, String domain);
00114     
00115 private:
00116     String extractValueIn(const char* name, const String& cookie);
00117     String m_name;
00118     String m_value;
00119     String m_domain;
00120     String m_path;
00121     double m_expires; /*in seconds since january 1970 the 1st at 00h00m00s */
00122     bool m_secure;
00123 };
00124 
00129 class BTCookieMap {
00130 public:
00131     BTCookieMap() : m_count(0) {}
00132     ~BTCookieMap() {}
00138     int add(const BTCookie& cookie);
00139     
00140     String createBackupStringFromCookies();
00141     
00145     String getNameValuePairs();
00146     
00152     String getNameValuePairs(String path, bool siteIsSecure);
00153     
00154     HashMap<String, BTCookie> getMap() { return m_cookieMap; }
00155     
00156 private:
00158     HashMap<String, BTCookie> m_cookieMap;
00159     
00161     unsigned short m_count;
00162 };
00163 
00164 #endif // BTCOOKIE_H
00165 
00166 

Generated on Wed Nov 21 20:04:16 2007 for Origyn Web Browser by Doxygen 1.5.3

pleyo.com
pleyo.com