Helix Web Services Client  1
Helix Web Services Client SDK for Qt Applications
Helix Web Services Client SDK for Qt

Basic usage

The primary interface for Helix Web Services involves the hws::Client. The hws::Client interacts with the server via several remote calls. Subsequently, using this API usually starts by attaching slots up to several signals. Then you setup a signal

#include <hws.h>
hws::Client client;
// Each client should be tied to a particular Perforce Web Services instance.
client.setUrl("http://p4_web_services.mycompany.com");
connect(client, &hws::Client::logInDone,
myObj, &MyObj::logInDone);
myObj, &MyObj::executeMethodDone);
client.logIn("myuser", "mypassword");
// Some possible 'callback' handlers
void MyObj::logInDone(RequestErrorPtr err, SessionPtr session)
{
// You should probably check for errors, and probably cache the session
// here so you don't have to re-log in
// Load all projects just for a fun starting point
client.fetchProjects();
}
void MyObj::executeMethodDone(RequestErrorPtr err,
const QString & method,
const QString & path,
const QSharedPointer<hws::Client::QVariantMapList> data)
{
// given the method and path, probably reformat and dispatch the
// data to your application's handlers
}

Each hws::Client instance requires a Session. A session can be created by calling the logIn method, which will then store the session locally. (That Session instance can be stored locally and then, instead of calling logIn, you call setSession.) This session will be valid as long as the underlying Perforce server ticket allows. If you start to receive authentication errors, your client will have to log in again, and restore a new session.

Authentication errors are returned with the code RequestError::AUTHENTICATION_ERROR of any RequestError returned by pretty much any server call.