Kaydet (Commit) 5dbcc32f authored tarafından Kai Sommerfeld's avatar Kai Sommerfeld

#96458# - Now compiles without errors/warnings on Solaris.

üst ef75a992
......@@ -2,9 +2,9 @@
*
* $RCSfile: LinkSequence.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: kso $ $Date: 2002-08-15 10:05:25 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -91,6 +91,40 @@ struct LinkSequenceParseContext
~LinkSequenceParseContext() { delete pLink; }
};
//////////////////////////////////////////////////////////////////////////
extern "C" static int validate_callback(
void * userdata, ne_xml_elmid parent, ne_xml_elmid child )
{
// @@@
return NE_XML_VALID;
}
//////////////////////////////////////////////////////////////////////////
extern "C" static int endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata )
{
LinkSequenceParseContext * pCtx
= static_cast< LinkSequenceParseContext * >( userdata );
if ( !pCtx->pLink )
pCtx->pLink = new ucb::Link;
switch ( s->id )
{
case DAV_ELM_src:
pCtx->pLink->Source = rtl::OUString::createFromAscii( cdata );
break;
case DAV_ELM_dst:
pCtx->pLink->Destination = rtl::OUString::createFromAscii( cdata );
break;
default:
break;
}
return 0;
}
//////////////////////////////////////////////////////////////////////////
// static
bool LinkSequence::createFromXML( const rtl::OString & rInData,
......@@ -174,39 +208,3 @@ bool LinkSequence::toXML( const uno::Sequence< ucb::Link > & rInData,
}
return false;
}
//////////////////////////////////////////////////////////////////////////
// static
int LinkSequence::validate_callback(
void * userdata, ne_xml_elmid parent, ne_xml_elmid child )
{
// @@@
return NE_XML_VALID;
}
//////////////////////////////////////////////////////////////////////////
// static
int LinkSequence::endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata )
{
LinkSequenceParseContext * pCtx
= static_cast< LinkSequenceParseContext * >( userdata );
if ( !pCtx->pLink )
pCtx->pLink = new ucb::Link;
switch ( s->id )
{
case DAV_ELM_src:
pCtx->pLink->Source = rtl::OUString::createFromAscii( cdata );
break;
case DAV_ELM_dst:
pCtx->pLink->Destination = rtl::OUString::createFromAscii( cdata );
break;
default:
break;
}
return 0;
}
......@@ -2,9 +2,9 @@
*
* $RCSfile: LinkSequence.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: kso $ $Date: 2002-08-15 10:05:25 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -95,13 +95,6 @@ public:
static bool toXML( const com::sun::star::uno::Sequence<
com::sun::star::ucb::Link > & rInData,
rtl::OUString & rOutData );
static int validate_callback( void * userdata,
ne_xml_elmid parent,
ne_xml_elmid child );
static int endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata );
};
}
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: LockEntrySequence.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: kso $ $Date: 2002-08-15 10:05:25 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -97,6 +97,45 @@ struct LockEntrySequenceParseContext
~LockEntrySequenceParseContext() { delete pEntry; }
};
//////////////////////////////////////////////////////////////////////////
extern "C" static int validate_callback( void * userdata,
ne_xml_elmid parent,
ne_xml_elmid child )
{
// @@@
return NE_XML_VALID;
}
//////////////////////////////////////////////////////////////////////////
extern "C" static int endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata )
{
LockEntrySequenceParseContext * pCtx
= static_cast< LockEntrySequenceParseContext * >( userdata );
if ( !pCtx->pEntry )
pCtx->pEntry = new ucb::LockEntry;
switch ( s->id )
{
case DAV_ELM_exclusive:
pCtx->pEntry->Scope = ucb::LockScope_EXCLUSIVE;
break;
case DAV_ELM_shared:
pCtx->pEntry->Scope = ucb::LockScope_SHARED;
break;
case DAV_ELM_write:
pCtx->pEntry->Type = ucb::LockType_WRITE;
break;
default:
break;
}
return 0;
}
//////////////////////////////////////////////////////////////////////////
// static
bool LockEntrySequence::createFromXML( const rtl::OString & rInData,
......@@ -154,45 +193,3 @@ bool LockEntrySequence::createFromXML( const rtl::OString & rInData,
rOutData.realloc( nCount );
return success;
}
//////////////////////////////////////////////////////////////////////////
// static
int LockEntrySequence::validate_callback( void * userdata,
ne_xml_elmid parent,
ne_xml_elmid child )
{
// @@@
return NE_XML_VALID;
}
//////////////////////////////////////////////////////////////////////////
// static
int LockEntrySequence::endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata )
{
LockEntrySequenceParseContext * pCtx
= static_cast< LockEntrySequenceParseContext * >( userdata );
if ( !pCtx->pEntry )
pCtx->pEntry = new ucb::LockEntry;
switch ( s->id )
{
case DAV_ELM_exclusive:
pCtx->pEntry->Scope = ucb::LockScope_EXCLUSIVE;
break;
case DAV_ELM_shared:
pCtx->pEntry->Scope = ucb::LockScope_SHARED;
break;
case DAV_ELM_write:
pCtx->pEntry->Type = ucb::LockType_WRITE;
break;
default:
break;
}
return 0;
}
......@@ -2,9 +2,9 @@
*
* $RCSfile: LockEntrySequence.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: kso $ $Date: 2002-08-15 10:05:25 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -92,13 +92,6 @@ public:
static bool createFromXML( const rtl::OString & rInData,
com::sun::star::uno::Sequence<
com::sun::star::ucb::LockEntry > & rOutData );
static int validate_callback( void * userdata,
ne_xml_elmid parent,
ne_xml_elmid child );
static int endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata );
};
}
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: LockSequence.cxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: kso $ $Date: 2002-08-15 10:05:26 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -108,65 +108,7 @@ struct LockSequenceParseContext
};
//////////////////////////////////////////////////////////////////////////
// static
bool LockSequence::createFromXML( const rtl::OString & rInData,
uno::Sequence< ucb::Lock > & rOutData )
{
const sal_Int32 TOKEN_LENGTH = 13; // </activelock>
bool success = true;
// rInData may contain multiple <activelock>...</activelock> tags.
sal_Int32 nCount = 0;
sal_Int32 nStart = 0;
sal_Int32 nEnd = rInData.indexOf( "</activelock>" );
while ( nEnd > -1 )
{
ne_xml_parser * parser = ne_xml_create();
if ( !parser )
{
success = false;
break;
}
LockSequenceParseContext aCtx;
ne_xml_push_handler( parser,
elements,
validate_callback,
0, // startelement_callback
endelement_callback,
&aCtx );
ne_xml_parse( parser,
rInData.getStr() + nStart,
nEnd - nStart + TOKEN_LENGTH );
success = !!ne_xml_valid( parser );
ne_xml_destroy( parser );
if ( !success )
break;
if ( aCtx.pLock )
{
nCount++;
if ( nCount > rOutData.getLength() )
rOutData.realloc( rOutData.getLength() + 1 );
rOutData[ nCount - 1 ] = *aCtx.pLock;
}
nStart = nEnd + TOKEN_LENGTH + 1;
nEnd = rInData.indexOf( "</activelock>", nStart );
}
// rOutData.realloc( nCount );
return success;
}
//////////////////////////////////////////////////////////////////////////
// static
int LockSequence::validate_callback( void * userdata,
extern "C" static int validate_callback( void * userdata,
ne_xml_elmid parent,
ne_xml_elmid child )
{
......@@ -176,7 +118,7 @@ int LockSequence::validate_callback( void * userdata,
//////////////////////////////////////////////////////////////////////////
// static
int LockSequence::endelement_callback( void * userdata,
extern "C" static int endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata )
{
......@@ -267,3 +209,60 @@ int LockSequence::endelement_callback( void * userdata,
}
return 0;
}
//////////////////////////////////////////////////////////////////////////
// static
bool LockSequence::createFromXML( const rtl::OString & rInData,
uno::Sequence< ucb::Lock > & rOutData )
{
const sal_Int32 TOKEN_LENGTH = 13; // </activelock>
bool success = true;
// rInData may contain multiple <activelock>...</activelock> tags.
sal_Int32 nCount = 0;
sal_Int32 nStart = 0;
sal_Int32 nEnd = rInData.indexOf( "</activelock>" );
while ( nEnd > -1 )
{
ne_xml_parser * parser = ne_xml_create();
if ( !parser )
{
success = false;
break;
}
LockSequenceParseContext aCtx;
ne_xml_push_handler( parser,
elements,
validate_callback,
0, // startelement_callback
endelement_callback,
&aCtx );
ne_xml_parse( parser,
rInData.getStr() + nStart,
nEnd - nStart + TOKEN_LENGTH );
success = !!ne_xml_valid( parser );
ne_xml_destroy( parser );
if ( !success )
break;
if ( aCtx.pLock )
{
nCount++;
if ( nCount > rOutData.getLength() )
rOutData.realloc( rOutData.getLength() + 1 );
rOutData[ nCount - 1 ] = *aCtx.pLock;
}
nStart = nEnd + TOKEN_LENGTH + 1;
nEnd = rInData.indexOf( "</activelock>", nStart );
}
// rOutData.realloc( nCount );
return success;
}
......@@ -2,9 +2,9 @@
*
* $RCSfile: LockSequence.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: kso $ $Date: 2002-08-15 10:05:26 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -92,13 +92,6 @@ public:
static bool createFromXML( const rtl::OString & rInData,
com::sun::star::uno::Sequence<
com::sun::star::ucb::Lock > & rOutData );
static int validate_callback( void * userdata,
ne_xml_elmid parent,
ne_xml_elmid child );
static int endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata );
};
}
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: NeonPropFindRequest.cxx,v $
*
* $Revision: 1.9 $
* $Revision: 1.10 $
*
* last change: $Author: kso $ $Date: 2002-08-15 10:05:28 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -96,110 +96,7 @@ using namespace std;
using namespace webdav_ucp;
// -------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------
NeonPropFindRequest::NeonPropFindRequest( HttpSession* inSession,
const char* inPath,
const Depth inDepth,
const vector< OUString >& inPropNames,
vector< DAVResource >& ioResources,
int & nError )
{
// Generate the list of properties we're looking for
int thePropCount = inPropNames.size();
if ( thePropCount > 0 )
{
NeonPropName* thePropNames = new NeonPropName[ thePropCount + 1 ];
for ( int theIndex = 0; theIndex < thePropCount; theIndex ++ )
{
// Split fullname into namespace and name!
DAVProperties::createNeonPropName(
inPropNames[ theIndex ], thePropNames[ theIndex ] );
}
thePropNames[ theIndex ].nspace = NULL;
thePropNames[ theIndex ].name = NULL;
nError = ne_simple_propfind( inSession,
inPath,
inDepth,
thePropNames,
propfind_results,
&ioResources );
for ( theIndex = 0; theIndex < thePropCount; theIndex ++ )
free( (void *)thePropNames[ theIndex ].name );
delete [] thePropNames;
}
else
{
// ALLPROP
nError = ne_simple_propfind( inSession,
inPath,
inDepth,
NULL, // 0 == allprop
propfind_results,
&ioResources );
}
// #87585# - Sometimes neon lies (because some servers lie).
if ( ( nError == NE_OK ) && ioResources.empty() )
nError = NE_ERROR;
}
// -------------------------------------------------------------------
// Constructor
// - obtains property names
// -------------------------------------------------------------------
NeonPropFindRequest::NeonPropFindRequest(
HttpSession* inSession,
const char* inPath,
const Depth inDepth,
std::vector< DAVResourceInfo > & ioResInfo,
int & nError )
{
nError = ne_propnames( inSession,
inPath,
inDepth,
propnames_results,
&ioResInfo );
// #87585# - Sometimes neon lies (because some servers lie).
if ( ( nError == NE_OK ) && ioResInfo.empty() )
nError = NE_ERROR;
}
// -------------------------------------------------------------------
// Destructor
// -------------------------------------------------------------------
NeonPropFindRequest::~NeonPropFindRequest( )
{
}
// -------------------------------------------------------------------
// static
void NeonPropFindRequest::propfind_results( void* userdata,
const char* href,
const NeonPropFindResultSet* set )
{
// @@@ href is not the uri! DAVResource ctor wants uri!
DAVResource theResource(
OStringToOUString( href, RTL_TEXTENCODING_UTF8 ) );
ne_propset_iterate( set, propfind_iter, &theResource );
// Add entry to resources list.
vector< DAVResource > * theResources
= static_cast< vector< DAVResource > * >( userdata );
theResources->push_back( theResource );
}
// -------------------------------------------------------------------
// static
int NeonPropFindRequest::propfind_iter( void* userdata,
extern "C" static int propfind_iter( void* userdata,
const NeonPropName* pname,
const char* value,
const HttpStatus* status )
......@@ -305,29 +202,25 @@ int NeonPropFindRequest::propfind_iter( void* userdata,
}
// -------------------------------------------------------------------
// static
void NeonPropFindRequest::propnames_results(
void* userdata,
extern "C" static void propfind_results( void* userdata,
const char* href,
const NeonPropFindResultSet* results )
const NeonPropFindResultSet* set )
{
// @@@ href is not the uri! DAVResourceInfo ctor wants uri!
// @@@ href is not the uri! DAVResource ctor wants uri!
// Create entry for the resource.
DAVResourceInfo theResource(
DAVResource theResource(
OStringToOUString( href, RTL_TEXTENCODING_UTF8 ) );
// Fill entry.
ne_propset_iterate( results, propnames_iter, &theResource );
ne_propset_iterate( set, propfind_iter, &theResource );
// Add entry to resources list.
vector< DAVResourceInfo > * theResources
= static_cast< vector< DAVResourceInfo > * >( userdata );
vector< DAVResource > * theResources
= static_cast< vector< DAVResource > * >( userdata );
theResources->push_back( theResource );
}
// -------------------------------------------------------------------
// static
int NeonPropFindRequest::propnames_iter( void* userdata,
extern "C" static int propnames_iter( void* userdata,
const NeonPropName* pname,
const char* value,
const HttpStatus* status )
......@@ -341,3 +234,106 @@ int NeonPropFindRequest::propnames_iter( void* userdata,
theResource->properties.push_back( aFullName );
return 0;
}
// -------------------------------------------------------------------
extern "C" static void propnames_results(
void* userdata,
const char* href,
const NeonPropFindResultSet* results )
{
// @@@ href is not the uri! DAVResourceInfo ctor wants uri!
// Create entry for the resource.
DAVResourceInfo theResource(
OStringToOUString( href, RTL_TEXTENCODING_UTF8 ) );
// Fill entry.
ne_propset_iterate( results, propnames_iter, &theResource );
// Add entry to resources list.
vector< DAVResourceInfo > * theResources
= static_cast< vector< DAVResourceInfo > * >( userdata );
theResources->push_back( theResource );
}
// -------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------
NeonPropFindRequest::NeonPropFindRequest( HttpSession* inSession,
const char* inPath,
const Depth inDepth,
const vector< OUString >& inPropNames,
vector< DAVResource >& ioResources,
int & nError )
{
// Generate the list of properties we're looking for
int thePropCount = inPropNames.size();
if ( thePropCount > 0 )
{
NeonPropName* thePropNames = new NeonPropName[ thePropCount + 1 ];
for ( int theIndex = 0; theIndex < thePropCount; theIndex ++ )
{
// Split fullname into namespace and name!
DAVProperties::createNeonPropName(
inPropNames[ theIndex ], thePropNames[ theIndex ] );
}
thePropNames[ theIndex ].nspace = NULL;
thePropNames[ theIndex ].name = NULL;
nError = ne_simple_propfind( inSession,
inPath,
inDepth,
thePropNames,
propfind_results,
&ioResources );
for ( theIndex = 0; theIndex < thePropCount; theIndex ++ )
free( (void *)thePropNames[ theIndex ].name );
delete [] thePropNames;
}
else
{
// ALLPROP
nError = ne_simple_propfind( inSession,
inPath,
inDepth,
NULL, // 0 == allprop
propfind_results,
&ioResources );
}
// #87585# - Sometimes neon lies (because some servers lie).
if ( ( nError == NE_OK ) && ioResources.empty() )
nError = NE_ERROR;
}
// -------------------------------------------------------------------
// Constructor
// - obtains property names
// -------------------------------------------------------------------
NeonPropFindRequest::NeonPropFindRequest(
HttpSession* inSession,
const char* inPath,
const Depth inDepth,
std::vector< DAVResourceInfo > & ioResInfo,
int & nError )
{
nError = ne_propnames( inSession,
inPath,
inDepth,
propnames_results,
&ioResInfo );
// #87585# - Sometimes neon lies (because some servers lie).
if ( ( nError == NE_OK ) && ioResInfo.empty() )
nError = NE_ERROR;
}
// -------------------------------------------------------------------
// Destructor
// -------------------------------------------------------------------
NeonPropFindRequest::~NeonPropFindRequest( )
{
}
......@@ -2,9 +2,9 @@
*
* $RCSfile: NeonPropFindRequest.hxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: kso $ $Date: 2001-05-16 15:29:59 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -99,26 +99,6 @@ public:
int & nError );
~NeonPropFindRequest();
private:
// Neon callback functions
static void propfind_results( void* userdata,
const char* href,
const NeonPropFindResultSet* set );
static int propfind_iter( void* userdata,
const NeonPropName* pname,
const char* value,
const HttpStatus* status );
static void propnames_results( void* userdata,
const char* href,
const NeonPropFindResultSet* results );
static int propnames_iter( void* userdata,
const NeonPropName* pname,
const char* value,
const HttpStatus* status );
};
}; // namespace webdav_ucp
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: NeonSession.cxx,v $
*
* $Revision: 1.18 $
* $Revision: 1.19 $
*
* last change: $Author: kso $ $Date: 2002-08-21 07:34:53 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -181,6 +181,160 @@ static sal_uInt16 makeStatusCode( const rtl::OUString & rStatusText )
return sal_uInt16( rStatusText.copy( 0, nPos ).toInt32() );
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
// Callback functions
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// -------------------------------------------------------------------
// ResponseBlockReader
// A simple Neon response_block_reader for use with an XInputStream
// -------------------------------------------------------------------
extern "C" static void ResponseBlockReader( void * inUserData,
const char * inBuf,
size_t inLen )
{
// neon calls this function with (inLen == 0)...
if ( inLen > 0 )
{
NeonInputStream * theInputStream
= static_cast< NeonInputStream *>( inUserData );
theInputStream->AddToStream( inBuf, inLen );
}
}
// -------------------------------------------------------------------
// ResponseBlockWriter
// A simple Neon response_block_reader for use with an XOutputStream
// -------------------------------------------------------------------
extern "C" static void ResponseBlockWriter( void * inUserData,
const char * inBuf,
size_t inLen )
{
// neon calls this function with (inLen == 0)...
if ( inLen > 0 )
{
uno::Reference< io::XOutputStream > * theOutputStreamPtr
= static_cast< uno::Reference< io::XOutputStream > * >(
inUserData );
uno::Reference< io::XOutputStream > theOutputStream
= *theOutputStreamPtr;
const uno::Sequence< sal_Int8 > theSequence(
(sal_Int8 *)inBuf, inLen );
theOutputStream->writeBytes( theSequence );
}
}
extern "C" static int NeonAuth( void * inUserData,
const char * inRealm,
int attempt,
char * inoutUserName,
char * inoutPassWord )
{
NeonSession * theSession = static_cast< NeonSession * >( inUserData );
if ( !theSession->getServerAuthListener() )
{
// abort
return -1;
}
// username buffer is prefilled with user name from last attempt.
rtl::OUString theUserName(
rtl::OUString::createFromAscii( inoutUserName ) );
rtl::OUString thePassWord; /*(
// @@@ Neon does not initialize password buffer
// (last checked: 0.22.0).
rtl::OUString::createFromAscii( inoutPassWord ) ); */
int theRetVal = theSession->getServerAuthListener()->authenticate(
rtl::OUString::createFromAscii( inRealm ),
theSession->getHostName(),
theUserName,
thePassWord,
theSession->getCommandEnvironment() );
strcpy( inoutUserName,
rtl::OUStringToOString( theUserName, RTL_TEXTENCODING_UTF8 ) );
strcpy( inoutPassWord,
rtl::OUStringToOString( thePassWord, RTL_TEXTENCODING_UTF8 ) );
return theRetVal;
}
extern "C" static void ProgressNotify( void * userdata,
off_t progress,
off_t total )
{
// progress: bytes read so far
// total: total bytes to read, -1 -> total count not known
}
extern "C" static void StatusNotify( void * userdata,
ne_conn_status status,
const char *info )
{
#if 0
typedef enum {
ne_conn_namelookup, /* lookup up hostname (info = hostname) */
ne_conn_connecting, /* connecting to host (info = hostname) */
ne_conn_connected, /* connected to host (info = hostname) */
ne_conn_secure /* connection now secure (info = crypto level) */
} ne_conn_status;
#endif
// info: hostname
}
extern "C" static void PreSendRequest( ne_request * req,
void * userdata,
ne_buffer * headers )
{
// userdata -> value returned by 'create'
NeonSession * pSession = static_cast< NeonSession * >( userdata );
if ( pSession )
{
const RequestDataMap * pRequestData
= static_cast< const RequestDataMap* >(
pSession->getRequestData() );
RequestDataMap::const_iterator it = pRequestData->find( req );
if ( it != pRequestData->end() )
{
if ( (*it).second.aContentType.getLength() )
{
char * pData = headers->data;
if ( strstr( pData, "Content-Type:" ) == NULL )
{
rtl::OString aType
= rtl::OUStringToOString( (*it).second.aContentType,
RTL_TEXTENCODING_UTF8 );
ne_buffer_concat( headers, "Content-Type: ",
aType.getStr(), EOL, NULL );
}
}
if ( (*it).second.aReferer.getLength() )
{
char * pData = headers->data;
if ( strstr( pData, "Referer:" ) == NULL )
{
rtl::OString aReferer
= rtl::OUStringToOString( (*it).second.aReferer,
RTL_TEXTENCODING_UTF8 );
ne_buffer_concat( headers, "Referer: ",
aReferer.getStr(), EOL, NULL );
}
}
}
}
}
// -------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------
......@@ -504,7 +658,8 @@ uno::Reference< io::XInputStream > NeonSession::GET(
NeonInputStream * theInputStream = new NeonInputStream;
int theRetVal = GET( m_pHttpSession,
rtl::OUStringToOString( inPath, RTL_TEXTENCODING_UTF8 ),
rtl::OUStringToOString(
inPath, RTL_TEXTENCODING_UTF8 ),
ResponseBlockReader,
theInputStream );
HandleError( theRetVal );
......@@ -525,7 +680,8 @@ void NeonSession::GET( const rtl::OUString & inPath,
m_xEnv = inEnv;
int theRetVal = GET( m_pHttpSession,
rtl::OUStringToOString( inPath, RTL_TEXTENCODING_UTF8 ),
rtl::OUStringToOString(
inPath, RTL_TEXTENCODING_UTF8 ),
ResponseBlockWriter,
&ioOutputStream );
HandleError( theRetVal );
......@@ -938,44 +1094,6 @@ HttpSession * NeonSession::CreateSession( const ::rtl::OUString & inScheme,
return theHttpSession;
}
// -------------------------------------------------------------------
// ResponseBlockReader
// A simple Neon response_block_reader for use with an XInputStream
// -------------------------------------------------------------------
void NeonSession::ResponseBlockReader( void * inUserData,
const char * inBuf,
size_t inLen )
{
// neon calls this function with (inLen == 0)...
if ( inLen > 0 )
{
NeonInputStream * theInputStream
= static_cast< NeonInputStream *>( inUserData );
theInputStream->AddToStream( inBuf, inLen );
}
}
// -------------------------------------------------------------------
// ResponseBlockWriter
// A simple Neon response_block_reader for use with an XOutputStream
// -------------------------------------------------------------------
void NeonSession::ResponseBlockWriter( void * inUserData,
const char * inBuf,
size_t inLen )
{
// neon calls this function with (inLen == 0)...
if ( inLen > 0 )
{
uno::Reference< io::XOutputStream > * theOutputStreamPtr
= static_cast< uno::Reference< io::XOutputStream > * >( inUserData );
uno::Reference< io::XOutputStream > theOutputStream
= *theOutputStreamPtr;
const uno::Sequence< sal_Int8 > theSequence( (sal_Int8 *)inBuf, inLen );
theOutputStream->writeBytes( theSequence );
}
}
// Note: Uncomment the following if locking support is required
/*
void NeonSession::Lockit( const Lock & inLock, bool inLockit )
......@@ -1048,110 +1166,6 @@ void NeonSession::Lockit( const Lock & inLock, bool inLockit )
}
*/
int NeonSession::NeonAuth( void * inUserData,
const char * inRealm,
int attempt,
char * inoutUserName,
char * inoutPassWord )
{
NeonSession * theSession = static_cast< NeonSession * >( inUserData );
if ( !theSession->m_pListener )
{
// abort
return -1;
}
// username buffer is prefilled with user name from last attempt.
rtl::OUString theUserName(
rtl::OUString::createFromAscii( inoutUserName ) );
rtl::OUString thePassWord; /*(
// @@@ Neon does not initialize password buffer
// (last checked: 0.22.0).
rtl::OUString::createFromAscii( inoutPassWord ) ); */
int theRetVal = theSession->m_pListener->authenticate(
rtl::OUString::createFromAscii( inRealm ),
theSession->m_aHostName,
theUserName,
thePassWord,
theSession->m_xEnv );
strcpy( inoutUserName,
rtl::OUStringToOString( theUserName, RTL_TEXTENCODING_UTF8 ) );
strcpy( inoutPassWord,
rtl::OUStringToOString( thePassWord, RTL_TEXTENCODING_UTF8 ) );
return theRetVal;
}
// static
void NeonSession::ProgressNotify( void * userdata, off_t progress, off_t total )
{
// progress: bytes read so far
// total: total bytes to read, -1 -> total count not known
}
// static
void NeonSession::StatusNotify(
void * userdata, ne_conn_status status, const char *info )
{
#if 0
typedef enum {
ne_conn_namelookup, /* lookup up hostname (info = hostname) */
ne_conn_connecting, /* connecting to host (info = hostname) */
ne_conn_connected, /* connected to host (info = hostname) */
ne_conn_secure /* connection now secure (info = crypto level) */
} ne_conn_status;
#endif
// info: hostname
}
// static
void NeonSession::PreSendRequest( ne_request * req,
void * userdata,
ne_buffer * headers )
{
// userdata -> value returned by 'create'
NeonSession * pSession = static_cast< NeonSession * >( userdata );
if ( pSession )
{
RequestDataMap * pRequestData
= static_cast< RequestDataMap* >( pSession->m_pRequestData );
RequestDataMap::const_iterator it = pRequestData->find( req );
if ( it != pRequestData->end() )
{
if ( (*it).second.aContentType.getLength() )
{
char * pData = headers->data;
if ( strstr( pData, "Content-Type:" ) == NULL )
{
rtl::OString aType
= rtl::OUStringToOString( (*it).second.aContentType,
RTL_TEXTENCODING_UTF8 );
ne_buffer_concat( headers, "Content-Type: ",
aType.getStr(), EOL, NULL );
}
}
if ( (*it).second.aReferer.getLength() )
{
char * pData = headers->data;
if ( strstr( pData, "Referer:" ) == NULL )
{
rtl::OString aReferer
= rtl::OUStringToOString( (*it).second.aReferer,
RTL_TEXTENCODING_UTF8 );
ne_buffer_concat( headers, "Referer: ",
aReferer.getStr(), EOL, NULL );
}
}
}
}
}
// static
int NeonSession::GET( ne_session * sess,
const char * uri,
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: NeonSession.hxx,v $
*
* $Revision: 1.11 $
* $Revision: 1.12 $
*
* last change: $Author: kso $ $Date: 2002-08-15 10:05:29 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -131,6 +131,17 @@ class NeonSession : public DAVSession
com::sun::star::ucb::XCommandEnvironment >& inEnv )
throw ( DAVException );
DAVAuthListener * getServerAuthListener() const
{ return m_pListener; }
const com::sun::star::uno::Reference<
com::sun::star::ucb::XCommandEnvironment > &
getCommandEnvironment() const { return m_xEnv; }
const rtl::OUString & getHostName() const { return m_aHostName; }
const void * getRequestData() const { return m_pRequestData; }
// allprop & named
virtual void PROPFIND( const ::rtl::OUString & inPath,
const Depth inDepth,
......@@ -250,42 +261,12 @@ class NeonSession : public DAVSession
const ::rtl::OUString & inUserInfo )
throw( DAVException );
// A simple Neon response_block_reader for use with an XInputStream
static void ResponseBlockReader( void * inUserData,
const char * inBuf,
size_t inLen );
// A simple Neon response_block_reader for use with an XOutputStream
static void ResponseBlockWriter( void * inUserData,
const char * inBuf,
size_t inLen );
// Note: Uncomment the following if locking support is required
// void Lockit( const Lock & inLock, bool inLockit )
// throw ( DAVException );
// Authentication callback.
static int NeonAuth( void * inUserData,
const char * inRealm,
int attempt,
char * inoutUserName,
char * inoutPassWord );
// Progress / Status callbacks.
static void NeonSession::ProgressNotify( void * userdata,
off_t progress,
off_t total );
static void NeonSession::StatusNotify( void * userdata,
ne_conn_status status,
const char *info );
// pre-send-request callback
static void PreSendRequest( ne_request * req,
void * userdata,
ne_buffer * headers );
// low level GET implementation, used by both public GET implementations
// low level GET implementation, used by public GET implementations
static int GET( ne_session * sess,
const char * uri,
ne_block_reader reader,
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: UCBDeadPropertyValue.cxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: kso $ $Date: 2002-08-15 10:05:30 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -127,6 +127,62 @@ struct UCBDeadPropertyValueParseContext
~UCBDeadPropertyValueParseContext() { delete pType; delete pValue; }
};
//////////////////////////////////////////////////////////////////////////
extern "C" static int validate_callback( void * userdata,
ne_xml_elmid parent,
ne_xml_elmid child )
{
switch ( parent )
{
case 0:
if ( child == DAV_ELM_ucbprop )
return NE_XML_VALID;
break;
case DAV_ELM_ucbprop:
return NE_XML_VALID;
default:
break;
}
return NE_XML_DECLINE;
}
//////////////////////////////////////////////////////////////////////////
// static
extern "C" static int endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata )
{
UCBDeadPropertyValueParseContext * pCtx
= static_cast< UCBDeadPropertyValueParseContext * >( userdata );
switch ( s->id )
{
case DAV_ELM_type:
OSL_ENSURE( !pCtx->pType,
"UCBDeadPropertyValue::endelement_callback - "
"Type already set!" );
pCtx->pType = new rtl::OUString(
rtl::OUString::createFromAscii( cdata ) );
break;
case DAV_ELM_value:
OSL_ENSURE( !pCtx->pValue,
"UCBDeadPropertyValue::endelement_callback - "
"Value already set!" );
pCtx->pValue = new rtl::OUString(
rtl::OUString::createFromAscii( cdata ) );
break;
default:
break;
}
return 0;
}
//////////////////////////////////////////////////////////////////////////
static rtl::OUString encodeValue( const rtl::OUString & rValue )
{
......@@ -498,60 +554,3 @@ bool UCBDeadPropertyValue::toXML( const uno::Any & rInData,
return true;
}
//////////////////////////////////////////////////////////////////////////
// static
int UCBDeadPropertyValue::validate_callback( void * userdata,
ne_xml_elmid parent,
ne_xml_elmid child )
{
switch ( parent )
{
case 0:
if ( child == DAV_ELM_ucbprop )
return NE_XML_VALID;
break;
case DAV_ELM_ucbprop:
return NE_XML_VALID;
default:
break;
}
return NE_XML_DECLINE;
}
//////////////////////////////////////////////////////////////////////////
// static
int UCBDeadPropertyValue::endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata )
{
UCBDeadPropertyValueParseContext * pCtx
= static_cast< UCBDeadPropertyValueParseContext * >( userdata );
switch ( s->id )
{
case DAV_ELM_type:
OSL_ENSURE( !pCtx->pType,
"UCBDeadPropertyValue::endelement_callback - "
"Type already set!" );
pCtx->pType = new rtl::OUString(
rtl::OUString::createFromAscii( cdata ) );
break;
case DAV_ELM_value:
OSL_ENSURE( !pCtx->pValue,
"UCBDeadPropertyValue::endelement_callback - "
"Value already set!" );
pCtx->pValue = new rtl::OUString(
rtl::OUString::createFromAscii( cdata ) );
break;
default:
break;
}
return 0;
}
......@@ -2,9 +2,9 @@
*
* $RCSfile: UCBDeadPropertyValue.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: kso $ $Date: 2002-08-15 10:05:30 $
* last change: $Author: kso $ $Date: 2002-08-22 11:37:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -106,13 +106,6 @@ public:
com::sun::star::uno::Any & rOutData );
static bool toXML( const com::sun::star::uno::Any & rInData,
rtl::OUString & rOutData );
static int validate_callback( void * userdata,
ne_xml_elmid parent,
ne_xml_elmid child );
static int endelement_callback( void * userdata,
const struct ne_xml_elm * s,
const char * cdata );
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment