1*39a19a47SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*39a19a47SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*39a19a47SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*39a19a47SAndrew Rist * distributed with this work for additional information 6*39a19a47SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*39a19a47SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*39a19a47SAndrew Rist * "License"); you may not use this file except in compliance 9*39a19a47SAndrew Rist * with the License. You may obtain a copy of the License at 10*39a19a47SAndrew Rist * 11*39a19a47SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*39a19a47SAndrew Rist * 13*39a19a47SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*39a19a47SAndrew Rist * software distributed under the License is distributed on an 15*39a19a47SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*39a19a47SAndrew Rist * KIND, either express or implied. See the License for the 17*39a19a47SAndrew Rist * specific language governing permissions and limitations 18*39a19a47SAndrew Rist * under the License. 19*39a19a47SAndrew Rist * 20*39a19a47SAndrew Rist *************************************************************/ 21*39a19a47SAndrew Rist 22*39a19a47SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SVTOOLS_HTTPCOOK_HXX 25cdf0e10cSrcweir #define SVTOOLS_HTTPCOOK_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <tools/datetime.hxx> 28cdf0e10cSrcweir #include <tools/stream.hxx> 29cdf0e10cSrcweir #include <tools/string.hxx> 30cdf0e10cSrcweir #include <svl/poolitem.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir /*======================================================================= 33cdf0e10cSrcweir * 34cdf0e10cSrcweir *=====================================================================*/ 35cdf0e10cSrcweir #define CNTHTTP_COOKIE_FLAG_SECURE 0x01 36cdf0e10cSrcweir 37cdf0e10cSrcweir #define CNTHTTP_COOKIE_POLICY_INTERACTIVE 0x00 38cdf0e10cSrcweir #define CNTHTTP_COOKIE_POLICY_ACCEPTED 0x01 39cdf0e10cSrcweir #define CNTHTTP_COOKIE_POLICY_BANNED 0x02 40cdf0e10cSrcweir 41cdf0e10cSrcweir #define CNTHTTP_COOKIE_DOMAIN_POLICY 0x10 42cdf0e10cSrcweir 43cdf0e10cSrcweir #define CNTHTTP_COOKIE_DOMAIN_ACCEPTED \ 44cdf0e10cSrcweir (CNTHTTP_COOKIE_DOMAIN_POLICY | CNTHTTP_COOKIE_POLICY_ACCEPTED) 45cdf0e10cSrcweir #define CNTHTTP_COOKIE_DOMAIN_BANNED \ 46cdf0e10cSrcweir (CNTHTTP_COOKIE_DOMAIN_POLICY | CNTHTTP_COOKIE_POLICY_BANNED) 47cdf0e10cSrcweir 48cdf0e10cSrcweir /*======================================================================= 49cdf0e10cSrcweir * 50cdf0e10cSrcweir * CntHTTPCookie. 51cdf0e10cSrcweir * 52cdf0e10cSrcweir *=====================================================================*/ 53cdf0e10cSrcweir struct CntHTTPCookie 54cdf0e10cSrcweir { 55cdf0e10cSrcweir String m_aName; 56cdf0e10cSrcweir String m_aValue; 57cdf0e10cSrcweir String m_aDomain; 58cdf0e10cSrcweir String m_aPath; 59cdf0e10cSrcweir DateTime m_aExpires; 60cdf0e10cSrcweir sal_uInt16 m_nFlags; 61cdf0e10cSrcweir sal_uInt16 m_nPolicy; 62cdf0e10cSrcweir CntHTTPCookieCntHTTPCookie63cdf0e10cSrcweir CntHTTPCookie (void) 64cdf0e10cSrcweir : m_aExpires (Date(0), Time(0)), 65cdf0e10cSrcweir m_nFlags (0), 66cdf0e10cSrcweir m_nPolicy (CNTHTTP_COOKIE_POLICY_INTERACTIVE) 67cdf0e10cSrcweir {} 68cdf0e10cSrcweir replacesCntHTTPCookie69cdf0e10cSrcweir sal_Bool replaces (const CntHTTPCookie& rOther) const 70cdf0e10cSrcweir { 71cdf0e10cSrcweir return ((m_aDomain == rOther.m_aDomain) && 72cdf0e10cSrcweir (m_aPath == rOther.m_aPath ) && 73cdf0e10cSrcweir (m_aName == rOther.m_aName ) ); 74cdf0e10cSrcweir } 75cdf0e10cSrcweir operator ==CntHTTPCookie76cdf0e10cSrcweir sal_Bool operator== (const CntHTTPCookie& rOther) const 77cdf0e10cSrcweir { 78cdf0e10cSrcweir return ((m_aName == rOther.m_aName ) && 79cdf0e10cSrcweir (m_aValue == rOther.m_aValue ) && 80cdf0e10cSrcweir (m_aDomain == rOther.m_aDomain ) && 81cdf0e10cSrcweir (m_aPath == rOther.m_aPath ) && 82cdf0e10cSrcweir (m_aExpires == rOther.m_aExpires) && 83cdf0e10cSrcweir (m_nFlags == rOther.m_nFlags ) && 84cdf0e10cSrcweir (m_nPolicy == rOther.m_nPolicy ) ); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir writeCntHTTPCookie87cdf0e10cSrcweir void write (SvStream& rStrm) const 88cdf0e10cSrcweir { 89cdf0e10cSrcweir SfxPoolItem::writeUnicodeString(rStrm, m_aName); 90cdf0e10cSrcweir SfxPoolItem::writeUnicodeString(rStrm, m_aValue); 91cdf0e10cSrcweir SfxPoolItem::writeUnicodeString(rStrm, m_aDomain); 92cdf0e10cSrcweir SfxPoolItem::writeUnicodeString(rStrm, m_aPath); 93cdf0e10cSrcweir 94cdf0e10cSrcweir rStrm << m_aExpires.GetDate(); 95cdf0e10cSrcweir rStrm << m_aExpires.GetTime(); 96cdf0e10cSrcweir 97cdf0e10cSrcweir rStrm << m_nFlags; 98cdf0e10cSrcweir rStrm << m_nPolicy; 99cdf0e10cSrcweir } 100cdf0e10cSrcweir readCntHTTPCookie101cdf0e10cSrcweir void read (SvStream& rStrm, bool bUnicode) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir SfxPoolItem::readUnicodeString(rStrm, m_aName, bUnicode); 104cdf0e10cSrcweir SfxPoolItem::readUnicodeString(rStrm, m_aValue, bUnicode); 105cdf0e10cSrcweir SfxPoolItem::readUnicodeString(rStrm, m_aDomain, bUnicode); 106cdf0e10cSrcweir SfxPoolItem::readUnicodeString(rStrm, m_aPath, bUnicode); 107cdf0e10cSrcweir 108cdf0e10cSrcweir sal_uInt32 nValue = 0; 109cdf0e10cSrcweir rStrm >> nValue; 110cdf0e10cSrcweir m_aExpires.SetDate (nValue); 111cdf0e10cSrcweir rStrm >> nValue; 112cdf0e10cSrcweir m_aExpires.SetTime (nValue); 113cdf0e10cSrcweir 114cdf0e10cSrcweir rStrm >> m_nFlags; 115cdf0e10cSrcweir rStrm >> m_nPolicy; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir }; 118cdf0e10cSrcweir 119cdf0e10cSrcweir /*======================================================================= 120cdf0e10cSrcweir * 121cdf0e10cSrcweir * CntHTTPCookieRequest. 122cdf0e10cSrcweir * 123cdf0e10cSrcweir *=====================================================================*/ 124cdf0e10cSrcweir enum CntHTTPCookieRequestType 125cdf0e10cSrcweir { 126cdf0e10cSrcweir CNTHTTP_COOKIE_REQUEST_RECV = 0, 127cdf0e10cSrcweir CNTHTTP_COOKIE_REQUEST_SEND 128cdf0e10cSrcweir }; 129cdf0e10cSrcweir 130cdf0e10cSrcweir struct CntHTTPCookieRequest 131cdf0e10cSrcweir { 132cdf0e10cSrcweir const String& m_rURL; 133cdf0e10cSrcweir List& m_rCookieList; 134cdf0e10cSrcweir CntHTTPCookieRequestType m_eType; 135cdf0e10cSrcweir sal_uInt16 m_nRet; 136cdf0e10cSrcweir CntHTTPCookieRequestCntHTTPCookieRequest137cdf0e10cSrcweir CntHTTPCookieRequest ( 138cdf0e10cSrcweir const String& rURL, 139cdf0e10cSrcweir List& rCookieList, 140cdf0e10cSrcweir CntHTTPCookieRequestType eType) 141cdf0e10cSrcweir : m_rURL (rURL), 142cdf0e10cSrcweir m_rCookieList (rCookieList), 143cdf0e10cSrcweir m_eType(eType), 144cdf0e10cSrcweir m_nRet (CNTHTTP_COOKIE_POLICY_BANNED) {} 145cdf0e10cSrcweir }; 146cdf0e10cSrcweir 147cdf0e10cSrcweir #endif // SVTOOLS_HTTPCOOK_HXX 148cdf0e10cSrcweir 149