• 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
  • transfer-plugins
  • contentfetch
contentfetchfactory.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2 
3  Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 */
10 
11 #include "contentfetchfactory.h"
12 
13 #include "core/scheduler.h"
14 #include "core/transfergroup.h"
15 #include "contentfetch.h"
16 #include "contentfetchsetting.h"
17 
18 #include <QStringList>
19 #include <QList>
20 #include <QRegExp>
21 #include <QtGlobal>
22 
23 #include <KDebug>
24 
25 KGET_EXPORT_PLUGIN( ContentFetchFactory )
26 
27 ContentFetchFactory::ContentFetchFactory(QObject *parent,
28  const QVariantList &args)
29  : TransferFactory(parent, args)
30 {
31 }
32 
33 ContentFetchFactory::~ContentFetchFactory()
34 {
35 }
36 
37 Transfer * ContentFetchFactory::createTransfer( const KUrl &srcUrl,
38  const KUrl &destUrl,
39  TransferGroup * parent,
40  Scheduler * scheduler,
41  const QDomElement * e )
42 {
43  QStringList scriptPathList;
44  QVector<QRegExp> regexpList;
45  QStringList allRegexpList = ContentFetchSetting::self()->urlRegexpList();
46  QStringList allScriptPathList = ContentFetchSetting::self()->pathList();
47  QList<int> allEnableList = ContentFetchSetting::self()->enableList();
48 
49  // TODO: change to notify user without crash
50  // Q_ASSERT_X(scriptPathList.size() == regexpList.size(), "kcfg File", "Contentfetch config file corrupted!");
51  for (int i = 0; i < allRegexpList.size(); ++i)
52  {
53  if (allEnableList[i])
54  {
55  regexpList.push_back(QRegExp(allRegexpList[i]));
56  scriptPathList.push_back(allScriptPathList[i]);
57  }
58  }
59  // No user script exists
60  if (regexpList.size() == 0)
61  {
62  return 0;
63  }
64  QString url = srcUrl.url();
65  QStringList::iterator fileIter = scriptPathList.begin();
66  for(QVector<QRegExp>::iterator iter = regexpList.begin();
67  iter != regexpList.end(); ++iter, ++fileIter)
68  {
69  if (iter->indexIn(url) != -1)
70  {
71  kDebug(5001) << url << " match " << iter->pattern();
72  return new ContentFetch(parent, this, scheduler, srcUrl, destUrl,
73  *fileIter, e);
74  }
75  }
76  return 0;
77 }
78 
79 TransferHandler * ContentFetchFactory::createTransferHandler(
80  Transfer * transfer,
81  Scheduler * scheduler)
82 {
83  return new TransferHandler(transfer, scheduler);
84 }
85 
86 QWidget * ContentFetchFactory::createDetailsWidget(TransferHandler *transfer)
87 {
88  Q_UNUSED(transfer)
89  return 0; //Temporary!!
90 }
91 
92 const QList<KAction*> ContentFetchFactory::actions(TransferHandler *handler)
93 {
94  Q_UNUSED(handler)
95  return QList<KAction*>();
96 }
TransferHandler
Class TransferHandler:
Definition: transferhandler.h:48
TransferGroup
class TransferGroup:
Definition: transfergroup.h:46
Scheduler
Scheduler class: what handle all the jobs in kget.
Definition: scheduler.h:32
contentfetch.h
ContentFetchFactory::~ContentFetchFactory
~ContentFetchFactory()
Definition: contentfetchfactory.cpp:33
ContentFetchSetting::enableList
static QList< int > enableList()
Get List of whether the script is enabled.
Definition: contentfetchsetting.h:89
QWidget
QObject
ContentFetchSetting::self
static ContentFetchSetting * self()
Definition: contentfetchsetting.cpp:17
scheduler.h
ContentFetchSetting::urlRegexpList
static QStringList urlRegexpList()
Get List of the Regexp to match input URL.
Definition: contentfetchsetting.h:32
ContentFetchFactory
Definition: contentfetchfactory.h:23
transfergroup.h
ContentFetchFactory::createTransferHandler
TransferHandler * createTransferHandler(Transfer *transfer, Scheduler *scheduler)
Definition: contentfetchfactory.cpp:79
contentfetchfactory.h
ContentFetch
Definition: contentfetch.h:19
contentfetchsetting.h
ContentFetchFactory::createDetailsWidget
QWidget * createDetailsWidget(TransferHandler *transfer)
Definition: contentfetchfactory.cpp:86
ContentFetchSetting::pathList
static QStringList pathList()
Get List of the available search engine URLs.
Definition: contentfetchsetting.h:51
KGET_EXPORT_PLUGIN
#define KGET_EXPORT_PLUGIN(classname)
Declares a class as plugin.
Definition: kget_export.h:40
ContentFetchFactory::createTransfer
Transfer * createTransfer(const KUrl &srcUrl, const KUrl &destUrl, TransferGroup *parent, Scheduler *scheduler, const QDomElement *e=0)
Definition: contentfetchfactory.cpp:37
TransferFactory
TransferFactory.
Definition: transferfactory.h:52
Transfer
Definition: transfer.h:36
ContentFetchFactory::actions
const QList< KAction * > actions(TransferHandler *handler=0)
Definition: contentfetchfactory.cpp:92
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 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