• 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.h
Go to the documentation of this file.
1 /*
2  kopetetransfermanager.h
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 #ifndef KOPETETRANSFERMANAGER_H
21 #define KOPETETRANSFERMANAGER_H
22 
23 #include <QtCore/QObject>
24 #include <QtCore/QPointer>
25 #include <QtCore/QString>
26 #include <QtCore/QMap>
27 
28 #include "kopete_export.h"
29 
30 #include <kio/job.h>
31 
32 namespace Kopete
33 {
34 
35 class Transfer;
36 class Contact;
37 class Message;
38 class ChatSession;
39 
43 class KOPETE_EXPORT FileTransferInfo
44 {
45 public:
46  enum KopeteTransferDirection { Incoming, Outgoing };
47 
48  FileTransferInfo();
49  FileTransferInfo( Contact *, const QStringList&, const unsigned long size, const QString &, KopeteTransferDirection di, const unsigned int id, QString internalId=QString(), const QPixmap &preview=QPixmap(), bool saveToDirectory = false );
50  ~FileTransferInfo() {}
51 
52  bool isValid() const { return (mContact && mId > 0); }
53  unsigned int transferId() const { return mId; }
54  Contact* contact() const { return mContact; }
55  QString file() const { return mFiles.value( 0 ); }
56  QStringList files() const { return mFiles; }
57  QString recipient() const { return mRecipient; }
58  unsigned long size() const { return mSize; }
59  QString internalId() const { return m_intId; }
60  KopeteTransferDirection direction() const { return mDirection; }
61  QPixmap preview() const { return mPreview; }
62  bool saveToDirectory() const { return mSaveToDirectory; }
63 
64 private:
65  unsigned long mSize;
66  QString mRecipient;
67  unsigned int mId;
68  QPointer<Contact> mContact;
69  QStringList mFiles;
70  QString m_intId;
71  KopeteTransferDirection mDirection;
72  QPixmap mPreview;
73  bool mSaveToDirectory;
74 };
75 
79 class KOPETE_EXPORT TransferManager : public QObject
80 {
81  Q_OBJECT
82 
83 public:
87  static TransferManager* transferManager();
88  virtual ~TransferManager() {}
89 
93  Transfer *addTransfer( Contact *contact, const QString& file, const unsigned long size, const QString &recipient, FileTransferInfo::KopeteTransferDirection di);
94 
99  Transfer *addTransfer( Contact *contact, const QStringList& files, const unsigned long size, const QString &recipient, FileTransferInfo::KopeteTransferDirection di);
100 
104  unsigned int askIncomingTransfer( Contact *contact, const QString& file, const unsigned long size, const QString& description=QString(), QString internalId=QString(), const QPixmap &preview=QPixmap() );
105 
113  unsigned int askIncomingTransfer( Contact *contact, const QStringList& files, const unsigned long size, const QString& description=QString(), QString internalId=QString(), const QPixmap &preview=QPixmap() );
114 
118  void saveIncomingTransfer( unsigned int id );
119 
123  void cancelIncomingTransfer( unsigned int id );
124 
140  void sendFile( const KUrl &file, const QString &localFile, unsigned long fileSize,
141  bool mustBeLocal, QObject *sendTo, const char *slot );
142 
143 signals:
145  void done( Kopete::Transfer* );
146 
148  void canceled( Kopete::Transfer* );
149 
153  void accepted(Kopete::Transfer*, const QString &fileName);
154 
156  void refused(const Kopete::FileTransferInfo& );
157 
159  void askIncomingDone( unsigned int id );
160 
162  void sendFile(const KUrl &file, const QString &localFile, unsigned int fileSize);
163 
164 private slots:
165  void slotComplete(KJob*);
166 
167 private:
168  TransferManager( QObject *parent );
169 
170  void removeTransfer( unsigned int id );
171 
172  KUrl getSaveFile( const KUrl& startDir ) const;
173  KUrl getSaveDir( const KUrl& startDir ) const;
174 
175  QMap<unsigned int, Transfer *> mTransfersMap;
176  QMap<unsigned int, FileTransferInfo> mTransferRequestInfoMap;
177 };
178 
183 class KOPETE_EXPORT Transfer : public KIO::Job
184 {
185  Q_OBJECT
186 
187 public:
191  Transfer( const FileTransferInfo &, const QString &localFile, bool showProgressInfo = true);
192 
196  explicit Transfer( const FileTransferInfo &, bool showProgressInfo = true);
197 
201  ~Transfer();
202 
204  const FileTransferInfo &info() const;
205 
211  KUrl sourceURL();
212 
217  KUrl destinationURL();
218 protected:
219  void emitCopying(const KUrl &src, const KUrl &dest);
220 
221  virtual void timerEvent ( QTimerEvent * event );
222 
223 public slots:
227  void slotNextFile( const QString &sourceFile, const QString &destinationFile );
228 
232  void slotProcessed(unsigned int);
233 
237  void slotComplete();
238 
245  void slotError( int error, const QString &errorText );
246 
248  void slotCancelled();
253  bool showMessage( QString text ) const;
254 
255 signals:
259  void transferCanceled();
260 
261 private:
262  void init( const KUrl &, bool );
263 
264  static KUrl displayURL( const Contact *contact, const QString &file );
265 
266  bool showHtmlMessage( QString text ) const;
267  QString fileForMessage() const;
268 
269  void stopTransferRateTimer();
270  Kopete::ChatSession* chatSession() const;
271 
272  class Private;
273  Private* d;
274 private slots:
275  void slotResultEmitted();
276  void slotContactDestroyed();
277 };
278 
279 }
280 
281 #endif // KOPETETRANSFERMANAGER_H
282 // vim: set noet ts=4 sts=4 sw=4:
KOPETE_EXPORT
#define KOPETE_EXPORT
Definition: kopete_export.h:27
Kopete::FileTransferInfo::~FileTransferInfo
~FileTransferInfo()
Definition: kopetetransfermanager.h:50
Kopete::FileTransferInfo
Definition: kopetetransfermanager.h:43
Kopete::TransferManager::~TransferManager
virtual ~TransferManager()
Definition: kopetetransfermanager.h:88
Kopete::FileTransferInfo::direction
KopeteTransferDirection direction() const
Definition: kopetetransfermanager.h:60
QMap
QPointer
Kopete::FileTransferInfo::internalId
QString internalId() const
Definition: kopetetransfermanager.h:59
Kopete::FileTransferInfo::size
unsigned long size() const
Definition: kopetetransfermanager.h:58
Kopete::ChatSession
Definition: kopetechatsession.h:74
Kopete::FileTransferInfo::recipient
QString recipient() const
Definition: kopetetransfermanager.h:57
Kopete::FileTransferInfo::saveToDirectory
bool saveToDirectory() const
Definition: kopetetransfermanager.h:62
QTimerEvent
QObject
Kopete::FileTransferInfo::preview
QPixmap preview() const
Definition: kopetetransfermanager.h:61
kopete_export.h
Kopete::FileTransferInfo::transferId
unsigned int transferId() const
Definition: kopetetransfermanager.h:53
QString
Kopete::Contact
Definition: kopetecontact.h:58
Kopete::FileTransferInfo::files
QStringList files() const
Definition: kopetetransfermanager.h:56
QStringList
QPixmap
Kopete::FileTransferInfo::file
QString file() const
Definition: kopetetransfermanager.h:55
Kopete::FileTransferInfo::contact
Contact * contact() const
Definition: kopetetransfermanager.h:54
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
Creates and manages kopete file transfers.
Definition: kopetetransfermanager.h:79
Kopete::FileTransferInfo::KopeteTransferDirection
KopeteTransferDirection
Definition: kopetetransfermanager.h:46
KJob
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