![]() |
|
|
00001 /*************************************************************************** 00002 * inspectorJ - java profiler * 00003 * Copyright (C) 2007 by James May 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00027 #include "inspectorj/jdwp/jdwpreply.h" 00028 #include <iostream> 00029 00030 using namespace inspectorj::jdwp; 00031 00038 JDWPReply::JDWPReply(jdwpReplyPacket &replyPacket) 00039 : JDWPPacket() 00040 { 00041 reply.len = replyPacket.len; 00042 reply.id = replyPacket.id; 00043 reply.flags = replyPacket.flags; 00044 reply.errorCode = replyPacket.errorCode; 00045 int dataSize = reply.len - JDWP_HEADER_LENGTH; 00046 if (dataSize > 0) { 00047 reply.data = new jbyte[dataSize]; 00048 memcpy(reply.data, replyPacket.data, dataSize); 00049 } else { 00050 reply.data = NULL; 00051 } 00052 00053 00054 if (reply.len > JDWP_HEADER_LENGTH) { 00055 bytes = QByteArray((char*)reply.data, reply.len - JDWP_HEADER_LENGTH); 00056 data = new QDataStream(&bytes, QIODevice::ReadWrite); 00057 } else { 00058 // no data exists so we only need write mode 00059 data = new QDataStream(&bytes, QIODevice::WriteOnly); 00060 } 00061 } 00062 00069 JDWPReply* JDWPReply::copy() 00070 { 00071 return new JDWPReply(reply); 00072 } 00073 00077 JDWPReply::~JDWPReply() 00078 { 00079 if (reply.data) { 00080 delete[] reply.data; 00081 reply.data = 0; 00082 } 00083 } 00084 00089 jbyte JDWPReply::getPacketType() 00090 { 00091 return (jbyte) JDWPTRANSPORT_FLAGS_REPLY; 00092 } 00093 00097 jint JDWPReply::getId() 00098 { 00099 return reply.id; 00100 } 00101 00105 short JDWPReply::getErrorCode() 00106 { 00107 return (short)reply.errorCode; 00108 } 00109 00110 void JDWPReply::setErrorCode(short err) 00111 { 00112 reply.errorCode = err; 00113 } 00114