#include <molequeue/client/client.h>
|
enum | MessageType {
Invalid = -1,
ListQueues,
SubmitJob,
CancelJob,
LookupJob,
RegisterOpenWith,
ListOpenWithNames,
UnregisterOpenWith
} |
|
|
JsonRpcClient * | m_jsonRpcClient |
|
QHash< unsigned int, MessageType > | m_requests |
|
The Client class is used by clients to submit jobs to a running MoleQueue server.
- Author
- Marcus D. Hanwell
Provides a simple Qt C++ API to use the MoleQueue JSON-RPC calls to submit and query the state of submitted jobs.
bool isConnected |
( |
| ) |
const |
Query if the client is connected to a server.
- Returns
- True if connected, false if not.
bool connectToServer |
( |
const QString & |
serverName = "MoleQueue" | ) |
|
|
slot |
Connect to the server.
- Parameters
-
serverName | Name of the socket to connect to, the default of "MoleQueue" is usually correct when connecting to the running MoleQueue. |
Request the list of queues and programs from the server. The signal queueListReceived() will be emitted once this has been received.
- Returns
- The local ID of the job submission request.
Submit a job to MoleQueue. If the returned local ID is retained the signal for a job submission will provide the MoleQueue ID along with the local ID.
- Parameters
-
job | The job specification to be submitted to MoleQueue. |
- Returns
- The local ID of the job submission request.
int lookupJob |
( |
unsigned int |
moleQueueId | ) |
|
|
slot |
Request information about a job. You should supply the MoleQueue ID that was received in response to a job submission.
- Parameters
-
moleQueueId | The MoleQueue ID for the job. |
- Returns
- The local ID of the job submission request.
int cancelJob |
( |
unsigned int |
moleQueueId | ) |
|
|
slot |
Cancel a job that was submitted.
- Parameters
-
moleQueueId | The MoleQueue ID for the job. |
- Returns
- The local ID of the job submission request.
int registerOpenWith |
( |
const QString & |
name, |
|
|
const QString & |
executable, |
|
|
const QList< QRegExp > & |
filePatterns |
|
) |
| |
|
slot |
Register an executable file handler with MoleQueue.
@param name GUI name of the file handler.
@param executable Executable to call with the filename as the first
argument. If the full path to the exectuble is not specified, it must be
in the user's $PATH.
@param filePatterns A list of QRegExp objects that the handler can open.
The QRegExp objects must use RegExp, RegExp2, WildCard, or WildCardUnix
pattern syntax, else they will be ignored.
@return The local ID of the request.
@note The executable is expected to use the following calling convention
to open files:
executable /absolute/path/to/selected/fileName
int registerOpenWith |
( |
const QString & |
name, |
|
|
const QString & |
rpcServer, |
|
|
const QString & |
rpcMethod, |
|
|
const QList< QRegExp > & |
filePatterns |
|
) |
| |
|
slot |
Register a JSON-RPC 2.0 local socket file handler with MoleQueue.
@param name GUI name of the file handler.
@param rpcServer Name of the local socket that the server is listening on.
@param rpcMethod JSON-RPC 2.0 request method to use.
@param filePatterns A list of QRegExp objects that the handler can open.
The QRegExp objects must use RegExp, RegExp2, WildCard, or WildCardUnix
pattern syntax, else they will be ignored.
@return The local ID of the request.
@note The following JSON-RPC 2.0 request is sent to the server when the
handler is activated:
{
"jsonrpc": "2.0",
"method": "<rpcMethod>",
"params": {
"fileName": "/absolute/path/to/selected/fileName"
}
},
"id": "XXX"
}
where <rpcMethod> is replaced by the rpcMethod argument.
int listOpenWithNames |
( |
| ) |
|
|
slot |
Request a list of all file handler names.
- Returns
- The local ID of the request.
int unregisterOpenWith |
( |
const QString & |
handlerName | ) |
|
|
slot |
Unregister the indicated file handler from the molequeue server.
- Parameters
-
handlerName | Name of the file handler to remove. |
- Returns
- The local ID of the request.
- See Also
- listOpenWithNames
flush Flush all pending messages to the server.
- Warning
- This should not need to be called if used in an event loop, as Qt will start writing to the socket as soon as control returns to the event loop.
void connectionStateChanged |
( |
| ) |
|
|
signal |
Emitted when the connection state changes.
void queueListReceived |
( |
QJsonObject |
queues | ) |
|
|
signal |
Emitted when the remote queue list is received. This gives a list of lists, the primary key is the queue name, and that contains a list of available programs for each queue.
- Parameters
-
queues | A JSON object containing the names of the queues and the programs each queue have available. |
void submitJobResponse |
( |
int |
localId, |
|
|
unsigned int |
moleQueueId |
|
) |
| |
|
signal |
Emitted when the job request response is received.
- Parameters
-
localId | The local ID the job submission response is in reply to. |
moleQueueId | The remote MoleQueue ID for the job submission (can be used to perform further actions on the job). |
void lookupJobResponse |
( |
int |
localId, |
|
|
QJsonObject |
jobInfo |
|
) |
| |
|
signal |
Emitted when a job lookup response is received.
- Parameters
-
localId | The local ID the job submission response is in reply to. |
jobInfo | A Json object containing all available job information. |
void cancelJobResponse |
( |
unsigned int |
moleQueueId | ) |
|
|
signal |
Emitted when a job is successfully cancelled.
void jobStateChanged |
( |
unsigned int |
moleQueueId, |
|
|
QString |
oldState, |
|
|
QString |
newState |
|
) |
| |
|
signal |
Emitted when the job state changes.
void registerOpenWithResponse |
( |
int |
localId | ) |
|
|
signal |
Emitted when a successful registerOpenWith response is received.
void listOpenWithNamesResponse |
( |
int |
localId, |
|
|
QJsonArray |
handlerNames |
|
) |
| |
|
signal |
Emitted when a successful listOpenWithNames response is received.
void unregisterOpenWithResponse |
( |
int |
localId | ) |
|
|
signal |
Emitted when a successful unregisterOpenWith response is received.
void errorReceived |
( |
int |
localId, |
|
|
int |
errorCode, |
|
|
QString |
errorMessage, |
|
|
QJsonValue |
errorData |
|
) |
| |
|
signal |
Emitted when an error response is received.
void processResult |
( |
const QJsonObject & |
response | ) |
|
|
protectedslot |
Parse the response object and emit the appropriate signal(s).
void processNotification |
( |
const QJsonObject & |
notification | ) |
|
|
protectedslot |
Parse a notification object and emit the appropriate signal(s).
void processError |
( |
const QJsonObject & |
notification | ) |
|
|
protectedslot |
Parse an error object and emit the appropriate signal(s).
The documentation for this class was generated from the following file: