vboxweb.h revision 346cc7e1843368faa82a774a9fc62507ddc91c28
/*
* vboxweb.h:
* header file for "real" web server code.
*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/****************************************************************************
*
* debug macro
*
****************************************************************************/
// #ifdef DEBUG
// #else
// #define WEBDEBUG(a) do { } while(0)
// #endif
/****************************************************************************
*
* global variables
*
****************************************************************************/
extern bool g_fVerbose;
/****************************************************************************
*
* typedefs
*
****************************************************************************/
// type used by gSOAP-generated code
// type used internally by our class
// typedef WSDLT_ID ManagedObjectID;
// #define VBOXWEB_ERROR_BASE 10000
// #define VBOXWEB_INVALID_MANAGED_OBJECT (VBOXWEB_ERROR_BASE + 0)
// #define VBOXWEB_INVALID_MANAGED_OBJECT_TYPE (VBOXWEB_ERROR_BASE + 1)
/****************************************************************************
*
* SOAP exceptions
*
****************************************************************************/
/****************************************************************************
*
* conversion helpers
*
****************************************************************************/
/****************************************************************************
*
* managed object reference classes
*
****************************************************************************/
/**
*
*/
{
bool _fDestructing;
// hide the copy constructor because we're not copyable
int authenticate(const char *pcszUsername,
const char *pcszPassword);
{
return _uSessionID;
}
WSDLT_ID getSessionObject() const;
void touch();
time_t getLastObjectLookup() const
{
return _tLastObjectLookup;
}
void DumpRefs();
};
/**
* ManagedObjectRef is used to map COM pointers to object IDs
* within a session. Such object IDs are 64-bit integers.
*
* When a webservice method call is invoked on an object, it
* has an opaque string called a "managed object reference". Such
* a string consists of a session ID combined with an object ID.
*
*/
{
// owning session:
// value:
const char *_pcszInterface;
// keys:
// long ID as string
const char *pcszInterface,
~ManagedObjectRef();
{
return _id;
}
{
return _pObj;
}
const char* getInterfaceName() const
{
return _pcszInterface;
}
ManagedObjectRef **pRef);
};
/**
* Template function that resolves a managed object reference to a COM pointer
* of the template class T. Gets called from tons of generated code in
*
* This is a template function so that we can support ComPtr's for arbitrary
* interfaces and automatically verify that the managed object reference on
* the internal stack actually is of the expected interface.
*
* @param soap
* @param id integer managed object reference, as passed in by web service client
* @param pComPtr reference to COM pointer object that receives the com pointer,
* if SOAP_OK is returned
* @return error code or SOAP_OK if no error
*/
{
int rc;
else
{
// pRef->getComPtr returns a ComPtr<IUnknown>; by casting it to
// ComPtr<T>, we implicitly do a queryInterface() call
return 0;
WEBDEBUG((" Interface not supported for object reference %s, which is of class %s\n", id.c_str(), pRef->getInterfaceName()));
}
return rc;
}
/**
* Template function that creates a new managed object for the given COM
* pointer of the template class T. If a reference already exists for the
* given pointer, then that reference's ID is returned instead.
*
* @param idParent managed object reference of calling object; used to extract session ID
* @param pc COM object for which to create a reference
* @return existing or new managed object reference
*/
const char *pcszInterface,
{
{
// WEBDEBUG(("\n-- found session for %s\n", idParent.c_str()));
)
}
return 0;
}