Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
KGet
Commits
314137d7
Commit
314137d7
authored
Aug 27, 2022
by
Nicolas Fella
Browse files
Remove contentfetch plugin
It has been disabled for a decade
parent
402fbff7
Pipeline
#226028
passed with stage
in 3 minutes and 15 seconds
Changes
27
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
transfer-plugins/CMakeLists.txt
View file @
314137d7
...
...
@@ -5,7 +5,6 @@ if (KF5Torrent_FOUND)
add_subdirectory
(
bittorrent
)
endif
(
KF5Torrent_FOUND
)
add_subdirectory
(
mirrorsearch
)
#add_subdirectory(contentfetch)
if
(
LIBMMS_FOUND
)
add_subdirectory
(
mmsthreads
)
endif
(
LIBMMS_FOUND
)
...
...
transfer-plugins/contentfetch/CMakeLists.txt
deleted
100644 → 0
View file @
402fbff7
add_subdirectory
(
scripts
)
add_library
(
kget_contentfetchfactory MODULE
)
target_sources
(
kget_contentfetchfactory PRIVATE
contentfetch.cpp
contentfetchfactory.cpp
script.cpp
scriptdownloadengine.cpp
scriptconfigadaptor.cpp
)
kconfig_add_kcfg_files
(
kget_contentfetchfactory contentfetchsetting.kcfgc
)
kcoreaddons_desktop_to_json
(
kget_contentfetchfactory kget_contentfetchfactory.desktop
)
target_link_libraries
(
kget_contentfetchfactory KF5::KIOCore KF5::KrossCore kgetcore
)
install
(
TARGETS kget_contentfetchfactory DESTINATION
${
KGET_PLUGIN_INSTALL_DIR
}
)
install
(
FILES kget_contentfetchfactory.kcfg DESTINATION
${
KDE_INSTALL_KCFGDIR
}
)
###Build KCM-Module
kcoreaddons_add_plugin
(
kcm_kget_contentfetchfactory INSTALL_NAMESPACE
"kget_kcms"
)
target_sources
(
kcm_kget_contentfetchfactory PRIVATE
dlgcontentfetchsettingwidget.cpp
dlgscriptediting.cpp
scriptconfigadaptor.cpp
)
ki18n_wrap_ui
(
kcm_kget_contentfetchfactory
dlgcontentfetchsettingwidget.ui
dlgscriptediting.ui
)
kconfig_add_kcfg_files
(
kcm_kget_contentfetchfactory contentfetchsetting.kcfgc
)
target_link_libraries
(
kcm_kget_contentfetchfactory KF5::KIOCore
KF5::KrossCore
${
KDE4_KROSSUI_LIBS
}
)
transfer-plugins/contentfetch/README
deleted
100644 → 0
View file @
402fbff7
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
This file describes how to write a script using the kross interface from
the content fetch plugin.
== API ==
=== Functions ===
Script developer must implement certain functions in the
script to be called by the content fetch plugin.
* startDownload(config) (MUST implement)
config: SciptConfigAdaptor type
Descrption:
KGet will call this function when it gets the url from the user
input and are ready to start the download process. This is the main
entry point of the script.
* configureScript(widget, config) (Optional)
Parameter:
widget: SettingWidgetAddptor (QWidget) type
config: SciptConfigAdaptor type
Description:
If your script need config options, and you have implement a ui to
show them (eg. via pyqt/pykde) , you will need this one. General way
to do this is to implement your own QWidget subclass and call
widget.setWidget(your_widget) to show it. You might use the config to
deal with ini style file conveniently.
* configurationAccepted(widget, config) (Optional)
Parameter:
widget: SettingWidgetAddptor (QWidget) type
config: SciptConfigAdaptor type
Description:
This function is called when user click 'ok' from the setting ui.
Generally you should save your options, possibly with the help of
the 'config' object.
=== Class ===
Some objects are not directly exposed to script, they are passed
in through the function arguments. Here describe their types.
* ScriptConfigAdaptor
** void setWidget(widget)
Parameter:
widget: QWidget type
Description:
The 'widget' should be your own script setting ui widget, once
you are ready with your widget, call this function to show it.
* SettingWidgetAdaptor
Description:
This class is a helper class to provide a parser for the convenience
to load/save the configuration file.
Functions:
** void setFile(config_file, path = "")
Parameter:
config_file: QString/string, config file name
path: QString/string, optional. The path of the config file, if
omitted, default value is the $KDEUSERDIR/share/app/kget/contentfetch_scripts_setting/
Description:
Initial the file, must be called before any read/write.
** void unsetFile()
Description:
Free the file resource, ready to call setFile() again.
** QVariant read(group, key, default_value)
Parameters:
group: string, section name
key: string, key name
default_value: int/double/string/list/stringlist
Description:
Read specific value from config, if not found, return default_value.
** void write()
Parameters:
group: string, section name
key: string, key name
value: int/double/string/list/stringlist
Description:
Change specific value in the config.
** void save()
Description:
Save the config data into file.
** void reset()
Abandon changes in the config data, reread from file.
=== Object ===
Objects are pointers exported to script using the kross lib,to use these
objects, you must import them first.
E.g. In python, you do 'import kgetcore'
* kgetcore
** void addTransfer(sourceUrl, filename)
Parameter:
sourceUrl: QString/string
filename: QString/string, optional
Description:
Add the sourceUrl into the kget transferlist with the download file
set to 'filename'. If filename is ommitted, then kget will determine
the filename.
** string getSourceUrl()
Description:
Return the sourceurl from user input.
** void finish()
Description:
Notify kget the processing of the script finishes, should be called
at the end of the script.
** void abort(error_message = "")
Parameter:
error_message: QString/string, optional
Description:
Notify kget the script has failed with the error message.
== NOTICE ==
* Don't use threading/thread function within python, it will freeze kget
(due to some GIL related issue?). Just write old-styled serialized
program. Same thing for other languages. This might be solved with the
improvement of kross.
transfer-plugins/contentfetch/contentfetch.cpp
deleted
100644 → 0
View file @
402fbff7
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#include
"contentfetch.h"
#include
"core/kget.h"
#include
"core/transfergroup.h"
#include
"script.h"
#include
<QDebug>
#include
<KLocalizedString>
#include
<KMessageBox>
#include
<KUrl>
#include
<kross/core/manager.h>
#include
<kross/core/action.h>
#include
<QDomElement>
#include
<QFile>
#include
<QString>
ContentFetch
::
ContentFetch
(
TransferGroup
*
parent
,
TransferFactory
*
factory
,
Scheduler
*
scheduler
,
const
KUrl
&
source
,
const
KUrl
&
dest
,
const
QString
&
scriptFile
,
const
QDomElement
*
e
)
:
Transfer
(
parent
,
factory
,
scheduler
,
source
,
dest
,
e
),
m_p_group
(
parent
),
m_scriptFile
(
scriptFile
),
m_destDir
(
dest
.
directory
(
KUrl
::
AppendTrailingSlash
))
{
m_p_script
=
new
Script
(
this
,
source
);
connect
(
m_p_script
,
SIGNAL
(
newTransfer
(
QString
,
QString
)),
this
,
SLOT
(
slotAddTransfer
(
QString
,
QString
)));
connect
(
m_p_script
,
SIGNAL
(
finished
()),
this
,
SLOT
(
slotFinish
()));
connect
(
m_p_script
,
SIGNAL
(
aborted
(
QString
)),
this
,
SLOT
(
slotAbort
(
QString
)));
connect
(
m_p_script
,
SIGNAL
(
percentUpdated
(
int
)),
this
,
SLOT
(
setPercent
(
int
)));
connect
(
m_p_script
,
SIGNAL
(
textStatusUpdated
(
QString
)),
this
,
SLOT
(
slotSetTextStatus
(
QString
)));
}
void
ContentFetch
::
deinit
()
{
return
;
}
void
ContentFetch
::
start
()
{
qCDebug
(
KGET_DEBUG
)
<<
"ContentFetch::start"
;
setStatus
(
Job
::
Running
,
i18nc
(
"Transfer state: processing script"
,
"Processing script...."
),
"media-playback-start"
);
setTransferChange
(
Tc_Status
,
true
);
m_p_script
->
setFile
(
m_scriptFile
);
m_p_script
->
start
();
qCDebug
(
KGET_DEBUG
)
<<
"ContentFetch::start() finished!"
;
}
void
ContentFetch
::
stop
()
{
if
(
status
()
==
Stopped
)
{
return
;
}
qCDebug
(
KGET_DEBUG
)
<<
"ContentFetch::stop"
;
// kill -9 the script
m_p_script
->
terminate
();
// delete m_p_script to avoid crash?
setStatus
(
Job
::
Stopped
,
i18nc
(
"transfer state: stopped"
,
"Stopped"
),
"process-stop"
);
setTransferChange
(
Tc_Status
,
true
);
}
void
ContentFetch
::
slotAddTransfer
(
const
QString
&
url
,
const
QString
&
filename
)
{
// even if filename is empty it's still ok
qDebug
()
<<
"The whole filename is "
<<
m_destDir
+
filename
;
KGet
::
addTransfer
(
KUrl
(
url
),
m_destDir
+
filename
,
m_p_group
->
name
(),
true
);
}
void
ContentFetch
::
slotFinish
()
{
m_percent
=
100
;
setStatus
(
Job
::
Finished
,
i18nc
(
"Transfer State: Finished"
,
"Finished"
),
"dialog-ok"
);
setTransferChange
(
Tc_Status
|
Tc_Percent
,
true
);
//delete m_p_script;
}
void
ContentFetch
::
slotAbort
(
const
QString
&
error
)
{
if
(
error
.
isEmpty
())
{
setStatus
(
Job
::
Aborted
,
i18nc
(
"Transfer State: Aborted"
,
"Aborted"
),
"process-stop"
);
}
else
{
setStatus
(
Job
::
Aborted
,
error
,
"process-stop"
);
}
setTransferChange
(
Tc_Status
,
true
);
}
void
ContentFetch
::
slotSetTextStatus
(
const
QString
&
text
)
{
setStatus
(
Job
::
Running
,
text
,
"media-playback-start"
);
setTransferChange
(
Tc_Status
,
true
);
}
bool
ContentFetch
::
isResumable
()
const
{
return
false
;
}
void
ContentFetch
::
setPercent
(
int
percent
)
{
m_percent
=
percent
;
setTransferChange
(
Transfer
::
Tc_Percent
,
true
);
}
transfer-plugins/contentfetch/contentfetch.h
deleted
100644 → 0
View file @
402fbff7
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#ifndef CONTENT_FETCH_H
#define CONTENT_FETCH_H
#include
"core/transfer.h"
#include
"script.h"
#include
<QString>
class
ContentFetch
:
public
Transfer
{
Q_OBJECT
public:
ContentFetch
(
TransferGroup
*
parent
,
TransferFactory
*
factory
,
Scheduler
*
scheduler
,
const
KUrl
&
src
,
const
KUrl
&
dest
,
const
QString
&
scriptFile
,
const
QDomElement
*
e
=
nullptr
);
public
Q_SLOTS
:
void
deinit
();
// --- Job virtual functions ---
void
start
();
void
stop
();
bool
isResumable
()
const
;
void
setPercent
(
int
percent
);
private:
Script
*
m_p_script
;
TransferGroup
*
m_p_group
;
QString
m_scriptFile
;
QString
m_destDir
;
private
Q_SLOTS
:
void
slotFinish
();
void
slotAbort
(
const
QString
&
);
void
slotAddTransfer
(
const
QString
&
url
,
const
QString
&
filename
);
void
slotSetTextStatus
(
const
QString
&
text
);
};
#endif // CONTENT_FETCH_H
transfer-plugins/contentfetch/contentfetchfactory.cpp
deleted
100644 → 0
View file @
402fbff7
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#include
"contentfetchfactory.h"
#include
"core/scheduler.h"
#include
"core/transfergroup.h"
#include
"contentfetch.h"
#include
"contentfetchsetting.h"
#include
<QStringList>
#include
<QList>
#include
<QRegExp>
#include
<QtGlobal>
#include
<QDebug>
K_PLUGIN_CLASS_WITH_JSON
(
ContentFetchFactory
,
"kget_contentfetchfactory.json"
)
ContentFetchFactory
::
ContentFetchFactory
(
QObject
*
parent
,
const
QVariantList
&
args
)
:
TransferFactory
(
parent
,
args
)
{
}
ContentFetchFactory
::~
ContentFetchFactory
()
{
}
Transfer
*
ContentFetchFactory
::
createTransfer
(
const
KUrl
&
srcUrl
,
const
KUrl
&
destUrl
,
TransferGroup
*
parent
,
Scheduler
*
scheduler
,
const
QDomElement
*
e
)
{
QStringList
scriptPathList
;
QVector
<
QRegExp
>
regexpList
;
QStringList
allRegexpList
=
ContentFetchSetting
::
self
()
->
urlRegexpList
();
QStringList
allScriptPathList
=
ContentFetchSetting
::
self
()
->
pathList
();
QList
<
int
>
allEnableList
=
ContentFetchSetting
::
self
()
->
enableList
();
// TODO: change to notify user without crash
// Q_ASSERT_X(scriptPathList.size() == regexpList.size(), "kcfg File", "Contentfetch config file corrupted!");
for
(
int
i
=
0
;
i
<
allRegexpList
.
size
();
++
i
)
{
if
(
allEnableList
[
i
])
{
regexpList
.
push_back
(
QRegExp
(
allRegexpList
[
i
]));
scriptPathList
.
push_back
(
allScriptPathList
[
i
]);
}
}
// No user script exists
if
(
regexpList
.
size
()
==
0
)
{
return
0
;
}
QString
url
=
srcUrl
.
url
();
QStringList
::
iterator
fileIter
=
scriptPathList
.
begin
();
for
(
QVector
<
QRegExp
>::
iterator
iter
=
regexpList
.
begin
();
iter
!=
regexpList
.
end
();
++
iter
,
++
fileIter
)
{
if
(
iter
->
indexIn
(
url
)
!=
-
1
)
{
qCDebug
(
KGET_DEBUG
)
<<
url
<<
" match "
<<
iter
->
pattern
();
return
new
ContentFetch
(
parent
,
this
,
scheduler
,
srcUrl
,
destUrl
,
*
fileIter
,
e
);
}
}
return
0
;
}
TransferHandler
*
ContentFetchFactory
::
createTransferHandler
(
Transfer
*
transfer
,
Scheduler
*
scheduler
)
{
return
new
TransferHandler
(
transfer
,
scheduler
);
}
QWidget
*
ContentFetchFactory
::
createDetailsWidget
(
TransferHandler
*
transfer
)
{
Q_UNUSED
(
transfer
)
return
0
;
//Temporary!!
}
const
QList
<
QAction
*>
ContentFetchFactory
::
actions
(
TransferHandler
*
handler
)
{
Q_UNUSED
(
handler
)
return
QList
<
QAction
*>
();
}
transfer-plugins/contentfetch/contentfetchfactory.h
deleted
100644 → 0
View file @
402fbff7
/* This file is part of the KDE project
Copyright (C) 2004 Ningyu Shi <shiningyu@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#ifndef CONTENT_FETCH_FACTORY_H
#define CONTENT_FETCH_FACTORY_H
#include
"core/plugin/transferfactory.h"
#include
<QStringList>
#include
<QList>
class
Transfer
;
class
TransferGroup
;
class
Scheduler
;
class
ContentFetchFactory
:
public
TransferFactory
{
Q_OBJECT
public:
ContentFetchFactory
(
QObject
*
parent
,
const
QVariantList
&
args
);
~
ContentFetchFactory
();
Transfer
*
createTransfer
(
const
KUrl
&
srcUrl
,
const
KUrl
&
destUrl
,
TransferGroup
*
parent
,
Scheduler
*
scheduler
,
const
QDomElement
*
e
=
nullptr
);
TransferHandler
*
createTransferHandler
(
Transfer
*
transfer
,
Scheduler
*
scheduler
);
QWidget
*
createDetailsWidget
(
TransferHandler
*
transfer
);
const
QList
<
QAction
*>
actions
(
TransferHandler
*
handler
=
nullptr
);
};
#endif // CONTENT_FETCH_FACTORY_H
transfer-plugins/contentfetch/contentfetchsetting.kcfgc
deleted
100644 → 0
View file @
402fbff7
ClassName=ContentFetchSetting
File=kget_contentfetchfactory.kcfg
Mutators=true
Singleton=true
Visibility=KDE_EXPORT
IncludeFiles=qstandardpaths.h
transfer-plugins/contentfetch/dlgcontentfetchsettingwidget.cpp
deleted
100644 → 0
View file @
402fbff7
/* This file is part of the KDE project
Copyright (C) 2008 Ningyu Shi <shiningyu@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#include
"dlgcontentfetchsettingwidget.h"
#include
"dlgscriptediting.h"
#include
"contentfetchsetting.h"
#include
"scriptconfigadaptor.h"
#include
"kget_export.h"
#include
<QSize>
#include
<QDialog>
#include
<QDebug>
#include
<KConfigGroup>
KGET_EXPORT_PLUGIN_CONFIG
(
DlgContentFetchSettingWidget
)
DlgContentFetchSettingWidget
::
DlgContentFetchSettingWidget
(
QWidget
*
parent
=
nullptr
,
const
QVariantList
&
args
=
QVariantList
())
:
KCModule
(
KGetFactory
::
componentData
(),
parent
,
args
),
m_p_action
(
nullptr
)
{
ui
.
setupUi
(
this
);
ui
.
newScriptButton
->
setIcon
(
QIcon
::
fromTheme
(
"list-add"
));
ui
.
removeScriptButton
->
setIcon
(
QIcon
::
fromTheme
(
"list-remove"
));
loadContentFetchSetting
();
connect
(
ui
.
newScriptButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
slotNewScript
()));
connect
(
ui
.
editScriptButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
slotEditScript
()));
connect
(
ui
.
configureScriptButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
slotConfigureScript
()));
connect
(
ui
.
removeScriptButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
slotRemoveScript
()));
connect
(
ui
.
scriptTreeWidget
,
SIGNAL
(
itemClicked
(
QTreeWidgetItem
*
,
int
)),
this
,
SLOT
(
slotCheckConfigurable
(
QTreeWidgetItem
*
,
int
)));
connect
(
ui
.
scriptTreeWidget
,
SIGNAL
(
itemChanged
(
QTreeWidgetItem
*
,
int
)),
this
,
SLOT
(
slotEnableChanged
(
QTreeWidgetItem
*
,
int
)));
}
DlgContentFetchSettingWidget
::~
DlgContentFetchSettingWidget
()
{
}
void
DlgContentFetchSettingWidget
::
slotNewScript
()
{
QPointer
<
DlgScriptEditing
>
dialog
=
new
DlgScriptEditing
(
this
);
if
(
dialog
->
exec
())
{
addScriptItem
(
true
,
dialog
->
scriptPath
(),
dialog
->
scriptUrlRegexp
(),
dialog
->
scriptDescription
());
}
changed
();
}
void
DlgContentFetchSettingWidget
::
slotEditScript
()
{
QList
<
QTreeWidgetItem
*>
selectedItems
=
ui
.
scriptTreeWidget
->
selectedItems
();
// only edit one item at one time
if
(
selectedItems
.
size
()
!=
1
)
{
return
;
}
QTreeWidgetItem
&
item
=
*
(
selectedItems
[
0
]);
QPointer
<
DlgScriptEditing
>
dialog
=
new
DlgScriptEditing
(
this
,
(
QStringList
()
<<
item
.
toolTip
(
0
)
<<
item
.
text
(
1
)
<<
item
.
text
(
2
)));
if
(
dialog
->
exec
())
{
if
(
item
.
toolTip
(
0
)
!=
dialog
->
scriptPath
())
{
item
.
setText
(
0
,
QFileInfo
(
dialog
->
scriptPath
()).
fileName
());
item
.
setToolTip
(
0
,
dialog
->
scriptPath
());
changed
();
}
if
(
item
.
text
(
1
)
!=
dialog
->
scriptUrlRegexp
())
{
item
.
setText
(
1
,
dialog
->
scriptUrlRegexp
());
changed
();
}
if
(
item
.
text
(
2
)
!=
dialog
->
scriptDescription
())
{
item
.
setText
(
2
,
dialog
->
scriptDescription
());
changed
();
}
}
}
void
DlgContentFetchSettingWidget
::
slotConfigureScript
()
{
QList
<
QTreeWidgetItem
*>
selectedItems
=
ui
.
scriptTreeWidget
->
selectedItems
();
// only configure one item at one time
if
(
selectedItems
.
size
()
!=
1
)
{
return
;
}
QString
filename
=
selectedItems
[
0
]
->
toolTip
(
0
);
if
(
m_p_action
)
{
delete
m_p_action
;
}
m_p_action
=
new
Kross
::
Action
(
this
,
QString
(
"%1_ContentFetchConfig"
).
arg
(
filename
));
// TODO add check file
m_p_action
->
setFile
(
filename
);
m_p_action
->
addObject
(
this
,
"kgetscriptconfig"
,
Kross
::
ChildrenInterface
::
AutoConnectSignals
);