Skip to content

Commit

Permalink
feat: allow deleting apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex4386 committed Jun 8, 2024
1 parent 4e04a13 commit c9bc43a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
47 changes: 21 additions & 26 deletions src/scenes/mtp/mtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ void handle_mtp_command(AppMTP* mtp, struct MTPContainer* container) {
mtp, MTP_TYPE_RESPONSE, MTP_RESP_OK, container->header.transaction_id, NULL, 0);
break;
}
case MTP_OP_DELETE_OBJECT:
FURI_LOG_I("MTP", "DeleteObject operation");
if(DeleteObject(mtp, container->params[0])) {
send_mtp_response(mtp, 3, MTP_RESP_OK, container->header.transaction_id, NULL);
} else {
send_mtp_response(
mtp, 3, MTP_RESP_INVALID_OBJECT_HANDLE, container->header.transaction_id, NULL);
}
break;

case MTP_OP_GET_DEVICE_PROP_VALUE:
FURI_LOG_I("MTP", "GetDevicePropValue operation");
Expand Down Expand Up @@ -1061,36 +1070,22 @@ void WriteMTPBEString(uint8_t* buffer, const char* str, uint16_t* length) {
*length = ptr - buffer;
}

uint32_t CreateObject(AppMTP* mtp, uint32_t parent_handle, const char* name, bool is_directory) {
bool DeleteObject(AppMTP* mtp, uint32_t handle) {
UNUSED(mtp);
MTPObject new_object;
UNUSED(new_object);
UNUSED(parent_handle);
UNUSED(name);
UNUSED(is_directory);

FURI_LOG_I("MTP", "Creating object %s", name);
return 0;
}
FURI_LOG_I("MTP", "Deleting object %ld", handle);

uint32_t ReadObject(AppMTP* mtp, uint32_t handle, uint8_t* buffer, uint32_t size) {
UNUSED(mtp);
UNUSED(buffer);
UNUSED(size);
FURI_LOG_I("MTP", "Reading object %ld", handle);
char* path = get_path_from_handle(mtp, handle);
if(path == NULL) {
return false;
}

return 0;
}
if(!storage_file_exists(mtp->storage, path)) {
return false;
}

void WriteObject(AppMTP* mtp, uint32_t handle, uint8_t* data, uint32_t size) {
UNUSED(mtp);
UNUSED(data);
UNUSED(size);
FURI_LOG_I("MTP", "Writing object %ld", handle);
}
if(storage_common_remove(mtp->storage, path) != FSE_OK) {
return false;
}

bool DeleteObject(AppMTP* mtp, uint32_t handle) {
UNUSED(mtp);
FURI_LOG_I("MTP", "Deleting object %ld", handle);
return true;
}
6 changes: 2 additions & 4 deletions src/scenes/mtp/mtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
#define MTP_OP_GET_OBJECT_HANDLES 0x1007
#define MTP_OP_GET_OBJECT_INFO 0x1008
#define MTP_OP_GET_OBJECT 0x1009

#define MTP_OP_DELETE_OBJECT 0x100B
#define MTP_OP_SEND_OBJECT_INFO 0x100C
#define MTP_OP_SEND_OBJECT 0x100D
#define MTP_OP_DELETE_OBJECT 0x100B
#define MTP_OP_GET_DEVICE_PROP_DESC 0x1014
#define MTP_OP_GET_DEVICE_PROP_VALUE 0x1015

Expand Down Expand Up @@ -135,9 +136,6 @@ void OpenSession(AppMTP* mtp, uint32_t session_id);
void CloseSession(AppMTP* mtp);
void GetStorageIDs(AppMTP* mtp, uint32_t* storage_ids, uint32_t* count);
int GetStorageInfo(AppMTP* mtp, uint32_t storage_id, uint8_t* buf);
uint32_t CreateObject(AppMTP* mtp, uint32_t parent_handle, const char* name, bool is_directory);
uint32_t ReadObject(AppMTP* mtp, uint32_t handle, uint8_t* buffer, uint32_t size);
void WriteObject(AppMTP* mtp, uint32_t handle, uint8_t* data, uint32_t size);
bool DeleteObject(AppMTP* mtp, uint32_t handle);

void mtp_handle_bulk(AppMTP* mtp, uint8_t* buffer, uint32_t length);
Expand Down

0 comments on commit c9bc43a

Please sign in to comment.