• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kio/kio
 

kio/kio

  • kio
  • kio
slavebase.cpp
1 /*
2  *
3  * This file is part of the KDE libraries
4  * Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
5  * Copyright (c) 2000 David Faure <faure@kde.org>
6  * Copyright (c) 2000 Stephan Kulow <coolo@kde.org>
7  *
8  * $Id$
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License version 2 as published by the Free Software Foundation.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public License
20  * along with this library; see the file COPYING.LIB. If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  *
24  **/
25 
26 #include "slavebase.h"
27 
28 #include <config.h>
29 
30 #include <sys/time.h>
31 #ifdef HAVE_SYS_SELECT_H
32 #include <sys/select.h> // Needed on some systems.
33 #endif
34 
35 #include <assert.h>
36 #include <kdebug.h>
37 #include <stdlib.h>
38 #include <errno.h>
39 #include <unistd.h>
40 #include <signal.h>
41 #include <time.h>
42 
43 #include <tqfile.h>
44 
45 #include <dcopclient.h>
46 
47 #include <kapplication.h>
48 #include <ksock.h>
49 #include <kcrash.h>
50 #include <kdesu/client.h>
51 #include <klocale.h>
52 #include <ksocks.h>
53 
54 #include "kremoteencoding.h"
55 
56 #include "kio/slavebase.h"
57 #include "kio/connection.h"
58 #include "kio/ioslave_defaults.h"
59 #include "kio/slaveinterface.h"
60 
61 #include "uiserver_stub.h"
62 
63 using namespace KIO;
64 
65 template class TQPtrList<TQValueList<UDSAtom> >;
66 typedef TQValueList<TQCString> AuthKeysList;
67 typedef TQMap<TQString,TQCString> AuthKeysMap;
68 #define KIO_DATA TQByteArray data; TQDataStream stream( data, IO_WriteOnly ); stream
69 #define KIO_FILESIZE_T(x) (unsigned long)(x & 0xffffffff) << (unsigned long)(x >> 32)
70 
71 namespace KIO {
72 
73 class SlaveBaseConfig : public KConfigBase
74 {
75 public:
76  SlaveBaseConfig(SlaveBase *_slave)
77  : slave(_slave) { }
78 
79  bool internalHasGroup(const TQCString &) const { qWarning("hasGroup(const TQCString &)");
80 return false; }
81 
82  TQStringList groupList() const { return TQStringList(); }
83 
84  TQMap<TQString,TQString> entryMap(const TQString &group) const
85  { Q_UNUSED(group); return TQMap<TQString,TQString>(); }
86 
87  void reparseConfiguration() { }
88 
89  KEntryMap internalEntryMap( const TQString &pGroup) const { Q_UNUSED(pGroup); return KEntryMap(); }
90 
91  KEntryMap internalEntryMap() const { return KEntryMap(); }
92 
93  void putData(const KEntryKey &_key, const KEntry&_data, bool _checkGroup)
94  { Q_UNUSED(_key); Q_UNUSED(_data); Q_UNUSED(_checkGroup); }
95 
96  KEntry lookupData(const KEntryKey &_key) const
97  {
98  KEntry entry;
99  TQString value = slave->metaData(_key.c_key);
100  if (!value.isNull())
101  entry.mValue = value.utf8();
102  return entry;
103  }
104 protected:
105  SlaveBase *slave;
106 };
107 
108 
109 class SlaveBasePrivate {
110 public:
111  TQString slaveid;
112  bool resume:1;
113  bool needSendCanResume:1;
114  bool onHold:1;
115  bool wasKilled:1;
116  MetaData configData;
117  SlaveBaseConfig *config;
118  KURL onHoldUrl;
119 
120  struct timeval last_tv;
121  KIO::filesize_t totalSize;
122  KIO::filesize_t sentListEntries;
123  DCOPClient *dcopClient;
124  KRemoteEncoding *remotefile;
125  time_t timeout;
126  TQByteArray timeoutData;
127 };
128 
129 }
130 
131 static SlaveBase *globalSlave;
132 long SlaveBase::s_seqNr;
133 
134 static volatile bool slaveWriteError = false;
135 
136 static const char *s_protocol;
137 
138 #ifdef Q_OS_UNIX
139 static void genericsig_handler(int sigNumber)
140 {
141  signal(sigNumber,SIG_IGN);
142  //WABA: Don't do anything that requires malloc, we can deadlock on it since
143  //a SIGTERM signal can come in while we are in malloc/free.
144  //kdDebug()<<"kioslave : exiting due to signal "<<sigNumber<<endl;
145  //set the flag which will be checked in dispatchLoop() and which *should* be checked
146  //in lengthy operations in the various slaves
147  if (globalSlave!=0)
148  globalSlave->setKillFlag();
149  signal(SIGALRM,SIG_DFL);
150  alarm(5); //generate an alarm signal in 5 seconds, in this time the slave has to exit
151 }
152 #endif
153 
155 
156 SlaveBase::SlaveBase( const TQCString &protocol,
157  const TQCString &pool_socket,
158  const TQCString &app_socket )
159  : mProtocol(protocol), m_pConnection(0),
160  mPoolSocket( TQFile::decodeName(pool_socket)),
161  mAppSocket( TQFile::decodeName(app_socket))
162 {
163  s_protocol = protocol.data();
164 #ifdef Q_OS_UNIX
165  if (!getenv("KDE_DEBUG"))
166  {
167  KCrash::setCrashHandler( sigsegv_handler );
168  signal(SIGILL,&sigsegv_handler);
169  signal(SIGTRAP,&sigsegv_handler);
170  signal(SIGABRT,&sigsegv_handler);
171  signal(SIGBUS,&sigsegv_handler);
172  signal(SIGALRM,&sigsegv_handler);
173  signal(SIGFPE,&sigsegv_handler);
174 #ifdef SIGPOLL
175  signal(SIGPOLL, &sigsegv_handler);
176 #endif
177 #ifdef SIGSYS
178  signal(SIGSYS, &sigsegv_handler);
179 #endif
180 #ifdef SIGVTALRM
181  signal(SIGVTALRM, &sigsegv_handler);
182 #endif
183 #ifdef SIGXCPU
184  signal(SIGXCPU, &sigsegv_handler);
185 #endif
186 #ifdef SIGXFSZ
187  signal(SIGXFSZ, &sigsegv_handler);
188 #endif
189  }
190 
191  struct sigaction act;
192  act.sa_handler = sigpipe_handler;
193  sigemptyset( &act.sa_mask );
194  act.sa_flags = 0;
195  sigaction( SIGPIPE, &act, 0 );
196 
197  signal(SIGINT,&genericsig_handler);
198  signal(SIGQUIT,&genericsig_handler);
199  signal(SIGTERM,&genericsig_handler);
200 #endif
201 
202  globalSlave=this;
203 
204  appconn = new Connection();
205  listEntryCurrentSize = 100;
206  struct timeval tp;
207  gettimeofday(&tp, 0);
208  listEntry_sec = tp.tv_sec;
209  listEntry_usec = tp.tv_usec;
210  mConnectedToApp = true;
211 
212  d = new SlaveBasePrivate;
213  // by kahl for netmgr (need a way to identify slaves)
214  d->slaveid = protocol;
215  d->slaveid += TQString::number(getpid());
216  d->resume = false;
217  d->needSendCanResume = false;
218  d->config = new SlaveBaseConfig(this);
219  d->onHold = false;
220  d->wasKilled=false;
221  d->last_tv.tv_sec = 0;
222  d->last_tv.tv_usec = 0;
223 // d->processed_size = 0;
224  d->totalSize=0;
225  d->sentListEntries=0;
226  d->timeout = 0;
227  connectSlave(mAppSocket);
228 
229  d->dcopClient = 0;
230  d->remotefile = 0;
231 }
232 
233 SlaveBase::~SlaveBase()
234 {
235  delete d;
236  s_protocol = "";
237 }
238 
239 DCOPClient *SlaveBase::dcopClient()
240 {
241  if (!d->dcopClient)
242  {
243  d->dcopClient = KApplication::dcopClient();
244  if (!d->dcopClient->isAttached())
245  d->dcopClient->attach();
246  d->dcopClient->setDaemonMode( true );
247  }
248  return d->dcopClient;
249 }
250 
251 void SlaveBase::dispatchLoop()
252 {
253 #ifdef Q_OS_UNIX //TODO: WIN32
254  fd_set rfds;
255  int retval;
256 
257  while (true)
258  {
259  if (d->timeout && (d->timeout < time(0)))
260  {
261  TQByteArray data = d->timeoutData;
262  d->timeout = 0;
263  d->timeoutData = TQByteArray();
264  special(data);
265  }
266  FD_ZERO(&rfds);
267 
268  assert(appconn->inited());
269  int maxfd = appconn->fd_from();
270  FD_SET(appconn->fd_from(), &rfds);
271  if( d->dcopClient )
272  {
273  FD_SET( d->dcopClient->socket(), &rfds );
274  if( d->dcopClient->socket() > maxfd )
275  maxfd = d->dcopClient->socket();
276  }
277 
278  if (!d->timeout) // we can wait forever
279  {
280  retval = select( maxfd + 1, &rfds, NULL, NULL, NULL);
281  }
282  else
283  {
284  struct timeval tv;
285  tv.tv_sec = kMax(d->timeout-time(0),(time_t) 1);
286  tv.tv_usec = 0;
287  retval = select( maxfd + 1, &rfds, NULL, NULL, &tv);
288  }
289  if ((retval>0) && FD_ISSET(appconn->fd_from(), &rfds))
290  { // dispatch application messages
291  int cmd;
292  TQByteArray data;
293  if ( appconn->read(&cmd, data) != -1 )
294  {
295  dispatch(cmd, data);
296  }
297  else // some error occurred, perhaps no more application
298  {
299  // When the app exits, should the slave be put back in the pool ?
300  if (mConnectedToApp && !mPoolSocket.isEmpty())
301  {
302  disconnectSlave();
303  mConnectedToApp = false;
304  closeConnection();
305  connectSlave(mPoolSocket);
306  }
307  else
308  {
309  return;
310  }
311  }
312  }
313  if( retval > 0 && d->dcopClient && FD_ISSET( d->dcopClient->socket(), &rfds ))
314  {
315  d->dcopClient->processSocketData( d->dcopClient->socket());
316  }
317  if ((retval<0) && (errno != EINTR))
318  {
319  kdDebug(7019) << "dispatchLoop(): select returned " << retval << " "
320  << (errno==EBADF?"EBADF":errno==EINTR?"EINTR":errno==EINVAL?"EINVAL":errno==ENOMEM?"ENOMEM":"unknown")
321  << " (" << errno << ")" << endl;
322  return;
323  }
324  //I think we get here when we were killed in dispatch() and not in select()
325  if (wasKilled())
326  {
327  kdDebug(7019)<<" dispatchLoop() slave was killed, returning"<<endl;
328  return;
329  }
330  }
331 #else
332 #error The KIO slave system only works under UNIX
333 #endif
334 }
335 
336 void SlaveBase::connectSlave(const TQString& path)
337 {
338 #ifdef Q_OS_UNIX //TODO: KSocket not yet available on WIN32
339  appconn->init(new KSocket(TQFile::encodeName(path).data()));
340  if (!appconn->inited())
341  {
342  kdDebug(7019) << "SlaveBase: failed to connect to " << path << endl;
343  exit();
344  }
345 
346  setConnection(appconn);
347 #endif
348 }
349 
350 void SlaveBase::disconnectSlave()
351 {
352  appconn->close();
353 }
354 
355 void SlaveBase::setMetaData(const TQString &key, const TQString &value)
356 {
357  mOutgoingMetaData.replace(key, value);
358 }
359 
360 TQString SlaveBase::metaData(const TQString &key) const
361 {
362  if (mIncomingMetaData.contains(key))
363  return mIncomingMetaData[key];
364  if (d->configData.contains(key))
365  return d->configData[key];
366  return TQString::null;
367 }
368 
369 bool SlaveBase::hasMetaData(const TQString &key) const
370 {
371  if (mIncomingMetaData.contains(key))
372  return true;
373  if (d->configData.contains(key))
374  return true;
375  return false;
376 }
377 
378 // ### remove the next two methods for KDE4 (they miss the const)
379 TQString SlaveBase::metaData(const TQString &key) {
380  return const_cast<const SlaveBase*>(this)->metaData( key );
381 }
382 bool SlaveBase::hasMetaData(const TQString &key) {
383  return const_cast<const SlaveBase*>(this)->hasMetaData( key );
384 }
385 
386 KConfigBase *SlaveBase::config()
387 {
388  return d->config;
389 }
390 
391 void SlaveBase::sendMetaData()
392 {
393  KIO_DATA << mOutgoingMetaData;
394 
395  slaveWriteError = false;
396  m_pConnection->send( INF_META_DATA, data );
397  if (slaveWriteError) exit();
398  mOutgoingMetaData.clear(); // Clear
399 }
400 
401 KRemoteEncoding *SlaveBase::remoteEncoding()
402 {
403  if (d->remotefile != 0)
404  return d->remotefile;
405 
406  return d->remotefile = new KRemoteEncoding(metaData("Charset").latin1());
407 }
408 
409 void SlaveBase::data( const TQByteArray &data )
410 {
411  if (!mOutgoingMetaData.isEmpty())
412  sendMetaData();
413  slaveWriteError = false;
414  m_pConnection->send( MSG_DATA, data );
415  if (slaveWriteError) exit();
416 }
417 
418 void SlaveBase::dataReq( )
419 {
420 /*
421  if (!mOutgoingMetaData.isEmpty())
422  sendMetaData();
423 */
424  if (d->needSendCanResume)
425  canResume(0);
426  m_pConnection->send( MSG_DATA_REQ );
427 }
428 
429 void SlaveBase::error( int _errid, const TQString &_text )
430 {
431  mIncomingMetaData.clear(); // Clear meta data
432  mOutgoingMetaData.clear();
433  KIO_DATA << (TQ_INT32) _errid << _text;
434 
435  m_pConnection->send( MSG_ERROR, data );
436  //reset
437  listEntryCurrentSize = 100;
438  d->sentListEntries=0;
439  d->totalSize=0;
440 }
441 
442 void SlaveBase::connected()
443 {
444  slaveWriteError = false;
445  m_pConnection->send( MSG_CONNECTED );
446  if (slaveWriteError) exit();
447 }
448 
449 void SlaveBase::finished()
450 {
451  mIncomingMetaData.clear(); // Clear meta data
452  if (!mOutgoingMetaData.isEmpty())
453  sendMetaData();
454  m_pConnection->send( MSG_FINISHED );
455 
456  // reset
457  listEntryCurrentSize = 100;
458  d->sentListEntries=0;
459  d->totalSize=0;
460 }
461 
462 void SlaveBase::needSubURLData()
463 {
464  m_pConnection->send( MSG_NEED_SUBURL_DATA );
465 }
466 
467 void SlaveBase::slaveStatus( const TQString &host, bool connected )
468 {
469  pid_t pid = getpid();
470  TQ_INT8 b = connected ? 1 : 0;
471  KIO_DATA << pid << mProtocol << host << b;
472  if (d->onHold)
473  stream << d->onHoldUrl;
474  m_pConnection->send( MSG_SLAVE_STATUS, data );
475 }
476 
477 void SlaveBase::canResume()
478 {
479  m_pConnection->send( MSG_CANRESUME );
480 }
481 
482 void SlaveBase::totalSize( KIO::filesize_t _bytes )
483 {
484  KIO_DATA << KIO_FILESIZE_T(_bytes);
485  slaveWriteError = false;
486  m_pConnection->send( INF_TOTAL_SIZE, data );
487  if (slaveWriteError) exit();
488 
489  //this one is usually called before the first item is listed in listDir()
490  struct timeval tp;
491  gettimeofday(&tp, 0);
492  listEntry_sec = tp.tv_sec;
493  listEntry_usec = tp.tv_usec;
494  d->totalSize=_bytes;
495  d->sentListEntries=0;
496 }
497 
498 void SlaveBase::processedSize( KIO::filesize_t _bytes )
499 {
500  bool emitSignal=false;
501  struct timeval tv;
502  int gettimeofday_res=gettimeofday( &tv, 0L );
503 
504  if( _bytes == d->totalSize )
505  emitSignal=true;
506  else if ( gettimeofday_res == 0 ) {
507  time_t msecdiff = 2000;
508  if (d->last_tv.tv_sec) {
509  // Compute difference, in ms
510  msecdiff = 1000 * ( tv.tv_sec - d->last_tv.tv_sec );
511  time_t usecdiff = tv.tv_usec - d->last_tv.tv_usec;
512  if ( usecdiff < 0 ) {
513  msecdiff--;
514  msecdiff += 1000;
515  }
516  msecdiff += usecdiff / 1000;
517  }
518  emitSignal=msecdiff >= 100; // emit size 10 times a second
519  }
520 
521  if( emitSignal ) {
522  KIO_DATA << KIO_FILESIZE_T(_bytes);
523  slaveWriteError = false;
524  m_pConnection->send( INF_PROCESSED_SIZE, data );
525  if (slaveWriteError) exit();
526  if ( gettimeofday_res == 0 ) {
527  d->last_tv.tv_sec = tv.tv_sec;
528  d->last_tv.tv_usec = tv.tv_usec;
529  }
530  }
531 // d->processed_size = _bytes;
532 }
533 
534 void SlaveBase::processedPercent( float /* percent */ )
535 {
536  kdDebug(7019) << "SlaveBase::processedPercent: STUB" << endl;
537 }
538 
539 
540 void SlaveBase::speed( unsigned long _bytes_per_second )
541 {
542  KIO_DATA << (TQ_UINT32) _bytes_per_second;
543  slaveWriteError = false;
544  m_pConnection->send( INF_SPEED, data );
545  if (slaveWriteError) exit();
546 }
547 
548 void SlaveBase::redirection( const KURL& _url )
549 {
550  KIO_DATA << _url;
551  m_pConnection->send( INF_REDIRECTION, data );
552 }
553 
554 void SlaveBase::errorPage()
555 {
556  m_pConnection->send( INF_ERROR_PAGE );
557 }
558 
559 static bool isSubCommand(int cmd)
560 {
561  return ( (cmd == CMD_REPARSECONFIGURATION) ||
562  (cmd == CMD_META_DATA) ||
563  (cmd == CMD_CONFIG) ||
564  (cmd == CMD_SUBURL) ||
565  (cmd == CMD_SLAVE_STATUS) ||
566  (cmd == CMD_SLAVE_CONNECT) ||
567  (cmd == CMD_SLAVE_HOLD) ||
568  (cmd == CMD_MULTI_GET));
569 }
570 
571 void SlaveBase::mimeType( const TQString &_type)
572 {
573  // kdDebug(7019) << "(" << getpid() << ") SlaveBase::mimeType '" << _type << "'" << endl;
574  int cmd;
575  do
576  {
577  // Send the meta-data each time we send the mime-type.
578  if (!mOutgoingMetaData.isEmpty())
579  {
580  // kdDebug(7019) << "(" << getpid() << ") mimeType: emitting meta data" << endl;
581  KIO_DATA << mOutgoingMetaData;
582  m_pConnection->send( INF_META_DATA, data );
583  }
584  KIO_DATA << _type;
585  m_pConnection->send( INF_MIME_TYPE, data );
586  while(true)
587  {
588  cmd = 0;
589  if ( m_pConnection->read( &cmd, data ) == -1 ) {
590  kdDebug(7019) << "SlaveBase: mimetype: read error" << endl;
591  exit();
592  }
593  // kdDebug(7019) << "(" << getpid() << ") Slavebase: mimetype got " << cmd << endl;
594  if ( cmd == CMD_HOST) // Ignore.
595  continue;
596  if ( isSubCommand(cmd) )
597  {
598  dispatch( cmd, data );
599  continue; // Disguised goto
600  }
601  break;
602  }
603  }
604  while (cmd != CMD_NONE);
605  mOutgoingMetaData.clear();
606 }
607 
608 void SlaveBase::exit()
609 {
610  this->~SlaveBase();
611  ::exit(255);
612 }
613 
614 void SlaveBase::warning( const TQString &_msg)
615 {
616  KIO_DATA << _msg;
617  m_pConnection->send( INF_WARNING, data );
618 }
619 
620 void SlaveBase::infoMessage( const TQString &_msg)
621 {
622  KIO_DATA << _msg;
623  m_pConnection->send( INF_INFOMESSAGE, data );
624 }
625 
626 bool SlaveBase::requestNetwork(const TQString& host)
627 {
628  KIO_DATA << host << d->slaveid;
629  m_pConnection->send( MSG_NET_REQUEST, data );
630 
631  if ( waitForAnswer( INF_NETWORK_STATUS, 0, data ) != -1 )
632  {
633  bool status;
634  TQDataStream stream( data, IO_ReadOnly );
635  stream >> status;
636  return status;
637  } else
638  return false;
639 }
640 
641 void SlaveBase::dropNetwork(const TQString& host)
642 {
643  KIO_DATA << host << d->slaveid;
644  m_pConnection->send( MSG_NET_DROP, data );
645 }
646 
647 void SlaveBase::statEntry( const UDSEntry& entry )
648 {
649  KIO_DATA << entry;
650  slaveWriteError = false;
651  m_pConnection->send( MSG_STAT_ENTRY, data );
652  if (slaveWriteError) exit();
653 }
654 
655 void SlaveBase::listEntry( const UDSEntry& entry, bool _ready )
656 {
657  static struct timeval tp;
658  static const int maximum_updatetime = 300;
659  static const int minimum_updatetime = 100;
660 
661  if (!_ready) {
662  pendingListEntries.append(entry);
663 
664  if (pendingListEntries.count() > listEntryCurrentSize) {
665  gettimeofday(&tp, 0);
666 
667  long diff = ((tp.tv_sec - listEntry_sec) * 1000000 +
668  tp.tv_usec - listEntry_usec) / 1000;
669  if (diff==0) diff=1;
670 
671  if (diff > maximum_updatetime) {
672  listEntryCurrentSize = listEntryCurrentSize * 3 / 4;
673  _ready = true;
674  }
675 //if we can send all list entries of this dir which have not yet been sent
676 //within maximum_updatetime, then make listEntryCurrentSize big enough for all of them
677  else if (((pendingListEntries.count()*maximum_updatetime)/diff) > (d->totalSize-d->sentListEntries))
678  listEntryCurrentSize=d->totalSize-d->sentListEntries+1;
679 //if we are below minimum_updatetime, estimate how much we will get within
680 //maximum_updatetime
681  else if (diff < minimum_updatetime)
682  listEntryCurrentSize = (pendingListEntries.count() * maximum_updatetime) / diff;
683  else
684  _ready=true;
685  }
686  }
687  if (_ready) { // may happen when we started with !ready
688  listEntries( pendingListEntries );
689  pendingListEntries.clear();
690 
691  gettimeofday(&tp, 0);
692  listEntry_sec = tp.tv_sec;
693  listEntry_usec = tp.tv_usec;
694  }
695 }
696 
697 void SlaveBase::listEntries( const UDSEntryList& list )
698 {
699  KIO_DATA << (TQ_UINT32)list.count();
700  UDSEntryListConstIterator it = list.begin();
701  UDSEntryListConstIterator end = list.end();
702  for (; it != end; ++it)
703  stream << *it;
704  slaveWriteError = false;
705  m_pConnection->send( MSG_LIST_ENTRIES, data);
706  if (slaveWriteError) exit();
707  d->sentListEntries+=(uint)list.count();
708 }
709 
710 void SlaveBase::sendAuthenticationKey( const TQCString& key,
711  const TQCString& group,
712  bool keepPass )
713 {
714  KIO_DATA << key << group << keepPass;
715  m_pConnection->send( MSG_AUTH_KEY, data );
716 }
717 
718 void SlaveBase::delCachedAuthentication( const TQString& key )
719 {
720  KIO_DATA << key.utf8() ;
721  m_pConnection->send( MSG_DEL_AUTH_KEY, data );
722 }
723 
724 void SlaveBase::sigsegv_handler(int sig)
725 {
726 #ifdef Q_OS_UNIX
727  signal(sig,SIG_DFL); // Next one kills
728 
729  //Kill us if we deadlock
730  signal(SIGALRM,SIG_DFL);
731  alarm(5); //generate an alarm signal in 5 seconds, in this time the slave has to exit
732 
733  // Debug and printf should be avoided because they might
734  // call malloc.. and get in a nice recursive malloc loop
735  char buffer[120];
736  snprintf(buffer, sizeof(buffer), "kioslave: ####### CRASH ###### protocol = %s pid = %d signal = %d\n", s_protocol, getpid(), sig);
737  if (write(2, buffer, strlen(buffer)) >= 0) {
738 #ifdef SECURE_DEBUG
739  kdBacktraceFD();
740 #else // SECURE_DEBUG
741  // Screw the malloc issue! We want nice demangled backtraces!
742  // Anyway we are not supposed to go into infinite loop because next signal
743  // will kill us. If you are unlucky and there is a second crash during
744  // backtrase in your system, you can define SECURE_DEBUG to avoid it
745 
746  // Extra sync here so we are sure even if the backtrace will fail
747  // we will pass at least some crash message.
748  fsync(2);
749  TQString backtrace = kdBacktrace();
750  if (write(2, backtrace.ascii(), backtrace.length()) < 0) {
751  // FIXME
752  // Could not write crash information
753  }
754 #endif // SECURE_DEBUG
755  }
756  ::exit(1);
757 #endif
758 }
759 
760 void SlaveBase::sigpipe_handler (int)
761 {
762  // We ignore a SIGPIPE in slaves.
763  // A SIGPIPE can happen in two cases:
764  // 1) Communication error with application.
765  // 2) Communication error with network.
766  slaveWriteError = true;
767 
768  // Don't add anything else here, especially no debug output
769 }
770 
771 void SlaveBase::setHost(TQString const &, int, TQString const &, TQString const &)
772 {
773 }
774 
775 void SlaveBase::openConnection(void)
776 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CONNECT)); }
777 void SlaveBase::closeConnection(void)
778 { } // No response!
779 void SlaveBase::stat(KURL const &)
780 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_STAT)); }
781 void SlaveBase::put(KURL const &, int, bool, bool)
782 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_PUT)); }
783 void SlaveBase::special(const TQByteArray &)
784 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SPECIAL)); }
785 void SlaveBase::listDir(KURL const &)
786 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_LISTDIR)); }
787 void SlaveBase::get(KURL const & )
788 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_GET)); }
789 void SlaveBase::mimetype(KURL const &url)
790 { get(url); }
791 void SlaveBase::rename(KURL const &, KURL const &, bool)
792 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_RENAME)); }
793 void SlaveBase::symlink(TQString const &, KURL const &, bool)
794 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SYMLINK)); }
795 void SlaveBase::copy(KURL const &, KURL const &, int, bool)
796 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_COPY)); }
797 void SlaveBase::del(KURL const &, bool)
798 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_DEL)); }
799 void SlaveBase::mkdir(KURL const &, int)
800 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_MKDIR)); }
801 void SlaveBase::chmod(KURL const &, int)
802 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CHMOD)); }
803 void SlaveBase::setSubURL(KURL const &)
804 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SUBURL)); }
805 void SlaveBase::multiGet(const TQByteArray &)
806 { error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_MULTI_GET)); }
807 
808 
809 void SlaveBase::slave_status()
810 { slaveStatus( TQString::null, false ); }
811 
812 void SlaveBase::reparseConfiguration()
813 {
814 }
815 
816 bool SlaveBase::dispatch()
817 {
818  assert( m_pConnection );
819 
820  int cmd;
821  TQByteArray data;
822  if ( m_pConnection->read( &cmd, data ) == -1 )
823  {
824  kdDebug(7019) << "SlaveBase::dispatch() has read error." << endl;
825  return false;
826  }
827 
828  dispatch( cmd, data );
829  return true;
830 }
831 
832 bool SlaveBase::openPassDlg( AuthInfo& info )
833 {
834  return openPassDlg(info, TQString::null);
835 }
836 
837 bool SlaveBase::openPassDlg( AuthInfo& info, const TQString &errorMsg )
838 {
839  TQCString replyType;
840  TQByteArray params;
841  TQByteArray reply;
842  AuthInfo authResult;
843  long windowId = metaData("window-id").toLong();
844  long progressId = metaData("progress-id").toLong();
845  unsigned long userTimestamp = metaData("user-timestamp").toULong();
846 
847  kdDebug(7019) << "SlaveBase::openPassDlg window-id=" << windowId << " progress-id=" << progressId << endl;
848 
849  (void) dcopClient(); // Make sure to have a dcop client.
850 
851  UIServer_stub uiserver( "kio_uiserver", "UIServer" );
852  if (progressId)
853  uiserver.setJobVisible( progressId, false );
854 
855  TQDataStream stream(params, IO_WriteOnly);
856 
857  if (metaData("no-auth-prompt").lower() == "true")
858  stream << info << TQString("<NoAuthPrompt>") << windowId << s_seqNr << userTimestamp;
859  else
860  stream << info << errorMsg << windowId << s_seqNr << userTimestamp;
861 
862  bool callOK = d->dcopClient->call( "kded", "kpasswdserver", "queryAuthInfo(KIO::AuthInfo, TQString, long int, long int, unsigned long int)",
863  params, replyType, reply );
864 
865  if (progressId)
866  uiserver.setJobVisible( progressId, true );
867 
868  if (!callOK)
869  {
870  kdWarning(7019) << "Can't communicate with kded_kpasswdserver (openPassDlg)!" << endl;
871  return false;
872  }
873 
874  if ( replyType == "KIO::AuthInfo" )
875  {
876  TQDataStream stream2( reply, IO_ReadOnly );
877  stream2 >> authResult >> s_seqNr;
878  }
879  else
880  {
881  kdError(7019) << "DCOP function queryAuthInfo(...) returns "
882  << replyType << ", expected KIO::AuthInfo" << endl;
883  return false;
884  }
885 
886  if (!authResult.isModified())
887  return false;
888 
889  info = authResult;
890 
891  kdDebug(7019) << "SlaveBase::openPassDlg: username=" << info.username << endl;
892  kdDebug(7019) << "SlaveBase::openPassDlg: password=[hidden]" << endl;
893 
894  return true;
895 }
896 
897 int SlaveBase::messageBox( MessageBoxType type, const TQString &text, const TQString &caption,
898  const TQString &buttonYes, const TQString &buttonNo )
899 {
900  return messageBox( text, type, caption, buttonYes, buttonNo, TQString::null );
901 }
902 
903 int SlaveBase::messageBox( const TQString &text, MessageBoxType type, const TQString &caption,
904  const TQString &buttonYes, const TQString &buttonNo, const TQString &dontAskAgainName )
905 {
906  kdDebug(7019) << "messageBox " << type << " " << text << " - " << caption << buttonYes << buttonNo << endl;
907  KIO_DATA << (TQ_INT32)type << text << caption << buttonYes << buttonNo << dontAskAgainName;
908  m_pConnection->send( INF_MESSAGEBOX, data );
909  if ( waitForAnswer( CMD_MESSAGEBOXANSWER, 0, data ) != -1 )
910  {
911  TQDataStream stream( data, IO_ReadOnly );
912  int answer;
913  stream >> answer;
914  kdDebug(7019) << "got messagebox answer" << answer << endl;
915  return answer;
916  } else
917  return 0; // communication failure
918 }
919 
920 bool SlaveBase::canResume( KIO::filesize_t offset )
921 {
922  kdDebug(7019) << "SlaveBase::canResume offset=" << KIO::number(offset) << endl;
923  d->needSendCanResume = false;
924  KIO_DATA << KIO_FILESIZE_T(offset);
925  m_pConnection->send( MSG_RESUME, data );
926  if ( offset )
927  {
928  int cmd;
929  if ( waitForAnswer( CMD_RESUMEANSWER, CMD_NONE, data, &cmd ) != -1 )
930  {
931  kdDebug(7019) << "SlaveBase::canResume returning " << (cmd == CMD_RESUMEANSWER) << endl;
932  return cmd == CMD_RESUMEANSWER;
933  } else
934  return false;
935  }
936  else // No resuming possible -> no answer to wait for
937  return true;
938 }
939 
940 
941 
942 int SlaveBase::waitForAnswer( int expected1, int expected2, TQByteArray & data, int *pCmd )
943 {
944  int cmd, result;
945  for (;;)
946  {
947  result = m_pConnection->read( &cmd, data );
948  if ( result == -1 )
949  {
950  kdDebug(7019) << "SlaveBase::waitForAnswer has read error." << endl;
951  return -1;
952  }
953  if ( cmd == expected1 || cmd == expected2 )
954  {
955  if ( pCmd ) *pCmd = cmd;
956  return result;
957  }
958  if ( isSubCommand(cmd) )
959  {
960  dispatch( cmd, data );
961  }
962  else
963  {
964  kdWarning() << "Got cmd " << cmd << " while waiting for an answer!" << endl;
965  }
966  }
967 }
968 
969 
970 int SlaveBase::readData( TQByteArray &buffer)
971 {
972  int result = waitForAnswer( MSG_DATA, 0, buffer );
973  //kdDebug(7019) << "readData: length = " << result << " " << endl;
974  return result;
975 }
976 
977 void SlaveBase::setTimeoutSpecialCommand(int timeout, const TQByteArray &data)
978 {
979  if (timeout > 0)
980  d->timeout = time(0)+(time_t)timeout;
981  else if (timeout == 0)
982  d->timeout = 1; // Immediate timeout
983  else
984  d->timeout = 0; // Canceled
985 
986  d->timeoutData = data;
987 }
988 
989 void SlaveBase::dispatch( int command, const TQByteArray &data )
990 {
991  TQDataStream stream( data, IO_ReadOnly );
992 
993  KURL url;
994  int i;
995 
996  switch( command ) {
997  case CMD_HOST: {
998  // Reset s_seqNr, see kpasswdserver/DESIGN
999  s_seqNr = 0;
1000  TQString passwd;
1001  TQString host, user;
1002  stream >> host >> i >> user >> passwd;
1003  setHost( host, i, user, passwd );
1004  }
1005  break;
1006  case CMD_CONNECT:
1007  openConnection( );
1008  break;
1009  case CMD_DISCONNECT:
1010  closeConnection( );
1011  break;
1012  case CMD_SLAVE_STATUS:
1013  slave_status();
1014  break;
1015  case CMD_SLAVE_CONNECT:
1016  {
1017  d->onHold = false;
1018  TQString app_socket;
1019  TQDataStream stream( data, IO_ReadOnly);
1020  stream >> app_socket;
1021  appconn->send( MSG_SLAVE_ACK );
1022  disconnectSlave();
1023  mConnectedToApp = true;
1024  connectSlave(app_socket);
1025  } break;
1026  case CMD_SLAVE_HOLD:
1027  {
1028  KURL url;
1029  TQDataStream stream( data, IO_ReadOnly);
1030  stream >> url;
1031  d->onHoldUrl = url;
1032  d->onHold = true;
1033  disconnectSlave();
1034  mConnectedToApp = false;
1035  // Do not close connection!
1036  connectSlave(mPoolSocket);
1037  } break;
1038  case CMD_REPARSECONFIGURATION:
1039  reparseConfiguration();
1040  break;
1041  case CMD_CONFIG:
1042  stream >> d->configData;
1043 #ifdef Q_OS_UNIX //TODO: not yet available on WIN32
1044  KSocks::setConfig(d->config);
1045 #endif
1046  delete d->remotefile;
1047  d->remotefile = 0;
1048  break;
1049  case CMD_GET:
1050  {
1051  stream >> url;
1052  get( url );
1053  } break;
1054  case CMD_PUT:
1055  {
1056  int permissions;
1057  TQ_INT8 iOverwrite, iResume;
1058  stream >> url >> iOverwrite >> iResume >> permissions;
1059  bool overwrite = ( iOverwrite != 0 );
1060  bool resume = ( iResume != 0 );
1061 
1062  // Remember that we need to send canResume(), TransferJob is expecting
1063  // it. Well, in theory this shouldn't be done if resume is true.
1064  // (the resume bool is currently unused)
1065  d->needSendCanResume = true /* !resume */;
1066 
1067  put( url, permissions, overwrite, resume);
1068  } break;
1069  case CMD_STAT:
1070  stream >> url;
1071  stat( url );
1072  break;
1073  case CMD_MIMETYPE:
1074  stream >> url;
1075  mimetype( url );
1076  break;
1077  case CMD_LISTDIR:
1078  stream >> url;
1079  listDir( url );
1080  break;
1081  case CMD_MKDIR:
1082  stream >> url >> i;
1083  mkdir( url, i );
1084  break;
1085  case CMD_RENAME:
1086  {
1087  TQ_INT8 iOverwrite;
1088  KURL url2;
1089  stream >> url >> url2 >> iOverwrite;
1090  bool overwrite = (iOverwrite != 0);
1091  rename( url, url2, overwrite );
1092  } break;
1093  case CMD_SYMLINK:
1094  {
1095  TQ_INT8 iOverwrite;
1096  TQString target;
1097  stream >> target >> url >> iOverwrite;
1098  bool overwrite = (iOverwrite != 0);
1099  symlink( target, url, overwrite );
1100  } break;
1101  case CMD_COPY:
1102  {
1103  int permissions;
1104  TQ_INT8 iOverwrite;
1105  KURL url2;
1106  stream >> url >> url2 >> permissions >> iOverwrite;
1107  bool overwrite = (iOverwrite != 0);
1108  copy( url, url2, permissions, overwrite );
1109  } break;
1110  case CMD_DEL:
1111  {
1112  TQ_INT8 isFile;
1113  stream >> url >> isFile;
1114  del( url, isFile != 0);
1115  } break;
1116  case CMD_CHMOD:
1117  stream >> url >> i;
1118  chmod( url, i);
1119  break;
1120  case CMD_SPECIAL:
1121  special( data );
1122  break;
1123  case CMD_META_DATA:
1124  //kdDebug(7019) << "(" << getpid() << ") Incoming meta-data..." << endl;
1125  stream >> mIncomingMetaData;
1126  break;
1127  case CMD_SUBURL:
1128  stream >> url;
1129  setSubURL(url);
1130  break;
1131  case CMD_NONE:
1132  fprintf(stderr, "Got unexpected CMD_NONE!\n");
1133  break;
1134  case CMD_MULTI_GET:
1135  multiGet( data );
1136  break;
1137  default:
1138  // Some command we don't understand.
1139  // Just ignore it, it may come from some future version of KDE.
1140  break;
1141  }
1142 }
1143 
1144 TQString SlaveBase::createAuthCacheKey( const KURL& url )
1145 {
1146  if( !url.isValid() )
1147  return TQString::null;
1148 
1149  // Generate the basic key sequence.
1150  TQString key = url.protocol();
1151  key += '-';
1152  key += url.host();
1153  int port = url.port();
1154  if( port )
1155  {
1156  key += ':';
1157  key += TQString::number(port);
1158  }
1159 
1160  return key;
1161 }
1162 
1163 bool SlaveBase::pingCacheDaemon() const
1164 {
1165 #ifdef Q_OS_UNIX
1166  // TODO: Ping kded / kpasswdserver
1167  KDEsuClient client;
1168  int success = client.ping();
1169  if( success == -1 )
1170  {
1171  success = client.startServer();
1172  if( success == -1 )
1173  {
1174  kdDebug(7019) << "Cannot start a new deamon!!" << endl;
1175  return false;
1176  }
1177  kdDebug(7019) << "Sucessfully started new cache deamon!!" << endl;
1178  }
1179  return true;
1180 #else
1181  return false;
1182 #endif
1183 }
1184 
1185 bool SlaveBase::checkCachedAuthentication( AuthInfo& info )
1186 {
1187  TQCString replyType;
1188  TQByteArray params;
1189  TQByteArray reply;
1190  AuthInfo authResult;
1191  long windowId = metaData("window-id").toLong();
1192  unsigned long userTimestamp = metaData("user-timestamp").toULong();
1193 
1194  kdDebug(7019) << "SlaveBase::checkCachedAuthInfo window = " << windowId << " url = " << info.url.url() << endl;
1195 
1196  (void) dcopClient(); // Make sure to have a dcop client.
1197 
1198  TQDataStream stream(params, IO_WriteOnly);
1199  stream << info << windowId << userTimestamp;
1200 
1201  if ( !d->dcopClient->call( "kded", "kpasswdserver", "checkAuthInfo(KIO::AuthInfo, long int, unsigned long int)",
1202  params, replyType, reply ) )
1203  {
1204  kdWarning(7019) << "Can't communicate with kded_kpasswdserver (checkCachedAuthentication)!" << endl;
1205  return false;
1206  }
1207 
1208  if ( replyType == "KIO::AuthInfo" )
1209  {
1210  TQDataStream stream2( reply, IO_ReadOnly );
1211  stream2 >> authResult;
1212  }
1213  else
1214  {
1215  kdError(7019) << "DCOP function checkAuthInfo(...) returns "
1216  << replyType << ", expected KIO::AuthInfo" << endl;
1217  return false;
1218  }
1219  if (!authResult.isModified())
1220  {
1221  return false;
1222  }
1223 
1224  info = authResult;
1225  return true;
1226 }
1227 
1228 bool SlaveBase::cacheAuthentication( const AuthInfo& info )
1229 {
1230  TQByteArray params;
1231  long windowId = metaData("window-id").toLong();
1232 
1233  (void) dcopClient(); // Make sure to have a dcop client.
1234 
1235  TQDataStream stream(params, IO_WriteOnly);
1236  stream << info << windowId;
1237 
1238  d->dcopClient->send( "kded", "kpasswdserver", "addAuthInfo(KIO::AuthInfo, long int)", params );
1239 
1240  return true;
1241 }
1242 
1243 int SlaveBase::connectTimeout()
1244 {
1245  bool ok;
1246  TQString tmp = metaData("ConnectTimeout");
1247  int result = tmp.toInt(&ok);
1248  if (ok)
1249  return result;
1250  return DEFAULT_CONNECT_TIMEOUT;
1251 }
1252 
1253 int SlaveBase::proxyConnectTimeout()
1254 {
1255  bool ok;
1256  TQString tmp = metaData("ProxyConnectTimeout");
1257  int result = tmp.toInt(&ok);
1258  if (ok)
1259  return result;
1260  return DEFAULT_PROXY_CONNECT_TIMEOUT;
1261 }
1262 
1263 
1264 int SlaveBase::responseTimeout()
1265 {
1266  bool ok;
1267  TQString tmp = metaData("ResponseTimeout");
1268  int result = tmp.toInt(&ok);
1269  if (ok)
1270  return result;
1271  return DEFAULT_RESPONSE_TIMEOUT;
1272 }
1273 
1274 
1275 int SlaveBase::readTimeout()
1276 {
1277  bool ok;
1278  TQString tmp = metaData("ReadTimeout");
1279  int result = tmp.toInt(&ok);
1280  if (ok)
1281  return result;
1282  return DEFAULT_READ_TIMEOUT;
1283 }
1284 
1285 bool SlaveBase::wasKilled() const
1286 {
1287  return d->wasKilled;
1288 }
1289 
1290 void SlaveBase::setKillFlag()
1291 {
1292  d->wasKilled=true;
1293 }
1294 
1295 void SlaveBase::virtual_hook( int, void* )
1296 { /*BASE::virtual_hook( id, data );*/ }
1297 
KIO::SlaveBase::finished
void finished()
Call to signal successful completion of any command (besides openConnection and closeConnection) ...
Definition: slavebase.cpp:449
KIO::Connection::read
int read(int *_cmd, TQByteArray &data)
Receive data.
Definition: connection.cpp:216
KIO::put
KIO_EXPORT TransferJob * put(const KURL &url, int permissions, bool overwrite, bool resume, bool showProgressInfo=true)
Put (a.k.a.
Definition: job.cpp:1380
KIO::Slave::resume
void resume()
Resumes the operation of the attached kioslave.
Definition: slave.cpp:264
KIO::SlaveBase::requestNetwork
bool requestNetwork(const TQString &host=TQString::null)
Used by the slave to check if it can connect to a given host.
Definition: slavebase.cpp:626
KIO
A namespace for KIO globals.
Definition: authinfo.h:29
KIO::SlaveBase::setHost
virtual void setHost(const TQString &host, int port, const TQString &user, const TQString &pass)
Set the host.
Definition: slavebase.cpp:771
KIO::SlaveBase::listDir
virtual void listDir(const KURL &url)
Lists the contents of url.
Definition: slavebase.cpp:785
KIO::Slave::setHost
void setHost(const TQString &host, int port, const TQString &user, const TQString &passwd)
Set host for url.
Definition: slave.cpp:328
KIO::SlaveBase::mkdir
virtual void mkdir(const KURL &url, int permissions)
Create a directory.
Definition: slavebase.cpp:799
KIO::AuthInfo::isModified
bool isModified() const
Use this method to check if the object was modified.
Definition: authinfo.h:76
KIO::SlaveBase::errorPage
void errorPage()
Tell that we will only get an error page here.
Definition: slavebase.cpp:554
KRemoteEncoding
Allows encoding and decoding properly remote filenames into Unicode.
Definition: kremoteencoding.h:44
KIO::SlaveBase::responseTimeout
int responseTimeout()
Definition: slavebase.cpp:1264
KIO::AuthInfo
This class is intended to make it easier to prompt for, cache and retrieve authorization information...
Definition: authinfo.h:51
KIO::SlaveBase::delCachedAuthentication
void delCachedAuthentication(const TQString &key)
Definition: slavebase.cpp:718
KIO::SlaveBase::slaveStatus
void slaveStatus(const TQString &host, bool connected)
Used to report the status of the slave.
Definition: slavebase.cpp:467
KIO::SlaveBase::config
KConfigBase * config()
Returns a configuration object to query config/meta-data information from.
Definition: slavebase.cpp:386
KIO::SlaveBase::metaData
TQString metaData(const TQString &key) const
Queries for config/meta-data send by the application to the slave.
Definition: slavebase.cpp:360
KIO::SlaveBase::checkCachedAuthentication
bool checkCachedAuthentication(AuthInfo &info)
Checks for cached authentication based on parameters given by info.
Definition: slavebase.cpp:1185
KIO::SlaveBase::warning
void warning(const TQString &msg)
Call to signal a warning, to be displayed in a dialog box.
Definition: slavebase.cpp:614
KIO::SlaveBase::hasMetaData
bool hasMetaData(const TQString &key) const
Queries for the existence of a certain config/meta-data entry send by the application to the slave...
Definition: slavebase.cpp:369
KIO::SlaveBase::dataReq
void dataReq()
Asks for data from the job.
Definition: slavebase.cpp:418
KIO::MetaData
MetaData is a simple map of key/value strings.
Definition: global.h:514
KIO::SlaveBase::reparseConfiguration
virtual void reparseConfiguration()
Called by the scheduler to tell the slave that the configuration changed (i.e.
Definition: slavebase.cpp:812
KIO::SlaveBase::mimetype
virtual void mimetype(const KURL &url)
Finds mimetype for one file or directory.
Definition: slavebase.cpp:789
KIO::SlaveBase::totalSize
void totalSize(KIO::filesize_t _bytes)
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.
Definition: slavebase.cpp:482
KIO::number
KIO_EXPORT TQString number(KIO::filesize_t size)
Converts a size to a string representation Not unlike TQString::number(...)
Definition: global.cpp:96
KIO::SlaveBase::processedPercent
void processedPercent(float percent)
Only use this if you can&#39;t know in advance the size of the copied data.
Definition: slavebase.cpp:534
KIO::AuthInfo::url
KURL url
The URL for which authentication is to be stored.
Definition: authinfo.h:94
KIO::SlaveBase::stat
virtual void stat(const KURL &url)
Finds all details for one file or directory.
Definition: slavebase.cpp:779
KIO::SlaveBase::special
virtual void special(const TQByteArray &data)
Used for any command that is specific to this slave (protocol) Examples are : HTTP POST...
Definition: slavebase.cpp:783
KIO::listDir
KIO_EXPORT ListJob * listDir(const KURL &url, bool showProgressInfo=true, bool includeHidden=true)
List the contents of url, which is assumed to be a directory.
Definition: job.cpp:2152
KIO::SlaveBase::readTimeout
int readTimeout()
Definition: slavebase.cpp:1275
KIO::mimetype
KIO_EXPORT MimetypeJob * mimetype(const KURL &url, bool showProgressInfo=true)
Find mimetype for one file or directory.
Definition: job.cpp:1509
KIO::SlaveBase::connected
void connected()
Call in openConnection, if you reimplement it, when you&#39;re done.
Definition: slavebase.cpp:442
KIO::SlaveBase::processedSize
void processedSize(KIO::filesize_t _bytes)
Call this during get and copy, once in a while, to give some info about the current state...
Definition: slavebase.cpp:498
KIO::UDSEntry
TQValueList< UDSAtom > UDSEntry
An entry is the list of atoms containing all the information for a file or URL.
Definition: global.h:506
KIO::SlaveBase::chmod
virtual void chmod(const KURL &url, int permissions)
Change permissions on path The slave emits ERR_DOES_NOT_EXIST or ERR_CANNOT_CHMOD.
Definition: slavebase.cpp:801
KIO::special
KIO_EXPORT SimpleJob * special(const KURL &url, const TQByteArray &data, bool showProgressInfo=true)
Execute any command that is specific to one slave (protocol).
Definition: job.cpp:786
KIO::SlaveBase::dcopClient
DCOPClient * dcopClient()
Return the dcop client used by this slave.
Definition: slavebase.cpp:239
KIO::Slave::protocol
TQString protocol()
The protocol this slave handles.
Definition: slave.h:104
KIO::SlaveBase
There are two classes that specifies the protocol between application (job) and kioslave.
Definition: slavebase.h:45
KIO::SlaveBase::waitForAnswer
int waitForAnswer(int expected1, int expected2, TQByteArray &data, int *pCmd=0)
Wait for an answer to our request, until we get expected1 or expected2.
Definition: slavebase.cpp:942
KIO::SlaveBase::put
virtual void put(const KURL &url, int permissions, bool overwrite, bool resume)
put, i.e.
Definition: slavebase.cpp:781
KIO::SlaveBase::setTimeoutSpecialCommand
void setTimeoutSpecialCommand(int timeout, const TQByteArray &data=TQByteArray())
This function sets a timeout of timeout seconds and calls special(data) when the timeout occurs as if...
Definition: slavebase.cpp:977
KIO::chmod
KIO_EXPORT ChmodJob * chmod(const KFileItemList &lstItems, int permissions, int mask, TQString newOwner, TQString newGroup, bool recursive, bool showProgressInfo=true)
Creates a job that changes permissions/ownership on several files or directories, optionally recursiv...
Definition: chmodjob.cpp:230
KIO::Slave::passwd
TQString passwd()
Definition: slave.h:139
KIO::SlaveBase::statEntry
void statEntry(const UDSEntry &_entry)
Call this from stat() to express details about an object, the UDSEntry customarily contains the atoms...
Definition: slavebase.cpp:647
KIO::Connection
This class provides a simple means for IPC between two applications via a pipe.
Definition: connection.h:49
KIO::SlaveBase::cacheAuthentication
bool cacheAuthentication(const AuthInfo &info)
Explicitly store authentication information.
Definition: slavebase.cpp:1228
KIO::copy
KIO_EXPORT CopyJob * copy(const KURL &src, const KURL &dest, bool showProgressInfo=true)
Copy a file or directory src into the destination dest, which can be a file (including the final file...
Definition: job.cpp:3886
KIO::Slave::user
TQString user()
Definition: slave.h:134
KIO::SlaveBase::openPassDlg
bool openPassDlg(KIO::AuthInfo &info, const TQString &errorMsg)
Prompt the user for Authorization info (login & password).
Definition: slavebase.cpp:837
KIO::SlaveBase::slave_status
virtual void slave_status()
Called to get the status of the slave.
Definition: slavebase.cpp:809
KIO::SlaveBase::connectTimeout
int connectTimeout()
Definition: slavebase.cpp:1243
KIO::Slave::host
TQString host()
Definition: slave.h:124
KIO::SlaveBase::closeConnection
virtual void closeConnection()
Closes the connection (forced) Called when the application disconnects the slave to close any open ne...
Definition: slavebase.cpp:777
KIO::rename
KIO_EXPORT SimpleJob * rename(const KURL &src, const KURL &dest, bool overwrite)
Rename a file or directory.
Definition: job.cpp:772
KIO::filesize_t
TQ_ULLONG filesize_t
64-bit file size
Definition: global.h:39
KIO::SlaveBase::wasKilled
bool wasKilled() const
If your ioslave was killed by a signal, wasKilled() returns true.
Definition: slavebase.cpp:1285
KIO::SlaveBase::mimeType
void mimeType(const TQString &_type)
Call this in mimetype() and in get(), when you know the mimetype.
Definition: slavebase.cpp:571
KIO::SlaveBase::pingCacheDaemon
bool pingCacheDaemon() const
Definition: slavebase.cpp:1163
KIO::SlaveBase::needSubURLData
void needSubURLData()
Call to signal that data from the sub-URL is needed.
Definition: slavebase.cpp:462
KIO::SlaveBase::remoteEncoding
KRemoteEncoding * remoteEncoding()
Returns an object that can translate remote filenames into proper Unicode forms.
Definition: slavebase.cpp:401
KIO::SlaveBase::symlink
virtual void symlink(const TQString &target, const KURL &dest, bool overwrite)
Creates a symbolic link named dest, pointing to target, which may be a relative or an absolute path...
Definition: slavebase.cpp:793
KIO::SlaveBase::setMetaData
void setMetaData(const TQString &key, const TQString &value)
Sets meta-data to be send to the application before the first data() or finished() signal...
Definition: slavebase.cpp:355
KIO::stat
KIO_EXPORT StatJob * stat(const KURL &url, bool showProgressInfo=true)
Find all details for one file or directory.
Definition: job.cpp:886
KIO::SlaveBase::proxyConnectTimeout
int proxyConnectTimeout()
Definition: slavebase.cpp:1253
KIO::SlaveBase::infoMessage
void infoMessage(const TQString &msg)
Call to signal a message, to be displayed if the application wants to, for instance in a status bar...
Definition: slavebase.cpp:620
KIO::del
KIO_EXPORT DeleteJob * del(const KURL &src, bool shred=false, bool showProgressInfo=true)
Delete a file or directory.
Definition: job.cpp:4386
KIO::SlaveBase::listEntry
void listEntry(const UDSEntry &_entry, bool ready)
internal function to be called by the slave.
Definition: slavebase.cpp:655
KIO::Connection::send
void send(int cmd, const TQByteArray &arr=TQByteArray())
Sends/queues the given command to be sent.
Definition: connection.cpp:105
KIO::SlaveBase::readData
int readData(TQByteArray &buffer)
Read data send by the job, after a dataReq.
Definition: slavebase.cpp:970
KIO::SlaveBase::error
void error(int _errid, const TQString &_text)
Call to signal an error.
Definition: slavebase.cpp:429
KIO::SlaveBase::speed
void speed(unsigned long _bytes_per_second)
Call this in get and copy, to give the current transfer speed, but only if it can&#39;t be calculated out...
Definition: slavebase.cpp:540
KIO::symlink
KIO_EXPORT SimpleJob * symlink(const TQString &target, const KURL &dest, bool overwrite, bool showProgressInfo=true)
Create or move a symlink.
Definition: job.cpp:779
KIO::SlaveInterface::openPassDlg
void openPassDlg(KIO::AuthInfo &info)
Prompt the user for authrization info (login & password).
Definition: slaveinterface.cpp:469
KIO::SlaveBase::connectSlave
void connectSlave(const TQString &path)
internal function to connect a slave to/ disconnect from either the slave pool or the application ...
Definition: slavebase.cpp:336
KIO::SlaveBase::get
virtual void get(const KURL &url)
get, aka read.
Definition: slavebase.cpp:787
KIO::SlaveBase::setSubURL
virtual void setSubURL(const KURL &url)
Prepare slave for streaming operation.
Definition: slavebase.cpp:803
KIO::SlaveBase::messageBox
int messageBox(MessageBoxType type, const TQString &text, const TQString &caption=TQString::null, const TQString &buttonYes=TQString::null, const TQString &buttonNo=TQString::null)
Call this to show a message box from the slave.
Definition: slavebase.cpp:897
KIO::SlaveBase::data
void data(const TQByteArray &data)
Sends data in the slave to the job (i.e.
Definition: slavebase.cpp:409
KIO::SlaveBase::sendMetaData
void sendMetaData()
Internal function to transmit meta data to the application.
Definition: slavebase.cpp:391
KIO::SlaveBase::copy
virtual void copy(const KURL &src, const KURL &dest, int permissions, bool overwrite)
Copy src into dest.
Definition: slavebase.cpp:795
KIO::SlaveBase::redirection
void redirection(const KURL &_url)
Call this to signal a redirection The job will take care of going to that url.
Definition: slavebase.cpp:548
KIO::SlaveBase::createAuthCacheKey
TQString createAuthCacheKey(const KURL &url)
Definition: slavebase.cpp:1144
KIO::unsupportedActionErrorString
KIO_EXPORT TQString unsupportedActionErrorString(const TQString &protocol, int cmd)
Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...
Definition: global.cpp:439
KIO::Slave::port
int port()
Definition: slave.h:129
KIO::SlaveBase::multiGet
virtual void multiGet(const TQByteArray &data)
Used for multiple get.
Definition: slavebase.cpp:805
KIO::mkdir
KIO_EXPORT SimpleJob * mkdir(const KURL &url, int permissions=-1)
Creates a single directory.
Definition: job.cpp:751
KIO::SlaveBase::dropNetwork
void dropNetwork(const TQString &host=TQString::null)
Used by the slave to withdraw a connection requested by requestNetwork.
Definition: slavebase.cpp:641
KIO::SlaveBase::listEntries
void listEntries(const UDSEntryList &_entry)
Call this in listDir, each time you have a bunch of entries to report.
Definition: slavebase.cpp:697
KIO::SlaveBase::del
virtual void del(const KURL &url, bool isfile)
Delete a file or directory.
Definition: slavebase.cpp:797
KIO::SlaveBase::rename
virtual void rename(const KURL &src, const KURL &dest, bool overwrite)
Rename oldname into newname.
Definition: slavebase.cpp:791
KIO::AuthInfo::username
TQString username
This is required for caching.
Definition: authinfo.h:99
KIO::SlaveBase::openConnection
virtual void openConnection()
Opens the connection (forced) When this function gets called the slave is operating in connection-ori...
Definition: slavebase.cpp:775
KIO::SlaveBase::setKillFlag
void setKillFlag()
Internally used.
Definition: slavebase.cpp:1290
KIO::SlaveBase::sendAuthenticationKey
void sendAuthenticationKey(const TQCString &gKey, const TQCString &key, bool keep)
Definition: slavebase.cpp:710

kio/kio

Skip menu "kio/kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kio/kio

Skip menu "kio/kio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kio/kio by doxygen 1.8.13
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |