j_message.cc

Go to the documentation of this file.
00001 ///
00002 /// \file       j_message.cc
00003 ///             JDWP USB message implementation
00004 ///
00005 
00006 /*
00007     Copyright (C) 2009, Nicolas VIVIEN
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018     See the GNU General Public License in the COPYING file at the
00019     root directory of this project for more details.
00020 */
00021 
00022 #include "j_message.h"
00023 #include "debug.h"
00024 #include "data.h"
00025 
00026 
00027 namespace Barry { namespace JDWP {
00028 
00029 
00030 JDWMessage::JDWMessage(int socket)
00031         : m_socket(socket)
00032 {
00033 }
00034 
00035 
00036 JDWMessage::~JDWMessage()
00037 {
00038 }
00039 
00040 
00041 void JDWMessage::RawSend(Data &send, int timeout)
00042 {
00043         bool ret = m_jdwp.Write(m_socket, send, timeout);
00044 
00045         if (ret)
00046                 barryverbose("JDWMessage::RawSend: Socket ID " << m_socket
00047                                 << "\nSent:\n" << send);
00048 }
00049 
00050 
00051 bool JDWMessage::RawReceive(Data &receive, int timeout)
00052 {
00053         bool ret;
00054 
00055         ret = m_jdwp.Read(m_socket, receive, timeout);
00056 
00057         if (ret)
00058                 barryverbose("JDWMessage::RawReceive: Socket ID " << m_socket
00059                                 << "\nReceived:\n" << receive);
00060 
00061         return ret;
00062 }
00063 
00064 
00065 void JDWMessage::Send(Data &send, int timeout)
00066 {
00067         RawSend(send, timeout);
00068 }
00069 
00070 
00071 void JDWMessage::Send(Data &send, Data &receive, int timeout)
00072 {
00073         RawSend(send, timeout);
00074         RawReceive(receive, timeout);
00075 }
00076 
00077 
00078 bool JDWMessage::Receive(Data &receive, int timeout)
00079 {
00080         return RawReceive(receive, timeout);
00081 }
00082 
00083 }} // namespace Barry::JDWP
00084