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

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • core
urlchecker.h
Go to the documentation of this file.
1 /***************************************************************************
2 * Copyright (C) 2010 Matthias Fuchs <mat69@gmx.net> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
19 
20 #ifndef KGET_URL_CHECKER_H
21 #define KGET_URL_CHECKER_H
22 
23 #include "../kget_export.h"
24 
25 #include <KUrl>
26 
27 class Transfer;
28 class TransferHandler;
29 
34 class KGET_EXPORT UrlChecker
35 {
36  public:
37  enum UrlType {
38  Source,
39  Destination,
40  Folder
41  };
42 
50  explicit UrlChecker(UrlType type);
51  ~UrlChecker();
52 
56  static void removeDuplicates(KUrl::List &urls);
57 
58  //NOTE only first found error is reported, i.e. NotWriteable before ExistingFile if both are the case
59  enum UrlError {
60  //General
61  NoError = 0,
62  Empty,
63  Invalid,
64 
65  //Source only
66  NoProtocol,
67  NoHost,
68 
69  //Destination and Folder only
70  NotWriteable
71  };
72 
73  enum UrlWarning {
74  NoWarning = 0,
75  //Source and Destination only
76  ExistingFinishedTransfer,
77  ExistingTransfer,
78 
79  //Destination only
80  ExistingFile
81  };
82 
98  static UrlError checkUrl(const KUrl &url, const UrlType type, bool showNotification = false);
99 
104  static UrlError checkSource(const KUrl &source, bool showNotification = false);
105 
110  static UrlError checkDestination(const KUrl &destination, bool showNotification = false);
111 
116  static UrlError checkFolder(const KUrl &folder, bool showNotification = false);
117 
127  static bool wouldOverwrite(const KUrl &source, const KUrl &dest);
128 
139  static TransferHandler *existingTransfer(const KUrl &url, const UrlType type, UrlWarning *warning = 0);
140 
144  static KUrl::List hasExistingTransferMessages(const KUrl::List &urls, const UrlType type);
145 
153  static QString message(const KUrl &url, const UrlType type, const UrlError error);
154 
162  static QString message(const KUrl &url, const UrlType type, const UrlWarning warning);
163 
168  static QString message(const KUrl::List &urls, const UrlType type, const UrlError error);
169 
174  static QString message(const KUrl::List &urls, const UrlType type, const UrlWarning warning);
175 
186  static KUrl destUrl(const KUrl &destOrFolder, const KUrl &source, const QString &fileName = QString());
187 
189 
190  UrlType type() const;
191 
197  void setType(UrlType type);
198 
202  void clear();
203 
212  UrlError addUrl(const KUrl &url);
213 
223  bool addUrls(const KUrl::List &urls);
224 
228  void displayErrorMessages();
229 
234  KUrl::List correctUrls() const;
235 
246  void existingTransfers();
247 
259  KUrl checkExistingFile(const KUrl &source, const KUrl &destination);
260 
266  KUrl::List errorUrls()const;
267 
274  QHash<UrlError, KUrl::List> splitErrorUrls() const;
275 
276  private:
277  static TransferHandler *existingSource(const KUrl &url, UrlWarning &warning);
278  static TransferHandler *existingDestination(const KUrl &url, UrlWarning &warning);
279  static int hasExistingDialog(const KUrl &url, const UrlChecker::UrlType type, const UrlWarning warning);//TODO description --> returncode etc.!
280  static void removeTransfers(const QList<TransferHandler*> &toRemove);
281 
282  enum ExistingDialogReturn {
283  Cancel = 0,
284 
285  //old stuff is overwritten/deleted
286  Yes,
287  YesAll,
288 
289  //new stuff is not used
290  No,
291  NoAll
292  };
293 
294  private:
295  UrlType m_type;
296  KUrl::List m_correctUrls;
297  QHash<UrlError, KUrl::List> m_splitErrorUrls;
298 
299  QHash<UrlWarning, QPair<KUrl, Transfer*> > m_existingTransfers;
300  KUrl::List m_nonExistingUrls;
301 
302  //Existing files stuff
303  bool m_cancle;
304  bool m_overwriteAll;
305  bool m_autoRenameAll;
306  bool m_skipAll;
307 };
308 
309 
310 #endif
UrlChecker
This class provides static methods to check if urls are valid, and if not provides enums to see what ...
Definition: urlchecker.h:34
TransferHandler
Class TransferHandler:
Definition: transferhandler.h:48
UrlChecker::ExistingTransfer
Definition: urlchecker.h:77
UrlChecker::UrlError
UrlError
Definition: urlchecker.h:59
UrlChecker::Source
Definition: urlchecker.h:38
UrlChecker::Empty
Definition: urlchecker.h:62
UrlChecker::NoHost
Definition: urlchecker.h:67
UrlChecker::ExistingFinishedTransfer
Definition: urlchecker.h:76
UrlChecker::NoProtocol
Definition: urlchecker.h:66
UrlChecker::Invalid
Definition: urlchecker.h:63
UrlChecker::Destination
Definition: urlchecker.h:39
KGET_EXPORT
#define KGET_EXPORT
Definition: kget_export.h:24
UrlChecker::UrlWarning
UrlWarning
Definition: urlchecker.h:73
UrlChecker::UrlType
UrlType
Definition: urlchecker.h:37
Transfer
Definition: transfer.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

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