<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US"> <head> <title>kio/kio: slavebase.cpp Source File (kio/kio)</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org" r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org" r (n 0 s 0 v 0 l 0))' /> <meta name="trademark" content="KDE e.V." /> <meta name="description" content="K Desktop Environment Homepage, KDE.org" /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta name="robots" content="all" /> <link rel="shortcut icon" href="../../../favicon.ico" /> <link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" /> </head> <body> <div id="nav_header_top" align="right"> <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a> <a href="../../.."><img id="nav_header_logo" alt="Home" align="left" src="../../../kde_gear_64.png" border="0" /></a> <span class="doNotDisplay">::</span> <div id="nav_header_title" align="left">KDE API Reference</div> </div> <div id="nav_header_bottom" align="right"> <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span> <div id="nav_header_bottom_right" style="text-align: left;"> / <a href="../../..">API Reference</a> / <a href="../../html/index.html">kio</a> / <a href=".">kio</a> </div> </div> <table id="main" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top" class="menuheader" height="0"></td> <td id="contentcolumn" valign="top" rowspan="2" > <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;"> <a name="content"></a> <!-- Generated by Doxygen 1.7.4 --> <div class="header"> <div class="headertitle"> <div class="title">slavebase.cpp</div> </div> </div> <div class="contents"> <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> *</span> <a name="l00003"></a>00003 <span class="comment"> * This file is part of the KDE libraries</span> <a name="l00004"></a>00004 <span class="comment"> * Copyright (c) 2000 Waldo Bastian <bastian@kde.org></span> <a name="l00005"></a>00005 <span class="comment"> * Copyright (c) 2000 David Faure <faure@kde.org></span> <a name="l00006"></a>00006 <span class="comment"> * Copyright (c) 2000 Stephan Kulow <coolo@kde.org></span> <a name="l00007"></a>00007 <span class="comment"> *</span> <a name="l00008"></a>00008 <span class="comment"> * $Id: slavebase.cpp 714066 2007-09-18 17:05:12Z lunakl $</span> <a name="l00009"></a>00009 <span class="comment"> *</span> <a name="l00010"></a>00010 <span class="comment"> * This library is free software; you can redistribute it and/or</span> <a name="l00011"></a>00011 <span class="comment"> * modify it under the terms of the GNU Library General Public</span> <a name="l00012"></a>00012 <span class="comment"> * License version 2 as published by the Free Software Foundation.</span> <a name="l00013"></a>00013 <span class="comment"> *</span> <a name="l00014"></a>00014 <span class="comment"> * This library is distributed in the hope that it will be useful,</span> <a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00017"></a>00017 <span class="comment"> * Library General Public License for more details.</span> <a name="l00018"></a>00018 <span class="comment"> *</span> <a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU Library General Public License</span> <a name="l00020"></a>00020 <span class="comment"> * along with this library; see the file COPYING.LIB. If not, write to</span> <a name="l00021"></a>00021 <span class="comment"> * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,</span> <a name="l00022"></a>00022 <span class="comment"> * Boston, MA 02110-1301, USA.</span> <a name="l00023"></a>00023 <span class="comment"> *</span> <a name="l00024"></a>00024 <span class="comment"> **/</span> <a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="preprocessor">#include "slavebase.h"</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="preprocessor">#include <config.h></span> <a name="l00029"></a>00029 <a name="l00030"></a>00030 <span class="preprocessor">#include <sys/time.h></span> <a name="l00031"></a>00031 <span class="preprocessor">#ifdef HAVE_SYS_SELECT_H</span> <a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#include <sys/select.h></span> <span class="comment">// Needed on some systems.</span> <a name="l00033"></a>00033 <span class="preprocessor">#endif</span> <a name="l00034"></a>00034 <span class="preprocessor"></span> <a name="l00035"></a>00035 <span class="preprocessor">#include <assert.h></span> <a name="l00036"></a>00036 <span class="preprocessor">#include <kdebug.h></span> <a name="l00037"></a>00037 <span class="preprocessor">#include <stdlib.h></span> <a name="l00038"></a>00038 <span class="preprocessor">#include <errno.h></span> <a name="l00039"></a>00039 <span class="preprocessor">#include <unistd.h></span> <a name="l00040"></a>00040 <span class="preprocessor">#include <signal.h></span> <a name="l00041"></a>00041 <span class="preprocessor">#include <time.h></span> <a name="l00042"></a>00042 <a name="l00043"></a>00043 <span class="preprocessor">#include <qfile.h></span> <a name="l00044"></a>00044 <a name="l00045"></a>00045 <span class="preprocessor">#include <dcopclient.h></span> <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="preprocessor">#include <kapplication.h></span> <a name="l00048"></a>00048 <span class="preprocessor">#include <ksock.h></span> <a name="l00049"></a>00049 <span class="preprocessor">#include <kcrash.h></span> <a name="l00050"></a>00050 <span class="preprocessor">#include <kdesu/client.h></span> <a name="l00051"></a>00051 <span class="preprocessor">#include <klocale.h></span> <a name="l00052"></a>00052 <span class="preprocessor">#include <ksocks.h></span> <a name="l00053"></a>00053 <a name="l00054"></a>00054 <span class="preprocessor">#include "kremoteencoding.h"</span> <a name="l00055"></a>00055 <a name="l00056"></a>00056 <span class="preprocessor">#include "kio/slavebase.h"</span> <a name="l00057"></a>00057 <span class="preprocessor">#include "kio/connection.h"</span> <a name="l00058"></a>00058 <span class="preprocessor">#include "kio/ioslave_defaults.h"</span> <a name="l00059"></a>00059 <span class="preprocessor">#include "kio/slaveinterface.h"</span> <a name="l00060"></a>00060 <a name="l00061"></a>00061 <span class="preprocessor">#include "uiserver_stub.h"</span> <a name="l00062"></a>00062 <a name="l00063"></a>00063 <span class="preprocessor">#ifndef NDEBUG</span> <a name="l00064"></a>00064 <span class="preprocessor"></span><span class="preprocessor">#ifdef HAVE_BACKTRACE</span> <a name="l00065"></a>00065 <span class="preprocessor"></span><span class="preprocessor">#include <execinfo.h></span> <a name="l00066"></a>00066 <span class="preprocessor">#endif</span> <a name="l00067"></a>00067 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00068"></a>00068 <span class="preprocessor"></span> <a name="l00069"></a>00069 <span class="keyword">using namespace </span>KIO; <a name="l00070"></a>00070 <a name="l00071"></a>00071 <span class="keyword">template</span> <span class="keyword">class </span><a class="codeRef" href="qptrlist.html">QPtrList<QValueList<UDSAtom></a> >; <a name="l00072"></a>00072 <span class="keyword">typedef</span> <a class="codeRef" href="qvaluelist.html">QValueList<QCString></a> <a class="codeRef" href="qvaluelist.html">AuthKeysList</a>; <a name="l00073"></a>00073 <span class="keyword">typedef</span> <a class="codeRef" href="qmap.html">QMap<QString,QCString></a> <a class="codeRef" href="qmap.html">AuthKeysMap</a>; <a name="l00074"></a>00074 <span class="preprocessor">#define KIO_DATA QByteArray data; QDataStream stream( data, IO_WriteOnly ); stream</span> <a name="l00075"></a>00075 <span class="preprocessor"></span><span class="preprocessor">#define KIO_FILESIZE_T(x) (unsigned long)(x & 0xffffffff) << (unsigned long)(x >> 32)</span> <a name="l00076"></a>00076 <span class="preprocessor"></span> <a name="l00077"></a>00077 <span class="keyword">namespace </span>KIO { <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="keyword">class </span>SlaveBaseConfig : <span class="keyword">public</span> KConfigBase <a name="l00080"></a>00080 { <a name="l00081"></a>00081 <span class="keyword">public</span>: <a name="l00082"></a>00082 SlaveBaseConfig(<a class="code" href="classKIO_1_1SlaveBase.html" title="There are two classes that specifies the protocol between application (job) and kioslave.">SlaveBase</a> *_slave) <a name="l00083"></a>00083 : slave(_slave) { } <a name="l00084"></a>00084 <a name="l00085"></a>00085 <span class="keywordtype">bool</span> internalHasGroup(<span class="keyword">const</span> <a class="codeRef" href="qcstring.html">QCString</a> &)<span class="keyword"> const </span>{ qWarning(<span class="stringliteral">"hasGroup(const QCString &)"</span>); <a name="l00086"></a>00086 <span class="keywordflow">return</span> <span class="keyword">false</span>; } <a name="l00087"></a>00087 <a name="l00088"></a>00088 <a class="codeRef" href="qstringlist.html">QStringList</a> groupList()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="codeRef" href="qstringlist.html">QStringList</a>(); } <a name="l00089"></a>00089 <a name="l00090"></a>00090 <a class="codeRef" href="qmap.html">QMap<QString,QString></a> entryMap(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &group)<span class="keyword"> const</span> <a name="l00091"></a>00091 <span class="keyword"> </span>{ Q_UNUSED(group); <span class="keywordflow">return</span> <a class="codeRef" href="qmap.html">QMap<QString,QString></a>(); } <a name="l00092"></a>00092 <a name="l00093"></a>00093 <span class="keywordtype">void</span> reparseConfiguration() { } <a name="l00094"></a>00094 <a name="l00095"></a>00095 KEntryMap internalEntryMap( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &pGroup)<span class="keyword"> const </span>{ Q_UNUSED(pGroup); <span class="keywordflow">return</span> KEntryMap(); } <a name="l00096"></a>00096 <a name="l00097"></a>00097 KEntryMap internalEntryMap()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> KEntryMap(); } <a name="l00098"></a>00098 <a name="l00099"></a>00099 <span class="keywordtype">void</span> putData(<span class="keyword">const</span> KEntryKey &_key, <span class="keyword">const</span> KEntry&_data, <span class="keywordtype">bool</span> _checkGroup) <a name="l00100"></a>00100 { Q_UNUSED(_key); Q_UNUSED(_data); Q_UNUSED(_checkGroup); } <a name="l00101"></a>00101 <a name="l00102"></a>00102 KEntry lookupData(<span class="keyword">const</span> KEntryKey &_key)<span class="keyword"> const</span> <a name="l00103"></a>00103 <span class="keyword"> </span>{ <a name="l00104"></a>00104 KEntry entry; <a name="l00105"></a>00105 <a class="codeRef" href="qstring.html">QString</a> value = slave->metaData(_key.c_key); <a name="l00106"></a>00106 <span class="keywordflow">if</span> (!value.<a class="codeRef" href="qstring.html#isNull">isNull</a>()) <a name="l00107"></a>00107 entry.mValue = value.<a class="codeRef" href="qstring.html#utf8">utf8</a>(); <a name="l00108"></a>00108 <span class="keywordflow">return</span> entry; <a name="l00109"></a>00109 } <a name="l00110"></a>00110 <span class="keyword">protected</span>: <a name="l00111"></a>00111 <a class="code" href="classKIO_1_1SlaveBase.html" title="There are two classes that specifies the protocol between application (job) and kioslave.">SlaveBase</a> *slave; <a name="l00112"></a>00112 }; <a name="l00113"></a>00113 <a name="l00114"></a>00114 <a name="l00115"></a>00115 <span class="keyword">class </span>SlaveBasePrivate { <a name="l00116"></a>00116 <span class="keyword">public</span>: <a name="l00117"></a>00117 <a class="codeRef" href="qstring.html">QString</a> slaveid; <a name="l00118"></a>00118 <span class="keywordtype">bool</span> resume:1; <a name="l00119"></a>00119 <span class="keywordtype">bool</span> needSendCanResume:1; <a name="l00120"></a>00120 <span class="keywordtype">bool</span> onHold:1; <a name="l00121"></a>00121 <span class="keywordtype">bool</span> wasKilled:1; <a name="l00122"></a>00122 <a class="code" href="classKIO_1_1MetaData.html" title="MetaData is a simple map of key/value strings.">MetaData</a> configData; <a name="l00123"></a>00123 SlaveBaseConfig *config; <a name="l00124"></a>00124 KURL onHoldUrl; <a name="l00125"></a>00125 <a name="l00126"></a>00126 <span class="keyword">struct </span>timeval last_tv; <a name="l00127"></a>00127 <a class="code" href="namespaceKIO.html#a90b418366ba9052c97d4dca845026f43" title="64-bit file size">KIO::filesize_t</a> totalSize; <a name="l00128"></a>00128 <a class="code" href="namespaceKIO.html#a90b418366ba9052c97d4dca845026f43" title="64-bit file size">KIO::filesize_t</a> sentListEntries; <a name="l00129"></a>00129 DCOPClient *dcopClient; <a name="l00130"></a>00130 <a class="code" href="classKRemoteEncoding.html" title="Allows encoding and decoding properly remote filenames into Unicode.">KRemoteEncoding</a> *remotefile; <a name="l00131"></a>00131 time_t timeout; <a name="l00132"></a>00132 <a class="codeRef" href="qbytearray.html">QByteArray</a> timeoutData; <a name="l00133"></a>00133 }; <a name="l00134"></a>00134 <a name="l00135"></a>00135 } <a name="l00136"></a>00136 <a name="l00137"></a>00137 <span class="keyword">static</span> <a class="code" href="classKIO_1_1SlaveBase.html" title="There are two classes that specifies the protocol between application (job) and kioslave.">SlaveBase</a> *globalSlave; <a name="l00138"></a>00138 <span class="keywordtype">long</span> SlaveBase::s_seqNr; <a name="l00139"></a>00139 <a name="l00140"></a>00140 <span class="keyword">static</span> <span class="keyword">volatile</span> <span class="keywordtype">bool</span> slaveWriteError = <span class="keyword">false</span>; <a name="l00141"></a>00141 <a name="l00142"></a>00142 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *s_protocol; <a name="l00143"></a>00143 <a name="l00144"></a>00144 <span class="preprocessor">#ifdef Q_OS_UNIX</span> <a name="l00145"></a>00145 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">void</span> genericsig_handler(<span class="keywordtype">int</span> sigNumber) <a name="l00146"></a>00146 { <a name="l00147"></a>00147 signal(sigNumber,SIG_IGN); <a name="l00148"></a>00148 <span class="comment">//WABA: Don't do anything that requires malloc, we can deadlock on it since</span> <a name="l00149"></a>00149 <span class="comment">//a SIGTERM signal can come in while we are in malloc/free.</span> <a name="l00150"></a>00150 <span class="comment">//kdDebug()<<"kioslave : exiting due to signal "<<sigNumber<<endl;</span> <a name="l00151"></a>00151 <span class="comment">//set the flag which will be checked in dispatchLoop() and which *should* be checked</span> <a name="l00152"></a>00152 <span class="comment">//in lengthy operations in the various slaves</span> <a name="l00153"></a>00153 <span class="keywordflow">if</span> (globalSlave!=0) <a name="l00154"></a>00154 globalSlave-><a class="code" href="classKIO_1_1SlaveBase.html#adec67d7af5a083429029c47dc02fc488" title="Internally used.">setKillFlag</a>(); <a name="l00155"></a>00155 signal(SIGALRM,SIG_DFL); <a name="l00156"></a>00156 alarm(5); <span class="comment">//generate an alarm signal in 5 seconds, in this time the slave has to exit</span> <a name="l00157"></a>00157 } <a name="l00158"></a>00158 <span class="preprocessor">#endif</span> <a name="l00159"></a>00159 <span class="preprocessor"></span> <a name="l00161"></a>00161 <a name="l00162"></a>00162 SlaveBase::SlaveBase( <span class="keyword">const</span> <a class="codeRef" href="qcstring.html">QCString</a> &protocol, <a name="l00163"></a>00163 <span class="keyword">const</span> <a class="codeRef" href="qcstring.html">QCString</a> &pool_socket, <a name="l00164"></a>00164 <span class="keyword">const</span> <a class="codeRef" href="qcstring.html">QCString</a> &app_socket ) <a name="l00165"></a>00165 : mProtocol(protocol), m_pConnection(0), <a name="l00166"></a>00166 mPoolSocket( <a class="codeRef" href="qfile.html">QFile</a>::decodeName(pool_socket)), <a name="l00167"></a>00167 mAppSocket( <a class="codeRef" href="qfile.html">QFile</a>::decodeName(app_socket)) <a name="l00168"></a>00168 { <a name="l00169"></a>00169 s_protocol = protocol.data(); <a name="l00170"></a>00170 <span class="preprocessor">#ifdef Q_OS_UNIX</span> <a name="l00171"></a>00171 <span class="preprocessor"></span> <span class="keywordflow">if</span> (!getenv(<span class="stringliteral">"KDE_DEBUG"</span>)) <a name="l00172"></a>00172 { <a name="l00173"></a>00173 KCrash::setCrashHandler( sigsegv_handler ); <a name="l00174"></a>00174 signal(SIGILL,&sigsegv_handler); <a name="l00175"></a>00175 signal(SIGTRAP,&sigsegv_handler); <a name="l00176"></a>00176 signal(SIGABRT,&sigsegv_handler); <a name="l00177"></a>00177 signal(SIGBUS,&sigsegv_handler); <a name="l00178"></a>00178 signal(SIGALRM,&sigsegv_handler); <a name="l00179"></a>00179 signal(SIGFPE,&sigsegv_handler); <a name="l00180"></a>00180 <span class="preprocessor">#ifdef SIGPOLL</span> <a name="l00181"></a>00181 <span class="preprocessor"></span> signal(SIGPOLL, &sigsegv_handler); <a name="l00182"></a>00182 <span class="preprocessor">#endif</span> <a name="l00183"></a>00183 <span class="preprocessor"></span><span class="preprocessor">#ifdef SIGSYS</span> <a name="l00184"></a>00184 <span class="preprocessor"></span> signal(SIGSYS, &sigsegv_handler); <a name="l00185"></a>00185 <span class="preprocessor">#endif</span> <a name="l00186"></a>00186 <span class="preprocessor"></span><span class="preprocessor">#ifdef SIGVTALRM</span> <a name="l00187"></a>00187 <span class="preprocessor"></span> signal(SIGVTALRM, &sigsegv_handler); <a name="l00188"></a>00188 <span class="preprocessor">#endif</span> <a name="l00189"></a>00189 <span class="preprocessor"></span><span class="preprocessor">#ifdef SIGXCPU</span> <a name="l00190"></a>00190 <span class="preprocessor"></span> signal(SIGXCPU, &sigsegv_handler); <a name="l00191"></a>00191 <span class="preprocessor">#endif</span> <a name="l00192"></a>00192 <span class="preprocessor"></span><span class="preprocessor">#ifdef SIGXFSZ</span> <a name="l00193"></a>00193 <span class="preprocessor"></span> signal(SIGXFSZ, &sigsegv_handler); <a name="l00194"></a>00194 <span class="preprocessor">#endif</span> <a name="l00195"></a>00195 <span class="preprocessor"></span> } <a name="l00196"></a>00196 <a name="l00197"></a>00197 <span class="keyword">struct </span>sigaction act; <a name="l00198"></a>00198 act.sa_handler = sigpipe_handler; <a name="l00199"></a>00199 sigemptyset( &act.sa_mask ); <a name="l00200"></a>00200 act.sa_flags = 0; <a name="l00201"></a>00201 sigaction( SIGPIPE, &act, 0 ); <a name="l00202"></a>00202 <a name="l00203"></a>00203 signal(SIGINT,&genericsig_handler); <a name="l00204"></a>00204 signal(SIGQUIT,&genericsig_handler); <a name="l00205"></a>00205 signal(SIGTERM,&genericsig_handler); <a name="l00206"></a>00206 <span class="preprocessor">#endif</span> <a name="l00207"></a>00207 <span class="preprocessor"></span> <a name="l00208"></a>00208 globalSlave=<span class="keyword">this</span>; <a name="l00209"></a>00209 <a name="l00210"></a>00210 appconn = <span class="keyword">new</span> <a class="code" href="classKIO_1_1Connection.html" title="This class provides a simple means for IPC between two applications via a pipe.">Connection</a>(); <a name="l00211"></a>00211 listEntryCurrentSize = 100; <a name="l00212"></a>00212 <span class="keyword">struct </span>timeval tp; <a name="l00213"></a>00213 gettimeofday(&tp, 0); <a name="l00214"></a>00214 listEntry_sec = tp.tv_sec; <a name="l00215"></a>00215 listEntry_usec = tp.tv_usec; <a name="l00216"></a>00216 mConnectedToApp = <span class="keyword">true</span>; <a name="l00217"></a>00217 <a name="l00218"></a>00218 d = <span class="keyword">new</span> SlaveBasePrivate; <a name="l00219"></a>00219 <span class="comment">// by kahl for netmgr (need a way to identify slaves)</span> <a name="l00220"></a>00220 d->slaveid = <a class="code" href="classKIO_1_1Slave.html#a1e80a3ad140b01ed73e176082d9f5235" title="The protocol this slave handles.">protocol</a>; <a name="l00221"></a>00221 d->slaveid += <a class="code" href="namespaceKIO.html#a61e1ebe49305dcd7418b4692d56079b0" title="Converts a size to a string representation Not unlike QString::number(...)">QString::number</a>(getpid()); <a name="l00222"></a>00222 d->resume = <span class="keyword">false</span>; <a name="l00223"></a>00223 d->needSendCanResume = <span class="keyword">false</span>; <a name="l00224"></a>00224 d->config = <span class="keyword">new</span> SlaveBaseConfig(<span class="keyword">this</span>); <a name="l00225"></a>00225 d->onHold = <span class="keyword">false</span>; <a name="l00226"></a>00226 d->wasKilled=<span class="keyword">false</span>; <a name="l00227"></a>00227 d->last_tv.tv_sec = 0; <a name="l00228"></a>00228 d->last_tv.tv_usec = 0; <a name="l00229"></a>00229 <span class="comment">// d->processed_size = 0;</span> <a name="l00230"></a>00230 d->totalSize=0; <a name="l00231"></a>00231 d->sentListEntries=0; <a name="l00232"></a>00232 d->timeout = 0; <a name="l00233"></a>00233 connectSlave(mAppSocket); <a name="l00234"></a>00234 <a name="l00235"></a>00235 d->dcopClient = 0; <a name="l00236"></a>00236 d->remotefile = 0; <a name="l00237"></a>00237 } <a name="l00238"></a>00238 <a name="l00239"></a>00239 SlaveBase::~SlaveBase() <a name="l00240"></a>00240 { <a name="l00241"></a>00241 <span class="keyword">delete</span> d; <a name="l00242"></a>00242 s_protocol = <span class="stringliteral">""</span>; <a name="l00243"></a>00243 } <a name="l00244"></a>00244 <a name="l00245"></a><a class="code" href="classKIO_1_1SlaveBase.html#a8bc430ce9cae11652fe5dad601789d02">00245</a> DCOPClient *<a class="code" href="classKIO_1_1SlaveBase.html#a8bc430ce9cae11652fe5dad601789d02" title="Return the dcop client used by this slave.">SlaveBase::dcopClient</a>() <a name="l00246"></a>00246 { <a name="l00247"></a>00247 <span class="keywordflow">if</span> (!d->dcopClient) <a name="l00248"></a>00248 { <a name="l00249"></a>00249 d->dcopClient = <a class="code" href="classKIO_1_1SlaveBase.html#a8bc430ce9cae11652fe5dad601789d02" title="Return the dcop client used by this slave.">KApplication::dcopClient</a>(); <a name="l00250"></a>00250 <span class="keywordflow">if</span> (!d->dcopClient->isAttached()) <a name="l00251"></a>00251 d->dcopClient->attach(); <a name="l00252"></a>00252 d->dcopClient->setDaemonMode( <span class="keyword">true</span> ); <a name="l00253"></a>00253 } <a name="l00254"></a>00254 <span class="keywordflow">return</span> d->dcopClient; <a name="l00255"></a>00255 } <a name="l00256"></a>00256 <a name="l00257"></a>00257 <span class="keywordtype">void</span> SlaveBase::dispatchLoop() <a name="l00258"></a>00258 { <a name="l00259"></a>00259 <span class="preprocessor">#ifdef Q_OS_UNIX //TODO: WIN32</span> <a name="l00260"></a>00260 <span class="preprocessor"></span> fd_set rfds; <a name="l00261"></a>00261 <span class="keywordtype">int</span> retval; <a name="l00262"></a>00262 <a name="l00263"></a>00263 <span class="keywordflow">while</span> (<span class="keyword">true</span>) <a name="l00264"></a>00264 { <a name="l00265"></a>00265 <span class="keywordflow">if</span> (d->timeout && (d->timeout < time(0))) <a name="l00266"></a>00266 { <a name="l00267"></a>00267 <a class="codeRef" href="qbytearray.html">QByteArray</a> <a class="code" href="classKIO_1_1SlaveBase.html#aad44fb5ca04e9fc4d9f4e0ecebde3736" title="Sends data in the slave to the job (i.e.">data</a> = d->timeoutData; <a name="l00268"></a>00268 d->timeout = 0; <a name="l00269"></a>00269 d->timeoutData = <a class="codeRef" href="qbytearray.html">QByteArray</a>(); <a name="l00270"></a>00270 <a class="code" href="classKIO_1_1SlaveBase.html#aa53ecc830f2f57cde6b8c81cf3a1d14c" title="Used for any command that is specific to this slave (protocol) Examples are : HTTP POST...">special</a>(data); <a name="l00271"></a>00271 } <a name="l00272"></a>00272 FD_ZERO(&rfds); <a name="l00273"></a>00273 <a name="l00274"></a>00274 assert(appconn-><a class="code" href="classKIO_1_1Connection.html#aa10731b9f95ac43561738bf73375d3ee" title="Checks whether the connection has been initialized.">inited</a>()); <a name="l00275"></a>00275 <span class="keywordtype">int</span> maxfd = appconn-><a class="code" href="classKIO_1_1Connection.html#a42efa5eb36d0d355351ac0762845073c" title="Returns the input file descriptor.">fd_from</a>(); <a name="l00276"></a>00276 FD_SET(appconn-><a class="code" href="classKIO_1_1Connection.html#a42efa5eb36d0d355351ac0762845073c" title="Returns the input file descriptor.">fd_from</a>(), &rfds); <a name="l00277"></a>00277 <span class="keywordflow">if</span>( d->dcopClient ) <a name="l00278"></a>00278 { <a name="l00279"></a>00279 FD_SET( d->dcopClient->socket(), &rfds ); <a name="l00280"></a>00280 <span class="keywordflow">if</span>( d->dcopClient->socket() > maxfd ) <a name="l00281"></a>00281 maxfd = d->dcopClient->socket(); <a name="l00282"></a>00282 } <a name="l00283"></a>00283 <a name="l00284"></a>00284 <span class="keywordflow">if</span> (!d->timeout) <span class="comment">// we can wait forever</span> <a name="l00285"></a>00285 { <a name="l00286"></a>00286 retval = select( maxfd + 1, &rfds, NULL, NULL, NULL); <a name="l00287"></a>00287 } <a name="l00288"></a>00288 <span class="keywordflow">else</span> <a name="l00289"></a>00289 { <a name="l00290"></a>00290 <span class="keyword">struct </span>timeval tv; <a name="l00291"></a>00291 tv.tv_sec = kMax(d->timeout-time(0),(time_t) 1); <a name="l00292"></a>00292 tv.tv_usec = 0; <a name="l00293"></a>00293 retval = select( maxfd + 1, &rfds, NULL, NULL, &tv); <a name="l00294"></a>00294 } <a name="l00295"></a>00295 <span class="keywordflow">if</span> ((retval>0) && FD_ISSET(appconn-><a class="code" href="classKIO_1_1Connection.html#a42efa5eb36d0d355351ac0762845073c" title="Returns the input file descriptor.">fd_from</a>(), &rfds)) <a name="l00296"></a>00296 { <span class="comment">// dispatch application messages</span> <a name="l00297"></a>00297 <span class="keywordtype">int</span> cmd; <a name="l00298"></a>00298 <a class="codeRef" href="qbytearray.html">QByteArray</a> <a class="code" href="classKIO_1_1SlaveBase.html#aad44fb5ca04e9fc4d9f4e0ecebde3736" title="Sends data in the slave to the job (i.e.">data</a>; <a name="l00299"></a>00299 <span class="keywordflow">if</span> ( appconn-><a class="code" href="classKIO_1_1Connection.html#a484f8dada25c7d8315e1964b419278e7" title="Receive data.">read</a>(&cmd, data) != -1 ) <a name="l00300"></a>00300 { <a name="l00301"></a>00301 dispatch(cmd, data); <a name="l00302"></a>00302 } <a name="l00303"></a>00303 <span class="keywordflow">else</span> <span class="comment">// some error occurred, perhaps no more application</span> <a name="l00304"></a>00304 { <a name="l00305"></a>00305 <span class="comment">// When the app exits, should the slave be put back in the pool ?</span> <a name="l00306"></a>00306 <span class="keywordflow">if</span> (mConnectedToApp && !mPoolSocket.<a class="codeRef" href="qstring.html#isEmpty">isEmpty</a>()) <a name="l00307"></a>00307 { <a name="l00308"></a>00308 disconnectSlave(); <a name="l00309"></a>00309 mConnectedToApp = <span class="keyword">false</span>; <a name="l00310"></a>00310 <a class="code" href="classKIO_1_1SlaveBase.html#acb154c5b60f5dd11de7df4acf20572f0" title="Closes the connection (forced) Called when the application disconnects the slave to close any open ne...">closeConnection</a>(); <a name="l00311"></a>00311 <a class="code" href="classKIO_1_1SlaveBase.html#a985d6642f4d331032d02b69c19399313" title="internal function to connect a slave to/ disconnect from either the slave pool or the application...">connectSlave</a>(mPoolSocket); <a name="l00312"></a>00312 } <a name="l00313"></a>00313 <span class="keywordflow">else</span> <a name="l00314"></a>00314 { <a name="l00315"></a>00315 <span class="keywordflow">return</span>; <a name="l00316"></a>00316 } <a name="l00317"></a>00317 } <a name="l00318"></a>00318 } <a name="l00319"></a>00319 <span class="keywordflow">if</span>( retval > 0 && d->dcopClient && FD_ISSET( d->dcopClient->socket(), &rfds )) <a name="l00320"></a>00320 { <a name="l00321"></a>00321 d->dcopClient->processSocketData( d->dcopClient->socket()); <a name="l00322"></a>00322 } <a name="l00323"></a>00323 <span class="keywordflow">if</span> ((retval<0) && (errno != EINTR)) <a name="l00324"></a>00324 { <a name="l00325"></a>00325 kdDebug(7019) << <span class="stringliteral">"dispatchLoop(): select returned "</span> << retval << <span class="stringliteral">" "</span> <a name="l00326"></a>00326 << (errno==EBADF?<span class="stringliteral">"EBADF"</span>:errno==EINTR?<span class="stringliteral">"EINTR"</span>:errno==EINVAL?<span class="stringliteral">"EINVAL"</span>:errno==ENOMEM?<span class="stringliteral">"ENOMEM"</span>:<span class="stringliteral">"unknown"</span>) <a name="l00327"></a>00327 << <span class="stringliteral">" ("</span> << errno << <span class="stringliteral">")"</span> << endl; <a name="l00328"></a>00328 <span class="keywordflow">return</span>; <a name="l00329"></a>00329 } <a name="l00330"></a>00330 <span class="comment">//I think we get here when we were killed in dispatch() and not in select()</span> <a name="l00331"></a>00331 <span class="keywordflow">if</span> (<a class="code" href="classKIO_1_1SlaveBase.html#ad0ed5cda199cafe99743b3efcc24aa92" title="If your ioslave was killed by a signal, wasKilled() returns true.">wasKilled</a>()) <a name="l00332"></a>00332 { <a name="l00333"></a>00333 kdDebug(7019)<<<span class="stringliteral">" dispatchLoop() slave was killed, returning"</span><<endl; <a name="l00334"></a>00334 <span class="keywordflow">return</span>; <a name="l00335"></a>00335 } <a name="l00336"></a>00336 } <a name="l00337"></a>00337 <span class="preprocessor">#endif</span> <a name="l00338"></a>00338 <span class="preprocessor"></span>} <a name="l00339"></a>00339 <a name="l00340"></a><a class="code" href="classKIO_1_1SlaveBase.html#a985d6642f4d331032d02b69c19399313">00340</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a985d6642f4d331032d02b69c19399313" title="internal function to connect a slave to/ disconnect from either the slave pool or the application...">SlaveBase::connectSlave</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a>& path) <a name="l00341"></a>00341 { <a name="l00342"></a>00342 <span class="preprocessor">#ifdef Q_OS_UNIX //TODO: KSocket not yet available on WIN32</span> <a name="l00343"></a>00343 <span class="preprocessor"></span> appconn-><a class="code" href="classKIO_1_1Connection.html#a0f54611829c4890db1cfac4ce09259f2" title="Initialize this connection to use the given socket.">init</a>(<span class="keyword">new</span> KSocket(<a class="codeRef" href="qfile.html#encodeName">QFile::encodeName</a>(path))); <a name="l00344"></a>00344 <span class="keywordflow">if</span> (!appconn-><a class="code" href="classKIO_1_1Connection.html#aa10731b9f95ac43561738bf73375d3ee" title="Checks whether the connection has been initialized.">inited</a>()) <a name="l00345"></a>00345 { <a name="l00346"></a>00346 kdDebug(7019) << <span class="stringliteral">"SlaveBase: failed to connect to "</span> << path << endl; <a name="l00347"></a>00347 exit(); <a name="l00348"></a>00348 } <a name="l00349"></a>00349 <a name="l00350"></a>00350 setConnection(appconn); <a name="l00351"></a>00351 <span class="preprocessor">#endif</span> <a name="l00352"></a>00352 <span class="preprocessor"></span>} <a name="l00353"></a>00353 <a name="l00354"></a>00354 <span class="keywordtype">void</span> SlaveBase::disconnectSlave() <a name="l00355"></a>00355 { <a name="l00356"></a>00356 appconn-><a class="code" href="classKIO_1_1Connection.html#aea9f9d78e2b92747d4e4575ccb97361e" title="Closes the connection.">close</a>(); <a name="l00357"></a>00357 } <a name="l00358"></a>00358 <a name="l00359"></a><a class="code" href="classKIO_1_1SlaveBase.html#af34190cea639885ec37b279ba9fed624">00359</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#af34190cea639885ec37b279ba9fed624" title="Sets meta-data to be send to the application before the first data() or finished() signal...">SlaveBase::setMetaData</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &key, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &value) <a name="l00360"></a>00360 { <a name="l00361"></a>00361 mOutgoingMetaData.<a class="codeRef" href="qmap.html#replace">replace</a>(key, value); <a name="l00362"></a>00362 } <a name="l00363"></a>00363 <a name="l00364"></a><a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9">00364</a> <a class="codeRef" href="qstring.html">QString</a> <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">SlaveBase::metaData</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &key)<span class="keyword"> const</span> <a name="l00365"></a>00365 <span class="keyword"></span>{ <a name="l00366"></a>00366 <span class="keywordflow">if</span> (mIncomingMetaData.<a class="codeRef" href="qmap.html#contains">contains</a>(key)) <a name="l00367"></a>00367 <span class="keywordflow">return</span> mIncomingMetaData[key]; <a name="l00368"></a>00368 <span class="keywordflow">if</span> (d->configData.contains(key)) <a name="l00369"></a>00369 <span class="keywordflow">return</span> d->configData[key]; <a name="l00370"></a>00370 <span class="keywordflow">return</span> QString::null; <a name="l00371"></a>00371 } <a name="l00372"></a>00372 <a name="l00373"></a><a class="code" href="classKIO_1_1SlaveBase.html#a28e86730b118588380ab3e1e965695c1">00373</a> <span class="keywordtype">bool</span> <a class="code" href="classKIO_1_1SlaveBase.html#a28e86730b118588380ab3e1e965695c1" title="Queries for the existence of a certain config/meta-data entry send by the application to the slave...">SlaveBase::hasMetaData</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &key)<span class="keyword"> const</span> <a name="l00374"></a>00374 <span class="keyword"></span>{ <a name="l00375"></a>00375 <span class="keywordflow">if</span> (mIncomingMetaData.<a class="codeRef" href="qmap.html#contains">contains</a>(key)) <a name="l00376"></a>00376 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00377"></a>00377 <span class="keywordflow">if</span> (d->configData.contains(key)) <a name="l00378"></a>00378 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00379"></a>00379 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00380"></a>00380 } <a name="l00381"></a>00381 <a name="l00382"></a>00382 <span class="comment">// ### remove the next two methods for KDE4 (they miss the const)</span> <a name="l00383"></a><a class="code" href="classKIO_1_1SlaveBase.html#a13c179cc55eb1f500ae35c1a35f20051">00383</a> <a class="codeRef" href="qstring.html">QString</a> <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">SlaveBase::metaData</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &key) { <a name="l00384"></a>00384 <span class="keywordflow">return</span> <span class="keyword">const_cast<</span><span class="keyword">const </span><a class="code" href="classKIO_1_1SlaveBase.html" title="There are two classes that specifies the protocol between application (job) and kioslave.">SlaveBase</a>*<span class="keyword">></span>(<span class="keyword">this</span>)-><a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>( key ); <a name="l00385"></a>00385 } <a name="l00386"></a><a class="code" href="classKIO_1_1SlaveBase.html#acc42f04e293a38c08560b3dbd58ea94e">00386</a> <span class="keywordtype">bool</span> <a class="code" href="classKIO_1_1SlaveBase.html#a28e86730b118588380ab3e1e965695c1" title="Queries for the existence of a certain config/meta-data entry send by the application to the slave...">SlaveBase::hasMetaData</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &key) { <a name="l00387"></a>00387 <span class="keywordflow">return</span> <span class="keyword">const_cast<</span><span class="keyword">const </span><a class="code" href="classKIO_1_1SlaveBase.html" title="There are two classes that specifies the protocol between application (job) and kioslave.">SlaveBase</a>*<span class="keyword">></span>(<span class="keyword">this</span>)-><a class="code" href="classKIO_1_1SlaveBase.html#a28e86730b118588380ab3e1e965695c1" title="Queries for the existence of a certain config/meta-data entry send by the application to the slave...">hasMetaData</a>( key ); <a name="l00388"></a>00388 } <a name="l00389"></a>00389 <a name="l00390"></a><a class="code" href="classKIO_1_1SlaveBase.html#ac70a447e25ff38f993499bbd9e696df0">00390</a> KConfigBase *<a class="code" href="classKIO_1_1SlaveBase.html#ac70a447e25ff38f993499bbd9e696df0" title="Returns a configuration object to query config/meta-data information from.">SlaveBase::config</a>() <a name="l00391"></a>00391 { <a name="l00392"></a>00392 <span class="keywordflow">return</span> d->config; <a name="l00393"></a>00393 } <a name="l00394"></a>00394 <a name="l00395"></a><a class="code" href="classKIO_1_1SlaveBase.html#a73dfc533c2c9126e9af7e347a4016f2b">00395</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a73dfc533c2c9126e9af7e347a4016f2b" title="Internal function to transmit meta data to the application.">SlaveBase::sendMetaData</a>() <a name="l00396"></a>00396 { <a name="l00397"></a>00397 KIO_DATA << mOutgoingMetaData; <a name="l00398"></a>00398 <a name="l00399"></a>00399 slaveWriteError = <span class="keyword">false</span>; <a name="l00400"></a>00400 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_META_DATA, data ); <a name="l00401"></a>00401 <span class="keywordflow">if</span> (slaveWriteError) exit(); <a name="l00402"></a>00402 mOutgoingMetaData.clear(); <span class="comment">// Clear</span> <a name="l00403"></a>00403 } <a name="l00404"></a>00404 <a name="l00405"></a><a class="code" href="classKIO_1_1SlaveBase.html#a8099184cb7144a07de3ed83b0940dfa1">00405</a> <a class="code" href="classKRemoteEncoding.html" title="Allows encoding and decoding properly remote filenames into Unicode.">KRemoteEncoding</a> *<a class="code" href="classKIO_1_1SlaveBase.html#a8099184cb7144a07de3ed83b0940dfa1" title="Returns an object that can translate remote filenames into proper Unicode forms.">SlaveBase::remoteEncoding</a>() <a name="l00406"></a>00406 { <a name="l00407"></a>00407 <span class="keywordflow">if</span> (d->remotefile != 0) <a name="l00408"></a>00408 <span class="keywordflow">return</span> d->remotefile; <a name="l00409"></a>00409 <a name="l00410"></a>00410 <span class="keywordflow">return</span> d->remotefile = <span class="keyword">new</span> <a class="code" href="classKRemoteEncoding.html" title="Allows encoding and decoding properly remote filenames into Unicode.">KRemoteEncoding</a>(<a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"Charset"</span>).latin1()); <a name="l00411"></a>00411 } <a name="l00412"></a>00412 <a name="l00413"></a><a class="code" href="classKIO_1_1SlaveBase.html#aad44fb5ca04e9fc4d9f4e0ecebde3736">00413</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#aad44fb5ca04e9fc4d9f4e0ecebde3736" title="Sends data in the slave to the job (i.e.">SlaveBase::data</a>( <span class="keyword">const</span> <a class="codeRef" href="qbytearray.html">QByteArray</a> &data ) <a name="l00414"></a>00414 { <a name="l00415"></a>00415 <span class="keywordflow">if</span> (!mOutgoingMetaData.<a class="codeRef" href="qmap.html#isEmpty">isEmpty</a>()) <a name="l00416"></a>00416 <a class="code" href="classKIO_1_1SlaveBase.html#a73dfc533c2c9126e9af7e347a4016f2b" title="Internal function to transmit meta data to the application.">sendMetaData</a>(); <a name="l00417"></a>00417 slaveWriteError = <span class="keyword">false</span>; <a name="l00418"></a>00418 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_DATA, data ); <a name="l00419"></a>00419 <span class="keywordflow">if</span> (slaveWriteError) exit(); <a name="l00420"></a>00420 } <a name="l00421"></a>00421 <a name="l00422"></a><a class="code" href="classKIO_1_1SlaveBase.html#a5d1e0e56a1589c04533d8a5498883257">00422</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a5d1e0e56a1589c04533d8a5498883257" title="Asks for data from the job.">SlaveBase::dataReq</a>( ) <a name="l00423"></a>00423 { <a name="l00424"></a>00424 <span class="comment">/*</span> <a name="l00425"></a>00425 <span class="comment"> if (!mOutgoingMetaData.isEmpty())</span> <a name="l00426"></a>00426 <span class="comment"> sendMetaData();</span> <a name="l00427"></a>00427 <span class="comment">*/</span> <a name="l00428"></a>00428 <span class="keywordflow">if</span> (d->needSendCanResume) <a name="l00429"></a>00429 <a class="code" href="classKIO_1_1SlaveBase.html#adf63a85dff9c3240a810bb3db6bc84cb" title="Call this at the beginning of put(), to give the size of the existing partial file, if there is one.">canResume</a>(0); <a name="l00430"></a>00430 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_DATA_REQ ); <a name="l00431"></a>00431 } <a name="l00432"></a>00432 <a name="l00433"></a><a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb">00433</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">SlaveBase::error</a>( <span class="keywordtype">int</span> _errid, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &_text ) <a name="l00434"></a>00434 { <a name="l00435"></a>00435 mIncomingMetaData.<a class="codeRef" href="qmap.html#clear">clear</a>(); <span class="comment">// Clear meta data</span> <a name="l00436"></a>00436 mOutgoingMetaData.<a class="codeRef" href="qmap.html#clear">clear</a>(); <a name="l00437"></a>00437 KIO_DATA << (Q_INT32) _errid << _text; <a name="l00438"></a>00438 <a name="l00439"></a>00439 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_ERROR, data ); <a name="l00440"></a>00440 <span class="comment">//reset</span> <a name="l00441"></a>00441 listEntryCurrentSize = 100; <a name="l00442"></a>00442 d->sentListEntries=0; <a name="l00443"></a>00443 d->totalSize=0; <a name="l00444"></a>00444 } <a name="l00445"></a>00445 <a name="l00446"></a><a class="code" href="classKIO_1_1SlaveBase.html#a7eeae308a8c3dac6ce59c54839cb6e67">00446</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a7eeae308a8c3dac6ce59c54839cb6e67" title="Call in openConnection, if you reimplement it, when you're done.">SlaveBase::connected</a>() <a name="l00447"></a>00447 { <a name="l00448"></a>00448 slaveWriteError = <span class="keyword">false</span>; <a name="l00449"></a>00449 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_CONNECTED ); <a name="l00450"></a>00450 <span class="keywordflow">if</span> (slaveWriteError) exit(); <a name="l00451"></a>00451 } <a name="l00452"></a>00452 <a name="l00453"></a><a class="code" href="classKIO_1_1SlaveBase.html#a4987924a8e9e087ebf4a9edc11299708">00453</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a4987924a8e9e087ebf4a9edc11299708" title="Call to signal successful completion of any command (besides openConnection and closeConnection)">SlaveBase::finished</a>() <a name="l00454"></a>00454 { <a name="l00455"></a>00455 mIncomingMetaData.<a class="codeRef" href="qmap.html#clear">clear</a>(); <span class="comment">// Clear meta data</span> <a name="l00456"></a>00456 <span class="keywordflow">if</span> (!mOutgoingMetaData.<a class="codeRef" href="qmap.html#isEmpty">isEmpty</a>()) <a name="l00457"></a>00457 <a class="code" href="classKIO_1_1SlaveBase.html#a73dfc533c2c9126e9af7e347a4016f2b" title="Internal function to transmit meta data to the application.">sendMetaData</a>(); <a name="l00458"></a>00458 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_FINISHED ); <a name="l00459"></a>00459 <a name="l00460"></a>00460 <span class="comment">// reset</span> <a name="l00461"></a>00461 listEntryCurrentSize = 100; <a name="l00462"></a>00462 d->sentListEntries=0; <a name="l00463"></a>00463 d->totalSize=0; <a name="l00464"></a>00464 } <a name="l00465"></a>00465 <a name="l00466"></a><a class="code" href="classKIO_1_1SlaveBase.html#a9c4f884614d9c0446053dc38908884b2">00466</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a9c4f884614d9c0446053dc38908884b2" title="Call to signal that data from the sub-URL is needed.">SlaveBase::needSubURLData</a>() <a name="l00467"></a>00467 { <a name="l00468"></a>00468 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_NEED_SUBURL_DATA ); <a name="l00469"></a>00469 } <a name="l00470"></a>00470 <a name="l00471"></a><a class="code" href="classKIO_1_1SlaveBase.html#a4e8216f4d231b9afce5c298ebc9bc9b1">00471</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a4e8216f4d231b9afce5c298ebc9bc9b1" title="Used to report the status of the slave.">SlaveBase::slaveStatus</a>( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &host, <span class="keywordtype">bool</span> connected ) <a name="l00472"></a>00472 { <a name="l00473"></a>00473 pid_t pid = getpid(); <a name="l00474"></a>00474 Q_INT8 b = connected ? 1 : 0; <a name="l00475"></a>00475 KIO_DATA << pid << <a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a> << host << b; <a name="l00476"></a>00476 <span class="keywordflow">if</span> (d->onHold) <a name="l00477"></a>00477 stream << d->onHoldUrl; <a name="l00478"></a>00478 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_SLAVE_STATUS, data ); <a name="l00479"></a>00479 } <a name="l00480"></a>00480 <a name="l00481"></a>00481 <span class="keywordtype">void</span> SlaveBase::canResume() <a name="l00482"></a>00482 { <a name="l00483"></a>00483 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_CANRESUME ); <a name="l00484"></a>00484 } <a name="l00485"></a>00485 <a name="l00486"></a><a class="code" href="classKIO_1_1SlaveBase.html#ac94502ceba28f85c51301beb34d5850d">00486</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#ac94502ceba28f85c51301beb34d5850d" title="Call this in get and copy, to give the total size of the file Call in listDir too, when you know the total number of items.">SlaveBase::totalSize</a>( <a class="code" href="namespaceKIO.html#a90b418366ba9052c97d4dca845026f43" title="64-bit file size">KIO::filesize_t</a> _bytes ) <a name="l00487"></a>00487 { <a name="l00488"></a>00488 KIO_DATA << KIO_FILESIZE_T(_bytes); <a name="l00489"></a>00489 slaveWriteError = <span class="keyword">false</span>; <a name="l00490"></a>00490 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_TOTAL_SIZE, data ); <a name="l00491"></a>00491 <span class="keywordflow">if</span> (slaveWriteError) exit(); <a name="l00492"></a>00492 <a name="l00493"></a>00493 <span class="comment">//this one is usually called before the first item is listed in listDir()</span> <a name="l00494"></a>00494 <span class="keyword">struct </span>timeval tp; <a name="l00495"></a>00495 gettimeofday(&tp, 0); <a name="l00496"></a>00496 listEntry_sec = tp.tv_sec; <a name="l00497"></a>00497 listEntry_usec = tp.tv_usec; <a name="l00498"></a>00498 d->totalSize=_bytes; <a name="l00499"></a>00499 d->sentListEntries=0; <a name="l00500"></a>00500 } <a name="l00501"></a>00501 <a name="l00502"></a><a class="code" href="classKIO_1_1SlaveBase.html#a34c2dce719c07647edc8ac695bf1632d">00502</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a34c2dce719c07647edc8ac695bf1632d" title="Call this during get and copy, once in a while, to give some info about the current state...">SlaveBase::processedSize</a>( <a class="code" href="namespaceKIO.html#a90b418366ba9052c97d4dca845026f43" title="64-bit file size">KIO::filesize_t</a> _bytes ) <a name="l00503"></a>00503 { <a name="l00504"></a>00504 <span class="keywordtype">bool</span> emitSignal=<span class="keyword">false</span>; <a name="l00505"></a>00505 <span class="keyword">struct </span>timeval tv; <a name="l00506"></a>00506 <span class="keywordtype">int</span> gettimeofday_res=gettimeofday( &tv, 0L ); <a name="l00507"></a>00507 <a name="l00508"></a>00508 <span class="keywordflow">if</span>( _bytes == d->totalSize ) <a name="l00509"></a>00509 emitSignal=<span class="keyword">true</span>; <a name="l00510"></a>00510 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( gettimeofday_res == 0 ) { <a name="l00511"></a>00511 time_t msecdiff = 2000; <a name="l00512"></a>00512 <span class="keywordflow">if</span> (d->last_tv.tv_sec) { <a name="l00513"></a>00513 <span class="comment">// Compute difference, in ms</span> <a name="l00514"></a>00514 msecdiff = 1000 * ( tv.tv_sec - d->last_tv.tv_sec ); <a name="l00515"></a>00515 time_t usecdiff = tv.tv_usec - d->last_tv.tv_usec; <a name="l00516"></a>00516 <span class="keywordflow">if</span> ( usecdiff < 0 ) { <a name="l00517"></a>00517 msecdiff--; <a name="l00518"></a>00518 msecdiff += 1000; <a name="l00519"></a>00519 } <a name="l00520"></a>00520 msecdiff += usecdiff / 1000; <a name="l00521"></a>00521 } <a name="l00522"></a>00522 emitSignal=msecdiff >= 100; <span class="comment">// emit size 10 times a second</span> <a name="l00523"></a>00523 } <a name="l00524"></a>00524 <a name="l00525"></a>00525 <span class="keywordflow">if</span>( emitSignal ) { <a name="l00526"></a>00526 KIO_DATA << KIO_FILESIZE_T(_bytes); <a name="l00527"></a>00527 slaveWriteError = <span class="keyword">false</span>; <a name="l00528"></a>00528 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_PROCESSED_SIZE, data ); <a name="l00529"></a>00529 <span class="keywordflow">if</span> (slaveWriteError) exit(); <a name="l00530"></a>00530 <span class="keywordflow">if</span> ( gettimeofday_res == 0 ) { <a name="l00531"></a>00531 d->last_tv.tv_sec = tv.tv_sec; <a name="l00532"></a>00532 d->last_tv.tv_usec = tv.tv_usec; <a name="l00533"></a>00533 } <a name="l00534"></a>00534 } <a name="l00535"></a>00535 <span class="comment">// d->processed_size = _bytes;</span> <a name="l00536"></a>00536 } <a name="l00537"></a>00537 <a name="l00538"></a><a class="code" href="classKIO_1_1SlaveBase.html#aa2b0e9a7973c3fab3512aff3e3775b3d">00538</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#aa2b0e9a7973c3fab3512aff3e3775b3d" title="Only use this if you can't know in advance the size of the copied data.">SlaveBase::processedPercent</a>( <span class="keywordtype">float</span> <span class="comment">/* percent */</span> ) <a name="l00539"></a>00539 { <a name="l00540"></a>00540 kdDebug(7019) << <span class="stringliteral">"SlaveBase::processedPercent: STUB"</span> << endl; <a name="l00541"></a>00541 } <a name="l00542"></a>00542 <a name="l00543"></a>00543 <a name="l00544"></a><a class="code" href="classKIO_1_1SlaveBase.html#a21412eed653f9b4fdd0d2b4ea7a7897b">00544</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a21412eed653f9b4fdd0d2b4ea7a7897b" title="Call this in get and copy, to give the current transfer speed, but only if it can't be calculated out...">SlaveBase::speed</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> _bytes_per_second ) <a name="l00545"></a>00545 { <a name="l00546"></a>00546 KIO_DATA << (Q_UINT32) _bytes_per_second; <a name="l00547"></a>00547 slaveWriteError = <span class="keyword">false</span>; <a name="l00548"></a>00548 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_SPEED, data ); <a name="l00549"></a>00549 <span class="keywordflow">if</span> (slaveWriteError) exit(); <a name="l00550"></a>00550 } <a name="l00551"></a>00551 <a name="l00552"></a><a class="code" href="classKIO_1_1SlaveBase.html#a8944bf9f3547c0cb4f724f6a22e10c41">00552</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a8944bf9f3547c0cb4f724f6a22e10c41" title="Call this to signal a redirection The job will take care of going to that url.">SlaveBase::redirection</a>( <span class="keyword">const</span> KURL& _url ) <a name="l00553"></a>00553 { <a name="l00554"></a>00554 KIO_DATA << _url; <a name="l00555"></a>00555 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_REDIRECTION, data ); <a name="l00556"></a>00556 } <a name="l00557"></a>00557 <a name="l00558"></a><a class="code" href="classKIO_1_1SlaveBase.html#a41a60ea8659c176dd0f48f704a4a191c">00558</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a41a60ea8659c176dd0f48f704a4a191c" title="Tell that we will only get an error page here.">SlaveBase::errorPage</a>() <a name="l00559"></a>00559 { <a name="l00560"></a>00560 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_ERROR_PAGE ); <a name="l00561"></a>00561 } <a name="l00562"></a>00562 <a name="l00563"></a>00563 <span class="keyword">static</span> <span class="keywordtype">bool</span> isSubCommand(<span class="keywordtype">int</span> cmd) <a name="l00564"></a>00564 { <a name="l00565"></a>00565 <span class="keywordflow">return</span> ( (cmd == CMD_REPARSECONFIGURATION) || <a name="l00566"></a>00566 (cmd == CMD_META_DATA) || <a name="l00567"></a>00567 (cmd == CMD_CONFIG) || <a name="l00568"></a>00568 (cmd == CMD_SUBURL) || <a name="l00569"></a>00569 (cmd == CMD_SLAVE_STATUS) || <a name="l00570"></a>00570 (cmd == CMD_SLAVE_CONNECT) || <a name="l00571"></a>00571 (cmd == CMD_SLAVE_HOLD) || <a name="l00572"></a>00572 (cmd == CMD_MULTI_GET)); <a name="l00573"></a>00573 } <a name="l00574"></a>00574 <a name="l00575"></a><a class="code" href="classKIO_1_1SlaveBase.html#a0f72b6d4e8c94b39d208be0852ea2f50">00575</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a0f72b6d4e8c94b39d208be0852ea2f50" title="Call this in mimetype() and in get(), when you know the mimetype.">SlaveBase::mimeType</a>( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &_type) <a name="l00576"></a>00576 { <a name="l00577"></a>00577 <span class="comment">// kdDebug(7019) << "(" << getpid() << ") SlaveBase::mimeType '" << _type << "'" << endl;</span> <a name="l00578"></a>00578 <span class="keywordtype">int</span> cmd; <a name="l00579"></a>00579 <span class="keywordflow">do</span> <a name="l00580"></a>00580 { <a name="l00581"></a>00581 <span class="comment">// Send the meta-data each time we send the mime-type.</span> <a name="l00582"></a>00582 <span class="keywordflow">if</span> (!mOutgoingMetaData.<a class="codeRef" href="qmap.html#isEmpty">isEmpty</a>()) <a name="l00583"></a>00583 { <a name="l00584"></a>00584 <span class="comment">// kdDebug(7019) << "(" << getpid() << ") mimeType: emitting meta data" << endl;</span> <a name="l00585"></a>00585 KIO_DATA << mOutgoingMetaData; <a name="l00586"></a>00586 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_META_DATA, data ); <a name="l00587"></a>00587 } <a name="l00588"></a>00588 KIO_DATA << _type; <a name="l00589"></a>00589 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_MIME_TYPE, data ); <a name="l00590"></a>00590 <span class="keywordflow">while</span>(<span class="keyword">true</span>) <a name="l00591"></a>00591 { <a name="l00592"></a>00592 cmd = 0; <a name="l00593"></a>00593 <span class="keywordflow">if</span> ( m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a484f8dada25c7d8315e1964b419278e7" title="Receive data.">read</a>( &cmd, data ) == -1 ) { <a name="l00594"></a>00594 kdDebug(7019) << <span class="stringliteral">"SlaveBase: mimetype: read error"</span> << endl; <a name="l00595"></a>00595 exit(); <a name="l00596"></a>00596 } <a name="l00597"></a>00597 <span class="comment">// kdDebug(7019) << "(" << getpid() << ") Slavebase: mimetype got " << cmd << endl;</span> <a name="l00598"></a>00598 <span class="keywordflow">if</span> ( cmd == CMD_HOST) <span class="comment">// Ignore.</span> <a name="l00599"></a>00599 <span class="keywordflow">continue</span>; <a name="l00600"></a>00600 <span class="keywordflow">if</span> ( isSubCommand(cmd) ) <a name="l00601"></a>00601 { <a name="l00602"></a>00602 dispatch( cmd, data ); <a name="l00603"></a>00603 <span class="keywordflow">continue</span>; <span class="comment">// Disguised goto</span> <a name="l00604"></a>00604 } <a name="l00605"></a>00605 <span class="keywordflow">break</span>; <a name="l00606"></a>00606 } <a name="l00607"></a>00607 } <a name="l00608"></a>00608 <span class="keywordflow">while</span> (cmd != CMD_NONE); <a name="l00609"></a>00609 mOutgoingMetaData.<a class="codeRef" href="qmap.html#clear">clear</a>(); <a name="l00610"></a>00610 } <a name="l00611"></a>00611 <a name="l00612"></a>00612 <span class="keywordtype">void</span> SlaveBase::exit() <a name="l00613"></a>00613 { <a name="l00614"></a>00614 this->~<a class="code" href="classKIO_1_1SlaveBase.html" title="There are two classes that specifies the protocol between application (job) and kioslave.">SlaveBase</a>(); <a name="l00615"></a>00615 ::exit(255); <a name="l00616"></a>00616 } <a name="l00617"></a>00617 <a name="l00618"></a><a class="code" href="classKIO_1_1SlaveBase.html#a482f0189b8b21ec7ae05b69d197941e7">00618</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a482f0189b8b21ec7ae05b69d197941e7" title="Call to signal a warning, to be displayed in a dialog box.">SlaveBase::warning</a>( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &_msg) <a name="l00619"></a>00619 { <a name="l00620"></a>00620 KIO_DATA << _msg; <a name="l00621"></a>00621 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_WARNING, data ); <a name="l00622"></a>00622 } <a name="l00623"></a>00623 <a name="l00624"></a><a class="code" href="classKIO_1_1SlaveBase.html#a3154faa5dc1693fddfb3a179093cad5e">00624</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a3154faa5dc1693fddfb3a179093cad5e" title="Call to signal a message, to be displayed if the application wants to, for instance in a status bar...">SlaveBase::infoMessage</a>( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &_msg) <a name="l00625"></a>00625 { <a name="l00626"></a>00626 KIO_DATA << _msg; <a name="l00627"></a>00627 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_INFOMESSAGE, data ); <a name="l00628"></a>00628 } <a name="l00629"></a>00629 <a name="l00630"></a><a class="code" href="classKIO_1_1SlaveBase.html#a1817f00288b6314ee1adcb9f4d671b70">00630</a> <span class="keywordtype">bool</span> <a class="code" href="classKIO_1_1SlaveBase.html#a1817f00288b6314ee1adcb9f4d671b70" title="Used by the slave to check if it can connect to a given host.">SlaveBase::requestNetwork</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a>& host) <a name="l00631"></a>00631 { <a name="l00632"></a>00632 KIO_DATA << host << d->slaveid; <a name="l00633"></a>00633 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_NET_REQUEST, data ); <a name="l00634"></a>00634 <a name="l00635"></a>00635 <span class="keywordflow">if</span> ( <a class="code" href="classKIO_1_1SlaveBase.html#a5303431dc9f943fcce8961011aa8f951" title="Wait for an answer to our request, until we get expected1 or expected2.">waitForAnswer</a>( INF_NETWORK_STATUS, 0, data ) != -1 ) <a name="l00636"></a>00636 { <a name="l00637"></a>00637 <span class="keywordtype">bool</span> status; <a name="l00638"></a>00638 <a class="codeRef" href="qdatastream.html">QDataStream</a> stream( data, IO_ReadOnly ); <a name="l00639"></a>00639 stream >> status; <a name="l00640"></a>00640 <span class="keywordflow">return</span> status; <a name="l00641"></a>00641 } <span class="keywordflow">else</span> <a name="l00642"></a>00642 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00643"></a>00643 } <a name="l00644"></a>00644 <a name="l00645"></a><a class="code" href="classKIO_1_1SlaveBase.html#ab6820c455d2e898bad0549a93fcf06ad">00645</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#ab6820c455d2e898bad0549a93fcf06ad" title="Used by the slave to withdraw a connection requested by requestNetwork.">SlaveBase::dropNetwork</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a>& host) <a name="l00646"></a>00646 { <a name="l00647"></a>00647 KIO_DATA << host << d->slaveid; <a name="l00648"></a>00648 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_NET_DROP, data ); <a name="l00649"></a>00649 } <a name="l00650"></a>00650 <a name="l00651"></a><a class="code" href="classKIO_1_1SlaveBase.html#a75ec4b5f1c05be67d51bd2704afdfc32">00651</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a75ec4b5f1c05be67d51bd2704afdfc32" title="Call this from stat() to express details about an object, the UDSEntry customarily contains the atoms...">SlaveBase::statEntry</a>( <span class="keyword">const</span> <a class="codeRef" href="qvaluelist.html">UDSEntry</a>& entry ) <a name="l00652"></a>00652 { <a name="l00653"></a>00653 KIO_DATA << entry; <a name="l00654"></a>00654 slaveWriteError = <span class="keyword">false</span>; <a name="l00655"></a>00655 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_STAT_ENTRY, data ); <a name="l00656"></a>00656 <span class="keywordflow">if</span> (slaveWriteError) exit(); <a name="l00657"></a>00657 } <a name="l00658"></a>00658 <a name="l00659"></a><a class="code" href="classKIO_1_1SlaveBase.html#ac144ec3a8fcbaed9488bd9a0d71de22c">00659</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#ac144ec3a8fcbaed9488bd9a0d71de22c" title="internal function to be called by the slave.">SlaveBase::listEntry</a>( <span class="keyword">const</span> <a class="codeRef" href="qvaluelist.html">UDSEntry</a>& entry, <span class="keywordtype">bool</span> _ready ) <a name="l00660"></a>00660 { <a name="l00661"></a>00661 <span class="keyword">static</span> <span class="keyword">struct </span>timeval tp; <a name="l00662"></a>00662 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> maximum_updatetime = 300; <a name="l00663"></a>00663 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> minimum_updatetime = 100; <a name="l00664"></a>00664 <a name="l00665"></a>00665 <span class="keywordflow">if</span> (!_ready) { <a name="l00666"></a>00666 pendingListEntries.<a class="codeRef" href="qvaluelist.html#append">append</a>(entry); <a name="l00667"></a>00667 <a name="l00668"></a>00668 <span class="keywordflow">if</span> (pendingListEntries.<a class="codeRef" href="qvaluelist.html#count">count</a>() > listEntryCurrentSize) { <a name="l00669"></a>00669 gettimeofday(&tp, 0); <a name="l00670"></a>00670 <a name="l00671"></a>00671 <span class="keywordtype">long</span> diff = ((tp.tv_sec - listEntry_sec) * 1000000 + <a name="l00672"></a>00672 tp.tv_usec - listEntry_usec) / 1000; <a name="l00673"></a>00673 <span class="keywordflow">if</span> (diff==0) diff=1; <a name="l00674"></a>00674 <a name="l00675"></a>00675 <span class="keywordflow">if</span> (diff > maximum_updatetime) { <a name="l00676"></a>00676 listEntryCurrentSize = listEntryCurrentSize * 3 / 4; <a name="l00677"></a>00677 _ready = <span class="keyword">true</span>; <a name="l00678"></a>00678 } <a name="l00679"></a>00679 <span class="comment">//if we can send all list entries of this dir which have not yet been sent</span> <a name="l00680"></a>00680 <span class="comment">//within maximum_updatetime, then make listEntryCurrentSize big enough for all of them</span> <a name="l00681"></a>00681 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (((pendingListEntries.<a class="codeRef" href="qvaluelist.html#count">count</a>()*maximum_updatetime)/diff) > (d->totalSize-d->sentListEntries)) <a name="l00682"></a>00682 listEntryCurrentSize=d->totalSize-d->sentListEntries+1; <a name="l00683"></a>00683 <span class="comment">//if we are below minimum_updatetime, estimate how much we will get within</span> <a name="l00684"></a>00684 <span class="comment">//maximum_updatetime</span> <a name="l00685"></a>00685 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (diff < minimum_updatetime) <a name="l00686"></a>00686 listEntryCurrentSize = (pendingListEntries.<a class="codeRef" href="qvaluelist.html#count">count</a>() * maximum_updatetime) / diff; <a name="l00687"></a>00687 <span class="keywordflow">else</span> <a name="l00688"></a>00688 _ready=<span class="keyword">true</span>; <a name="l00689"></a>00689 } <a name="l00690"></a>00690 } <a name="l00691"></a>00691 <span class="keywordflow">if</span> (_ready) { <span class="comment">// may happen when we started with !ready</span> <a name="l00692"></a>00692 <a class="code" href="classKIO_1_1SlaveBase.html#ab8ef312d646dd82062ce03f5edc55879" title="Call this in listDir, each time you have a bunch of entries to report.">listEntries</a>( pendingListEntries ); <a name="l00693"></a>00693 pendingListEntries.<a class="codeRef" href="qvaluelist.html#clear">clear</a>(); <a name="l00694"></a>00694 <a name="l00695"></a>00695 gettimeofday(&tp, 0); <a name="l00696"></a>00696 listEntry_sec = tp.tv_sec; <a name="l00697"></a>00697 listEntry_usec = tp.tv_usec; <a name="l00698"></a>00698 } <a name="l00699"></a>00699 } <a name="l00700"></a>00700 <a name="l00701"></a><a class="code" href="classKIO_1_1SlaveBase.html#ab8ef312d646dd82062ce03f5edc55879">00701</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#ab8ef312d646dd82062ce03f5edc55879" title="Call this in listDir, each time you have a bunch of entries to report.">SlaveBase::listEntries</a>( <span class="keyword">const</span> <a class="codeRef" href="qvaluelist.html">UDSEntryList</a>& list ) <a name="l00702"></a>00702 { <a name="l00703"></a>00703 KIO_DATA << (Q_UINT32)list.<a class="codeRef" href="qvaluelist.html#count">count</a>(); <a name="l00704"></a>00704 <a class="codeRef" href="qvaluelistconstiterator.html">UDSEntryListConstIterator</a> it = list.<a class="codeRef" href="qvaluelist.html#begin">begin</a>(); <a name="l00705"></a>00705 <a class="codeRef" href="qvaluelistconstiterator.html">UDSEntryListConstIterator</a> end = list.<a class="codeRef" href="qvaluelist.html#end">end</a>(); <a name="l00706"></a>00706 <span class="keywordflow">for</span> (; it != end; ++it) <a name="l00707"></a>00707 stream << *it; <a name="l00708"></a>00708 slaveWriteError = <span class="keyword">false</span>; <a name="l00709"></a>00709 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_LIST_ENTRIES, data); <a name="l00710"></a>00710 <span class="keywordflow">if</span> (slaveWriteError) exit(); <a name="l00711"></a>00711 d->sentListEntries+=(uint)list.<a class="codeRef" href="qvaluelist.html#count">count</a>(); <a name="l00712"></a>00712 } <a name="l00713"></a>00713 <a name="l00714"></a><a class="code" href="classKIO_1_1SlaveBase.html#a7a256f7876d9e06e5dedca3159586c9e">00714</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a7a256f7876d9e06e5dedca3159586c9e">SlaveBase::sendAuthenticationKey</a>( <span class="keyword">const</span> <a class="codeRef" href="qcstring.html">QCString</a>& key, <a name="l00715"></a>00715 <span class="keyword">const</span> <a class="codeRef" href="qcstring.html">QCString</a>& group, <a name="l00716"></a>00716 <span class="keywordtype">bool</span> keepPass ) <a name="l00717"></a>00717 { <a name="l00718"></a>00718 KIO_DATA << key << group << keepPass; <a name="l00719"></a>00719 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_AUTH_KEY, data ); <a name="l00720"></a>00720 } <a name="l00721"></a>00721 <a name="l00722"></a><a class="code" href="classKIO_1_1SlaveBase.html#ab538af2295fb78590e2c34b02f387b7c">00722</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#ab538af2295fb78590e2c34b02f387b7c">SlaveBase::delCachedAuthentication</a>( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a>& key ) <a name="l00723"></a>00723 { <a name="l00724"></a>00724 KIO_DATA << key.<a class="codeRef" href="qstring.html#utf8">utf8</a>() ; <a name="l00725"></a>00725 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_DEL_AUTH_KEY, data ); <a name="l00726"></a>00726 } <a name="l00727"></a>00727 <a name="l00728"></a>00728 <span class="keywordtype">void</span> SlaveBase::sigsegv_handler(<span class="keywordtype">int</span> sig) <a name="l00729"></a>00729 { <a name="l00730"></a>00730 <span class="preprocessor">#ifdef Q_OS_UNIX</span> <a name="l00731"></a>00731 <span class="preprocessor"></span> signal(sig,SIG_DFL); <span class="comment">// Next one kills</span> <a name="l00732"></a>00732 <a name="l00733"></a>00733 <span class="comment">//Kill us if we deadlock</span> <a name="l00734"></a>00734 signal(SIGALRM,SIG_DFL); <a name="l00735"></a>00735 alarm(5); <span class="comment">//generate an alarm signal in 5 seconds, in this time the slave has to exit</span> <a name="l00736"></a>00736 <a name="l00737"></a>00737 <span class="comment">// Debug and printf should be avoided because they might</span> <a name="l00738"></a>00738 <span class="comment">// call malloc.. and get in a nice recursive malloc loop</span> <a name="l00739"></a>00739 <span class="keywordtype">char</span> buffer[120]; <a name="l00740"></a>00740 snprintf(buffer, <span class="keyword">sizeof</span>(buffer), <span class="stringliteral">"kioslave: ####### CRASH ###### protocol = %s pid = %d signal = %d\n"</span>, s_protocol, getpid(), sig); <a name="l00741"></a>00741 write(2, buffer, strlen(buffer)); <a name="l00742"></a>00742 <span class="preprocessor">#ifndef NDEBUG</span> <a name="l00743"></a>00743 <span class="preprocessor"></span><span class="preprocessor">#ifdef HAVE_BACKTRACE</span> <a name="l00744"></a>00744 <span class="preprocessor"></span> <span class="keywordtype">void</span>* trace[256]; <a name="l00745"></a>00745 <span class="keywordtype">int</span> n = backtrace(trace, 256); <a name="l00746"></a>00746 <span class="keywordflow">if</span> (n) <a name="l00747"></a>00747 backtrace_symbols_fd(trace, n, 2); <a name="l00748"></a>00748 <span class="preprocessor">#endif</span> <a name="l00749"></a>00749 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00750"></a>00750 <span class="preprocessor"></span> ::exit(1); <a name="l00751"></a>00751 <span class="preprocessor">#endif</span> <a name="l00752"></a>00752 <span class="preprocessor"></span>} <a name="l00753"></a>00753 <a name="l00754"></a>00754 <span class="keywordtype">void</span> SlaveBase::sigpipe_handler (<span class="keywordtype">int</span>) <a name="l00755"></a>00755 { <a name="l00756"></a>00756 <span class="comment">// We ignore a SIGPIPE in slaves.</span> <a name="l00757"></a>00757 <span class="comment">// A SIGPIPE can happen in two cases:</span> <a name="l00758"></a>00758 <span class="comment">// 1) Communication error with application.</span> <a name="l00759"></a>00759 <span class="comment">// 2) Communication error with network.</span> <a name="l00760"></a>00760 slaveWriteError = <span class="keyword">true</span>; <a name="l00761"></a>00761 <a name="l00762"></a>00762 <span class="comment">// Don't add anything else here, especially no debug output</span> <a name="l00763"></a>00763 } <a name="l00764"></a>00764 <a name="l00765"></a><a class="code" href="classKIO_1_1SlaveBase.html#aa317789e4dfdbff726a6fd547b24dcab">00765</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#aa317789e4dfdbff726a6fd547b24dcab" title="Set the host.">SlaveBase::setHost</a>(<a class="codeRef" href="qstring.html">QString</a> <span class="keyword">const</span> &, <span class="keywordtype">int</span>, <a class="codeRef" href="qstring.html">QString</a> <span class="keyword">const</span> &, <a class="codeRef" href="qstring.html">QString</a> <span class="keyword">const</span> &) <a name="l00766"></a>00766 { <a name="l00767"></a>00767 } <a name="l00768"></a>00768 <a name="l00769"></a><a class="code" href="classKIO_1_1SlaveBase.html#a4cc0692960fe1c11d318c4ef272e332c">00769</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a4cc0692960fe1c11d318c4ef272e332c" title="Opens the connection (forced) When this function gets called the slave is operating in connection-ori...">SlaveBase::openConnection</a>(<span class="keywordtype">void</span>) <a name="l00770"></a>00770 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_CONNECT)); } <a name="l00771"></a><a class="code" href="classKIO_1_1SlaveBase.html#acb154c5b60f5dd11de7df4acf20572f0">00771</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#acb154c5b60f5dd11de7df4acf20572f0" title="Closes the connection (forced) Called when the application disconnects the slave to close any open ne...">SlaveBase::closeConnection</a>(<span class="keywordtype">void</span>) <a name="l00772"></a>00772 { } <span class="comment">// No response!</span> <a name="l00773"></a><a class="code" href="classKIO_1_1SlaveBase.html#a20aa8e52e38af682a80f1ef2016c83c9">00773</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a20aa8e52e38af682a80f1ef2016c83c9" title="Finds all details for one file or directory.">SlaveBase::stat</a>(KURL <span class="keyword">const</span> &) <a name="l00774"></a>00774 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_STAT)); } <a name="l00775"></a><a class="code" href="classKIO_1_1SlaveBase.html#ab1207ed4e333ca0ed6377771fd21cf3d">00775</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#ab1207ed4e333ca0ed6377771fd21cf3d" title="put, i.e.">SlaveBase::put</a>(KURL <span class="keyword">const</span> &, <span class="keywordtype">int</span>, <span class="keywordtype">bool</span>, <span class="keywordtype">bool</span>) <a name="l00776"></a>00776 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_PUT)); } <a name="l00777"></a><a class="code" href="classKIO_1_1SlaveBase.html#aa53ecc830f2f57cde6b8c81cf3a1d14c">00777</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#aa53ecc830f2f57cde6b8c81cf3a1d14c" title="Used for any command that is specific to this slave (protocol) Examples are : HTTP POST...">SlaveBase::special</a>(<span class="keyword">const</span> <a class="codeRef" href="qbytearray.html">QByteArray</a> &) <a name="l00778"></a>00778 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_SPECIAL)); } <a name="l00779"></a><a class="code" href="classKIO_1_1SlaveBase.html#acfee67cfc81e5d2fae72cb20c2707d4b">00779</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#acfee67cfc81e5d2fae72cb20c2707d4b" title="Lists the contents of url.">SlaveBase::listDir</a>(KURL <span class="keyword">const</span> &) <a name="l00780"></a>00780 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_LISTDIR)); } <a name="l00781"></a><a class="code" href="classKIO_1_1SlaveBase.html#a79b675fda88d631f0b6dc578abbb479e">00781</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a79b675fda88d631f0b6dc578abbb479e" title="get, aka read.">SlaveBase::get</a>(KURL <span class="keyword">const</span> & ) <a name="l00782"></a>00782 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_GET)); } <a name="l00783"></a><a class="code" href="classKIO_1_1SlaveBase.html#a46a782488ab6760075fd2cd686133cc6">00783</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a46a782488ab6760075fd2cd686133cc6" title="Finds mimetype for one file or directory.">SlaveBase::mimetype</a>(KURL <span class="keyword">const</span> &url) <a name="l00784"></a>00784 { <span class="keyword">get</span>(url); } <a name="l00785"></a><a class="code" href="classKIO_1_1SlaveBase.html#aab6a8ec51a45397af85637b10d1a38ba">00785</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#aab6a8ec51a45397af85637b10d1a38ba" title="Rename oldname into newname.">SlaveBase::rename</a>(KURL <span class="keyword">const</span> &, KURL <span class="keyword">const</span> &, <span class="keywordtype">bool</span>) <a name="l00786"></a>00786 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_RENAME)); } <a name="l00787"></a><a class="code" href="classKIO_1_1SlaveBase.html#ad827dec554072a0d34c8fa6763282394">00787</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#ad827dec554072a0d34c8fa6763282394" title="Creates a symbolic link named dest, pointing to target, which may be a relative or an absolute path...">SlaveBase::symlink</a>(<a class="codeRef" href="qstring.html">QString</a> <span class="keyword">const</span> &, KURL <span class="keyword">const</span> &, <span class="keywordtype">bool</span>) <a name="l00788"></a>00788 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_SYMLINK)); } <a name="l00789"></a><a class="code" href="classKIO_1_1SlaveBase.html#a9a39d9ce598d112c8ab625dd241f99ab">00789</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a9a39d9ce598d112c8ab625dd241f99ab" title="Copy src into dest.">SlaveBase::copy</a>(KURL <span class="keyword">const</span> &, KURL <span class="keyword">const</span> &, <span class="keywordtype">int</span>, <span class="keywordtype">bool</span>) <a name="l00790"></a>00790 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_COPY)); } <a name="l00791"></a><a class="code" href="classKIO_1_1SlaveBase.html#adf9650287055c9238a1ddfba037bdf2a">00791</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#adf9650287055c9238a1ddfba037bdf2a" title="Delete a file or directory.">SlaveBase::del</a>(KURL <span class="keyword">const</span> &, <span class="keywordtype">bool</span>) <a name="l00792"></a>00792 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_DEL)); } <a name="l00793"></a><a class="code" href="classKIO_1_1SlaveBase.html#a32a4d92f51277226fd9588324d52c888">00793</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a32a4d92f51277226fd9588324d52c888" title="Create a directory.">SlaveBase::mkdir</a>(KURL <span class="keyword">const</span> &, <span class="keywordtype">int</span>) <a name="l00794"></a>00794 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_MKDIR)); } <a name="l00795"></a><a class="code" href="classKIO_1_1SlaveBase.html#a83365ff7f5ca58c9e3ec0c223b8d6038">00795</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a83365ff7f5ca58c9e3ec0c223b8d6038" title="Change permissions on path The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD.">SlaveBase::chmod</a>(KURL <span class="keyword">const</span> &, <span class="keywordtype">int</span>) <a name="l00796"></a>00796 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_CHMOD)); } <a name="l00797"></a><a class="code" href="classKIO_1_1SlaveBase.html#a06756e6e7741e063b18a96c9dfc3d2b5">00797</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a06756e6e7741e063b18a96c9dfc3d2b5" title="Prepare slave for streaming operation.">SlaveBase::setSubURL</a>(KURL <span class="keyword">const</span> &) <a name="l00798"></a>00798 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_SUBURL)); } <a name="l00799"></a><a class="code" href="classKIO_1_1SlaveBase.html#af23180c391259b8abd8e386c868cd559">00799</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#af23180c391259b8abd8e386c868cd559" title="Used for multiple get.">SlaveBase::multiGet</a>(<span class="keyword">const</span> <a class="codeRef" href="qbytearray.html">QByteArray</a> &) <a name="l00800"></a>00800 { <a class="code" href="classKIO_1_1SlaveBase.html#a6938ad4b6647c3f0150ba77d06725efb" title="Call to signal an error.">error</a>( ERR_UNSUPPORTED_ACTION, <a class="code" href="namespaceKIO.html#a1757c6533ace2e8bad19d3b636d61065" title="Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...">unsupportedActionErrorString</a>(<a class="code" href="classKIO_1_1SlaveBase.html#af8a3facada70082ba2d9aa9ae7a6bb7e" title="Name of the protocol supported by this slave.">mProtocol</a>, CMD_MULTI_GET)); } <a name="l00801"></a>00801 <a name="l00802"></a>00802 <a name="l00803"></a><a class="code" href="classKIO_1_1SlaveBase.html#ac42712ebb2fad1237050521c2d9bafe7">00803</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#ac42712ebb2fad1237050521c2d9bafe7" title="Called to get the status of the slave.">SlaveBase::slave_status</a>() <a name="l00804"></a>00804 { <a class="code" href="classKIO_1_1SlaveBase.html#a4e8216f4d231b9afce5c298ebc9bc9b1" title="Used to report the status of the slave.">slaveStatus</a>( QString::null, <span class="keyword">false</span> ); } <a name="l00805"></a>00805 <a name="l00806"></a><a class="code" href="classKIO_1_1SlaveBase.html#a36448af5d807bdcd01143d4394287f1a">00806</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a36448af5d807bdcd01143d4394287f1a" title="Called by the scheduler to tell the slave that the configuration changed (i.e.">SlaveBase::reparseConfiguration</a>() <a name="l00807"></a>00807 { <a name="l00808"></a>00808 } <a name="l00809"></a>00809 <a name="l00810"></a>00810 <span class="keywordtype">bool</span> SlaveBase::dispatch() <a name="l00811"></a>00811 { <a name="l00812"></a>00812 assert( m_pConnection ); <a name="l00813"></a>00813 <a name="l00814"></a>00814 <span class="keywordtype">int</span> cmd; <a name="l00815"></a>00815 <a class="codeRef" href="qbytearray.html">QByteArray</a> <a class="code" href="classKIO_1_1SlaveBase.html#aad44fb5ca04e9fc4d9f4e0ecebde3736" title="Sends data in the slave to the job (i.e.">data</a>; <a name="l00816"></a>00816 <span class="keywordflow">if</span> ( m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a484f8dada25c7d8315e1964b419278e7" title="Receive data.">read</a>( &cmd, data ) == -1 ) <a name="l00817"></a>00817 { <a name="l00818"></a>00818 kdDebug(7019) << <span class="stringliteral">"SlaveBase::dispatch() has read error."</span> << endl; <a name="l00819"></a>00819 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00820"></a>00820 } <a name="l00821"></a>00821 <a name="l00822"></a>00822 dispatch( cmd, data ); <a name="l00823"></a>00823 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00824"></a>00824 } <a name="l00825"></a>00825 <a name="l00826"></a><a class="code" href="classKIO_1_1SlaveBase.html#a9484f69b42978084d988478be9532f4d">00826</a> <span class="keywordtype">bool</span> <a class="code" href="classKIO_1_1SlaveBase.html#a113f5b399282087a84ce6d83e06034ca" title="Prompt the user for Authorization info (login & password).">SlaveBase::openPassDlg</a>( <a class="code" href="classKIO_1_1AuthInfo.html" title="This class is intended to make it easier to prompt for, cache and retrieve authorization information...">AuthInfo</a>& info ) <a name="l00827"></a>00827 { <a name="l00828"></a>00828 <span class="keywordflow">return</span> <a class="code" href="classKIO_1_1SlaveBase.html#a113f5b399282087a84ce6d83e06034ca" title="Prompt the user for Authorization info (login & password).">openPassDlg</a>(info, QString::null); <a name="l00829"></a>00829 } <a name="l00830"></a>00830 <a name="l00831"></a><a class="code" href="classKIO_1_1SlaveBase.html#a113f5b399282087a84ce6d83e06034ca">00831</a> <span class="keywordtype">bool</span> <a class="code" href="classKIO_1_1SlaveBase.html#a113f5b399282087a84ce6d83e06034ca" title="Prompt the user for Authorization info (login & password).">SlaveBase::openPassDlg</a>( <a class="code" href="classKIO_1_1AuthInfo.html" title="This class is intended to make it easier to prompt for, cache and retrieve authorization information...">AuthInfo</a>& info, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &errorMsg ) <a name="l00832"></a>00832 { <a name="l00833"></a>00833 <a class="codeRef" href="qcstring.html">QCString</a> replyType; <a name="l00834"></a>00834 <a class="codeRef" href="qbytearray.html">QByteArray</a> params; <a name="l00835"></a>00835 <a class="codeRef" href="qbytearray.html">QByteArray</a> reply; <a name="l00836"></a>00836 <a class="code" href="classKIO_1_1AuthInfo.html" title="This class is intended to make it easier to prompt for, cache and retrieve authorization information...">AuthInfo</a> authResult; <a name="l00837"></a>00837 <span class="keywordtype">long</span> windowId = <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"window-id"</span>).<a class="codeRef" href="qstring.html#toLong">toLong</a>(); <a name="l00838"></a>00838 <span class="keywordtype">long</span> progressId = <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"progress-id"</span>).<a class="codeRef" href="qstring.html#toLong">toLong</a>(); <a name="l00839"></a>00839 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> userTimestamp = <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"user-timestamp"</span>).<a class="codeRef" href="qstring.html#toULong">toULong</a>(); <a name="l00840"></a>00840 <a name="l00841"></a>00841 kdDebug(7019) << <span class="stringliteral">"SlaveBase::openPassDlg window-id="</span> << windowId << <span class="stringliteral">" progress-id="</span> << progressId << endl; <a name="l00842"></a>00842 <a name="l00843"></a>00843 (void) <a class="code" href="classKIO_1_1SlaveBase.html#a8bc430ce9cae11652fe5dad601789d02" title="Return the dcop client used by this slave.">dcopClient</a>(); <span class="comment">// Make sure to have a dcop client.</span> <a name="l00844"></a>00844 <a name="l00845"></a>00845 UIServer_stub uiserver( <span class="stringliteral">"kio_uiserver"</span>, <span class="stringliteral">"UIServer"</span> ); <a name="l00846"></a>00846 <span class="keywordflow">if</span> (progressId) <a name="l00847"></a>00847 uiserver.setJobVisible( progressId, <span class="keyword">false</span> ); <a name="l00848"></a>00848 <a name="l00849"></a>00849 <a class="codeRef" href="qdatastream.html">QDataStream</a> stream(params, IO_WriteOnly); <a name="l00850"></a>00850 <a name="l00851"></a>00851 <span class="keywordflow">if</span> (<a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"no-auth-prompt"</span>).lower() == <span class="stringliteral">"true"</span>) <a name="l00852"></a>00852 stream << info << <a class="codeRef" href="qstring.html">QString</a>(<span class="stringliteral">"<NoAuthPrompt>"</span>) << windowId << s_seqNr << userTimestamp; <a name="l00853"></a>00853 <span class="keywordflow">else</span> <a name="l00854"></a>00854 stream << info << errorMsg << windowId << s_seqNr << userTimestamp; <a name="l00855"></a>00855 <a name="l00856"></a>00856 <span class="keywordtype">bool</span> callOK = d->dcopClient->call( <span class="stringliteral">"kded"</span>, <span class="stringliteral">"kpasswdserver"</span>, <span class="stringliteral">"queryAuthInfo(KIO::AuthInfo, QString, long int, long int, unsigned long int)"</span>, <a name="l00857"></a>00857 params, replyType, reply ); <a name="l00858"></a>00858 <a name="l00859"></a>00859 <span class="keywordflow">if</span> (progressId) <a name="l00860"></a>00860 uiserver.setJobVisible( progressId, <span class="keyword">true</span> ); <a name="l00861"></a>00861 <a name="l00862"></a>00862 <span class="keywordflow">if</span> (!callOK) <a name="l00863"></a>00863 { <a name="l00864"></a>00864 kdWarning(7019) << <span class="stringliteral">"Can't communicate with kded_kpasswdserver!"</span> << endl; <a name="l00865"></a>00865 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00866"></a>00866 } <a name="l00867"></a>00867 <a name="l00868"></a>00868 <span class="keywordflow">if</span> ( replyType == <span class="stringliteral">"KIO::AuthInfo"</span> ) <a name="l00869"></a>00869 { <a name="l00870"></a>00870 <a class="codeRef" href="qdatastream.html">QDataStream</a> stream2( reply, IO_ReadOnly ); <a name="l00871"></a>00871 stream2 >> authResult >> s_seqNr; <a name="l00872"></a>00872 } <a name="l00873"></a>00873 <span class="keywordflow">else</span> <a name="l00874"></a>00874 { <a name="l00875"></a>00875 kdError(7019) << <span class="stringliteral">"DCOP function queryAuthInfo(...) returns "</span> <a name="l00876"></a>00876 << replyType << <span class="stringliteral">", expected KIO::AuthInfo"</span> << endl; <a name="l00877"></a>00877 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00878"></a>00878 } <a name="l00879"></a>00879 <a name="l00880"></a>00880 <span class="keywordflow">if</span> (!authResult.<a class="code" href="classKIO_1_1AuthInfo.html#a078e06e077555d8bf793643874bb05ec" title="Use this method to check if the object was modified.">isModified</a>()) <a name="l00881"></a>00881 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00882"></a>00882 <a name="l00883"></a>00883 info = authResult; <a name="l00884"></a>00884 <a name="l00885"></a>00885 kdDebug(7019) << <span class="stringliteral">"SlaveBase::openPassDlg: username="</span> << info.<a class="code" href="classKIO_1_1AuthInfo.html#abc129ff4f95d42a753c227a8923e06fe" title="This is required for caching.">username</a> << endl; <a name="l00886"></a>00886 kdDebug(7019) << <span class="stringliteral">"SlaveBase::openPassDlg: password=[hidden]"</span> << endl; <a name="l00887"></a>00887 <a name="l00888"></a>00888 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00889"></a>00889 } <a name="l00890"></a>00890 <a name="l00891"></a><a class="code" href="classKIO_1_1SlaveBase.html#af5d01ca517e03731b132bc9b2b22ca65">00891</a> <span class="keywordtype">int</span> <a class="code" href="classKIO_1_1SlaveBase.html#af5d01ca517e03731b132bc9b2b22ca65" title="Call this to show a message box from the slave.">SlaveBase::messageBox</a>( MessageBoxType type, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &text, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &caption, <a name="l00892"></a>00892 <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &buttonYes, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &buttonNo ) <a name="l00893"></a>00893 { <a name="l00894"></a>00894 <span class="keywordflow">return</span> <a class="code" href="classKIO_1_1SlaveBase.html#af5d01ca517e03731b132bc9b2b22ca65" title="Call this to show a message box from the slave.">messageBox</a>( text, type, caption, buttonYes, buttonNo, QString::null ); <a name="l00895"></a>00895 } <a name="l00896"></a>00896 <a name="l00897"></a><a class="code" href="classKIO_1_1SlaveBase.html#acdeda452b508c5092f46fb43378c84ef">00897</a> <span class="keywordtype">int</span> <a class="code" href="classKIO_1_1SlaveBase.html#af5d01ca517e03731b132bc9b2b22ca65" title="Call this to show a message box from the slave.">SlaveBase::messageBox</a>( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &text, MessageBoxType type, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &caption, <a name="l00898"></a>00898 <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &buttonYes, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &buttonNo, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &dontAskAgainName ) <a name="l00899"></a>00899 { <a name="l00900"></a>00900 kdDebug(7019) << <span class="stringliteral">"messageBox "</span> << type << <span class="stringliteral">" "</span> << text << <span class="stringliteral">" - "</span> << caption << buttonYes << buttonNo << endl; <a name="l00901"></a>00901 KIO_DATA << (Q_INT32)type << text << caption << buttonYes << buttonNo << dontAskAgainName; <a name="l00902"></a>00902 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( INF_MESSAGEBOX, data ); <a name="l00903"></a>00903 <span class="keywordflow">if</span> ( <a class="code" href="classKIO_1_1SlaveBase.html#a5303431dc9f943fcce8961011aa8f951" title="Wait for an answer to our request, until we get expected1 or expected2.">waitForAnswer</a>( CMD_MESSAGEBOXANSWER, 0, data ) != -1 ) <a name="l00904"></a>00904 { <a name="l00905"></a>00905 <a class="codeRef" href="qdatastream.html">QDataStream</a> stream( data, IO_ReadOnly ); <a name="l00906"></a>00906 <span class="keywordtype">int</span> answer; <a name="l00907"></a>00907 stream >> answer; <a name="l00908"></a>00908 kdDebug(7019) << <span class="stringliteral">"got messagebox answer"</span> << answer << endl; <a name="l00909"></a>00909 <span class="keywordflow">return</span> answer; <a name="l00910"></a>00910 } <span class="keywordflow">else</span> <a name="l00911"></a>00911 <span class="keywordflow">return</span> 0; <span class="comment">// communication failure</span> <a name="l00912"></a>00912 } <a name="l00913"></a>00913 <a name="l00914"></a><a class="code" href="classKIO_1_1SlaveBase.html#adf63a85dff9c3240a810bb3db6bc84cb">00914</a> <span class="keywordtype">bool</span> SlaveBase::canResume( <a class="code" href="namespaceKIO.html#a90b418366ba9052c97d4dca845026f43" title="64-bit file size">KIO::filesize_t</a> offset ) <a name="l00915"></a>00915 { <a name="l00916"></a>00916 kdDebug(7019) << <span class="stringliteral">"SlaveBase::canResume offset="</span> << <a class="code" href="namespaceKIO.html#a61e1ebe49305dcd7418b4692d56079b0" title="Converts a size to a string representation Not unlike QString::number(...)">KIO::number</a>(offset) << endl; <a name="l00917"></a>00917 d->needSendCanResume = <span class="keyword">false</span>; <a name="l00918"></a>00918 KIO_DATA << KIO_FILESIZE_T(offset); <a name="l00919"></a>00919 m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_RESUME, data ); <a name="l00920"></a>00920 <span class="keywordflow">if</span> ( offset ) <a name="l00921"></a>00921 { <a name="l00922"></a>00922 <span class="keywordtype">int</span> cmd; <a name="l00923"></a>00923 <span class="keywordflow">if</span> ( <a class="code" href="classKIO_1_1SlaveBase.html#a5303431dc9f943fcce8961011aa8f951" title="Wait for an answer to our request, until we get expected1 or expected2.">waitForAnswer</a>( CMD_RESUMEANSWER, CMD_NONE, data, &cmd ) != -1 ) <a name="l00924"></a>00924 { <a name="l00925"></a>00925 kdDebug(7019) << <span class="stringliteral">"SlaveBase::canResume returning "</span> << (cmd == CMD_RESUMEANSWER) << endl; <a name="l00926"></a>00926 <span class="keywordflow">return</span> cmd == CMD_RESUMEANSWER; <a name="l00927"></a>00927 } <span class="keywordflow">else</span> <a name="l00928"></a>00928 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00929"></a>00929 } <a name="l00930"></a>00930 <span class="keywordflow">else</span> <span class="comment">// No resuming possible -> no answer to wait for</span> <a name="l00931"></a>00931 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00932"></a>00932 } <a name="l00933"></a>00933 <a name="l00934"></a>00934 <a name="l00935"></a>00935 <a name="l00936"></a><a class="code" href="classKIO_1_1SlaveBase.html#a5303431dc9f943fcce8961011aa8f951">00936</a> <span class="keywordtype">int</span> <a class="code" href="classKIO_1_1SlaveBase.html#a5303431dc9f943fcce8961011aa8f951" title="Wait for an answer to our request, until we get expected1 or expected2.">SlaveBase::waitForAnswer</a>( <span class="keywordtype">int</span> expected1, <span class="keywordtype">int</span> expected2, <a class="codeRef" href="qbytearray.html">QByteArray</a> & data, <span class="keywordtype">int</span> *pCmd ) <a name="l00937"></a>00937 { <a name="l00938"></a>00938 <span class="keywordtype">int</span> cmd, result; <a name="l00939"></a>00939 <span class="keywordflow">for</span> (;;) <a name="l00940"></a>00940 { <a name="l00941"></a>00941 result = m_pConnection-><a class="code" href="classKIO_1_1Connection.html#a484f8dada25c7d8315e1964b419278e7" title="Receive data.">read</a>( &cmd, data ); <a name="l00942"></a>00942 <span class="keywordflow">if</span> ( result == -1 ) <a name="l00943"></a>00943 { <a name="l00944"></a>00944 kdDebug(7019) << <span class="stringliteral">"SlaveBase::waitForAnswer has read error."</span> << endl; <a name="l00945"></a>00945 <span class="keywordflow">return</span> -1; <a name="l00946"></a>00946 } <a name="l00947"></a>00947 <span class="keywordflow">if</span> ( cmd == expected1 || cmd == expected2 ) <a name="l00948"></a>00948 { <a name="l00949"></a>00949 <span class="keywordflow">if</span> ( pCmd ) *pCmd = cmd; <a name="l00950"></a>00950 <span class="keywordflow">return</span> result; <a name="l00951"></a>00951 } <a name="l00952"></a>00952 <span class="keywordflow">if</span> ( isSubCommand(cmd) ) <a name="l00953"></a>00953 { <a name="l00954"></a>00954 dispatch( cmd, data ); <a name="l00955"></a>00955 } <a name="l00956"></a>00956 <span class="keywordflow">else</span> <a name="l00957"></a>00957 { <a name="l00958"></a>00958 kdWarning() << <span class="stringliteral">"Got cmd "</span> << cmd << <span class="stringliteral">" while waiting for an answer!"</span> << endl; <a name="l00959"></a>00959 } <a name="l00960"></a>00960 } <a name="l00961"></a>00961 } <a name="l00962"></a>00962 <a name="l00963"></a>00963 <a name="l00964"></a><a class="code" href="classKIO_1_1SlaveBase.html#a916816221119da4dda1f78b33f5748ae">00964</a> <span class="keywordtype">int</span> <a class="code" href="classKIO_1_1SlaveBase.html#a916816221119da4dda1f78b33f5748ae" title="Read data send by the job, after a dataReq.">SlaveBase::readData</a>( <a class="codeRef" href="qbytearray.html">QByteArray</a> &buffer) <a name="l00965"></a>00965 { <a name="l00966"></a>00966 <span class="keywordtype">int</span> result = <a class="code" href="classKIO_1_1SlaveBase.html#a5303431dc9f943fcce8961011aa8f951" title="Wait for an answer to our request, until we get expected1 or expected2.">waitForAnswer</a>( MSG_DATA, 0, buffer ); <a name="l00967"></a>00967 <span class="comment">//kdDebug(7019) << "readData: length = " << result << " " << endl;</span> <a name="l00968"></a>00968 <span class="keywordflow">return</span> result; <a name="l00969"></a>00969 } <a name="l00970"></a>00970 <a name="l00971"></a><a class="code" href="classKIO_1_1SlaveBase.html#a3682aa116f843af6c60211e7eddd3c60">00971</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#a3682aa116f843af6c60211e7eddd3c60" title="This function sets a timeout of timeout seconds and calls special(data) when the timeout occurs as if...">SlaveBase::setTimeoutSpecialCommand</a>(<span class="keywordtype">int</span> timeout, <span class="keyword">const</span> <a class="codeRef" href="qbytearray.html">QByteArray</a> &data) <a name="l00972"></a>00972 { <a name="l00973"></a>00973 <span class="keywordflow">if</span> (timeout > 0) <a name="l00974"></a>00974 d->timeout = time(0)+(time_t)timeout; <a name="l00975"></a>00975 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (timeout == 0) <a name="l00976"></a>00976 d->timeout = 1; <span class="comment">// Immediate timeout</span> <a name="l00977"></a>00977 <span class="keywordflow">else</span> <a name="l00978"></a>00978 d->timeout = 0; <span class="comment">// Canceled</span> <a name="l00979"></a>00979 <a name="l00980"></a>00980 d->timeoutData = <a class="code" href="classKIO_1_1SlaveBase.html#aad44fb5ca04e9fc4d9f4e0ecebde3736" title="Sends data in the slave to the job (i.e.">data</a>; <a name="l00981"></a>00981 } <a name="l00982"></a>00982 <a name="l00983"></a>00983 <span class="keywordtype">void</span> SlaveBase::dispatch( <span class="keywordtype">int</span> command, <span class="keyword">const</span> <a class="codeRef" href="qbytearray.html">QByteArray</a> &data ) <a name="l00984"></a>00984 { <a name="l00985"></a>00985 <a class="codeRef" href="qdatastream.html">QDataStream</a> stream( data, IO_ReadOnly ); <a name="l00986"></a>00986 <a name="l00987"></a>00987 KURL url; <a name="l00988"></a>00988 <span class="keywordtype">int</span> i; <a name="l00989"></a>00989 <a name="l00990"></a>00990 <span class="keywordflow">switch</span>( command ) { <a name="l00991"></a>00991 <span class="keywordflow">case</span> CMD_HOST: { <a name="l00992"></a>00992 <span class="comment">// Reset s_seqNr, see kpasswdserver/DESIGN</span> <a name="l00993"></a>00993 s_seqNr = 0; <a name="l00994"></a>00994 <a class="codeRef" href="qstring.html">QString</a> passwd; <a name="l00995"></a>00995 <a class="codeRef" href="qstring.html">QString</a> host, user; <a name="l00996"></a>00996 stream >> host >> i >> user >> passwd; <a name="l00997"></a>00997 <a class="code" href="classKIO_1_1SlaveBase.html#aa317789e4dfdbff726a6fd547b24dcab" title="Set the host.">setHost</a>( host, i, user, passwd ); <a name="l00998"></a>00998 } <a name="l00999"></a>00999 <span class="keywordflow">break</span>; <a name="l01000"></a>01000 <span class="keywordflow">case</span> CMD_CONNECT: <a name="l01001"></a>01001 <a class="code" href="classKIO_1_1SlaveBase.html#a4cc0692960fe1c11d318c4ef272e332c" title="Opens the connection (forced) When this function gets called the slave is operating in connection-ori...">openConnection</a>( ); <a name="l01002"></a>01002 <span class="keywordflow">break</span>; <a name="l01003"></a>01003 <span class="keywordflow">case</span> CMD_DISCONNECT: <a name="l01004"></a>01004 <a class="code" href="classKIO_1_1SlaveBase.html#acb154c5b60f5dd11de7df4acf20572f0" title="Closes the connection (forced) Called when the application disconnects the slave to close any open ne...">closeConnection</a>( ); <a name="l01005"></a>01005 <span class="keywordflow">break</span>; <a name="l01006"></a>01006 <span class="keywordflow">case</span> CMD_SLAVE_STATUS: <a name="l01007"></a>01007 <a class="code" href="classKIO_1_1SlaveBase.html#ac42712ebb2fad1237050521c2d9bafe7" title="Called to get the status of the slave.">slave_status</a>(); <a name="l01008"></a>01008 <span class="keywordflow">break</span>; <a name="l01009"></a>01009 <span class="keywordflow">case</span> CMD_SLAVE_CONNECT: <a name="l01010"></a>01010 { <a name="l01011"></a>01011 d->onHold = <span class="keyword">false</span>; <a name="l01012"></a>01012 <a class="codeRef" href="qstring.html">QString</a> app_socket; <a name="l01013"></a>01013 <a class="codeRef" href="qdatastream.html">QDataStream</a> stream( data, IO_ReadOnly); <a name="l01014"></a>01014 stream >> app_socket; <a name="l01015"></a>01015 appconn-><a class="code" href="classKIO_1_1Connection.html#a3c61c23fd90df8b110026e26a5c46b2f" title="Sends/queues the given command to be sent.">send</a>( MSG_SLAVE_ACK ); <a name="l01016"></a>01016 disconnectSlave(); <a name="l01017"></a>01017 mConnectedToApp = <span class="keyword">true</span>; <a name="l01018"></a>01018 <a class="code" href="classKIO_1_1SlaveBase.html#a985d6642f4d331032d02b69c19399313" title="internal function to connect a slave to/ disconnect from either the slave pool or the application...">connectSlave</a>(app_socket); <a name="l01019"></a>01019 } <span class="keywordflow">break</span>; <a name="l01020"></a>01020 <span class="keywordflow">case</span> CMD_SLAVE_HOLD: <a name="l01021"></a>01021 { <a name="l01022"></a>01022 KURL url; <a name="l01023"></a>01023 <a class="codeRef" href="qdatastream.html">QDataStream</a> stream( data, IO_ReadOnly); <a name="l01024"></a>01024 stream >> url; <a name="l01025"></a>01025 d->onHoldUrl = url; <a name="l01026"></a>01026 d->onHold = <span class="keyword">true</span>; <a name="l01027"></a>01027 disconnectSlave(); <a name="l01028"></a>01028 mConnectedToApp = <span class="keyword">false</span>; <a name="l01029"></a>01029 <span class="comment">// Do not close connection!</span> <a name="l01030"></a>01030 <a class="code" href="classKIO_1_1SlaveBase.html#a985d6642f4d331032d02b69c19399313" title="internal function to connect a slave to/ disconnect from either the slave pool or the application...">connectSlave</a>(mPoolSocket); <a name="l01031"></a>01031 } <span class="keywordflow">break</span>; <a name="l01032"></a>01032 <span class="keywordflow">case</span> CMD_REPARSECONFIGURATION: <a name="l01033"></a>01033 <a class="code" href="classKIO_1_1SlaveBase.html#a36448af5d807bdcd01143d4394287f1a" title="Called by the scheduler to tell the slave that the configuration changed (i.e.">reparseConfiguration</a>(); <a name="l01034"></a>01034 <span class="keywordflow">break</span>; <a name="l01035"></a>01035 <span class="keywordflow">case</span> CMD_CONFIG: <a name="l01036"></a>01036 stream >> d->configData; <a name="l01037"></a>01037 <span class="preprocessor">#ifdef Q_OS_UNIX //TODO: not yet available on WIN32</span> <a name="l01038"></a>01038 <span class="preprocessor"></span> KSocks::setConfig(d->config); <a name="l01039"></a>01039 <span class="preprocessor">#endif</span> <a name="l01040"></a>01040 <span class="preprocessor"></span> <span class="keyword">delete</span> d->remotefile; <a name="l01041"></a>01041 d->remotefile = 0; <a name="l01042"></a>01042 <span class="keywordflow">break</span>; <a name="l01043"></a>01043 <span class="keywordflow">case</span> CMD_GET: <a name="l01044"></a>01044 { <a name="l01045"></a>01045 stream >> url; <a name="l01046"></a>01046 <span class="keyword">get</span>( url ); <a name="l01047"></a>01047 } <span class="keywordflow">break</span>; <a name="l01048"></a>01048 <span class="keywordflow">case</span> CMD_PUT: <a name="l01049"></a>01049 { <a name="l01050"></a>01050 <span class="keywordtype">int</span> permissions; <a name="l01051"></a>01051 Q_INT8 iOverwrite, iResume; <a name="l01052"></a>01052 stream >> url >> iOverwrite >> iResume >> permissions; <a name="l01053"></a>01053 <span class="keywordtype">bool</span> overwrite = ( iOverwrite != 0 ); <a name="l01054"></a>01054 <span class="keywordtype">bool</span> resume = ( iResume != 0 ); <a name="l01055"></a>01055 <a name="l01056"></a>01056 <span class="comment">// Remember that we need to send canResume(), TransferJob is expecting</span> <a name="l01057"></a>01057 <span class="comment">// it. Well, in theory this shouldn't be done if resume is true.</span> <a name="l01058"></a>01058 <span class="comment">// (the resume bool is currently unused)</span> <a name="l01059"></a>01059 d->needSendCanResume = <span class="keyword">true</span> <span class="comment">/* !resume */</span>; <a name="l01060"></a>01060 <a name="l01061"></a>01061 <a class="code" href="classKIO_1_1SlaveBase.html#ab1207ed4e333ca0ed6377771fd21cf3d" title="put, i.e.">put</a>( url, permissions, overwrite, resume); <a name="l01062"></a>01062 } <span class="keywordflow">break</span>; <a name="l01063"></a>01063 <span class="keywordflow">case</span> CMD_STAT: <a name="l01064"></a>01064 stream >> url; <a name="l01065"></a>01065 <a class="code" href="classKIO_1_1SlaveBase.html#a20aa8e52e38af682a80f1ef2016c83c9" title="Finds all details for one file or directory.">stat</a>( url ); <a name="l01066"></a>01066 <span class="keywordflow">break</span>; <a name="l01067"></a>01067 <span class="keywordflow">case</span> CMD_MIMETYPE: <a name="l01068"></a>01068 stream >> url; <a name="l01069"></a>01069 <a class="code" href="classKIO_1_1SlaveBase.html#a46a782488ab6760075fd2cd686133cc6" title="Finds mimetype for one file or directory.">mimetype</a>( url ); <a name="l01070"></a>01070 <span class="keywordflow">break</span>; <a name="l01071"></a>01071 <span class="keywordflow">case</span> CMD_LISTDIR: <a name="l01072"></a>01072 stream >> url; <a name="l01073"></a>01073 <a class="code" href="classKIO_1_1SlaveBase.html#acfee67cfc81e5d2fae72cb20c2707d4b" title="Lists the contents of url.">listDir</a>( url ); <a name="l01074"></a>01074 <span class="keywordflow">break</span>; <a name="l01075"></a>01075 <span class="keywordflow">case</span> CMD_MKDIR: <a name="l01076"></a>01076 stream >> url >> i; <a name="l01077"></a>01077 <a class="code" href="classKIO_1_1SlaveBase.html#a32a4d92f51277226fd9588324d52c888" title="Create a directory.">mkdir</a>( url, i ); <a name="l01078"></a>01078 <span class="keywordflow">break</span>; <a name="l01079"></a>01079 <span class="keywordflow">case</span> CMD_RENAME: <a name="l01080"></a>01080 { <a name="l01081"></a>01081 Q_INT8 iOverwrite; <a name="l01082"></a>01082 KURL url2; <a name="l01083"></a>01083 stream >> url >> url2 >> iOverwrite; <a name="l01084"></a>01084 <span class="keywordtype">bool</span> overwrite = (iOverwrite != 0); <a name="l01085"></a>01085 <a class="code" href="classKIO_1_1SlaveBase.html#aab6a8ec51a45397af85637b10d1a38ba" title="Rename oldname into newname.">rename</a>( url, url2, overwrite ); <a name="l01086"></a>01086 } <span class="keywordflow">break</span>; <a name="l01087"></a>01087 <span class="keywordflow">case</span> CMD_SYMLINK: <a name="l01088"></a>01088 { <a name="l01089"></a>01089 Q_INT8 iOverwrite; <a name="l01090"></a>01090 <a class="codeRef" href="qstring.html">QString</a> target; <a name="l01091"></a>01091 stream >> target >> url >> iOverwrite; <a name="l01092"></a>01092 <span class="keywordtype">bool</span> overwrite = (iOverwrite != 0); <a name="l01093"></a>01093 <a class="code" href="classKIO_1_1SlaveBase.html#ad827dec554072a0d34c8fa6763282394" title="Creates a symbolic link named dest, pointing to target, which may be a relative or an absolute path...">symlink</a>( target, url, overwrite ); <a name="l01094"></a>01094 } <span class="keywordflow">break</span>; <a name="l01095"></a>01095 <span class="keywordflow">case</span> CMD_COPY: <a name="l01096"></a>01096 { <a name="l01097"></a>01097 <span class="keywordtype">int</span> permissions; <a name="l01098"></a>01098 Q_INT8 iOverwrite; <a name="l01099"></a>01099 KURL url2; <a name="l01100"></a>01100 stream >> url >> url2 >> permissions >> iOverwrite; <a name="l01101"></a>01101 <span class="keywordtype">bool</span> overwrite = (iOverwrite != 0); <a name="l01102"></a>01102 <a class="code" href="classKIO_1_1SlaveBase.html#a9a39d9ce598d112c8ab625dd241f99ab" title="Copy src into dest.">copy</a>( url, url2, permissions, overwrite ); <a name="l01103"></a>01103 } <span class="keywordflow">break</span>; <a name="l01104"></a>01104 <span class="keywordflow">case</span> CMD_DEL: <a name="l01105"></a>01105 { <a name="l01106"></a>01106 Q_INT8 isFile; <a name="l01107"></a>01107 stream >> url >> isFile; <a name="l01108"></a>01108 <a class="code" href="classKIO_1_1SlaveBase.html#adf9650287055c9238a1ddfba037bdf2a" title="Delete a file or directory.">del</a>( url, isFile != 0); <a name="l01109"></a>01109 } <span class="keywordflow">break</span>; <a name="l01110"></a>01110 <span class="keywordflow">case</span> CMD_CHMOD: <a name="l01111"></a>01111 stream >> url >> i; <a name="l01112"></a>01112 <a class="code" href="classKIO_1_1SlaveBase.html#a83365ff7f5ca58c9e3ec0c223b8d6038" title="Change permissions on path The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD.">chmod</a>( url, i); <a name="l01113"></a>01113 <span class="keywordflow">break</span>; <a name="l01114"></a>01114 <span class="keywordflow">case</span> CMD_SPECIAL: <a name="l01115"></a>01115 <a class="code" href="classKIO_1_1SlaveBase.html#aa53ecc830f2f57cde6b8c81cf3a1d14c" title="Used for any command that is specific to this slave (protocol) Examples are : HTTP POST...">special</a>( data ); <a name="l01116"></a>01116 <span class="keywordflow">break</span>; <a name="l01117"></a>01117 <span class="keywordflow">case</span> CMD_META_DATA: <a name="l01118"></a>01118 <span class="comment">//kdDebug(7019) << "(" << getpid() << ") Incoming meta-data..." << endl;</span> <a name="l01119"></a>01119 stream >> mIncomingMetaData; <a name="l01120"></a>01120 <span class="keywordflow">break</span>; <a name="l01121"></a>01121 <span class="keywordflow">case</span> CMD_SUBURL: <a name="l01122"></a>01122 stream >> url; <a name="l01123"></a>01123 <a class="code" href="classKIO_1_1SlaveBase.html#a06756e6e7741e063b18a96c9dfc3d2b5" title="Prepare slave for streaming operation.">setSubURL</a>(url); <a name="l01124"></a>01124 <span class="keywordflow">break</span>; <a name="l01125"></a>01125 <span class="keywordflow">case</span> CMD_NONE: <a name="l01126"></a>01126 fprintf(stderr, <span class="stringliteral">"Got unexpected CMD_NONE!\n"</span>); <a name="l01127"></a>01127 <span class="keywordflow">break</span>; <a name="l01128"></a>01128 <span class="keywordflow">case</span> CMD_MULTI_GET: <a name="l01129"></a>01129 <a class="code" href="classKIO_1_1SlaveBase.html#af23180c391259b8abd8e386c868cd559" title="Used for multiple get.">multiGet</a>( data ); <a name="l01130"></a>01130 <span class="keywordflow">break</span>; <a name="l01131"></a>01131 <span class="keywordflow">default</span>: <a name="l01132"></a>01132 <span class="comment">// Some command we don't understand.</span> <a name="l01133"></a>01133 <span class="comment">// Just ignore it, it may come from some future version of KDE.</span> <a name="l01134"></a>01134 <span class="keywordflow">break</span>; <a name="l01135"></a>01135 } <a name="l01136"></a>01136 } <a name="l01137"></a>01137 <a name="l01138"></a><a class="code" href="classKIO_1_1SlaveBase.html#aac3dfdf13010022d7ac020d5a252e98e">01138</a> <a class="codeRef" href="qstring.html">QString</a> <a class="code" href="classKIO_1_1SlaveBase.html#aac3dfdf13010022d7ac020d5a252e98e">SlaveBase::createAuthCacheKey</a>( <span class="keyword">const</span> KURL& url ) <a name="l01139"></a>01139 { <a name="l01140"></a>01140 <span class="keywordflow">if</span>( !url.isValid() ) <a name="l01141"></a>01141 <span class="keywordflow">return</span> QString::null; <a name="l01142"></a>01142 <a name="l01143"></a>01143 <span class="comment">// Generate the basic key sequence.</span> <a name="l01144"></a>01144 <a class="codeRef" href="qstring.html">QString</a> key = url.protocol(); <a name="l01145"></a>01145 key += <span class="charliteral">'-'</span>; <a name="l01146"></a>01146 key += url.host(); <a name="l01147"></a>01147 <span class="keywordtype">int</span> port = url.port(); <a name="l01148"></a>01148 <span class="keywordflow">if</span>( port ) <a name="l01149"></a>01149 { <a name="l01150"></a>01150 key += <span class="charliteral">':'</span>; <a name="l01151"></a>01151 key += <a class="code" href="namespaceKIO.html#a61e1ebe49305dcd7418b4692d56079b0" title="Converts a size to a string representation Not unlike QString::number(...)">QString::number</a>(port); <a name="l01152"></a>01152 } <a name="l01153"></a>01153 <a name="l01154"></a>01154 <span class="keywordflow">return</span> key; <a name="l01155"></a>01155 } <a name="l01156"></a>01156 <a name="l01157"></a><a class="code" href="classKIO_1_1SlaveBase.html#aefa59d4b391063e96745d0d8a56389c3">01157</a> <span class="keywordtype">bool</span> <a class="code" href="classKIO_1_1SlaveBase.html#aefa59d4b391063e96745d0d8a56389c3">SlaveBase::pingCacheDaemon</a>()<span class="keyword"> const</span> <a name="l01158"></a>01158 <span class="keyword"></span>{ <a name="l01159"></a>01159 <span class="preprocessor">#ifdef Q_OS_UNIX</span> <a name="l01160"></a>01160 <span class="preprocessor"></span> <span class="comment">// TODO: Ping kded / kpasswdserver</span> <a name="l01161"></a>01161 KDEsuClient client; <a name="l01162"></a>01162 <span class="keywordtype">int</span> success = client.ping(); <a name="l01163"></a>01163 <span class="keywordflow">if</span>( success == -1 ) <a name="l01164"></a>01164 { <a name="l01165"></a>01165 success = client.startServer(); <a name="l01166"></a>01166 <span class="keywordflow">if</span>( success == -1 ) <a name="l01167"></a>01167 { <a name="l01168"></a>01168 kdDebug(7019) << <span class="stringliteral">"Cannot start a new deamon!!"</span> << endl; <a name="l01169"></a>01169 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l01170"></a>01170 } <a name="l01171"></a>01171 kdDebug(7019) << <span class="stringliteral">"Sucessfully started new cache deamon!!"</span> << endl; <a name="l01172"></a>01172 } <a name="l01173"></a>01173 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l01174"></a>01174 <span class="preprocessor">#else</span> <a name="l01175"></a>01175 <span class="preprocessor"></span> <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l01176"></a>01176 <span class="preprocessor">#endif</span> <a name="l01177"></a>01177 <span class="preprocessor"></span>} <a name="l01178"></a>01178 <a name="l01179"></a><a class="code" href="classKIO_1_1SlaveBase.html#aee686a3ca9912f27dd4d7b6654a851f0">01179</a> <span class="keywordtype">bool</span> <a class="code" href="classKIO_1_1SlaveBase.html#aee686a3ca9912f27dd4d7b6654a851f0" title="Checks for cached authentication based on parameters given by info.">SlaveBase::checkCachedAuthentication</a>( <a class="code" href="classKIO_1_1AuthInfo.html" title="This class is intended to make it easier to prompt for, cache and retrieve authorization information...">AuthInfo</a>& info ) <a name="l01180"></a>01180 { <a name="l01181"></a>01181 <a class="codeRef" href="qcstring.html">QCString</a> replyType; <a name="l01182"></a>01182 <a class="codeRef" href="qbytearray.html">QByteArray</a> params; <a name="l01183"></a>01183 <a class="codeRef" href="qbytearray.html">QByteArray</a> reply; <a name="l01184"></a>01184 <a class="code" href="classKIO_1_1AuthInfo.html" title="This class is intended to make it easier to prompt for, cache and retrieve authorization information...">AuthInfo</a> authResult; <a name="l01185"></a>01185 <span class="keywordtype">long</span> windowId = <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"window-id"</span>).<a class="codeRef" href="qstring.html#toLong">toLong</a>(); <a name="l01186"></a>01186 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> userTimestamp = <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"user-timestamp"</span>).<a class="codeRef" href="qstring.html#toULong">toULong</a>(); <a name="l01187"></a>01187 <a name="l01188"></a>01188 kdDebug(7019) << <span class="stringliteral">"SlaveBase::checkCachedAuthInfo window = "</span> << windowId << <span class="stringliteral">" url = "</span> << info.<a class="code" href="classKIO_1_1AuthInfo.html#ae39069d497447ad0ce8ba4a2c39f3d71" title="The URL for which authentication is to be stored.">url</a>.url() << endl; <a name="l01189"></a>01189 <a name="l01190"></a>01190 (void) <a class="code" href="classKIO_1_1SlaveBase.html#a8bc430ce9cae11652fe5dad601789d02" title="Return the dcop client used by this slave.">dcopClient</a>(); <span class="comment">// Make sure to have a dcop client.</span> <a name="l01191"></a>01191 <a name="l01192"></a>01192 <a class="codeRef" href="qdatastream.html">QDataStream</a> stream(params, IO_WriteOnly); <a name="l01193"></a>01193 stream << info << windowId << userTimestamp; <a name="l01194"></a>01194 <a name="l01195"></a>01195 <span class="keywordflow">if</span> ( !d->dcopClient->call( <span class="stringliteral">"kded"</span>, <span class="stringliteral">"kpasswdserver"</span>, <span class="stringliteral">"checkAuthInfo(KIO::AuthInfo, long int, unsigned long int)"</span>, <a name="l01196"></a>01196 params, replyType, reply ) ) <a name="l01197"></a>01197 { <a name="l01198"></a>01198 kdWarning(7019) << <span class="stringliteral">"Can't communicate with kded_kpasswdserver!"</span> << endl; <a name="l01199"></a>01199 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l01200"></a>01200 } <a name="l01201"></a>01201 <a name="l01202"></a>01202 <span class="keywordflow">if</span> ( replyType == <span class="stringliteral">"KIO::AuthInfo"</span> ) <a name="l01203"></a>01203 { <a name="l01204"></a>01204 <a class="codeRef" href="qdatastream.html">QDataStream</a> stream2( reply, IO_ReadOnly ); <a name="l01205"></a>01205 stream2 >> authResult; <a name="l01206"></a>01206 } <a name="l01207"></a>01207 <span class="keywordflow">else</span> <a name="l01208"></a>01208 { <a name="l01209"></a>01209 kdError(7019) << <span class="stringliteral">"DCOP function checkAuthInfo(...) returns "</span> <a name="l01210"></a>01210 << replyType << <span class="stringliteral">", expected KIO::AuthInfo"</span> << endl; <a name="l01211"></a>01211 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l01212"></a>01212 } <a name="l01213"></a>01213 <span class="keywordflow">if</span> (!authResult.<a class="code" href="classKIO_1_1AuthInfo.html#a078e06e077555d8bf793643874bb05ec" title="Use this method to check if the object was modified.">isModified</a>()) <a name="l01214"></a>01214 { <a name="l01215"></a>01215 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l01216"></a>01216 } <a name="l01217"></a>01217 <a name="l01218"></a>01218 info = authResult; <a name="l01219"></a>01219 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l01220"></a>01220 } <a name="l01221"></a>01221 <a name="l01222"></a><a class="code" href="classKIO_1_1SlaveBase.html#a55551c0a0f2e5df188188e93f923c366">01222</a> <span class="keywordtype">bool</span> <a class="code" href="classKIO_1_1SlaveBase.html#a55551c0a0f2e5df188188e93f923c366" title="Explicitly store authentication information.">SlaveBase::cacheAuthentication</a>( <span class="keyword">const</span> <a class="code" href="classKIO_1_1AuthInfo.html" title="This class is intended to make it easier to prompt for, cache and retrieve authorization information...">AuthInfo</a>& info ) <a name="l01223"></a>01223 { <a name="l01224"></a>01224 <a class="codeRef" href="qbytearray.html">QByteArray</a> params; <a name="l01225"></a>01225 <span class="keywordtype">long</span> windowId = <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"window-id"</span>).<a class="codeRef" href="qstring.html#toLong">toLong</a>(); <a name="l01226"></a>01226 <a name="l01227"></a>01227 (void) <a class="code" href="classKIO_1_1SlaveBase.html#a8bc430ce9cae11652fe5dad601789d02" title="Return the dcop client used by this slave.">dcopClient</a>(); <span class="comment">// Make sure to have a dcop client.</span> <a name="l01228"></a>01228 <a name="l01229"></a>01229 <a class="codeRef" href="qdatastream.html">QDataStream</a> stream(params, IO_WriteOnly); <a name="l01230"></a>01230 stream << info << windowId; <a name="l01231"></a>01231 <a name="l01232"></a>01232 d->dcopClient->send( <span class="stringliteral">"kded"</span>, <span class="stringliteral">"kpasswdserver"</span>, <span class="stringliteral">"addAuthInfo(KIO::AuthInfo, long int)"</span>, params ); <a name="l01233"></a>01233 <a name="l01234"></a>01234 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l01235"></a>01235 } <a name="l01236"></a>01236 <a name="l01237"></a><a class="code" href="classKIO_1_1SlaveBase.html#a4b6837dedec839a8f5a0806cfcf0dc4f">01237</a> <span class="keywordtype">int</span> <a class="code" href="classKIO_1_1SlaveBase.html#a4b6837dedec839a8f5a0806cfcf0dc4f">SlaveBase::connectTimeout</a>() <a name="l01238"></a>01238 { <a name="l01239"></a>01239 <span class="keywordtype">bool</span> ok; <a name="l01240"></a>01240 <a class="codeRef" href="qstring.html">QString</a> tmp = <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"ConnectTimeout"</span>); <a name="l01241"></a>01241 <span class="keywordtype">int</span> result = tmp.<a class="codeRef" href="qstring.html#toInt">toInt</a>(&ok); <a name="l01242"></a>01242 <span class="keywordflow">if</span> (ok) <a name="l01243"></a>01243 <span class="keywordflow">return</span> result; <a name="l01244"></a>01244 <span class="keywordflow">return</span> DEFAULT_CONNECT_TIMEOUT; <a name="l01245"></a>01245 } <a name="l01246"></a>01246 <a name="l01247"></a><a class="code" href="classKIO_1_1SlaveBase.html#a02b257fae6b0a4e3a5a7b01887426fec">01247</a> <span class="keywordtype">int</span> <a class="code" href="classKIO_1_1SlaveBase.html#a02b257fae6b0a4e3a5a7b01887426fec">SlaveBase::proxyConnectTimeout</a>() <a name="l01248"></a>01248 { <a name="l01249"></a>01249 <span class="keywordtype">bool</span> ok; <a name="l01250"></a>01250 <a class="codeRef" href="qstring.html">QString</a> tmp = <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"ProxyConnectTimeout"</span>); <a name="l01251"></a>01251 <span class="keywordtype">int</span> result = tmp.<a class="codeRef" href="qstring.html#toInt">toInt</a>(&ok); <a name="l01252"></a>01252 <span class="keywordflow">if</span> (ok) <a name="l01253"></a>01253 <span class="keywordflow">return</span> result; <a name="l01254"></a>01254 <span class="keywordflow">return</span> DEFAULT_PROXY_CONNECT_TIMEOUT; <a name="l01255"></a>01255 } <a name="l01256"></a>01256 <a name="l01257"></a>01257 <a name="l01258"></a><a class="code" href="classKIO_1_1SlaveBase.html#a6283e14c737a1144bb1feba44f7b4fcd">01258</a> <span class="keywordtype">int</span> <a class="code" href="classKIO_1_1SlaveBase.html#a6283e14c737a1144bb1feba44f7b4fcd">SlaveBase::responseTimeout</a>() <a name="l01259"></a>01259 { <a name="l01260"></a>01260 <span class="keywordtype">bool</span> ok; <a name="l01261"></a>01261 <a class="codeRef" href="qstring.html">QString</a> tmp = <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"ResponseTimeout"</span>); <a name="l01262"></a>01262 <span class="keywordtype">int</span> result = tmp.<a class="codeRef" href="qstring.html#toInt">toInt</a>(&ok); <a name="l01263"></a>01263 <span class="keywordflow">if</span> (ok) <a name="l01264"></a>01264 <span class="keywordflow">return</span> result; <a name="l01265"></a>01265 <span class="keywordflow">return</span> DEFAULT_RESPONSE_TIMEOUT; <a name="l01266"></a>01266 } <a name="l01267"></a>01267 <a name="l01268"></a>01268 <a name="l01269"></a><a class="code" href="classKIO_1_1SlaveBase.html#abba229df038eb2c52a21127a971f7a5b">01269</a> <span class="keywordtype">int</span> <a class="code" href="classKIO_1_1SlaveBase.html#abba229df038eb2c52a21127a971f7a5b">SlaveBase::readTimeout</a>() <a name="l01270"></a>01270 { <a name="l01271"></a>01271 <span class="keywordtype">bool</span> ok; <a name="l01272"></a>01272 <a class="codeRef" href="qstring.html">QString</a> tmp = <a class="code" href="classKIO_1_1SlaveBase.html#a505bfa093dbbd2d9718d0dbe06c671e9" title="Queries for config/meta-data send by the application to the slave.">metaData</a>(<span class="stringliteral">"ReadTimeout"</span>); <a name="l01273"></a>01273 <span class="keywordtype">int</span> result = tmp.<a class="codeRef" href="qstring.html#toInt">toInt</a>(&ok); <a name="l01274"></a>01274 <span class="keywordflow">if</span> (ok) <a name="l01275"></a>01275 <span class="keywordflow">return</span> result; <a name="l01276"></a>01276 <span class="keywordflow">return</span> DEFAULT_READ_TIMEOUT; <a name="l01277"></a>01277 } <a name="l01278"></a>01278 <a name="l01279"></a><a class="code" href="classKIO_1_1SlaveBase.html#ad0ed5cda199cafe99743b3efcc24aa92">01279</a> <span class="keywordtype">bool</span> <a class="code" href="classKIO_1_1SlaveBase.html#ad0ed5cda199cafe99743b3efcc24aa92" title="If your ioslave was killed by a signal, wasKilled() returns true.">SlaveBase::wasKilled</a>()<span class="keyword"> const</span> <a name="l01280"></a>01280 <span class="keyword"></span>{ <a name="l01281"></a>01281 <span class="keywordflow">return</span> d->wasKilled; <a name="l01282"></a>01282 } <a name="l01283"></a>01283 <a name="l01284"></a><a class="code" href="classKIO_1_1SlaveBase.html#adec67d7af5a083429029c47dc02fc488">01284</a> <span class="keywordtype">void</span> <a class="code" href="classKIO_1_1SlaveBase.html#adec67d7af5a083429029c47dc02fc488" title="Internally used.">SlaveBase::setKillFlag</a>() <a name="l01285"></a>01285 { <a name="l01286"></a>01286 d->wasKilled=<span class="keyword">true</span>; <a name="l01287"></a>01287 } <a name="l01288"></a>01288 <a name="l01289"></a>01289 <span class="keywordtype">void</span> SlaveBase::virtual_hook( <span class="keywordtype">int</span>, <span class="keywordtype">void</span>* ) <a name="l01290"></a>01290 { <span class="comment">/*BASE::virtual_hook( id, data );*/</span> } <a name="l01291"></a>01291 </pre></div></div> </div> </div></div> </td> </tr> <tr> <td valign="top" id="leftmenu" width="25%"> <a name="navigation"></a> <div class="menu_box"><h2>kio/kio</h2> <div class="nav_list"> <ul><li><a href="index.html">Main Page</a></li><li><a href="modules.html">Modules</a></li><li><a href="namespaces.html">Namespace List</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="namespacemembers.html">Namespace Members</a></li><li><a href="functions.html">Class Members</a></li><li><a href="pages.html">Related Pages</a></li></ul> <!-- <h2>Class Picker</h2> <div style="text-align: center;"> <form name="guideform"> <select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value"> <option value="annotated.html">-- Choose --</option> <option value="classKACL.html">kacl</option>, <option value="classKAr.html">kar</option>, <option value="classKArchive.html">karchive</option>, <option value="classKArchiveDirectory.html">karchivedirectory</option>, <option value="classKArchiveEntry.html">karchiveentry</option>, <option value="classKArchiveFile.html">karchivefile</option>, <option value="classKAutoMount.html">kautomount</option>, <option value="classKAutoUnmount.html">kautounmount</option>, <option value="classKDataTool.html">kdatatool</option>, <option value="classKDataToolAction.html">kdatatoolaction</option>, <option value="classKDataToolInfo.html">kdatatoolinfo</option>, <option value="classKDCOPServiceStarter.html">kdcopservicestarter</option>, <option value="classKDEDesktopMimeType.html">kdedesktopmimetype</option>, <option value="classKDirLister.html">kdirlister</option>, <option value="classKDirNotify.html">kdirnotify</option>, <option value="classKDirWatch.html">kdirwatch</option>, <option value="classKEMailSettings.html">kemailsettings</option>, <option value="classKExecMimeType.html">kexecmimetype</option>, <option value="classKFileFilter.html">kfilefilter</option>, <option value="classKFileItem.html">kfileitem</option>, <option value="classKFileMetaInfo.html">kfilemetainfo</option>, <option value="classKFileMetaInfoGroup.html">kfilemetainfogroup</option>, <option value="classKFileMetaInfoItem.html">kfilemetainfoitem</option>, <option value="classKFileMimeTypeInfo.html">kfilemimetypeinfo</option>, <option value="classKFileMimeTypeInfo_1_1GroupInfo.html">kfilemimetypeinfo::groupinfo</option>, <option value="classKFileMimeTypeInfo_1_1ItemInfo.html">kfilemimetypeinfo::iteminfo</option>, <option value="classKFilePlugin.html">kfileplugin</option>, <option value="classKFileShare.html">kfileshare</option>, <option value="classKFilterBase.html">kfilterbase</option>, <option value="classKFilterDev.html">kfilterdev</option>, <option value="classKFolderType.html">kfoldertype</option>, <option value="classKImageIO.html">kimageio</option>, <option value="classKIO_1_1AuthInfo.html">kio::authinfo</option>, <option value="classKIO_1_1ChmodJob.html">kio::chmodjob</option>, <option value="classKIO_1_1Connection.html">kio::connection</option>, <option value="classKIO_1_1CopyJob.html">kio::copyjob</option>, <option value="classKIO_1_1DataProtocol.html">kio::dataprotocol</option>, <option value="classKIO_1_1DataSlave.html">kio::dataslave</option>, <option value="classKIO_1_1DavJob.html">kio::davjob</option>, <option value="classKIO_1_1DeleteJob.html">kio::deletejob</option>, <option value="classKIO_1_1FileCopyJob.html">kio::filecopyjob</option>, <option value="classKIO_1_1ForwardingSlaveBase.html">kio::forwardingslavebase</option>, <option value="classKIO_1_1Job.html">kio::job</option>, <option value="classKIO_1_1ListJob.html">kio::listjob</option>, <option value="classKIO_1_1MetaData.html">kio::metadata</option>, <option value="classKIO_1_1MetaInfoJob.html">kio::metainfojob</option>, <option value="classKIO_1_1MimetypeJob.html">kio::mimetypejob</option>, <option value="classKIO_1_1MkdirJob.html">kio::mkdirjob</option>, <option value="classKIO_1_1MultiGetJob.html">kio::multigetjob</option>, <option value="classKIO_1_1NetAccess.html">kio::netaccess</option>, <option value="classKIO_1_1NetRC.html">kio::netrc</option>, <option value="classKIO_1_1PasswordDialog.html">kio::passworddialog</option>, <option value="classKIO_1_1PreviewJob.html">kio::previewjob</option>, <option value="classKIO_1_1ProgressBase.html">kio::progressbase</option>, <option value="classKIO_1_1RenameDlg.html">kio::renamedlg</option>, <option value="classKIO_1_1Scheduler.html">kio::scheduler</option>, <option value="classKIO_1_1SimpleJob.html">kio::simplejob</option>, <option value="classKIO_1_1Slave.html">kio::slave</option>, <option value="classKIO_1_1SlaveBase.html">kio::slavebase</option>, <option value="classKIO_1_1SlaveConfig.html">kio::slaveconfig</option>, <option value="classKIO_1_1SlaveInterface.html">kio::slaveinterface</option>, <option value="classKIO_1_1StatJob.html">kio::statjob</option>, <option value="classKIO_1_1StatusbarProgress.html">kio::statusbarprogress</option>, <option value="classKIO_1_1StoredTransferJob.html">kio::storedtransferjob</option>, <option value="classKIO_1_1TCPSlaveBase.html">kio::tcpslavebase</option>, <option value="classKIO_1_1TransferJob.html">kio::transferjob</option>, <option value="classKLimitedIODevice.html">klimitediodevice</option>, <option value="classKMimeMagic.html">kmimemagic</option>, <option value="classKMimeMagicResult.html">kmimemagicresult</option>, <option value="classKMimeType.html">kmimetype</option>, <option value="classKMimeTypeChooser.html">kmimetypechooser</option>, <option value="classKMimeTypeChooserDialog.html">kmimetypechooserdialog</option>, <option value="classKMimeTypeResolver.html">kmimetyperesolver</option>, <option value="classKNFSShare.html">knfsshare</option>, <option value="classKOCRDialog.html">kocrdialog</option>, <option value="classKOCRDialogFactory.html">kocrdialogfactory</option>, <option value="classKOpenWithHandler.html">kopenwithhandler</option>, <option value="classKProtocolInfo.html">kprotocolinfo</option>, <option value="classKProtocolManager.html">kprotocolmanager</option>, <option value="classKRemoteEncoding.html">kremoteencoding</option>, <option value="classKRun.html">krun</option>, <option value="classKSambaShare.html">ksambashare</option>, <option value="classKScanDialog.html">kscandialog</option>, <option value="classKScanDialogFactory.html">kscandialogfactory</option>, <option value="classKService.html">kservice</option>, <option value="classKServiceGroup.html">kservicegroup</option>, <option value="classKServiceOffer.html">kserviceoffer</option>, <option value="classKServiceType.html">kservicetype</option>, <option value="classKServiceTypeProfile.html">kservicetypeprofile</option>, <option value="classKShellCompletion.html">kshellcompletion</option>, <option value="classKShred.html">kshred</option>, <option value="classKSimpleFileFilter.html">ksimplefilefilter</option>, <option value="classKTar.html">ktar</option>, <option value="classKTrader.html">ktrader</option>, <option value="classKURIFilter.html">kurifilter</option>, <option value="classKURIFilterData.html">kurifilterdata</option>, <option value="classKURIFilterPlugin.html">kurifilterplugin</option>, <option value="classKURIFilterPluginList.html">kurifilterpluginlist</option>, <option value="classKURLCompletion.html">kurlcompletion</option>, <option value="classKURLPixmapProvider.html">kurlpixmapprovider</option>, <option value="classKZip.html">kzip</option>, <option value="classObserver.html">observer</option>, <option value="classRenameDlgPlugin.html">renamedlgplugin</option>, <option value="classThumbCreator.html">thumbcreator</option>, </select> </form> </div> --> </div></div> <div class="menu_box"><h2>API Dox</h2> <div class="nav_list"> <ul> <li><a href="../../../arts/html/index.html">arts</a></li><li><a href="../../../dcop/html/index.html">dcop</a></li><li><a href="../../../dnssd/html/index.html">dnssd</a></li><li><a href="../../../interfaces/html/index.html">interfaces</a></li><li> <a href="../../../interfaces/kimproxy/interface/html/index.html">interface</a></li><li> <a href="../../../interfaces/kimproxy/library/html/index.html">library</a></li><li> <a href="../../../interfaces/kspeech/html/index.html">kspeech</a></li><li> <a href="../../../interfaces/ktexteditor/html/index.html">ktexteditor</a></li><li><a href="../../../kabc/html/index.html">kabc</a></li><li><a href="../../../kate/html/index.html">kate</a></li><li><a href="../../../kcmshell/html/index.html">kcmshell</a></li><li><a href="../../../kdecore/html/index.html">kdecore</a></li><li><a href="../../../kded/html/index.html">kded</a></li><li><a href="../../../kdefx/html/index.html">kdefx</a></li><li><a href="../../../kdeprint/html/index.html">kdeprint</a></li><li><a href="../../../kdesu/html/index.html">kdesu</a></li><li><a href="../../../kdeui/html/index.html">kdeui</a></li><li><a href="../../../kdoctools/html/index.html">kdoctools</a></li><li><a href="../../../khtml/html/index.html">khtml</a></li><li><a href="../../../kimgio/html/index.html">kimgio</a></li><li><a href="../../../kinit/html/index.html">kinit</a></li><li><a href="../../../kio/html/index.html">kio</a></li><li> <a href="../../../kio/bookmarks/html/index.html">bookmarks</a></li><li> <a href="../../../kio/httpfilter/html/index.html">httpfilter</a></li><li> <a href="../../../kio/kfile/html/index.html">kfile</a></li><li> <a href="../../../kio/kio/html/index.html">kio</a></li><li> <a href="../../../kio/kioexec/html/index.html">kioexec</a></li><li> <a href="../../../kio/kpasswdserver/html/index.html">kpasswdserver</a></li><li> <a href="../../../kio/kssl/html/index.html">kssl</a></li><li><a href="../../../kioslave/html/index.html">kioslave</a></li><li> <a href="../../../kioslave/http/html/index.html">http</a></li><li><a href="../../../kjs/html/index.html">kjs</a></li><li><a href="../../../kmdi/html/index.html">kmdi</a></li><li> <a href="../../../kmdi/kmdi/html/index.html">kmdi</a></li><li><a href="../../../knewstuff/html/index.html">knewstuff</a></li><li><a href="../../../kparts/html/index.html">kparts</a></li><li><a href="../../../kresources/html/index.html">kresources</a></li><li><a href="../../../kspell2/html/index.html">kspell2</a></li><li><a href="../../../kunittest/html/index.html">kunittest</a></li><li><a href="../../../kutils/html/index.html">kutils</a></li><li><a href="../../../kwallet/html/index.html">kwallet</a></li><li><a href="../../../libkmid/html/index.html">libkmid</a></li><li><a href="../../../libkscreensaver/html/index.html">libkscreensaver</a></li> </ul></div></div> </td> </tr> </table> <span class="doNotDisplay"> <a href="http://www.kde.org/" accesskey="8">KDE Home</a> | <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> | <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a> </span> <div style="height: 8px"></div> <div id="footer"> <div id="footer_left"> Maintained by <a href="mailto:groot@kde.org">Adriaan de Groot</a> and <a href="mailto:winter@kde.org">Allen Winter</a>. <br/> KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> | <a href="http://www.kde.org/contact/impressum.php">Legal</a> </div> <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div> </div> <!-- WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL BE BLOCKED INSTANTLY AND PERMANENTLY! <a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a> WARNING END --> </body> </html>