Basic support for event canceling
This commit is contained in:
@@ -176,9 +176,8 @@ void CmaClient::enterEventLoop(vita_device_t *device)
|
|||||||
|
|
||||||
// this one shuold be processed inmediately
|
// this one shuold be processed inmediately
|
||||||
} else if(event.Code == PTP_EC_VITA_RequestCancelTask) {
|
} else if(event.Code == PTP_EC_VITA_RequestCancelTask) {
|
||||||
quint32 eventIdToCancel = event.Param2;
|
eventLoop.vitaEventCancelTask(&event, event.Param1);
|
||||||
qDebug("Cancelling event %d", eventIdToCancel);
|
qDebug("Ended event, code: 0x%x, id: %d", event.Code, event.Param1);
|
||||||
VitaMTP_CancelTask(device, eventIdToCancel);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
cmaevent.cpp
29
cmaevent.cpp
@@ -298,8 +298,9 @@ void CmaEvent::vitaEventSendObjectMetadataItems(vita_event_t *event, int eventId
|
|||||||
metadata->next_metadata = NULL;
|
metadata->next_metadata = NULL;
|
||||||
qDebug("Sending metadata for OHFI %d (%s)", ohfi, metadata->path);
|
qDebug("Sending metadata for OHFI %d (%s)", ohfi, metadata->path);
|
||||||
|
|
||||||
if(VitaMTP_SendObjectMetadata(device, eventId, metadata) != PTP_RC_OK) {
|
quint16 ret = VitaMTP_SendObjectMetadata(device, eventId, metadata);
|
||||||
qWarning("Error sending metadata");
|
if(ret != PTP_RC_OK) {
|
||||||
|
qWarning("Error sending metadata. Code: %04X", ret);
|
||||||
} else {
|
} else {
|
||||||
VitaMTP_ReportResult(device, eventId, PTP_RC_OK);
|
VitaMTP_ReportResult(device, eventId, PTP_RC_OK);
|
||||||
}
|
}
|
||||||
@@ -318,6 +319,24 @@ void CmaEvent::vitaEventUnimplementated(vita_event_t *event, int eventId)
|
|||||||
qWarning("Param1: 0x%08X, Param2: 0x%08X, Param3: 0x%08X", event->Param1, event->Param2, event->Param3);
|
qWarning("Param1: 0x%08X, Param2: 0x%08X, Param3: 0x%08X", event->Param1, event->Param2, event->Param3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CmaEvent::vitaEventCancelTask(vita_event_t *event, int eventId)
|
||||||
|
{
|
||||||
|
qDebug("Event recieved in %s, code: 0x%x, id: %d", Q_FUNC_INFO, event->Code, eventId);
|
||||||
|
|
||||||
|
quint32 eventIdToCancel = event->Param2;
|
||||||
|
qDebug("Cancelling event %d", eventIdToCancel);
|
||||||
|
quint16 ret = VitaMTP_CancelTask(device, eventIdToCancel);
|
||||||
|
|
||||||
|
// wait until the current event finishes so we can report the result to the device
|
||||||
|
|
||||||
|
qDebug("Waiting for send event to finish");
|
||||||
|
mutex.lock();
|
||||||
|
if(ret == PTP_RC_OK) {
|
||||||
|
VitaMTP_ReportResult(device, eventId, PTP_RC_OK);
|
||||||
|
}
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
void CmaEvent::vitaEventSendNumOfObject(vita_event_t *event, int eventId)
|
void CmaEvent::vitaEventSendNumOfObject(vita_event_t *event, int eventId)
|
||||||
{
|
{
|
||||||
qDebug("Event recieved in %s, code: 0x%x, id: %d", Q_FUNC_INFO, event->Code, eventId);
|
qDebug("Event recieved in %s, code: 0x%x, id: %d", Q_FUNC_INFO, event->Code, eventId);
|
||||||
@@ -409,8 +428,10 @@ void CmaEvent::vitaEventSendObject(vita_event_t *event, int eventId)
|
|||||||
qDebug("Sending %s of %lu bytes to device", object->metadata.name, len);
|
qDebug("Sending %s of %lu bytes to device", object->metadata.name, len);
|
||||||
qDebug("OHFI %d with handle 0x%08X", ohfi, parentHandle);
|
qDebug("OHFI %d with handle 0x%08X", ohfi, parentHandle);
|
||||||
|
|
||||||
if(VitaMTP_SendObject(device, &parentHandle, &handle, &object->metadata, data) != PTP_RC_OK) {
|
VitaMTP_RegisterCancelEventId(eventId);
|
||||||
qWarning("Sending of %s failed.", object->metadata.name);
|
quint16 ret = VitaMTP_SendObject(device, &parentHandle, &handle, &object->metadata, data);
|
||||||
|
if(ret != PTP_RC_OK) {
|
||||||
|
qWarning("Sending of %s failed. Code: %04X", object->metadata.name, ret);
|
||||||
file.unmap(data);
|
file.unmap(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,8 @@ class CmaEvent : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit CmaEvent(vita_device_t *s_device);
|
explicit CmaEvent(vita_device_t *s_device);
|
||||||
|
|
||||||
|
void vitaEventCancelTask(vita_event_t *event, int eventId);
|
||||||
|
|
||||||
// don't make the db reference static
|
// don't make the db reference static
|
||||||
static Database *db;
|
static Database *db;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user