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

tdeio/tdeio

  • tdeio
  • tdeio
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 <tdeapplication.h>
48#include <ksock.h>
49#include <kcrash.h>
50#include <tdesu/client.h>
51#include <tdelocale.h>
52#include <ksocks.h>
53
54#include "kremoteencoding.h"
55
56#include "tdeio/slavebase.h"
57#include "tdeio/connection.h"
58#include "tdeio/ioslave_defaults.h"
59#include "tdeio/slaveinterface.h"
60
61#include "uiserver_stub.h"
62
63using namespace TDEIO;
64
65template class TQPtrList<TQValueList<UDSAtom> >;
66typedef TQValueList<TQCString> AuthKeysList;
67typedef TQMap<TQString,TQCString> AuthKeysMap;
68#define TDEIO_DATA TQByteArray data; TQDataStream stream( data, IO_WriteOnly ); stream
69#define TDEIO_FILESIZE_T(x) (unsigned long)(x & 0xffffffff) << (unsigned long)(x >> 32)
70
71namespace TDEIO {
72
73class SlaveBaseConfig : public TDEConfigBase
74{
75public:
76 SlaveBaseConfig(SlaveBase *_slave)
77 : slave(_slave) { }
78
79 bool internalHasGroup(const TQCString &) const { tqWarning("hasGroup(const TQCString &)");
80return 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 }
104protected:
105 SlaveBase *slave;
106};
107
108
109class SlaveBasePrivate {
110public:
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 TDEIO::filesize_t totalSize;
122 TDEIO::filesize_t sentListEntries;
123 DCOPClient *dcopClient;
124 KRemoteEncoding *remotefile;
125 time_t timeout;
126 TQByteArray timeoutData;
127};
128
129}
130
131static SlaveBase *globalSlave;
132long SlaveBase::s_seqNr;
133
134static volatile bool slaveWriteError = false;
135
136static const char *s_protocol;
137
138#ifdef Q_OS_UNIX
139static 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()<<"tdeioslave : 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
156SlaveBase::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("TDE_DEBUG"))
166 {
167 TDECrash::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
233SlaveBase::~SlaveBase()
234{
235 delete d;
236 s_protocol = "";
237}
238
239DCOPClient *SlaveBase::dcopClient()
240{
241 if (!d->dcopClient)
242 {
243 d->dcopClient = TDEApplication::dcopClient();
244 if (!d->dcopClient->isAttached())
245 d->dcopClient->attach();
246 d->dcopClient->setDaemonMode( true );
247 }
248 return d->dcopClient;
249}
250
251void 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 TDEIO slave system only works under UNIX
333#endif
334}
335
336void SlaveBase::connectSlave(const TQString& path)
337{
338#ifdef Q_OS_UNIX //TODO: TDESocket not yet available on WIN32
339 appconn->init(new TDESocket(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
350void SlaveBase::disconnectSlave()
351{
352 appconn->close();
353}
354
355void SlaveBase::setMetaData(const TQString &key, const TQString &value)
356{
357 mOutgoingMetaData.replace(key, value);
358}
359
360TQString 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
369bool 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)
379TQString SlaveBase::metaData(const TQString &key) {
380 return const_cast<const SlaveBase*>(this)->metaData( key );
381}
382bool SlaveBase::hasMetaData(const TQString &key) {
383 return const_cast<const SlaveBase*>(this)->hasMetaData( key );
384}
385
386TDEConfigBase *SlaveBase::config()
387{
388 return d->config;
389}
390
391void SlaveBase::sendMetaData()
392{
393 TDEIO_DATA << mOutgoingMetaData;
394
395 slaveWriteError = false;
396 m_pConnection->send( INF_META_DATA, data );
397 if (slaveWriteError) exit();
398 mOutgoingMetaData.clear(); // Clear
399}
400
401KRemoteEncoding *SlaveBase::remoteEncoding()
402{
403 if (d->remotefile != 0)
404 return d->remotefile;
405
406 return d->remotefile = new KRemoteEncoding(metaData("Charset").latin1());
407}
408
409void 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
418void 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
429void SlaveBase::error( int _errid, const TQString &_text )
430{
431 mIncomingMetaData.clear(); // Clear meta data
432 mOutgoingMetaData.clear();
433 TDEIO_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
442void SlaveBase::connected()
443{
444 slaveWriteError = false;
445 m_pConnection->send( MSG_CONNECTED );
446 if (slaveWriteError) exit();
447}
448
449void 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
462void SlaveBase::needSubURLData()
463{
464 m_pConnection->send( MSG_NEED_SUBURL_DATA );
465}
466
467void SlaveBase::slaveStatus( const TQString &host, bool connected )
468{
469 pid_t pid = getpid();
470 TQ_INT8 b = connected ? 1 : 0;
471 TDEIO_DATA << pid << mProtocol << host << b;
472 if (d->onHold)
473 stream << d->onHoldUrl;
474 m_pConnection->send( MSG_SLAVE_STATUS, data );
475}
476
477void SlaveBase::canResume()
478{
479 m_pConnection->send( MSG_CANRESUME );
480}
481
482void SlaveBase::totalSize( TDEIO::filesize_t _bytes )
483{
484 TDEIO_DATA << TDEIO_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
498void SlaveBase::processedSize( TDEIO::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 TDEIO_DATA << TDEIO_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
534void SlaveBase::processedPercent( float /* percent */ )
535{
536 kdDebug(7019) << "SlaveBase::processedPercent: STUB" << endl;
537}
538
539
540void SlaveBase::speed( unsigned long _bytes_per_second )
541{
542 TDEIO_DATA << (TQ_UINT32) _bytes_per_second;
543 slaveWriteError = false;
544 m_pConnection->send( INF_SPEED, data );
545 if (slaveWriteError) exit();
546}
547
548void SlaveBase::redirection( const KURL& _url )
549{
550 TDEIO_DATA << _url;
551 m_pConnection->send( INF_REDIRECTION, data );
552}
553
554void SlaveBase::errorPage()
555{
556 m_pConnection->send( INF_ERROR_PAGE );
557}
558
559static 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
571void 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 TDEIO_DATA << mOutgoingMetaData;
582 m_pConnection->send( INF_META_DATA, data );
583 }
584 TDEIO_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
608void SlaveBase::exit()
609{
610 this->~SlaveBase();
611 ::exit(255);
612}
613
614void SlaveBase::warning( const TQString &_msg)
615{
616 TDEIO_DATA << _msg;
617 m_pConnection->send( INF_WARNING, data );
618}
619
620void SlaveBase::infoMessage( const TQString &_msg)
621{
622 TDEIO_DATA << _msg;
623 m_pConnection->send( INF_INFOMESSAGE, data );
624}
625
626bool SlaveBase::requestNetwork(const TQString& host)
627{
628 TDEIO_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
641void SlaveBase::dropNetwork(const TQString& host)
642{
643 TDEIO_DATA << host << d->slaveid;
644 m_pConnection->send( MSG_NET_DROP, data );
645}
646
647void SlaveBase::statEntry( const UDSEntry& entry )
648{
649 TDEIO_DATA << entry;
650 slaveWriteError = false;
651 m_pConnection->send( MSG_STAT_ENTRY, data );
652 if (slaveWriteError) exit();
653}
654
655void 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
697void SlaveBase::listEntries( const UDSEntryList& list )
698{
699 TDEIO_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
710void SlaveBase::sendAuthenticationKey( const TQCString& key,
711 const TQCString& group,
712 bool keepPass )
713{
714 TDEIO_DATA << key << group << keepPass;
715 m_pConnection->send( MSG_AUTH_KEY, data );
716}
717
718void SlaveBase::delCachedAuthentication( const TQString& key )
719{
720 TDEIO_DATA << key.utf8() ;
721 m_pConnection->send( MSG_DEL_AUTH_KEY, data );
722}
723
724void 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), "tdeioslave: ####### 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
760void 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
771void SlaveBase::setHost(TQString const &, int, TQString const &, TQString const &)
772{
773}
774
775void SlaveBase::openConnection(void)
776{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CONNECT)); }
777void SlaveBase::closeConnection(void)
778{ } // No response!
779void SlaveBase::stat(KURL const &)
780{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_STAT)); }
781void SlaveBase::put(KURL const &, int, bool, bool)
782{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_PUT)); }
783void SlaveBase::special(const TQByteArray &)
784{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SPECIAL)); }
785void SlaveBase::listDir(KURL const &)
786{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_LISTDIR)); }
787void SlaveBase::get(KURL const & )
788{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_GET)); }
789void SlaveBase::mimetype(KURL const &url)
790{ get(url); }
791void SlaveBase::rename(KURL const &, KURL const &, bool)
792{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_RENAME)); }
793void SlaveBase::symlink(TQString const &, KURL const &, bool)
794{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SYMLINK)); }
795void SlaveBase::copy(KURL const &, KURL const &, int, bool)
796{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_COPY)); }
797void SlaveBase::del(KURL const &, bool)
798{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_DEL)); }
799void SlaveBase::mkdir(KURL const &, int)
800{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_MKDIR)); }
801void SlaveBase::chmod(KURL const &, int)
802{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CHMOD)); }
803void SlaveBase::setSubURL(KURL const &)
804{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SUBURL)); }
805void SlaveBase::multiGet(const TQByteArray &)
806{ error( ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_MULTI_GET)); }
807
808
809void SlaveBase::slave_status()
810{ slaveStatus( TQString::null, false ); }
811
812void SlaveBase::reparseConfiguration()
813{
814}
815
816void SlaveBase::localURL(const KURL& remoteURL)
817{
818 bool local = remoteURL.isLocalFile();
819 TQ_INT8 islocal;
820 KURL retURL;
821 if (local) {
822 islocal = true;
823 retURL = remoteURL;
824 }
825 else {
826 islocal = false;
827 retURL = remoteURL;
828 }
829 TDEIO_DATA << islocal << retURL;
830 m_pConnection->send( INF_LOCALURL, data );
831}
832
833bool SlaveBase::dispatch()
834{
835 assert( m_pConnection );
836
837 int cmd;
838 TQByteArray data;
839 if ( m_pConnection->read( &cmd, data ) == -1 )
840 {
841 kdDebug(7019) << "SlaveBase::dispatch() has read error." << endl;
842 return false;
843 }
844
845 dispatch( cmd, data );
846 return true;
847}
848
849bool SlaveBase::openPassDlg( AuthInfo& info )
850{
851 return openPassDlg(info, TQString::null);
852}
853
854bool SlaveBase::openPassDlg( AuthInfo& info, const TQString &errorMsg )
855{
856 TQCString replyType;
857 TQByteArray params;
858 TQByteArray reply;
859 AuthInfo authResult;
860 long windowId = metaData("window-id").toLong();
861 long progressId = metaData("progress-id").toLong();
862 unsigned long userTimestamp = metaData("user-timestamp").toULong();
863
864 kdDebug(7019) << "SlaveBase::openPassDlg window-id=" << windowId << " progress-id=" << progressId << endl;
865
866 (void) dcopClient(); // Make sure to have a dcop client.
867
868 UIServer_stub uiserver( "tdeio_uiserver", "UIServer" );
869 if (progressId)
870 uiserver.setJobVisible( progressId, false );
871
872 TQDataStream stream(params, IO_WriteOnly);
873
874 if (metaData("no-auth-prompt").lower() == "true")
875 stream << info << TQString("<NoAuthPrompt>") << windowId << s_seqNr << userTimestamp;
876 else
877 stream << info << errorMsg << windowId << s_seqNr << userTimestamp;
878
879 bool callOK = d->dcopClient->call( "kded", "kpasswdserver", "queryAuthInfo(TDEIO::AuthInfo, TQString, long int, long int, unsigned long int)",
880 params, replyType, reply );
881
882 if (progressId)
883 uiserver.setJobVisible( progressId, true );
884
885 if (!callOK)
886 {
887 kdWarning(7019) << "Can't communicate with kded_kpasswdserver (openPassDlg)!" << endl;
888 return false;
889 }
890
891 if ( replyType == "TDEIO::AuthInfo" )
892 {
893 TQDataStream stream2( reply, IO_ReadOnly );
894 stream2 >> authResult >> s_seqNr;
895 }
896 else
897 {
898 kdError(7019) << "DCOP function queryAuthInfo(...) returns "
899 << replyType << ", expected TDEIO::AuthInfo" << endl;
900 return false;
901 }
902
903 if (!authResult.isModified())
904 return false;
905
906 info = authResult;
907
908 kdDebug(7019) << "SlaveBase::openPassDlg: username=" << info.username << endl;
909 kdDebug(7019) << "SlaveBase::openPassDlg: password=[hidden]" << endl;
910
911 return true;
912}
913
914int SlaveBase::messageBox( MessageBoxType type, const TQString &text, const TQString &caption,
915 const TQString &buttonYes, const TQString &buttonNo )
916{
917 return messageBox( text, type, caption, buttonYes, buttonNo, TQString::null );
918}
919
920int SlaveBase::messageBox( const TQString &text, MessageBoxType type, const TQString &caption,
921 const TQString &buttonYes, const TQString &buttonNo, const TQString &dontAskAgainName )
922{
923 kdDebug(7019) << "messageBox " << type << " " << text << " - " << caption << buttonYes << buttonNo << endl;
924 TDEIO_DATA << (TQ_INT32)type << text << caption << buttonYes << buttonNo << dontAskAgainName;
925 m_pConnection->send( INF_MESSAGEBOX, data );
926 if ( waitForAnswer( CMD_MESSAGEBOXANSWER, 0, data ) != -1 )
927 {
928 TQDataStream stream( data, IO_ReadOnly );
929 int answer;
930 stream >> answer;
931 kdDebug(7019) << "got messagebox answer" << answer << endl;
932 return answer;
933 } else
934 return 0; // communication failure
935}
936
937bool SlaveBase::canResume( TDEIO::filesize_t offset )
938{
939 kdDebug(7019) << "SlaveBase::canResume offset=" << TDEIO::number(offset) << endl;
940 d->needSendCanResume = false;
941 TDEIO_DATA << TDEIO_FILESIZE_T(offset);
942 m_pConnection->send( MSG_RESUME, data );
943 if ( offset )
944 {
945 int cmd;
946 if ( waitForAnswer( CMD_RESUMEANSWER, CMD_NONE, data, &cmd ) != -1 )
947 {
948 kdDebug(7019) << "SlaveBase::canResume returning " << (cmd == CMD_RESUMEANSWER) << endl;
949 return cmd == CMD_RESUMEANSWER;
950 } else
951 return false;
952 }
953 else // No resuming possible -> no answer to wait for
954 return true;
955}
956
957
958
959int SlaveBase::waitForAnswer( int expected1, int expected2, TQByteArray & data, int *pCmd )
960{
961 int cmd, result;
962 for (;;)
963 {
964 result = m_pConnection->read( &cmd, data );
965 if ( result == -1 )
966 {
967 kdDebug(7019) << "SlaveBase::waitForAnswer has read error." << endl;
968 return -1;
969 }
970 if ( cmd == expected1 || cmd == expected2 )
971 {
972 if ( pCmd ) *pCmd = cmd;
973 return result;
974 }
975 if ( isSubCommand(cmd) )
976 {
977 dispatch( cmd, data );
978 }
979 else
980 {
981 kdWarning() << "Got cmd " << cmd << " while waiting for an answer!" << endl;
982 }
983 }
984}
985
986
987int SlaveBase::readData( TQByteArray &buffer)
988{
989 int result = waitForAnswer( MSG_DATA, 0, buffer );
990 //kdDebug(7019) << "readData: length = " << result << " " << endl;
991 return result;
992}
993
994void SlaveBase::setTimeoutSpecialCommand(int timeout, const TQByteArray &data)
995{
996 if (timeout > 0)
997 d->timeout = time(0)+(time_t)timeout;
998 else if (timeout == 0)
999 d->timeout = 1; // Immediate timeout
1000 else
1001 d->timeout = 0; // Canceled
1002
1003 d->timeoutData = data;
1004}
1005
1006void SlaveBase::dispatch( int command, const TQByteArray &data )
1007{
1008 TQDataStream stream( data, IO_ReadOnly );
1009
1010 KURL url;
1011 int i;
1012
1013 switch( command ) {
1014 case CMD_HOST: {
1015 // Reset s_seqNr, see kpasswdserver/DESIGN
1016 s_seqNr = 0;
1017 TQString passwd;
1018 TQString host, user;
1019 stream >> host >> i >> user >> passwd;
1020 setHost( host, i, user, passwd );
1021 }
1022 break;
1023 case CMD_CONNECT:
1024 openConnection( );
1025 break;
1026 case CMD_DISCONNECT:
1027 closeConnection( );
1028 break;
1029 case CMD_SLAVE_STATUS:
1030 slave_status();
1031 break;
1032 case CMD_SLAVE_CONNECT:
1033 {
1034 d->onHold = false;
1035 TQString app_socket;
1036 TQDataStream stream( data, IO_ReadOnly);
1037 stream >> app_socket;
1038 appconn->send( MSG_SLAVE_ACK );
1039 disconnectSlave();
1040 mConnectedToApp = true;
1041 connectSlave(app_socket);
1042 } break;
1043 case CMD_SLAVE_HOLD:
1044 {
1045 KURL url;
1046 TQDataStream stream( data, IO_ReadOnly);
1047 stream >> url;
1048 d->onHoldUrl = url;
1049 d->onHold = true;
1050 disconnectSlave();
1051 mConnectedToApp = false;
1052 // Do not close connection!
1053 connectSlave(mPoolSocket);
1054 } break;
1055 case CMD_REPARSECONFIGURATION:
1056 reparseConfiguration();
1057 break;
1058 case CMD_CONFIG:
1059 stream >> d->configData;
1060#ifdef Q_OS_UNIX //TODO: not yet available on WIN32
1061 KSocks::setConfig(d->config);
1062#endif
1063 delete d->remotefile;
1064 d->remotefile = 0;
1065 break;
1066 case CMD_GET:
1067 {
1068 stream >> url;
1069 get( url );
1070 } break;
1071 case CMD_PUT:
1072 {
1073 int permissions;
1074 TQ_INT8 iOverwrite, iResume;
1075 stream >> url >> iOverwrite >> iResume >> permissions;
1076 bool overwrite = ( iOverwrite != 0 );
1077 bool resume = ( iResume != 0 );
1078
1079 // Remember that we need to send canResume(), TransferJob is expecting
1080 // it. Well, in theory this shouldn't be done if resume is true.
1081 // (the resume bool is currently unused)
1082 d->needSendCanResume = true /* !resume */;
1083
1084 put( url, permissions, overwrite, resume);
1085 } break;
1086 case CMD_STAT:
1087 stream >> url;
1088 stat( url );
1089 break;
1090 case CMD_MIMETYPE:
1091 stream >> url;
1092 mimetype( url );
1093 break;
1094 case CMD_LISTDIR:
1095 stream >> url;
1096 listDir( url );
1097 break;
1098 case CMD_MKDIR:
1099 stream >> url >> i;
1100 mkdir( url, i );
1101 break;
1102 case CMD_RENAME:
1103 {
1104 TQ_INT8 iOverwrite;
1105 KURL url2;
1106 stream >> url >> url2 >> iOverwrite;
1107 bool overwrite = (iOverwrite != 0);
1108 rename( url, url2, overwrite );
1109 } break;
1110 case CMD_SYMLINK:
1111 {
1112 TQ_INT8 iOverwrite;
1113 TQString target;
1114 stream >> target >> url >> iOverwrite;
1115 bool overwrite = (iOverwrite != 0);
1116 symlink( target, url, overwrite );
1117 } break;
1118 case CMD_COPY:
1119 {
1120 int permissions;
1121 TQ_INT8 iOverwrite;
1122 KURL url2;
1123 stream >> url >> url2 >> permissions >> iOverwrite;
1124 bool overwrite = (iOverwrite != 0);
1125 copy( url, url2, permissions, overwrite );
1126 } break;
1127 case CMD_DEL:
1128 {
1129 TQ_INT8 isFile;
1130 stream >> url >> isFile;
1131 del( url, isFile != 0);
1132 } break;
1133 case CMD_CHMOD:
1134 stream >> url >> i;
1135 chmod( url, i);
1136 break;
1137 case CMD_SPECIAL:
1138 special( data );
1139 break;
1140 case CMD_META_DATA:
1141 //kdDebug(7019) << "(" << getpid() << ") Incoming meta-data..." << endl;
1142 stream >> mIncomingMetaData;
1143 break;
1144 case CMD_SUBURL:
1145 stream >> url;
1146 setSubURL(url);
1147 break;
1148 case CMD_NONE:
1149 fprintf(stderr, "Got unexpected CMD_NONE!\n");
1150 break;
1151 case CMD_MULTI_GET:
1152 multiGet( data );
1153 break;
1154 case CMD_LOCALURL:
1155 {
1156 stream >> url;
1157 localURL( url );
1158 } break;
1159 default:
1160 // Some command we don't understand.
1161 // Just ignore it, it may come from some future version of KDE.
1162 break;
1163 }
1164}
1165
1166TQString SlaveBase::createAuthCacheKey( const KURL& url )
1167{
1168 if( !url.isValid() )
1169 return TQString::null;
1170
1171 // Generate the basic key sequence.
1172 TQString key = url.protocol();
1173 key += '-';
1174 key += url.host();
1175 int port = url.port();
1176 if( port )
1177 {
1178 key += ':';
1179 key += TQString::number(port);
1180 }
1181
1182 return key;
1183}
1184
1185bool SlaveBase::pingCacheDaemon() const
1186{
1187#ifdef Q_OS_UNIX
1188 // TODO: Ping kded / kpasswdserver
1189 TDEsuClient client;
1190 int success = client.ping();
1191 if( success == -1 )
1192 {
1193 success = client.startServer();
1194 if( success == -1 )
1195 {
1196 kdDebug(7019) << "Cannot start a new deamon!!" << endl;
1197 return false;
1198 }
1199 kdDebug(7019) << "Sucessfully started new cache deamon!!" << endl;
1200 }
1201 return true;
1202#else
1203 return false;
1204#endif
1205}
1206
1207bool SlaveBase::checkCachedAuthentication( AuthInfo& info )
1208{
1209 TQCString replyType;
1210 TQByteArray params;
1211 TQByteArray reply;
1212 AuthInfo authResult;
1213 long windowId = metaData("window-id").toLong();
1214 unsigned long userTimestamp = metaData("user-timestamp").toULong();
1215
1216 kdDebug(7019) << "SlaveBase::checkCachedAuthInfo window = " << windowId << " url = " << info.url.url() << endl;
1217
1218 (void) dcopClient(); // Make sure to have a dcop client.
1219
1220 TQDataStream stream(params, IO_WriteOnly);
1221 stream << info << windowId << userTimestamp;
1222
1223 if ( !d->dcopClient->call( "kded", "kpasswdserver", "checkAuthInfo(TDEIO::AuthInfo, long int, unsigned long int)",
1224 params, replyType, reply ) )
1225 {
1226 kdWarning(7019) << "Can't communicate with kded_kpasswdserver (checkCachedAuthentication)!" << endl;
1227 return false;
1228 }
1229
1230 if ( replyType == "TDEIO::AuthInfo" )
1231 {
1232 TQDataStream stream2( reply, IO_ReadOnly );
1233 stream2 >> authResult;
1234 }
1235 else
1236 {
1237 kdError(7019) << "DCOP function checkAuthInfo(...) returns "
1238 << replyType << ", expected TDEIO::AuthInfo" << endl;
1239 return false;
1240 }
1241 if (!authResult.isModified())
1242 {
1243 return false;
1244 }
1245
1246 info = authResult;
1247 return true;
1248}
1249
1250bool SlaveBase::cacheAuthentication( const AuthInfo& info )
1251{
1252 TQByteArray params;
1253 long windowId = metaData("window-id").toLong();
1254
1255 (void) dcopClient(); // Make sure to have a dcop client.
1256
1257 TQDataStream stream(params, IO_WriteOnly);
1258 stream << info << windowId;
1259
1260 d->dcopClient->send( "kded", "kpasswdserver", "addAuthInfo(TDEIO::AuthInfo, long int)", params );
1261
1262 return true;
1263}
1264
1265int SlaveBase::connectTimeout()
1266{
1267 bool ok;
1268 TQString tmp = metaData("ConnectTimeout");
1269 int result = tmp.toInt(&ok);
1270 if (ok)
1271 return result;
1272 return DEFAULT_CONNECT_TIMEOUT;
1273}
1274
1275int SlaveBase::proxyConnectTimeout()
1276{
1277 bool ok;
1278 TQString tmp = metaData("ProxyConnectTimeout");
1279 int result = tmp.toInt(&ok);
1280 if (ok)
1281 return result;
1282 return DEFAULT_PROXY_CONNECT_TIMEOUT;
1283}
1284
1285
1286int SlaveBase::responseTimeout()
1287{
1288 bool ok;
1289 TQString tmp = metaData("ResponseTimeout");
1290 int result = tmp.toInt(&ok);
1291 if (ok)
1292 return result;
1293 return DEFAULT_RESPONSE_TIMEOUT;
1294}
1295
1296
1297int SlaveBase::readTimeout()
1298{
1299 bool ok;
1300 TQString tmp = metaData("ReadTimeout");
1301 int result = tmp.toInt(&ok);
1302 if (ok)
1303 return result;
1304 return DEFAULT_READ_TIMEOUT;
1305}
1306
1307bool SlaveBase::wasKilled() const
1308{
1309 return d->wasKilled;
1310}
1311
1312void SlaveBase::setKillFlag()
1313{
1314 d->wasKilled=true;
1315}
1316
1317void SlaveBase::virtual_hook( int, void* )
1318{ /*BASE::virtual_hook( id, data );*/ }
1319
KRemoteEncoding
Allows encoding and decoding properly remote filenames into Unicode.
Definition kremoteencoding.h:45
TDEIO::AuthInfo
This class is intended to make it easier to prompt for, cache and retrieve authorization information.
Definition authinfo.h:52
TDEIO::AuthInfo::username
TQString username
This is required for caching.
Definition authinfo.h:99
TDEIO::AuthInfo::url
KURL url
The URL for which authentication is to be stored.
Definition authinfo.h:94
TDEIO::AuthInfo::isModified
bool isModified() const
Use this method to check if the object was modified.
Definition authinfo.h:76
TDEIO::Connection
This class provides a simple means for IPC between two applications via a pipe.
Definition connection.h:49
TDEIO::Connection::send
void send(int cmd, const TQByteArray &arr=TQByteArray())
Sends/queues the given command to be sent.
Definition connection.cpp:105
TDEIO::Connection::init
void init(TDESocket *sock)
Initialize this connection to use the given socket.
Definition connection.cpp:131
TDEIO::Connection::inited
bool inited() const
Checks whether the connection has been initialized.
Definition connection.h:93
TDEIO::Connection::read
int read(int *_cmd, TQByteArray &data)
Receive data.
Definition connection.cpp:216
TDEIO::Connection::fd_from
int fd_from() const
Returns the input file descriptor.
Definition connection.h:81
TDEIO::Connection::close
void close()
Closes the connection.
Definition connection.cpp:86
TDEIO::MetaData
MetaData is a simple map of key/value strings.
Definition global.h:516
TDEIO::SlaveBase
There are two classes that specifies the protocol between application (job) and tdeioslave.
Definition slavebase.h:46
TDEIO::SlaveBase::proxyConnectTimeout
int proxyConnectTimeout()
Definition slavebase.cpp:1275
TDEIO::SlaveBase::setSubURL
virtual void setSubURL(const KURL &url)
Prepare slave for streaming operation.
Definition slavebase.cpp:803
TDEIO::SlaveBase::wasKilled
bool wasKilled() const
If your ioslave was killed by a signal, wasKilled() returns true.
Definition slavebase.cpp:1307
TDEIO::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
TDEIO::SlaveBase::openPassDlg
bool openPassDlg(TDEIO::AuthInfo &info, const TQString &errorMsg)
Prompt the user for Authorization info (login & password).
Definition slavebase.cpp:854
TDEIO::SlaveBase::delCachedAuthentication
void delCachedAuthentication(const TQString &key)
Definition slavebase.cpp:718
TDEIO::SlaveBase::stat
virtual void stat(const KURL &url)
Finds all details for one file or directory.
Definition slavebase.cpp:779
TDEIO::SlaveBase::config
TDEConfigBase * config()
Returns a configuration object to query config/meta-data information from.
Definition slavebase.cpp:386
TDEIO::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't be calculated out...
Definition slavebase.cpp:540
TDEIO::SlaveBase::sendAuthenticationKey
void sendAuthenticationKey(const TQCString &gKey, const TQCString &key, bool keep)
Definition slavebase.cpp:710
TDEIO::SlaveBase::data
void data(const TQByteArray &data)
Sends data in the slave to the job (i.e.
Definition slavebase.cpp:409
TDEIO::SlaveBase::createAuthCacheKey
TQString createAuthCacheKey(const KURL &url)
Definition slavebase.cpp:1166
TDEIO::SlaveBase::canResume
bool canResume(TDEIO::filesize_t offset)
Call this at the beginning of put(), to give the size of the existing partial file,...
Definition slavebase.cpp:937
TDEIO::SlaveBase::mkdir
virtual void mkdir(const KURL &url, int permissions)
Create a directory.
Definition slavebase.cpp:799
TDEIO::SlaveBase::reparseConfiguration
virtual void reparseConfiguration()
Called by the scheduler to tell the slave that the configuration changed (i.e.
Definition slavebase.cpp:812
TDEIO::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:959
TDEIO::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
TDEIO::SlaveBase::errorPage
void errorPage()
Tell that we will only get an error page here.
Definition slavebase.cpp:554
TDEIO::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:994
TDEIO::SlaveBase::mimetype
virtual void mimetype(const KURL &url)
Finds mimetype for one file or directory.
Definition slavebase.cpp:789
TDEIO::SlaveBase::finished
void finished()
Call to signal successful completion of any command (besides openConnection and closeConnection)
Definition slavebase.cpp:449
TDEIO::SlaveBase::connectTimeout
int connectTimeout()
Definition slavebase.cpp:1265
TDEIO::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
TDEIO::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
TDEIO::SlaveBase::cacheAuthentication
bool cacheAuthentication(const AuthInfo &info)
Explicitly store authentication information.
Definition slavebase.cpp:1250
TDEIO::SlaveBase::dataReq
void dataReq()
Asks for data from the job.
Definition slavebase.cpp:418
TDEIO::SlaveBase::responseTimeout
int responseTimeout()
Definition slavebase.cpp:1286
TDEIO::SlaveBase::mimeType
void mimeType(const TQString &_type)
Call this in mimetype() and in get(), when you know the mimetype.
Definition slavebase.cpp:571
TDEIO::SlaveBase::warning
void warning(const TQString &msg)
Call to signal a warning, to be displayed in a dialog box.
Definition slavebase.cpp:614
TDEIO::SlaveBase::pingCacheDaemon
bool pingCacheDaemon() const
Definition slavebase.cpp:1185
TDEIO::SlaveBase::sendMetaData
void sendMetaData()
Internal function to transmit meta data to the application.
Definition slavebase.cpp:391
TDEIO::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
TDEIO::SlaveBase::get
virtual void get(const KURL &url)
get, aka read.
Definition slavebase.cpp:787
TDEIO::SlaveBase::readData
int readData(TQByteArray &buffer)
Read data send by the job, after a dataReq.
Definition slavebase.cpp:987
TDEIO::SlaveBase::connected
void connected()
Call in openConnection, if you reimplement it, when you're done.
Definition slavebase.cpp:442
TDEIO::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:914
TDEIO::SlaveBase::remoteEncoding
KRemoteEncoding * remoteEncoding()
Returns an object that can translate remote filenames into proper Unicode forms.
Definition slavebase.cpp:401
TDEIO::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
TDEIO::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
TDEIO::SlaveBase::dcopClient
DCOPClient * dcopClient()
Return the dcop client used by this slave.
Definition slavebase.cpp:239
TDEIO::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
TDEIO::SlaveBase::mProtocol
TQCString mProtocol
Name of the protocol supported by this slave.
Definition slavebase.h:809
TDEIO::SlaveBase::copy
virtual void copy(const KURL &src, const KURL &dest, int permissions, bool overwrite)
Copy src into dest.
Definition slavebase.cpp:795
TDEIO::SlaveBase::needSubURLData
void needSubURLData()
Call to signal that data from the sub-URL is needed.
Definition slavebase.cpp:462
TDEIO::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
TDEIO::SlaveBase::processedPercent
void processedPercent(float percent)
Only use this if you can't know in advance the size of the copied data.
Definition slavebase.cpp:534
TDEIO::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
TDEIO::SlaveBase::rename
virtual void rename(const KURL &src, const KURL &dest, bool overwrite)
Rename oldname into newname.
Definition slavebase.cpp:791
TDEIO::SlaveBase::put
virtual void put(const KURL &url, int permissions, bool overwrite, bool resume)
put, i.e.
Definition slavebase.cpp:781
TDEIO::SlaveBase::multiGet
virtual void multiGet(const TQByteArray &data)
Used for multiple get.
Definition slavebase.cpp:805
TDEIO::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
TDEIO::SlaveBase::readTimeout
int readTimeout()
Definition slavebase.cpp:1297
TDEIO::SlaveBase::listEntry
void listEntry(const UDSEntry &_entry, bool ready)
internal function to be called by the slave.
Definition slavebase.cpp:655
TDEIO::SlaveBase::processedSize
void processedSize(TDEIO::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
TDEIO::SlaveBase::slave_status
virtual void slave_status()
Called to get the status of the slave.
Definition slavebase.cpp:809
TDEIO::SlaveBase::dropNetwork
void dropNetwork(const TQString &host=TQString::null)
Used by the slave to withdraw a connection requested by requestNetwork.
Definition slavebase.cpp:641
TDEIO::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
TDEIO::SlaveBase::listDir
virtual void listDir(const KURL &url)
Lists the contents of url.
Definition slavebase.cpp:785
TDEIO::SlaveBase::setHost
virtual void setHost(const TQString &host, int port, const TQString &user, const TQString &pass)
Set the host.
Definition slavebase.cpp:771
TDEIO::SlaveBase::metaData
TQString metaData(const TQString &key) const
Queries for config/meta-data send by the application to the slave.
Definition slavebase.cpp:360
TDEIO::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
TDEIO::SlaveBase::setKillFlag
void setKillFlag()
Internally used.
Definition slavebase.cpp:1312
TDEIO::SlaveBase::del
virtual void del(const KURL &url, bool isfile)
Delete a file or directory.
Definition slavebase.cpp:797
TDEIO::SlaveBase::error
void error(int _errid, const TQString &_text)
Call to signal an error.
Definition slavebase.cpp:429
TDEIO::SlaveBase::slaveStatus
void slaveStatus(const TQString &host, bool connected)
Used to report the status of the slave.
Definition slavebase.cpp:467
TDEIO::SlaveBase::checkCachedAuthentication
bool checkCachedAuthentication(AuthInfo &info)
Checks for cached authentication based on parameters given by info.
Definition slavebase.cpp:1207
TDEIO::SlaveBase::totalSize
void totalSize(TDEIO::filesize_t _bytes)
Call this in get and copy, to give the total size of the file Call in listDir too,...
Definition slavebase.cpp:482
TDEIO::SlaveBase::localURL
virtual void localURL(const KURL &remoteURL)
For use with for ForwardingSlaveBase Returns the local URL of the given remote URL if possible.
Definition slavebase.cpp:816
TDEIO
A namespace for TDEIO globals.
Definition authinfo.h:29
TDEIO::number
TDEIO_EXPORT TQString number(TDEIO::filesize_t size)
Converts a size to a string representation Not unlike TQString::number(...)
Definition global.cpp:96
TDEIO::UDSEntry
TQValueList< UDSAtom > UDSEntry
An entry is the list of atoms containing all the information for a file or URL.
Definition global.h:507
TDEIO::unsupportedActionErrorString
TDEIO_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
TDEIO::filesize_t
TQ_ULLONG filesize_t
64-bit file size
Definition global.h:39

tdeio/tdeio

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

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.9.8
This website is maintained by Timothy Pearson.