1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
<html>
<head>
<title>Camstream: CamStream API documentation</title>
<link rel="stylesheet" href="../../tech.css" type="text/css">
</head>
<body>
<!-- Generated by Doxygen 1.3.7 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div>
<h1>FTPClient.h</h1><a href="_f_t_p_client_8h.html">Go to the documentation of this file.</a><pre class="fragment"><div>00001 <span class="preprocessor">#ifndef FTPCLIENT_HPP</span>
00002 <span class="preprocessor"></span><span class="preprocessor">#define FTPCLIENT_HPP</span>
00003 <span class="preprocessor"></span>
00004 <span class="preprocessor">#if HAVE_CONFIG_H</span>
00005 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="config_8h.html">config.h</a>"</span>
00006 <span class="preprocessor">#endif</span>
00007 <span class="preprocessor"></span>
00008 <span class="preprocessor">#include <qdns.h></span>
00009 <span class="preprocessor">#include <qfile.h></span>
00010 <span class="preprocessor">#include <qhostaddress.h></span>
00011 <span class="preprocessor">#include <qsocket.h></span>
00012 <span class="preprocessor">#include <qsocketnotifier.h></span>
00013 <span class="preprocessor">#include <qstring.h></span>
00014
00015 <span class="preprocessor">#include "<a class="code" href="_f_t_p_listen_8h.html">FTPListen.h</a>"</span>
00016
<a name="l00017"></a><a class="code" href="class_c_f_t_p_client.html">00017</a> <span class="keyword">class </span><a class="code" href="class_c_f_t_p_client.html">CFTPClient</a>: <span class="keyword">public</span> QObject
00018 {
00019 Q_OBJECT
00020 <span class="keyword">public</span>:
<a name="l00021"></a><a class="code" href="class_c_f_t_p_client.html#w28">00021</a> <span class="keyword">enum</span> <a class="code" href="class_c_f_t_p_client.html#w28">Commands</a> {
00022 <a class="code" href="class_c_f_t_p_client.html#w28w0">cmdNop</a>,
00023 <a class="code" href="class_c_f_t_p_client.html#w28w1">cmdLogin</a>,
00024 <a class="code" href="class_c_f_t_p_client.html#w28w2">cmdLogout</a>,
00025 <a class="code" href="class_c_f_t_p_client.html#w28w3">cmdSetType</a>,
00026 <a class="code" href="class_c_f_t_p_client.html#w28w4">cmdChangeDir</a>,
00027 <a class="code" href="class_c_f_t_p_client.html#w28w5">cmdListDir</a>,
00028 <a class="code" href="class_c_f_t_p_client.html#w28w6">cmdUpload</a>,
00029 <a class="code" href="class_c_f_t_p_client.html#w28w7">cmdDownload</a>,
00030 <a class="code" href="class_c_f_t_p_client.html#w28w8">cmdRename</a>,
00031 <span class="comment">// end of real commands</span>
00032
00033 <a class="code" href="class_c_f_t_p_client.html#w28w9">cmdPassive</a>,
00034 <a class="code" href="class_c_f_t_p_client.html#w28w10">cmdDeleteLocalFile</a>,
00035 <a class="code" href="class_c_f_t_p_client.html#w28w11">cmdDestroy</a>,
00036 };
00037
<a name="l00038"></a><a class="code" href="class_c_f_t_p_client.html#w29">00038</a> <span class="keyword">enum</span> <a class="code" href="class_c_f_t_p_client.html#w29">States</a> {
00039 <a class="code" href="class_c_f_t_p_client.html#w29w12">stNOC</a>,
00040 <a class="code" href="class_c_f_t_p_client.html#w29w13">stDNSBusy</a>,
00041 <a class="code" href="class_c_f_t_p_client.html#w29w14">stConnecting</a>,
00042 <a class="code" href="class_c_f_t_p_client.html#w29w15">stConnected</a>,
00043 <a class="code" href="class_c_f_t_p_client.html#w29w16">stLogin</a>,
00044 <a class="code" href="class_c_f_t_p_client.html#w29w17">stAuthenticate</a>,
00045
00046 <a class="code" href="class_c_f_t_p_client.html#w29w18">stIdle</a>,
00047
00048 <a class="code" href="class_c_f_t_p_client.html#w29w19">stSendingPort</a>,
00049 <a class="code" href="class_c_f_t_p_client.html#w29w20">stWaitData</a>,
00050 <a class="code" href="class_c_f_t_p_client.html#w29w21">stTransfer</a>,
00051 <a class="code" href="class_c_f_t_p_client.html#w29w22">stClosingData</a>,
00052
00053 <a class="code" href="class_c_f_t_p_client.html#w29w23">stFailed</a>,
00054 <a class="code" href="class_c_f_t_p_client.html#w29w24">stUnknown</a>,
00055 };
00056
<a name="l00057"></a><a class="code" href="class_c_f_t_p_client.html#w30">00057</a> <span class="keyword">enum</span> <a class="code" href="class_c_f_t_p_client.html#w30">TransferMethods</a> {
00058 <a class="code" href="class_c_f_t_p_client.html#w30w25">tmUnknown</a>,
00059 <a class="code" href="class_c_f_t_p_client.html#w30w26">tmAscii</a>,
00060 <a class="code" href="class_c_f_t_p_client.html#w30w27">tmBinary</a>,
00061 };
00062
00063 <span class="keyword">private</span>:
00064 QString m_UserName, m_Password;
00065 QString m_ServerName;
00066 <span class="keywordtype">int</span> m_ServerPort;
00067
00068 QSocket *m_pCtrlFD;
00069 <span class="keywordtype">int</span> m_DataFD;
00070 QSocketNotifier *m_pDataConnectNotifier;
00071 QSocketNotifier *m_pDataNotifier;
00072 <a class="code" href="class_c_f_t_p_listen.html">CFTPListen</a> *m_pListenFD;
00073 QFile m_LocalFile;
00074 QHostAddress m_MyAddress;
00075
00076 <span class="keywordtype">char</span> *inputbuffer, *linebuffer;
00077 QString m_ResponseBuffer; <span class="comment">// complete response, including multiline</span>
00078 <span class="keywordtype">char</span> LastChar;
00079 <span class="keywordtype">int</span> LineLen; <span class="comment">// Characters in linebuffer</span>
00080 <span class="keywordtype">int</span> Response; <span class="comment">// FTP response code</span>
00081 QString RemoteFileName;
00082
00083 <span class="keywordtype">bool</span> m_Passive; <span class="comment">// Are we in passive mode?</span>
00084 QHostAddress m_PassiveAddress;
00085 Q_UINT16 m_PassivePort;
00086
00087 QString outputbuffer;
00088
00089 <span class="keywordtype">char</span> *m_TransferBuffer;
00090 <span class="keywordtype">int</span> m_TransferBufferSize, m_TransferBufferHead, m_TransferBufferUsed;
00091 <span class="keywordtype">int</span> TotalTransfered;
00092
00093 TransferMethods m_TransferMethod; <span class="comment">// ASCII vs. BINARY</span>
00094 States CurrentState;
00095 Commands CurrentCommand;
00096
00097 <span class="keywordtype">bool</span> m_Log;
00098
00099 <span class="keywordtype">void</span> InitBuffers();
00100 <span class="keywordtype">void</span> CloseAllFD();
00101 <span class="keywordtype">void</span> SetupControl();
00102 <span class="keywordtype">void</span> CloseControl();
00103 <span class="keywordtype">bool</span> SetupListen();
00104 <span class="keywordtype">void</span> CloseListen();
00105 <span class="keywordtype">bool</span> SetupLocal(<span class="keyword">const</span> QString &filename, <span class="keywordtype">bool</span> write, <span class="keywordtype">bool</span> truncate = <span class="keyword">true</span>);
00106 <span class="keywordtype">void</span> CloseLocal();
00107 <span class="keywordtype">bool</span> SetupDataActive();
00108 <span class="keywordtype">bool</span> SetupDataPassive();
00109 <span class="keywordtype">void</span> CloseData();
00110 <span class="keywordtype">void</span> HookData();
00111
00112 <span class="keywordtype">void</span> SetState(States new_st, <span class="keywordtype">int</span> response = 0);
00113
00114 <span class="keywordtype">void</span> InterpretLine();
00115 <span class="keywordtype">void</span> InterpretResponse();
00116
00117 <span class="keywordtype">void</span> Send();
00118 <span class="keywordtype">void</span> SendUser();
00119 <span class="keywordtype">void</span> SendPass();
00120 <span class="keywordtype">void</span> SendList();
00121 <span class="keywordtype">void</span> SendPort(<span class="keyword">const</span> QHostAddress &, Q_UINT16 port);
00122 <span class="keywordtype">void</span> SendStore(<span class="keyword">const</span> QString &filename);
00123
00124 <span class="keywordtype">void</span> StartSending();
00125 <span class="keywordtype">void</span> StartReceiving();
00126
00127 <span class="keyword">private</span> slots:
00128 <span class="keywordtype">void</span> ControlRead();
00129 <span class="keywordtype">void</span> ControlError(<span class="keywordtype">int</span>);
00130 <span class="keywordtype">void</span> ControlResolved();
00131 <span class="keywordtype">void</span> ControlConnected();
00132 <span class="keywordtype">void</span> ControlClosed();
00133
00134 <span class="keywordtype">void</span> ListenConnect();
00135
00136 <span class="keywordtype">void</span> DataConnect(<span class="keywordtype">int</span> socket);
00137 <span class="keywordtype">void</span> DataRead();
00138 <span class="keywordtype">void</span> DataWrite();
00139 <span class="keywordtype">void</span> DataClose();
00140
00141 <span class="keyword">public</span>:
00142 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *CommandStr[];
00143 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *StateStr[];
00144
00145 <a class="code" href="class_c_f_t_p_client.html">CFTPClient</a>(QObject *parent = 0, <span class="keyword">const</span> <span class="keywordtype">char</span> *name = 0);
00146 <a class="code" href="class_c_f_t_p_client.html#a1">~CFTPClient</a>();
00147
00148 <span class="keywordtype">void</span> SetLogging(<span class="keywordtype">bool</span> log);
00149
00150 <span class="keywordtype">int</span> <a class="code" href="class_c_f_t_p_client.html#a3">GetCommand</a>() const;
00151 <span class="keywordtype">int</span> GetState() const;
00152 <span class="keywordtype">void</span> SetPassive();
00153 <span class="keywordtype">void</span> SetActive();
00154
00155 <span class="keywordtype">void</span> Connect(const QString &user, const QString &pass, const QString &server, <span class="keywordtype">int</span> port = 21);
00156
00157 <span class="keywordtype">void</span> Upload(const QString &local_file, const QString &remote_file = QString::null);
00158 <span class="keywordtype">void</span> SetTypeAscii();
00159 <span class="keywordtype">void</span> SetTypeBinary();
00160 <span class="keywordtype">void</span> ChangeDir(const QString &new_dir);
00161 <span class="keywordtype">void</span> ListDir();
00162 <span class="keywordtype">void</span> Rename(const QString &from, const QString &to);
00163
00164 <span class="keywordtype">void</span> Logout();
00165
00166 QString GetErrorString(<span class="keywordtype">int</span> result) const;
00167
00168 signals:
00180 <span class="keywordtype">void</span> StateChange(<span class="keywordtype">int</span> command, <span class="keywordtype">int</span> new_state, <span class="keywordtype">int</span> result, const QString &server_msg);
00181
00183 <span class="keywordtype">void</span> LoggedIn();
00185 <span class="keywordtype">void</span> LoginFailed();
00187 <span class="keywordtype">void</span> ControlPortClosed();
00188 <span class="keywordtype">void</span> TimeOut();
00189
00190 <span class="keywordtype">void</span> ListDirEntry(const QString &filename);
00191
00193 <span class="keywordtype">void</span> Progress(<span class="keywordtype">int</span> offset);
00194 };
00195
00196 #endif
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Wed Dec 13 23:38:46 2006 for CamStream by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address>
</body>
</html>
|