added the cancelTransport() method
This commit is contained in:
parent
c12f102b7b
commit
a577df91bd
7 changed files with 282 additions and 170 deletions
|
@ -420,45 +420,6 @@ class StorageClientInterface
|
|||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* The possible states of an asynchronous transport process.
|
||||
*/
|
||||
typedef enum { initState,
|
||||
pendingState,
|
||||
finishedState,
|
||||
closedState,
|
||||
failedState } TransportState;
|
||||
|
||||
/**
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*
|
||||
* If the return value is
|
||||
* <ul><li>initState or pendingState, then the operation
|
||||
* is in progress, and you need to call this function again until
|
||||
* a different value is returned;</li>
|
||||
* <li>finishedState, then the asynchronous XML-RPC call has
|
||||
* completed normally;</li>
|
||||
* <li>closedState, then the transport has been
|
||||
* closed or canceled, and the token is no longer valid;</li>
|
||||
* <li>failedState, then an error has occured (and the token is
|
||||
* no longer valid); the error message is returned in the (optional)
|
||||
* errorMessage return parameter.
|
||||
* </ul>
|
||||
*
|
||||
* @param token the transport token of an asynchronous method.
|
||||
* @param errorMessage return parameter: if the transport has failed,
|
||||
* this will contain the error message (optional).
|
||||
* @return the state of the transport.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual TransportState
|
||||
checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage
|
||||
= Ptr<Glib::ustring>::Ref())
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Return the list of audio clip IDs found by the search method.
|
||||
*
|
||||
|
@ -619,6 +580,60 @@ class StorageClientInterface
|
|||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* The possible states of an asynchronous transport process.
|
||||
*/
|
||||
typedef enum { initState,
|
||||
pendingState,
|
||||
finishedState,
|
||||
closedState,
|
||||
failedState } TransportState;
|
||||
|
||||
/**
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*
|
||||
* If the return value is
|
||||
* <ul><li>initState or pendingState, then the operation
|
||||
* is in progress, and you need to call this function again until
|
||||
* a different value is returned;</li>
|
||||
* <li>finishedState, then the asynchronous XML-RPC call has
|
||||
* completed normally;</li>
|
||||
* <li>closedState, then the transport has been
|
||||
* closed or canceled, and the token is no longer valid;</li>
|
||||
* <li>failedState, then an error has occured (and the token is
|
||||
* no longer valid); the error message is returned in the (optional)
|
||||
* errorMessage return parameter.
|
||||
* </ul>
|
||||
*
|
||||
* @param token the transport token of an asynchronous method.
|
||||
* @param errorMessage return parameter: if the transport has failed,
|
||||
* this will contain the error message (optional).
|
||||
* @return the state of the transport.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual TransportState
|
||||
checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage
|
||||
= Ptr<Glib::ustring>::Ref())
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Cancel an asynchronous network transport operation.
|
||||
*
|
||||
* @param sessionId the session ID from the authentication client.
|
||||
* @param token the transport token of an asynchronous method.
|
||||
* @return the state of the transport.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual void
|
||||
cancelTransport(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<const Glib::ustring>::Ref token)
|
||||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
|
|
|
@ -859,25 +859,6 @@ TestStorageClient :: remoteSearchClose(Ptr<const Glib::ustring>::Ref token)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
StorageClientInterface::TransportState
|
||||
TestStorageClient :: checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
if (token && *token == "fake_token") {
|
||||
return pendingState;
|
||||
} else {
|
||||
if (errorMessage) {
|
||||
errorMessage->assign("bad token");
|
||||
}
|
||||
return failedState;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* See if the Playable instance satisfies the search criteria
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -1097,3 +1078,33 @@ TestStorageClient :: exportPlaylistClose(
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
StorageClientInterface::TransportState
|
||||
TestStorageClient :: checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
if (token && *token == "fake_token") {
|
||||
return pendingState;
|
||||
} else {
|
||||
if (errorMessage) {
|
||||
errorMessage->assign("bad token");
|
||||
}
|
||||
return failedState;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Cancel an asynchronous network transport operation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TestStorageClient :: cancelTransport(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<const Glib::ustring>::Ref token)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -569,35 +569,6 @@ class TestStorageClient :
|
|||
remoteSearchClose(Ptr<const Glib::ustring>::Ref token)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*
|
||||
* If the return value is
|
||||
* <ul><li>initState or pendingState, then the operation
|
||||
* is in progress, and you need to call this function again until
|
||||
* a different value is returned;</li>
|
||||
* <li>finishedState, then the asynchronous XML-RPC call has
|
||||
* completed normally;</li>
|
||||
* <li>closedState, then the transport has been
|
||||
* closed or canceled, and the token is no longer valid;</li>
|
||||
* <li>failedState, then an error has occured (and the token is
|
||||
* no longer valid); the error message is returned in the (optional)
|
||||
* errorMessage return parameter.
|
||||
* </ul>
|
||||
*
|
||||
* @param token the transport token of an asynchronous method.
|
||||
* @param errorMessage return parameter: if the transport has failed,
|
||||
* this will contain the error message (optional).
|
||||
* @return the state of the transport.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual TransportState
|
||||
checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage
|
||||
= Ptr<Glib::ustring>::Ref())
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Return the list of audio clip IDs found by the search method.
|
||||
*
|
||||
|
@ -740,6 +711,49 @@ class TestStorageClient :
|
|||
virtual void
|
||||
exportPlaylistClose(Ptr<const Glib::ustring>::Ref token) const
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*
|
||||
* If the return value is
|
||||
* <ul><li>initState or pendingState, then the operation
|
||||
* is in progress, and you need to call this function again until
|
||||
* a different value is returned;</li>
|
||||
* <li>finishedState, then the asynchronous XML-RPC call has
|
||||
* completed normally;</li>
|
||||
* <li>closedState, then the transport has been
|
||||
* closed or canceled, and the token is no longer valid;</li>
|
||||
* <li>failedState, then an error has occured (and the token is
|
||||
* no longer valid); the error message is returned in the (optional)
|
||||
* errorMessage return parameter.
|
||||
* </ul>
|
||||
*
|
||||
* @param token the transport token of an asynchronous method.
|
||||
* @param errorMessage return parameter: if the transport has failed,
|
||||
* this will contain the error message (optional).
|
||||
* @return the state of the transport.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual TransportState
|
||||
checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage
|
||||
= Ptr<Glib::ustring>::Ref())
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Cancel an asynchronous network transport operation.
|
||||
*
|
||||
* @param sessionId the session ID from the authentication client.
|
||||
* @param token the transport token of an asynchronous method.
|
||||
* @return the state of the transport.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual void
|
||||
cancelTransport(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<const Glib::ustring>::Ref token)
|
||||
throw (XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -560,5 +560,9 @@ TestStorageClientTest :: remoteSearchTest(void)
|
|||
CPPUNIT_ASSERT_THROW(
|
||||
tsc->remoteSearchClose(token), XmlRpcMethodFaultException
|
||||
);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
tsc->cancelTransport(dummySessionId, token);
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -785,7 +785,7 @@ const std::string remoteSearchTokenParamName = "trtok";
|
|||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: checkTransport */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the check transport method on the storage server
|
||||
* The name of the check transport method on the storage server
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string checkTransportMethodName = "locstor.getTransportInfo";
|
||||
|
||||
|
@ -804,6 +804,29 @@ const std::string checkTransportStateParamName = "state";
|
|||
*----------------------------------------------------------------------------*/
|
||||
const std::string checkTransportErrorMessageParamName = "errmsg";
|
||||
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: doTransportAction */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the do transport action method on the storage server
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string doTransportActionMethodName = "locstor.doTransportAction";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the session ID parameter in the input structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string doTransportActionSessionIdParamName = "sessid";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the token parameter in the input structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string doTransportActionTokenParamName = "trtok";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the action parameter in the input structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string doTransportActionActionParamName = "action";
|
||||
|
||||
}
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
@ -2180,58 +2203,6 @@ WebStorageClient :: remoteSearchClose(Ptr<const Glib::ustring>::Ref token)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
StorageClientInterface::TransportState
|
||||
WebStorageClient :: checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
||||
parameters.clear();
|
||||
parameters[checkTransportTokenParamName]
|
||||
= std::string(*token);
|
||||
|
||||
execute(checkTransportMethodName, parameters, result);
|
||||
|
||||
checkStruct(checkTransportMethodName,
|
||||
result,
|
||||
checkTransportStateParamName,
|
||||
XmlRpcValue::TypeString);
|
||||
|
||||
std::string state = result[checkTransportStateParamName];
|
||||
if (state == "init") {
|
||||
return initState;
|
||||
} else if (state == "pending") {
|
||||
return pendingState;
|
||||
} else if (state == "finished") {
|
||||
return finishedState;
|
||||
} else if (state == "closed") {
|
||||
return closedState;
|
||||
} else if (state == "failed") {
|
||||
if (errorMessage) {
|
||||
checkStruct(checkTransportMethodName,
|
||||
result,
|
||||
checkTransportErrorMessageParamName,
|
||||
XmlRpcValue::TypeString);
|
||||
errorMessage->assign(std::string(
|
||||
result[checkTransportErrorMessageParamName]));
|
||||
}
|
||||
return failedState;
|
||||
} else {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "Unrecognized transport state returned by XML-RPC method '"
|
||||
<< checkTransportMethodName
|
||||
<< "':\n"
|
||||
<< result;
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return a list of all playlists in the storage.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -2462,3 +2433,78 @@ WebStorageClient :: exportPlaylistClose(
|
|||
execute(exportPlaylistCloseMethodName, parameters, result);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
StorageClientInterface::TransportState
|
||||
WebStorageClient :: checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
||||
parameters.clear();
|
||||
parameters[checkTransportTokenParamName]
|
||||
= std::string(*token);
|
||||
|
||||
execute(checkTransportMethodName, parameters, result);
|
||||
|
||||
checkStruct(checkTransportMethodName,
|
||||
result,
|
||||
checkTransportStateParamName,
|
||||
XmlRpcValue::TypeString);
|
||||
|
||||
std::string state = result[checkTransportStateParamName];
|
||||
if (state == "init") {
|
||||
return initState;
|
||||
} else if (state == "pending") {
|
||||
return pendingState;
|
||||
} else if (state == "finished") {
|
||||
return finishedState;
|
||||
} else if (state == "closed") {
|
||||
return closedState;
|
||||
} else if (state == "failed") {
|
||||
if (errorMessage) {
|
||||
checkStruct(checkTransportMethodName,
|
||||
result,
|
||||
checkTransportErrorMessageParamName,
|
||||
XmlRpcValue::TypeString);
|
||||
errorMessage->assign(std::string(
|
||||
result[checkTransportErrorMessageParamName]));
|
||||
}
|
||||
return failedState;
|
||||
} else {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "Unrecognized transport state returned by XML-RPC method '"
|
||||
<< checkTransportMethodName
|
||||
<< "':\n"
|
||||
<< result;
|
||||
throw XmlRpcMethodResponseException(eMsg.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Cancel an asynchronous network transport operation.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
WebStorageClient :: cancelTransport(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<const Glib::ustring>::Ref token)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
XmlRpcValue parameters;
|
||||
XmlRpcValue result;
|
||||
|
||||
parameters.clear();
|
||||
parameters[doTransportActionSessionIdParamName]
|
||||
= sessionId->getId();
|
||||
parameters[doTransportActionTokenParamName]
|
||||
= std::string(*token);
|
||||
parameters[doTransportActionActionParamName]
|
||||
= "cancel";
|
||||
|
||||
execute(doTransportActionMethodName, parameters, result);
|
||||
}
|
||||
|
||||
|
|
|
@ -664,35 +664,6 @@ class WebStorageClient :
|
|||
remoteSearchClose(Ptr<const Glib::ustring>::Ref token)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*
|
||||
* If the return value is
|
||||
* <ul><li>initState or pendingState, then the operation
|
||||
* is in progress, and you need to call this function again until
|
||||
* a different value is returned;</li>
|
||||
* <li>finishedState, then the asynchronous XML-RPC call has
|
||||
* completed normally;</li>
|
||||
* <li>closedState, then the transport has been
|
||||
* closed or canceled, and the token is no longer valid;</li>
|
||||
* <li>failedState, then an error has occured (and the token is
|
||||
* no longer valid); the error message is returned in the (optional)
|
||||
* errorMessage return parameter.
|
||||
* </ul>
|
||||
*
|
||||
* @param token the transport token of an asynchronous method.
|
||||
* @param errorMessage return parameter: if the transport has failed,
|
||||
* this will contain the error message (optional).
|
||||
* @return the state of the transport.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual TransportState
|
||||
checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage
|
||||
= Ptr<Glib::ustring>::Ref())
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Return the list of playlist IDs found by the search method.
|
||||
*
|
||||
|
@ -832,6 +803,49 @@ class WebStorageClient :
|
|||
virtual void
|
||||
exportPlaylistClose(Ptr<const Glib::ustring>::Ref token) const
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Check the status of the asynchronous network transport operation.
|
||||
*
|
||||
* If the return value is
|
||||
* <ul><li>initState or pendingState, then the operation
|
||||
* is in progress, and you need to call this function again until
|
||||
* a different value is returned;</li>
|
||||
* <li>finishedState, then the asynchronous XML-RPC call has
|
||||
* completed normally;</li>
|
||||
* <li>closedState, then the transport has been
|
||||
* closed or canceled, and the token is no longer valid;</li>
|
||||
* <li>failedState, then an error has occured (and the token is
|
||||
* no longer valid); the error message is returned in the (optional)
|
||||
* errorMessage return parameter.
|
||||
* </ul>
|
||||
*
|
||||
* @param token the transport token of an asynchronous method.
|
||||
* @param errorMessage return parameter: if the transport has failed,
|
||||
* this will contain the error message (optional).
|
||||
* @return the state of the transport.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual TransportState
|
||||
checkTransport(Ptr<const Glib::ustring>::Ref token,
|
||||
Ptr<Glib::ustring>::Ref errorMessage
|
||||
= Ptr<Glib::ustring>::Ref())
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Cancel an asynchronous network transport operation.
|
||||
*
|
||||
* @param sessionId the session ID from the authentication client.
|
||||
* @param token the transport token of an asynchronous method.
|
||||
* @return the state of the transport.
|
||||
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||
* call.
|
||||
*/
|
||||
virtual void
|
||||
cancelTransport(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<const Glib::ustring>::Ref token)
|
||||
throw (XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -933,6 +933,10 @@ WebStorageClientTest :: remoteSearchTest(void)
|
|||
);
|
||||
CPPUNIT_ASSERT(token);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
wsc->cancelTransport(sessionId, token)
|
||||
);
|
||||
|
||||
Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring);
|
||||
StorageClientInterface::TransportState state;
|
||||
|
||||
|
@ -951,7 +955,11 @@ WebStorageClientTest :: remoteSearchTest(void)
|
|||
CPPUNIT_ASSERT_EQUAL(StorageClientInterface::finishedState, state);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
wsc->remoteSearchClose(token)
|
||||
wsc->remoteSearchClose(token);
|
||||
);
|
||||
|
||||
CPPUNIT_ASSERT_THROW(
|
||||
wsc->cancelTransport(sessionId, token), XmlRpcMethodFaultException
|
||||
);
|
||||
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue