Compare commits

...

No commits in common. "2.3.0" and "master" have entirely different histories.

1569 changed files with 118467 additions and 183696 deletions

8
.clog.toml Normal file
View File

@ -0,0 +1,8 @@
[clog]
repository = "https://github.com/linuxdeepin/dde-dock"
from-latest-tag = true
changelog = "CHANGELOG.md"
[sections]
Others = ["chore", "refactor"]

15
.github/workflows/backup-to-gitlab.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: backup to gitlab
on: [push]
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
backup-to-gitlabwh:
uses: linuxdeepin/.github/.github/workflows/backup-to-gitlabwh.yml@master
secrets: inherit
backup-to-gitee:
uses: linuxdeepin/.github/.github/workflows/backup-to-gitee.yml@master
secrets: inherit

12
.github/workflows/call-api-check.yml vendored Normal file
View File

@ -0,0 +1,12 @@
name: apiCheck
on:
pull_request_target:
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
api-check:
uses: linuxdeepin/.github/.github/workflows/api-check.yml@master

16
.github/workflows/call-auto-tag.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: auto tag
on:
pull_request_target:
types: [opened, synchronize, closed]
paths:
- "debian/changelog"
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
auto_tag:
uses: linuxdeepin/.github/.github/workflows/auto-tag.yml@master
secrets: inherit

View File

@ -0,0 +1,13 @@
name: Call build-distribution
on:
push:
paths-ignore:
- ".github/workflows/**"
pull_request_target:
paths-ignore:
- ".github/workflows/**"
jobs:
check_job:
uses: linuxdeepin/.github/.github/workflows/build-distribution.yml@master
secrets: inherit

9
.github/workflows/call-chatOps.yml vendored Normal file
View File

@ -0,0 +1,9 @@
name: chatOps
on:
issue_comment:
types: [created]
jobs:
chatopt:
uses: linuxdeepin/.github/.github/workflows/chatOps.yml@master
secrets: inherit

15
.github/workflows/call-clacheck.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Call CLA check
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened, closed, synchronize]
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
clacheck:
uses: linuxdeepin/.github/.github/workflows/cla-check.yml@master
secrets: inherit

11
.github/workflows/call-commitlint.yml vendored Normal file
View File

@ -0,0 +1,11 @@
name: Call commitlint
on:
pull_request_target:
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
check_job:
uses: linuxdeepin/.github/.github/workflows/commitlint.yml@master

20
.github/workflows/call-debian-check.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: debianCheck
on:
pull_request_target:
types: [opened, synchronize, reopened]
permissions:
pull-requests: write
contents: read
checks: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
debian-check:
uses: linuxdeepin/.github/.github/workflows/debian-check.yml@master
with:
job_name: "debian-check"

View File

@ -0,0 +1,16 @@
name: Call License and README Check
on:
pull_request_target:
types: [opened, synchronize, reopened]
permissions:
pull-requests: write
contents: read
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
license-check:
uses: linuxdeepin/.github/.github/workflows/license-check.yml@master

17
.github/workflows/call-static-check.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: staticCheck
on:
pull_request_target:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: read
checks: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
static-check:
uses: linuxdeepin/.github/.github/workflows/static-check.yml@master

26
.github/workflows/cppcheck.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: cppcheck
on:
pull_request_target:
paths-ignore:
- ".github/workflows/**"
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
cppchceck:
name: cppcheck
runs-on: ubuntu-latest
steps:
- run: export
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- uses: linuxdeepin/action-cppcheck@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
pull_request_id: ${{ github.event.pull_request.number }}
allow_approve: false

77
.gitignore vendored
View File

@ -1,36 +1,41 @@
*.*.swp
Planner
Test
test-*
test_*
_*
*.*~
*.cfg
*.ini
.#*
.test
*/*.test
grub2/grub2
themes/themes
network/network
network/dev_test.go
accounts/accounts
audio/audio
datetime/datetime
deepin-daemon/deepin-daemon
desktop-toggle/desktop-toggle
display/display
dock-apps-builder/dock-apps-builder
dock-daemon/dock-daemon
inputdevices/inputdevices
keybinding/keybinding
launcher-daemon/launcher-daemon
mime/mime
mounts/mounts
power/power
system-info/system-info
zone-settings/zone-settings
bluetooth/bluetooth
main_network.go
bin/dde-session-daemon/dde-session-daemon
!launcher/testdata/.config/launcher/*
# Compiled Object files
*.slo
*.lo
*.o
# Compiled Dynamic libraries
*.so
*.dylib
# Compiled Static libraries
*.lai
*.la
*.a
build*/
obj-*-linux-gnu/
*.pro.user*
CMakeLists.txt.user*
*.DS_Store
*.qm
.directory
# binary file
dde-dock
.vscode
*/dbusinterface/generation_dbus_interface/
*/*/dbusinterface/generation_dbus_interface/
.transifexrc
.cache
# debain
debian/.debhelper/
debian/dde-dock/
debian/dde-dock-dev/
debian/dde-dock-onboard-plugin/
debian/tmp/
debian/*.log
debian/*.substvars
debian/debhelper-build-stamp
debian/files

5
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,5 @@
include:
- remote: 'https://gitlab.deepin.io/dev-tools/letmeci/raw/master/gitlab-ci/dde.yml'
variables:
CPPCHECK: "true"
CODESPELL: "true"

View File

@ -1,5 +0,0 @@
[gerrit]
host=cr.deepin.io
port=29418
project=dde-daemon
defaultbranch=master

50
.obs/workflows.yml Normal file
View File

@ -0,0 +1,50 @@
test_build:
steps:
- link_package:
source_project: deepin:Develop:dde
source_package: %{SCM_REPOSITORY_NAME}
target_project: deepin:CI
- configure_repositories:
project: deepin:CI
repositories:
- name: deepin_develop
paths:
- target_project: deepin:CI
target_repository: deepin_develop
architectures:
- x86_64
- aarch64
- name: debian
paths:
- target_project: deepin:CI
target_repository: debian_sid
architectures:
- x86_64
- name: archlinux
paths:
- target_project: deepin:CI
target_repository: archlinux
architectures:
- x86_64
filters:
event: pull_request
tag_build:
steps:
- trigger_services:
project: deepin:Unstable:dde
package: %{SCM_REPOSITORY_NAME}
filters:
event: tag_push
commit_build:
steps:
- trigger_services:
project: deepin:Develop:dde
package: %{SCM_REPOSITORY_NAME}
filters:
event: push

19
.packit.yaml Normal file
View File

@ -0,0 +1,19 @@
# See the documentation for more information:
# https://packit.dev/docs/configuration/
specfile_path: rpm/deepin-dock.spec
# add or remove files that should be synced
synced_files:
- rpm/deepin-dock.spec
- .packit.yaml
upstream_package_name: dde-dock
# downstream (Fedora) RPM package name
downstream_package_name: deepin-dock
actions:
fix-spec-file: |
bash -c "sed -i -r \"0,/Version:/ s/Version:(\s*)\S*/Version:\1${PACKIT_PROJECT_VERSION}/\" rpm/deepin-dock.spec"
post-upstream-clone: |
cp rpm/dde-dock.spec rpm/deepin-dock.spec

6
.project Normal file
View File

@ -0,0 +1,6 @@
{
"type": "homebrew" | "opensource",
"3rdparty: ["*.xml"],
"ignore": ["CHANGELOG.md", "./debian", "README.md", "./cmake", "technology-overview.md", "CMakeLists.txt", "CMakeLists.txt.user", "./plugins/plugin-guide", "./.tx", "*.qrc", "*.svg", "*.png", "*.qm", "*.ts"],
"license": ["LICENSE"]
}

70
.reuse/dep5 Normal file
View File

@ -0,0 +1,70 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: dde-dock
Upstream-Contact: UnionTech Software Technology Co., Ltd. <>
Source: https://github.com/linuxdeepin/dde-dock
# ci
Files: .github/* .gitlab-ci.yml .obs/*
Copyright: None
License: CC0-1.0
# Packaging configuration
Files: rpm/* debian/* archlinux/*
Copyright: None
License: CC0-1.0
# README & DOC
Files: README.md README.zh_CN.md CHANGELOG.md doc/* technology-overview.md plugins/plugin-guide/plugins-developer-guide.md
Copyright: UnionTech Software Technology Co., Ltd.
License: CC-BY-4.0
# translation
Files: translations/* plugins/*.ts
Copyright: UnionTech Software Technology Co., Ltd.
License: LGPL-3.0-or-later
# png svg
Files: plugins/*.png plugins/*.svg frame/*.svg tests/*.png tests/*.svg plugins/*.dci
Copyright: UnionTech Software Technology Co., Ltd.
License: LGPL-3.0-or-later
# qrc
Files: plugins/*.qrc frame/*.qrc tests/*.qrc
Copyright: None
License: CC0-1.0
# Project file
Files: frame/*CMakeLists.txt plugins/*CMakeLists.txt CMakeLists.txt .project tests/CMakeLists.txt .gitignore tests/cmake/modules/FindGMock.cmake
Copyright: None
License: CC0-1.0
# xml toml json policy yaml
Files: gschema/*.xml plugins/*.xml frame/*.xml .clog.toml plugins/*.json configs/*.json .packit.yaml .tx/config .tx/deepin.conf plugins/overlay-warning/com.deepin.dde.dock.overlay.policy plugins/dcc-dock-plugin/.tx/config
frame/taskmanager/window_patterns.json
Copyright: None
License: CC0-1.0
# in
Files: cmake/DdeDock/DdeDockConfig.cmake.in dde-dock.pc.in frame/environments.h.in
Copyright: None
License: CC0-1.0
# sh
Files: gen_report.sh lupdate.sh plugins/dcc-dock-plugin/translate_generation.sh tests/test-recoverage.sh translate_generation.sh
Copyright: None
License: CC0-1.0
# xml2cpp
Files: frame/dbus/* plugins/disk-mount/dbus/dbusdiskmount.* plugins/power/dbus/dbuspower.* plugins/shutdown/dbus/dbuspowermanager.* plugins/tray/dbus/dbustraymanager.*
Copyright: The Qt Company Ltd.
License: CC0-1.0
# policy kit
Files: plugins/overlay-warning/org.deepin.dde.dock.overlay.policy
Copyright: UnionTech Software Technology Co., Ltd.
License: LGPL-3.0-or-later
Files: toolGenerate/**/*
Copyright: None
License: CC0-1.0

View File

@ -1,11 +1,10 @@
[main]
host = https://www.transifex.com
minimum_perc = 80
mode = developer
[dde-daemon.dde-daemon-20140620]
file_filter = misc/po/<lang>.po
source_file = misc/po/dde-daemon.pot
[o:linuxdeepin:p:deepin-desktop-environment:r:dde-dock]
file_filter = translations/dde-dock_<lang>.ts
minimum_perc = 0
source_file = translations/dde-dock.ts
source_lang = en
type = PO
type = QT

2
.tx/deepin.conf Normal file
View File

@ -0,0 +1,2 @@
[transifex]
branch = m23

1140
CHANGELOG.md Normal file

File diff suppressed because it is too large Load Diff

168
CMakeLists.txt Normal file
View File

@ -0,0 +1,168 @@
cmake_minimum_required(VERSION 3.16)
if (NOT DEFINED VERSION)
set(VERSION 6.0.37)
endif()
project(dde-dock)
find_package(DtkTools REQUIRED)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_PTHREADS_INIT 1)
set(CMAKE_PREFER_PTHREAD_FLAG ON)
#set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_FLAGS "-g -Wall")
#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all")
set(CMAKE_EXE_LINKER_FLAGS "-z relro -z now -z noexecstack -pie")
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -fPIE")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
# generate a compile commands file as complete database for vim-YouCompleteMe or some other similar tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Install settings
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif ()
include(GNUInstallDirs)
if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")
# generate qm
execute_process(COMMAND bash "translate_generation.sh"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif ()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_DEBUG")
# Test architecture
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "sw_64")
# add compiler flags -mieee for mathmatic
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mieee")
add_definitions(-DDISABLE_SHOW_ANIMATION)
endif()
function(generation_dbus_interface xmldir outdir)
IF(EXISTS ${outdir})
file(REMOVE_RECURSE ${outdir})
ENDIF()
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${outdir})
file(GLOB_RECURSE allXmls ${xmldir}/*.xml)
foreach(XMLFILE ${allXmls})
string(FIND ${XMLFILE} "/" INDEX REVERSE)
string(SUBSTRING ${XMLFILE} ${INDEX} -1 classname)
string(REPLACE "/" "" classname ${classname})
string(REPLACE ".xml" "" classname ${classname})
string(REPLACE "." "_" classname ${classname})
string(TOLOWER ${classname} filename)
execute_process(COMMAND ${DTK_XML2CPP} -c ${classname} -p ${outdir}/${filename} ${XMLFILE}
WORKING_DIRECTORY ${outdir})
endforeach()
endfunction(generation_dbus_interface)
file(GLOB INTERFACES "interfaces/*.h")
add_definitions(-DCVERSION="${VERSION}")
#include使
#CMakeListsCMakeLists
#
include_directories(
frame/accessible
frame/controller
frame/dbus
frame/dbus/sni
frame/display
frame/item
frame/item/components
frame/item/resources
frame/model
frame/util
frame/window
frame/window/components
frame/window/tray
frame/window/tray/widgets
frame/xcb
../widgets
../interfaces
)
aux_source_directory(frame/accessible ACCESSIBLE)
aux_source_directory(frame/controller CONTROLLER)
aux_source_directory(frame/dbus DBUS)
aux_source_directory(frame/dbus/sni SNI)
aux_source_directory(frame/display DISPLAY)
aux_source_directory(frame/item ITEM)
aux_source_directory(frame/model MODEL)
aux_source_directory(frame/item/components ITEMCOMPONENTS)
aux_source_directory(frame/item/resources RESOURCES)
aux_source_directory(frame/util UTIL)
aux_source_directory(frame/window WINDOW)
aux_source_directory(frame/window/components WINDOWCOMPONENTS)
aux_source_directory(frame/window/tray WINDOWTRAY)
aux_source_directory(frame/window/tray/widgets WINDOWTRAYWIDGET)
aux_source_directory(frame/xcb XCB)
file(GLOB SRC_PATH
${ACCESSIBLE}
${CONTROLLER}
${DBUS}
${SNI}
${DISPLAY}
${ITEM}
${MODEL}
${ITEMCOMPONENTS}
${UTIL}
${WINDOW}
${WINDOWCOMPONENTS}
${WINDOWTRAY}
${WINDOWTRAYWIDGET}
${XCB}
)
add_subdirectory("frame")
add_subdirectory("plugins")
#add_subdirectory("tests")
## qm files
file(GLOB QM_FILES "translations/*.qm")
install(FILES ${QM_FILES}
DESTINATION share/dde-dock/translations)
## dev files
install(FILES ${INTERFACES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dde-dock)
configure_file(dde-dock.pc.in dde-dock.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/dde-dock.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
configure_file(
${CMAKE_SOURCE_DIR}/cmake/DdeDock/DdeDockConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/DdeDockConfig.cmake
@ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/DdeDockConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/DdeDock)
install(FILES gschema/com.deepin.dde.dock.module.gschema.xml
DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)
#dconfig
file(GLOB DCONFIG_FILES "configs/*.json")
install(FILES ${DCONFIG_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/dsg/configs/dde-dock/)
# Address Sanitizer ,
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address -O2")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -O2")

674
COPYING
View File

@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state 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 program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

165
LICENSE Normal file
View File

@ -0,0 +1,165 @@
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.

156
LICENSES/CC-BY-4.0.txt Normal file
View File

@ -0,0 +1,156 @@
Creative Commons Attribution 4.0 International
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensors permission is not necessary for any reasonfor example, because of any applicable exception or limitation to copyrightthen that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
Section 1 Definitions.
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
A. reproduce and Share the Licensed Material, in whole or in part; and
B. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
3. Term. The term of this Public License is specified in Section 6(a).
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
5. Downstream recipients.
A. Offer from the Licensor Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this Public License.
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
Section 3 License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified form), You must:
A. retain the following if it is supplied by the Licensor with the Licensed Material:
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of warranties;
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
Section 4 Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
Section 5 Disclaimer of Warranties and Limitation of Liability.
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Section 6 Term and Termination.
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
2. upon express reinstatement by the Licensor.
c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 Interpretation.
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
Creative Commons may be contacted at creativecommons.org.

121
LICENSES/CC0-1.0.txt Normal file
View File

@ -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.

View File

@ -0,0 +1,232 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 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.
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
“This License” refers to version 3 of the GNU General Public License.
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
A “covered work” means either the unmodified Program or a work based on the Program.
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU 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 Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state 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 program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
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.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -0,0 +1,304 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://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.
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
“This License” refers to version 3 of the GNU General Public License.
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
A “covered work” means either the unmodified Program or a work based on the Program.
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU 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 Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state 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 program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
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.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -1,90 +0,0 @@
PREFIX = /usr
GOPATH_DIR = gopath
GOPKG_PREFIX = pkg.linuxdeepin.com/dde-daemon
ifndef USE_GCCGO
GOBUILD = go build
else
LDFLAGS = $(shell pkg-config --libs gio-2.0 x11 xi xtst xcursor xfixes libpulse libudev gdk-3.0 gdk-pixbuf-xlib-2.0 gtk+-3.0 sqlite3 fontconfig)
GOBUILD = go build -compiler gccgo -gccgoflags "${LDFLAGS}"
endif
BINARIES = \
backlight_helper \
dde-session-daemon \
dde-system-daemon \
desktop-toggle \
grub2 \
grub2ext \
gtk-thumb-tool \
search \
theme-thumb-tool \
langselector
LANGUAGES = $(basename $(notdir $(wildcard misc/po/*.po)))
all: build
prepare:
@if [ ! -d ${GOPATH_DIR}/src/${GOPKG_PREFIX} ]; then \
mkdir -p ${GOPATH_DIR}/src/$(dir ${GOPKG_PREFIX}); \
ln -sf ../../.. ${GOPATH_DIR}/src/${GOPKG_PREFIX}; \
fi
out/bin/%:
env GOPATH="${GOPATH}:${CURDIR}/${GOPATH_DIR}" ${GOBUILD} -o $@ ${GOPKG_PREFIX}/bin/${@F}
ifdef USE_GCCGO
out/bin/gtk-thumb-tool:
env GOPATH="${GOPATH}:${CURDIR}/${GOPATH_DIR}" \
go build -compiler gccgo -gccgoflags \
"$(shell pkg-config --libs gtk+-2.0 libmetacity-private)" \
-o $@ ${GOPKG_PREFIX}/bin/${@F}
endif
out/locale/%/LC_MESSAGES/dde-daemon.mo:misc/po/%.po
mkdir -p $(@D)
msgfmt -o $@ $<
translate: $(addsuffix /LC_MESSAGES/dde-daemon.mo, $(addprefix out/locale/, ${LANGUAGES}))
build: prepare $(addprefix out/bin/, ${BINARIES})
test: prepare
env GOPATH="${GOPATH}:${CURDIR}/${GOPATH_DIR}" go test -v ./...
install: build translate
mkdir -pv ${DESTDIR}${PREFIX}/lib/deepin-daemon
cp out/bin/* ${DESTDIR}${PREFIX}/lib/deepin-daemon/
mkdir -pv ${DESTDIR}${PREFIX}/share/locale
cp -r out/locale/* ${DESTDIR}${PREFIX}/share/locale
mkdir -pv ${DESTDIR}/etc/dbus-1/system.d
cp misc/conf/*.conf ${DESTDIR}/etc/dbus-1/system.d/
mkdir -pv ${DESTDIR}${PREFIX}/share/dbus-1
cp -r misc/services ${DESTDIR}${PREFIX}/share/dbus-1/
cp -r misc/system-services ${DESTDIR}${PREFIX}/share/dbus-1/
mkdir -pv ${DESTDIR}${PREFIX}/share/polkit-1/actions
cp misc/polkit-action/* ${DESTDIR}${PREFIX}/share/polkit-1/actions/
mkdir -pv ${DESTDIR}${PREFIX}/share/glib-2.0/schemas
cp misc/schemas/* ${DESTDIR}${PREFIX}/share/glib-2.0/schemas
mkdir -pv ${DESTDIR}${PREFIX}/share/dde-daemon
cp -r misc/usr/share/dde-daemon/* ${DESTDIR}${PREFIX}/share/dde-daemon/
mkdir -pv ${DESTDIR}${PREFIX}/bin
cp misc/tool/wireless_script*.sh ${DESTDIR}${PREFIX}/bin/wireless-script
mkdir -pv ${DESTDIR}${PREFIX}/share/personalization/thumbnail
cp -r misc/thumbnail/* ${DESTDIR}${PREFIX}/share/personalization/thumbnail/
clean:
rm -rf ${GOPATH_DIR}
rm -rf out/bin
rm -rf out/locale
rebuild: clean build

View File

@ -1,2 +1,51 @@
depends go-dlib dde-go-dbus-factory.
Used by deepin-system-settings-2014
# DDE Dock
DDE Dock is the dock of Deepin Desktop Environment.
A tutorial for build dde-dock plugin: [plugins-developer-guide](plugins/plugin-guide/plugins-developer-guide.md)
### Dependencies
You can also check the "Depends" provided in the `debian/control` file.
### Build dependencies
You can also check the "Build-Depends" provided in the `debian/control` file.
## Installation
### Build from source code
1. Make sure you have installed all dependencies.
2. Build:
```
$ cd dde-dock
$ mkdir Build
$ cd Build
$ cmake ..
$ make
```
3. Install:
```
$ sudo make install
```
## Getting help
* [Matrix](https://matrix.to/#/#deepin-community:matrix.org)
* [WiKi](https://wiki.deepin.org)
* [Forum](https://bbs.deepin.org)
* [Developer Center](https://github.com/linuxdeepin/developer-center/issues)
## Getting involved
We encourage you to report issues and contribute changes
* [Contribution guide for developers](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers-en). (English)
* [开发者代码贡献指南](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers) (中文)
## License
dde-dock is licensed under [LGPL-3.0-or-later](LICENSE).

51
README.zh_CN.md Normal file
View File

@ -0,0 +1,51 @@
# DDE Dock
DDE Dock是深度桌面环境的任务栏组件。
构建 dde-dock 插件的教程:[plugins-developer-guide](plugins/plugin-guide/plugins-developer-guide.md)
### 依赖
请查看“debian/control”文件中提供的“Depends”。
### 编译依赖
请查看“debian/control”文件中提供的“Build-Depends”。
## 安装
### 构建过程
1. 确保已经安装了所有的编译依赖
2. 构建
```
$ cd dde-dock
$ mkdir Build
$ cd Build
$ cmake ..
$ make
```
3. 安装
```
$ sudo make install
```
## 帮助
* [Matrix](https://matrix.to/#/#deepin-community:matrix.org)
* [WiKi](https://wiki.deepin.org)
* [官方论坛](https://bbs.deepin.org)
* [开发者中心](https://github.com/linuxdeepin/developer-center/issues)
## 贡献指南
我们鼓励您报告问题并做出更改
* [Contribution guide for developers](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers-en). (English)
* [开发者代码贡献指南](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers) (中文)
## 开源许可证
dde-dock在 [LGPL-3.0-or-later](LICENSE)下发布。

View File

@ -1,236 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
import (
"fmt"
. "pkg.linuxdeepin.com/dde-daemon/accounts/username_checker"
"pkg.linuxdeepin.com/lib/dbus"
dutils "pkg.linuxdeepin.com/lib/utils"
"strings"
)
const newUserConfigFile = "/etc/adduser.conf"
func (obj *Manager) CreateGuestAccount() string {
args := []string{}
shell, err := getNewUserDefaultShell(newUserConfigFile)
if err != nil {
logger.Debug(err)
}
username := getGuestName()
passwd := encodePasswd("")
args = append(args, "-m")
if len(shell) != 0 {
args = append(args, "-s")
args = append(args, shell)
}
args = append(args, "-d")
args = append(args, "/tmp/"+username)
args = append(args, "-l")
args = append(args, "-p")
args = append(args, passwd)
args = append(args, username)
if !execCommand(CMD_USERADD, args) {
return ""
}
info, _ := getUserInfoByName(username)
return info.Path
}
func (obj *Manager) AllowGuestAccount(dbusMsg dbus.DMessage, allow bool) bool {
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
if ok := dutils.WriteKeyToKeyFile(ACCOUNT_CONFIG_FILE,
ACCOUNT_GROUP_KEY, ACCOUNT_KEY_GUEST, allow); !ok {
logger.Error("AllowGuest Failed")
return false
}
return true
}
func (obj *Manager) CreateUser(dbusMsg dbus.DMessage, name, fullname string, accountTyte int32) error {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In CreateUser:%v",
err)
}
}()
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return fmt.Errorf("Authentication failed")
}
go func() {
args := []string{}
shell, err := getNewUserDefaultShell(newUserConfigFile)
if err != nil {
logger.Debug(err)
}
args = append(args, "-m")
if len(shell) != 0 {
args = append(args, "-s")
args = append(args, shell)
}
args = append(args, "-c")
args = append(args, fullname)
args = append(args, name)
if !execCommand(CMD_USERADD, args) {
return
}
info, _ := getUserInfoByName(name)
u, ok := obj.pathUserMap[info.Path]
if ok {
u.setAccountType(accountTyte)
}
changeFileOwner(name, name, "/home/"+name)
}()
return nil
}
func (obj *Manager) DeleteUser(dbusMsg dbus.DMessage, name string, removeFiles bool) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In DeleteUser:%v",
err)
}
}()
//if ok := opUtils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
args := []string{}
user, ok := obj.pathUserMap[obj.FindUserByName(name)]
if ok {
if user.AutomaticLogin {
user.SetAutomaticLogin(dbusMsg, false)
}
}
if removeFiles {
args = append(args, "-r")
}
args = append(args, "-f")
args = append(args, name)
if !execCommand("/bin/rm", []string{"-rf", "/etc/subuid"}) {
return false
}
if !execCommand(CMD_USERDEL, args) {
return false
}
if removeFiles {
obj.rmAllIconFileByName(name)
}
return true
}
func (obj *Manager) FindUserById(id string) string {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In FindUserById:%v",
err)
}
}()
path := USER_MANAGER_PATH + id
for _, v := range obj.UserList {
if path == v {
return path
}
}
return ""
}
func (obj *Manager) FindUserByName(name string) string {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In FindUserByName:%v", err)
}
}()
if info, ok := getUserInfoByName(name); ok {
return info.Path
}
return ""
}
func (obj *Manager) RandUserIcon() (string, bool) {
if icon := getRandUserIcon(); len(icon) > 0 {
return icon, true
}
return "", false
}
func (m *Manager) IsUsernameValid(username string) (bool, string, int32) {
err := CheckUsernameValid(username)
if err != nil {
return false, err.Message.Error(), err.Code
}
return true, "", -1
}
func (m *Manager) IsPasswordValid(passwd string) bool {
return true
}
func (m *Manager) rmAllIconFileByName(username string) {
if len(username) < 1 {
return
}
list := []string{}
localList := getIconList(ICON_LOCAL_DIR)
for _, l := range localList {
if strings.Contains(l, username+"-") {
list = append(list, l)
}
}
for _, v := range list {
rmAllFile(v)
}
}

View File

@ -1,144 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
import (
"fmt"
"pkg.linuxdeepin.com/lib/dbus"
)
func (obj *Manager) GetDBusInfo() dbus.DBusInfo {
return dbus.DBusInfo{
Dest: ACCOUNT_DEST,
ObjectPath: ACCOUNT_MANAGER_PATH,
Interface: ACCOUNT_MANAGER_IFC,
}
}
func (obj *Manager) setPropUserList(list []string) {
if !isStrListEqual(obj.UserList, list) {
obj.UserList = list
dbus.NotifyChange(obj, "UserList")
}
}
func (obj *Manager) setPropAllowGuest(isAllow bool) {
if obj.AllowGuest != isAllow {
obj.AllowGuest = isAllow
dbus.NotifyChange(obj, "AllowGuest")
}
}
func (m *Manager) setPropGuestIcon(icon string) {
if m.GuestIcon != icon {
m.GuestIcon = icon
dbus.NotifyChange(m, "GuestIcon")
}
}
func (obj *Manager) newUserByPath(path string) error {
if len(path) == 0 {
return fmt.Errorf("Invalid ObjectPath")
}
u := newUser(path)
if u == nil {
return fmt.Errorf("Create User Object Failed")
}
if err := dbus.InstallOnSystem(u); err != nil {
return fmt.Errorf("Install DBus For %s Failed: %v", path, err)
}
u.setProps()
obj.pathUserMap[path] = u
return nil
}
func (m *Manager) destroyUser(path string) {
u, ok := m.pathUserMap[path]
if !ok {
return
}
if u.watcher != nil {
u.quitFlag <- true
u.watcher.Close()
}
dbus.UnInstallObject(u)
u = nil
delete(m.pathUserMap, path)
}
func (m *Manager) destroyAllUser() {
for _, path := range m.UserList {
m.destroyUser(path)
}
m.pathUserMap = make(map[string]*User)
}
func (obj *Manager) updateAllUserInfo() {
obj.destroyAllUser()
for _, path := range obj.UserList {
err := obj.newUserByPath(path)
if err != nil {
logger.Error(err)
}
}
}
func (m *Manager) handleuserAdded(list []string) {
for _, path := range list {
err := m.newUserByPath(path)
if err != nil {
logger.Error(err)
continue
}
dbus.Emit(m, "UserAdded", path)
}
m.setPropUserList(getUserList())
}
func (m *Manager) handleUserRemoved(list []string) {
for _, path := range list {
m.destroyUser(path)
dbus.Emit(m, "UserDeleted", path)
}
m.setPropUserList(getUserList())
}
func (obj *Manager) destroy() {
if obj.listWatcher != nil {
obj.listQuit <- true
obj.listWatcher.Close()
}
if obj.infoWatcher != nil {
obj.infoQuit <- true
obj.infoWatcher.Close()
}
obj.destroyAllUser()
}

View File

@ -1,263 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
import (
"bufio"
"github.com/howeyc/fsnotify"
"io/ioutil"
"os"
dutils "pkg.linuxdeepin.com/lib/utils"
"regexp"
"strconv"
"strings"
)
type Manager struct {
UserList []string
AllowGuest bool
GuestIcon string
pathUserMap map[string]*User
listWatcher *fsnotify.Watcher
infoWatcher *fsnotify.Watcher
listQuit chan bool
infoQuit chan bool
UserAdded func(string)
UserDeleted func(string)
Error func(string)
}
var _manager *Manager
func GetManager() *Manager {
if _manager == nil {
_manager = newManager()
}
return _manager
}
func newManager() *Manager {
obj := &Manager{}
obj.pathUserMap = make(map[string]*User)
obj.setPropUserList(getUserList())
obj.setPropAllowGuest(isAllowGuest())
obj.setPropGuestIcon(GUEST_USER_ICON)
var err error
obj.listWatcher, err = fsnotify.NewWatcher()
if err != nil {
logger.Error("New User List Watcher Failed:", err)
}
obj.infoWatcher, err = fsnotify.NewWatcher()
if err != nil {
logger.Error("New User Info Watcher Failed:", err)
}
if obj.listWatcher != nil {
obj.listQuit = make(chan bool)
obj.watchUserListFile()
go obj.handleUserListChanged()
}
if obj.infoWatcher != nil {
obj.infoQuit = make(chan bool)
obj.watchUserInfoFile()
go obj.handleUserInfoChanged()
}
return obj
}
func getUserInfoList() []UserInfo {
contents, err := ioutil.ReadFile(ETC_PASSWD)
if err != nil {
logger.Errorf("ReadFile '%s' failed: %s", ETC_PASSWD, err)
return nil
}
infos := []UserInfo{}
lines := strings.Split(string(contents), "\n")
for _, line := range lines {
strs := strings.Split(line, ":")
/* len of each line in /etc/passwd by spliting ':' is 7 */
if len(strs) != PASSWD_SPLIT_LEN {
continue
}
info := newUserInfo(strs[0], strs[2], strs[3],
strs[5], strs[6])
if checkUserIsHuman(&info) {
infos = append(infos, info)
}
}
return infos
}
func newUserInfo(name, uid, gid, home, shell string) UserInfo {
info := UserInfo{}
info.Name = name
info.Uid = uid
info.Gid = gid
info.Home = home
info.Shell = shell
info.Path = USER_MANAGER_PATH + uid
return info
}
func checkUserIsHuman(info *UserInfo) bool {
if info.Name == "root" {
return false
}
shells := strings.Split(info.Shell, "/")
tmpShell := shells[len(shells)-1]
if SHELL_END_FALSE == tmpShell ||
SHELL_END_NOLOGIN == tmpShell {
return false
}
if !detectedViaShadowFile(info) {
id, _ := strconv.ParseInt(info.Uid, 10, 64)
if id < 1000 {
return false
}
}
return true
}
func detectedViaShadowFile(info *UserInfo) bool {
contents, err := ioutil.ReadFile(ETC_SHADOW)
if err != nil {
logger.Errorf("ReadFile '%s' failed: %s", ETC_SHADOW, err)
return false
}
isHuman := false
info.Locked = false
lines := strings.Split(string(contents), "\n")
for _, line := range lines {
strs := strings.Split(line, ":")
if len(strs) != SHADOW_SPLIT_LEN {
continue
}
if strs[0] != info.Name {
continue
}
pw := strs[1]
if pw[0] == '*' {
break
}
if pw[0] == '!' {
info.Locked = true
}
//加盐密码最短为13
if len(pw) < 13 {
break
}
isHuman = true
}
return isHuman
}
func getUserList() []string {
infos := getUserInfoList()
list := []string{}
for _, info := range infos {
list = append(list, info.Path)
}
return list
}
func isAllowGuest() bool {
if v, ok := dutils.ReadKeyFromKeyFile(ACCOUNT_CONFIG_FILE,
ACCOUNT_GROUP_KEY, ACCOUNT_KEY_GUEST, true); !ok {
dutils.WriteKeyToKeyFile(ACCOUNT_CONFIG_FILE,
ACCOUNT_GROUP_KEY, ACCOUNT_KEY_GUEST, false)
return false
} else {
if ret, ok := v.(bool); ok {
return ret
}
}
return false
}
func getUserInfoByPath(path string) (UserInfo, bool) {
for _, info := range getUserInfoList() {
if path == info.Path {
return info, true
}
}
return UserInfo{}, false
}
func getUserInfoByName(name string) (UserInfo, bool) {
for _, info := range getUserInfoList() {
if name == info.Name {
return info, true
}
}
return UserInfo{}, false
}
func getNewUserDefaultShell(filename string) (string, error) {
fp, err := os.Open(filename)
if err != nil {
return "", err
}
var shell string
match := regexp.MustCompile(`^DSHELL=(.*)`)
scanner := bufio.NewScanner(fp)
for scanner.Scan() {
line := scanner.Text()
fields := match.FindStringSubmatch(line)
if len(fields) > 1 {
shell = fields[1]
break
}
}
fp.Close()
return shell, nil
}

View File

@ -1,51 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
import (
C "launchpad.net/gocheck"
"testing"
)
type testWrap struct{}
func Test(t *testing.T) {
C.TestingT(t)
}
func init() {
C.Suite(&testWrap{})
}
func (*testWrap) TestNewUserShell(c *C.C) {
shell, err := getNewUserDefaultShell("testdata/adduser.conf")
c.Check(err, C.Not(C.NotNil))
c.Check(shell, C.Equals, "/bin/zsh")
shell, err = getNewUserDefaultShell("testdata/adduser1.conf")
c.Check(err, C.Not(C.NotNil))
c.Check(shell, C.Equals, "")
shell, err = getNewUserDefaultShell("testdata/xxxxxxx")
c.Check(err, C.NotNil)
c.Check(shell, C.Equals, "")
}

View File

@ -1,297 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
// #cgo CFLAGS: -Wall -g
// #cgo LDFLAGS: -lcrypt
// #include <stdlib.h>
// #include "mkpasswd.h"
import "C"
import (
libpolkit1 "dbus/org/freedesktop/policykit1"
"errors"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"pkg.linuxdeepin.com/lib/dbus"
dutils "pkg.linuxdeepin.com/lib/utils"
"strings"
"sync"
"time"
"unsafe"
)
const (
POLKIT_DEST = "org.freedesktop.PolicyKit1"
POLKIT_PATH = "/org/freedesktop/PolicyKit1/Authority"
POLKIT_IFC = "org.freedesktop.PolicyKit1.Authority"
)
func getGuestName() string {
seedStr := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
l := len(seedStr)
name := "guest-"
for i := 0; i < 6; i++ {
rand.Seed(time.Now().Unix() * int64((i+2)*(i+3)))
index := rand.Intn(l)
name += string(seedStr[index])
}
return name
}
func execCommand(cmd string, args []string) bool {
if out, err := exec.Command(cmd, args...).CombinedOutput(); err != nil {
dbus.Emit(GetManager(), "Error", string(out))
logger.Warningf("Exec '%s %v' failed: %v", cmd, args, err)
return false
}
return true
}
func strIsInList(str string, list []string) bool {
for _, v := range list {
if str == v {
return true
}
}
return false
}
func isStrListEqual(list1, list2 []string) bool {
l1 := len(list1)
l2 := len(list2)
if l1 != l2 {
return false
}
for i := 0; i < l1; i++ {
if list1[i] != list2[i] {
return false
}
}
return true
}
func deleteStrFromList(ele string, list []string) []string {
tmp := []string{}
for _, l := range list {
if ele == l {
continue
}
tmp = append(tmp, l)
}
return tmp
}
func compareStrList(list1, list2 []string) ([]string, int) {
if isStrListEqual(list1, list2) {
return nil, 0
}
l1 := len(list1)
l2 := len(list2)
tmp := []string{}
if l1 < l2 {
for i := 0; i < l2; i++ {
j := 0
for ; j < l1; j++ {
if list1[j] == list2[i] {
break
}
}
if j == l1 {
tmp = append(tmp, list2[i])
}
}
return tmp, 1
}
if l1 > l2 {
for i := 0; i < l1; i++ {
j := 0
for ; j < l2; j++ {
if list1[i] == list2[j] {
break
}
}
if j == l2 {
tmp = append(tmp, list1[i])
}
}
return tmp, -1
}
return tmp, 0
}
func changeFileOwner(user, group, dir string) {
args := []string{}
args = append(args, "-R")
args = append(args, user+":"+group)
args = append(args, dir)
go execCommand(CMD_CHOWN, args)
}
func encodePasswd(words string) string {
str := C.CString(words)
defer C.free(unsafe.Pointer(str))
ret := C.mkpasswd(str)
return C.GoString(ret)
}
func changePasswd(username, password string) {
data, err := ioutil.ReadFile(ETC_SHADOW)
if err != nil {
return
}
lines := strings.Split(string(data), "\n")
index := 0
line := ""
okFlag := false
for index, line = range lines {
strs := strings.Split(line, ":")
if strs[0] == username {
if strs[1] == password {
break
}
strs[1] = password
l := len(strs)
line = ""
for i, s := range strs {
if i == l-1 {
line += s
continue
}
line += s + ":"
}
okFlag = true
break
}
}
if okFlag {
okFlag = false
contents := ""
l := len(lines)
for i, tmp := range lines {
if i == index {
contents += line
} else {
contents += tmp
}
if i < l-1 {
contents += "\n"
}
}
f, err := os.Create(ETC_SHADOW_BAK)
if err != nil {
logger.Errorf("Create '%s' failed: %v\n",
ETC_SHADOW_BAK, err)
panic(err)
}
defer f.Close()
var mutex sync.Mutex
mutex.Lock()
_, err = f.WriteString(contents)
if err != nil {
logger.Errorf("WriteString '%s' failed: %v\n",
ETC_SHADOW_BAK, err)
panic(err)
}
f.Sync()
os.Rename(ETC_SHADOW_BAK, ETC_SHADOW)
os.Chmod(ETC_SHADOW, 0600)
mutex.Unlock()
}
}
type polkitSubject struct {
/*
* The following kinds of subjects are known:
* Unix Process: should be set to unix-process with keys
* pid (of type uint32) and
* start-time (of type uint64)
* Unix Session: should be set to unix-session with the key
* session-id (of type string)
* System Bus Name: should be set to system-bus-name with the key
* name (of type string)
*/
SubjectKind string
SubjectDetails map[string]dbus.Variant
}
func polkitAuthWithPid(actionId string, pid uint32) bool {
objPolkit, err := libpolkit1.NewAuthority("org.freedesktop.PolicyKit1",
"/org/freedesktop/PolicyKit1/Authority")
if err != nil {
logger.Error("New PolicyKit Object Failed: ", err)
return false
}
subject := polkitSubject{}
subject.SubjectKind = "unix-process"
subject.SubjectDetails = make(map[string]dbus.Variant)
subject.SubjectDetails["pid"] = dbus.MakeVariant(uint32(pid))
subject.SubjectDetails["start-time"] = dbus.MakeVariant(uint64(0))
details := make(map[string]string)
details[""] = ""
flags := uint32(1)
cancelId := ""
ret, err1 := objPolkit.CheckAuthorization(subject, actionId, details,
flags, cancelId)
if err1 != nil {
logger.Error("CheckAuthorization Failed: ", err1)
return false
}
// Is Authority
if !ret[0].(bool) {
return false
}
return true
}
func rmAllFile(filename string) error {
if !dutils.IsFileExist(filename) {
return errors.New("File not exist")
}
return os.RemoveAll(filename)
}

View File

@ -1,102 +0,0 @@
/**
* Copyright (c) 2011 ~ 2013 Deepin, Inc.
* 2011 ~ 2013 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
type UserInfo struct {
Name string
Uid string
Gid string
Home string
Shell string
Path string
Locked bool
}
const (
ACCOUNT_DEST = "com.deepin.daemon.Accounts"
ACCOUNT_MANAGER_PATH = "/com/deepin/daemon/Accounts"
ACCOUNT_MANAGER_IFC = "com.deepin.daemon.Accounts"
USER_MANAGER_PATH = "/com/deepin/daemon/Accounts/User"
USER_MANAGER_IFC = "com.deepin.daemon.Accounts.User"
)
const (
ETC_PASSWD = "/etc/passwd"
ETC_SHADOW = "/etc/shadow"
ETC_SHADOW_BAK = "/etc/shadow.bak"
ETC_GROUP = "/etc/group"
ETC_DISPLAY_MANAGER = "/etc/X11/default-display-manager"
ETC_LIGHTDM_CONFIG = "/etc/lightdm/lightdm.conf"
ETC_GDM_CONFIG = "/etc/gdm/custom.conf"
ETC_KDM_CONFIG = "/etc/kde4/kdm/kdmrc"
USER_KDM_CONFIG = "/usr/share/config/kdm/kdmrc"
LIGHTDM_AUTOLOGIN_GROUP = "SeatDefaults"
LIGHTDM_AUTOLOGIN_USER = "autologin-user"
GDM_AUTOLOGIN_GROUP = "daemon"
GDM_AUTOLOGIN_USER = "AutomaticLogin"
KDM_AUTOLOGIN_GROUP = "X-:0-Core"
KDM_AUTOLOGIN_ENABLE = "AutoLoginEnable"
KDM_AUTOLOGIN_USER = "AutoLoginUser"
ETC_PERM = 0644
PASSWD_SPLIT_LEN = 7
SHADOW_SPLIT_LEN = 9
GROUP_SPLIT_LEN = 4
)
const (
SHELL_END_FALSE = "false"
SHELL_END_NOLOGIN = "nologin"
KEY_TYPE_BOOL = 0
KEY_TYPE_INT = 1
KEY_TYPE_STRING = 2
KEY_TYPE_STRING_LIST = 3
ACCOUNT_TYPE_STANDARD = 0
ACCOUNT_TYPE_ADMINISTRATOR = 1
GUEST_USER_ICON = "/var/lib/AccountsService/icons/guest.png"
ACCOUNT_CONFIG_FILE = "/var/lib/AccountsService/accounts.ini"
ACCOUNT_GROUP_KEY = "Accounts"
ACCOUNT_KEY_GUEST = "AllowGuest"
USER_ICON_DIR = "/var/lib/AccountsService/icons/"
USER_DEFAULT_ICON = USER_ICON_DIR + "1.png"
USER_CONFIG_DIR = "/var/lib/AccountsService/users"
ICON_SYSTEM_DIR = "/var/lib/AccountsService/icons"
ICON_LOCAL_DIR = "/var/lib/AccountsService/icons/local"
USER_DEFAULT_BG = "file:///usr/share/backgrounds/default_background.jpg"
)
const (
CMD_USERADD = "/usr/sbin/useradd"
CMD_USERDEL = "/usr/sbin/userdel"
CMD_CHOWN = "/bin/chown"
CMD_USERMOD = "/usr/sbin/usermod"
CMD_GPASSWD = "/usr/bin/gpasswd"
POLKIT_CHANGED_OWN_DATA = "com.deepin.daemon.accounts.change-own-user-data"
POLKIT_MANAGER_USER = "com.deepin.daemon.accounts.user-administration"
POLKIT_SET_LOGIN_OPTION = "com.deepin.daemon.accounts.set-login-option"
)

View File

@ -1,302 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
import (
"github.com/howeyc/fsnotify"
"path"
dutils "pkg.linuxdeepin.com/lib/utils"
"regexp"
"sync"
)
var _handleFlag = false
func (obj *Manager) watchUserListFile() {
var err error
if obj.listWatcher == nil {
if obj.listWatcher, err = fsnotify.NewWatcher(); err != nil {
logger.Error("New User List Watcher Failed:", err)
return
}
}
obj.listWatcher.Watch(ETC_SHADOW)
obj.listWatcher.Watch(ACCOUNT_CONFIG_FILE)
}
func (obj *Manager) removeUserListFileWatch() {
if obj.listWatcher == nil {
return
}
obj.listWatcher.RemoveWatch(ETC_SHADOW)
obj.listWatcher.RemoveWatch(ACCOUNT_CONFIG_FILE)
}
func (obj *Manager) watchUserInfoFile() {
var err error
if obj.infoWatcher == nil {
if obj.infoWatcher, err = fsnotify.NewWatcher(); err != nil {
logger.Error("New User Info Watcher Failed:", err)
return
}
}
obj.infoWatcher.Watch(ETC_GROUP)
obj.infoWatcher.Watch(ETC_SHADOW)
obj.infoWatcher.Watch(ICON_SYSTEM_DIR)
obj.infoWatcher.Watch(ICON_LOCAL_DIR)
if dutils.IsFileExist(ETC_LIGHTDM_CONFIG) {
obj.infoWatcher.Watch(ETC_LIGHTDM_CONFIG)
}
if dutils.IsFileExist(ETC_GDM_CONFIG) {
obj.infoWatcher.Watch(ETC_GDM_CONFIG)
}
if dutils.IsFileExist(ETC_KDM_CONFIG) {
obj.infoWatcher.Watch(ETC_KDM_CONFIG)
}
}
func (obj *Manager) removeUserInfoFileWatch() {
if obj.infoWatcher == nil {
return
}
obj.infoWatcher.RemoveWatch(ETC_GROUP)
obj.infoWatcher.RemoveWatch(ETC_SHADOW)
obj.infoWatcher.RemoveWatch(ICON_SYSTEM_DIR)
obj.infoWatcher.RemoveWatch(ICON_LOCAL_DIR)
if dutils.IsFileExist(ETC_LIGHTDM_CONFIG) {
obj.infoWatcher.RemoveWatch(ETC_LIGHTDM_CONFIG)
}
if dutils.IsFileExist(ETC_GDM_CONFIG) {
obj.infoWatcher.RemoveWatch(ETC_GDM_CONFIG)
}
if dutils.IsFileExist(ETC_KDM_CONFIG) {
obj.infoWatcher.RemoveWatch(ETC_KDM_CONFIG)
}
}
var uLock sync.Mutex
func (obj *Manager) handleUserListChanged() {
for {
select {
case <-obj.listQuit:
return
case ev, ok := <-obj.listWatcher.Event:
if !ok {
if obj.listWatcher != nil {
obj.removeUserListFileWatch()
}
obj.watchUserListFile()
break
}
if ev == nil {
break
}
if ok, _ := regexp.MatchString(`\.swa?px?$`, ev.Name); ok {
break
}
logger.Debug("User List Event:", ev)
if ev.IsDelete() {
obj.removeUserListFileWatch()
obj.watchUserListFile()
//break
}
ok1, _ := regexp.MatchString(ACCOUNT_CONFIG_FILE, ev.Name)
if ok1 {
obj.setPropAllowGuest(isAllowGuest())
break
}
if !_handleFlag {
uLock.Lock()
_handleFlag = true
list, ret := compareStrList(obj.UserList, getUserList())
switch ret {
case 1:
obj.handleuserAdded(list)
case -1:
obj.handleUserRemoved(list)
}
_handleFlag = false
uLock.Unlock()
}
case err, ok := <-obj.listWatcher.Error:
if !ok || err != nil {
if obj.listWatcher != nil {
obj.removeUserListFileWatch()
}
obj.watchUserListFile()
break
}
}
}
}
func (obj *Manager) handleUserInfoChanged() {
for {
select {
case <-obj.infoQuit:
return
case ev, ok := <-obj.infoWatcher.Event:
if !ok {
if obj.infoWatcher != nil {
obj.removeUserInfoFileWatch()
}
obj.watchUserInfoFile()
break
}
if ev == nil {
break
}
if ok, _ := regexp.MatchString(`\.swa?px?$`, ev.Name); ok {
break
}
logger.Debug("User Info Event:", ev)
ok3, _ := regexp.MatchString(ICON_SYSTEM_DIR, ev.Name)
ok4, _ := regexp.MatchString(ICON_LOCAL_DIR, ev.Name)
if ok3 || ok4 {
for _, u := range obj.pathUserMap {
u.setPropIconList(u.getPropIconList())
}
}
if ev.IsDelete() {
obj.removeUserInfoFileWatch()
obj.watchUserInfoFile()
//break
}
ok1, _ := regexp.MatchString(ETC_GROUP, ev.Name)
if ok1 {
for _, u := range obj.pathUserMap {
u.setPropAccountType(u.getPropAccountType())
}
break
}
ok2, _ := regexp.MatchString(ETC_SHADOW, ev.Name)
if ok2 {
for _, info := range getUserInfoList() {
u, ok := obj.pathUserMap[obj.FindUserByName(info.Name)]
if !ok {
continue
}
u.setPropLocked(info.Locked)
}
break
}
ok5, _ := regexp.MatchString(ETC_LIGHTDM_CONFIG, ev.Name)
ok6, _ := regexp.MatchString(ETC_GDM_CONFIG, ev.Name)
ok7, _ := regexp.MatchString(ETC_KDM_CONFIG, ev.Name)
if ok5 || ok6 || ok7 {
for _, u := range obj.pathUserMap {
u.setPropAutomaticLogin(u.getPropAutomaticLogin())
}
break
}
case err, ok := <-obj.infoWatcher.Error:
if !ok || err != nil {
if obj.infoWatcher != nil {
obj.removeUserInfoFileWatch()
}
obj.watchUserInfoFile()
break
}
}
}
}
func (obj *User) watchUserConfig() {
if obj.watcher == nil {
var err error
if obj.watcher, err = fsnotify.NewWatcher(); err != nil {
logger.Error("New watcher in newUser failed:", err)
return
}
}
obj.watcher.Watch(path.Join(USER_CONFIG_DIR, obj.UserName))
}
func (obj *User) removeUserConfigWatch() {
if obj.watcher == nil {
return
}
obj.watcher.RemoveWatch(path.Join(USER_CONFIG_DIR, obj.UserName))
}
func (obj *User) handUserConfigChanged() {
for {
select {
case <-obj.quitFlag:
return
case ev, ok := <-obj.watcher.Event:
if !ok {
if obj.watcher != nil {
obj.removeUserConfigWatch()
}
obj.watchUserConfig()
break
}
if ev == nil {
break
}
if ok, _ := regexp.MatchString(`\.swa?px?$`, ev.Name); ok {
break
}
logger.Debug("User Config Event:", ev)
if ev.IsDelete() {
obj.removeUserConfigWatch()
obj.watchUserConfig()
break
}
obj.setPropIconList(obj.getPropIconList())
obj.setPropIconFile(obj.getPropIconFile())
obj.setPropBackgroundFile(obj.getPropBackgroundFile())
obj.setPropHistoryIcons(obj.getPropHistoryIcons())
case err, ok := <-obj.watcher.Error:
if !ok || err != nil {
if obj.watcher != nil {
obj.removeUserConfigWatch()
}
obj.watchUserConfig()
break
}
}
}
}

View File

@ -1,61 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
import "pkg.linuxdeepin.com/dde-daemon"
import (
"pkg.linuxdeepin.com/lib/dbus"
"pkg.linuxdeepin.com/lib/log"
)
func init() {
loader.Register(&loader.Module{
Name: "accounts",
Start: Start,
Stop: Stop,
Enable: true,
})
}
var (
logger = log.NewLogger(ACCOUNT_DEST)
)
func Start() {
logger.BeginTracing()
defer logger.EndTracing()
obj := GetManager()
if err := dbus.InstallOnSystem(obj); err != nil {
logger.Error("Install DBus Failed:", err)
return
}
obj.updateAllUserInfo()
}
func Stop() {
obj := GetManager()
obj.destroy()
dbus.UnInstallObject(obj)
}

View File

@ -1,69 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
/*#include <stdio.h>*/
#include <time.h>
#include <unistd.h>
#include <crypt.h>
#include "mkpasswd.h"
char *
mkpasswd (const char *words)
{
unsigned long seed[2];
char salt[] = "$6$........";
const char *const seedchars =
"./0123456789ABCDEFGHIJKLMNOPQRST"
"UVWXYZabcdefghijklmnopqrstuvwxyz";
char *password;
int i;
/* Generate a (not very) random seed.
You should do it better than this... */
seed[0] = time(NULL);
seed[1] = getpid() ^ (seed[0] >> 14 & 0x30000);
/* Turn it into printable characters from `seedchars'. */
for (i = 0; i < 8; i++) {
salt[3 + i] = seedchars[(seed[i / 5] >> (i % 5) * 6) & 0x3f];
}
// DES Encrypt
password = crypt(words, salt);
return password;
}
/*
int
main(int argc, char *argv[])
{
if (argc != 2 ) {
printf("args error\n");
return -1;
}
char *passwd = mkpasswd(argv[1]);
printf("mkpasswd: %s\n", passwd);
return 0;
}
*/

View File

@ -1,27 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
#ifndef __MKPASSWD_H__
#define __MKPASSWD_H__
char* mkpasswd(const char *words);
#endif

View File

@ -1,85 +0,0 @@
# /etc/adduser.conf: `adduser' configuration.
# See adduser(8) and adduser.conf(5) for full documentation.
# The DSHELL variable specifies the default login shell on your
# system.
DSHELL=/bin/zsh
# The DHOME variable specifies the directory containing users' home
# directories.
DHOME=/home
# If GROUPHOMES is "yes", then the home directories will be created as
# /home/groupname/user.
GROUPHOMES=no
# If LETTERHOMES is "yes", then the created home directories will have
# an extra directory - the first letter of the user name. For example:
# /home/u/user.
LETTERHOMES=no
# The SKEL variable specifies the directory containing "skeletal" user
# files; in other words, files such as a sample .profile that will be
# copied to the new user's home directory when it is created.
SKEL=/etc/skel
# FIRST_SYSTEM_[GU]ID to LAST_SYSTEM_[GU]ID inclusive is the range for UIDs
# for dynamically allocated administrative and system accounts/groups.
# Please note that system software, such as the users allocated by the base-passwd
# package, may assume that UIDs less than 100 are unallocated.
FIRST_SYSTEM_UID=100
LAST_SYSTEM_UID=999
FIRST_SYSTEM_GID=100
LAST_SYSTEM_GID=999
# FIRST_[GU]ID to LAST_[GU]ID inclusive is the range of UIDs of dynamically
# allocated user accounts/groups.
FIRST_UID=1000
LAST_UID=29999
FIRST_GID=1000
LAST_GID=29999
# The USERGROUPS variable can be either "yes" or "no". If "yes" each
# created user will be given their own group to use as a default. If
# "no", each created user will be placed in the group whose gid is
# USERS_GID (see below).
USERGROUPS=yes
# If USERGROUPS is "no", then USERS_GID should be the GID of the group
# `users' (or the equivalent group) on your system.
USERS_GID=100
# If DIR_MODE is set, directories will be created with the specified
# mode. Otherwise the default mode 0755 will be used.
DIR_MODE=0755
# If SETGID_HOME is "yes" home directories for users with their own
# group the setgid bit will be set. This was the default for
# versions << 3.13 of adduser. Because it has some bad side effects we
# no longer do this per default. If you want it nevertheless you can
# still set it here.
SETGID_HOME=no
# If QUOTAUSER is set, a default quota will be set from that user with
# `edquota -p QUOTAUSER newuser'
QUOTAUSER=""
# If SKEL_IGNORE_REGEX is set, adduser will ignore files matching this
# regular expression when creating a new home directory
SKEL_IGNORE_REGEX="dpkg-(old|new|dist|save)"
# Set this if you want the --add_extra_groups option to adduser to add
# new users to other groups.
# This is the list of groups that new non-system users will be added to
# Default:
#EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users"
# If ADD_EXTRA_GROUPS is set to something non-zero, the EXTRA_GROUPS
# option above will be default behavior for adding new, non-system users
#ADD_EXTRA_GROUPS=1
# check user and group names also against this regular expression.
#NAME_REGEX="^[a-z][-a-z0-9_]*\$"

View File

@ -1,85 +0,0 @@
# /etc/adduser.conf: `adduser' configuration.
# See adduser(8) and adduser.conf(5) for full documentation.
# The DSHELL variable specifies the default login shell on your
# system.
DSHELL=
# The DHOME variable specifies the directory containing users' home
# directories.
DHOME=/home
# If GROUPHOMES is "yes", then the home directories will be created as
# /home/groupname/user.
GROUPHOMES=no
# If LETTERHOMES is "yes", then the created home directories will have
# an extra directory - the first letter of the user name. For example:
# /home/u/user.
LETTERHOMES=no
# The SKEL variable specifies the directory containing "skeletal" user
# files; in other words, files such as a sample .profile that will be
# copied to the new user's home directory when it is created.
SKEL=/etc/skel
# FIRST_SYSTEM_[GU]ID to LAST_SYSTEM_[GU]ID inclusive is the range for UIDs
# for dynamically allocated administrative and system accounts/groups.
# Please note that system software, such as the users allocated by the base-passwd
# package, may assume that UIDs less than 100 are unallocated.
FIRST_SYSTEM_UID=100
LAST_SYSTEM_UID=999
FIRST_SYSTEM_GID=100
LAST_SYSTEM_GID=999
# FIRST_[GU]ID to LAST_[GU]ID inclusive is the range of UIDs of dynamically
# allocated user accounts/groups.
FIRST_UID=1000
LAST_UID=29999
FIRST_GID=1000
LAST_GID=29999
# The USERGROUPS variable can be either "yes" or "no". If "yes" each
# created user will be given their own group to use as a default. If
# "no", each created user will be placed in the group whose gid is
# USERS_GID (see below).
USERGROUPS=yes
# If USERGROUPS is "no", then USERS_GID should be the GID of the group
# `users' (or the equivalent group) on your system.
USERS_GID=100
# If DIR_MODE is set, directories will be created with the specified
# mode. Otherwise the default mode 0755 will be used.
DIR_MODE=0755
# If SETGID_HOME is "yes" home directories for users with their own
# group the setgid bit will be set. This was the default for
# versions << 3.13 of adduser. Because it has some bad side effects we
# no longer do this per default. If you want it nevertheless you can
# still set it here.
SETGID_HOME=no
# If QUOTAUSER is set, a default quota will be set from that user with
# `edquota -p QUOTAUSER newuser'
QUOTAUSER=""
# If SKEL_IGNORE_REGEX is set, adduser will ignore files matching this
# regular expression when creating a new home directory
SKEL_IGNORE_REGEX="dpkg-(old|new|dist|save)"
# Set this if you want the --add_extra_groups option to adduser to add
# new users to other groups.
# This is the list of groups that new non-system users will be added to
# Default:
#EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users"
# If ADD_EXTRA_GROUPS is set to something non-zero, the EXTRA_GROUPS
# option above will be default behavior for adding new, non-system users
#ADD_EXTRA_GROUPS=1
# check user and group names also against this regular expression.
#NAME_REGEX="^[a-z][-a-z0-9_]*\$"

View File

@ -1,284 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
import (
"github.com/howeyc/fsnotify"
"io/ioutil"
"math/rand"
"os"
"path"
dutils "pkg.linuxdeepin.com/lib/utils"
"regexp"
"strings"
)
type User struct {
Uid string
Gid string
UserName string
HomeDir string
Shell string
IconFile string
BackgroundFile string
AutomaticLogin bool
AccountType int32
Locked bool
LoginTime uint64
HistoryIcons []string
IconList []string
objectPath string
watcher *fsnotify.Watcher
quitFlag chan bool
}
func addUserToAdmList(name string) bool {
tmps := []string{}
tmps = append(tmps, "-a")
tmps = append(tmps, name)
tmps = append(tmps, "sudo")
return execCommand(CMD_GPASSWD, tmps)
}
func deleteUserFromAdmList(name string) bool {
tmps := []string{}
tmps = append(tmps, "-d")
tmps = append(tmps, name)
tmps = append(tmps, "sudo")
return execCommand(CMD_GPASSWD, tmps)
}
func getRandUserIcon() string {
list := getIconList(ICON_SYSTEM_DIR)
l := len(list)
if l <= 0 {
return ""
}
index := rand.Int31n(int32(l))
return list[index]
}
func getIconList(dir string) []string {
iconfd, err := os.Open(dir)
if err != nil {
logger.Warningf("Open '%s' failed: %v",
dir, err)
return nil
}
names, _ := iconfd.Readdirnames(0)
list := []string{}
for _, v := range names {
if strings.Contains(v, "guest") {
continue
}
tmp := strings.ToLower(v)
//ok, _ := regexp.MatchString(`jpe?g$||png$||gif$`, tmp)
ok1, _ := regexp.MatchString(`\.jpe?g$`, tmp)
ok2, _ := regexp.MatchString(`\.png$`, tmp)
ok3, _ := regexp.MatchString(`\.gif$`, tmp)
if ok1 || ok2 || ok3 {
list = append(list, path.Join(dir, v))
}
}
return list
}
func getAdministratorList() []string {
contents, err := ioutil.ReadFile(ETC_GROUP)
if err != nil {
logger.Errorf("ReadFile '%s' failed: %s", ETC_PASSWD, err)
return nil
}
list := ""
lines := strings.Split(string(contents), "\n")
for _, line := range lines {
strs := strings.Split(line, ":")
if len(strs) != GROUP_SPLIT_LEN {
continue
}
if strs[0] == "sudo" {
list = strs[3]
break
}
}
return strings.Split(list, ",")
}
func setAutomaticLogin(name string) {
dsp := getDefaultDisplayManager()
logger.Debugf("Set %s Auto For: %s", name, dsp)
switch dsp {
case "lightdm":
if dutils.IsFileExist(ETC_LIGHTDM_CONFIG) {
dutils.WriteKeyToKeyFile(ETC_LIGHTDM_CONFIG,
LIGHTDM_AUTOLOGIN_GROUP,
LIGHTDM_AUTOLOGIN_USER,
name)
}
case "gdm":
if dutils.IsFileExist(ETC_GDM_CONFIG) {
dutils.WriteKeyToKeyFile(ETC_GDM_CONFIG,
GDM_AUTOLOGIN_GROUP,
GDM_AUTOLOGIN_USER,
name)
}
case "kdm":
if dutils.IsFileExist(ETC_KDM_CONFIG) {
dutils.WriteKeyToKeyFile(ETC_KDM_CONFIG,
KDM_AUTOLOGIN_GROUP,
KDM_AUTOLOGIN_ENABLE,
true)
dutils.WriteKeyToKeyFile(ETC_KDM_CONFIG,
KDM_AUTOLOGIN_GROUP,
KDM_AUTOLOGIN_USER,
name)
} else if dutils.IsFileExist(USER_KDM_CONFIG) {
dutils.WriteKeyToKeyFile(ETC_KDM_CONFIG,
KDM_AUTOLOGIN_GROUP,
KDM_AUTOLOGIN_ENABLE,
true)
dutils.WriteKeyToKeyFile(USER_KDM_CONFIG,
KDM_AUTOLOGIN_GROUP,
KDM_AUTOLOGIN_USER,
name)
}
default:
logger.Warning("No support display manager")
}
}
func isAutoLogin(username string) bool {
dsp := getDefaultDisplayManager()
//logger.Info("Display: ", dsp)
switch dsp {
case "lightdm":
if dutils.IsFileExist(ETC_LIGHTDM_CONFIG) {
v, ok := dutils.ReadKeyFromKeyFile(ETC_LIGHTDM_CONFIG,
LIGHTDM_AUTOLOGIN_GROUP,
LIGHTDM_AUTOLOGIN_USER,
"")
//logger.Info("AutoUser: ", v.(string))
//logger.Info("UserName: ", username)
if ok && v.(string) == username {
return true
}
}
case "gdm":
if dutils.IsFileExist(ETC_GDM_CONFIG) {
v, ok := dutils.ReadKeyFromKeyFile(ETC_GDM_CONFIG,
GDM_AUTOLOGIN_GROUP,
GDM_AUTOLOGIN_USER,
"")
if ok && v.(string) == username {
return true
}
}
case "kdm":
if dutils.IsFileExist(ETC_KDM_CONFIG) {
v, ok := dutils.ReadKeyFromKeyFile(ETC_KDM_CONFIG,
KDM_AUTOLOGIN_GROUP,
KDM_AUTOLOGIN_USER,
"")
if ok && v.(string) == username {
return true
}
} else if dutils.IsFileExist(USER_KDM_CONFIG) {
v, ok := dutils.ReadKeyFromKeyFile(USER_KDM_CONFIG,
KDM_AUTOLOGIN_GROUP,
KDM_AUTOLOGIN_USER,
"")
if ok && v.(string) == username {
return true
}
}
}
return false
}
func getDefaultDisplayManager() string {
contents, err := ioutil.ReadFile(ETC_DISPLAY_MANAGER)
if err != nil {
logger.Errorf("ReadFile '%s' failed: %s",
ETC_DISPLAY_MANAGER, err)
return ""
}
tmp := ""
for _, b := range contents {
if b == '\n' {
tmp += ""
continue
}
tmp += string(b)
}
return path.Base(tmp)
}
func (user *User) setProps() {
info, _ := getUserInfoByPath(user.objectPath)
user.setPropUserName(info.Name)
user.setPropHomeDir(info.Home)
user.setPropShell(info.Shell)
user.setPropLocked(info.Locked)
user.setPropAutomaticLogin(user.getPropAutomaticLogin())
user.setPropAccountType(user.getPropAccountType())
user.setPropIconList(user.getPropIconList())
user.setPropIconFile(user.getPropIconFile())
user.setPropBackgroundFile(user.getPropBackgroundFile())
user.setPropHistoryIcons(user.getPropHistoryIcons())
}
func newUser(path string) *User {
info, ok := getUserInfoByPath(path)
if !ok {
return nil
}
obj := &User{}
obj.objectPath = info.Path
obj.Uid = info.Uid
obj.Gid = info.Gid
var err error
obj.watcher, err = fsnotify.NewWatcher()
if err != nil {
logger.Warning("New watcher in newUser failed:", err)
}
if obj.watcher != nil {
obj.quitFlag = make(chan bool)
obj.watchUserConfig()
go obj.handUserConfigChanged()
}
return obj
}

View File

@ -1,306 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
import (
"os"
"path"
"pkg.linuxdeepin.com/lib/dbus"
"pkg.linuxdeepin.com/lib/graphic"
dutils "pkg.linuxdeepin.com/lib/utils"
"strings"
)
func (u *User) SetUserName(dbusMsg dbus.DMessage, username string) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In SetUserName:%v",
err)
}
}()
//if ok := dutils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
if u.UserName != username {
u.setUserName(username)
}
return true
}
func (u *User) SetHomeDir(dbusMsg dbus.DMessage, dir string) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In SetHomeDir:%v",
err)
}
}()
//if ok := dutils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
if u.HomeDir != dir {
u.setHomeDir(dir)
}
return true
}
func (u *User) SetShell(dbusMsg dbus.DMessage, shell string) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In SetShell:%v",
err)
}
}()
//if ok := dutils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
if u.Shell != shell {
u.setShell(shell)
}
return true
}
func (u *User) SetPassword(dbusMsg dbus.DMessage, words string) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In SetPassword:%v",
err)
}
}()
//if ok := dutils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
passwd := encodePasswd(words)
changePasswd(u.UserName, passwd)
u.setLocked(false)
return true
}
func (u *User) SetAutomaticLogin(dbusMsg dbus.DMessage, auto bool) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In SetAutomaticLogin:%v",
err)
}
}()
//if ok := dutils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
if u.AutomaticLogin != auto {
u.setAutomaticLogin(auto)
}
return true
}
func (u *User) SetAccountType(dbusMsg dbus.DMessage, t int32) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In SetAccountType:%v",
err)
}
}()
//if ok := dutils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
if u.AccountType != t {
u.setAccountType(t)
}
return true
}
func (u *User) SetLocked(dbusMsg dbus.DMessage, locked bool) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In SetLocked:%v",
err)
}
}()
//if ok := dutils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
if u.Locked != locked {
u.setLocked(locked)
}
return true
}
func (u *User) SetIconFile(dbusMsg dbus.DMessage, icon string) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In SetIconFile:%v",
err)
}
}()
//if ok := dutils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
if !dutils.IsFileExist(icon) ||
!graphic.IsSupportedImage(icon) {
return false
}
if u.IconFile == icon {
return true
}
if !strIsInList(icon, u.IconList) {
if ok := dutils.IsFileExist(ICON_LOCAL_DIR); !ok {
if err := os.MkdirAll(ICON_LOCAL_DIR, 0755); err != nil {
return false
}
}
name := path.Base(icon)
dest := path.Join(ICON_LOCAL_DIR, u.UserName+"-"+name)
if err := dutils.CopyFile(icon, dest); err != nil {
return false
}
icon = dest
}
u.setIconFile(icon)
return true
}
func (u *User) SetBackgroundFile(dbusMsg dbus.DMessage, bg string) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In SetBackgroundFile:%v",
err)
}
}()
//if ok := dutils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
if u.BackgroundFile != bg {
u.setBackgroundFile(bg)
}
return true
}
func (u *User) DeleteHistoryIcon(dbusMsg dbus.DMessage, icon string) bool {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In DeleteHistoryIcon:%v",
err)
}
}()
//if ok := dutils.PolkitAuthWithPid(POLKIT_MANAGER_USER,
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
u.deleteHistoryIcon(icon)
return true
}
func (u *User) DeleteIconFile(dbusMsg dbus.DMessage, icon string) (success bool) {
defer func() {
if err := recover(); err != nil {
logger.Errorf("Recover Error In DeleteHistoryIcon:%v",
err)
}
}()
if ok := polkitAuthWithPid(POLKIT_MANAGER_USER,
dbusMsg.GetSenderPID()); !ok {
return false
}
if err := rmAllFile(icon); err != nil {
return false
}
u.deleteHistoryIcon(icon)
return true
}
func (u *User) IsIconDeletable(icon string) bool {
if icon == u.IconFile {
return false
}
if strings.Contains(icon, path.Join(ICON_LOCAL_DIR, u.UserName)) {
return true
}
return false
}
func (u *User) GetLargeIcon() string {
baseName := path.Base(u.IconFile)
dir := path.Dir(u.IconFile)
filename := path.Join(dir, "bigger", baseName)
if !dutils.IsFileExist(filename) {
return ""
}
return filename
}

View File

@ -1,380 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package accounts
import (
"path"
"pkg.linuxdeepin.com/lib/dbus"
dutils "pkg.linuxdeepin.com/lib/utils"
"strings"
)
func (obj *User) GetDBusInfo() dbus.DBusInfo {
return dbus.DBusInfo{
Dest: ACCOUNT_DEST,
ObjectPath: obj.objectPath,
Interface: USER_MANAGER_IFC,
}
}
func (obj *User) setPropUserName(name string) {
if len(name) < 1 {
return
}
if obj.UserName != name {
obj.UserName = name
dbus.NotifyChange(obj, "UserName")
}
}
func (obj *User) setPropHomeDir(homeDir string) {
if len(homeDir) < 1 {
return
}
if obj.HomeDir != homeDir {
obj.HomeDir = homeDir
dbus.NotifyChange(obj, "HomeDir")
}
}
func (obj *User) setPropShell(shell string) {
if len(shell) < 1 {
return
}
if obj.Shell != shell {
obj.Shell = shell
dbus.NotifyChange(obj, "Shell")
}
}
func (obj *User) setPropIconFile(icon string) {
if len(icon) < 1 {
return
}
if obj.IconFile != icon {
obj.IconFile = icon
dbus.NotifyChange(obj, "IconFile")
}
}
func (obj *User) setPropBackgroundFile(bg string) {
if len(bg) < 1 {
return
}
if obj.BackgroundFile != bg {
obj.BackgroundFile = bg
dbus.NotifyChange(obj, "BackgroundFile")
}
}
func (obj *User) setPropAutomaticLogin(enable bool) {
//if obj.AutomaticLogin != enable {
obj.AutomaticLogin = enable
dbus.NotifyChange(obj, "AutomaticLogin")
//}
}
func (obj *User) setPropAccountType(acctype int32) {
//if obj.AccountType != acctype {
obj.AccountType = acctype
dbus.NotifyChange(obj, "AccountType")
//}
}
func (obj *User) setPropLocked(locked bool) {
//if obj.Locked != locked {
obj.Locked = locked
dbus.NotifyChange(obj, "Locked")
//}
}
func (obj *User) setPropHistoryIcons(iconList []string) {
if !isStrListEqual(obj.HistoryIcons, iconList) {
obj.HistoryIcons = iconList
dbus.NotifyChange(obj, "HistoryIcons")
}
}
func (obj *User) setPropIconList(iconList []string) {
if !isStrListEqual(obj.IconList, iconList) {
obj.IconList = iconList
dbus.NotifyChange(obj, "IconList")
}
}
func (obj *User) getPropIconFile() string {
file := path.Join(USER_CONFIG_DIR, obj.UserName)
icon := ""
wFlag := false
if !dutils.IsFileExist(file) {
icon = getRandUserIcon()
wFlag = true
} else {
if v, ok := dutils.ReadKeyFromKeyFile(file, "User",
"Icon", ""); !ok {
icon = getRandUserIcon()
wFlag = true
} else {
icon = v.(string)
}
}
if wFlag {
dutils.WriteKeyToKeyFile(file, "User", "Icon", icon)
}
return icon
}
func (obj *User) getPropBackgroundFile() string {
file := path.Join(USER_CONFIG_DIR, obj.UserName)
bg := ""
wFlag := false
if !dutils.IsFileExist(file) {
bg = USER_DEFAULT_BG
wFlag = true
} else {
if v, ok := dutils.ReadKeyFromKeyFile(file, "User",
"Background", ""); !ok {
bg = USER_DEFAULT_BG
wFlag = true
} else {
bg = v.(string)
}
}
if wFlag {
dutils.WriteKeyToKeyFile(file, "User", "Background", bg)
}
return bg
}
func (obj *User) getPropAutomaticLogin() bool {
return isAutoLogin(obj.UserName)
}
func (obj *User) getPropAccountType() int32 {
list := getAdministratorList()
if strIsInList(obj.UserName, list) {
return ACCOUNT_TYPE_ADMINISTRATOR
}
return ACCOUNT_TYPE_STANDARD
}
func (obj *User) getPropHistoryIcons() []string {
list := []string{}
file := path.Join(USER_CONFIG_DIR, obj.UserName)
if !dutils.IsFileExist(file) {
list = append(list, obj.IconFile)
} else {
if v, ok := dutils.ReadKeyFromKeyFile(file, "User",
"HistoryIcons", []string{}); !ok {
list = append(list, obj.IconFile)
} else {
list = append(list, v.([]string)...)
}
}
tmp := []string{}
for _, v := range list {
if v == obj.IconFile {
continue
}
tmp = append(tmp, v)
}
list = tmp
return list
}
func (obj *User) getPropIconList() []string {
list := []string{}
sysList := getIconList(ICON_SYSTEM_DIR)
list = append(list, sysList...)
localList := getIconList(ICON_LOCAL_DIR)
for _, l := range localList {
if strings.Contains(l, obj.UserName+"-") {
list = append(list, l)
}
}
return list
}
func (obj *User) addHistoryIcon(iconPath string) {
file := path.Join(USER_CONFIG_DIR, obj.UserName)
if !dutils.IsFileExist(file) || !dutils.IsFileExist(iconPath) {
return
}
list, _ := dutils.ReadKeyFromKeyFile(file, "User",
"HistoryIcons", []string{})
ret := []string{}
ret = append(ret, iconPath)
cnt := 1
if list != nil {
strs := list.([]string)
as := deleteStrFromList(iconPath, strs)
for _, l := range as {
if cnt >= 10 {
break
}
if ok := dutils.IsFileExist(l); !ok {
continue
}
ret = append(ret, l)
cnt++
}
}
dutils.WriteKeyToKeyFile(file, "User", "HistoryIcons", ret)
return
}
func (obj *User) deleteHistoryIcon(iconPath string) {
file := path.Join(USER_CONFIG_DIR, obj.UserName)
if !dutils.IsFileExist(file) {
return
}
list, ok := dutils.ReadKeyFromKeyFile(file, "User",
"HistoryIcons", []string{})
if !ok || list == nil {
return
}
tmp := deleteStrFromList(iconPath, list.([]string))
dutils.WriteKeyToKeyFile(file, "User", "HistoryIcons", tmp)
return
}
func (obj *User) setUserName(name string) {
if len(name) < 1 {
return
}
args := []string{}
args = append(args, "-l")
args = append(args, name)
args = append(args, obj.UserName)
execCommand(CMD_USERMOD, args)
}
func (obj *User) setHomeDir(homeDir string) {
if len(homeDir) < 1 {
return
}
args := []string{}
args = append(args, "-m")
args = append(args, "-d")
args = append(args, homeDir)
args = append(args, obj.UserName)
execCommand(CMD_USERMOD, args)
}
func (obj *User) setShell(shell string) {
if len(shell) < 1 {
return
}
args := []string{}
args = append(args, "-s")
args = append(args, shell)
args = append(args, obj.UserName)
execCommand(CMD_USERMOD, args)
}
func (obj *User) setIconFile(icon string) {
if len(icon) < 1 {
return
}
file := path.Join(USER_CONFIG_DIR, obj.UserName)
dutils.WriteKeyToKeyFile(file, "User", "Icon", icon)
obj.addHistoryIcon(icon)
}
func (obj *User) setBackgroundFile(bg string) {
if len(bg) < 1 {
return
}
file := path.Join(USER_CONFIG_DIR, obj.UserName)
dutils.WriteKeyToKeyFile(file, "User", "Background", bg)
}
func (obj *User) setAutomaticLogin(auto bool) {
if auto {
setAutomaticLogin(obj.UserName)
} else {
setAutomaticLogin("")
}
}
func (obj *User) setAccountType(acctype int32) {
t := obj.getPropAccountType()
switch acctype {
case ACCOUNT_TYPE_ADMINISTRATOR:
if t != ACCOUNT_TYPE_ADMINISTRATOR {
ok := addUserToAdmList(obj.UserName)
if ok {
obj.setPropAccountType(acctype)
}
}
case ACCOUNT_TYPE_STANDARD:
if t == ACCOUNT_TYPE_ADMINISTRATOR {
ok := deleteUserFromAdmList(obj.UserName)
if ok {
obj.setPropAccountType(acctype)
}
}
}
}
func (obj *User) setLocked(locked bool) {
args := []string{}
if locked {
args = append(args, "-L")
args = append(args, obj.UserName)
} else {
args = append(args, "-U")
args = append(args, obj.UserName)
}
ok := execCommand(CMD_USERMOD, args)
if ok {
obj.setPropLocked(locked)
}
}

View File

@ -1,36 +0,0 @@
root:x:0:0:root:/root:/bin/zsh
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
libuuid:x:100:101::/var/lib/libuuid:
messagebus:x:101:104::/var/run/dbus:/bin/false
syslog:x:102:105::/home/syslog:/bin/false
usbmux:x:103:46:usbmux daemon,,,:/home/usbmux:/bin/false
lightdm:x:104:110:Light Display Manager:/var/lib/lightdm:/bin/false
dnsmasq:x:105:65534:dnsmasq,,,:/var/lib/misc:/bin/false
avahi-autoipd:x:106:114:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/bin/false
avahi:x:107:115:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
rtkit:x:108:118:RealtimeKit,,,:/proc:/bin/false
saned:x:109:119::/home/saned:/bin/false
colord:x:110:120:colord colour management daemon,,,:/var/lib/colord:/bin/false
hplip:x:111:7:HPLIP system user,,,:/var/run/hplip:/bin/false
pulse:x:112:121:PulseAudio daemon,,,:/var/run/pulse:/bin/false
deepin-daemon:x:113:123::/home/deepin-daemon:/bin/false
nm-openconnect:x:114:124:NetworkManager OpenConnect plugin,,,:/var/lib/NetworkManager:/bin/false
wen:x:1001:1001:wen:/home/wen:/bin/zsh
test1:x:1002:1002:test1:/home/test1:/bin/bash
test2:x:1003:1003:test2:/home/test2:/bin/bash

View File

@ -1,172 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package username_checker
import (
"fmt"
"io/ioutil"
. "pkg.linuxdeepin.com/lib/gettext"
"regexp"
"strconv"
"strings"
)
const (
passwdFilePath = "/etc/passwd"
groupFilePath = "/etc/group"
)
type usernameInfo struct {
name string
id string
}
type ErrorInfo struct {
Message error
Code int32
}
var (
ErrCodeEmpty int32 = 1
ErrCodeInvalidChar int32 = 2
ErrCodeFirstNotLower int32 = 3
ErrCodeExist int32 = 4
ErrCodeSystemUsed int32 = 5
)
var (
ErrMSGEmpty error
ErrMSGInvalidChar error
ErrMSGFirstNotLower error
ErrMSGExist error
ErrMSGSystemUsed error
)
func initErrorInfo() {
ErrMSGEmpty = fmt.Errorf(Tr("Username can not be empty."))
ErrMSGInvalidChar = fmt.Errorf(Tr("Username must comprise a~z, 0~9, - or _."))
ErrMSGFirstNotLower = fmt.Errorf(Tr("The first character must be in lower case."))
ErrMSGExist = fmt.Errorf(Tr("The username exists."))
ErrMSGSystemUsed = fmt.Errorf(Tr("The username has been used by system."))
}
func CheckUsernameValid(username string) *ErrorInfo {
if ErrMSGEmpty == nil {
initErrorInfo()
}
if len(username) == 0 {
return &ErrorInfo{
Message: ErrMSGEmpty,
Code: ErrCodeEmpty,
}
}
ok, err := checkNameExist(username, passwdFilePath)
if ok {
return err
}
/**
* The username is allowed only started with a letter,
* and is composed of letters and numbers
*/
match := regexp.MustCompile(`^[a-z]`)
if !match.MatchString(username) {
return &ErrorInfo{
Message: ErrMSGFirstNotLower,
Code: ErrCodeFirstNotLower,
}
}
match = regexp.MustCompile(`^[a-z][a-z0-9_-]*$`)
if !match.MatchString(username) {
return &ErrorInfo{
Message: ErrMSGInvalidChar,
Code: ErrCodeInvalidChar,
}
}
return nil
}
func checkNameExist(name, config string) (bool, *ErrorInfo) {
infos, err := getNameListFromFile(config)
if err != nil {
return false, nil
}
exist, info := isNameInInfoList(name, infos)
if !exist {
return false, nil
}
interval, _ := strconv.ParseInt(info.id, 10, 64)
if interval < 1000 {
return true, &ErrorInfo{
Message: ErrMSGSystemUsed,
Code: ErrCodeSystemUsed,
}
} else {
return true, &ErrorInfo{
Message: ErrMSGExist,
Code: ErrCodeExist,
}
}
return false, nil
}
func getNameListFromFile(config string) ([]usernameInfo, error) {
contents, err := ioutil.ReadFile(config)
if err != nil {
return nil, err
}
var infos []usernameInfo
lines := strings.Split(string(contents), "\n")
for _, line := range lines {
if len(line) == 0 {
continue
}
tmp := strings.Split(line, ":")
if len(tmp) < 3 {
continue
}
info := usernameInfo{name: tmp[0], id: tmp[2]}
infos = append(infos, info)
}
return infos, nil
}
func isNameInInfoList(name string, infos []usernameInfo) (bool, usernameInfo) {
for _, info := range infos {
if name == info.name {
return true, info
}
}
return false, usernameInfo{}
}

View File

@ -1,142 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package username_checker
import (
C "launchpad.net/gocheck"
"testing"
)
type testWrapper struct{}
func init() {
initErrorInfo()
C.Suite(&testWrapper{})
}
func Test(t *testing.T) {
C.TestingT(t)
}
type errorInfo struct {
name string
code int32
ret bool
}
func (*testWrapper) TestUsernameValid(c *C.C) {
var infos = []errorInfo{
{
name: "",
code: ErrCodeEmpty,
ret: true,
},
{
name: "Asdf",
code: ErrCodeFirstNotLower,
ret: true,
},
{
name: "root",
code: ErrCodeSystemUsed,
ret: true,
},
{
name: "xx12$%",
code: ErrCodeInvalidChar,
ret: true,
},
{
name: "0",
code: ErrCodeFirstNotLower,
ret: true,
},
{
name: "A",
code: ErrCodeFirstNotLower,
ret: true,
},
{
name: "-",
code: ErrCodeFirstNotLower,
ret: true,
},
{
name: "_",
code: ErrCodeFirstNotLower,
ret: true,
},
{
name: "i",
code: -1,
ret: false,
},
{
name: "iixxx",
code: -1,
ret: false,
},
}
for _, info := range infos {
err := CheckUsernameValid(info.name)
if info.ret {
c.Check(err.Code, C.Equals, info.code)
} else {
c.Check(err, C.Not(C.NotNil))
}
}
}
func (*testWrapper) TestUsernameExist(c *C.C) {
var infos = []errorInfo{
{
name: "",
code: -1,
ret: false,
},
{
name: "root",
code: ErrCodeSystemUsed,
ret: true,
},
{
name: "wen",
code: ErrCodeExist,
ret: true,
},
{
name: "iixxx",
code: -1,
ret: false,
},
}
for _, info := range infos {
_, err := checkNameExist(info.name, "testdata/passwd")
if info.ret {
c.Check(err.Code, C.Equals, info.code)
} else {
c.Check(err, C.Not(C.NotNil))
}
}
}

View File

@ -1,263 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package appearance
import (
"os"
"path"
"pkg.linuxdeepin.com/dde-daemon/appearance/fonts"
"pkg.linuxdeepin.com/lib/glib-2.0"
dutils "pkg.linuxdeepin.com/lib/utils"
)
const (
systemThemePath = "/usr/share/personalization/themes"
userThemePath = ".local/share/personalization/themes"
customDThemeId = "Custom"
tempDThemeCustom = "/usr/share/dde-daemon/template/theme_custom"
dirPermMode = 0755
)
func (m *Manager) setTheme(themeType string, value interface{}) {
dinfo := m.newThemeInfo(themeType, value)
if dinfo == nil {
return
}
if theme, ok := m.isThemeExist(dinfo); ok {
m.Set("theme", theme)
return
}
if m.modifyCustomTheme(dinfo) {
m.settings.SetString(deepinGSKeyTheme, customDThemeId)
}
}
func (m *Manager) applyTheme(name string) {
if name != m.CurrentTheme.Get() {
return
}
t, ok := m.themeObjMap[name]
if !ok {
return
}
m.gtk.Set(t.GtkTheme)
m.icon.Set(t.IconTheme)
m.cursor.Set(t.CursorTheme)
m.bg.Set(t.Background)
m.font.Set(fonts.FontTypeStandard, t.FontName, t.FontSize)
m.font.Set(fonts.FontTypeMonospaced, t.FontMono, t.FontSize)
m.sound.Set(t.SoundTheme)
m.greeter.Set(m.settings.GetString(deepinGSKeyGreeter))
}
func (m *Manager) modifyCustomTheme(info *Theme) bool {
homeDir := dutils.GetHomeDir()
dir := path.Join(homeDir, userThemePath, "Custom")
if !dutils.IsFileExist(dir) {
err := os.MkdirAll(dir, dirPermMode)
if err != nil {
logger.Debug(err)
return false
}
}
filename := path.Join(dir, "theme.ini")
var newFile bool
if !dutils.IsFileExist(filename) {
err := dutils.CopyFile(tempDThemeCustom, filename)
if err != nil {
logger.Debug(err)
return false
}
newFile = true
}
kFile := glib.NewKeyFile()
defer kFile.Free()
_, err := kFile.LoadFromFile(filename,
glib.KeyFileFlagsKeepComments|
glib.KeyFileFlagsKeepTranslations)
if err != nil {
return false
}
kFile.SetString(groupKeyComponent, themeKeyGtk, info.GtkTheme)
kFile.SetString(groupKeyComponent, themeKeyIcon, info.IconTheme)
kFile.SetString(groupKeyComponent, themeKeyCursor, info.CursorTheme)
kFile.SetString(groupKeyComponent, themeKeySound, info.SoundTheme)
kFile.SetString(groupKeyComponent, themeKeyBackground, info.Background)
kFile.SetString(groupKeyComponent, themeKeyFontName, info.FontName)
kFile.SetString(groupKeyComponent, themeKeyFontMono, info.FontMono)
kFile.SetInteger(groupKeyComponent, themeKeyFontSize, int(info.FontSize))
_, contents, err := kFile.ToData()
if err != nil {
return false
}
m.wLocker.Lock()
defer m.wLocker.Unlock()
ok := dutils.WriteStringToKeyFile(filename, contents)
if newFile && ok {
touchFile()
}
return ok
}
func (m *Manager) isThemeExist(info *Theme) (string, bool) {
for n, t := range m.themeObjMap {
if isThemeInfoSame(info, t) {
return n, true
}
}
return "", false
}
func (m *Manager) newThemeInfo(themeType string, value interface{}) *Theme {
t, ok := m.themeObjMap[m.CurrentTheme.Get()]
if !ok {
logger.Debug("Get Current Theme Object Failed")
return nil
}
switch themeType {
case "gtk":
return &Theme{
GtkTheme: value.(string),
IconTheme: t.IconTheme,
CursorTheme: t.CursorTheme,
SoundTheme: t.SoundTheme,
Background: t.Background,
FontName: t.FontName,
FontMono: t.FontMono,
FontSize: t.FontSize,
}
case "icon":
return &Theme{
GtkTheme: t.GtkTheme,
IconTheme: value.(string),
CursorTheme: t.CursorTheme,
SoundTheme: t.SoundTheme,
Background: t.Background,
FontName: t.FontName,
FontMono: t.FontMono,
FontSize: t.FontSize,
}
case "cursor":
return &Theme{
GtkTheme: t.GtkTheme,
IconTheme: t.IconTheme,
CursorTheme: value.(string),
SoundTheme: t.SoundTheme,
Background: t.Background,
FontName: t.FontName,
FontMono: t.FontMono,
FontSize: t.FontSize,
}
case "sound":
return &Theme{
GtkTheme: t.GtkTheme,
IconTheme: t.IconTheme,
CursorTheme: t.CursorTheme,
SoundTheme: value.(string),
Background: t.Background,
FontName: t.FontName,
FontMono: t.FontMono,
FontSize: t.FontSize,
}
case "background":
return &Theme{
GtkTheme: t.GtkTheme,
IconTheme: t.IconTheme,
CursorTheme: t.CursorTheme,
SoundTheme: t.SoundTheme,
Background: value.(string),
FontName: t.FontName,
FontMono: t.FontMono,
FontSize: t.FontSize,
}
case "font-standard":
return &Theme{
GtkTheme: t.GtkTheme,
IconTheme: t.IconTheme,
CursorTheme: t.CursorTheme,
SoundTheme: t.SoundTheme,
Background: t.Background,
FontName: value.(string),
FontMono: t.FontMono,
FontSize: t.FontSize,
}
case "font-mono":
return &Theme{
GtkTheme: t.GtkTheme,
IconTheme: t.IconTheme,
CursorTheme: t.CursorTheme,
SoundTheme: t.SoundTheme,
Background: t.Background,
FontName: t.FontName,
FontMono: value.(string),
FontSize: t.FontSize,
}
case "font-size":
return &Theme{
GtkTheme: t.GtkTheme,
IconTheme: t.IconTheme,
CursorTheme: t.CursorTheme,
SoundTheme: t.SoundTheme,
Background: t.Background,
FontName: t.FontName,
FontMono: t.FontMono,
FontSize: value.(int32),
}
}
return nil
}
func getThemeObjectList(list []string) []string {
list = sortNameByDeepin(list)
var tmp []string
for _, name := range list {
name = path.Base(name)
tmp = append(tmp, themeDBusPath+name)
}
return tmp
}
func touchFile() {
dir := path.Join(os.Getenv("HOME"), userThemePath)
filename := path.Join(dir, "__emit-signal__")
if !dutils.IsFileExist(filename) {
os.MkdirAll(filename, dirPermMode)
} else {
os.RemoveAll(filename)
}
}

View File

@ -1,340 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package background
import (
"fmt"
"os"
"path"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
"pkg.linuxdeepin.com/lib/glib-2.0"
"pkg.linuxdeepin.com/lib/graphic"
dutils "pkg.linuxdeepin.com/lib/utils"
"regexp"
"strings"
)
const (
settingsKeyPictureURI = "picture-uri"
defaultBgFile = "/usr/share/backgrounds/default_background.jpg"
dirModePerm = 0755
)
var (
errUserPict = fmt.Errorf("Get User Picture Failed")
)
type Background struct {
infoList []PathInfo
eventHandler func([]string)
watcher *dutils.WatchProxy
}
func NewBackground(handler func([]string)) *Background {
if handler == nil {
return nil
}
bg := &Background{}
bg.eventHandler = handler
sysList, userList := getDirInfoList()
bg.infoList = getBackgroundInfoList(sysList, userList)
bg.watcher = dutils.NewWatchProxy()
if bg.watcher != nil {
bg.watcher.SetFileList(getBgDirList(bg.infoList))
bg.watcher.SetEventHandler(bg.handleEvent)
go bg.watcher.StartWatch()
}
return bg
}
func (bg *Background) IsValueValid(value string) bool {
filename := dutils.DecodeURI(value)
if dutils.IsFileExist(filename) &&
graphic.IsSupportedImage(filename) {
return true
}
return false
}
func (bg *Background) GetInfoByName(name string) (PathInfo, error) {
return GetInfoByName(name, bg.infoList)
}
func (bg *Background) Set(uri string) error {
settings := NewGSettings("com.deepin.dde.personalization")
defer Unref(settings)
value := settings.GetString(settingsKeyPictureURI)
if isBackgroundSame(uri, value) {
return nil
}
if isBackgroundInInfoList(uri, bg.infoList) {
settings.SetString(settingsKeyPictureURI, uri)
return nil
}
// cp uri to user wallpapers
src := dutils.DecodeURI(uri)
if !dutils.IsFileExist(src) {
src = defaultBgFile
}
dir := getUserWallpaper()
if len(dir) == 0 {
return errUserPict
}
filename := path.Join(dir, path.Base(src))
err := dutils.CopyFile(src, filename)
if err != nil {
return err
}
settings.SetString(settingsKeyPictureURI,
dutils.EncodeURI(filename, dutils.SCHEME_FILE))
return nil
}
func (bg *Background) Delete(uri string) error {
for _, info := range bg.infoList {
if info.FilePath == uri {
if info.FileFlag == FileFlagUserOwned {
return os.RemoveAll(dutils.DecodeURI(info.FilePath))
}
break
}
}
return nil
}
func (bg *Background) Destroy() {
if bg.watcher == nil {
return
}
bg.watcher.EndWatch()
bg.watcher = nil
}
func (bg *Background) GetNameStrList() []string {
var list []string
for _, info := range bg.infoList {
list = append(list, info.FilePath)
}
return list
}
func (bg *Background) GetFlag(name string) int32 {
for _, info := range bg.infoList {
if name == info.FilePath {
return info.FileFlag
}
}
return -1
}
func (bg *Background) GetThumbnail(src string) string {
thumb := GetThumbnail(BackgroundThumbSeed, src)
if len(thumb) != 0 {
return thumb
}
GenerateThumbnail()
return dutils.DecodeURI(src)
}
func getBgDirList(infoList []PathInfo) []string {
var list []string
for _, info := range infoList {
dir := dutils.DecodeURI(info.FilePath)
list = append(list, dir)
}
return list
}
func getBackgroundInfoList(sysList, userList []PathInfo) []PathInfo {
var list []PathInfo
for _, dirInfo := range userList {
images := getImageList(dirInfo.FilePath)
for _, img := range images {
var info PathInfo
info.BaseName = path.Base(img)
info.FilePath = dutils.EncodeURI(img, dutils.SCHEME_FILE)
info.FileFlag = dirInfo.FileFlag
list = append(list, info)
}
}
for _, dirInfo := range sysList {
images := getImageList(dirInfo.FilePath)
for _, img := range images {
if isBackgroundInInfoList(img, list) {
continue
}
var info PathInfo
info.BaseName = path.Base(img)
info.FilePath = dutils.EncodeURI(img, dutils.SCHEME_FILE)
info.FileFlag = dirInfo.FileFlag
list = append(list, info)
}
}
return list
}
func getDirInfoList() ([]PathInfo, []PathInfo) {
sysList := []PathInfo{
{
BaseName: "",
FilePath: "/usr/share/backgrounds",
FileFlag: FileFlagSystemOwned,
},
}
tmpList := GetInfoListFromDirs([]PathInfo{
{
BaseName: "",
FilePath: "/usr/share/personalization/themes",
FileFlag: FileFlagSystemOwned,
},
}, []string{"wallpapers"})
for _, info := range tmpList {
info.FilePath = path.Join(info.FilePath, "wallpapers")
sysList = append(sysList, info)
}
homeDir := os.Getenv("HOME")
userList := []PathInfo{
{
BaseName: "",
FilePath: path.Join(homeDir, ".backgrounds"),
FileFlag: FileFlagUserOwned,
},
}
tmpList = GetInfoListFromDirs([]PathInfo{
{
BaseName: "",
FilePath: path.Join(homeDir, ".local/personalization/themes"),
FileFlag: FileFlagSystemOwned,
},
}, []string{"wallpapers"})
for _, info := range tmpList {
info.FilePath = path.Join(info.FilePath, "wallpapers")
userList = append(userList, info)
}
dir := getUserWallpaper()
if len(dir) != 0 {
userList = append(userList, PathInfo{
BaseName: "",
FilePath: dir,
FileFlag: FileFlagUserOwned,
})
}
return sysList, userList
}
func getUserWallpaper() string {
pict := glib.GetUserSpecialDir(
glib.UserDirectoryDirectoryPictures)
dir := path.Join(pict, "Wallpapers")
if !dutils.IsFileExist(dir) {
err := os.MkdirAll(dir, dirModePerm)
if err != nil {
return ""
}
}
return dir
}
func getImageList(dir string) []string {
var list []string
fp, err := os.Open(dir)
if err != nil {
return list
}
infos, err := fp.Readdir(0)
fp.Close()
if err != nil {
return list
}
for _, info := range infos {
if !info.Mode().IsRegular() {
continue
}
name := strings.ToLower(info.Name())
ok, _ := regexp.MatchString(`\.jpe?g$|\.png$`, name)
if !ok {
continue
}
list = append(list, path.Join(dir, info.Name()))
}
return list
}
func isBackgroundInInfoList(bg string, infos []PathInfo) bool {
for _, info := range infos {
if isBackgroundSame(bg, info.FilePath) {
return true
}
}
return false
}
func isBackgroundSame(uri1, uri2 string) bool {
bg1 := dutils.DecodeURI(uri1)
bg2 := dutils.DecodeURI(uri2)
md51, ok := dutils.SumFileMd5(bg1)
if !ok {
return false
}
md52, ok := dutils.SumFileMd5(bg2)
if !ok {
return false
}
if md51 == md52 {
return true
}
return false
}

View File

@ -1,51 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package background
import (
C "launchpad.net/gocheck"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
"testing"
)
type testWrapper struct{}
func init() {
C.Suite(&testWrapper{})
}
func Test(t *testing.T) {
C.TestingT(t)
}
func (*testWrapper) TestInfoList(c *C.C) {
userDirs := []PathInfo{
{
BaseName: "",
FilePath: "testdata/Wallpapers",
FileFlag: FileFlagUserOwned,
},
}
list := getBackgroundInfoList(nil, userDirs)
c.Check(len(list), C.Equals, 8)
}

View File

@ -1,38 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package background
import (
"github.com/howeyc/fsnotify"
)
func (bg *Background) handleEvent(ev *fsnotify.FileEvent) {
if ev == nil {
return
}
sysList, userList := getDirInfoList()
bg.infoList = getBackgroundInfoList(sysList, userList)
if bg.eventHandler != nil {
bg.eventHandler(bg.GetNameStrList())
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 822 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 708 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 665 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 KiB

View File

@ -1,47 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
#include <gtk/gtk.h>
#include "cursor.h"
static void
update_cursor()
{
GdkCursor *cursor = gdk_cursor_new(GDK_LEFT_PTR);
gdk_window_set_cursor(gdk_get_default_root_window(), cursor);
g_object_unref(G_OBJECT(cursor));
}
void
handle_cursor_changed()
{
static gboolean init = FALSE;
if (init) {
return;
}
init = TRUE;
GtkSettings* s = gtk_settings_get_default();
g_signal_connect(s, "notify::gtk-cursor-theme-name",
update_cursor, NULL);
}

View File

@ -1,28 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
#ifndef __CURSOR_H__
#define __CURSOR_H__
void handle_cursor_changed();
int apply_qt_cursor(const char *theme);
#endif

View File

@ -1,51 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package cursor_theme
import (
C "launchpad.net/gocheck"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
"testing"
)
type testWrapper struct{}
func init() {
C.Suite(&testWrapper{})
}
func Test(t *testing.T) {
C.TestingT(t)
}
func (*testWrapper) TestInfoList(c *C.C) {
userDirs := []PathInfo{
{
BaseName: "",
FilePath: "testdata",
FileFlag: FileFlagUserOwned,
},
}
list := getThemeList(nil, userDirs)
c.Check(len(list), C.Equals, 1)
}

View File

@ -1,239 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package cursor_theme
// #cgo pkg-config: x11 xcursor xfixes gtk+-3.0
// #cgo CFLAGS: -Wall -g
// #include <stdlib.h>
// #include "cursor.h"
import "C"
import (
"fmt"
"os"
"path"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
"pkg.linuxdeepin.com/dde-daemon/xsettings"
dutils "pkg.linuxdeepin.com/lib/utils"
"unsafe"
)
const (
systemThemePath = "/usr/share/icons"
userThemePath = ".icons"
systemThumbPath = "/usr/share/personalization/thumbnail/CursorThemes"
userThumbPath = ".local/share/personalization/thumbnail/CursorThemes"
dirModePerm = 0755
)
var (
themeConditions = []string{"cursors"}
errWriteCursor = fmt.Errorf("Write cursor theme failed")
errInvalidTheme = fmt.Errorf("Invalid Theme")
errFixedQtCursor = fmt.Errorf("Fixed Qt cursor failed")
)
type CursorTheme struct {
infoList []PathInfo
eventHandler func([]string)
watcher *dutils.WatchProxy
}
func NewCursorTheme(handler func([]string)) *CursorTheme {
if handler == nil {
return nil
}
cursor := &CursorTheme{}
cursor.eventHandler = handler
sysDirs, userDirs := getDirInfoList()
cursor.infoList = getThemeList(sysDirs, userDirs)
cursor.watcher = dutils.NewWatchProxy()
if cursor.watcher != nil {
cursor.watcher.SetFileList(getDirList())
cursor.watcher.SetEventHandler(cursor.handleEvent)
go cursor.watcher.StartWatch()
}
xsettings.InitXSettings()
// handle cursor changed by gtk+
C.handle_cursor_changed()
return cursor
}
func (cursor *CursorTheme) IsValueValid(value string) bool {
if IsNameInInfoList(value, cursor.infoList) {
return true
}
return false
}
func (cursor *CursorTheme) GetInfoByName(name string) (PathInfo, error) {
return GetInfoByName(name, cursor.infoList)
}
func (cursor *CursorTheme) Set(theme string) error {
if !IsNameInInfoList(theme, cursor.infoList) {
return errInvalidTheme
}
// Ignore xsettings error
setThemeViaXSettings(theme)
fixedQtCursor(theme)
dir := path.Join(os.Getenv("HOME"), ".icons/default")
if !dutils.IsFileExist(dir) {
err := os.MkdirAll(dir, dirModePerm)
if err != nil {
return err
}
}
filename := path.Join(dir, "index.theme")
ok := dutils.WriteKeyToKeyFile(filename,
"Icon Theme", "Inherits", theme)
if !ok {
return errWriteCursor
}
return nil
}
func (cursor *CursorTheme) Delete(name string) error {
for _, info := range cursor.infoList {
if info.BaseName == name {
if info.FileFlag == FileFlagUserOwned {
return os.RemoveAll(info.FilePath)
}
}
}
return nil
}
func (cursor *CursorTheme) Destroy() {
if cursor.watcher != nil {
return
}
cursor.watcher.EndWatch()
cursor.watcher = nil
xsettings.Unref()
}
func (cursor *CursorTheme) GetNameStrList() []string {
return GetBaseNameList(cursor.infoList)
}
func (cursor *CursorTheme) GetFlag(name string) int32 {
return GetFileFlagByName(name, cursor.infoList)
}
func (cursor *CursorTheme) GetThumbnail(theme string) string {
var thumb string
for _, info := range cursor.infoList {
if theme != info.BaseName {
continue
}
if info.FileFlag == FileFlagSystemOwned {
thumb = path.Join(systemThumbPath,
theme+"-thumbnail.png")
} else {
thumb = path.Join(os.Getenv("HOME"),
userThumbPath,
theme+"-thumbnail.png")
}
if dutils.IsFileExist(thumb) {
break
}
thumb = GetThumbnail("--cursor", info.FilePath)
break
}
return thumb
}
func setThemeViaXSettings(theme string) error {
return xsettings.SetString(xsettings.GtkStringCursorTheme, theme)
}
func fixedQtCursor(theme string) error {
ctheme := C.CString(theme)
ret := C.apply_qt_cursor(ctheme)
C.free(unsafe.Pointer(ctheme))
if ret != 0 {
return errFixedQtCursor
}
return nil
}
func getDirInfoList() ([]PathInfo, []PathInfo) {
sysDirs := []PathInfo{
{
BaseName: "",
FilePath: systemThemePath,
FileFlag: FileFlagSystemOwned,
},
}
userPath := path.Join(os.Getenv("HOME"), userThemePath)
userDirs := []PathInfo{
{
BaseName: "",
FilePath: userPath,
FileFlag: FileFlagUserOwned,
}}
return sysDirs, userDirs
}
func getThemeList(sysDirs, userDirs []PathInfo) []PathInfo {
cursorList := GetInfoListFromDirs(userDirs, themeConditions)
sysList := GetInfoListFromDirs(sysDirs, themeConditions)
for _, info := range sysList {
if IsNameInInfoList(info.BaseName, cursorList) {
continue
}
cursorList = append(cursorList, info)
}
return cursorList
}
func getDirList() []string {
var list []string
list = append(list, systemThemePath)
list = append(list, path.Join(os.Getenv("HOME"), userThemePath))
return list
}

View File

@ -1,38 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package cursor_theme
import (
"github.com/howeyc/fsnotify"
)
func (cursor *CursorTheme) handleEvent(ev *fsnotify.FileEvent) {
if ev == nil {
return
}
sysDirs, userDirs := getDirInfoList()
cursor.infoList = getThemeList(sysDirs, userDirs)
if cursor.eventHandler != nil {
cursor.eventHandler(cursor.GetNameStrList())
}
}

View File

@ -1,201 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
#include <stdio.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xcursor/Xcursor.h>
#include <X11/extensions/Xfixes.h>
static char* findAlternative(const char *name);
static XcursorImages* xcLoadImages(const char *theme,
const char *image, int size);
static unsigned long loadCursorHandle(Display *disp,
const char *theme, const char *name, int size);
static char*
findAlternative(const char *name)
{
if (!name) {
return NULL;
}
// Qt uses non-standard names for some core cursors.
// If Xcursor fails to load the cursor, Qt creates it with the correct name
// using the core protcol instead (which in turn calls Xcursor).
// We emulate that process here.
// Note that there's a core cursor called cross, but it's not the one Qt expects.
// Precomputed MD5 hashes for the hardcoded bitmap cursors in Qt and KDE.
// Note that the MD5 hash for left_ptr_watch is for the KDE version of that cursor.
static char* xcursor_alter[] = {
"cross", "crosshair",
"up_arrow", "center_ptr",
"wait", "watch",
"ibeam", "xterm",
"size_all", "fleur",
"pointing_hand", "hand2",
"size_ver", "00008160000006810000408080010102",
"size_hor", "028006030e0e7ebffc7f7070c0600140",
"size_bdiag", "c7088f0f3e6c8088236ef8e1e3e70000",
"size_fdiag", "fcf1c3c7cd4491d801f1e1c78f100000",
"whats_this", "d9ce0ab605698f320427677b458ad60b",
"split_h", "14fef782d02440884392942c11205230",
"split_v", "2870a09082c103050810ffdffffe0204",
"forbidden", "03b6e0fcb3499374a867c041f52298f0",
"left_ptr_watch", "3ecb610c1bf2410f44200f48c40d3599",
"hand2", "e29285e634086352946a0e7090d73106",
"openhand", "9141b49c8149039304290b508d208c40",
"closedhand", "05e88622050804100c20044008402080",
NULL};
int i;
for (i = 0; xcursor_alter[i] != NULL; i+=2) {
if (strcmp(xcursor_alter[i], name) == 0) {
return xcursor_alter[i+1];
}
}
return NULL;
}
static XcursorImages*
xcLoadImages(const char *theme, const char *image, int size)
{
if (!theme || !image) {
return NULL;
}
return XcursorLibraryLoadImages(image, theme, size);
}
static unsigned long
loadCursorHandle(Display *disp, const char *theme, const char *name, int size)
{
if (size == -1) {
size = XcursorGetDefaultSize(disp);
}
// Load the cursor images
XcursorImages *images = NULL;
images = xcLoadImages(theme, name, size);
if (!images) {
images = xcLoadImages(theme,
findAlternative(name), size);
if (!images) {
return 0;
}
}
unsigned long handle = (unsigned long)XcursorImagesLoadCursor(disp,
images);
XcursorImagesDestroy(images);
return handle;
}
int
apply_qt_cursor(const char *theme)
{
if (!theme) {
fprintf(stderr, "Cursor theme is NULL\n");
return -1;
}
/**
* Only running once
* Setting it by startdde is not effective, need to set again, why?
**/
static int running = 0;
if (running == 2) {
return 0;
}
/**
* Fixed Qt cursor not work when cursor theme changed.
* For details see: lxqt-config/lxqt-config-cursor
*
* XFixes multiple qt cursor name, a X Error will be occured.
* Now only XFixes qt cursor name 'left_ptr'
* Why?
**/
static char* list[] = {
// Qt cursors
"left_ptr",
// "up_arrow",
// "cross",
// "wait",
// "left_ptr_watch",
// "ibeam",
// "size_ver",
// "size_hor",
// "size_bdiag",
// "size_fdiag",
// "size_all",
// "split_v",
// "split_h",
// "pointing_hand",
// "openhand",
// "closedhand",
// "forbidden",
// "whats_this",
// X core cursors
// "X_cursor",
"right_ptr",
"hand1",
"hand2",
"watch",
"xterm",
"crosshair",
"left_ptr_watch",
// "center_ptr", // invalid Cursor parameter, why?
"sb_h_double_arrow",
"sb_v_double_arrow",
"fleur",
"top_left_corner",
"top_side",
"top_right_corner",
"right_side",
"bottom_right_corner",
"bottom_side",
"bottom_left_corner",
"left_side",
"question_arrow",
"pirate",
NULL};
Display *disp = XOpenDisplay(0);
if (!disp) {
fprintf(stderr, "Open display failed\n");
return -1;
}
int i;
for (i = 0; list[i] != NULL; i++) {
Cursor cursor = (Cursor)loadCursorHandle(disp, theme,
list[i], -1);
XFixesChangeCursorByName(disp, cursor, list[i]);
// FIXME: do we need to free the cursor?
}
XCloseDisplay(disp);
running++;
return 0;
}

View File

@ -1,51 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package deepin_theme
import (
C "launchpad.net/gocheck"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
"testing"
)
type testWrapper struct{}
func init() {
C.Suite(&testWrapper{})
}
func Test(t *testing.T) {
C.TestingT(t)
}
func (*testWrapper) TestInfoList(c *C.C) {
userDirs := []PathInfo{
{
BaseName: "",
FilePath: "testdata",
FileFlag: FileFlagUserOwned,
},
}
list := getThemeList(nil, userDirs)
c.Check(len(list), C.Equals, 2)
}

View File

@ -1,191 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package deepin_theme
import (
"fmt"
"os"
"path"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
dutils "pkg.linuxdeepin.com/lib/utils"
)
const (
systemThemePath = "/usr/share/personalization/themes"
userThemePath = ".local/share/personalization/themes"
)
var (
themeConditions = []string{"theme.ini"}
errInvalidTheme = fmt.Errorf("Invalid Theme")
)
type DeepinTheme struct {
infoList []PathInfo
eventHandler func([]string)
watcher *dutils.WatchProxy
}
func NewDeepinTheme(handler func([]string)) *DeepinTheme {
if handler == nil {
return nil
}
dtheme := &DeepinTheme{}
sysDirs, userDirs := getDirInfoList()
dtheme.infoList = getThemeList(sysDirs, userDirs)
dtheme.eventHandler = handler
dtheme.watcher = dutils.NewWatchProxy()
if dtheme.watcher != nil {
dtheme.watcher.SetFileList(getDirList())
dtheme.watcher.SetEventHandler(dtheme.handleEvent)
go dtheme.watcher.StartWatch()
}
return dtheme
}
func (dtheme *DeepinTheme) IsValueValid(value string) bool {
for _, info := range dtheme.infoList {
if info.BaseName == value {
return true
}
}
return false
}
func (dtheme *DeepinTheme) GetInfoByName(name string) (PathInfo, error) {
return GetInfoByName(name, dtheme.infoList)
}
func (dtheme *DeepinTheme) Set(name string) error {
if !dtheme.IsValueValid(name) {
return errInvalidTheme
}
settings := NewGSettings("com.deepin.dde.personalization")
defer Unref(settings)
value := settings.GetString("current-theme")
if value == name {
return nil
}
settings.SetString("current-theme", name)
return nil
}
func (dtheme *DeepinTheme) Delete(name string) error {
for _, info := range dtheme.infoList {
if info.BaseName == name {
if info.FileFlag == FileFlagUserOwned {
return os.RemoveAll(info.FilePath)
}
break
}
}
return nil
}
func (dtheme *DeepinTheme) Destroy() {
if dtheme.watcher == nil {
return
}
dtheme.watcher.EndWatch()
dtheme.watcher = nil
}
func (dtheme *DeepinTheme) GetNameStrList() []string {
return GetBaseNameList(dtheme.infoList)
}
func (dtheme *DeepinTheme) GetFlag(value string) int32 {
return GetFileFlagByName(value, dtheme.infoList)
}
func (dtheme *DeepinTheme) GetThumbnail(value string) string {
var thumb string
for _, info := range dtheme.infoList {
if info.BaseName == value {
thumb = path.Join(info.FilePath, "thumbnail.png")
break
}
}
if dutils.IsFileExist(thumb) {
return thumb
}
return ""
}
func getDirInfoList() ([]PathInfo, []PathInfo) {
sysDirs := []PathInfo{
{
BaseName: "",
FilePath: systemThemePath,
FileFlag: FileFlagSystemOwned,
},
}
userDirs := []PathInfo{
{
BaseName: "",
FilePath: path.Join(os.Getenv("HOME"), userThemePath),
FileFlag: FileFlagUserOwned,
},
}
return sysDirs, userDirs
}
func getThemeList(sysDirs, userDirs []PathInfo) []PathInfo {
infoList := GetInfoListFromDirs(userDirs, themeConditions)
sysList := GetInfoListFromDirs(sysDirs, themeConditions)
for _, info := range sysList {
if IsNameInInfoList(info.BaseName, infoList) {
continue
}
infoList = append(infoList, info)
}
return infoList
}
func getDirList() []string {
var list []string
list = append(list, systemThemePath)
userDir := path.Join(os.Getenv("HOME"), userThemePath)
if !dutils.IsFileExist(userDir) {
os.MkdirAll(userDir, 0755)
}
list = append(list, userDir)
return list
}

View File

@ -1,38 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package deepin_theme
import (
"github.com/howeyc/fsnotify"
)
func (dtheme *DeepinTheme) handleEvent(ev *fsnotify.FileEvent) {
if ev == nil {
return
}
sysDirs, userDirs := getDirInfoList()
dtheme.infoList = getThemeList(sysDirs, userDirs)
if dtheme.eventHandler != nil {
dtheme.eventHandler(dtheme.GetNameStrList())
}
}

View File

@ -1,75 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package factory
import (
"pkg.linuxdeepin.com/dde-daemon/appearance/factory/background"
"pkg.linuxdeepin.com/dde-daemon/appearance/factory/cursor_theme"
"pkg.linuxdeepin.com/dde-daemon/appearance/factory/deepin_theme"
"pkg.linuxdeepin.com/dde-daemon/appearance/factory/greeter_theme"
"pkg.linuxdeepin.com/dde-daemon/appearance/factory/gtk_theme"
"pkg.linuxdeepin.com/dde-daemon/appearance/factory/icon_theme"
"pkg.linuxdeepin.com/dde-daemon/appearance/factory/sound_theme"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
)
type FactoryInterface interface {
Set(value string) error
Delete(value string) error
Destroy()
GetFlag(value string) int32
GetNameStrList() []string
GetThumbnail(value string) string
IsValueValid(value string) bool
GetInfoByName(name string) (PathInfo, error)
}
const (
ObjectTypeGtk int32 = 0
ObjectTypeIcon = 1
ObjectTypeCursor = 2
ObjectTypeSound = 3
ObjectTypeGreeter = 4
ObjectTypeBackground = 5
ObjectTypeDeepinTheme = 6
)
func NewFactory(objType int32, handler func([]string)) FactoryInterface {
switch objType {
case ObjectTypeGtk:
return gtk_theme.NewGtkTheme(handler)
case ObjectTypeIcon:
return icon_theme.NewIconTheme(handler)
case ObjectTypeCursor:
return cursor_theme.NewCursorTheme(handler)
case ObjectTypeSound:
return sound_theme.NewSoundTheme(handler)
case ObjectTypeGreeter:
return greeter_theme.NewGreeterTheme(handler)
case ObjectTypeBackground:
return background.NewBackground(handler)
case ObjectTypeDeepinTheme:
return deepin_theme.NewDeepinTheme(handler)
}
return nil
}

View File

@ -1,51 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package greeter_theme
import (
C "launchpad.net/gocheck"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
"testing"
)
type testWrapper struct{}
func init() {
C.Suite(&testWrapper{})
}
func Test(t *testing.T) {
C.TestingT(t)
}
func (*testWrapper) TestInfoList(c *C.C) {
userDirs := []PathInfo{
{
BaseName: "",
FilePath: "testdata",
FileFlag: FileFlagUserOwned,
},
}
list := getThemeList(nil, userDirs)
c.Check(len(list), C.Equals, 1)
}

View File

@ -1,189 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package greeter_theme
import (
"dbus/com/deepin/api/greeterutils"
"fmt"
"os"
"path"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
dutils "pkg.linuxdeepin.com/lib/utils"
)
const (
systemThemePath = "/usr/share/personalization/greeter-theme"
userThemePath = ".local/share/personalization/greeter-theme"
)
var (
themeConditions = []string{"thumb.png"}
errInvalidUser = fmt.Errorf("Invalid User")
errInvalidTheme = fmt.Errorf("Invalid Theme")
)
type GreeterTheme struct {
infoList []PathInfo
eventHandler func([]string)
watcher *dutils.WatchProxy
}
func NewGreeterTheme(handler func([]string)) *GreeterTheme {
if handler == nil {
return nil
}
greeter := &GreeterTheme{}
sysDirs, userDirs := getDirInfoList()
greeter.infoList = getThemeList(sysDirs, userDirs)
greeter.eventHandler = handler
greeter.watcher = dutils.NewWatchProxy()
if greeter.watcher != nil {
greeter.watcher.SetFileList(getDirList())
greeter.watcher.SetEventHandler(greeter.handleEvent)
go greeter.watcher.StartWatch()
}
return greeter
}
func (greeter *GreeterTheme) IsValueValid(value string) bool {
if IsNameInInfoList(value, greeter.infoList) {
return true
}
return false
}
func (greeter *GreeterTheme) GetInfoByName(name string) (PathInfo, error) {
return GetInfoByName(name, greeter.infoList)
}
func (greeter *GreeterTheme) Set(name string) error {
if !IsNameInInfoList(name, greeter.infoList) {
return errInvalidTheme
}
username := dutils.GetUserName()
homeDir := os.Getenv("HOME")
if homeDir == path.Join("/tmp", username) {
return errInvalidUser
}
greeterObj, err := greeterutils.NewGreeterUtils(
"com.deepin.api.GreeterUtils",
"/com/deepin/api/GreeterUtils")
if err != nil {
return err
}
return greeterObj.SetGreeterTheme(username, name)
}
func (greeter *GreeterTheme) Delete(name string) error {
for _, info := range greeter.infoList {
if info.BaseName == name {
if info.FileFlag == FileFlagUserOwned {
return os.RemoveAll(info.FilePath)
}
break
}
}
return nil
}
func (greeter *GreeterTheme) Destroy() {
if greeter.watcher == nil {
return
}
greeter.watcher.EndWatch()
greeter.watcher = nil
}
func (greeter *GreeterTheme) GetNameStrList() []string {
return GetBaseNameList(greeter.infoList)
}
func (greeter *GreeterTheme) GetFlag(name string) int32 {
return GetFileFlagByName(name, greeter.infoList)
}
func (greeter *GreeterTheme) GetThumbnail(theme string) string {
var thumb string
for _, info := range greeter.infoList {
if theme == info.BaseName {
thumb = path.Join(info.FilePath, "thumb.png")
thumb = dutils.EncodeURI(thumb, dutils.SCHEME_FILE)
break
}
}
return thumb
}
func getDirInfoList() ([]PathInfo, []PathInfo) {
sysDirs := []PathInfo{
{
BaseName: "",
FilePath: systemThemePath,
FileFlag: FileFlagSystemOwned,
},
}
userPath := path.Join(os.Getenv("HOME"), userThemePath)
userDirs := []PathInfo{
{
BaseName: "",
FilePath: userPath,
FileFlag: FileFlagUserOwned,
},
}
return sysDirs, userDirs
}
func getThemeList(sysDirs, userDirs []PathInfo) []PathInfo {
infoList := GetInfoListFromDirs(userDirs, themeConditions)
sysList := GetInfoListFromDirs(sysDirs, themeConditions)
for _, info := range sysList {
if IsNameInInfoList(info.BaseName, infoList) {
continue
}
infoList = append(infoList, info)
}
return infoList
}
func getDirList() []string {
var list []string
list = append(list, systemThemePath)
list = append(list, path.Join(os.Getenv("HOME"), userThemePath))
return list
}

View File

@ -1,38 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package greeter_theme
import (
"github.com/howeyc/fsnotify"
)
func (greeter *GreeterTheme) handleEvent(ev *fsnotify.FileEvent) {
if ev == nil {
return
}
sysDirs, userDirs := getDirInfoList()
greeter.infoList = getThemeList(sysDirs, userDirs)
if greeter.eventHandler != nil {
greeter.eventHandler(greeter.GetNameStrList())
}
}

View File

@ -1,55 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package gtk_theme
import (
C "launchpad.net/gocheck"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
"testing"
)
type testWrapper struct{}
func init() {
C.Suite(&testWrapper{})
}
func Test(t *testing.T) {
C.TestingT(t)
}
func (*testWrapper) TestInfoList(c *C.C) {
userDirs := []PathInfo{
{
BaseName: "",
FilePath: "testdata",
FileFlag: FileFlagUserOwned,
},
}
list := getThemeList(nil, userDirs)
c.Check(len(list), C.Equals, 2)
}
func (*testWrapper) TestWriteConfig(c *C.C) {
c.Check(setQt4Theme("testdata/Trolltech.conf"), C.Not(C.NotNil))
}

View File

@ -1,237 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package gtk_theme
import (
"fmt"
"os"
"path"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
"pkg.linuxdeepin.com/dde-daemon/xsettings"
dutils "pkg.linuxdeepin.com/lib/utils"
)
const (
systemThemePath = "/usr/share/themes"
userThemePath = ".themes"
systemThumbPath = "/usr/share/personalization/thumbnail/WindowThemes"
userThumbPath = ".local/share/personalization/thumbnail/WindowThemes"
wmGSettingsSchema = "org.gnome.desktop.wm.preferences"
)
var (
themeConditions = []string{"gtk-2.0", "gtk-3.0", "metacity-1"}
errInvalidTheme = fmt.Errorf("Invalid Theme")
errReadKey = fmt.Errorf("Read key from keyfile failed")
errWriteValue = fmt.Errorf("Write value to keyfile failed")
)
type GtkTheme struct {
infoList []PathInfo
eventHandler func([]string)
watcher *dutils.WatchProxy
}
func NewGtkTheme(handler func([]string)) *GtkTheme {
if handler == nil {
return nil
}
gtk := &GtkTheme{}
gtk.eventHandler = handler
sysDirs, userDirs := getDirInfoList()
gtk.infoList = getThemeList(sysDirs, userDirs)
gtk.watcher = dutils.NewWatchProxy()
if gtk.watcher != nil {
gtk.watcher.SetFileList(getDirList())
gtk.watcher.SetEventHandler(gtk.handleEvent)
go gtk.watcher.StartWatch()
}
xsettings.InitXSettings()
return gtk
}
func (gtk *GtkTheme) IsValueValid(value string) bool {
if IsNameInInfoList(value, gtk.infoList) {
return true
}
return false
}
func (gtk *GtkTheme) GetInfoByName(name string) (PathInfo, error) {
return GetInfoByName(name, gtk.infoList)
}
func (gtk *GtkTheme) Set(theme string) error {
if !IsNameInInfoList(theme, gtk.infoList) {
return errInvalidTheme
}
err := setThemeViaXSettings(theme)
if err != nil {
return err
}
setCompizTheme(theme)
setQt4Theme(GetUserQt4Config())
return nil
}
func (gtk *GtkTheme) Delete(name string) error {
for _, info := range gtk.infoList {
if info.BaseName == name {
if info.FileFlag == FileFlagUserOwned {
return os.RemoveAll(info.FilePath)
}
}
}
return nil
}
func (gtk *GtkTheme) Destroy() {
if gtk.watcher == nil {
return
}
gtk.watcher.EndWatch()
gtk.watcher = nil
xsettings.Unref()
}
func (gtk *GtkTheme) GetNameStrList() []string {
return GetBaseNameList(gtk.infoList)
}
func (gtk *GtkTheme) GetFlag(theme string) int32 {
return GetFileFlagByName(theme, gtk.infoList)
}
func (gtk *GtkTheme) GetThumbnail(theme string) string {
var thumb string
for _, info := range gtk.infoList {
if theme != info.BaseName {
continue
}
if info.FileFlag == FileFlagSystemOwned {
thumb = path.Join(systemThumbPath,
theme+"-thumbnail.png")
} else {
thumb = path.Join(os.Getenv("HOME"),
userThumbPath,
theme+"-thumbnail.png")
}
if dutils.IsFileExist(thumb) {
break
}
thumb = GetThumbnail("--gtk", info.FilePath)
break
}
return thumb
}
func getDirInfoList() ([]PathInfo, []PathInfo) {
sysDirs := []PathInfo{
{
BaseName: "",
FilePath: systemThemePath,
FileFlag: FileFlagSystemOwned,
},
}
userPath := path.Join(os.Getenv("HOME"), userThemePath)
userDirs := []PathInfo{
{
BaseName: "",
FilePath: userPath,
FileFlag: FileFlagUserOwned,
},
}
return sysDirs, userDirs
}
func getThemeList(sysDirs, userDirs []PathInfo) []PathInfo {
gtkList := GetInfoListFromDirs(userDirs, themeConditions)
sysList := GetInfoListFromDirs(sysDirs, themeConditions)
for _, info := range sysList {
if IsNameInInfoList(info.BaseName, gtkList) {
continue
}
gtkList = append(gtkList, info)
}
return gtkList
}
func setThemeViaXSettings(theme string) error {
return xsettings.SetString(xsettings.NetStringThemeName, theme)
}
func setQt4Theme(config string) error {
value, _ := dutils.ReadKeyFromKeyFile(config, "Qt", "style", "")
if value == "GTK+" {
return nil
}
ok := dutils.WriteKeyToKeyFile(config, "Qt", "style", "GTK+")
if !ok {
return errWriteValue
}
return nil
}
func setCompizTheme(theme string) {
settings := CheckAndNewGSettings(wmGSettingsSchema)
if settings == nil {
return
}
settings.SetString("theme", theme)
//Unref(settings)
}
func getDirList() []string {
list := []string{}
list = append(list, systemThemePath)
userDir := path.Join(os.Getenv("HOME"), userThemePath)
if !dutils.IsFileExist(userDir) {
os.MkdirAll(userDir, 0755)
}
list = append(list, userDir)
return list
}

View File

@ -1,38 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package gtk_theme
import (
"github.com/howeyc/fsnotify"
)
func (gtk *GtkTheme) handleEvent(ev *fsnotify.FileEvent) {
if ev == nil {
return
}
sysDirs, userDirs := getDirInfoList()
gtk.infoList = getThemeList(sysDirs, userDirs)
if gtk.eventHandler != nil {
gtk.eventHandler(gtk.GetNameStrList())
}
}

View File

@ -1,138 +0,0 @@
[Qt]
font="WenQuanYi Micro Hei ,11,-1,5,50,0,0,0,0,0"
cursorFlashTime=1200
filedialog="@ByteArray(\0\0\0\xbe\0\0\0\x3\0\0\0\x1e\0\0\0\xff\0\0\0\0\0\0\0\x2\0\0\0M\0\0\xe\0\x1\0\0\0\x4\x1\0\0\0\x1\0\0\0\x2\0\0\0\x5\x66ile:\0\0\0\x11\x66ile:///home/iwen\0\0\0\x3\0\0\0,\0/\0h\0o\0m\0\x65\0/\0i\0w\0\x65\0n\0/\0.\0g\0o\0l\0\x64\0\x65\0n\0\x64\0i\0\x63\0t\0\0\0\x14\0/\0h\0o\0m\0\x65\0/\0i\0w\0\x65\0n\0\0\0 \0/\0h\0o\0m\0\x65\0/\0i\0w\0\x65\0n\0/\0\x43\0l\0o\0u\0\x64\0\0\0 \0/\0h\0o\0m\0\x65\0/\0i\0w\0\x65\0n\0/\0\x43\0l\0o\0u\0\x64\0\0\0~\0\0\0\xff\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x2 \0\0\0\x4\x1\x1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x64\xff\xff\xff\xff\0\0\0\x81\0\0\0\0\0\0\0\x4\0\0\x1\x1c\0\0\0\x1\0\0\0\0\0\0\0\x43\0\0\0\x1\0\0\0\0\0\0\0H\0\0\0\x1\0\0\0\0\0\0\0y\0\0\0\x1\0\0\0\0\0\0\0\x1)"
Palette\active=#000000, #dcdad5, #ffffff, #cbc7c4, #b8b6b2, #b8b5b2, #000000, #ffffff, #000000, #ffffff, #dcdad5, #a9a8a4, #4b6983, #ffffff, #0000ff, #ff00ff, #efefef, #000000, #ffffdc, #000000
Palette\inactive=#000000, #dcdad5, #ffffff, #cbc7c4, #b8b6b2, #b8b5b2, #000000, #ffffff, #000000, #ffffff, #dcdad5, #a9a8a4, #9c9a94, #ffffff, #0000ff, #ff00ff, #efefef, #000000, #ffffdc, #000000
Palette\disabled=#6e6d6a, #dcdad5, #ffffff, #cbc7c4, #b8b6b2, #b8b5b2, #6e6d6a, #ffffff, #6e6d6a, #ffffff, #dcdad5, #a9a8a4, #838383, #ffffff, #0000ff, #ff00ff, #efefef, #000000, #ffffdc, #000000
fontPath=@Invalid()
embedFonts=true
style=GTK+
doubleClickInterval=400
wheelScrollLines=3
resolveSymlinks=false
globalStrut\width=0
globalStrut\height=0
useRtlExtensions=false
XIMInputStyle=On The Spot
DefaultInputMethod=xim
audiosink=Auto
videomode=Auto
GUIEffects=none
[Qt%20Plugin%20Cache%204.8.false]
usr\lib\x86_64-linux-gnu\qt4\plugins\inputmethods\libqimsw-multi.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:13
usr\lib\x86_64-linux-gnu\qt4\plugins\inputmethods\qtim-fcitx.so=40806, 1, x86_64 linux g++-4 full-config, 2014-03-11T11:51:12
usr\lib\x86_64-linux-gnu\qt4\plugins\iconengines\libqsvgicon.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:20
usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqgif.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:13
usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqico.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:13
usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqjpeg.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:13
usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqmng.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:13
usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqsvg.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:20
usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqtga.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:13
usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqtiff.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:13
usr\lib\i386-linux-gnu\qt4\plugins\inputmethods\libqimsw-multi.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:19
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqgif.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqico.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqjpeg.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:19
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqmng.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqtga.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqtiff.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqconnmanbearer.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:23
usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqgenericbearer.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:23
usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqnmbearer.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:22
usr\lib\x86_64-linux-gnu\qt4\plugins\bearer\libqconnmanbearer.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:16
usr\lib\x86_64-linux-gnu\qt4\plugins\bearer\libqgenericbearer.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:16
usr\lib\x86_64-linux-gnu\qt4\plugins\bearer\libqnmbearer.so=40806, 0, x86_64 linux g++-4 full-config, 2014-03-12T22:24:16
usr\lib\x86_64-linux-gnu\qt4\plugins\gui_platform\libqtlxqt.so=40806, 1, x86_64 linux g++-4 full-config, 2014-07-18T17:42:25
usr\lib\kde4\plugins\styles\qtcurve.so=40804, 0, x86_64 linux g++-4 full-config, 2013-05-24T07:25:44
usr\lib\i386-linux-gnu\qt4\plugins\systemtrayicon\libsni-qt.so=40802, 1, i386 linux g++-4 full-config, 2012-07-31T19:32:05
[Qt%20Factory%20Cache%204.8]
com.trolltech.Qt.QInputContextFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\inputmethods\libqimsw-multi.so=2014-03-12T22:24:13, imsw-multi
com.trolltech.Qt.QInputContextFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\inputmethods\qtim-fcitx.so=2014-03-11T11:51:12, fcitx
com.trolltech.Qt.QIconEngineFactoryInterfaceV2%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\iconengines\libqsvgicon.so=2014-03-12T22:24:20, svg, svgz, svg.gz
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqgif.so=2014-03-12T22:24:13, gif
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqico.so=2014-03-12T22:24:13, ico
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqjpeg.so=2014-03-12T22:24:13, jpeg, jpg
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqmng.so=2014-03-12T22:24:13, mng
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqsvg.so=2014-03-12T22:24:20, svg, svgz
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqtga.so=2014-03-12T22:24:13, tga
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\imageformats\libqtiff.so=2014-03-12T22:24:13, tiff, tif
com.trolltech.Qt.QInputContextFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\inputmethods\libqimsw-multi.so=2014-03-12T22:28:19, imsw-multi
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqgif.so=2014-03-12T22:28:20, gif
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqico.so=2014-03-12T22:28:20, ico
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqjpeg.so=2014-03-12T22:28:19, jpeg, jpg
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqmng.so=2014-03-12T22:28:20, mng
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqtga.so=2014-03-12T22:28:20, tga
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqtiff.so=2014-03-12T22:28:20, tiff, tif
com.trolltech.Qt.QBearerEngineFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqconnmanbearer.so=2014-03-12T22:28:23, connman
com.trolltech.Qt.QBearerEngineFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqgenericbearer.so=2014-03-12T22:28:23, generic
com.trolltech.Qt.QBearerEngineFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqnmbearer.so=2014-03-12T22:28:22, networkmanager
com.trolltech.Qt.QIconEngineFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\iconengines\libqsvgicon.so=2014-03-12T22:24:20
com.trolltech.Qt.QBearerEngineFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\bearer\libqconnmanbearer.so=2014-03-12T22:24:16, connman
com.trolltech.Qt.QBearerEngineFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\bearer\libqgenericbearer.so=2014-03-12T22:24:16, generic
com.trolltech.Qt.QBearerEngineFactoryInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\bearer\libqnmbearer.so=2014-03-12T22:24:16, networkmanager
com.nokia.qt.QGuiPlatformPluginInterface%3A\usr\lib\x86_64-linux-gnu\qt4\plugins\gui_platform\libqtlxqt.so=2014-07-18T17:42:25, lxqt
com.trolltech.Qt.QStyleFactoryInterface%3A\usr\lib\kde4\plugins\styles\qtcurve.so=2013-05-24T07:25:44, QtCurve
com.nokia.qt.QSystemTrayIconSysFactoryInterface%3A\usr\lib\i386-linux-gnu\qt4\plugins\systemtrayicon\libsni-qt.so=2012-07-31T19:32:05, default
[Qt%20Plugin%20Cache%204.7.false]
opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqgif.so=40704, 0, i386 linux g++-4 full-config, 2014-03-17T12:12:33
opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqico.so=40704, 0, i386 linux g++-4 full-config, 2014-03-17T12:12:33
opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqjpeg.so=40704, 0, i386 linux g++-4 full-config, 2014-03-17T12:12:33
opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqmng.so=40704, 0, i386 linux g++-4 full-config, 2014-03-17T12:12:33
opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqtiff.so=40704, 0, i386 linux g++-4 full-config, 2014-03-17T12:12:33
usr\lib\i386-linux-gnu\qt4\plugins\inputmethods\libqimsw-multi.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:19
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqgif.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqico.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqjpeg.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:19
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqmng.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqtga.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqtiff.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqconnmanbearer.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:23
usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqgenericbearer.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:23
usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqnmbearer.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:22
usr\lib\i386-linux-gnu\qt4\plugins\codecs\libqcncodecs.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:06
usr\lib\i386-linux-gnu\qt4\plugins\codecs\libqjpcodecs.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:07
usr\lib\i386-linux-gnu\qt4\plugins\codecs\libqkrcodecs.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:06
usr\lib\i386-linux-gnu\qt4\plugins\codecs\libqtwcodecs.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:06
opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqcncodecs.so=40704, 0, i386 linux g++-4 full-config, 2014-03-17T12:12:32
opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqjpcodecs.so=40704, 0, i386 linux g++-4 full-config, 2014-03-17T12:12:32
opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqkrcodecs.so=40704, 0, i386 linux g++-4 full-config, 2014-03-17T12:12:32
opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqtwcodecs.so=40704, 0, i386 linux g++-4 full-config, 2014-03-17T12:12:32
[Qt%20Factory%20Cache%204.7]
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqgif.so=2014-10-21T04:50:39, gif
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqico.so=2014-10-21T04:50:39, ico
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqjpeg.so=2014-10-21T04:50:39, jpeg, jpg
com.trolltech.Qt.QTextCodecFactoryInterface%3A\opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqcncodecs.so=2014-10-21T04:50:39, GB18030, GBK, GB2312, gb2312.1980-0, gbk-0, CP936, MS936, windows-936, MIB: 114, MIB: 113, MIB: 2025, MIB: 57, MIB: -113
com.trolltech.Qt.QTextCodecFactoryInterface%3A\opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqjpcodecs.so=2014-10-21T04:50:39, EUC-JP, ISO-2022-JP, Shift_JIS, jisx0201*-0, jisx0208*-0, JIS7, SJIS, MS_Kanji, MIB: 18, MIB: 39, MIB: 17, MIB: 15, MIB: 63
com.trolltech.Qt.QTextCodecFactoryInterface%3A\opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqkrcodecs.so=2014-10-21T04:50:39, EUC-KR, ksc5601.1987-0, cp949, MIB: 38, MIB: 36, MIB: -949
com.trolltech.Qt.QTextCodecFactoryInterface%3A\opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqtwcodecs.so=2014-10-21T04:50:39, Big5, Big5-HKSCS, big5-0, big5hkscs-0, Big5-ETen, CP950, MIB: 2026, MIB: 2101, MIB: -2026, MIB: -2101
com.trolltech.Qt.QImageIOHandlerFactoryInterface%3A\opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqtiff.so=2014-10-21T04:50:39, tiff, tif
[Qt%20Plugin%20Cache%204.7.debug]
opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqgif.so=40704, 1, i386 linux g++-4 full-config, 2014-10-21T04:50:39
opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqico.so=40704, 1, i386 linux g++-4 full-config, 2014-10-21T04:50:39
opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqjpeg.so=40704, 1, i386 linux g++-4 full-config, 2014-10-21T04:50:39
opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqmng.so=40704, 1, i386 linux g++-4 full-config, 2014-10-21T04:50:39
opt\kingsoft\wps-office\office6\qt\plugins\imageformats\libqtiff.so=40704, 1, i386 linux g++-4 full-config, 2014-10-21T04:50:39
usr\lib\i386-linux-gnu\qt4\plugins\inputmethods\libqimsw-multi.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:19
usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqconnmanbearer.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:23
usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqgenericbearer.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:23
usr\lib\i386-linux-gnu\qt4\plugins\bearer\libqnmbearer.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:22
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqgif.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqico.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqjpeg.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:19
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqmng.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqtga.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\imageformats\libqtiff.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:20
usr\lib\i386-linux-gnu\qt4\plugins\codecs\libqcncodecs.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:06
usr\lib\i386-linux-gnu\qt4\plugins\codecs\libqjpcodecs.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:07
usr\lib\i386-linux-gnu\qt4\plugins\codecs\libqkrcodecs.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:06
usr\lib\i386-linux-gnu\qt4\plugins\codecs\libqtwcodecs.so=40806, 0, i386 linux g++-4 full-config, 2014-03-12T22:28:06
opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqcncodecs.so=40704, 1, i386 linux g++-4 full-config, 2014-10-21T04:50:39
opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqjpcodecs.so=40704, 1, i386 linux g++-4 full-config, 2014-10-21T04:50:39
opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqkrcodecs.so=40704, 1, i386 linux g++-4 full-config, 2014-10-21T04:50:39
opt\kingsoft\wps-office\office6\qt\plugins\codecs\libqtwcodecs.so=40704, 1, i386 linux g++-4 full-config, 2014-10-21T04:50:39

View File

@ -1,38 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package icon_theme
import (
"github.com/howeyc/fsnotify"
)
func (icon *IconTheme) handleEvent(ev *fsnotify.FileEvent) {
if ev == nil {
return
}
sysDirs, userDirs := getDirInfoList()
icon.infoList = getThemeList(sysDirs, userDirs)
if icon.eventHandler != nil {
icon.eventHandler(icon.GetNameStrList())
}
}

View File

@ -1,83 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package icon_theme
import (
C "launchpad.net/gocheck"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
"testing"
)
type testWrapper struct{}
func init() {
C.Suite(&testWrapper{})
}
func Test(t *testing.T) {
C.TestingT(t)
}
func (*testWrapper) TestInfoList(c *C.C) {
userDirs := []PathInfo{
{
BaseName: "",
FilePath: "testdata",
FileFlag: FileFlagUserOwned,
},
}
list := getThemeList(nil, userDirs)
c.Check(len(list), C.Equals, 1)
}
func (*testWrapper) TestIconHidden(c *C.C) {
type testEnable struct {
filename string
ret bool
}
var infos = []testEnable{
{
filename: "testdata/index.theme",
ret: true,
},
{
filename: "testdata/index2.theme",
ret: false,
},
{
filename: "testdata/index3.theme",
ret: false,
},
{
filename: "testdata/index4.theme",
ret: false,
},
}
for _, info := range infos {
c.Check(isIconHidden(info.filename), C.Equals, info.ret)
c.Check(hasDirectories(info.filename),
C.Equals, info.ret)
}
}

View File

@ -1,247 +0,0 @@
/**
* Copyright (c) 2011 ~ 2014 Deepin, Inc.
* 2013 ~ 2014 jouyouyun
*
* Author: jouyouyun <jouyouwen717@gmail.com>
* Maintainer: jouyouyun <jouyouwen717@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
**/
package icon_theme
import (
"fmt"
"os"
"path"
. "pkg.linuxdeepin.com/dde-daemon/appearance/utils"
"pkg.linuxdeepin.com/dde-daemon/xsettings"
dutils "pkg.linuxdeepin.com/lib/utils"
)
const (
systemThemePath = "/usr/share/icons"
userThemePath = ".icons"
systemThumbPath = "/usr/share/personalization/thumbnail/IconThemes"
userThumbPath = ".local/share/personalization/thumbnail/IconThemes"
)
var (
themeConditions = []string{"index.theme"}
errInvalidTheme = fmt.Errorf("Invalid Theme")
)
type IconTheme struct {
infoList []PathInfo
eventHandler func([]string)
watcher *dutils.WatchProxy
}
func NewIconTheme(handler func([]string)) *IconTheme {
if handler == nil {
return nil
}
icon := &IconTheme{}
icon.eventHandler = handler
sysDirs, userDirs := getDirInfoList()
icon.infoList = getThemeList(sysDirs, userDirs)
icon.watcher = dutils.NewWatchProxy()
if icon.watcher != nil {
icon.watcher.SetFileList(getDirList())
icon.watcher.SetEventHandler(icon.handleEvent)
go icon.watcher.StartWatch()
}
xsettings.InitXSettings()
return icon
}
func (icon *IconTheme) IsValueValid(value string) bool {
if IsNameInInfoList(value, icon.infoList) {
return true
}
return false
}
func (icon *IconTheme) GetInfoByName(name string) (PathInfo, error) {
return GetInfoByName(name, icon.infoList)
}
func (icon *IconTheme) Set(theme string) error {
if !IsNameInInfoList(theme, icon.infoList) {
return errInvalidTheme
}
err := setThemeViaXSettings(theme)
if err != nil {
return err
}
return nil
}
func (icon *IconTheme) Delete(name string) error {
for _, info := range icon.infoList {
if info.BaseName == name {
if info.FileFlag == FileFlagUserOwned {
return os.RemoveAll(info.FilePath)
}
}
}
return nil
}
func (icon *IconTheme) Destroy() {
if icon.watcher == nil {
return
}
icon.watcher.EndWatch()
icon.watcher = nil
xsettings.Unref()
}
func (icon *IconTheme) GetNameStrList() []string {
return GetBaseNameList(icon.infoList)
}
func (icon *IconTheme) GetFlag(name string) int32 {
return GetFileFlagByName(name, icon.infoList)
}
func (icon *IconTheme) GetThumbnail(theme string) string {
var thumb string
for _, info := range icon.infoList {
if theme != info.BaseName {
continue
}
if info.FileFlag == FileFlagSystemOwned {
thumb = path.Join(systemThumbPath,
theme+"-thumbnail.png")
} else {
thumb = path.Join(os.Getenv("HOME"),
userThumbPath,
theme+"-thumbnail.png")
}
if dutils.IsFileExist(thumb) {
break
}
thumb = GetThumbnail("--icon", info.FilePath)
break
}
return thumb
}
func getDirInfoList() ([]PathInfo, []PathInfo) {
sysDirs := []PathInfo{
{
BaseName: "",
FilePath: systemThemePath,
FileFlag: FileFlagSystemOwned,
},
}
userPath := path.Join(os.Getenv("HOME"), userThemePath)
userDirs := []PathInfo{
{
BaseName: "",
FilePath: userPath,
FileFlag: FileFlagUserOwned,
},
}
return sysDirs, userDirs
}
func getThemeList(sysDirs, userDirs []PathInfo) []PathInfo {
localList := GetInfoListFromDirs(userDirs, themeConditions)
sysList := GetInfoListFromDirs(sysDirs, themeConditions)
for _, info := range sysList {
if IsNameInInfoList(info.BaseName, localList) {
continue
}
localList = append(localList, info)
}
var iconList []PathInfo
for _, info := range localList {
filename := path.Join(info.FilePath, "index.theme")
if isIconHidden(filename) || !hasDirectories(filename) {
continue
}
iconList = append(iconList, info)
}
return iconList
}
func setThemeViaXSettings(theme string) error {
return xsettings.SetString(xsettings.NetStringIconTheme, theme)
}
func getDirList() []string {
var list []string
list = append(list, systemThemePath)
userDir := path.Join(os.Getenv("HOME"), userThemePath)
if !dutils.IsFileExist(userDir) {
os.MkdirAll(userDir, 0755)
}
list = append(list, userDir)
return list
}
func isIconHidden(filename string) bool {
if !dutils.IsFileExist(filename) {
return true
}
v, ok := dutils.ReadKeyFromKeyFile(filename,
"Icon Theme", "Hidden", false)
if !ok {
return false
}
return v.(bool)
}
/**
* If icon theme index.theme has 'Directories', it's valid.
**/
func hasDirectories(filename string) bool {
if !dutils.IsFileExist(filename) {
return false
}
v, ok := dutils.ReadKeyFromKeyFile(filename,
"Icon Theme", "Directories", "")
if !ok || len(v.(string)) == 0 {
return false
}
return true
}

View File

@ -1,5 +0,0 @@
[Icon Theme]
Name=Hicolor
Comment=Fallback icon theme
Hidden=false
Directories=aa/bb,cc/dd

View File

@ -1,5 +0,0 @@
[Icon Theme]
Name=Hicolor
Comment=Fallback icon theme
Hidden=true
Directories=aa/bb,cc/dd

View File

@ -1,4 +0,0 @@
[Icon Theme]
Name=Hicolor
Comment=Fallback icon theme
Hidden=false

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