MtpResponseCode MtpServer::doEndEditObject() { MtpObjectHandle handle = mRequest.getParameter(1); ObjectEdit* edit = getEditObject(handle); if (!edit) { LOGE("object not open for edit in doEndEditObject"); return MTP_RESPONSE_GENERAL_ERROR; } commitEdit(edit); removeEditObject(handle); return MTP_RESPONSE_OK; }
void MtpServer::run() { int fd = mFD; LOGV("MtpServer::run fd: %d\n", fd); while (1) { int ret = mRequest.read(fd); if (ret < 0) { LOGV("request read returned %d, errno: %d", ret, errno); if (errno == ECANCELED) { // return to top of loop and wait for next command continue; } break; } MtpOperationCode operation = mRequest.getOperationCode(); MtpTransactionID transaction = mRequest.getTransactionID(); LOGV("operation: %s", MtpDebug::getOperationCodeName(operation)); mRequest.dump(); // FIXME need to generalize this bool dataIn = (operation == MTP_OPERATION_SEND_OBJECT_INFO || operation == MTP_OPERATION_SET_OBJECT_REFERENCES || operation == MTP_OPERATION_SET_OBJECT_PROP_VALUE || operation == MTP_OPERATION_SET_DEVICE_PROP_VALUE); if (dataIn) { int ret = mData.read(fd); if (ret < 0) { LOGE("data read returned %d, errno: %d", ret, errno); if (errno == ECANCELED) { // return to top of loop and wait for next command continue; } break; } LOGV("received data:"); mData.dump(); } else { mData.reset(); } if (handleRequest()) { if (!dataIn && mData.hasData()) { mData.setOperationCode(operation); mData.setTransactionID(transaction); LOGV("sending data:"); mData.dump(); ret = mData.write(fd); if (ret < 0) { LOGE("request write returned %d, errno: %d", ret, errno); if (errno == ECANCELED) { // return to top of loop and wait for next command continue; } break; } } mResponse.setTransactionID(transaction); LOGV("sending response %04X", mResponse.getResponseCode()); ret = mResponse.write(fd); mResponse.dump(); if (ret < 0) { LOGE("request write returned %d, errno: %d", ret, errno); if (errno == ECANCELED) { // return to top of loop and wait for next command continue; } break; } } else { LOGV("skipping response\n"); } } // commit any open edits int count = mObjectEditList.size(); for (int i = 0; i < count; i++) { ObjectEdit* edit = mObjectEditList[i]; commitEdit(edit); delete edit; } mObjectEditList.clear(); if (mSessionOpen) mDatabase->sessionEnded(); close(fd); mFD = -1; }
void SpinnerDefaultEditor::handleEditorTextFieldFocusLost(FocusEventDetails* const e) { commitEdit(); }
void MtpServer::run(int fd) { if (fd < 0) return; mFD = fd; MTPI("MtpServer::run fd: %d\n", fd); while (1) { MTPD("About to read device...\n"); int ret = mRequest.read(fd); if (ret < 0) { if (errno == ECANCELED) { // return to top of loop and wait for next command MTPD("request read returned %d ECANCELED, starting over\n", ret); continue; } MTPE("request read returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); break; } MtpOperationCode operation = mRequest.getOperationCode(); MtpTransactionID transaction = mRequest.getTransactionID(); MTPD("operation: %s", MtpDebug::getOperationCodeName(operation)); mRequest.dump(); // FIXME need to generalize this bool dataIn = (operation == MTP_OPERATION_SEND_OBJECT_INFO || operation == MTP_OPERATION_SET_OBJECT_REFERENCES || operation == MTP_OPERATION_SET_OBJECT_PROP_VALUE || operation == MTP_OPERATION_SET_DEVICE_PROP_VALUE); if (dataIn) { int ret = mData.read(fd); if (ret < 0) { if (errno == ECANCELED) { // return to top of loop and wait for next command MTPD("data read returned %d ECANCELED, starting over\n", ret); continue; } MTPD("data read returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); break; } MTPD("received data:"); mData.dump(); } else { mData.reset(); } if (handleRequest()) { if (!dataIn && mData.hasData()) { mData.setOperationCode(operation); mData.setTransactionID(transaction); MTPD("sending data:"); mData.dump(); ret = mData.write(fd); if (ret < 0) { if (errno == ECANCELED) { // return to top of loop and wait for next command MTPD("data write returned %d ECANCELED, starting over\n", ret); continue; } MTPE("data write returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); break; } } mResponse.setTransactionID(transaction); MTPD("sending response %04X\n", mResponse.getResponseCode()); ret = mResponse.write(fd); MTPD("ret: %d\n", ret); mResponse.dump(); if (ret < 0) { if (errno == ECANCELED) { // return to top of loop and wait for next command MTPD("response write returned %d ECANCELED, starting over\n", ret); continue; } MTPE("response write returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); break; } } else { MTPD("skipping response\n"); } } // commit any open edits int count = mObjectEditList.size(); for (int i = 0; i < count; i++) { ObjectEdit* edit = mObjectEditList[i]; commitEdit(edit); delete edit; } mObjectEditList.clear(); if (mSessionOpen) mDatabase->sessionEnded(); // This doesn't actually do anything but was carry over from AOSP close(fd); mFD = -1; }
void SpinnerDefaultEditor::handleEditorTextFieldActionPerformed(ActionEventDetails* const e) { commitEdit(); }