blob: 4ea85a8cf107e36698da69cc11e5ff40f3b48872 [file] [log] [blame]
Dennis Syrovatsky613f7c82005-12-18 14:24:06 +00001/* Copyright (C) 2005 TightVNC Team. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 *
18 * TightVNC distribution homepage on the Web: http://www.tightvnc.com/
19 *
20 */
21
22// -=- SFTMsgWriter.cxx
23
24#include <rfb/SFTMsgWriter.h>
25
26using namespace rfb;
27
28SFTMsgWriter::SFTMsgWriter(rdr::OutStream *pOS)
29{
30 m_pOS = pOS;
31}
32
33SFTMsgWriter::~SFTMsgWriter()
34{
35}
36
37bool
38SFTMsgWriter::writeFileListData(unsigned char flags, rfb::FileInfo *pFileInfo)
39{
40 return false;
41}
42
43bool
44SFTMsgWriter::writeFileDownloadData(unsigned int dataSize, void *pData)
45{
Dennis Syrovatskyed521352005-12-18 14:49:59 +000046 m_pOS->writeU8(msgTypeFileDownloadData);
47 m_pOS->writeU8(0);
48 m_pOS->writeU16(dataSize);
49 m_pOS->writeU16(dataSize);
50 m_pOS->writeBytes(pData, dataSize);
51 m_pOS->flush();
52 return true;
Dennis Syrovatsky613f7c82005-12-18 14:24:06 +000053}
54
55bool
56SFTMsgWriter::writeFileDownloadData(unsigned int modTime)
57{
Dennis Syrovatskyed521352005-12-18 14:49:59 +000058 m_pOS->writeU8(msgTypeFileDownloadData);
59 m_pOS->writeU8(0);
60 m_pOS->writeU16(0);
61 m_pOS->writeU16(0);
62 m_pOS->writeU32(modTime);
63 m_pOS->flush();
64 return true;
Dennis Syrovatsky613f7c82005-12-18 14:24:06 +000065}
66
67bool
68SFTMsgWriter::writeFileUploadCancel(unsigned int reasonLen, char *pReason)
69{
Dennis Syrovatskyed521352005-12-18 14:49:59 +000070 m_pOS->writeU8(msgTypeFileUploadCancel);
71 return writeU8U16StringMsg(0, reasonLen, pReason);
Dennis Syrovatsky613f7c82005-12-18 14:24:06 +000072}
73
74bool
75SFTMsgWriter::writeFileDownloadFailed(unsigned int reasonLen, char *pReason)
76{
Dennis Syrovatskyed521352005-12-18 14:49:59 +000077 m_pOS->writeU8(msgTypeFileDownloadFailed);
78 return writeU8U16StringMsg(0, reasonLen, pReason);
Dennis Syrovatsky613f7c82005-12-18 14:24:06 +000079}
80
81bool
82SFTMsgWriter::writeFileDirSizeData(unsigned int dirSizeLow,
83 unsigned short dirSizeHigh)
84{
Dennis Syrovatskyed521352005-12-18 14:49:59 +000085 m_pOS->writeU8(msgTypeFileDirSizeData);
86 m_pOS->writeU8(0);
87 m_pOS->writeU16(dirSizeHigh);
88 m_pOS->writeU32(dirSizeLow);
89 m_pOS->flush();
90 return true;
Dennis Syrovatsky613f7c82005-12-18 14:24:06 +000091}
92
93bool
94SFTMsgWriter::writeFileLastRqstFailed(unsigned char lastRequest,
95 unsigned short reasonLen,
96 char *pReason)
97{
Dennis Syrovatskyed521352005-12-18 14:49:59 +000098 m_pOS->writeU8(msgTypeFileLastRequestFailed);
99 return writeU8U16StringMsg(lastRequest, reasonLen, pReason);
Dennis Syrovatsky613f7c82005-12-18 14:24:06 +0000100}
101
102bool
103SFTMsgWriter::writeU8U16StringMsg(unsigned char p1, unsigned short p2, char *pP3)
104{
Dennis Syrovatskyed521352005-12-18 14:49:59 +0000105 m_pOS->writeU8(p1);
106 m_pOS->writeU16(p2);
107 m_pOS->writeBytes(pP3, p2);
108 m_pOS->flush();
109 return true;
Dennis Syrovatsky613f7c82005-12-18 14:24:06 +0000110}