• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
kopetetransfermanager.cpp
Go to the documentation of this file.
1 /*
2  kopetetransfermanager.cpp
3 
4  Copyright (c) 2002-2003 by Nick Betcher <nbetcher@kde.org>
5  Copyright (c) 2002-2003 by Richard Smith <kopete@metafoo.co.uk>
6  Copyright (c) 2008 by Roman Jarosz <kedgedev@centrum.cz>
7 
8  Kopete (c) 2002-2008 by the Kopete developers <kopete-devel@kde.org>
9 
10  *************************************************************************
11  * *
12  * This library is free software; you can redistribute it and/or *
13  * modify it under the terms of the GNU Lesser General Public *
14  * License as published by the Free Software Foundation; either *
15  * version 2 of the License, or (at your option) any later version. *
16  * *
17  *************************************************************************
18 */
19 
20 #include "kopetetransfermanager.h"
21 
22 #include <QtCore/QTimerEvent>
23 #include <QtGui/QTextDocument>
24 
25 #include <klocale.h>
26 #include <kdebug.h>
27 #include <kfiledialog.h>
28 #include <kfileitem.h>
29 #include <kmessagebox.h>
30 #include <kio/jobuidelegate.h>
31 #include <kuiserverjobtracker.h>
32 
33 #include "kopetemetacontact.h"
34 #include "kopetecontact.h"
35 #include "kopetemessage.h"
36 #include "kopetechatsession.h"
37 #include "kopeteuiglobal.h"
38 
39 /***************************
40  * Kopete::FileTransferInfo *
41  ***************************/
42 
43 Kopete::FileTransferInfo::FileTransferInfo()
44 {
45  mId = 0;
46  mContact = 0;
47  mSize = 0;
48  mSaveToDirectory = false;
49 }
50 
51 Kopete::FileTransferInfo::FileTransferInfo( Kopete::Contact *contact, const QStringList& files, const unsigned long size, const QString &recipient, KopeteTransferDirection di, const unsigned int id, QString internalId, const QPixmap &preview, bool saveToDirectory )
52 {
53  mContact = contact;
54  mFiles = files;
55  mId = id;
56  mSize = size;
57  mRecipient = recipient;
58  m_intId= internalId;
59  mDirection= di;
60  mPreview = preview;
61  mSaveToDirectory = saveToDirectory;
62 }
63 
64 /***************************
65  * Kopete::Transfer *
66  ***************************/
67 
68 static const int TransferRateWindowLength = 10;
69 static const int TransferRateTimerDelay = 1000;
70 
71 class Kopete::Transfer::Private
72 {
73 public:
74  Private( const Kopete::FileTransferInfo &ftInfo )
75  : info( ftInfo ), transferRateTimer( 0 )
76  {
77  memset( transferRate, 0, sizeof(transferRate) );
78  }
79 
80  FileTransferInfo info;
81  KUrl target;
82 
83  //if ft has one file then localUrl is file otherwise it's directory
84  KUrl localUrl;
85 
86  int transferRate[TransferRateWindowLength];
87  int transferRateTimer;
88 };
89 
90 Kopete::Transfer::Transfer( const Kopete::FileTransferInfo &kfti, const QString &localFile, bool showProgressInfo)
91  : KIO::Job(), d( new Private(kfti) )
92 {
93  connect( kfti.contact(), SIGNAL(destroyed(QObject*)), this, SLOT(slotContactDestroyed()) );
94  this->setUiDelegate(new KIO::JobUiDelegate());
95  if(showProgressInfo)
96  KIO::getJobTracker()->registerJob(this);
97 
98  KUrl targ; targ.setPath( localFile );
99  d->localUrl = targ;
100  init( targ, showProgressInfo );
101 }
102 
103 Kopete::Transfer::Transfer( const Kopete::FileTransferInfo &kfti, bool showProgressInfo)
104  : KIO::Job(), d( new Private(kfti) )
105 {
106  connect( kfti.contact(), SIGNAL(destroyed(QObject*)), this, SLOT(slotContactDestroyed()) );
107  this->setUiDelegate(new KIO::JobUiDelegate());
108  if(showProgressInfo)
109  KIO::getJobTracker()->registerJob(this);
110 
111  // TODO: use mInfo.url().fileName() after move to protocol-aware filetransfers
112  KUrl targ; targ.setPath( d->info.file() );
113  init( displayURL( d->info.contact(), targ.fileName() ), showProgressInfo );
114 }
115 
116 void Kopete::Transfer::init( const KUrl &target, bool showProgressInfo )
117 {
118  d->target = target;
119  setTotalAmount( KJob::Files, d->info.files().count() );
120  setTotalAmount( KJob::Bytes, d->info.size() );
121 
122  if( showProgressInfo )
123  emitCopying( sourceURL(), destinationURL() );
124 
125  connect( this, SIGNAL(result(KJob*)), SLOT(slotResultEmitted()) );
126 
127  ui()->setAutoErrorHandlingEnabled( false );
128 }
129 
130 Kopete::Transfer::~Transfer()
131 {
132  stopTransferRateTimer();
133 
134  delete d;
135 }
136 
137 const Kopete::FileTransferInfo &Kopete::Transfer::info() const
138 {
139  return d->info;
140 }
141 
142 KUrl Kopete::Transfer::displayURL( const Kopete::Contact *contact, const QString &file )
143 {
144  KUrl url;
145  url.setProtocol( QString::fromLatin1("kopete") );
146 
147  QString host;
148  if( !contact )
149  host = QString::fromLatin1("unknown origin");
150  else if( contact->metaContact() )
151  host = contact->metaContact()->displayName();
152  else
153  host = contact->contactId();
154  url.setHost(host);
155 
156  // url.setPath( contact->protocol()->displayName() );
157 
158  url.setFileName( file );
159  return url;
160 }
161 
162 void Kopete::Transfer::slotNextFile( const QString &sourceFile, const QString &destinationFile )
163 {
164  KUrl src;
165  KUrl dest;
166 
167  kDebug() << "source: " << sourceFile << " destination: " << destinationFile;
168  if( d->info.direction() == Kopete::FileTransferInfo::Incoming )
169  {
170  KUrl url( sourceFile );
171  src = displayURL( d->info.contact(), url.fileName() );
172  dest.setPath( destinationFile );
173  }
174  else
175  {
176  src.setPath( sourceFile );
177  KUrl url( destinationFile );
178  dest = displayURL( d->info.contact(), url.fileName() );
179  }
180 
181  setProcessedAmount( KJob::Files, processedAmount(KJob::Files) + 1 );
182  emit description(this, i18n("Copying"),
183  qMakePair(i18n("Source"), src.prettyUrl()),
184  qMakePair(i18n("Destination"), dest.prettyUrl()));
185 }
186 
187 // TODO: add possibility of network file transfers;
188 // call mInfo->url() not file()
189 KUrl Kopete::Transfer::sourceURL()
190 {
191  if( d->info.direction() == Kopete::FileTransferInfo::Incoming )
192  return displayURL( d->info.contact(), d->info.file() );
193  else
194  {
195  KUrl url; url.setPath( d->info.file() );
196  return url;
197  }
198 }
199 
200 KUrl Kopete::Transfer::destinationURL()
201 {
202  return d->target;
203 }
204 
205 void Kopete::Transfer::emitCopying(const KUrl &src, const KUrl &dest)
206 {
207  emit description(this, i18n("Copying"),
208  qMakePair(i18n("Source"), src.prettyUrl()),
209  qMakePair(i18n("Destination"), dest.prettyUrl()));
210 }
211 
212 void Kopete::Transfer::slotProcessed( unsigned int bytes )
213 {
214  if ( !d->transferRateTimer )
215  d->transferRateTimer = startTimer( TransferRateTimerDelay );
216 
217  d->transferRate[0] += (bytes - processedAmount(KJob::Bytes));
218 
219  setProcessedAmount( KJob::Bytes, bytes );
220  emitPercent( bytes, d->info.size() );
221 }
222 
223 void Kopete::Transfer::timerEvent( QTimerEvent *event )
224 {
225  if ( event->timerId() != d->transferRateTimer )
226  {
227  KIO::Job::timerEvent( event );
228  return;
229  }
230 
231  // Calculate average transferRate
232  qint64 bytesPerSecond = 0;
233  for ( int i = 0; i < TransferRateWindowLength; ++i )
234  bytesPerSecond += d->transferRate[i];
235 
236  bytesPerSecond /= qint64( TransferRateWindowLength );
237 
238  for ( int i = TransferRateWindowLength - 2; i >= 0; --i )
239  d->transferRate[i + 1] = d->transferRate[i];
240 
241  d->transferRate[0] = 0;
242  emitSpeed( bytesPerSecond );
243 
244  // Stop the timer if there is no activity.
245  if ( bytesPerSecond == 0 )
246  stopTransferRateTimer();
247 }
248 
249 void Kopete::Transfer::slotComplete()
250 {
251  stopTransferRateTimer();
252  setError( KJob::NoError );
253  showHtmlMessage( i18n("File transfer %1 completed.", fileForMessage() ) );
254  emitResult();
255 }
256 
257 void Kopete::Transfer::slotError( int error, const QString &errorText )
258 {
259  stopTransferRateTimer();
260  setError(error);
261  setErrorText(errorText);
262 
263  showHtmlMessage( i18n("File transfer %1 failed.", fileForMessage() ) );
264  emitResult();
265 }
266 
267 void Kopete::Transfer::slotResultEmitted()
268 {
269  if( error() == KIO::ERR_USER_CANCELED )
270  {
271  stopTransferRateTimer();
272  showHtmlMessage( i18n("You cancelled file transfer %1", fileForMessage() ) );
273  emit transferCanceled();
274  }
275 }
276 
277 void Kopete::Transfer::slotContactDestroyed()
278 {
279  setError( KIO::ERR_USER_CANCELED );
280  emitResult();
281 }
282 
283 void Kopete::Transfer::slotCancelled()
284 {
285  stopTransferRateTimer();
286 
287  // If cancel button was pressed suppress notification because it was show already in slotResultEmitted()
288  if ( error() != KIO::ERR_USER_CANCELED )
289  {
290  showHtmlMessage( i18n("File transfer %1 cancelled.", fileForMessage() ) );
291  emitResult();
292  }
293 }
294 
295 bool Kopete::Transfer::showMessage( QString text ) const
296 {
297  Kopete::ChatSession *cs = chatSession();
298  if ( !cs )
299  return false;
300 
301  Kopete::Message msg;
302  msg.setPlainBody( text );
303  cs->appendMessage( msg );
304  return true;
305 }
306 
307 bool Kopete::Transfer::showHtmlMessage( QString text ) const
308 {
309  Kopete::ChatSession *cs = chatSession();
310  if (! cs)
311  return false;
312 
313  Kopete::Message msg;
314  msg.setHtmlBody( text );
315  cs->appendMessage( msg );
316  return true;
317 }
318 
319 QString Kopete::Transfer::fileForMessage() const
320 {
321  if( d->info.direction() == Kopete::FileTransferInfo::Incoming )
322  return QString( "<a href=\"%1\">%2</a>" ).arg( d->localUrl.url(), Qt::escape( d->localUrl.toLocalFile() ) );
323  else
324  return Qt::escape( d->info.file() );
325 }
326 
327 void Kopete::Transfer::stopTransferRateTimer()
328 {
329  if ( d->transferRateTimer )
330  {
331  killTimer( d->transferRateTimer );
332  d->transferRateTimer = 0;
333  }
334 }
335 
336 Kopete::ChatSession* Kopete::Transfer::chatSession() const
337 {
338  Kopete::Contact *c = d->info.contact();
339  return ( c ) ? c->manager() : 0;
340 }
341 
342 /***************************
343  * Kopete::TransferManager *
344  ***************************/
345 
346 Kopete::TransferManager* Kopete::TransferManager::transferManager()
347 {
348  static TransferManager s(0L);
349  return &s;
350 }
351 
352 Kopete::TransferManager::TransferManager( QObject *parent ) : QObject( parent )
353 {
354 }
355 
356 Kopete::Transfer* Kopete::TransferManager::addTransfer( Kopete::Contact *contact, const QString& file, const unsigned long size, const QString &recipient, Kopete::FileTransferInfo::KopeteTransferDirection di)
357 {
358  return addTransfer( contact, QStringList(file), size, recipient, di );
359 }
360 
361 Kopete::Transfer* Kopete::TransferManager::addTransfer( Kopete::Contact *contact, const QStringList& files, const unsigned long size, const QString &recipient, Kopete::FileTransferInfo::KopeteTransferDirection di)
362 {
363  // Use message id to make file transfer id unique because we already use it for incoming file transfer.
364  uint id = Kopete::Message::nextId();
365  Kopete::FileTransferInfo info(contact, files, size, recipient, di, id);
366  Kopete::Transfer *trans = new Kopete::Transfer(info);
367  connect(trans, SIGNAL(result(KJob*)), this, SLOT(slotComplete(KJob*)));
368  mTransfersMap.insert(id, trans);
369  return trans;
370 }
371 
372 unsigned int Kopete::TransferManager::askIncomingTransfer( Kopete::Contact *contact, const QString& file, const unsigned long size, const QString& description, QString internalId, const QPixmap &preview )
373 {
374  return askIncomingTransfer( contact, QStringList( file ), size, description, internalId, preview );
375 }
376 
377 unsigned int Kopete::TransferManager::askIncomingTransfer( Kopete::Contact *contact, const QStringList& files, const unsigned long size, const QString& description, QString internalId, const QPixmap &preview )
378 {
379  Kopete::ChatSession *cs = contact->manager( Kopete::Contact::CanCreate );
380  if ( !cs )
381  return 0;
382 
383  const QString dn = contact->metaContact() ? contact->metaContact()->displayName() : contact->contactId();
384 
385  QString msgFileName;
386  foreach ( const QString &file, files )
387  {
388  QString trimmedFile = file.trimmed();
389  if ( !trimmedFile.isEmpty() )
390  msgFileName += trimmedFile + ", ";
391  }
392 
393  // Remove ", " from end
394  if ( msgFileName.size() >= 2 )
395  msgFileName = msgFileName.left( msgFileName.size() - 2 );
396 
397  Kopete::Message msg( contact, cs->myself() );
398  msg.setType( Kopete::Message::TypeFileTransferRequest );
399  msg.setDirection( Kopete::Message::Inbound );
400  msg.setPlainBody( description );
401  msg.setFileName( msgFileName );
402  msg.setFileSize( size );
403  msg.setFilePreview( preview );
404 
405  Kopete::FileTransferInfo info( contact, files, size, dn, Kopete::FileTransferInfo::Incoming,
406  msg.id(), internalId, preview, (files.count() > 1) );
407  mTransferRequestInfoMap.insert( msg.id(), info );
408 
409  cs->appendMessage( msg );
410 
411  return msg.id();
412 }
413 
414 void Kopete::TransferManager::saveIncomingTransfer( unsigned int id )
415 {
416  Kopete::FileTransferInfo info = mTransferRequestInfoMap.value( id );
417  if ( !info.isValid() )
418  return;
419 
420  KConfigGroup cg( KGlobal::config(), "File Transfer" );
421  const QString defaultPath = cg.readEntry( "defaultPath", QDir::homePath() );
422  KUrl url = QString(defaultPath + QLatin1String( "/" ) + info.file());
423 
424  if ( info.saveToDirectory() )
425  url = getSaveDir( url );
426  else
427  url = getSaveFile( url );
428 
429  if ( url.isEmpty() )
430  return;
431 
432  if ( !url.isValid() )
433  {
434  emit askIncomingDone( id );
435  emit refused( info );
436  mTransferRequestInfoMap.remove( id );
437  return;
438  }
439 
440  const QString directory = ( info.saveToDirectory() ) ? url.toLocalFile() : url.directory();
441  if( !directory.isEmpty() )
442  cg.writeEntry( "defaultPath", directory );
443 
444  Kopete::Transfer *trans = new Kopete::Transfer( info, url.toLocalFile() );
445  connect( trans, SIGNAL(result(KJob*)), this, SLOT(slotComplete(KJob*)) );
446  mTransfersMap.insert( info.transferId(), trans );
447  emit askIncomingDone( id );
448  emit accepted( trans, url.toLocalFile() );
449  mTransferRequestInfoMap.remove( id );
450 }
451 
452 void Kopete::TransferManager::cancelIncomingTransfer( unsigned int id )
453 {
454  Kopete::FileTransferInfo info = mTransferRequestInfoMap.value( id );
455  if ( !info.isValid() )
456  return;
457 
458  emit askIncomingDone( id );
459  emit refused( info );
460  mTransferRequestInfoMap.remove( id );
461 }
462 
463 void Kopete::TransferManager::slotComplete(KJob *job)
464 {
465  Kopete::Transfer *transfer=dynamic_cast<Kopete::Transfer*>(job);
466  if(!transfer)
467  return;
468 
469  emit done(transfer);
470 
471  for( QMap<unsigned, Kopete::Transfer*>::Iterator it = mTransfersMap.begin();
472  it != mTransfersMap.end(); ++it )
473  {
474  if( it.value() == transfer )
475  {
476  removeTransfer(it.key());
477  break;
478  }
479  }
480 }
481 
482 void Kopete::TransferManager::sendFile( const KUrl &file, const QString &fname, unsigned long sz,
483  bool mustBeLocal, QObject *sendTo, const char *slot )
484 {
485  KUrl url = file;
486  QString filename;
487  unsigned int size = 0;
488 
489  //If the file location is null, then get it from a file open dialog
490  if( !url.isValid() )
491  url = KFileDialog::getOpenUrl( KUrl(), QString::fromLatin1("*"), 0l, i18n( "Kopete File Transfer" ));
492  else
493  {
494  filename = fname;
495  size = sz;
496  }
497 
498  if( filename.isEmpty() )
499  filename = url.fileName();
500 
501  if( size == 0 )
502  {
503  KFileItem finfo(KFileItem::Unknown, KFileItem::Unknown, url);
504  size = (unsigned long)finfo.size();
505  }
506 
507  if( !url.isEmpty() )
508  {
509  if( mustBeLocal && !url.isLocalFile() )
510  {
511  KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Sorry,
512  i18n( "Sorry, sending files which are not stored locally is not yet supported by this protocol.\n"
513  "Please copy this file to your computer and try again." ) );
514  }
515  else
516  {
517  connect( this, SIGNAL(sendFile(KUrl,QString,uint)), sendTo, slot );
518  emit sendFile( url, filename, size );
519  disconnect( this, SIGNAL(sendFile(KUrl,QString,uint)), sendTo, slot );
520  }
521  }
522 }
523 
524 void Kopete::TransferManager::removeTransfer( unsigned int id )
525 {
526  mTransfersMap.remove(id);
527  //we don't need to delete the job, the job get deleted itself
528 }
529 
530 KUrl Kopete::TransferManager::getSaveFile( const KUrl& startDir ) const
531 {
532  KUrl url = startDir;
533  for ( ;; )
534  {
535  url = KFileDialog::getSaveUrl( url, QLatin1String( "*" ), 0, i18n( "File Transfer" ) );
536  if ( !url.isValid() )
537  return url;
538 
539  if ( !url.isLocalFile() )
540  {
541  KMessageBox::messageBox( 0, KMessageBox::Sorry, i18n( "You must provide a valid local filename" ) );
542  continue;
543  }
544 
545  QFileInfo fileInfo( url.toLocalFile() );
546  if ( fileInfo.exists() )
547  {
548  if ( !fileInfo.isWritable() )
549  {
550  KMessageBox::messageBox( 0, KMessageBox::Sorry, i18n( "You do not have permission to write to selected file" ) );
551  continue;
552  }
553 
554  int ret = KMessageBox::warningContinueCancel( 0, i18n( "The file '%1' already exists.\nDo you want to overwrite it ?", url.toLocalFile() ),
555  i18n( "Overwrite File" ), KStandardGuiItem::save() );
556  if ( ret == KMessageBox::Cancel )
557  continue;
558  }
559  else
560  {
561  QFileInfo dirInfo( url.directory() );
562  if ( !dirInfo.isDir() || !dirInfo.exists() )
563  {
564  KMessageBox::messageBox( 0, KMessageBox::Sorry, i18n( "The directory %1 does not exist", dirInfo.fileName() ) );
565  continue;
566  }
567  else if ( !dirInfo.isWritable() )
568  {
569  KMessageBox::messageBox( 0, KMessageBox::Sorry, i18n( "You do not have permission to write to selected directory" ) );
570  continue;
571  }
572 
573  }
574  break;
575  }
576  return url;
577 }
578 
579 KUrl Kopete::TransferManager::getSaveDir( const KUrl& startDir ) const
580 {
581  KUrl url = startDir;
582  for ( ;; )
583  {
584  url = KFileDialog::getExistingDirectoryUrl( url, 0, i18n( "File Transfer" ) );
585  if ( !url.isValid() )
586  return url;
587 
588  if ( !url.isLocalFile() )
589  {
590  KMessageBox::messageBox( 0, KMessageBox::Sorry, i18n( "You must provide a valid local directory" ) );
591  continue;
592  }
593 
594  QFileInfo dirInfo( url.toLocalFile() );
595  if ( !dirInfo.isDir() || !dirInfo.exists() )
596  {
597  KMessageBox::messageBox( 0, KMessageBox::Sorry, i18n( "The directory %1 does not exist", dirInfo.filePath() ) );
598  continue;
599  }
600  else if ( !dirInfo.isWritable() )
601  {
602  KMessageBox::messageBox( 0, KMessageBox::Sorry, i18n( "You do not have permission to write to selected directory" ) );
603  continue;
604  }
605  break;
606  }
607  return url;
608 }
609 
610 #include "kopetetransfermanager.moc"
611 
Kopete::TransferManager::cancelIncomingTransfer
void cancelIncomingTransfer(unsigned int id)
Cancels incoming file transfer request.
Definition: kopetetransfermanager.cpp:452
kopetemetacontact.h
Kopete::Transfer::slotProcessed
void slotProcessed(unsigned int)
Set the file size processed so far.
Definition: kopetetransfermanager.cpp:212
kopetetransfermanager.h
Kopete::FileTransferInfo
Definition: kopetetransfermanager.h:43
Kopete::Message::setHtmlBody
void setHtmlBody(const QString &body)
Sets the body of the message.
Definition: kopetemessage.cpp:239
Kopete::Contact::contactId
QString contactId
Definition: kopetecontact.h:70
Kopete::Message::setFileName
void setFileName(const QString &fileName)
Set file name of incoming file transfer.
Definition: kopetemessage.cpp:671
Kopete::Message::TypeFileTransferRequest
A incoming file transfer request message.
Definition: kopetemessage.h:102
Kopete::Transfer::destinationURL
KUrl destinationURL()
Retrieve a URL indicating where the file is being copied to.
Definition: kopetetransfermanager.cpp:200
TransferRateTimerDelay
static const int TransferRateTimerDelay
Definition: kopetetransfermanager.cpp:69
Kopete::Transfer::~Transfer
~Transfer()
Destructor.
Definition: kopetetransfermanager.cpp:130
Kopete::FileTransferInfo::Incoming
Definition: kopetetransfermanager.h:46
QMap
QString::size
int size() const
Kopete::TransferManager::sendFile
void sendFile(const KUrl &file, const QString &localFile, unsigned long fileSize, bool mustBeLocal, QObject *sendTo, const char *slot)
Ask the user which file to send when they click Send File.
Definition: kopetetransfermanager.cpp:482
Kopete::ChatSession
Definition: kopetechatsession.h:74
QDir::homePath
QString homePath()
Kopete::Transfer::slotComplete
void slotComplete()
Indicate that the transfer is complete.
Definition: kopetetransfermanager.cpp:249
Kopete::FileTransferInfo::saveToDirectory
bool saveToDirectory() const
Definition: kopetetransfermanager.h:62
kopeteuiglobal.h
Kopete::ChatSession::appendMessage
void appendMessage(Kopete::Message &msg)
Show a message to the chatwindow, or append it to the queue.
Definition: kopetechatsession.cpp:310
QTimerEvent
Kopete::Message::setDirection
void setDirection(MessageDirection direction)
Set the message direction.
Definition: kopetemessage.cpp:585
QList::count
int count(const T &value) const
Kopete::Transfer::slotNextFile
void slotNextFile(const QString &sourceFile, const QString &destinationFile)
Set the source and destination file names of currently processed file.
Definition: kopetetransfermanager.cpp:162
QObject
Kopete::Transfer::timerEvent
virtual void timerEvent(QTimerEvent *event)
Definition: kopetetransfermanager.cpp:223
Kopete::Contact::manager
virtual ChatSession * manager(CanCreateFlags canCreate=CannotCreate)=0
Returns the primary message manager affiliated with this contact Although a contact can have more tha...
QString::isEmpty
bool isEmpty() const
QString::trimmed
QString trimmed() const
Kopete::TransferManager::addTransfer
Transfer * addTransfer(Contact *contact, const QString &file, const unsigned long size, const QString &recipient, FileTransferInfo::KopeteTransferDirection di)
Adds a file transfer to the Kopete::TransferManager.
Definition: kopetetransfermanager.cpp:356
kopetechatsession.h
Kopete::MetaContact::displayName
QString displayName
Definition: kopetemetacontact.h:58
Kopete::Message::id
uint id() const
Get unique message id.
Definition: kopetemessage.cpp:187
Kopete::Transfer::showMessage
bool showMessage(QString text) const
something interesting happened; not an error / void slotInfo( int type, const QString &text ); ...
Definition: kopetetransfermanager.cpp:295
Kopete::Message::Inbound
Message is from the chat partner.
Definition: kopetemessage.h:90
Kopete::FileTransferInfo::transferId
unsigned int transferId() const
Definition: kopetetransfermanager.h:53
Kopete::Message::setPlainBody
void setPlainBody(const QString &body)
Sets the body of the message.
Definition: kopetemessage.cpp:234
QString
Kopete::Transfer::Transfer
Transfer(const FileTransferInfo &, const QString &localFile, bool showProgressInfo=true)
Constructor.
Definition: kopetetransfermanager.cpp:90
Kopete::Contact
Definition: kopetecontact.h:58
QMap::begin
iterator begin()
QStringList
QPixmap
Kopete::Transfer::slotError
void slotError(int error, const QString &errorText)
Inform the job that an error has occurred while transferring the file.
Definition: kopetetransfermanager.cpp:257
QFileInfo
Kopete::FileTransferInfo::file
QString file() const
Definition: kopetetransfermanager.h:55
Kopete::Transfer::slotCancelled
void slotCancelled()
transfer was cancelled (but not by our user)
Definition: kopetetransfermanager.cpp:283
Kopete::FileTransferInfo::contact
Contact * contact() const
Definition: kopetetransfermanager.h:54
Kopete::UI::Global::mainWidget
KOPETE_EXPORT QWidget * mainWidget()
Returns the main widget - this is the widget that message boxes and KNotify stuff should use as a par...
Definition: kopeteuiglobal.cpp:37
Kopete::Transfer
A KIO job for a kopete file transfer.
Definition: kopetetransfermanager.h:183
Kopete::FileTransferInfo::isValid
bool isValid() const
Definition: kopetetransfermanager.h:52
Kopete::TransferManager::transferManager
static TransferManager * transferManager()
Retrieve the transfer manager instance.
Definition: kopetetransfermanager.cpp:346
Kopete::FileTransferInfo::FileTransferInfo
FileTransferInfo()
Definition: kopetetransfermanager.cpp:43
Kopete::Message::nextId
static uint nextId()
Get next unique message id.
Definition: kopetemessage.cpp:192
Kopete::Transfer::sourceURL
KUrl sourceURL()
Retrieve a URL indicating where the file is being copied from.
Definition: kopetetransfermanager.cpp:189
Kopete::Contact::metaContact
MetaContact * metaContact() const
Get the metacontact for this contact.
Definition: kopetecontact.cpp:523
Kopete::TransferManager
Creates and manages kopete file transfers.
Definition: kopetetransfermanager.h:79
Kopete::ChatSession::myself
const Contact * myself() const
Get the local user in the session.
Definition: kopetechatsession.cpp:215
QLatin1String
Kopete::FileTransferInfo::KopeteTransferDirection
KopeteTransferDirection
Definition: kopetetransfermanager.h:46
Qt::escape
QString escape(const QString &plain)
Kopete::Message::setType
void setType(MessageType type)
Set message type.
Definition: kopetemessage.cpp:525
QTimerEvent::timerId
int timerId() const
Kopete::TransferManager::saveIncomingTransfer
void saveIncomingTransfer(unsigned int id)
Shows save file dialog and accepts/rejects incoming file transfer request.
Definition: kopetetransfermanager.cpp:414
QString::left
QString left(int n) const
QString::fromLatin1
QString fromLatin1(const char *str, int size)
Kopete::Contact::CanCreate
Definition: kopetecontact.h:297
Kopete::Message::setFilePreview
void setFilePreview(const QPixmap &preview)
Set file preview icon for file transfer.
Definition: kopetemessage.cpp:697
kopetemessage.h
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Kopete::Message
Representation of a message in Kopete.
Definition: kopetemessage.h:82
KJob
Kopete::Message::setFileSize
void setFileSize(unsigned long size)
Set file transfer size.
Definition: kopetemessage.cpp:684
TransferRateWindowLength
static const int TransferRateWindowLength
Definition: kopetetransfermanager.cpp:68
Kopete::Transfer::emitCopying
void emitCopying(const KUrl &src, const KUrl &dest)
Definition: kopetetransfermanager.cpp:205
kopetecontact.h
Kopete::Transfer::info
const FileTransferInfo & info() const
Get the info for this file transfer.
Definition: kopetetransfermanager.cpp:137
Kopete::TransferManager::askIncomingTransfer
unsigned int askIncomingTransfer(Contact *contact, const QString &file, const unsigned long size, const QString &description=QString(), QString internalId=QString(), const QPixmap &preview=QPixmap())
Adds incoming file transfer request to the Kopete::TransferManager.
Definition: kopetetransfermanager.cpp:372
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

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

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal