![]() |
|
|
00001 /*************************************************************************** 00002 * inspectorJ - java profiler * 00003 * Copyright (C) 2006 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 #ifndef CLIENT_PACKET_HANDLER_H 00028 #define CLIENT_PACKET_HANDLER_H 00029 00030 #include <QAbstractSocket> 00031 #include <QList> 00032 #include <QMessageBox> 00033 #include <QMultiMap> 00034 #include <QTcpSocket> 00035 #include <QtNetwork> 00036 #include "jdwpTransport.h" 00037 #include "inspectorj/client/jdwpaction.h" 00038 #include "inspectorj/jdwp/jdwpconstants.h" 00039 #include "inspectorj/jdwp/jdwpcommand.h" 00040 #include "inspectorj/jdwp/jdwpreply.h" 00041 00042 00043 using namespace inspectorj::client; 00044 using namespace inspectorj::jdwp; 00045 00046 namespace inspectorj { 00047 namespace client { 00048 00063 class ClientPacketHandler : public QObject 00064 { 00065 Q_OBJECT 00066 00067 public: 00068 ClientPacketHandler(QTcpSocket&); 00069 void readJDWPPacket(); 00070 void sendJDWPCommand(JDWPCommand*, QList<JDWPAction*>&); 00071 void getHandshake(bool &attached, QString &msg); 00072 static void getJDWPError(int errCode, QString &s); 00073 static bool handleJDWPError(JDWPPacket &packet); 00074 void getSocketError(QAbstractSocket::SocketError error, QString &errMsg); 00075 private: 00076 00078 JDWPAction *initIdSizesAction; 00079 00081 QMultiMap<int, JDWPAction* > replyCallbackMap; 00082 00084 QTcpSocket &tcpSocket; 00085 00087 quint32 packetSize; 00088 00089 void operator>>(QString &s); 00090 void handleResponse(JDWPPacket&); 00091 00092 private slots: 00093 void initIdSizes(JDWPPacket&); 00094 }; 00095 00096 } // end namespace client 00097 } // end namespace inspectorj 00098 00099 #endif // CLIENT_PACKET_HANDLER_H