37 #include <QtDBus/QtDBus>
38 #include <QtCore/QPointer>
39 #include <QtNetwork/QSslCertificate>
40 #include <QtNetwork/QSslError>
51 connect(&d_ptr->speed_timer, SIGNAL(
timeout()), SLOT(calcSpeed()));
83 Q_ASSERT( d->connection );
88 int ret = d->connection->read( &cmd, data );
98 if (d->slave_calcs_speed) {
99 d->speed_timer.stop();
104 gettimeofday(&tv, 0);
106 long diff = ((tv.tv_sec - d->start_time.tv_sec) * 1000000 +
107 tv.tv_usec - d->start_time.tv_usec) / 1000;
108 if (diff - d->last_time >= 900) {
113 for (
unsigned int i = 1; i <
max_nums; ++i) {
114 d->times[i-1] = d->times[i];
115 d->sizes[i-1] = d->sizes[i];
119 d->times[d->nums] = diff;
120 d->sizes[d->nums++] = d->filesize - d->offset;
122 KIO::filesize_t lspeed = 1000 * (d->sizes[d->nums-1] - d->sizes[0]) / (d->times[d->nums-1] - d->times[0]);
134 d->sizes[0] = d->filesize - d->offset;
140 #ifndef KDE_USE_FINAL // already defined in slavebase.cpp
145 template<
int T>
struct PIDType {
typedef pid_t PID_t; } ;
146 template<>
struct PIDType<2> {
typedef qint16 PID_t; } ;
147 template<>
struct PIDType<4> {
typedef qint32 PID_t; } ;
155 QDataStream stream(rawdata);
175 d->speed_timer.stop();
190 for (uint i = 0; i < count; i++) {
203 d->filesize = d->offset;
208 kDebug(7007) <<
"error " << i <<
" " << str1;
212 PIDType<sizeof(pid_t)>::PID_t stream_pid;
215 stream >> stream_pid >> protocol >> str1 >> b;
230 gettimeofday(&d->start_time, 0);
232 d->filesize = d->offset;
233 d->sizes[0] = d->filesize - d->offset;
236 d->speed_timer.start(1000);
237 d->slave_calcs_speed =
false;
254 d->slave_calcs_speed =
true;
255 d->speed_timer.stop();
272 if (!d->connection->suspended())
273 d->connection->sendnow(
CMD_NONE, QByteArray());
280 kDebug(7007) <<
"needs a msg box";
283 stream >> type >> text >> caption >> buttonYes >> buttonNo;
284 if (stream.atEnd()) {
285 messageBox(type, text, caption, buttonYes, buttonNo);
287 stream >> dontAskAgainName;
288 messageBox(type, text, caption, buttonYes, buttonNo, dontAskAgainName);
301 if (m.contains(QLatin1String(
"ssl_in_use"))) {
302 const QLatin1String ssl_(
"ssl_");
304 for (MetaData::ConstIterator it = constM.lowerBound(ssl_); it != constM.constEnd(); ++it) {
305 if (it.key().startsWith(ssl_)) {
306 d->sslMetaData.insert(it.key(), it.value());
319 stream >> host >> slaveid;
326 stream >> host >> slaveid;
341 kWarning(7007) <<
"Slave sends unknown command (" << _cmd <<
"), dropping slave";
362 kDebug(7007) <<
"requestNetwork " << host << slaveid;
363 QByteArray packedArgs;
364 QDataStream stream( &packedArgs, QIODevice::WriteOnly );
371 kDebug(7007) <<
"dropNetwork " << host << slaveid;
377 kDebug(7007) <<
"ok for resuming:" << resume;
384 if (!d->connection) {
388 if (d->connection->suspended()) {
389 d->connection->resume();
391 QByteArray packedArgs;
392 QDataStream stream( &packedArgs, QIODevice::WriteOnly );
395 kDebug(7007) <<
"message box answer" << result;
410 d->connection->suspend();
422 if (buttonYes ==
i18n(
"&Details")) {
424 }
else if (buttonYes ==
i18n(
"&Forever")) {
428 if (buttonNo ==
i18n(
"Co&ntinue")) {
430 }
else if (buttonNo ==
i18n(
"&Current Session only")) {
438 globalUserNotificationHandler()->requestMessageBox(
this, type, data);
450 return d->parentWindow;
456 QDataStream stream(&data, QIODevice::WriteOnly);
457 stream << info.hostName() << info.addresses() << info.error() << info.errorString();
461 #include "slaveinterface.moc"