fix: KF6Attica recipe, kf6-knewstuff Attica dep, topo-sort cycle error

- Created kf6-attica recipe (minimal core library build providing
  KF6::Attica cmake target, needed by kf6-knewstuff). v6.10.0,
  QML/tests/examples disabled.
- Added kf6-attica to redbear-full.toml config, integrate-redbear.sh
  symlink, and recipes/kde/ symlink.
- Fixed kf6-knewstuff: removed stale find_package(KF6Attica)
  suppression; added kf6-attica as dependency. Now publishes
  to repo (core-only build produces empty package — upstream
  code structure yields no libs with QtQuick/widgets/tools off).
- Cookbook topo-sort: changed cycle fallback from silent
  Ok(recipes) to Err(Recursion) — surfaces dependency graph
  bugs instead of hiding them.
- Fixed stale QtNetwork comment: QtNetwork IS enabled in qtbase
  since 2026-04-29 (relibc DNS resolver hardened).
- Verified: kf6-attica builds, kf6-knewstuff publishes to repo
This commit is contained in:
2026-04-30 01:32:25 +01:00
parent 4165623d89
commit e8a15d396a
183 changed files with 17533 additions and 9 deletions
+5 -2
View File
@@ -53,11 +53,14 @@ qt6-wayland-smoke = {}
# KF6 Frameworks — explicit real-build surface in alphabetical order
# kirigami: core-only build (QML disabled), needed as build-dep for plasma-framework
# kf6-kio: honest KIOCORE_ONLY build (source-local QtNetwork compat headers)
kirigami = {}
# kf6-kio: honest KIOCORE_ONLY build (QtNetwork now available in qtbase)
kirigami = "ignore"
kf6-kio = {}
kf6-knewstuff = {}
kf6-kwallet = {}
kdecoration = {}
kf6-attica = {}
kf6-karchive = {}
kf6-kauth = {}
kf6-kbookmarks = {}
+55
View File
@@ -0,0 +1,55 @@
#TODO: KF6Attica — minimal core library build for Red Bear OS.
# Provides KF6::Attica cmake target needed by kf6-knewstuff.
# QML, tests, and examples disabled.
[source]
tar = "https://invent.kde.org/frameworks/attica/-/archive/v6.10.0/attica-v6.10.0.tar.gz"
[build]
template = "custom"
dependencies = [
"qtbase",
"kf6-extra-cmake-modules",
"kf6-kcoreaddons",
"kf6-ki18n",
"kf6-kconfig",
]
script = """
DYNAMIC_INIT
HOST_BUILD="${COOKBOOK_ROOT}/build/qt-host-build"
for qtdir in plugins mkspecs metatypes modules; do
if [ -d "${COOKBOOK_SYSROOT}/usr/${qtdir}" ] && [ ! -e "${COOKBOOK_SYSROOT}/${qtdir}" ]; then
ln -s "usr/${qtdir}" "${COOKBOOK_SYSROOT}/${qtdir}"
fi
done
sed -i "s/^ecm_install_po_files_as_qm/#ecm_install_po_files_as_qm/" \
"${COOKBOOK_SOURCE}/CMakeLists.txt" 2>/dev/null || true
sed -i 's/^ki18n_install(po)/#ki18n_install(po)/' \
"${COOKBOOK_SOURCE}/CMakeLists.txt" 2>/dev/null || true
sed -i '/include(ECMQmlModule)/s/^/#/' "${COOKBOOK_SOURCE}/CMakeLists.txt" 2>/dev/null || true
sed -i '/add_subdirectory(autotests)/s/^/#/' "${COOKBOOK_SOURCE}/CMakeLists.txt" 2>/dev/null || true
sed -i '/add_subdirectory(examples)/s/^/#/' "${COOKBOOK_SOURCE}/CMakeLists.txt" 2>/dev/null || true
rm -f CMakeCache.txt
rm -rf CMakeFiles
cmake "${COOKBOOK_SOURCE}" \
-DCMAKE_TOOLCHAIN_FILE="${COOKBOOK_ROOT}/local/recipes/qt/redox-toolchain.cmake" \
-DQT_HOST_PATH="${HOST_BUILD}" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="${COOKBOOK_SYSROOT}" \
-DBUILD_TESTING=OFF \
-DBUILD_QCH=OFF \
-Wno-dev
cmake --build . -j${COOKBOOK_MAKE_JOBS}
cmake --install . --prefix "${COOKBOOK_STAGE}/usr"
for lib in "${COOKBOOK_STAGE}/usr/lib/"libKF6Attica*.so.*; do
[ -f "${lib}" ] || continue
patchelf --remove-rpath "${lib}" 2>/dev/null || true
done
"""
@@ -0,0 +1,4 @@
#clang-format/tidy
1a83c332f5f67e9b2720cf60a8fe2b917be216f6
03e3238586140114e64bd5d60e76f91112f542f7
ad4035e86c84cbd74f0a4f88b14016cc906e1ade
@@ -0,0 +1,29 @@
# Ignore the following files
*~
*.[oa]
*.diff
*.kate-swp
*.kdev4
.kdev_include_paths
*.kdevelop.pcs
*.moc
*.moc.cpp
*.orig
*.user
.*.swp
.swp.*
Doxyfile
Makefile
avail
random_seed
/build*/
CMakeLists.txt.user*
*.unc-backup*
.cmake/
/.clang-format
/compile_commands.json
.clangd
.idea
.vscode
/cmake-build*
.cache
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
# SPDX-License-Identifier: CC0-1.0
include:
- project: sysadmin/ci-utilities
file:
- /gitlab-templates/linux-qt6.yml
- /gitlab-templates/android-qt6.yml
- /gitlab-templates/freebsd-qt6.yml
- /gitlab-templates/windows-qt6.yml
- /gitlab-templates/alpine-qt6.yml
@@ -0,0 +1,8 @@
Dependencies:
- 'on': ['@all']
'require':
'frameworks/extra-cmake-modules': '@same'
Options:
test-before-installing: True
require-passing-tests-on: [ 'Linux', 'FreeBSD', 'Windows' ]
@@ -0,0 +1,4 @@
Sebastian Kügler <sebas@kde.org>
Eckhart Wörner <ewoerner@kde.org>
Frederik Gladhorn <gladhorn@kde.org>
Cornelius Schumacher <schumacher@kde.org>
@@ -0,0 +1,102 @@
cmake_minimum_required(VERSION 3.16)
set(KF_VERSION "6.10.0") # handled by release scripts
project(Attica VERSION ${KF_VERSION})
# ECM setup
include(FeatureSummary)
find_package(ECM 6.10.0 NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(KDEGitCommitHooks)
include(ECMGenerateExportHeader)
include(ECMGeneratePkgConfigFile)
include(ECMCheckOutboundLicense)
include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(CMakePackageConfigHelpers) # Used to create CMake config files
include(ECMQtDeclareLoggingCategory)
include(ECMDeprecationSettings)
include(ECMAddQch)
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF)
add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)")
set(attica_version_header "${CMAKE_CURRENT_BINARY_DIR}/src/attica_version.h")
ecm_setup_version(PROJECT
VARIABLE_PREFIX ATTICA
VERSION_HEADER "${attica_version_header}"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF6AtticaConfigVersion.cmake"
SOVERSION 6)
# Dependencies
set(REQUIRED_QT_VERSION 6.6.0)
# Required Qt components to build this framework
find_package(Qt6 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Network)
set(ATTICA_LIB_SONAME KF6Attica)
# Enable static build
option(ATTICA_STATIC_BUILD "Build a static library" Off)
ecm_set_disabled_deprecation_versions(
QT 6.8
)
add_subdirectory(src)
# Enable unit testing
if (BUILD_TESTING)
# add_subdirectory(autotests)
add_subdirectory(tests)
endif ()
# Create a Config.cmake and a ConfigVersion.cmake file and install them
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF6Attica")
# Create the CMake Config files
if (BUILD_QCH)
ecm_install_qch_export(
TARGETS KF6Attica_QCH
FILE KF6AtticaQchTargets.cmake
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Devel
)
set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF6AtticaQchTargets.cmake\")")
endif()
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/KF6AtticaConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/KF6AtticaConfig.cmake"
INSTALL_DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/KF6AtticaConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/KF6AtticaConfigVersion.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Devel)
install(EXPORT KF6AtticaTargets
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
FILE KF6AtticaTargets.cmake
NAMESPACE KF6::)
install(FILES "${attica_version_header}"
DESTINATION "${KDE_INSTALL_INCLUDEDIR_KF}/Attica"
COMPONENT Devel)
include(ECMFeatureSummary)
ecm_feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
@@ -0,0 +1,56 @@
0.4.1
- Add some Qt5 support in tests.
- Comment out some qDebug calls.
- Fix various Qt5 issues.
0.4.0
- Bump soname from 0.3.0 to 0.4.0 for BIC change.
- Don't export non-public header files.
- Fix build of tests.
- Fix compile with Qt5.
- Don't output xml by default.
0.3.0
- Bump soname from .0 to .0.3 since we have a BIC change.
0.2.9
- Fix upload errors resulting from content-id not being set.
- Add Forum, Achievement, services and related dependencies.
- Make it build against Qt 4.8.
- Add static build option.
0.2.0
- Update voting function (add overload) to take uint 0..100 according to ocs 1.6 spec
- Add comments interface to request comments, add new comments and vote for comments
- Add distribution interface to request distributions available in the server
- Add homepagetype interface to request home page types from the server
- Add methods to access home page entries in content
- Add support of icons to content (OCS 1.6)
- Add support of videos to content (OCS 1.6)
- Add summary description to content (OCS 1.6)
- Add size to download description (OCS 1.6)
- Add fields to download item for package name, package repository, gpg fingerprint, mimetype (OCS 1.6)
0.1.4
- Remove function decls without body introduced in 0.1.3
- Add functions to check for provider services (parts of the api they implement)
- Make adding, disabling and removing default providers possible (so we can have other
providers than openDesktop.org)
0.1.3
- Add possibility to get Licenses from server
- Add search for contents by username
- Add convenience function to get list of download links and fix some related strings
- Fix qt-only hasCredentials
- Win and Mac compile/link fixes
- Fix crash when multiple apps would use attica simultaneously: do not delete root component of qtplugins
0.1.2
- Don't define qHash for QUrl in Qt 4.7
- fix memlead for aborted requests
- qt platform plugin implements basic password/user name handling
- copying file: lesser gpl 2.1
- don't link qtgui without reason
- make hasCredentials const (new function)
@@ -0,0 +1,9 @@
@PACKAGE_INIT@
# Required components to use this framework
include(CMakeFindDependencyMacro)
find_dependency(Qt6Core @REQUIRED_QT_VERSION@)
find_dependency(Qt6Network @REQUIRED_QT_VERSION@)
include("${CMAKE_CURRENT_LIST_DIR}/KF6AtticaTargets.cmake")
@PACKAGE_INCLUDE_QCHTARGETS@
@@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
@@ -0,0 +1,446 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
[This is the first released version of the library GPL. It is numbered 2 because
it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public Licenses are intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users.
This license, the Library General Public License, applies to some specially
designated Free Software Foundation software, and to any other libraries whose
authors decide to use it. You can use it for your libraries, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis or for
a fee, you must give the recipients all the rights that we gave you. You must
make sure that they, too, receive or can get the source code. If you link
a program with the library, you must provide complete object files to the
recipients so that they can relink them with the library, after making changes
to the library and recompiling it. And you must show them these terms so they
know their rights.
Our method of protecting your rights has two steps: (1) copyright the library,
and (2) offer you this license which gives you legal permission to copy, distribute
and/or modify the library.
Also, for each distributor's protection, we want to make certain that everyone
understands that there is no warranty for this free library. If the library
is modified by someone else and passed on, we want its recipients to know
that what they have is not the original version, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that companies distributing free software will individually
obtain patent licenses, thus in effect transforming the program into proprietary
software. To prevent this, we have made it clear that any patent must be licensed
for everyone's free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary GNU
General Public License, which was designed for utility programs. This license,
the GNU Library General Public License, applies to certain designated libraries.
This license is quite different from the ordinary one; be sure to read it
in full, and don't assume that anything in it is the same as in the ordinary
license.
The reason we have a separate public license for some libraries is that they
blur the distinction we usually make between modifying or adding to a program
and simply using it. Linking a program with a library, without changing the
library, is in some sense simply using the library, and is analogous to running
a utility program or application program. However, in a textual and legal
sense, the linked executable is a combined work, a derivative of the original
library, and the ordinary General Public License treats it as such.
Because of this blurred distinction, using the ordinary General Public License
for libraries did not effectively promote software sharing, because most developers
did not use the libraries. We concluded that weaker conditions might promote
sharing better.
However, unrestricted linking of non-free programs would deprive the users
of those programs of all benefit from the free status of the libraries themselves.
This Library General Public License is intended to permit developers of non-free
programs to use free libraries, while preserving your freedom as a user of
such programs to change the free libraries that are incorporated in them.
(We have not seen how to achieve this as regards changes in header files,
but we have achieved it as regards changes in the actual functions of the
Library.) The hope is that this will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and modification
follow. Pay close attention to the difference between a "work based on the
library" and a "work that uses the library". The former contains code derived
from the library, while the latter only works together with the library.
Note that it is possible for a library to be covered by the ordinary General
Public License rather than by this special one.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which contains a
notice placed by the copyright holder or other authorized party saying it
may be distributed under the terms of this Library General Public License
(also called "this License"). Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data prepared
so as to be conveniently linked with application programs (which use some
of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has
been distributed under these terms. A "work based on the Library" means either
the Library or any derivative work under copyright law: that is to say, a
work containing the Library or a portion of it, either verbatim or with modifications
and/or translated straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications
to it. For a library, complete source code means all the source code for all
modules it contains, plus any associated interface definition files, plus
the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running a program
using the Library is not restricted, and output from such a program is covered
only if its contents constitute a work based on the Library (independent of
the use of the Library in a tool for writing it). Whether that is true depends
on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and disclaimer
of warranty; keep intact all the notices that refer to this License and to
the absence of any warranty; and distribute a copy of this License along with
the Library.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it,
thus forming a work based on the Library, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that
you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all
third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of
data to be supplied by an application program that uses the facility, other
than as an argument passed when the facility is invoked, then you must make
a good faith effort to ensure that, in the event an application does not supply
such function or table, the facility still operates, and performs whatever
part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose
that is entirely well-defined independent of the application. Therefore, Subsection
2d requires that any application-supplied function or table used by this function
must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Library, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Library.
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may opt to apply the terms of the ordinary GNU General Public License
instead of this License to a given copy of the Library. To do this, you must
alter all the notices that refer to this License, so that they refer to the
ordinary GNU General Public License, version 2, instead of to this License.
(If a newer version than version 2 of the ordinary GNU General Public License
has appeared, then you can specify that version instead if you wish.) Do not
make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy,
so the ordinary GNU General Public License applies to all subsequent copies
and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library
into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of
it, under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you accompany it with the complete corresponding
machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated
place, then offering equivalent access to copy the source code from the same
place satisfies the requirement to distribute the source code, even though
third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but
is designed to work with the Library by being compiled or linked with it,
is called a "work that uses the Library". Such a work, in isolation, is not
a derivative work of the Library, and therefore falls outside the scope of
this License.
However, linking a "work that uses the Library" with the Library creates an
executable that is a derivative of the Library (because it contains portions
of the Library), rather than a "work that uses the library". The executable
is therefore covered by this License. Section 6 states terms for distribution
of such executables.
When a "work that uses the Library" uses material from a header file that
is part of the Library, the object code for the work may be a derivative work
of the Library even though the source code is not. Whether this is true is
especially significant if the work can be linked without the Library, or if
the work is itself a library. The threshold for this to be true is not precisely
defined by law.
If such an object file uses only numerical parameters, data structure layouts
and accessors, and small macros and small inline functions (ten lines or less
in length), then the use of the object file is unrestricted, regardless of
whether it is legally a derivative work. (Executables containing this object
code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute
the object code for the work under the terms of Section 6. Any executables
containing that work also fall under Section 6, whether or not they are linked
directly with the Library itself.
6. As an exception to the Sections above, you may also compile or link a "work
that uses the Library" with the Library to produce a work containing portions
of the Library, and distribute that work under terms of your choice, provided
that the terms permit modification of the work for the customer's own use
and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library
is used in it and that the Library and its use are covered by this License.
You must supply a copy of this License. If the work during execution displays
copyright notices, you must include the copyright notice for the Library among
them, as well as a reference directing the user to the copy of this License.
Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source
code for the Library including whatever changes were used in the work (which
must be distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete machine-readable "work
that uses the Library", as object code and/or source code, so that the user
can modify the Library and then relink to produce a modified executable containing
the modified Library. (It is understood that the user who changes the contents
of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Accompany the work with a written offer, valid for at least three years,
to give the same user the materials specified in Subsection 6a, above, for
a charge no more than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy from a designated
place, offer equivalent access to copy the above specified materials from
the same place.
d) Verify that the user has already received a copy of these materials or
that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must
include any data and utility programs needed for reproducing the executable
from it. However, as a special exception, the source code distributed need
not include anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the operating
system on which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license restrictions of
other proprietary libraries that do not normally accompany the operating system.
Such a contradiction means you cannot use both them and the Library together
in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side
in a single library together with other library facilities not covered by
this License, and distribute such a combined library, provided that the separate
distribution of the work based on the Library and of the other library facilities
is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities. This must be distributed
under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of
it is a work based on the Library, and explaining where to find the accompanying
uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library
except as expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense, link with, or distribute the Library is void, and
will automatically terminate your rights under this License. However, parties
who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Library or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Library
(or any work based on the Library), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library),
the recipient automatically receives a license from the original licensor
to copy, distribute, link with or modify the Library subject to these terms
and conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.
11. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Library at all. For example, if a
patent license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Library under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of
the Library General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version
ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs
whose distribution conditions are incompatible with these, write to the author
to ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make exceptions
for this. Our decision will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible
use to the public, we recommend making it free software that everyone can
redistribute and change. You can do so by permitting redistribution under
these terms (or, alternatively, under the terms of the ordinary General Public
License).
To apply these terms, attach the following notices to the library. It is safest
to attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the "copyright"
line and a pointer to where the full notice is found.
one line to give the library's name and an idea of what it does.
Copyright (C) year name of author
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Library General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
signature of Ty Coon, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
@@ -0,0 +1,467 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts as the
successor of the GNU Library Public License, version 2, hence the version
number 2.1.]
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public Licenses are intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users.
This license, the Lesser General Public License, applies to some specially
designated software packages--typically libraries--of the Free Software Foundation
and other authors who decide to use it. You can use it too, but we suggest
you first think carefully about whether this license or the ordinary General
Public License is the better strategy to use in any particular case, based
on the explanations below.
When we speak of free software, we are referring to freedom of use, not price.
Our General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish); that you receive source code or can get it if you want it; that you
can change the software and use pieces of it in new free programs; and that
you are informed that you can do these things.
To protect your rights, we need to make restrictions that forbid distributors
to deny you these rights or to ask you to surrender these rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the library or if you modify it.
For example, if you distribute copies of the library, whether gratis or for
a fee, you must give the recipients all the rights that we gave you. You must
make sure that they, too, receive or can get the source code. If you link
other code with the library, you must provide complete object files to the
recipients, so that they can relink them with the library after making changes
to the library and recompiling it. And you must show them these terms so they
know their rights.
We protect your rights with a two-step method: (1) we copyright the library,
and (2) we offer you this license, which gives you legal permission to copy,
distribute and/or modify the library.
To protect each distributor, we want to make it very clear that there is no
warranty for the free library. Also, if the library is modified by someone
else and passed on, the recipients should know that what they have is not
the original version, so that the original author's reputation will not be
affected by problems that might be introduced by others.
Finally, software patents pose a constant threat to the existence of any free
program. We wish to make sure that a company cannot effectively restrict the
users of a free program by obtaining a restrictive license from a patent holder.
Therefore, we insist that any patent license obtained for a version of the
library must be consistent with the full freedom of use specified in this
license.
Most GNU software, including some libraries, is covered by the ordinary GNU
General Public License. This license, the GNU Lesser General Public License,
applies to certain designated libraries, and is quite different from the ordinary
General Public License. We use this license for certain libraries in order
to permit linking those libraries into non-free programs.
When a program is linked with a library, whether statically or using a shared
library, the combination of the two is legally speaking a combined work, a
derivative of the original library. The ordinary General Public License therefore
permits such linking only if the entire combination fits its criteria of freedom.
The Lesser General Public License permits more lax criteria for linking other
code with the library.
We call this license the "Lesser" General Public License because it does Less
to protect the user's freedom than the ordinary General Public License. It
also provides other free software developers Less of an advantage over competing
non-free programs. These disadvantages are the reason we use the ordinary
General Public License for many libraries. However, the Lesser license provides
advantages in certain special circumstances.
For example, on rare occasions, there may be a special need to encourage the
widest possible use of a certain library, so that it becomes a de-facto standard.
To achieve this, non-free programs must be allowed to use the library. A more
frequent case is that a free library does the same job as widely used non-free
libraries. In this case, there is little to gain by limiting the free library
to free software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free programs
enables a greater number of people to use a large body of free software. For
example, permission to use the GNU C Library in non-free programs enables
many more people to use the whole GNU operating system, as well as its variant,
the GNU/Linux operating system.
Although the Lesser General Public License is Less protective of the users'
freedom, it does ensure that the user of a program that is linked with the
Library has the freedom and the wherewithal to run that program using a modified
version of the Library.
The precise terms and conditions for copying, distribution and modification
follow. Pay close attention to the difference between a "work based on the
library" and a "work that uses the library". The former contains code derived
from the library, whereas the latter must be combined with the library in
order to run.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other program
which contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Lesser General
Public License (also called "this License"). Each licensee is addressed as
"you".
A "library" means a collection of software functions and/or data prepared
so as to be conveniently linked with application programs (which use some
of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has
been distributed under these terms. A "work based on the Library" means either
the Library or any derivative work under copyright law: that is to say, a
work containing the Library or a portion of it, either verbatim or with modifications
and/or translated straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications
to it. For a library, complete source code means all the source code for all
modules it contains, plus any associated interface definition files, plus
the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running a program
using the Library is not restricted, and output from such a program is covered
only if its contents constitute a work based on the Library (independent of
the use of the Library in a tool for writing it). Whether that is true depends
on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and disclaimer
of warranty; keep intact all the notices that refer to this License and to
the absence of any warranty; and distribute a copy of this License along with
the Library.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it,
thus forming a work based on the Library, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that
you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all
third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of
data to be supplied by an application program that uses the facility, other
than as an argument passed when the facility is invoked, then you must make
a good faith effort to ensure that, in the event an application does not supply
such function or table, the facility still operates, and performs whatever
part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose
that is entirely well-defined independent of the application. Therefore, Subsection
2d requires that any application-supplied function or table used by this function
must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Library, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Library.
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may opt to apply the terms of the ordinary GNU General Public License
instead of this License to a given copy of the Library. To do this, you must
alter all the notices that refer to this License, so that they refer to the
ordinary GNU General Public License, version 2, instead of to this License.
(If a newer version than version 2 of the ordinary GNU General Public License
has appeared, then you can specify that version instead if you wish.) Do not
make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy,
so the ordinary GNU General Public License applies to all subsequent copies
and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library
into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of
it, under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you accompany it with the complete corresponding
machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated
place, then offering equivalent access to copy the source code from the same
place satisfies the requirement to distribute the source code, even though
third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but
is designed to work with the Library by being compiled or linked with it,
is called a "work that uses the Library". Such a work, in isolation, is not
a derivative work of the Library, and therefore falls outside the scope of
this License.
However, linking a "work that uses the Library" with the Library creates an
executable that is a derivative of the Library (because it contains portions
of the Library), rather than a "work that uses the library". The executable
is therefore covered by this License. Section 6 states terms for distribution
of such executables.
When a "work that uses the Library" uses material from a header file that
is part of the Library, the object code for the work may be a derivative work
of the Library even though the source code is not. Whether this is true is
especially significant if the work can be linked without the Library, or if
the work is itself a library. The threshold for this to be true is not precisely
defined by law.
If such an object file uses only numerical parameters, data structure layouts
and accessors, and small macros and small inline functions (ten lines or less
in length), then the use of the object file is unrestricted, regardless of
whether it is legally a derivative work. (Executables containing this object
code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute
the object code for the work under the terms of Section 6. Any executables
containing that work also fall under Section 6, whether or not they are linked
directly with the Library itself.
6. As an exception to the Sections above, you may also combine or link a "work
that uses the Library" with the Library to produce a work containing portions
of the Library, and distribute that work under terms of your choice, provided
that the terms permit modification of the work for the customer's own use
and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library
is used in it and that the Library and its use are covered by this License.
You must supply a copy of this License. If the work during execution displays
copyright notices, you must include the copyright notice for the Library among
them, as well as a reference directing the user to the copy of this License.
Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source
code for the Library including whatever changes were used in the work (which
must be distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete machine-readable "work
that uses the Library", as object code and/or source code, so that the user
can modify the Library and then relink to produce a modified executable containing
the modified Library. (It is understood that the user who changes the contents
of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the Library. A
suitable mechanism is one that (1) uses at run time a copy of the library
already present on the user's computer system, rather than copying library
functions into the executable, and (2) will operate properly with a modified
version of the library, if the user installs one, as long as the modified
version is interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at least three years,
to give the same user the materials specified in Subsection 6a, above, for
a charge no more than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy from a designated
place, offer equivalent access to copy the above specified materials from
the same place.
e) Verify that the user has already received a copy of these materials or
that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must
include any data and utility programs needed for reproducing the executable
from it. However, as a special exception, the materials to be distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
It may happen that this requirement contradicts the license restrictions of
other proprietary libraries that do not normally accompany the operating system.
Such a contradiction means you cannot use both them and the Library together
in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side
in a single library together with other library facilities not covered by
this License, and distribute such a combined library, provided that the separate
distribution of the work based on the Library and of the other library facilities
is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities. This must be distributed
under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of
it is a work based on the Library, and explaining where to find the accompanying
uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library
except as expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense, link with, or distribute the Library is void, and
will automatically terminate your rights under this License. However, parties
who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Library or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Library
(or any work based on the Library), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library),
the recipient automatically receives a license from the original licensor
to copy, distribute, link with or modify the Library subject to these terms
and conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties with this License.
11. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Library at all. For example, if a
patent license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Library under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of
the Lesser General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version
ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs
whose distribution conditions are incompatible with these, write to the author
to ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make exceptions
for this. Our decision will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible
use to the public, we recommend making it free software that everyone can
redistribute and change. You can do so by permitting redistribution under
these terms (or, alternatively, under the terms of the ordinary General Public
License).
To apply these terms, attach the following notices to the library. It is safest
to attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the "copyright"
line and a pointer to where the full notice is found.
< one line to give the library's name and an idea of what it does. >
Copyright (C) < year > < name of author >
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this library; if not, write to the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information
on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
< signature of Ty Coon > , 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
@@ -0,0 +1,163 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the terms
and conditions of version 3 of the GNU General Public License, supplemented
by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser General
Public License, and the "GNU GPL" refers to version 3 of the GNU General Public
License.
"The Library" refers to a covered work governed by this License, other than
an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided by the
Library, but which is not otherwise based on the Library. Defining a subclass
of a class defined by the Library is deemed a mode of using an interface provided
by the Library.
A "Combined Work" is a work produced by combining or linking an Application
with the Library. The particular version of the Library with which the Combined
Work was made is also called the "Linked Version".
The "Minimal Corresponding Source" for a Combined Work means the Corresponding
Source for the Combined Work, excluding any source code for portions of the
Combined Work that, considered in isolation, are based on the Application,
and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the object
code and/or source code for the Application, including any data and utility
programs needed for reproducing the Combined Work from the Application, but
excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License without
being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a facility
refers to a function or data to be supplied by an Application that uses the
facility (other than as an argument passed when the facility is invoked),
then you may convey a copy of the modified version:
a) under this License, provided that you make a good faith effort to ensure
that, in the event an Application does not supply the function or data, the
facility still operates, and performs whatever part of its purpose remains
meaningful, or
b) under the GNU GPL, with none of the additional permissions of this License
applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a header
file that is part of the Library. You may convey such object code under terms
of your choice, provided that, if the incorporated material is not limited
to numerical parameters, data structure layouts and accessors, or small macros,
inline functions and templates (ten or fewer lines in length), you do both
of the following:
a) Give prominent notice with each copy of the object code that the Library
is used in it and that the Library and its use are covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken together,
effectively do not restrict modification of the portions of the Library contained
in the Combined Work and reverse engineering for debugging such modifications,
if you also do each of the following:
a) Give prominent notice with each copy of the Combined Work that the Library
is used in it and that the Library and its use are covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during execution, include
the copyright notice for the Library among these notices, as well as a reference
directing the user to the copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this License,
and the Corresponding Application Code in a form suitable for, and under terms
that permit, the user to recombine or relink the Application with a modified
version of the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
1) Use a suitable shared library mechanism for linking with the Library. A
suitable mechanism is one that (a) uses at run time a copy of the Library
already present on the user's computer system, and (b) will operate properly
with a modified version of the Library that is interface-compatible with the
Linked Version.
e) Provide Installation Information, but only if you would otherwise be required
to provide such information under section 6 of the GNU GPL, and only to the
extent that such information is necessary to install and execute a modified
version of the Combined Work produced by recombining or relinking the Application
with a modified version of the Linked Version. (If you use option 4d0, the
Installation Information must accompany the Minimal Corresponding Source and
Corresponding Application Code. If you use option 4d1, you must provide the
Installation Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the Library side
by side in a single library together with other library facilities that are
not Applications and are not covered by this License, and convey such a combined
library under terms of your choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities, conveyed under the
terms of this License.
b) Give prominent notice with the combined library that part of it is a work
based on the Library, and explaining where to find the accompanying uncombined
form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions of the
GNU Lesser General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library as you
received it specifies that a certain numbered version of the GNU Lesser General
Public License "or any later version" applies to it, you have the option of
following the terms and conditions either of that published version or of
any later version published by the Free Software Foundation. If the Library
as you received it does not specify a version number of the GNU Lesser General
Public License, you may choose any version of the GNU Lesser General Public
License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide whether
future versions of the GNU Lesser General Public License shall apply, that
proxy's public statement of acceptance of any version is permanent authorization
for you to choose that version for the Library.
@@ -0,0 +1,12 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the license or (at your option) any later version
that is accepted by the membership of KDE e.V. (or its successor
approved by the membership of KDE e.V.), which shall act as a
proxy as defined in Section 6 of version 3 of the license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@@ -0,0 +1,15 @@
# Attica
Open Collaboration Service client library
## Introduction
Attica is a Qt library that implements the Open Collaboration Services API version 1.6.
The REST API is defined here:
https://www.freedesktop.org/wiki/Specifications/open-collaboration-services/
It grants easy access to the services such as querying information about persons and contents.
The library is used in KNewStuff3 as content provider.
In order to integrate with KDE's Plasma Desktop, a platform plugin exists in [plasma-desktop](https://commits.kde.org/plasma-desktop?path=attica-kde).
Your basic entrypoint for using Attica's functionality is the Attica::ProviderManager class.
@@ -0,0 +1,11 @@
include(ECMAddTests)
find_package(Qt6 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Test)
set_package_properties(Qt6Test PROPERTIES PURPOSE "Required for autotests")
ecm_add_tests(
configtest.cpp
persontest.cpp
providertest.cpp
LINK_LIBRARIES Qt6::Test KF6::Attica
)
@@ -0,0 +1,44 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2018 Ralf Habacker <ralf.habacker@freenet.de>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include <QTest>
#include <configparser.h>
using namespace Attica;
class ConfigTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testParsing();
};
void ConfigTest::testParsing()
{
Config::Parser parser;
QString validData(
QLatin1String("<?xml version=\"1.0\"?>"
"<ocs><data>"
"<version>1.7</version>"
"<website>store.kde.org</website>"
"<host>api.kde-look.org</host>"
"<contact>contact@opendesktop.org</contact>"
"<ssl>true</ssl>"
"</data></ocs>"));
Config config = parser.parse(validData);
QVERIFY(config.isValid());
QString invalidData = QLatin1String("<ocs><braaaaaaaaaaawrlawrf></braaaaaaaaaaawrlawrf></ocs>");
config = parser.parse(invalidData);
QVERIFY(!config.isValid());
}
QTEST_GUILESS_MAIN(ConfigTest)
#include "configtest.moc"
@@ -0,0 +1,50 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Martin Sandsmark <martin.sandsmark@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include <QTest>
#include <personparser.h>
using namespace Attica;
class PersonTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testParsing();
};
void PersonTest::testParsing()
{
Person::Parser parser;
QString validData(
QLatin1String("<?xml version=\"1.0\"?>"
"<ocs><person>"
"<personid>10</personid>"
"<firstname>Ola</firstname>"
"<lastname>Nordmann</lastname>"
"<homepage>http://kde.org/</homepage>"
"<avatarpic>http://techbase.kde.org/skins/oxygen/top-kde.png</avatarpic>"
"<avatarpicfound>1</avatarpicfound>"
"<birthday>2010-06-21</birthday>"
"<city>Oslo</city>"
"<country>Norway</country>"
"<latitude>59.56</latitude>"
"<longitude>10.41</longitude>"
"</person></ocs>"));
Person person = parser.parse(validData);
QVERIFY(person.isValid());
QString invalidData = QLatin1String("<ocs><braaaaaaaaaaawrlawrf></braaaaaaaaaaawrlawrf></ocs>");
person = parser.parse(invalidData);
QVERIFY(!person.isValid());
}
QTEST_MAIN(PersonTest)
#include "persontest.moc"
@@ -0,0 +1,47 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Martin Sandsmark <martin.sandsmark@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "../privatedata.h"
#include "../privatedataparser.h"
#include <QTest>
using namespace Attica;
class PersonTest : public QObject
{
Q_OBJECT
private slots:
void testParsing();
void testMergeType();
};
void PersonTest::testParsing()
{
PrivateData::Parser parser;
QString validData(
"<?xml version=\"1.0\"?><ocs><attributes>"
"<key>keyfoo</key>"
"<value>valuebar</value>"
"<changed>01.01.1998</changed>"
"</attributes></ocs>");
PrivateData attributes = parser.parse(validData);
QVERIFY(attributes.attributeChanged("keyfoo").isValid());
QVERIFY(!attributes.attribute("keyfoo").isNull());
}
void PersonTest::testMergeType()
{
PrivateData a;
a.setMergeType(PrivateData::OverwriteLocal);
QVERIFY(a.mergeType() == PrivateData::OverwriteLocal);
}
QTEST_MAIN(PersonTest);
#include "moc_persontest.cxx"
@@ -0,0 +1,193 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2018 Ralf Habacker <ralf.habacker@freenet.de>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include <QEventLoop>
#include <QTest>
#include <QTimer>
#include <QLoggingCategory>
#include "config.h"
#include "content.h"
#include "providermanager.h"
using namespace Attica;
class ProviderTest : public QObject
{
Q_OBJECT
public:
ProviderTest();
~ProviderTest() override;
private:
void initProvider(const QUrl &url);
private Q_SLOTS:
void testFetchValidProvider();
void testFetchInvalidProvider();
void testSwitchSortOrder();
protected Q_SLOTS:
void providerAdded(Attica::Provider p);
void slotDefaultProvidersLoaded();
void slotConfigResult(Attica::BaseJob *j);
void slotListResult(Attica::BaseJob *j);
void slotList2Result(Attica::BaseJob *j);
void slotTimeout();
private:
Attica::ProviderManager *m_manager;
QEventLoop *m_eventloop;
QTimer m_timer;
bool m_errorReceived = false;
};
ProviderTest::ProviderTest()
: m_manager(nullptr)
, m_eventloop(new QEventLoop)
{
QLoggingCategory::setFilterRules(QStringLiteral("kf.attica.debug=true"));
}
ProviderTest::~ProviderTest()
{
delete m_manager;
delete m_eventloop;
}
void ProviderTest::slotDefaultProvidersLoaded()
{
qDebug() << "default providers loaded";
m_eventloop->exit();
}
void ProviderTest::providerAdded(Attica::Provider p)
{
qDebug() << "got provider" << p.name();
m_eventloop->exit();
}
void ProviderTest::initProvider(const QUrl &url)
{
m_errorReceived = false;
delete m_manager;
m_manager = new Attica::ProviderManager;
m_manager->setAuthenticationSuppressed(true);
connect(m_manager, &ProviderManager::defaultProvidersLoaded, this, &ProviderTest::slotDefaultProvidersLoaded);
connect(m_manager, &ProviderManager::providerAdded, this, &ProviderTest::providerAdded);
m_manager->addProviderFile(url);
connect(m_manager, &Attica::ProviderManager::failedToLoad, this, [this]() {
m_errorReceived = true;
m_eventloop->quit();
});
m_timer.singleShot(30000, this, &ProviderTest::slotTimeout);
m_eventloop->exec();
}
void ProviderTest::testFetchValidProvider()
{
initProvider(QUrl(QLatin1String("https://autoconfig.kde.org/ocs/providers.xml")));
Attica::Provider provider = m_manager->providers().at(0);
ItemJob<Config> *job = provider.requestConfig();
QVERIFY(job);
connect(job, &BaseJob::finished, this, &ProviderTest::slotConfigResult);
job->start();
m_eventloop->exec();
}
void ProviderTest::slotConfigResult(Attica::BaseJob *j)
{
if (j->metadata().error() == Metadata::NoError) {
Attica::ItemJob<Config> *itemJob = static_cast<Attica::ItemJob<Config> *>(j);
Attica::Config p = itemJob->result();
qDebug() << QLatin1String("Config loaded - Server has version") << p.version();
} else if (j->metadata().error() == Metadata::OcsError) {
qDebug() << QString(QLatin1String("OCS Error: %1")).arg(j->metadata().message());
} else if (j->metadata().error() == Metadata::NetworkError) {
qDebug() << QString(QLatin1String("Network Error: %1")).arg(j->metadata().message());
} else {
qDebug() << QString(QLatin1String("Unknown Error: %1")).arg(j->metadata().message());
}
m_eventloop->exit();
m_timer.stop();
QVERIFY(j->metadata().error() == Metadata::NoError);
}
void ProviderTest::testSwitchSortOrder()
{
initProvider(QUrl(QLatin1String("https://autoconfig.kde.org/ocs/providers.xml")));
Attica::Provider provider = m_manager->providers().at(0);
ListJob<Content> *job = provider.searchContents({}, {});
QVERIFY(job);
connect(job, &BaseJob::finished, this, &ProviderTest::slotListResult);
job->start();
m_eventloop->exec();
}
void ProviderTest::slotListResult(Attica::BaseJob *j)
{
if (j->metadata().error() == Metadata::NoError) {
Attica::ListJob<Content> *contentJob = static_cast<Attica::ListJob<Content> *>(j);
Content::List items = contentJob->itemList();
qDebug() << QLatin1String("First list of items loaded, we have the following amount:") << items.count();
} else if (j->metadata().error() == Metadata::OcsError) {
qDebug() << QString(QLatin1String("OCS Error: %1")).arg(j->metadata().message());
} else if (j->metadata().error() == Metadata::NetworkError) {
qDebug() << QString(QLatin1String("Network Error: %1")).arg(j->metadata().message());
} else {
qDebug() << QString(QLatin1String("Unknown Error: %1")).arg(j->metadata().message());
}
m_timer.stop();
QVERIFY(j->metadata().error() == Metadata::NoError);
// Now do the actual switch
Attica::Provider provider = m_manager->providers().at(0);
ListJob<Content> *job = provider.searchContents({}, {}, Provider::Downloads);
QVERIFY(job);
connect(job, &BaseJob::finished, this, &ProviderTest::slotList2Result);
m_timer.singleShot(30000, this, &ProviderTest::slotTimeout);
job->start();
}
void ProviderTest::slotList2Result(Attica::BaseJob *j)
{
if (j->metadata().error() == Metadata::NoError) {
Attica::ListJob<Content> *contentJob = static_cast<Attica::ListJob<Content> *>(j);
Content::List items = contentJob->itemList();
qDebug() << QLatin1String("Second list of items loaded, we have the following amount:") << items.count();
} else if (j->metadata().error() == Metadata::OcsError) {
qDebug() << QString(QLatin1String("OCS Error: %1")).arg(j->metadata().message());
} else if (j->metadata().error() == Metadata::NetworkError) {
qDebug() << QString(QLatin1String("Network Error: %1")).arg(j->metadata().message());
} else {
qDebug() << QString(QLatin1String("Unknown Error: %1")).arg(j->metadata().message());
}
m_eventloop->exit();
m_timer.stop();
QVERIFY(j->metadata().error() == Metadata::NoError);
}
void ProviderTest::slotTimeout()
{
QVERIFY(m_eventloop->isRunning());
m_eventloop->exit();
QFAIL("Timeout fetching provider");
}
void ProviderTest::testFetchInvalidProvider()
{
initProvider(QUrl(QLatin1String("https://invalid-url.org/ocs/providers.xml")));
QVERIFY(m_manager->providers().size() == 0);
QVERIFY(m_errorReceived);
}
QTEST_GUILESS_MAIN(ProviderTest)
#include "providertest.moc"
@@ -0,0 +1,7 @@
### KApiDox Project-specific Overrides file
# define so that deprecated API is not skipped
PREDEFINED += \
"ATTICA_ENABLE_DEPRECATED_SINCE(x, y)=1" \
"ATTICA_BUILD_DEPRECATED_SINCE(x, y)=1" \
"ATTICA_DEPRECATED_VERSION(x, y, t)="
@@ -0,0 +1,21 @@
maintainer:
description: Open Collaboration Services API
tier: 1
type: functional
platforms:
- name: Linux
- name: FreeBSD
- name: Windows
- name: macOS
- name: Android
portingAid: false
deprecated: false
release: true
libraries:
- cmake: "KF6::Attica"
license: LGPL-2.1-only OR LGPL-3.0-only
cmakename: KF6Attica
public_lib: true
group: Frameworks
subgroup: Tier 1
@@ -0,0 +1,236 @@
# mingw can't handle exported explicit template instantiations in a DLL
if (MINGW)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols ${CMAKE_SHARED_LINKER_FLAGS}")
endif (MINGW)
configure_file(version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h)
add_library(KF6Attica)
add_library(KF6::Attica ALIAS KF6Attica)
set_target_properties(KF6Attica PROPERTIES
VERSION ${ATTICA_VERSION}
SOVERSION ${ATTICA_SOVERSION}
EXPORT_NAME "Attica"
)
target_sources(KF6Attica PRIVATE
accountbalance.cpp
accountbalanceparser.cpp
achievement.cpp
achievementparser.cpp
buildservice.cpp
buildserviceparser.cpp
buildservicejob.cpp
buildservicejobparser.cpp
buildservicejoboutput.cpp
buildservicejoboutputparser.cpp
activity.cpp
activityparser.cpp
atticabasejob.cpp
atticautils.cpp
privatedata.cpp
privatedataparser.cpp
category.cpp
categoryparser.cpp
comment.cpp
commentparser.cpp
config.cpp
configparser.cpp
content.cpp
contentparser.cpp
deletejob.cpp
distribution.cpp
distributionparser.cpp
downloaddescription.cpp
downloaditem.cpp
downloaditemparser.cpp
event.cpp
eventparser.cpp
folder.cpp
folderparser.cpp
forum.cpp
forumparser.cpp
getjob.cpp
homepageentry.cpp
homepagetype.cpp
homepagetypeparser.cpp
icon.cpp
itemjob.cpp
knowledgebaseentry.cpp
knowledgebaseentryparser.cpp
license.cpp
licenseparser.cpp
listjob_inst.cpp
message.cpp
messageparser.cpp
metadata.cpp
parser.cpp
person.cpp
personparser.cpp
platformdependent_v2.cpp
postfiledata.cpp
postjob.cpp
project.cpp
projectparser.cpp
putjob.cpp
remoteaccount.cpp
remoteaccountparser.cpp
provider.cpp
providermanager.cpp
publisher.cpp
publisherparser.cpp
publisherfield.cpp
publisherfieldparser.cpp
qtplatformdependent.cpp
topic.cpp
topicparser.cpp
platformdependent_v3.cpp
)
ecm_qt_declare_logging_category(KF6Attica
HEADER attica_debug.h
IDENTIFIER ATTICA
CATEGORY_NAME kf.attica
OLD_CATEGORY_NAMES org.kde.attica
DESCRIPTION "Attica"
EXPORT ATTICA
)
file(GLOB TEST_FILES "*.cpp" "*.h")
ecm_check_outbound_license(
LICENSES LGPL-2.1-only LGPL-3.0-only
TEST_NAME KF6Attica
FILES ${TEST_FILES}
)
ecm_generate_export_header(KF6Attica
BASE_NAME Attica
GROUP_BASE_NAME KF
VERSION ${KF_VERSION}
USE_VERSION_HEADER
DEPRECATED_BASE_VERSION 0
DEPRECATION_VERSIONS
EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT}
)
target_link_libraries(KF6Attica
PUBLIC
Qt6::Core
Qt6::Network
)
target_include_directories(KF6Attica INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF}/Attica>")
ecm_generate_headers(Attica_CamelCase_HEADERS
HEADER_NAMES
Activity
AccountBalance
Achievement
Comment
Config
Content
Category
DeleteJob
Distribution
DownloadDescription
DownloadItem
Event
Folder
Forum
GetJob
HomePageEntry
HomePageType
Icon
ItemJob
KnowledgeBaseEntry
ListJob
License
Message
Metadata
Person
PrivateData
PostJob
Project
PutJob
RemoteAccount
BuildService
BuildServiceJob
BuildServiceJobOutput
ProviderManager
Provider
Publisher
PublisherField
Topic
PREFIX Attica
REQUIRED_HEADERS Attica_HEADERS
)
set(Attica_HEADERS
${Attica_HEADERS}
atticabasejob.h # TODO: rename to basejob.h, add atticabasejob.h forwarding to basejob.h for compat
atticautils.h # TODO: not exported, this should probably NOT be installed at all?
#interface for external platform plugins
platformdependent.h
platformdependent_v2.h
platformdependent_v3.h
)
install(FILES ${Attica_CamelCase_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/Attica/Attica COMPONENT Devel)
install(TARGETS KF6Attica
EXPORT KF6AtticaTargets
${KF_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES
${Attica_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/version.h
${CMAKE_CURRENT_BINARY_DIR}/attica_export.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/Attica/attica
COMPONENT Devel
)
ecm_qt_install_logging_categories(
EXPORT ATTICA
FILE attica.categories
DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
)
if(BUILD_QCH)
ecm_add_qch(
KF6Attica_QCH
NAME Attica
BASE_NAME KF6Attica
VERSION ${KF_VERSION}
ORG_DOMAIN org.kde
SOURCES # using only public headers, to cover only public API
${Attica_HEADERS}
MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md"
LINK_QCHS
Qt6Core_QCH
Qt6Network_QCH
INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}
BLANK_MACROS
ATTICA_EXPORT
ATTICA_DEPRECATED
ATTICA_DEPRECATED_EXPORT
"ATTICA_DEPRECATED_VERSION(x, y, t)"
TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR}
QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR}
COMPONENT Devel
)
endif()
# Install package config file
if(NOT WIN32)
ecm_generate_pkgconfig_file(BASE_NAME KF6Attica
LIB_NAME KF6Attica
INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF}/Attica
DEPS Qt6Core Qt6Network
DESCRIPTION "Qt library to access Open Collaboration Services"
INSTALL
)
endif(NOT WIN32)
@@ -0,0 +1,56 @@
/*
SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "accountbalance.h"
using namespace Attica;
class Q_DECL_HIDDEN AccountBalance::Private : public QSharedData
{
public:
QString balance;
QString currency;
};
AccountBalance::AccountBalance()
: d(new Private)
{
}
AccountBalance::AccountBalance(const Attica::AccountBalance &other)
: d(other.d)
{
}
AccountBalance &AccountBalance::operator=(const Attica::AccountBalance &other)
{
d = other.d;
return *this;
}
AccountBalance::~AccountBalance()
{
}
void AccountBalance::setBalance(const QString &balance)
{
d->balance = balance;
}
QString AccountBalance::balance() const
{
return d->balance;
}
void AccountBalance::setCurrency(const QString &currency)
{
d->currency = currency;
}
QString AccountBalance::currency() const
{
return d->currency;
}
@@ -0,0 +1,82 @@
/*
SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_ACCOUNTBALANCE_H
#define ATTICA_ACCOUNTBALANCE_H
#include <QSharedDataPointer>
#include <QString>
#include "attica_export.h"
namespace Attica
{
/**
* @class AccountBalance accountbalance.h <Attica/AccountBalance>
*
* Represents the money in the account of the user
*/
class ATTICA_EXPORT AccountBalance
{
public:
typedef QList<AccountBalance> List;
class Parser;
/**
* Creates an empty AccountBalance
*/
AccountBalance();
/**
* Copy constructor.
* @param other the AccountBalance to copy from
*/
AccountBalance(const AccountBalance &other);
/**
* Assignment operator.
* @param other the AccountBalance to assign from
* @return pointer to this AccountBalance
*/
AccountBalance &operator=(const AccountBalance &other);
/**
* Destructor.
*/
~AccountBalance();
/**
* Sets the currency in use.
* @param currency the new currency (Euro, US Dollar)
*/
void setCurrency(const QString &currency);
/**
* Gets the currency.
* @return the currency
*/
QString currency() const;
/**
* Sets the balance.
* @param balance
*/
void setBalance(const QString &name);
/**
* Gets the balance.
* @return the amount of money in the account
*/
QString balance() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif // ACCOUNTBALANCE_H
@@ -0,0 +1,35 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "accountbalanceparser.h"
#include <QXmlStreamReader>
using namespace Attica;
QStringList AccountBalance::Parser::xmlElement() const
{
return QStringList(QStringLiteral("person"));
}
AccountBalance AccountBalance::Parser::parseXml(QXmlStreamReader &xml)
{
AccountBalance item;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("balance")) {
item.setBalance(xml.readElementText());
} else if (xml.name() == QLatin1String("currency")) {
item.setCurrency(xml.readElementText());
}
}
}
return item;
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_ACCOUNTBALANCEPARSER_H
#define ATTICA_ACCOUNTBALANCEPARSER_H
#include "accountbalance.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN AccountBalance::Parser : public Attica::Parser<AccountBalance>
{
private:
AccountBalance parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,272 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "achievement.h"
using namespace Attica;
Achievement::Type Achievement::stringToAchievementType(const QString &achievementTypeString)
{
if (achievementTypeString == QLatin1String("flowing")) {
return Achievement::FlowingAchievement;
} else if (achievementTypeString == QLatin1String("stepped")) {
return Achievement::SteppedAchievement;
} else if (achievementTypeString == QLatin1String("namedsteps")) {
return Achievement::NamedstepsAchievement;
} else if (achievementTypeString == QLatin1String("set")) {
return Achievement::SetAchievement;
}
Q_ASSERT(false);
return Achievement::FlowingAchievement;
}
QString Achievement::achievementTypeToString(const Achievement::Type type)
{
switch (type) {
case Achievement::FlowingAchievement:
return QStringLiteral("flowing");
case Achievement::SteppedAchievement:
return QStringLiteral("stepped");
case Achievement::NamedstepsAchievement:
return QStringLiteral("namedsteps");
case Achievement::SetAchievement:
return QStringLiteral("set");
}
Q_ASSERT(false);
return QString();
}
Achievement::Visibility Achievement::stringToAchievementVisibility(const QString &achievementVisibilityString)
{
if (achievementVisibilityString == QLatin1String("visible")) {
return Achievement::VisibleAchievement;
} else if (achievementVisibilityString == QLatin1String("dependents")) {
return Achievement::DependentsAchievement;
} else if (achievementVisibilityString == QLatin1String("secret")) {
return Achievement::SecretAchievement;
}
Q_ASSERT(false);
return Achievement::VisibleAchievement;
}
QString Achievement::achievementVisibilityToString(const Achievement::Visibility visibility)
{
switch (visibility) {
case Achievement::VisibleAchievement:
return QStringLiteral("visible");
case Achievement::DependentsAchievement:
return QStringLiteral("dependents");
case Achievement::SecretAchievement:
return QStringLiteral("secret");
}
Q_ASSERT(false);
return QString();
}
class Q_DECL_HIDDEN Achievement::Private : public QSharedData
{
public:
QString m_id;
QString m_contentId;
QString m_name;
QString m_description;
QString m_explanation;
int m_points;
QUrl m_image;
QStringList m_dependencies;
Achievement::Visibility m_visibility;
Achievement::Type m_type;
QStringList m_options;
int m_steps;
QVariant m_progress;
Private()
: m_points(0)
, m_steps(0)
{
}
};
Achievement::Achievement()
: d(new Private)
{
}
Achievement::Achievement(const Achievement &other)
: d(other.d)
{
}
Achievement &Achievement::operator=(const Attica::Achievement &other)
{
d = other.d;
return *this;
}
Achievement::~Achievement()
{
}
void Achievement::setId(const QString &id)
{
d->m_id = id;
}
QString Achievement::id() const
{
return d->m_id;
}
void Achievement::setContentId(const QString &contentId)
{
d->m_contentId = contentId;
}
QString Achievement::contentId() const
{
return d->m_contentId;
}
void Achievement::setName(const QString &name)
{
d->m_name = name;
}
QString Achievement::name() const
{
return d->m_name;
}
void Achievement::setDescription(const QString &description)
{
d->m_description = description;
}
QString Achievement::description() const
{
return d->m_description;
}
void Achievement::setExplanation(const QString &explanation)
{
d->m_explanation = explanation;
}
QString Achievement::explanation() const
{
return d->m_explanation;
}
void Achievement::setPoints(const int points)
{
d->m_points = points;
}
int Achievement::points() const
{
return d->m_points;
}
void Achievement::setImage(const QUrl &image)
{
d->m_image = image;
}
QUrl Achievement::image() const
{
return d->m_image;
}
void Achievement::setDependencies(const QStringList &dependencies)
{
d->m_dependencies = dependencies;
}
void Achievement::addDependency(const QString &dependency)
{
d->m_dependencies.append(dependency);
}
void Achievement::removeDependency(const QString &dependency)
{
d->m_dependencies.removeOne(dependency);
}
QStringList Achievement::dependencies() const
{
return d->m_dependencies;
}
void Achievement::setVisibility(Achievement::Visibility visibility)
{
d->m_visibility = visibility;
}
Achievement::Visibility Achievement::visibility() const
{
return d->m_visibility;
}
void Achievement::setType(Achievement::Type type)
{
d->m_type = type;
}
Achievement::Type Achievement::type() const
{
return d->m_type;
}
void Achievement::setOptions(const QStringList &options)
{
d->m_options = options;
}
void Achievement::addOption(const QString &option)
{
d->m_options.append(option);
}
void Achievement::removeOption(const QString &option)
{
d->m_options.removeOne(option);
}
QStringList Achievement::options() const
{
return d->m_options;
}
void Achievement::setSteps(const int steps)
{
d->m_steps = steps;
}
int Achievement::steps() const
{
return d->m_steps;
}
void Achievement::setProgress(const QVariant &progress)
{
d->m_progress = progress;
}
QVariant Achievement::progress() const
{
return d->m_progress;
}
bool Achievement::isValid() const
{
return !(d->m_id.isEmpty());
}
@@ -0,0 +1,107 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_ACHIEVEMENT_H
#define ATTICA_ACHIEVEMENT_H
#include "attica_export.h"
#include <QSharedDataPointer>
#include <QStringList>
#include <QUrl>
#include <QVariant>
namespace Attica
{
/**
* @class Achievement achievement.h <Attica/Achievement>
*
* Represents an achievement.
*/
class ATTICA_EXPORT Achievement
{
public:
typedef QList<Achievement> List;
class Parser;
enum Type {
FlowingAchievement,
SteppedAchievement,
NamedstepsAchievement,
SetAchievement,
};
static Achievement::Type stringToAchievementType(const QString &achievementTypeString);
static QString achievementTypeToString(const Achievement::Type type);
enum Visibility {
VisibleAchievement,
DependentsAchievement,
SecretAchievement,
};
static Achievement::Visibility stringToAchievementVisibility(const QString &achievementVisibilityString);
static QString achievementVisibilityToString(const Achievement::Visibility visibility);
Achievement();
Achievement(const Achievement &other);
Achievement &operator=(const Achievement &other);
~Achievement();
void setId(const QString &id);
QString id() const;
void setContentId(const QString &contentId);
QString contentId() const;
void setName(const QString &name);
QString name() const;
void setDescription(const QString &description);
QString description() const;
void setExplanation(const QString &explanation);
QString explanation() const;
void setPoints(const int points);
int points() const;
void setImage(const QUrl &image);
QUrl image() const;
void setDependencies(const QStringList &dependencies);
void addDependency(const QString &dependency);
void removeDependency(const QString &dependency);
QStringList dependencies() const;
void setVisibility(Achievement::Visibility visibility);
Achievement::Visibility visibility() const;
void setType(Achievement::Type type);
Achievement::Type type() const;
void setOptions(const QStringList &options);
void addOption(const QString &option);
void removeOption(const QString &option);
QStringList options() const;
void setSteps(const int steps);
int steps() const;
void setProgress(const QVariant &progress);
QVariant progress() const;
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,136 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "achievementparser.h"
#include "atticautils.h"
using namespace Attica;
Achievement Achievement::Parser::parseXml(QXmlStreamReader &xml)
{
Achievement achievement;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
achievement.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("content_id")) {
achievement.setContentId(xml.readElementText());
} else if (xml.name() == QLatin1String("name")) {
achievement.setName(xml.readElementText());
} else if (xml.name() == QLatin1String("description")) {
achievement.setDescription(xml.readElementText());
} else if (xml.name() == QLatin1String("explanation")) {
achievement.setExplanation(xml.readElementText());
} else if (xml.name() == QLatin1String("points")) {
achievement.setPoints(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("image")) {
achievement.setImage(QUrl(xml.readElementText()));
} else if (xml.name() == QLatin1String("dependencies")) {
QStringList dependencies = parseXmlDependencies(xml);
achievement.setDependencies(dependencies);
} else if (xml.name() == QLatin1String("visibility")) {
achievement.setVisibility(Achievement::stringToAchievementVisibility(xml.readElementText()));
} else if (xml.name() == QLatin1String("type")) {
achievement.setType(Achievement::stringToAchievementType(xml.readElementText()));
} else if (xml.name() == QLatin1String("options")) {
QStringList options = parseXmlOptions(xml);
achievement.setOptions(options);
} else if (xml.name() == QLatin1String("steps")) {
achievement.setSteps(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("progress")) {
switch (achievement.type()) {
case Achievement::FlowingAchievement:
achievement.setProgress(QVariant(xml.readElementText().toFloat()));
break;
case Achievement::SteppedAchievement:
achievement.setProgress(QVariant(xml.readElementText().toInt()));
break;
case Achievement::NamedstepsAchievement:
achievement.setProgress(QVariant(xml.readElementText()));
break;
case Achievement::SetAchievement: {
QVariant progress = parseXmlProgress(xml);
achievement.setProgress(progress);
break;
}
default:
break;
}
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("achievement")) {
break;
}
}
return achievement;
}
QStringList Achievement::Parser::parseXmlDependencies(QXmlStreamReader &xml)
{
QStringList dependencies;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("achievement_id")) {
dependencies.append(xml.readElementText());
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("dependencies")) {
break;
}
}
return dependencies;
}
QStringList Achievement::Parser::parseXmlOptions(QXmlStreamReader &xml)
{
QStringList options;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("option")) {
options.append(xml.readElementText());
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("options")) {
break;
}
}
return options;
}
QVariant Achievement::Parser::parseXmlProgress(QXmlStreamReader &xml)
{
QStringList progress;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("reached")) {
progress.append(xml.readElementText());
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("progress")) {
break;
}
}
return progress;
}
QStringList Achievement::Parser::xmlElement() const
{
return QStringList(QStringLiteral("achievement"));
}
@@ -0,0 +1,29 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_ACHIEVEMENTPARSER_H
#define ATTICA_ACHIEVEMENTPARSER_H
#include "achievement.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN Achievement::Parser : public Attica::Parser<Achievement>
{
private:
Achievement parseXml(QXmlStreamReader &xml) override;
QStringList parseXmlOptions(QXmlStreamReader &xml);
QStringList parseXmlDependencies(QXmlStreamReader &xml);
QVariant parseXmlProgress(QXmlStreamReader &xml);
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,98 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "activity.h"
#include <QDateTime>
using namespace Attica;
class Q_DECL_HIDDEN Activity::Private : public QSharedData
{
public:
QString m_id;
Person m_associatedPerson;
QDateTime m_timestamp;
QString m_message;
QUrl m_link;
};
Activity::Activity()
: d(new Private)
{
}
Activity::Activity(const Attica::Activity &other)
: d(other.d)
{
}
Activity &Activity::operator=(const Attica::Activity &other)
{
d = other.d;
return *this;
}
Activity::~Activity()
{
}
void Activity::setId(const QString &id)
{
d->m_id = id;
}
QString Activity::id() const
{
return d->m_id;
}
void Activity::setAssociatedPerson(const Person &associatedPerson)
{
d->m_associatedPerson = associatedPerson;
}
Person Activity::associatedPerson() const
{
return d->m_associatedPerson;
}
void Activity::setTimestamp(const QDateTime &date)
{
d->m_timestamp = date;
}
QDateTime Activity::timestamp() const
{
return d->m_timestamp;
}
void Activity::setMessage(const QString &c)
{
d->m_message = c;
}
QString Activity::message() const
{
return d->m_message;
}
void Activity::setLink(const QUrl &v)
{
d->m_link = v;
}
QUrl Activity::link() const
{
return d->m_link;
}
bool Activity::isValid() const
{
return !(d->m_id.isEmpty());
}
@@ -0,0 +1,131 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_ACTIVITY_H
#define ATTICA_ACTIVITY_H
#include <QList>
#include <QSharedDataPointer>
#include <QUrl>
#include "attica_export.h"
#include "person.h"
class QDateTime;
namespace Attica
{
/**
* @class Activity activity.h <Attica/Activity>
*
* Represents a single news item (also known as activity)
*/
class ATTICA_EXPORT Activity
{
public:
typedef QList<Activity> List;
class Parser;
/**
* Creates an empty Activity
*/
Activity();
/**
* Copy constructor.
* @param other the Activity to copy from
*/
Activity(const Activity &other);
/**
* Assignment operator.
* @param other the Activity to assign from
* @return pointer to this Activity
*/
Activity &operator=(const Activity &other);
/**
* Destructor.
*/
~Activity();
/**
* Sets the id of the Activity.
* The id uniquely identifies an Activity with the OCS API.
* @param id the new id
*/
void setId(const QString &id);
/**
* Gets the id of the Activity.
* The id uniquely identifies an Activity with the OCS API.
* @return the id
*/
QString id() const;
/**
* Sets the user bound to the Activity.
* @param id the new user
*/
void setAssociatedPerson(const Person &associatedPerson);
/**
* Gets the user bound to the Activity.
* @return the user
*/
Person associatedPerson() const;
/**
* Sets the timestamp the Activity has been published.
* @param timestamp the new timestamp
*/
void setTimestamp(const QDateTime &timestamp);
/**
* Gets the timestamp the Activity has been published.
* @return the timestamp
*/
QDateTime timestamp() const;
/**
* Sets the message of the Activity.
* @param message the new message
*/
void setMessage(const QString &message);
/**
* Gets the message of the Activity.
* @return the message
*/
QString message() const;
/**
* Sets the link to further information about this Activity.
* @param link the new link
*/
void setLink(const QUrl &link);
/**
* Gets the link to further information about this Activity.
* @return the link
*/
QUrl link() const;
/**
* Checks whether this Activity has an id
* @return @c true if an id has been set, @c false otherwise
*/
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,57 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "activityparser.h"
#include <QDateTime>
#include <QRegularExpression>
using namespace Attica;
Activity Activity::Parser::parseXml(QXmlStreamReader &xml)
{
Activity activity;
Person person;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
activity.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("personid")) {
person.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("avatarpic")) {
person.setAvatarUrl(QUrl(xml.readElementText()));
} else if (xml.name() == QLatin1String("firstname")) {
person.setFirstName(xml.readElementText());
} else if (xml.name() == QLatin1String("lastname")) {
person.setLastName(xml.readElementText());
} else if (xml.name() == QLatin1String("timestamp")) {
QString timestampString = xml.readElementText();
timestampString.remove(QRegularExpression(QStringLiteral("\\+.*$")));
QDateTime timestamp = QDateTime::fromString(timestampString, Qt::ISODate);
activity.setTimestamp(timestamp);
} else if (xml.name() == QLatin1String("message")) {
activity.setMessage(xml.readElementText());
} else if (xml.name() == QLatin1String("link")) {
activity.setLink(QUrl(xml.readElementText()));
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("activity")) {
break;
}
}
activity.setAssociatedPerson(person);
return activity;
}
QStringList Activity::Parser::xmlElement() const
{
return QStringList(QStringLiteral("activity"));
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_ACTIVITYPARSER_H
#define ATTICA_ACTIVITYPARSER_H
#include "activity.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN Activity::Parser : public Attica::Parser<Activity>
{
private:
Activity parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,185 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "atticabasejob.h"
#include <QAuthenticator>
#include <QDebug>
#include <QNetworkReply>
#include <QTimer>
#include "platformdependent.h"
#include "platformdependent_v3.h"
#include <attica_debug.h>
#include <atticautils.h>
using namespace Attica;
class Q_DECL_HIDDEN BaseJob::Private
{
public:
Metadata m_metadata;
PlatformDependent *m_internals;
QPointer<QNetworkReply> m_reply;
bool aborted{false};
bool started = false;
Private(PlatformDependent *internals)
: m_internals(internals)
{
}
bool redirection(QUrl &newUrl) const
{
if (m_reply == nullptr || m_reply->error() != QNetworkReply::NoError) {
return false;
}
const int httpStatusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (httpStatusCode == 301 // Moved Permanently
|| httpStatusCode == 302 // Found
|| httpStatusCode == 303 // See Other
|| httpStatusCode == 307) { // Temporary Redirect
QNetworkRequest request = m_reply->request();
QUrl redirectUrl(m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl());
if (redirectUrl.isRelative()) {
QUrl baseUrl(request.url());
newUrl = baseUrl.resolved(redirectUrl);
qCDebug(ATTICA) << "resolving relative URL redirection to" << newUrl.toString();
} else {
newUrl = redirectUrl;
qCDebug(ATTICA) << "resolving absolute URL redirection to" << newUrl.toString();
}
return true;
}
return false;
}
};
BaseJob::BaseJob(PlatformDependent *internals)
: d(std::make_unique<Private>(internals))
{
}
BaseJob::~BaseJob() = default;
void BaseJob::dataFinished()
{
if (!d->m_reply) {
return;
}
bool error = d->m_reply->error() != QNetworkReply::NoError && d->m_reply->error() != QNetworkReply::OperationCanceledError;
// handle redirections automatically
QUrl newUrl;
if (d->redirection(newUrl)) {
// qCDebug(ATTICA) << "BaseJob::dataFinished" << newUrl;
QNetworkRequest request = d->m_reply->request();
QNetworkAccessManager::Operation operation = d->m_reply->operation();
if (newUrl.isValid() && operation == QNetworkAccessManager::GetOperation) {
d->m_reply->deleteLater();
// reissue same request with different Url
request.setUrl(newUrl);
d->m_reply = internals()->get(request);
connect(d->m_reply, &QNetworkReply::finished, this, &BaseJob::dataFinished);
return;
}
error = true;
}
if (error) {
d->m_metadata.setError(Metadata::NetworkError);
d->m_metadata.setStatusCode(d->m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
d->m_metadata.setStatusString(d->m_reply->errorString());
d->m_metadata.setHeaders(d->m_reply->rawHeaderPairs());
} else if (d->m_reply->error() == QNetworkReply::OperationCanceledError) {
d->m_metadata.setError(Metadata::NoError);
} else {
QByteArray data = d->m_reply->readAll();
// qCDebug(ATTICA) << "XML Returned:\n" << data;
parse(QString::fromUtf8(data.constData()));
if (d->m_metadata.statusCode() >= 100 && d->m_metadata.statusCode() < 200) {
d->m_metadata.setError(Metadata::NoError);
} else {
d->m_metadata.setError(Metadata::OcsError);
}
}
Q_EMIT finished(this);
d->m_reply->deleteLater();
deleteLater();
}
void BaseJob::start()
{
if (!d->started) {
d->started = true;
QTimer::singleShot(0, this, &BaseJob::doWork);
}
}
void BaseJob::doWork()
{
if (d->aborted) {
return;
}
auto platformDependentV3 = dynamic_cast<Attica::PlatformDependentV3 *>(d->m_internals);
if (platformDependentV3 && !platformDependentV3->isReady()) {
connect(platformDependentV3, &Attica::PlatformDependentV3::readyChanged, this, &BaseJob::doWork);
return;
}
d->m_reply = executeRequest();
qCDebug(ATTICA) << "executing" << Utils::toString(d->m_reply->operation()) << "request for" << d->m_reply->url();
connect(d->m_reply, &QNetworkReply::finished, this, &BaseJob::dataFinished);
connect(d->m_reply->manager(), &QNetworkAccessManager::authenticationRequired, this, &BaseJob::authenticationRequired);
connect(d->m_reply, &QNetworkReply::errorOccurred, [](QNetworkReply::NetworkError code) {
qCDebug(ATTICA) << "error found" << code;
});
}
void BaseJob::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth)
{
auth->setUser(reply->request().attribute((QNetworkRequest::Attribute)BaseJob::UserAttribute).toString());
auth->setPassword(reply->request().attribute((QNetworkRequest::Attribute)BaseJob::PasswordAttribute).toString());
}
void BaseJob::abort()
{
d->aborted = true;
if (d->m_reply) {
d->m_reply->abort();
d->m_reply->deleteLater();
}
deleteLater();
}
bool BaseJob::isAborted() const
{
return d->aborted;
}
PlatformDependent *BaseJob::internals()
{
return d->m_internals;
}
Metadata BaseJob::metadata() const
{
return d->m_metadata;
}
void BaseJob::setMetadata(const Attica::Metadata &data) const
{
d->m_metadata = data;
}
#include "moc_atticabasejob.cpp"
@@ -0,0 +1,88 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_ATTICABASEJOB_H
#define ATTICA_ATTICABASEJOB_H
#include <memory>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QObject>
#include <QSharedPointer>
#include <QUrl>
#include "attica_export.h"
#include "metadata.h"
class QNetworkReply;
namespace Attica
{
class PlatformDependent;
/**
* @class BaseJob atticabasejob.h
*
* The baseclass for all job classes.
*/
class ATTICA_EXPORT BaseJob : public QObject
{
Q_OBJECT
public:
~BaseJob() override;
Metadata metadata() const;
enum NetworkRequestCustomAttributes {
UserAttribute = QNetworkRequest::User + 1,
PasswordAttribute,
};
/**
* @returns whether abort() has been called on the job
*
* @since 5.87
*/
bool isAborted() const;
public Q_SLOTS:
void start();
void abort();
Q_SIGNALS:
void finished(Attica::BaseJob *job);
protected Q_SLOTS:
void dataFinished();
protected:
BaseJob(PlatformDependent *internals);
void setMetadata(const Metadata &data) const;
virtual QNetworkReply *executeRequest() = 0;
virtual void parse(const QString &xml) = 0;
PlatformDependent *internals();
void setError(int errorCode);
private Q_SLOTS:
ATTICA_NO_EXPORT void doWork();
ATTICA_NO_EXPORT void authenticationRequired(QNetworkReply *, QAuthenticator *);
private:
BaseJob(const BaseJob &other) = delete;
BaseJob &operator=(const BaseJob &other) = delete;
class Private;
std::unique_ptr<Private> d;
};
}
#endif
@@ -0,0 +1,83 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "atticautils.h"
#include <QStringList>
#include <QTimeZone>
using namespace Attica;
QDateTime Utils::parseQtDateTimeIso8601(const QString &str)
{
QDateTime result;
QStringList list;
QString datetime;
int tzsign = 0;
if (str.indexOf(QLatin1String("+")) != -1) {
list = str.split(QStringLiteral("+"));
datetime = list[0];
tzsign = 1;
} else if (str.indexOf(QLatin1String("-")) != -1) {
list = str.split(QStringLiteral("-"));
datetime = list[0];
tzsign = -1;
} else {
datetime = str;
}
// parse date time
result = QDateTime::fromString(datetime, Qt::ISODate);
result.setTimeZone(QTimeZone::utc());
// parse timezone
if (list.count() == 2) {
QString tz = list[1];
int hh = 0;
int mm = 0;
int tzsecs = 0;
if (tz.indexOf(QLatin1Char(':')) != -1) {
QStringList tzlist = tz.split(QLatin1Char(':'));
if (tzlist.count() == 2) {
hh = tzlist[0].toInt();
mm = tzlist[1].toInt();
}
} else {
QStringView sv(tz);
hh = sv.left(2).toInt();
mm = sv.mid(2).toInt();
}
tzsecs = 60 * 60 * hh + 60 * mm;
result = result.addSecs(-tzsecs * tzsign);
}
return result;
}
const char *Utils::toString(QNetworkAccessManager::Operation operation)
{
switch (operation) {
case QNetworkAccessManager::GetOperation:
return "Get";
case QNetworkAccessManager::HeadOperation:
return "Head";
case QNetworkAccessManager::PutOperation:
return "Put";
case QNetworkAccessManager::PostOperation:
return "Post";
case QNetworkAccessManager::DeleteOperation:
return "Delete";
case QNetworkAccessManager::CustomOperation:
return "Custom";
default:
return "unknown";
}
return "invalid";
}
@@ -0,0 +1,29 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICAUTILS_H
#define ATTICAUTILS_H
#include <QDateTime>
#include <QNetworkAccessManager>
#include <QString>
namespace Attica
{
class Utils
{
public:
/// parses the QtDateTime in ISO 8601 format correctly (recognizes TZ properly)
static QDateTime parseQtDateTimeIso8601(const QString &str);
static const char *toString(QNetworkAccessManager::Operation operation);
};
}
#endif // ATTICAUTILS_H
@@ -0,0 +1,90 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "buildservice.h"
using namespace Attica;
class Q_DECL_HIDDEN BuildService::Private : public QSharedData
{
public:
QString id;
QString name;
QString url;
// QStringList targets;
QList<Target> targets;
Private()
{
}
};
BuildService::BuildService()
: d(new Private)
{
}
BuildService::BuildService(const BuildService &other)
: d(other.d)
{
}
BuildService &BuildService::operator=(const Attica::BuildService &other)
{
d = other.d;
return *this;
}
BuildService::~BuildService()
{
}
void BuildService::setId(const QString &u)
{
d->id = u;
}
QString BuildService::id() const
{
return d->id;
}
void BuildService::setName(const QString &u)
{
d->name = u;
}
QString BuildService::name() const
{
return d->name;
}
void BuildService::addTarget(const Target &t)
{
d->targets << t;
}
QList<Target> BuildService::targets() const
{
return d->targets;
}
void BuildService::setUrl(const QString &u)
{
d->url = u;
}
QString BuildService::url() const
{
return d->url;
}
bool BuildService::isValid() const
{
return !(d->id.isEmpty());
}
@@ -0,0 +1,70 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_BUILDSERVICE_H
#define ATTICA_BUILDSERVICE_H
#include <QDate>
#include <QList>
#include <QMap>
#include <QSharedDataPointer>
#include <QStringList>
#include <QUrl>
#include "attica_export.h"
namespace Attica
{
/**
* @class Target buildservice.h <Attica/BuildService>
*
* The target in a build service.
*/
struct Target {
QString id;
QString name;
};
/**
* @class BuildService buildservice.h <Attica/BuildService>
*
* Represents a build service.
*/
class ATTICA_EXPORT BuildService
{
public:
typedef QList<BuildService> List;
class Parser;
BuildService();
BuildService(const BuildService &other);
BuildService &operator=(const BuildService &other);
~BuildService();
void setId(const QString &);
QString id() const;
void setName(const QString &);
QString name() const;
void setUrl(const QString &);
QString url() const;
void addTarget(const Target &);
QList<Target> targets() const;
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,154 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "buildservicejob.h"
using namespace Attica;
class Q_DECL_HIDDEN BuildServiceJob::Private : public QSharedData
{
public:
QString id;
QString name;
int status;
qreal progress;
QString projectId;
QString target;
QString buildServiceId;
QString url;
QString message;
Private()
{
}
};
BuildServiceJob::BuildServiceJob()
: d(new Private)
{
}
BuildServiceJob::BuildServiceJob(const BuildServiceJob &other)
: d(other.d)
{
}
BuildServiceJob &BuildServiceJob::operator=(const Attica::BuildServiceJob &other)
{
d = other.d;
return *this;
}
BuildServiceJob::~BuildServiceJob()
{
}
void BuildServiceJob::setId(const QString &u)
{
d->id = u;
}
QString BuildServiceJob::id() const
{
return d->id;
}
void BuildServiceJob::setName(const QString &u)
{
d->name = u;
}
QString BuildServiceJob::name() const
{
return d->name;
}
void BuildServiceJob::setProgress(const qreal p)
{
d->progress = p;
}
qreal BuildServiceJob::progress() const
{
return d->progress;
}
void BuildServiceJob::setStatus(const int status)
{
d->status = status;
}
bool BuildServiceJob::isRunning() const
{
return d->status == 1;
}
bool BuildServiceJob::isCompleted() const
{
return d->status == 2;
}
bool BuildServiceJob::isFailed() const
{
return d->status == 3;
}
void BuildServiceJob::setUrl(const QString &u)
{
d->url = u;
}
QString BuildServiceJob::url() const
{
return d->url;
}
void BuildServiceJob::setMessage(const QString &u)
{
d->message = u;
}
QString BuildServiceJob::message() const
{
return d->message;
}
void BuildServiceJob::setProjectId(const QString &u)
{
d->projectId = u;
}
QString BuildServiceJob::projectId() const
{
return d->projectId;
}
void BuildServiceJob::setTarget(const QString &u)
{
d->target = u;
}
QString BuildServiceJob::target() const
{
return d->target;
}
void BuildServiceJob::setBuildServiceId(const QString &u)
{
d->buildServiceId = u;
}
QString BuildServiceJob::buildServiceId() const
{
return d->buildServiceId;
}
bool BuildServiceJob::isValid() const
{
return !(d->id.isEmpty());
}
@@ -0,0 +1,77 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_BUILDSERVICEJOB_H
#define ATTICA_BUILDSERVICEJOB_H
#include <QDate>
#include <QList>
#include <QMap>
#include <QSharedDataPointer>
#include <QStringList>
#include <QUrl>
#include "attica_export.h"
namespace Attica
{
/**
* @class BuildServiceJob buildservicejob.h <Attica/BuildServiceJob>
*
* Represents a build service job.
*/
class ATTICA_EXPORT BuildServiceJob
{
public:
typedef QList<BuildServiceJob> List;
class Parser;
BuildServiceJob();
BuildServiceJob(const BuildServiceJob &other);
BuildServiceJob &operator=(const BuildServiceJob &other);
~BuildServiceJob();
void setId(const QString &);
QString id() const;
void setName(const QString &);
QString name() const;
void setUrl(const QString &);
QString url() const;
void setProjectId(const QString &);
QString projectId() const;
void setBuildServiceId(const QString &);
QString buildServiceId() const;
void setMessage(const QString &);
QString message() const;
void setTarget(const QString &);
QString target() const;
void setProgress(const qreal);
qreal progress() const;
void setStatus(const int);
bool isRunning() const;
bool isCompleted() const;
bool isFailed() const;
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,56 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Dan Leinir Turthra Jensen <admin@leinir.dk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "buildservicejoboutput.h"
using namespace Attica;
class Q_DECL_HIDDEN BuildServiceJobOutput::Private : public QSharedData
{
public:
QString output;
Private()
{
}
};
BuildServiceJobOutput::BuildServiceJobOutput()
: d(new Private)
{
}
BuildServiceJobOutput::BuildServiceJobOutput(const BuildServiceJobOutput &other)
: d(other.d)
{
}
BuildServiceJobOutput &BuildServiceJobOutput::operator=(const Attica::BuildServiceJobOutput &other)
{
d = other.d;
return *this;
}
BuildServiceJobOutput::~BuildServiceJobOutput()
{
}
void BuildServiceJobOutput::setOutput(const QString &output)
{
d->output = output;
}
QString BuildServiceJobOutput::output() const
{
return d->output;
}
bool BuildServiceJobOutput::isValid() const
{
return !(d->output.isNull());
}
@@ -0,0 +1,52 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Dan Leinir Turthra Jensen <admin@leinir.dk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_BUILDSERVICEJOBOUTPUT_H
#define ATTICA_BUILDSERVICEJOBOUTPUT_H
#include <QList>
#include <QSharedDataPointer>
#include <QString>
#include "attica_export.h"
namespace Attica
{
/**
* @class BuildServiceJobOutput buildservicejoboutput.h <Attica/BuildServiceJobOutput>
*
* Represents the ouput of a build service job.
*/
class ATTICA_EXPORT BuildServiceJobOutput
{
public:
typedef QList<BuildServiceJobOutput> List;
class Parser;
BuildServiceJobOutput();
BuildServiceJobOutput(const BuildServiceJobOutput &other);
BuildServiceJobOutput &operator=(const BuildServiceJobOutput &other);
~BuildServiceJobOutput();
void setOutput(const QString &output);
QString output() const;
bool isRunning() const;
bool isCompleted() const;
bool isFailed() const;
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
} // namespace Attica
#endif // ATTICA_BUILDSERVICEJOBOUTPUT_H
@@ -0,0 +1,36 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Dan Leinir Turthra Jensen <admin@leinir.dk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "buildservicejoboutputparser.h"
#include "qdebug.h"
using namespace Attica;
BuildServiceJobOutput BuildServiceJobOutput::Parser::parseXml(QXmlStreamReader &xml)
{
BuildServiceJobOutput buildservicejoboutput;
// For specs about the XML provided, see here:
// http://www.freedesktop.org/wiki/Specifications/open-collaboration-services-draft#BuildServiceJobs
while (!xml.atEnd()) {
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("output")) {
buildservicejoboutput.setOutput(xml.readElementText());
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("output")) {
break;
}
xml.readNext();
}
return buildservicejoboutput;
}
QStringList BuildServiceJobOutput::Parser::xmlElement() const
{
return QStringList(QStringLiteral("output"));
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Dan Leinir Turthra Jensen <admin@leinir.dk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_BUILDSERVICEJOBOUTPUTPARSER_H
#define ATTICA_BUILDSERVICEJOBOUTPUTPARSER_H
#include "buildservicejoboutput.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN BuildServiceJobOutput::Parser : public Attica::Parser<BuildServiceJobOutput>
{
public:
BuildServiceJobOutput parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
} // namespace Attica
#endif // ATTICA_BUILDSERVICEJOBOUTPUTPARSER_H
@@ -0,0 +1,56 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "buildservicejobparser.h"
#include <qdebug.h>
using namespace Attica;
BuildServiceJob BuildServiceJob::Parser::parseXml(QXmlStreamReader &xml)
{
BuildServiceJob buildservicejob;
// For specs about the XML provided, see here:
// http://www.freedesktop.org/wiki/Specifications/open-collaboration-services-draft#BuildServiceJobs
while (!xml.atEnd()) {
// qCDebug(ATTICA) << "XML returned:" << xml.text().toString();
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) { // FIXME: server should give "id" here ...
buildservicejob.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("project")) {
buildservicejob.setProjectId(xml.readElementText());
} else if (xml.name() == QLatin1String("buildservice")) {
buildservicejob.setBuildServiceId(xml.readElementText());
} else if (xml.name() == QLatin1String("target")) {
buildservicejob.setTarget(xml.readElementText());
} else if (xml.name() == QLatin1String("name")) {
buildservicejob.setName(xml.readElementText());
} else if (xml.name() == QLatin1String("status")) {
int status = xml.readElementText().toInt();
buildservicejob.setStatus(status);
} else if (xml.name() == QLatin1String("progress")) {
qreal progress = (qreal)(xml.readElementText().toFloat());
buildservicejob.setProgress(progress);
} else if (xml.name() == QLatin1String("message")) {
buildservicejob.setMessage(xml.readElementText());
} else if (xml.name() == QLatin1String("url")) {
buildservicejob.setUrl(xml.readElementText());
}
} else if (xml.isEndElement() && (xml.name() == QLatin1String("buildjob") || xml.name() == QLatin1String("user"))) {
break;
}
}
return buildservicejob;
}
QStringList BuildServiceJob::Parser::xmlElement() const
{
return QStringList(QStringLiteral("buildjob")) << QStringLiteral("user");
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_BUILDSERVICEJOBPARSER_H
#define ATTICA_BUILDSERVICEJOBPARSER_H
#include "buildservicejob.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN BuildServiceJob::Parser : public Attica::Parser<BuildServiceJob>
{
private:
BuildServiceJob parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,69 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "buildserviceparser.h"
#include <qdebug.h>
using namespace Attica;
BuildService BuildService::Parser::parseXml(QXmlStreamReader &xml)
{
// For specs about the XML provided, see here:
// http://www.freedesktop.org/wiki/Specifications/open-collaboration-services-draft
BuildService buildservice;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
buildservice.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("name")) {
buildservice.setName(xml.readElementText());
} else if (xml.name() == QLatin1String("registrationurl")) {
buildservice.setUrl(xml.readElementText());
} else if (xml.name() == QLatin1String("supportedtargets")) {
while (!xml.atEnd()) {
xml.readNextStartElement();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("target")) {
Target t;
while (!xml.atEnd()) {
xml.readNextStartElement();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
t.id = xml.readElementText();
} else if (xml.name() == QLatin1String("name")) {
t.name = xml.readElementText();
}
} else if (xml.isEndElement() && (xml.name() == QLatin1String("target"))) {
xml.readNext();
break;
}
}
buildservice.addTarget(t);
}
} else if (xml.isEndElement() && (xml.name() == QLatin1String("supportedtargets"))) {
xml.readNext();
break;
}
}
}
} else if (xml.isEndElement() //
&& (xml.name() == QLatin1String("buildservice") || xml.name() == QLatin1String("user"))) {
break;
}
}
return buildservice;
}
QStringList BuildService::Parser::xmlElement() const
{
return QStringList(QStringLiteral("buildservice")) << QStringLiteral("user");
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_BUILDSERVICEPARSER_H
#define ATTICA_BUILDSERVICEPARSER_H
#include "buildservice.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN BuildService::Parser : public Attica::Parser<BuildService>
{
private:
BuildService parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,77 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "category.h"
#include <QDebug>
#include <QString>
using namespace Attica;
class Q_DECL_HIDDEN Category::Private : public QSharedData
{
public:
QString m_id;
QString m_name;
QString m_displayName;
};
Category::Category()
: d(new Private)
{
}
Category::Category(const Attica::Category &other)
: d(other.d)
{
}
Category &Category::operator=(const Attica::Category &other)
{
d = other.d;
return *this;
}
Category::~Category()
{
}
void Category::setId(const QString &u)
{
d->m_id = u;
}
QString Category::id() const
{
return d->m_id;
}
void Category::setName(const QString &name)
{
d->m_name = name;
}
QString Category::name() const
{
return d->m_name;
}
void Category::setDisplayName(const QString &name)
{
d->m_displayName = name;
}
QString Category::displayName() const
{
return d->m_displayName;
}
bool Category::isValid() const
{
return !(d->m_id.isEmpty());
}
@@ -0,0 +1,109 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_CATEGORY_H
#define ATTICA_CATEGORY_H
#include <QList>
#include <QSharedDataPointer>
#include "attica_export.h"
namespace Attica
{
/**
* @class Category category.h <Attica/Category>
*
* Represents a single content category
*/
class ATTICA_EXPORT Category
{
public:
typedef QList<Category> List;
class Parser;
/**
* Creates an empty Category
*/
Category();
/**
* Copy constructor.
* @param other the Category to copy from
*/
Category(const Category &other);
/**
* Assignment operator.
* @param other the Category to assign from
* @return pointer to this Category
*/
Category &operator=(const Category &other);
/**
* Destructor.
*/
~Category();
/**
* Sets the id of the Category.
* The id uniquely identifies a Category with the OCS API.
* @param id the new id
*/
void setId(const QString &);
/**
* Gets the id of the Category.
* The id uniquely identifies a Category with the OCS API.
* @return the id
*/
QString id() const;
/**
* Sets the name of the Category.
* @param name the new name
*/
void setName(const QString &name);
/**
* Gets the name of the Category.
* @return the name
*/
QString name() const;
/**
* Checks whether this Category has an id
* @return @c true if an id has been set, @c false otherwise
*/
bool isValid() const;
/**
* Sets the display name of the Category.
* This name is guaranteed to be user friendly, while name may be
* internal for the server
* @param name the new name
* @since 5.31
*/
void setDisplayName(const QString &name);
/**
* Gets the display name of the Category.
* This name is guaranteed to be user friendly, while name may be
* internal for the server
* @return the name
* @since 5.31
*/
QString displayName() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,39 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "categoryparser.h"
using namespace Attica;
Category Category::Parser::parseXml(QXmlStreamReader &xml)
{
Category category;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
category.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("name")) {
category.setName(xml.readElementText());
} else if (xml.name() == QLatin1String("display_name")) {
category.setDisplayName(xml.readElementText());
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("category")) {
break;
}
}
return category;
}
QStringList Category::Parser::xmlElement() const
{
return QStringList(QStringLiteral("category"));
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_CATEGORYPARSER_H
#define ATTICA_CATEGORYPARSER_H
#include "category.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN Category::Parser : public Attica::Parser<Category>
{
private:
Category parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,124 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2012 Laszlo Papp <lpapp@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "cloud.h"
using namespace Attica;
class Q_DECL_HIDDEN Cloud::Private : public QSharedData
{
public:
QString m_name;
QString m_url;
QUrl m_icon;
qulonglong m_quota;
qulonglong m_free;
qulonglong m_used;
float m_relative;
QString m_key;
};
Cloud::Cloud()
: d(new Private)
{
}
Cloud::Cloud(const Attica::Cloud &other)
: d(other.d)
{
}
Cloud &Cloud::operator=(const Attica::Cloud &other)
{
d = other.d;
return *this;
}
Cloud::~Cloud()
{
}
void Cloud::setName(const QString &name)
{
d->m_name = name;
}
QString Cloud::name() const
{
return d->m_name;
}
void Cloud::setUrl(const QString &url)
{
d->m_url = url;
}
QString Cloud::url() const
{
return d->m_url;
}
void Cloud::setIcon(const QUrl &icon)
{
d->m_icon = icon;
}
QUrl Cloud::icon() const
{
return d->m_icon;
}
void Cloud::setQuota(qulonglong quota)
{
d->m_quota = quota;
}
qulonglong Cloud::quota() const
{
return d->m_quota;
}
void Cloud::setFree(qulonglong free)
{
d->m_free = free;
}
qulonglong Cloud::free() const
{
return d->m_free;
}
void Cloud::setUsed(qulonglong used)
{
d->m_used = used;
}
qulonglong Cloud::used() const
{
return d->m_used;
}
void Cloud::setRelative(float relative)
{
d->m_relative = relative;
}
float Cloud::relative() const
{
return d->m_relative;
}
void Cloud::setKey(const QString &key)
{
d->m_key = key;
}
QString Cloud::key() const
{
return d->m_key;
}
@@ -0,0 +1,194 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2012 Laszlo Papp <lpapp@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_CLOUD_H
#define ATTICA_CLOUD_H
#include "attica_export.h"
#include <QList>
#include <QSharedDataPointer>
#include <QUrl>
namespace Attica
{
/**
* @class Cloud cloud.h <Attica/Cloud>
*
* Represents a cloud service.
*/
class ATTICA_EXPORT Cloud
{
public:
typedef QList<Cloud> List;
class Parser;
/**
* Creates an empty Cloud
*/
Cloud();
/**
* Copy constructor.
* @param other the Cloud to copy from
*/
Cloud(const Cloud &other);
/**
* Assignment operator.
* @param other the Cloud to assign from
* @return pointer to this Activity
*/
Cloud &operator=(const Cloud &other);
/**
* Destructor.
*/
~Cloud();
/**
* Sets the name of the Cloud service
*
* @param name the new name
*/
void setName(const QString &name);
/**
* Gets the name of the Cloud service.
*
* @return the name
*/
QString name() const;
/**
* Sets the url of the Cloud service
*
* @param url the new url
*/
void setUrl(const QString &url);
/**
* Gets the url of the Cloud service.
*
* @return the url
*/
QString url() const;
/**
* Sets the icon of the Cloud service
*
* @param icon the new icon
*/
void setIcon(const QUrl &icon);
/**
* Gets the icon of the Cloud service.
*
* @return the icon
*/
QUrl icon() const;
/**
* Sets the quota of the Cloud service
*
* @param quota the new quota
*/
void setQuota(qulonglong quota);
/**
* Gets the quota of the Cloud service.
*
* @return the quota
*/
qulonglong quota() const;
/**
* Sets the free amount of the Cloud service
*
* @param free the new free amount
*/
void setFree(qulonglong free);
/**
* Gets the free amount of the Cloud service.
*
* @return the free amount
*/
qulonglong free() const;
/**
* Sets the used amount of the Cloud service
*
* @param used the new used amount
*/
void setUsed(qulonglong used);
/**
* Gets the used amount of the Cloud service.
*
* @return the used amount
*/
qulonglong used() const;
/**
* Sets the relative of the Cloud service
*
* @param relative the new relative
*/
void setRelative(float relative);
/**
* Gets the relative of the Cloud service.
*
* @return the relative
*/
float relative() const;
/**
* Sets the private key of the Cloud service
*
* @param privateKey the new privateKey
*/
void setKey(const QString &privateKey);
/**
* Gets the private key of the Cloud service.
*
* @return the private key
*/
QString key() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,51 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2012 Laszlo Papp <lpapp@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "cloudparser.h"
#include "atticautils.h"
using namespace Attica;
Cloud Cloud::Parser::parseXml(QXmlStreamReader &xml)
{
Cloud cloud;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("name")) {
cloud.setName(xml.readElementText());
} else if (xml.name() == QLatin1String("url")) {
cloud.setUrl(xml.readElementText());
// TODO: there should be usage for the attica icon class
} else if (xml.name() == QLatin1String("icon")) {
cloud.setIcon(QUrl(xml.readElementText()));
} else if (xml.name() == QLatin1String("quota")) {
cloud.setQuota(xml.readElementText().toULongLong());
} else if (xml.name() == QLatin1String("free")) {
cloud.setFree(xml.readElementText().toULongLong());
} else if (xml.name() == QLatin1String("used")) {
cloud.setUsed(xml.readElementText().toULongLong());
} else if (xml.name() == QLatin1String("relative")) {
cloud.setRelative(xml.readElementText().toFloat());
} else if (xml.name() == QLatin1String("key")) {
cloud.setKey(xml.readElementText());
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("cloud")) {
break;
}
}
return cloud;
}
QStringList Cloud::Parser::xmlElement() const
{
return QStringList(QLatin1String("cloud"));
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2012 Laszlo Papp <lpapp@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_CLOUDPARSER_H
#define ATTICA_CLOUDPARSER_H
#include "cloud.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN Cloud::Parser : public Attica::Parser<Cloud>
{
private:
Cloud parseXml(QXmlStreamReader &xml);
QStringList xmlElement() const;
};
}
#endif
@@ -0,0 +1,155 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "comment.h"
#include <QMap>
using namespace Attica;
QString Comment::commentTypeToString(const Comment::Type type)
{
switch (type) {
case ContentComment:
return QStringLiteral("1");
case ForumComment:
return QStringLiteral("4");
case KnowledgeBaseComment:
return QStringLiteral("7");
case EventComment:
return QStringLiteral("8");
}
Q_ASSERT(false);
return QString();
}
class Q_DECL_HIDDEN Comment::Private : public QSharedData
{
public:
QString m_id;
QString m_subject;
QString m_text;
int m_childCount;
QString m_user;
QDateTime m_date;
int m_score;
QList<Comment> m_children;
Private()
: m_childCount(0)
, m_score(0)
{
}
};
Comment::Comment()
: d(new Private)
{
}
Comment::Comment(const Comment &other)
: d(other.d)
{
}
Comment &Comment::operator=(const Attica::Comment &other)
{
d = other.d;
return *this;
}
Comment::~Comment()
{
}
void Comment::setId(const QString &id)
{
d->m_id = id;
}
QString Comment::id() const
{
return d->m_id;
}
void Comment::setSubject(const QString &subject)
{
d->m_subject = subject;
}
QString Comment::subject() const
{
return d->m_subject;
}
void Comment::setText(const QString &text)
{
d->m_text = text;
}
QString Comment::text() const
{
return d->m_text;
}
void Comment::setChildCount(const int childCount)
{
d->m_childCount = childCount;
}
int Comment::childCount() const
{
return d->m_childCount;
}
void Comment::setUser(const QString &user)
{
d->m_user = user;
}
QString Comment::user() const
{
return d->m_user;
}
void Comment::setDate(const QDateTime &date)
{
d->m_date = date;
}
QDateTime Comment::date() const
{
return d->m_date;
}
void Comment::setScore(const int score)
{
d->m_score = score;
}
int Comment::score() const
{
return d->m_score;
}
void Comment::setChildren(QList<Comment> children)
{
d->m_children = std::move(children); // TODO KF6 Make QList const & and remove the std::move
}
QList<Comment> Comment::children() const
{
return d->m_children;
}
bool Comment::isValid() const
{
return !(d->m_id.isEmpty());
}
@@ -0,0 +1,88 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_COMMENT_H
#define ATTICA_COMMENT_H
#include "attica_export.h"
#include <QDateTime>
#include <QSharedDataPointer>
#include <QUrl>
namespace Attica
{
/**
* @class Comment comment.h <Attica/Comment>
*
* Represents a comment.
*/
class ATTICA_EXPORT Comment
{
public:
typedef QList<Comment> List;
class Parser;
enum Type {
ContentComment,
ForumComment,
KnowledgeBaseComment,
EventComment,
};
static QString commentTypeToString(const Comment::Type type);
Comment();
Comment(const Comment &other);
Comment &operator=(const Comment &other);
~Comment();
void setId(const QString &id);
QString id() const;
void setSubject(const QString &subject);
QString subject() const;
void setText(const QString &text);
QString text() const;
void setChildCount(const int childCount);
int childCount() const;
void setUser(const QString &user);
QString user() const;
void setDate(const QDateTime &date);
QDateTime date() const;
/**
This is for internal usage, @see Provider::setCommentScore to set scores in comments.
@param score average comment score in scale from 0 to 100
*/
void setScore(const int score);
/**
Returns score of this comment.
@param score average comment score in scale from 0 to 100
*/
int score() const;
void setChildren(QList<Comment> comments);
QList<Comment> children() const;
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,77 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "commentparser.h"
#include "atticautils.h"
#include <QDebug>
using namespace Attica;
Comment Comment::Parser::parseXml(QXmlStreamReader &xml)
{
Comment comment;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
comment.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("subject")) {
comment.setSubject(xml.readElementText());
} else if (xml.name() == QLatin1String("text")) {
comment.setText(xml.readElementText());
} else if (xml.name() == QLatin1String("childcount")) {
comment.setChildCount(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("user")) {
comment.setUser(xml.readElementText());
} else if (xml.name() == QLatin1String("date")) {
comment.setDate(Utils::parseQtDateTimeIso8601(xml.readElementText()));
} else if (xml.name() == QLatin1String("score")) {
comment.setScore(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("children")) {
// This may seem strange, however we are dealing with a situation where we may
// receive multiple children subsections (the standard accepts this, and certain
// server implementations do do this)
QList<Comment> children = comment.children();
children += parseXmlChildren(xml);
comment.setChildren(children);
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("comment")) {
break;
}
}
return comment;
}
QList<Comment> Comment::Parser::parseXmlChildren(QXmlStreamReader &xml)
{
QList<Comment> children;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("comment")) {
Comment comment = parseXml(xml);
children.append(comment);
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("children")) {
break;
}
}
return children;
}
QStringList Comment::Parser::xmlElement() const
{
return QStringList(QStringLiteral("comment"));
}
@@ -0,0 +1,28 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_COMMENTPARSER_H
#define ATTICA_COMMENTPARSER_H
#include "comment.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN Comment::Parser : public Attica::Parser<Comment>
{
private:
Comment parseXml(QXmlStreamReader &xml) override;
QList<Comment> parseXmlChildren(QXmlStreamReader &xml);
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,101 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2018 Ralf Habacker <ralf.habacker@freenet.de>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "config.h"
using namespace Attica;
class Q_DECL_HIDDEN Config::Private : public QSharedData
{
public:
QString m_version;
QString m_website;
QString m_host;
QString m_contact;
bool m_ssl;
Private()
: m_ssl(false)
{
}
};
Config::Config()
: d(new Private)
{
}
Config::Config(const Attica::Config &other)
: d(other.d)
{
}
Config &Config::operator=(const Attica::Config &other)
{
d = other.d;
return *this;
}
Config::~Config()
{
}
QString Attica::Config::version() const
{
return d->m_version;
}
QString Config::website() const
{
return d->m_website;
}
QString Config::host() const
{
return d->m_host;
}
QString Config::contact() const
{
return d->m_contact;
}
bool Config::ssl() const
{
return d->m_ssl;
}
bool Config::isValid() const
{
return !(d->m_version.isEmpty());
}
void Config::setContact(const QString &contact)
{
d->m_contact = contact;
}
void Config::setVersion(const QString &version)
{
d->m_version = version;
}
void Config::setWebsite(const QString &website)
{
d->m_website = website;
}
void Config::setHost(const QString &host)
{
d->m_host = host;
}
void Config::setSsl(bool ssl)
{
d->m_ssl = ssl;
}
@@ -0,0 +1,77 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2018 Ralf Habacker <ralf.habacker@freenet.de>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_CONFIG_H
#define ATTICA_CONFIG_H
#include <QSharedDataPointer>
#include <QString>
#include "attica_export.h"
namespace Attica
{
/**
* @class Config config.h <Attica/Config>
*
* Represents a server config
*/
class ATTICA_EXPORT Config
{
public:
typedef QList<Config> List;
class Parser;
/**
* Creates an empty Config
*/
Config();
/**
* Copy constructor.
* @param other the Config to copy from
*/
Config(const Config &other);
/**
* Assignment operator.
* @param other the Config to assign from
* @return pointer to this Config
*/
Config &operator=(const Config &other);
/**
* Destructor.
*/
~Config();
QString contact() const;
QString host() const;
QString version() const;
bool ssl() const;
QString website() const;
void setContact(const QString &contact);
void setHost(const QString &host);
void setSsl(bool ssl);
void setVersion(const QString &version);
void setWebsite(const QString &website);
/**
* Checks whether this config is valid
* @return @c true if config is valid, @c false otherwise
*/
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,45 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2018 Ralf Habacker <ralf.habacker@freenet.de>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "configparser.h"
using namespace Attica;
Config Config::Parser::parseXml(QXmlStreamReader &xml)
{
Config config;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("version")) {
config.setVersion(xml.readElementText());
} else if (xml.name() == QLatin1String("website")) {
config.setWebsite(xml.readElementText());
} else if (xml.name() == QLatin1String("host")) {
config.setHost(xml.readElementText());
} else if (xml.name() == QLatin1String("contact")) {
config.setContact(xml.readElementText());
} else if (xml.name() == QLatin1String("ssl")) {
config.setSsl(xml.readElementText() == QLatin1String("true"));
}
}
if (xml.isEndElement() && xml.name() == QLatin1String("data")) {
break;
}
}
return config;
}
QStringList Config::Parser::xmlElement() const
{
return QStringList(QStringLiteral("data"));
}
@@ -0,0 +1,29 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2018 Ralf Habacker <ralf.habacker@freenet.de>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_CONFIGPARSER_H
#define ATTICA_CONFIGPARSER_H
#include "config.h"
#include "parser.h"
#include "attica_export.h"
namespace Attica
{
// exported for autotest
class ATTICA_EXPORT Config::Parser : public Attica::Parser<Config>
{
private:
Config parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,328 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "content.h"
#include <QDateTime>
using namespace Qt::StringLiterals;
using namespace Attica;
class Q_DECL_HIDDEN Content::Private : public QSharedData
{
public:
QString m_id;
QString m_name;
int m_downloads;
int m_numberOfComments;
int m_rating;
QDateTime m_created;
QDateTime m_updated;
QList<Icon> m_icons;
QList<QUrl> m_videos;
QStringList m_tags;
QMap<QString, QString> m_extendedAttributes;
Private()
: m_downloads(0)
, m_numberOfComments(0)
, m_rating(0)
{
}
};
Content::Content()
: d(new Private)
{
}
Content::Content(const Attica::Content &other)
: d(other.d)
{
}
Content &Content::operator=(const Attica::Content &other)
{
d = other.d;
return *this;
}
Content::~Content()
{
}
void Content::setId(const QString &u)
{
d->m_id = u;
}
QString Content::id() const
{
return d->m_id;
}
void Content::setName(const QString &name)
{
d->m_name = name;
}
QString Content::name() const
{
return d->m_name;
}
void Content::setRating(int v)
{
d->m_rating = v;
}
int Content::rating() const
{
return d->m_rating;
}
void Content::setDownloads(int v)
{
d->m_downloads = v;
}
int Content::downloads() const
{
return d->m_downloads;
}
void Content::setNumberOfComments(int v)
{
d->m_numberOfComments = v;
}
int Content::numberOfComments() const
{
return d->m_numberOfComments;
}
void Content::setCreated(const QDateTime &date)
{
d->m_created = date;
}
QDateTime Content::created() const
{
return d->m_created;
}
void Content::setUpdated(const QDateTime &date)
{
d->m_updated = date;
}
QDateTime Content::updated() const
{
return d->m_updated;
}
void Content::addAttribute(const QString &key, const QString &value)
{
d->m_extendedAttributes.insert(key, value);
}
QString Content::attribute(const QString &key) const
{
return d->m_extendedAttributes.value(key);
}
QMap<QString, QString> Content::attributes() const
{
return d->m_extendedAttributes;
}
bool Content::isValid() const
{
return !(d->m_id.isEmpty());
}
QString Content::summary() const
{
return attribute(QStringLiteral("summary"));
}
QString Content::description() const
{
return attribute(QStringLiteral("description"));
}
QUrl Content::detailpage() const
{
return QUrl(attribute(QStringLiteral("detailpage")));
}
QString Attica::Content::changelog() const
{
return attribute(QStringLiteral("changelog"));
}
QString Attica::Content::depend() const
{
return attribute(QStringLiteral("depend"));
}
QList<Attica::DownloadDescription> Attica::Content::downloadUrlDescriptions() const
{
QList<Attica::DownloadDescription> descriptions;
QMap<QString, QString>::const_iterator iter = d->m_extendedAttributes.constBegin();
while (iter != d->m_extendedAttributes.constEnd()) {
const QString &key = iter.key();
static const QLatin1String tag("downloadname");
if (key.startsWith(tag)) {
bool ok;
// remove "downloadlink", get the rest as number
const int num = QStringView(key).right(key.size() - tag.size()).toInt(&ok);
if (ok) {
// check if the download actually has a name
if (!iter.value().isEmpty()) {
descriptions.append(downloadUrlDescription(num));
}
}
}
++iter;
}
return descriptions;
}
Attica::DownloadDescription Attica::Content::downloadUrlDescription(int number) const
{
QString num(QString::number(number));
DownloadDescription desc;
Attica::DownloadDescription::Type downloadType = Attica::DownloadDescription::LinkDownload;
if (attribute(QLatin1String("downloadway") + num) == QLatin1Char('0')) {
downloadType = Attica::DownloadDescription::FileDownload;
} else if (attribute(QLatin1String("downloadway") + num) == QLatin1Char('1')) {
downloadType = Attica::DownloadDescription::LinkDownload;
} else if (attribute(QLatin1String("downloadway") + num) == QLatin1Char('2')) {
downloadType = Attica::DownloadDescription::PackageDownload;
}
desc.setType(downloadType);
desc.setId(number);
desc.setName(attribute(QLatin1String("downloadname") + num));
desc.setDistributionType(attribute(QLatin1String("downloadtype") + num));
desc.setHasPrice(attribute(QLatin1String("downloadbuy") + num) == QLatin1Char('1'));
desc.setLink(attribute(QLatin1String("downloadlink") + num));
desc.setPriceReason(attribute(QLatin1String("downloadreason") + num));
desc.setPriceAmount(attribute(QLatin1String("downloadprice") + num));
desc.setSize(attribute(QLatin1String("downloadsize") + num).toUInt());
desc.setGpgFingerprint(attribute(QLatin1String("downloadgpgfingerprint") + num));
desc.setGpgSignature(attribute(QLatin1String("downloadgpgsignature") + num));
desc.setPackageName(attribute(QLatin1String("downloadpackagename") + num));
desc.setRepository(attribute(QLatin1String("downloadrepository") + num));
desc.setTags(attribute(QLatin1String("downloadtags") + num).split(QLatin1Char(',')));
desc.setVersion(attribute("download_version"_L1 + num));
return desc;
}
QList<HomePageEntry> Attica::Content::homePageEntries()
{
QList<Attica::HomePageEntry> homepages;
QMap<QString, QString>::const_iterator iter = d->m_extendedAttributes.constBegin();
while (iter != d->m_extendedAttributes.constEnd()) {
QString key = iter.key();
if (key.startsWith(QLatin1String("homepagetype"))) {
bool ok;
// remove "homepage", get the rest as number
const int num = QStringView(key).right(key.size() - 12).toInt(&ok);
if (ok) {
// check if the homepage actually has a valid type
if (!iter.value().isEmpty()) {
homepages.append(homePageEntry(num));
}
}
}
++iter;
}
return homepages;
}
Attica::HomePageEntry Attica::Content::homePageEntry(int number) const
{
QString num(QString::number(number));
HomePageEntry homepage;
if (number == 1 && attribute(QStringLiteral("homepage1")).isEmpty()) {
num.clear();
}
homepage.setType(attribute(QLatin1String("homepagetype") + num));
homepage.setUrl(QUrl(attribute(QLatin1String("homepage") + num)));
return homepage;
}
QString Attica::Content::version() const
{
return attribute(QStringLiteral("version"));
}
QString Attica::Content::author() const
{
return attribute(QStringLiteral("personid"));
}
QString Attica::Content::license() const
{
return attribute(QStringLiteral("licensetype"));
}
QString Attica::Content::licenseName() const
{
return attribute(QStringLiteral("license"));
}
QString Attica::Content::previewPicture(const QString &number) const
{
return attribute(QLatin1String("previewpic") + number);
}
QString Attica::Content::smallPreviewPicture(const QString &number) const
{
return attribute(QLatin1String("smallpreviewpic") + number);
}
QList<Icon> Attica::Content::icons()
{
return d->m_icons;
}
QList<Icon> Attica::Content::icons() const
{
return d->m_icons;
}
void Attica::Content::setIcons(QList<Icon> icons)
{
d->m_icons = std::move(icons); // TODO KF6 Make QList const & and remove the std::move
}
QList<QUrl> Attica::Content::videos()
{
return d->m_videos;
}
void Attica::Content::setVideos(QList<QUrl> videos)
{
d->m_videos = std::move(videos);
}
QStringList Attica::Content::tags() const
{
return d->m_tags;
}
void Attica::Content::setTags(const QStringList &tags)
{
d->m_tags = tags;
}
@@ -0,0 +1,268 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_CONTENT_H
#define ATTICA_CONTENT_H
#include <QList>
#include <QMap>
#include <QSharedDataPointer>
#include <QString>
#include <QUrl>
#include "attica_export.h"
#include "downloaddescription.h"
#include "homepageentry.h"
#include "icon.h"
class QDateTime;
namespace Attica
{
/**
* @class Content content.h <Attica/Content>
*
* Represents a single content
*/
class ATTICA_EXPORT Content
{
public:
typedef QList<Content> List;
class Parser;
/**
* Creates an empty Content
*/
Content();
/**
* Copy constructor.
* @param other the Content to copy from
*/
Content(const Content &other);
/**
* Assignment operator.
* @param other the Content to assign from
* @return pointer to this Content
*/
Content &operator=(const Content &other);
/**
* Destructor.
*/
~Content();
/**
* Sets the id of the Content.
* The id uniquely identifies a Content with the OCS API.
* @param id the new id
*/
void setId(const QString &id);
/**
* Gets the id of the Content.
* The id uniquely identifies a Content with the OCS API.
* @return the id
*/
QString id() const;
/**
* Sets the name of the Content.
* @param name the new name
*/
void setName(const QString &name);
/**
* Gets the name of the Content.
* @return the name
*/
QString name() const;
/**
* Sets the rating of the Content.
* @param rating the new rating, has to be in the range 0-100
*/
void setRating(int rating);
/**
* Gets the rating of the Content.
* @return the rating in the range 0-100
*/
int rating() const;
/**
* Sets the number of downloads for the Content.
* @param downloads the new number of downloads
*/
void setDownloads(int downloads);
/**
* Gets the number of downloads for the Content (how often this has been downloaded from the server).
* @return the number of downloads
*/
int downloads() const;
/**
* Sets the number of comments for the Content.
* @param numComments the new number of downloads
*/
void setNumberOfComments(int numComments);
/**
* Gets the number of comments for the Content.
* @return the number of comments
*/
int numberOfComments() const;
/**
* Sets the date and time the Content has been created.
* @param created the new creation date and time
*/
void setCreated(const QDateTime &created);
/**
* Gets the date and time the Content has been created.
* @return the date and time of the last update
*/
QDateTime created() const;
/**
* Sets the time the Content has been last updated.
* @param updated the new date and time of the last update
*/
void setUpdated(const QDateTime &updated);
/**
* Gets the date and time the Content has been last updated.
* @return the date and time of the last update
*/
QDateTime updated() const;
/**
* A summary description of this content.
*/
QString summary() const;
/**
* A description of this content.
*/
QString description() const;
/**
* A webpage with the detailed description of this content.
*/
QUrl detailpage() const;
QString changelog() const;
QString version() const;
QString depend() const;
/**
Get the details about a download (a content can have multiple links, eg for different distros).
This is not very helpful if we don't know the allowed numbers.
*/
DownloadDescription downloadUrlDescription(int number) const;
/**
Get all possible downloads.
This is slow searching through lots of strings, so beware and don't call it too often.
*/
QList<DownloadDescription> downloadUrlDescriptions() const;
/**
Get the details about a home page (a content can have multiple home pages, blog, bugs, ...).
This is not very helpful if we don't know the allowed numbers.
*/
HomePageEntry homePageEntry(int number) const;
/**
Get all home pages for this content.
This is slow searching through lots of strings, so beware and don't call it too often.
*/
QList<HomePageEntry> homePageEntries();
QString previewPicture(const QString &number = QStringLiteral("1")) const;
QString smallPreviewPicture(const QString &number = QStringLiteral("1")) const;
QString license() const;
QString licenseName() const;
QString author() const;
/**
Get all icons for this content.
*/
QList<Icon> icons();
/**
Get all icons for this content.
*/
QList<Icon> icons() const;
/**
* Set list of icons.
* @param icons list of icons for this content
*/
void setIcons(QList<Icon> icons);
/**
Get all videos for this content.
*/
QList<QUrl> videos();
/**
* Set list of videos.
* @param videos list of videos for this content
*/
void setVideos(QList<QUrl> videos);
/**
* Get all the tags for this content
* @since 5.50
*/
QStringList tags() const;
/**
* Set the list of tags
* @param tags list of tags for this content
* @since 5.50
*/
void setTags(const QStringList &tags);
/**
* Add an attribute that is not included in the basis set of attributes exposed by the Content class.
* If the attribute already exists it gets overwritten.
* @param key the key of the attribute
* @param value the value of the attribute
*/
void addAttribute(const QString &key, const QString &value);
/**
* Get an attribute that is not included in the basis set of attributes exposed by the Content class.
* @param key the key of the attribute
* @return the value of the attribute with the specified key, or an empty string, if the key has not been found
*/
QString attribute(const QString &key) const;
/**
* Get all attributes that are not included in the basis set of attributes exposed by the Content class.
* @return the attribute mappings
*/
QMap<QString, QString> attributes() const;
/**
* Checks whether this Content has an id
* @return @c true if an id has been set, @c false otherwise
*/
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,93 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "contentparser.h"
#include <QDateTime>
#include <QDebug>
using namespace Attica;
Content Content::Parser::parseXml(QXmlStreamReader &xml)
{
Content content;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
content.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("name")) {
content.setName(xml.readElementText());
} else if (xml.name() == QLatin1String("score")) {
content.setRating(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("downloads")) {
content.setDownloads(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("comments")) {
content.setNumberOfComments(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("created")) {
// Qt doesn't accept +-Timezone modifiers, truncate if the string contains them
QString dateString = xml.readElementText().left(19);
content.setCreated(QDateTime::fromString(dateString, Qt::ISODate));
} else if (xml.name() == QLatin1String("changed")) {
// Qt doesn't accept +-Timezone modifiers, truncate if the string contains them
QString dateString = xml.readElementText().left(19);
content.setUpdated(QDateTime::fromString(dateString, Qt::ISODate));
} else if (xml.name() == QLatin1String("icon")) {
Icon icon;
icon.setUrl(QUrl(xml.readElementText()));
const QXmlStreamAttributes attributes = xml.attributes();
const auto width = attributes.value(QLatin1String("width"));
if (!width.isEmpty()) {
icon.setWidth(width.toInt());
}
const auto height = attributes.value(QLatin1String("height"));
if (!height.isEmpty()) {
icon.setHeight(height.toInt());
}
// append the icon to the current list of icons
QList<Icon> icons;
icons = content.icons();
icons.append(icon);
content.setIcons(icons);
} else if (xml.name() == QLatin1String("video")) {
QUrl video(xml.readElementText());
// append the video to the current list of videos
QList<QUrl> videos;
videos = content.videos();
videos.append(video);
content.setVideos(videos);
} else if (xml.name() == QLatin1String("tags")) {
content.setTags(xml.readElementText().split(QLatin1Char(',')));
} else {
content.addAttribute(xml.name().toString(), xml.readElementText());
}
}
if (xml.isEndElement() && xml.name() == QLatin1String("content")) {
break;
}
}
// in case the server only sets creation date, use that as updated also
if (content.updated().isNull()) {
content.setUpdated(content.created());
}
return content;
}
QStringList Content::Parser::xmlElement() const
{
return QStringList(QStringLiteral("content"));
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_CONTENTPARSER_H
#define ATTICA_CONTENTPARSER_H
#include "content.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN Content::Parser : public Attica::Parser<Content>
{
private:
Content parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,33 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "deletejob.h"
#include <QNetworkAccessManager>
#include "platformdependent_v2.h"
using namespace Attica;
DeleteJob::DeleteJob(PlatformDependent *internals, const QNetworkRequest &request)
: BaseJob(internals)
, m_request(request)
{
}
QNetworkReply *DeleteJob::executeRequest()
{
Attica::PlatformDependentV2 *platformDependentV2 = dynamic_cast<Attica::PlatformDependentV2 *>(internals());
if (!platformDependentV2) {
return nullptr;
}
return platformDependentV2->deleteResource(m_request);
}
#include "moc_deletejob.cpp"
@@ -0,0 +1,39 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_DELETEJOB_H
#define ATTICA_DELETEJOB_H
#include <QNetworkRequest>
#include "attica_export.h"
#include "atticabasejob.h"
namespace Attica
{
/**
* @class DeleteJob deletejob.h <Attica/DeleteJob>
*
* Represents a delete job.
*/
class ATTICA_EXPORT DeleteJob : public Attica::BaseJob
{
Q_OBJECT
protected:
DeleteJob(PlatformDependent *internals, const QNetworkRequest &request);
private:
QNetworkReply *executeRequest() override;
const QNetworkRequest m_request;
};
}
#endif
@@ -0,0 +1,64 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "distribution.h"
using namespace Attica;
class Q_DECL_HIDDEN Distribution::Private : public QSharedData
{
public:
int id;
QString name;
Private()
: id(-1)
{
}
};
Distribution::Distribution()
: d(new Private)
{
}
Distribution::Distribution(const Attica::Distribution &other)
: d(other.d)
{
}
Distribution &Distribution::operator=(const Attica::Distribution &other)
{
d = other.d;
return *this;
}
Distribution::~Distribution()
{
}
uint Distribution::id() const
{
return d->id;
}
void Distribution::setId(uint id)
{
d->id = id;
}
QString Distribution::name() const
{
return d->name;
}
void Distribution::setName(const QString &name)
{
d->name = name;
}
@@ -0,0 +1,73 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_DISTRIBUTION_H
#define ATTICA_DISTRIBUTION_H
#include <QSharedDataPointer>
#include <QUrl>
#include "attica_export.h"
namespace Attica
{
/**
@class Distribution distribution.h <Attica/Distribution>
The Distribution class contains information about one distribution that the server offers.
It consists of an integer id and a distribution name.
*/
class ATTICA_EXPORT Distribution
{
public:
typedef QList<Distribution> List;
class Parser;
/**
* Creates an empty Distribution
*/
Distribution();
/**
* Copy constructor.
* @param other the Distribution to copy from
*/
Distribution(const Distribution &other);
/**
* Assignment operator.
* @param other the Distribution to assign from
* @return pointer to this Distribution
*/
Distribution &operator=(const Distribution &other);
/**
* Destructor.
*/
~Distribution();
/*
<id>2000</id>
<name>Ark</name>
*/
uint id() const;
void setId(uint id);
QString name() const;
void setName(const QString &name);
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,37 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "distributionparser.h"
using namespace Attica;
QStringList Distribution::Parser::xmlElement() const
{
return QStringList(QStringLiteral("distribution"));
}
Distribution Distribution::Parser::parseXml(QXmlStreamReader &xml)
{
Distribution item;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
item.setId(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("name")) {
item.setName(xml.readElementText());
}
}
if (xml.isEndElement() && xml.name() == QLatin1String("distribution")) {
break;
}
}
return item;
}
@@ -0,0 +1,27 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_DISTRIBUTION_PARSER_H
#define ATTICA_DISTRIBUTION_PARSER_H
#include "distribution.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN Distribution::Parser : public Attica::Parser<Distribution>
{
private:
Distribution parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,217 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "downloaddescription.h"
#include <QStringList>
namespace Attica
{
class Q_DECL_HIDDEN DownloadDescription::Private : public QSharedData
{
public:
int id = 0;
Attica::DownloadDescription::Type type = Attica::DownloadDescription::FileDownload;
bool hasPrice = false;
QString category;
QString name;
QString link;
QString distributionType;
QString priceReason;
QString priceAmount;
QString gpgFingerprint;
QString gpgSignature;
QString packageName;
QString repository;
uint size = 0;
QStringList tags;
QString version;
};
}
using namespace Attica;
DownloadDescription::DownloadDescription()
: d(new Private)
{
}
DownloadDescription::DownloadDescription(const Attica::DownloadDescription &other)
: d(other.d)
{
}
DownloadDescription &DownloadDescription::operator=(const Attica::DownloadDescription &other)
{
d = other.d;
return *this;
}
DownloadDescription::~DownloadDescription()
{
}
QString Attica::DownloadDescription::category() const
{
return d->category;
}
int DownloadDescription::id() const
{
return d->id;
}
void DownloadDescription::setId(int id)
{
d->id = id;
}
void DownloadDescription::setCategory(const QString &category)
{
d->category = category;
}
QString Attica::DownloadDescription::distributionType() const
{
return d->distributionType;
}
void DownloadDescription::setDistributionType(const QString &distributionType)
{
d->distributionType = distributionType;
}
bool Attica::DownloadDescription::hasPrice() const
{
return d->hasPrice;
}
void DownloadDescription::setHasPrice(bool hasPrice)
{
d->hasPrice = hasPrice;
}
Attica::DownloadDescription::Type DownloadDescription::type() const
{
return d->type;
}
void DownloadDescription::setType(Attica::DownloadDescription::Type type)
{
d->type = type;
}
QString Attica::DownloadDescription::link() const
{
return d->link;
}
void DownloadDescription::setLink(const QString &link)
{
d->link = link;
}
QString Attica::DownloadDescription::name() const
{
return d->name;
}
void DownloadDescription::setName(const QString &name)
{
d->name = name;
}
QString Attica::DownloadDescription::priceAmount() const
{
return d->priceAmount;
}
void DownloadDescription::setPriceAmount(const QString &priceAmount)
{
d->priceAmount = priceAmount;
}
QString Attica::DownloadDescription::priceReason() const
{
return d->priceReason;
}
void Attica::DownloadDescription::setPriceReason(const QString &priceReason)
{
d->priceReason = priceReason;
}
uint Attica::DownloadDescription::size() const
{
return d->size;
}
void Attica::DownloadDescription::setSize(uint size)
{
d->size = size;
}
QString Attica::DownloadDescription::gpgFingerprint() const
{
return d->gpgFingerprint;
}
void Attica::DownloadDescription::setGpgFingerprint(const QString &fingerprint)
{
d->gpgFingerprint = fingerprint;
}
QString Attica::DownloadDescription::gpgSignature() const
{
return d->gpgSignature;
}
void Attica::DownloadDescription::setGpgSignature(const QString &signature)
{
d->gpgSignature = signature;
}
QString Attica::DownloadDescription::packageName() const
{
return d->packageName;
}
void Attica::DownloadDescription::setPackageName(const QString &packageName)
{
d->packageName = packageName;
}
QString Attica::DownloadDescription::repository() const
{
return d->repository;
}
void Attica::DownloadDescription::setRepository(const QString &repository)
{
d->repository = repository;
}
QStringList Attica::DownloadDescription::tags() const
{
return d->tags;
}
void Attica::DownloadDescription::setTags(const QStringList &tags)
{
d->tags = tags;
}
QString Attica::DownloadDescription::version() const
{
return d->version;
}
void Attica::DownloadDescription::setVersion(const QString &version)
{
d->version = version;
}
@@ -0,0 +1,103 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef DOWNLOADDESCRIPTION_H
#define DOWNLOADDESCRIPTION_H
#include <QSharedData>
#include <QString>
#include "attica_export.h"
namespace Attica
{
/**
* @class DownloadDescription downloaddescription.h <Attica/DownloadDescription>
*
* Represents a download description.
*/
class ATTICA_EXPORT DownloadDescription
{
public:
enum Type {
FileDownload = 0,
LinkDownload,
PackageDownload,
};
DownloadDescription();
DownloadDescription(const DownloadDescription &other);
DownloadDescription &operator=(const DownloadDescription &other);
~DownloadDescription();
/**
The id of the description - as one Content can have multiple download descriptions associated.
This will simply be 1, 2, ...
*/
int id() const;
Attica::DownloadDescription::Type type() const;
bool hasPrice() const;
QString category() const;
QString name() const;
QString link() const;
QString distributionType() const;
QString priceReason() const;
QString priceAmount() const;
uint size() const;
QString gpgFingerprint() const;
QString gpgSignature() const;
QString packageName() const;
QString repository() const;
/**
* Get the list of tags for this download description
* @since 5.50
*/
QStringList tags() const;
void setId(int id);
void setType(Attica::DownloadDescription::Type type);
void setHasPrice(bool hasPrice);
void setCategory(const QString &category);
void setName(const QString &name);
void setLink(const QString &link);
void setDistributionType(const QString &distributionType);
void setPriceReason(const QString &priceReason);
void setPriceAmount(const QString &priceAmount);
void setSize(uint size);
void setGpgFingerprint(const QString &fingerprint);
void setGpgSignature(const QString &signature);
void setPackageName(const QString &packageName);
void setRepository(const QString &repository);
/**
* Set the list of tags for this download description
* @since 5.50
*/
void setTags(const QStringList &tags);
/**
* The download version as set on the remote. May be QString() when not set.
* @since 6.5
*/
[[nodiscard]] QString version() const;
/**
* @since 6.5
*/
void setVersion(const QString &version);
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif // DOWNLOADDESCRIPTION_H
@@ -0,0 +1,118 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "downloaditem.h"
using namespace Attica;
class Q_DECL_HIDDEN DownloadItem::Private : public QSharedData
{
public:
QUrl m_url;
QString m_mimeType;
QString m_packageName;
QString m_packageRepository;
QString m_gpgFingerprint;
QString m_gpgSignature;
Attica::DownloadDescription::Type m_type;
Private()
: m_type(DownloadDescription::FileDownload)
{
}
};
DownloadItem::DownloadItem()
: d(new Private)
{
}
DownloadItem::DownloadItem(const Attica::DownloadItem &other)
: d(other.d)
{
}
DownloadItem &DownloadItem::operator=(const Attica::DownloadItem &other)
{
d = other.d;
return *this;
}
DownloadItem::~DownloadItem()
{
}
void DownloadItem::setUrl(const QUrl &url)
{
d->m_url = url;
}
QUrl DownloadItem::url() const
{
return d->m_url;
}
void DownloadItem::setMimeType(const QString &mimeType)
{
d->m_mimeType = mimeType;
}
QString DownloadItem::mimeType() const
{
return d->m_mimeType;
}
void DownloadItem::setPackageName(const QString &packageName)
{
d->m_packageName = packageName;
}
QString DownloadItem::packageName() const
{
return d->m_packageName;
}
void DownloadItem::setPackageRepository(const QString &packageRepository)
{
d->m_packageRepository = packageRepository;
}
QString DownloadItem::packageRepository() const
{
return d->m_packageRepository;
}
void DownloadItem::setGpgFingerprint(const QString &gpgFingerprint)
{
d->m_gpgFingerprint = gpgFingerprint;
}
QString DownloadItem::gpgFingerprint() const
{
return d->m_gpgFingerprint;
}
void DownloadItem::setGpgSignature(const QString &gpgSignature)
{
d->m_gpgSignature = gpgSignature;
}
QString DownloadItem::gpgSignature() const
{
return d->m_gpgSignature;
}
void DownloadItem::setType(Attica::DownloadDescription::Type type)
{
d->m_type = type;
}
Attica::DownloadDescription::Type DownloadItem::type()
{
return d->m_type;
}
@@ -0,0 +1,77 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_DOWNLOADITEM_H
#define ATTICA_DOWNLOADITEM_H
#include <QSharedDataPointer>
#include <QUrl>
#include "attica_export.h"
#include "downloaddescription.h"
namespace Attica
{
/**
* @class DownloadItem downloaditem.h <Attica/DownloadItem>
*
* Represents a download item.
*/
class ATTICA_EXPORT DownloadItem
{
public:
typedef QList<DownloadItem> List;
class Parser;
/**
* Creates an empty DownloadItem
*/
DownloadItem();
/**
* Copy constructor.
* @param other the DownloadItem to copy from
*/
DownloadItem(const DownloadItem &other);
/**
* Assignment operator.
* @param other the DownloadItem to assign from
* @return pointer to this DownloadItem
*/
DownloadItem &operator=(const DownloadItem &other);
/**
* Destructor.
*/
~DownloadItem();
void setUrl(const QUrl &url);
QUrl url() const;
void setMimeType(const QString &mimeType);
QString mimeType() const;
void setPackageName(const QString &packageName);
QString packageName() const;
void setPackageRepository(const QString &packageRepository);
QString packageRepository() const;
void setGpgFingerprint(const QString &gpgFingerprint);
QString gpgFingerprint() const;
void setGpgSignature(const QString &gpgSignature);
QString gpgSignature() const;
void setType(Attica::DownloadDescription::Type type);
Attica::DownloadDescription::Type type();
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif // DOWNLOADITEM_H
@@ -0,0 +1,45 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "downloaditemparser.h"
#include <QXmlStreamReader>
using namespace Attica;
QStringList DownloadItem::Parser::xmlElement() const
{
return QStringList(QStringLiteral("content"));
}
DownloadItem DownloadItem::Parser::parseXml(QXmlStreamReader &xml)
{
DownloadItem item;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("downloadlink")) {
item.setUrl(QUrl(xml.readElementText()));
} else if (xml.name() == QLatin1String("mimetype")) {
item.setMimeType(xml.readElementText());
} else if (xml.name() == QLatin1String("packagename")) {
item.setPackageName(xml.readElementText());
} else if (xml.name() == QLatin1String("packagerepository")) {
item.setPackageRepository(xml.readElementText());
} else if (xml.name() == QLatin1String("gpgfingerprint")) {
item.setGpgFingerprint(xml.readElementText());
} else if (xml.name() == QLatin1String("gpgsignature")) {
item.setGpgSignature(xml.readElementText());
} else if (xml.name() == QLatin1String("downloadway")) {
item.setType(DownloadDescription::Type(xml.readElementText().toInt()));
}
}
}
return item;
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_DOWNLOADITEMPARSER_H
#define ATTICA_DOWNLOADITEMPARSER_H
#include "downloaditem.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN DownloadItem::Parser : public Attica::Parser<DownloadItem>
{
private:
DownloadItem parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,184 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Eckhart Wörner <ewoerner@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "event.h"
using namespace Attica;
class Q_DECL_HIDDEN Event::Private : public QSharedData
{
public:
QString m_id;
QString m_name;
QString m_description;
QString m_user;
QDate m_startDate;
QDate m_endDate;
qreal m_latitude;
qreal m_longitude;
QUrl m_homepage;
QString m_country;
QString m_city;
QMap<QString, QString> m_extendedAttributes;
Private()
: m_latitude(0)
, m_longitude(0)
{
}
};
Event::Event()
: d(new Private)
{
}
Event::Event(const Event &other)
: d(other.d)
{
}
Event &Event::operator=(const Event &other)
{
d = other.d;
return *this;
}
Event::~Event()
{
}
void Event::setId(const QString &id)
{
d->m_id = id;
}
QString Event::id() const
{
return d->m_id;
}
void Event::setName(const QString &name)
{
d->m_name = name;
}
QString Event::name() const
{
return d->m_name;
}
void Event::setDescription(const QString &text)
{
d->m_description = text;
}
QString Event::description() const
{
return d->m_description;
}
void Event::setUser(const QString &id)
{
d->m_user = id;
}
QString Event::user() const
{
return d->m_user;
}
void Event::setStartDate(const QDate &date)
{
d->m_startDate = date;
}
QDate Event::startDate() const
{
return d->m_startDate;
}
void Event::setEndDate(const QDate &date)
{
d->m_endDate = date;
}
QDate Event::endDate() const
{
return d->m_endDate;
}
void Event::setLatitude(qreal lat)
{
d->m_latitude = lat;
}
qreal Event::latitude() const
{
return d->m_latitude;
}
void Event::setLongitude(qreal lon)
{
d->m_longitude = lon;
}
qreal Event::longitude() const
{
return d->m_longitude;
}
void Event::setHomepage(const QUrl &url)
{
d->m_homepage = url;
}
QUrl Event::homepage() const
{
return d->m_homepage;
}
void Event::setCountry(const QString &country)
{
d->m_country = country;
}
QString Event::country() const
{
return d->m_country;
}
void Event::setCity(const QString &city)
{
d->m_city = city;
}
QString Event::city() const
{
return d->m_city;
}
void Event::addExtendedAttribute(const QString &key, const QString &value)
{
d->m_extendedAttributes.insert(key, value);
}
QString Event::extendedAttribute(const QString &key) const
{
return d->m_extendedAttributes.value(key);
}
QMap<QString, QString> Event::extendedAttributes() const
{
return d->m_extendedAttributes;
}
bool Event::isValid() const
{
return !(d->m_id.isEmpty());
}
@@ -0,0 +1,224 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Eckhart Wörner <ewoerner@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_EVENT_H
#define ATTICA_EVENT_H
#include "attica_export.h"
#include <QDate>
#include <QList>
#include <QMap>
#include <QSharedDataPointer>
#include <QUrl>
namespace Attica
{
/**
* @class Event event.h <Attica/Event>
*
* Represents a single event
*/
class ATTICA_EXPORT Event
{
public:
typedef QList<Event> List;
class Parser;
/**
* Creates an empty Event
*/
Event();
/**
* Copy constructor.
* @param other the Event to copy from
*/
Event(const Event &other);
/**
* Assignment operator.
* @param other the Event to assign from
* @return pointer to this Event
*/
Event &operator=(const Event &other);
/**
* Destructor.
*/
~Event();
/**
* Sets the id of the Event.
* The id uniquely identifies a Event with the OCS API.
* @param id the new id
*/
void setId(const QString &id);
/**
* Gets the id of the Event.
* The id uniquely identifies a Event with the OCS API.
* @return the id
*/
QString id() const;
/**
* Sets the name of the Event.
* @param name the new name
*/
void setName(const QString &name);
/**
* Gets the name of the Event.
* @return the name
*/
QString name() const;
/**
* Sets the description of the Event.
* @param description the new description
*/
void setDescription(const QString &description);
/**
* Gets the description of the Event.
* @return the description
*/
QString description() const;
/**
* Sets the id of the user bound to the Event.
* @param user the new user id
*/
void setUser(const QString &user);
/**
* Gets the id of the user bound to the Event.
* @return the user id
*/
QString user() const;
/**
* Sets the start date of the Event.
* @param startDate the start date
*/
void setStartDate(const QDate &startDate);
/**
* Gets the start date of the Event.
* @return the start date
*/
QDate startDate() const;
/**
* Sets the end date of the Event.
* @param endDate the end date
*/
void setEndDate(const QDate &endDate);
/**
* Gets the start date of the Event.
* @return the end date
*/
QDate endDate() const;
/**
* Sets the latitude of the position the Event takes place.
* @param latitude the new latitude
*/
void setLatitude(qreal latitude);
/**
* Gets the latitude of the position the Event takes place.
* @return the latitude
*/
qreal latitude() const;
/**
* Sets the longitude of the position the Event takes place.
* @param longitude the new latitude
*/
void setLongitude(qreal longitude);
/**
* Gets the longitude of the position the Event takes place.
* @return the latitude
*/
qreal longitude() const;
/**
* Sets the homepage of the Event.
* @param homepage the new homepage
*/
void setHomepage(const QUrl &homepage);
/**
* Gets the homepage of the Event.
* @return the homepage
*/
QUrl homepage() const;
/**
* Sets the country where the Event takes place.
* @param country the new country
*/
void setCountry(const QString &country);
/**
* Gets the country where the Event takes place.
* @return the country
*/
QString country() const;
/**
* Sets the city where the Event takes place.
* @param city the new city
*/
void setCity(const QString &city);
/**
* Gets the city where the Event takes place.
* @return the city
*/
QString city() const;
/**
* Add an attribute that is not included in the basis set of attributes exposed by the Event class.
* If the attribute already exists it gets overwritten.
* @param key the key of the attribute
* @param value the value of the attribute
*/
void addExtendedAttribute(const QString &key, const QString &value);
/**
* Get an attribute that is not included in the basis set of attributes exposed by the Event class.
* @param key the key of the attribute
* @return the value of the attribute with the specified key, or an empty string, if the key has not been found
*/
QString extendedAttribute(const QString &key) const;
/**
* Get all attributes that are not included in the basis set of attributes exposed by the Event class.
* @return the attribute mappings
*/
QMap<QString, QString> extendedAttributes() const;
/**
* Checks whether this Event has an id
* @return @c true if an id has been set, @c false otherwise
*/
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,61 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Eckhart Wörner <ewoerner@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "eventparser.h"
#include <QRegularExpression>
using namespace Attica;
Event Event::Parser::parseXml(QXmlStreamReader &xml)
{
Event event;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
event.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("name")) {
event.setName(xml.readElementText());
} else if (xml.name() == QLatin1String("description")) {
event.setDescription(xml.readElementText());
} else if (xml.name() == QLatin1String("user")) {
event.setUser(xml.readElementText());
} else if (xml.name() == QLatin1String("startdate")) {
QString date = xml.readElementText().remove(QRegularExpression(QStringLiteral("\\+.*$")));
event.setStartDate(QDate::fromString(date, Qt::ISODate));
} else if (xml.name() == QLatin1String("enddate")) {
QString date = xml.readElementText().remove(QRegularExpression(QStringLiteral("\\+.*$")));
event.setEndDate(QDate::fromString(date, Qt::ISODate));
} else if (xml.name() == QLatin1String("latitude")) {
event.setLatitude(xml.readElementText().toFloat());
} else if (xml.name() == QLatin1String("longitude")) {
event.setLongitude(xml.readElementText().toFloat());
} else if (xml.name() == QLatin1String("homepage")) {
event.setHomepage(QUrl(xml.readElementText()));
} else if (xml.name() == QLatin1String("country")) {
event.setCountry(xml.readElementText());
} else if (xml.name() == QLatin1String("city")) {
event.setCity(xml.readElementText());
} else {
event.addExtendedAttribute(xml.name().toString(), xml.readElementText());
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("event")) {
break;
}
}
return event;
}
QStringList Event::Parser::xmlElement() const
{
return QStringList(QStringLiteral("event"));
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Eckhart Wörner <ewoerner@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_EVENTPARSER_H
#define ATTICA_EVENTPARSER_H
#include "event.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN Event::Parser : public Attica::Parser<Event>
{
private:
Event parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,90 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "folder.h"
using namespace Attica;
class Q_DECL_HIDDEN Folder::Private : public QSharedData
{
public:
QString m_id;
QString m_name;
int m_messageCount;
QString m_type;
Private()
: m_messageCount(0)
{
}
};
Folder::Folder()
: d(new Private)
{
}
Folder::Folder(const Folder &other)
: d(other.d)
{
}
Folder &Folder::operator=(const Folder &other)
{
d = other.d;
return *this;
}
Folder::~Folder()
{
}
void Folder::setId(const QString &u)
{
d->m_id = u;
}
QString Folder::id() const
{
return d->m_id;
}
void Folder::setName(const QString &name)
{
d->m_name = name;
}
QString Folder::name() const
{
return d->m_name;
}
void Folder::setMessageCount(int c)
{
d->m_messageCount = c;
}
int Folder::messageCount() const
{
return d->m_messageCount;
}
void Folder::setType(const QString &v)
{
d->m_type = v;
}
QString Folder::type() const
{
return d->m_type;
}
bool Folder::isValid() const
{
return !(d->m_id.isEmpty());
}
@@ -0,0 +1,116 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_FOLDER_H
#define ATTICA_FOLDER_H
#include "attica_export.h"
#include <QList>
#include <QSharedDataPointer>
#include <QString>
namespace Attica
{
/**
* @class Folder folder.h <Attica/Folder>
*
* Represents a single mail folder
*/
class ATTICA_EXPORT Folder
{
public:
typedef QList<Folder> List;
class Parser;
/**
* Creates an empty Folder
*/
Folder();
/**
* Copy constructor.
* @param other the Folder to copy from
*/
Folder(const Folder &other);
/**
* Assignment operator.
* @param other the Folder to assign from
* @return pointer to this Folder
*/
Folder &operator=(const Folder &other);
/**
* Destructor.
*/
~Folder();
/**
* Sets the id of the Folder.
* The id uniquely identifies a Folder with the OCS API.
* @param id the new id
*/
void setId(const QString &id);
/**
* Gets the id of the Folder.
* The id uniquely identifies a Folder with the OCS API.
* @return the id
*/
QString id() const;
/**
* Sets the name of the Folder.
* @param name the new name
*/
void setName(const QString &name);
/**
* Gets the name of the Folder.
* @return the name
*/
QString name() const;
/**
* Sets the number of messages in the Folder.
* @param messageCount the new number of messages
*/
void setMessageCount(int messageCount);
/**
* Gets the number of messages in the Folder.
* @return the number of messages
*/
int messageCount() const;
/**
* Sets the type of the folder
* @param type the new type
*/
void setType(const QString &type);
/**
* Gets the type of the Folder.
* @return the type
*/
QString type() const;
/**
* Checks whether this Folder has an id
* @return @c true if an id has been set, @c false otherwise
*/
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,41 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "folderparser.h"
using namespace Attica;
Folder Folder::Parser::parseXml(QXmlStreamReader &xml)
{
Folder folder;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
folder.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("name")) {
folder.setName(xml.readElementText());
} else if (xml.name() == QLatin1String("messagecount")) {
folder.setMessageCount(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("type")) {
folder.setType(xml.readElementText());
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("folder")) {
break;
}
}
return folder;
}
QStringList Folder::Parser::xmlElement() const
{
return QStringList(QStringLiteral("folder"));
}
@@ -0,0 +1,26 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2008 Cornelius Schumacher <schumacher@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_FOLDERPARSER_H
#define ATTICA_FOLDERPARSER_H
#include "folder.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN Folder::Parser : public Attica::Parser<Folder>
{
private:
Folder parseXml(QXmlStreamReader &xml) override;
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,135 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "forum.h"
using namespace Attica;
class Q_DECL_HIDDEN Forum::Private : public QSharedData
{
public:
QString m_id;
QString m_name;
QString m_description;
QDateTime m_date;
QUrl m_icon;
int m_childCount;
int m_topics;
QList<Forum> m_children;
Private()
: m_childCount(0)
, m_topics(0)
{
}
};
Forum::Forum()
: d(new Private)
{
}
Forum::Forum(const Forum &other)
: d(other.d)
{
}
Forum &Forum::operator=(const Attica::Forum &other)
{
d = other.d;
return *this;
}
Forum::~Forum()
{
}
void Forum::setId(const QString &id)
{
d->m_id = id;
}
QString Forum::id() const
{
return d->m_id;
}
void Forum::setName(const QString &name)
{
d->m_name = name;
}
QString Forum::name() const
{
return d->m_name;
}
void Forum::setDescription(const QString &description)
{
d->m_description = description;
}
QString Forum::description() const
{
return d->m_description;
}
void Forum::setDate(const QDateTime &date)
{
d->m_date = date;
}
QDateTime Forum::date() const
{
return d->m_date;
}
void Forum::setIcon(const QUrl &icon)
{
d->m_icon = icon;
}
QUrl Forum::icon() const
{
return d->m_icon;
}
void Forum::setChildCount(const int childCount)
{
d->m_childCount = childCount;
}
int Forum::childCount() const
{
return d->m_childCount;
}
void Forum::setChildren(QList<Forum> children)
{
d->m_children = std::move(children); // TODO KF6 Make QList const & and remove the std::move
}
QList<Forum> Forum::children() const
{
return d->m_children;
}
void Forum::setTopics(const int topics)
{
d->m_topics = topics;
}
int Forum::topics() const
{
return d->m_topics;
}
bool Forum::isValid() const
{
return !(d->m_id.isEmpty());
}
@@ -0,0 +1,72 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_FORUM_H
#define ATTICA_FORUM_H
#include "attica_export.h"
#include "topic.h"
#include <QDateTime>
#include <QSharedDataPointer>
#include <QUrl>
namespace Attica
{
/**
* @class Forum forum.h <Attica/Forum>
*
* Represents a forum.
*/
class ATTICA_EXPORT Forum
{
public:
typedef QList<Forum> List;
class Parser;
Forum();
Forum(const Forum &other);
Forum &operator=(const Forum &other);
~Forum();
void setId(const QString &id);
QString id() const;
void setName(const QString &name);
QString name() const;
void setDescription(const QString &description);
QString description() const;
void setDate(const QDateTime &date);
QDateTime date() const;
void setIcon(const QUrl &icon);
QUrl icon() const;
void setChildCount(const int childCount);
int childCount() const;
void setTopics(const int topics);
int topics() const;
void setChildren(QList<Forum> comments);
QList<Forum> children() const;
bool isValid() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif
@@ -0,0 +1,71 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "forumparser.h"
#include "atticautils.h"
using namespace Attica;
Forum Forum::Parser::parseXml(QXmlStreamReader &xml)
{
Forum forum;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("id")) {
forum.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("name")) {
forum.setName(xml.readElementText());
} else if (xml.name() == QLatin1String("description")) {
forum.setDescription(xml.readElementText());
} else if (xml.name() == QLatin1String("date")) {
forum.setDate(Utils::parseQtDateTimeIso8601(xml.readElementText()));
} else if (xml.name() == QLatin1String("icon")) {
forum.setIcon(QUrl(xml.readElementText()));
} else if (xml.name() == QLatin1String("childcount")) {
forum.setChildCount(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("children")) {
QList<Forum> children = parseXmlChildren(xml);
forum.setChildren(children);
} else if (xml.name() == QLatin1String("topics")) {
forum.setTopics(xml.readElementText().toInt());
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("forum")) {
break;
}
}
return forum;
}
QList<Forum> Forum::Parser::parseXmlChildren(QXmlStreamReader &xml)
{
QList<Forum> children;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("forum")) {
Forum forum = parseXml(xml);
children.append(forum);
}
} else if (xml.isEndElement() && xml.name() == QLatin1String("children")) {
break;
}
}
return children;
}
QStringList Forum::Parser::xmlElement() const
{
return QStringList(QStringLiteral("forum"));
}
@@ -0,0 +1,27 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2011 Laszlo Papp <djszapi@archlinux.us>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_FORUMPARSER_H
#define ATTICA_FORUMPARSER_H
#include "forum.h"
#include "parser.h"
namespace Attica
{
class Q_DECL_HIDDEN Forum::Parser : public Attica::Parser<Forum>
{
private:
Forum parseXml(QXmlStreamReader &xml) override;
QList<Forum> parseXmlChildren(QXmlStreamReader &xml);
QStringList xmlElement() const override;
};
}
#endif
@@ -0,0 +1,29 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Eckhart Wörner <ewoerner@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "getjob.h"
#include <QNetworkAccessManager>
#include "platformdependent.h"
#include <attica_debug.h>
using namespace Attica;
GetJob::GetJob(PlatformDependent *internals, const QNetworkRequest &request)
: BaseJob(internals)
, m_request(request)
{
}
QNetworkReply *GetJob::executeRequest()
{
return internals()->get(m_request);
}
#include "moc_getjob.cpp"
@@ -0,0 +1,39 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2009 Eckhart Wörner <ewoerner@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_GETJOB_H
#define ATTICA_GETJOB_H
#include <QNetworkRequest>
#include "attica_export.h"
#include "atticabasejob.h"
namespace Attica
{
/**
* @class GetJob getjob.h <Attica/GetJob>
*
* Represents a get job.
*/
class ATTICA_EXPORT GetJob : public Attica::BaseJob
{
Q_OBJECT
protected:
GetJob(PlatformDependent *internals, const QNetworkRequest &request);
private:
QNetworkReply *executeRequest() override;
const QNetworkRequest m_request;
};
}
#endif
@@ -0,0 +1,63 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "homepageentry.h"
using namespace Attica;
class Q_DECL_HIDDEN HomePageEntry::Private : public QSharedData
{
public:
QString type;
QUrl url;
Private()
{
}
};
HomePageEntry::HomePageEntry()
: d(new Private)
{
}
HomePageEntry::HomePageEntry(const Attica::HomePageEntry &other)
: d(other.d)
{
}
HomePageEntry &HomePageEntry::operator=(const Attica::HomePageEntry &other)
{
d = other.d;
return *this;
}
HomePageEntry::~HomePageEntry()
{
}
QString HomePageEntry::type() const
{
return d->type;
}
void HomePageEntry::setType(const QString &type)
{
d->type = type;
}
QUrl HomePageEntry::url() const
{
return d->url;
}
void HomePageEntry::setUrl(const QUrl &url)
{
d->url = url;
}
@@ -0,0 +1,67 @@
/*
This file is part of KDE.
SPDX-FileCopyrightText: 2010 Intel Corporation
SPDX-FileContributor: Mateu Batle Sastre <mbatle@collabora.co.uk>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef ATTICA_HOMEPAGEENTRY_H
#define ATTICA_HOMEPAGEENTRY_H
#include <QSharedDataPointer>
#include <QUrl>
#include "attica_export.h"
namespace Attica
{
/**
@class HomePageEntry homepageentry.h <Attica/HomePageEntry>
The HomePageEntry class contains information about one home page entry.
It consists of a type and a home page url.
*/
class ATTICA_EXPORT HomePageEntry
{
public:
typedef QList<HomePageEntry> List;
/**
* Creates an empty HomePageEntry
*/
HomePageEntry();
/**
* Copy constructor.
* @param other the HomePageEntry to copy from
*/
HomePageEntry(const HomePageEntry &other);
/**
* Assignment operator.
* @param other the HomePageEntry to assign from
* @return pointer to this HomePageEntry
*/
HomePageEntry &operator=(const HomePageEntry &other);
/**
* Destructor.
*/
~HomePageEntry();
QString type() const;
void setType(const QString &type);
QUrl url() const;
void setUrl(const QUrl &url);
private:
class Private;
QSharedDataPointer<Private> d;
};
}
#endif

Some files were not shown because too many files have changed in this diff Show More