diff --git a/.Doxyfile.cmake b/.Doxyfile.cmake index d0188bb..852f196 100644 --- a/.Doxyfile.cmake +++ b/.Doxyfile.cmake @@ -1,1844 +1,1830 @@ -# Copyright (c) 2013 Lamarque V. Souza (lamarque@kde.org). - -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) version 3, or any -# later version accepted by the membership of KDE e.V. (or its -# successor approved by the membership of KDE e.V.), which shall -# act as a proxy defined in Section 6 of version 3 of the license. +# SPDX-FileCopyrightText: 2013 Lamarque V. Souza # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library. If not, see . +# SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL # Doxyfile 1.8.1.2 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. PROJECT_NAME = NetworkManagerQt -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = v@VERSION@ -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "Qt wrapper for NetworkManager API" -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = doc -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = +STRIP_FROM_PATH = -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = +ALIASES = -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the # itcl::class meaning. -TCL_SUBST = +TCL_SUBST = -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. -EXTENSION_MAPPING = +EXTENSION_MAPPING = -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. # Disable only in case of backward compatibilities issues. MARKDOWN_SUPPORT = YES -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO -# If you use Microsoft's C++/CLI language, you should set this option to YES to +# If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = NO -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man # pages) or section (for LaTeX and RTF). INLINE_SIMPLE_STRUCTS = NO -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal # scope will be included in the documentation. EXTRACT_PACKAGE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file +# If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = NO -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = YES -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = YES -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional +# The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. -ENABLED_SECTIONS = +ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = NO -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = NO -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. This will remove the Namespaces entry from the Quick Index +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. -LAYOUT_FILE = +LAYOUT_FILE = -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. -CITE_BIB_FILES = +CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated +# The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = "@CMAKE_CURRENT_SOURCE_DIR@" -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ *.c++ \ *.d \ *.java \ *.ii \ *.ixx \ *.ipp \ *.i++ \ *.inl \ *.h \ *.hh \ *.hxx \ *.hpp \ *.h++ \ *.idl \ *.odl \ *.cs \ *.php \ *.php3 \ *.inc \ *.m \ *.markdown \ *.md \ *.mm \ *.dox \ *.py \ *.f90 \ *.f \ *.for \ *.vhd \ *.vhdl -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/examples @CMAKE_CURRENT_SOURCE_DIR@/tests @CMAKE_CURRENT_SOURCE_DIR@/dbus -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = *_p.h -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. -INPUT_FILTER = +INPUT_FILTER = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. -FILTER_PATTERNS = +FILTER_PATTERNS = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = YES -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. -FILTER_SOURCE_PATTERNS = +FILTER_SOURCE_PATTERNS = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES -# Setting the INLINE_SOURCES tag to YES will include the body +# Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code # fragments. Normal C, C++ and Fortran comments will always remain visible. STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = NO -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = NO #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! -HTML_HEADER = +HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = +HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own # style sheet in the HTML output directory as well, or it will be erased! -HTML_STYLESHEET = +HTML_STYLESHEET = -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. -HTML_EXTRA_FILES = +HTML_EXTRA_FILES = -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the # page has loaded. HTML_DYNAMIC_SECTIONS = NO -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries # and will result in a full expanded tree by default. HTML_INDEX_NUM_ENTRIES = 100 -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = +CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. -HHC_LOCATION = +HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members +# The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. -QCH_FILE = +QCH_FILE = -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters -QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_NAME = -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# # Qt Help Project / Custom Filters. -QHP_CUST_FILTER_ATTRS = +QHP_CUST_FILTER_ATTRS = -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# # Qt Help Project / Filter Attributes. -QHP_SECT_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. -QHG_LOCATION = +QHG_LOCATION = -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set # GENERATE_TREEVIEW to YES. DISABLE_INDEX = NO -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you # could consider to set DISABLE_INDEX to NO when enabling this option. GENERATE_TREEVIEW = NO -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. However, it is strongly recommended to install a local +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. However, it is strongly recommended to install a local # copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension # names that should be enabled during MathJax rendering. -MATHJAX_EXTENSIONS = +MATHJAX_EXTENSIONS = -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = YES -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. -EXTRA_PACKAGES = +EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! -LATEX_HEADER = +LATEX_HEADER = -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! -LATEX_FOOTER = +LATEX_FOOTER = -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See # http://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = -# Set optional variables used in the generation of an rtf document. +# Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man -# The MAN_EXTENSION tag determines the extension that is added to +# The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +XML_SCHEMA = -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +XML_DTD = -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = +INCLUDE_PATH = -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = +PREDEFINED = -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. For each -# tag file the location of the external documentation should be added. The -# format of a tag file without this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths -# or URLs. Note that each tag file must have a unique name (where the name does -# NOT include the path). If a tag file is not located in the directory in which +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which # doxygen is run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = -# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. -GENERATE_TAGFILE = +GENERATE_TAGFILE = -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script +# The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +MSCGEN_PATH = -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the # directory containing the font. DOT_FONTNAME = Helvetica -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to # set the path where dot can find it. -DOT_FONTPATH = +DOT_FONTPATH = -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the # CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO -# If the UML_LOOK tag is enabled, the fields and methods are shown inside -# the class node. If there are many fields or methods and many nodes the -# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS -# threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 -# If set to YES, the inheritance and collaboration graphs will show the +# If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = svg -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible. Older versions of IE do not have SVG support. INTERACTIVE_SVG = YES -# The tag DOT_PATH can be used to specify the path where the dot tool can be +# The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. -DOT_PATH = +DOT_PATH = -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the # \dotfile command). -DOTFILE_DIRS = +DOTFILE_DIRS = -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the # \mscfile command). -MSCFILE_DIRS = +MSCFILE_DIRS = -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES diff --git a/LICENSES/BSD-3-Clause.txt b/LICENSES/BSD-3-Clause.txt new file mode 100644 index 0000000..0741db7 --- /dev/null +++ b/LICENSES/BSD-3-Clause.txt @@ -0,0 +1,26 @@ +Copyright (c) . All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSES/GPL-2.0-only.txt b/LICENSES/GPL-2.0-only.txt new file mode 100644 index 0000000..0f3d641 --- /dev/null +++ b/LICENSES/GPL-2.0-only.txt @@ -0,0 +1,319 @@ +GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. + +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to +most of the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software +is covered by the GNU Lesser General Public License instead.) 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 this service if you +wish), that you receive source code or can get it if you want it, that you +can change the software or use pieces of it in new free programs; and that +you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to +deny you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of +the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or +for a fee, you must give the recipients all the rights that you have. 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. + +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If +the software is modified by someone else and passed on, we want its recipients +to know that what they have is not the original, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that redistributors of a free program will individually +obtain patent licenses, in effect making the program proprietary. To prevent +this, we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms +of this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or translated +into another language. (Hereinafter, translation is included without limitation +in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running the Program +is not restricted, and the output from the Program is covered only if its +contents constitute a work based on the Program (independent of having been +made by running the Program). Whether that is true depends on what the Program +does. + +1. You may copy and distribute 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 and disclaimer of warranty; +keep intact all the notices that refer to this License and to the absence +of any warranty; and give any other recipients of the Program a copy of this +License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, +thus forming a work based on the Program, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all +of these conditions: + +a) You must cause the modified files to carry prominent notices stating that +you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or +in part contains or is derived from the Program or any part thereof, to be +licensed as a whole at no charge to all third parties under the terms of this +License. + +c) If the modified program normally reads commands interactively when run, +you must cause it, when started running for such interactive use in the most +ordinary way, to print or display an announcement including an appropriate +copyright notice and a notice that there is no warranty (or else, saying that +you provide a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this License. +(Exception: if the Program itself is interactive but does not normally print +such an announcement, your work based on the Program is not required to print +an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Program, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend +to the entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise +the right to control the distribution of derivative or collective works based +on the Program. + +In addition, mere aggregation of another work not based on the Program with +the Program (or with a work based on the Program) on a volume of a storage +or distribution medium does not bring the other work under the scope of this +License. + +3. You may copy and distribute the Program (or a work based on it, under Section +2) in object code or executable form under the terms of Sections 1 and 2 above +provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, +which must be distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give +any third party, for a charge no more than your cost of physically performing +source distribution, a complete machine-readable copy of the corresponding +source code, to be distributed under the terms of Sections 1 and 2 above on +a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute +corresponding source code. (This alternative is allowed only for noncommercial +distribution and only if you received the program in object code or executable +form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all +the source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and installation +of the executable. However, as a special exception, the source code distributed +need not include anything that is normally distributed (in either source or +binary form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component itself +accompanies the executable. + +If distribution of executable or object code is made by offering access to +copy from a designated place, then offering equivalent access to copy the +source code from the same place counts as distribution of the source code, +even though third parties are not compelled to copy the source along with +the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except +as expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses terminated +so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute the +Program or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the Program +(or any work based on the Program), you indicate your acceptance of this License +to do so, and all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor +to copy, distribute or modify the Program subject to these terms and conditions. +You may not impose any further restrictions on the recipients' exercise of +the rights granted herein. You are not responsible for enforcing compliance +by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), conditions are imposed +on you (whether by court order, agreement or otherwise) that contradict the +conditions of this License, they do not excuse you from the conditions of +this License. If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, then as +a consequence you may not distribute the Program at all. For example, if a +patent license would not permit royalty-free redistribution of the Program +by all those who receive copies directly or indirectly through you, then the +only way you could satisfy both it and this License would be to refrain entirely +from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system, which is implemented by public license practices. +Many people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Program under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is +permitted only in or among countries not thus excluded. In such case, this +License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of +the 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 +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that version +or of any later version published by the Free Software Foundation. If the +Program does not specify a version number of this License, you may choose +any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing and reuse +of software generally. + + NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE +THE 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. +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 convey the exclusion +of warranty; and each file should have at least the "copyright" line and a +pointer to where the full notice is found. + + + +Copyright (C)< yyyy> + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This 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, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when +it starts in an interactive mode: + +Gnomovision version 69, Copyright (C) year name of author Gnomovision 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, the commands you use may be +called something other than `show w' and `show c'; they could even be mouse-clicks +or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the program, if necessary. Here +is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' +(which makes passes at compilers) written by James Hacker. + +, 1 April 1989 Ty Coon, President of Vice This 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. diff --git a/LICENSES/GPL-3.0-only.txt b/LICENSES/GPL-3.0-only.txt new file mode 100644 index 0000000..e142a52 --- /dev/null +++ b/LICENSES/GPL-3.0-only.txt @@ -0,0 +1,625 @@ +GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. + +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. + + + +Copyright (C) + +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 . + +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: + + Copyright (C) + +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 . + +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 . diff --git a/LICENSES/LGPL-2.1-only.txt b/LICENSES/LGPL-2.1-only.txt new file mode 100644 index 0000000..130dffb --- /dev/null +++ b/LICENSES/LGPL-2.1-only.txt @@ -0,0 +1,467 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. + +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as the +successor of the GNU Library Public License, version 2, hence the version +number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public Licenses are intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. + +This license, the Lesser General Public License, applies to some specially +designated software packages--typically libraries--of the Free Software Foundation +and other authors who decide to use it. You can use it too, but we suggest +you first think carefully about whether this license or the ordinary General +Public License is the better strategy to use in any particular case, based +on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. +Our General Public Licenses are designed to make sure that you have the freedom +to distribute copies of free software (and charge for this service if you +wish); that you receive source code or can get it if you want it; that you +can change the software and use pieces of it in new free programs; and that +you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distributors +to deny you these rights or to ask you to surrender these rights. These restrictions +translate to certain responsibilities for you if you distribute copies of +the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for +a fee, you must give the recipients all the rights that we gave you. You must +make sure that they, too, receive or can get the source code. If you link +other code with the library, you must provide complete object files to the +recipients, so that they can relink them with the library after making changes +to the library and recompiling it. And you must show them these terms so they +know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, +and (2) we offer you this license, which gives you legal permission to copy, +distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no +warranty for the free library. Also, if the library is modified by someone +else and passed on, the recipients should know that what they have is not +the original version, so that the original author's reputation will not be +affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any free +program. We wish to make sure that a company cannot effectively restrict the +users of a free program by obtaining a restrictive license from a patent holder. +Therefore, we insist that any patent license obtained for a version of the +library must be consistent with the full freedom of use specified in this +license. + +Most GNU software, including some libraries, is covered by the ordinary GNU +General Public License. This license, the GNU Lesser General Public License, +applies to certain designated libraries, and is quite different from the ordinary +General Public License. We use this license for certain libraries in order +to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared +library, the combination of the two is legally speaking a combined work, a +derivative of the original library. The ordinary General Public License therefore +permits such linking only if the entire combination fits its criteria of freedom. +The Lesser General Public License permits more lax criteria for linking other +code with the library. + +We call this license the "Lesser" General Public License because it does Less +to protect the user's freedom than the ordinary General Public License. It +also provides other free software developers Less of an advantage over competing +non-free programs. These disadvantages are the reason we use the ordinary +General Public License for many libraries. However, the Lesser license provides +advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage the +widest possible use of a certain library, so that it becomes a de-facto standard. +To achieve this, non-free programs must be allowed to use the library. A more +frequent case is that a free library does the same job as widely used non-free +libraries. In this case, there is little to gain by limiting the free library +to free software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs +enables a greater number of people to use a large body of free software. For +example, permission to use the GNU C Library in non-free programs enables +many more people to use the whole GNU operating system, as well as its variant, +the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' +freedom, it does ensure that the user of a program that is linked with the +Library has the freedom and the wherewithal to run that program using a modified +version of the Library. + +The precise terms and conditions for copying, distribution and modification +follow. Pay close attention to the difference between a "work based on the +library" and a "work that uses the library". The former contains code derived +from the library, whereas the latter must be combined with the library in +order to run. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program +which contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Lesser General +Public License (also called "this License"). Each licensee is addressed as +"you". + +A "library" means a collection of software functions and/or data prepared +so as to be conveniently linked with application programs (which use some +of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has +been distributed under these terms. A "work based on the Library" means either +the Library or any derivative work under copyright law: that is to say, a +work containing the Library or a portion of it, either verbatim or with modifications +and/or translated straightforwardly into another language. (Hereinafter, translation +is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications +to it. For a library, complete source code means all the source code for all +modules it contains, plus any associated interface definition files, plus +the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running a program +using the Library is not restricted, and output from such a program is covered +only if its contents constitute a work based on the Library (independent of +the use of the Library in a tool for writing it). Whether that is true depends +on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and disclaimer +of warranty; keep intact all the notices that refer to this License and to +the absence of any warranty; and distribute a copy of this License along with +the Library. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, +thus forming a work based on the Library, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all +of these conditions: + + a) The modified work must itself be a software library. + +b) You must cause the files modified to carry prominent notices stating that +you changed the files and the date of any change. + +c) You must cause the whole of the work to be licensed at no charge to all +third parties under the terms of this License. + +d) If a facility in the modified Library refers to a function or a table of +data to be supplied by an application program that uses the facility, other +than as an argument passed when the facility is invoked, then you must make +a good faith effort to ensure that, in the event an application does not supply +such function or table, the facility still operates, and performs whatever +part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose +that is entirely well-defined independent of the application. Therefore, Subsection +2d requires that any application-supplied function or table used by this function +must be optional: if the application does not supply it, the square root function +must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Library, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Library, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend +to the entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise +the right to control the distribution of derivative or collective works based +on the Library. + +In addition, mere aggregation of another work not based on the Library with +the Library (or with a work based on the Library) on a volume of a storage +or distribution medium does not bring the other work under the scope of this +License. + +3. You may opt to apply the terms of the ordinary GNU General Public License +instead of this License to a given copy of the Library. To do this, you must +alter all the notices that refer to this License, so that they refer to the +ordinary GNU General Public License, version 2, instead of to this License. +(If a newer version than version 2 of the ordinary GNU General Public License +has appeared, then you can specify that version instead if you wish.) Do not +make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, +so the ordinary GNU General Public License applies to all subsequent copies +and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library +into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of +it, under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you accompany it with the complete corresponding +machine-readable source code, which must be distributed under the terms of +Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated +place, then offering equivalent access to copy the source code from the same +place satisfies the requirement to distribute the source code, even though +third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but +is designed to work with the Library by being compiled or linked with it, +is called a "work that uses the Library". Such a work, in isolation, is not +a derivative work of the Library, and therefore falls outside the scope of +this License. + +However, linking a "work that uses the Library" with the Library creates an +executable that is a derivative of the Library (because it contains portions +of the Library), rather than a "work that uses the library". The executable +is therefore covered by this License. Section 6 states terms for distribution +of such executables. + +When a "work that uses the Library" uses material from a header file that +is part of the Library, the object code for the work may be a derivative work +of the Library even though the source code is not. Whether this is true is +especially significant if the work can be linked without the Library, or if +the work is itself a library. The threshold for this to be true is not precisely +defined by law. + +If such an object file uses only numerical parameters, data structure layouts +and accessors, and small macros and small inline functions (ten lines or less +in length), then the use of the object file is unrestricted, regardless of +whether it is legally a derivative work. (Executables containing this object +code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute +the object code for the work under the terms of Section 6. Any executables +containing that work also fall under Section 6, whether or not they are linked +directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "work +that uses the Library" with the Library to produce a work containing portions +of the Library, and distribute that work under terms of your choice, provided +that the terms permit modification of the work for the customer's own use +and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library +is used in it and that the Library and its use are covered by this License. +You must supply a copy of this License. If the work during execution displays +copyright notices, you must include the copyright notice for the Library among +them, as well as a reference directing the user to the copy of this License. +Also, you must do one of these things: + +a) Accompany the work with the complete corresponding machine-readable source +code for the Library including whatever changes were used in the work (which +must be distributed under Sections 1 and 2 above); and, if the work is an +executable linked with the Library, with the complete machine-readable "work +that uses the Library", as object code and/or source code, so that the user +can modify the Library and then relink to produce a modified executable containing +the modified Library. (It is understood that the user who changes the contents +of definitions files in the Library will not necessarily be able to recompile +the application to use the modified definitions.) + +b) Use a suitable shared library mechanism for linking with the Library. A +suitable mechanism is one that (1) uses at run time a copy of the library +already present on the user's computer system, rather than copying library +functions into the executable, and (2) will operate properly with a modified +version of the library, if the user installs one, as long as the modified +version is interface-compatible with the version that the work was made with. + +c) Accompany the work with a written offer, valid for at least three years, +to give the same user the materials specified in Subsection 6a, above, for +a charge no more than the cost of performing this distribution. + +d) If distribution of the work is made by offering access to copy from a designated +place, offer equivalent access to copy the above specified materials from +the same place. + +e) Verify that the user has already received a copy of these materials or +that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must +include any data and utility programs needed for reproducing the executable +from it. However, as a special exception, the materials to be distributed +need not include anything that is normally distributed (in either source or +binary form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component itself +accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of +other proprietary libraries that do not normally accompany the operating system. +Such a contradiction means you cannot use both them and the Library together +in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side +in a single library together with other library facilities not covered by +this License, and distribute such a combined library, provided that the separate +distribution of the work based on the Library and of the other library facilities +is otherwise permitted, and provided that you do these two things: + +a) Accompany the combined library with a copy of the same work based on the +Library, uncombined with any other library facilities. This must be distributed +under the terms of the Sections above. + +b) Give prominent notice with the combined library of the fact that part of +it is a work based on the Library, and explaining where to find the accompanying +uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library +except as expressly provided under this License. Any attempt otherwise to +copy, modify, sublicense, link with, or distribute the Library is void, and +will automatically terminate your rights under this License. However, parties +who have received copies, or rights, from you under this License will not +have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute the +Library or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the Library +(or any work based on the Library), you indicate your acceptance of this License +to do so, and all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), +the recipient automatically receives a license from the original licensor +to copy, distribute, link with or modify the Library subject to these terms +and conditions. You may not impose any further restrictions on the recipients' +exercise of the rights granted herein. You are not responsible for enforcing +compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), conditions are imposed +on you (whether by court order, agreement or otherwise) that contradict the +conditions of this License, they do not excuse you from the conditions of +this License. If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, then as +a consequence you may not distribute the Library at all. For example, if a +patent license would not permit royalty-free redistribution of the Library +by all those who receive copies directly or indirectly through you, then the +only way you could satisfy both it and this License would be to refrain entirely +from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system which is implemented by public license practices. +Many people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Library under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is +permitted only in or among countries not thus excluded. In such case, this +License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of +the Lesser General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to address +new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that version +or of any later version published by the Free Software Foundation. If the +Library does not specify a license version number, you may choose any version +ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs +whose distribution conditions are incompatible with these, write to the author +to ask for permission. For software which is copyrighted by the Free Software +Foundation, write to the Free Software Foundation; we sometimes make exceptions +for this. Our decision will be guided by the two goals of preserving the free +status of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY +"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE +OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE +THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE +OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA +OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES +OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH +HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible +use to the public, we recommend making it free software that everyone can +redistribute and change. You can do so by permitting redistribution under +these terms (or, alternatively, under the terms of the ordinary General Public +License). + +To apply these terms, attach the following notices to the library. It is safest +to attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the "copyright" +line and a pointer to where the full notice is found. + +< one line to give the library's name and an idea of what it does. > + +Copyright (C) < year > < name of author > + +This library is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free +Software Foundation; either version 2.1 of the License, or (at your option) +any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. + +You should have received a copy of the GNU Lesser General Public License along +with this library; if not, write to the Free Software Foundation, Inc., 51 +Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information +on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the library, if necessary. Here +is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in + +the library `Frob' (a library for tweaking knobs) written + +by James Random Hacker. + +< signature of Ty Coon > , 1 April 1990 + +Ty Coon, President of Vice + +That's all there is to it! diff --git a/LICENSES/LGPL-3.0-only.txt b/LICENSES/LGPL-3.0-only.txt new file mode 100644 index 0000000..bd405af --- /dev/null +++ b/LICENSES/LGPL-3.0-only.txt @@ -0,0 +1,163 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. + +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. diff --git a/LICENSES/LicenseRef-KDE-Accepted-GPL.txt b/LICENSES/LicenseRef-KDE-Accepted-GPL.txt new file mode 100644 index 0000000..60a2dff --- /dev/null +++ b/LICENSES/LicenseRef-KDE-Accepted-GPL.txt @@ -0,0 +1,12 @@ +This library 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) at any later version that is +accepted by the membership of KDE e.V. (or its successor +approved by the membership of KDE e.V.), which shall act as a +proxy as defined in Section 14 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. diff --git a/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt b/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt new file mode 100644 index 0000000..232b3c5 --- /dev/null +++ b/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt @@ -0,0 +1,12 @@ +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 3 of the license or (at your option) any later version +that is accepted by the membership of KDE e.V. (or its successor +approved by the membership of KDE e.V.), which shall act as a +proxy as defined in Section 6 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. diff --git a/autotests/activeconnectiontest.cpp b/autotests/activeconnectiontest.cpp index 2bada0d..25954eb 100644 --- a/autotests/activeconnectiontest.cpp +++ b/autotests/activeconnectiontest.cpp @@ -1,150 +1,136 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "activeconnectiontest.h" #include "device.h" #include "manager.h" #include "settings.h" #include "settings/ipv4setting.h" #include "settings/ipv6setting.h" #include "settings/wiredsetting.h" #include "fakenetwork/settings.h" #include "fakenetwork/wireddevice.h" #include #include #include void ActiveConnectionTest::initTestCase() { fakeNetwork = new FakeNetwork(); WiredDevice *device = new WiredDevice(); /* Device properties */ device->setAutoconnect(true); device->setCapabilities(3); device->setDeviceType(1); device->setDriver(QLatin1String("e1000e")); device->setDriverVersion(QLatin1String("2.3.2-k")); device->setFirmwareMissing(false); device->setFirmwareVersion(QLatin1String("0.13-3")); device->setInterface(QLatin1String("em1")); device->setManaged(true); device->setUdi(QLatin1String("/sys/devices/pci0000:00/0000:00:19.0/net/em1")); /* Wired device properties */ device->setCarrier(true); device->setHwAddress(QLatin1String("F0:DE:F1:FB:30:C1")); device->setPermanentHwAddress(QLatin1String("F0:DE:F1:FB:30:C1")); fakeNetwork->addDevice(device); NetworkManager::ConnectionSettings::Ptr connectionSettings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wired)); connectionSettings->setId("Wired connection"); connectionSettings->setUuid(QLatin1String("39af79a5-b053-4893-9378-7342a5a30d06")); NetworkManager::Ipv4Setting::Ptr ipv4Setting = connectionSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast(); ipv4Setting->setInitialized(true); ipv4Setting->setMethod(NetworkManager::Ipv4Setting::Automatic); NetworkManager::Ipv6Setting::Ptr ipv6Setting = connectionSettings->setting(NetworkManager::Setting::Ipv6).dynamicCast(); ipv6Setting->setInitialized(true); ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic); NetworkManager::WiredSetting::Ptr wiredSetting = connectionSettings->setting(NetworkManager::Setting::Wired).dynamicCast(); wiredSetting->setInitialized(true); // Something needs to be set to not use default values, when using default values we get an empty map wiredSetting->setSpeed(100); NetworkManager::Device::Ptr wiredDevice = NetworkManager::networkInterfaces().first().objectCast(); QSignalSpy availableConnectionAppearedSpy(wiredDevice.data(), SIGNAL(availableConnectionAppeared(QString))); NetworkManager::addConnection(connectionSettings->toMap()); QVERIFY(availableConnectionAppearedSpy.wait()); } void ActiveConnectionTest::testActiveConnection() { qRegisterMetaType("NetworkManager::ActiveConnection::State"); qRegisterMetaType("NetworkManager::ActiveConnection::Reason"); qRegisterMetaType("NetworkManager::Device::State"); qRegisterMetaType("NetworkManager::Device::StateChangeReason"); qRegisterMetaType("NetworkManager::Connectivity"); qRegisterMetaType("NetworkManager::Status"); NetworkManager::Device::Ptr device = NetworkManager::networkInterfaces().first(); QSignalSpy deviceActiveConnectionChangedSpy(device.data(), SIGNAL(activeConnectionChanged())); QSignalSpy deviceIpInterfaceChangedSpy(device.data(), SIGNAL(ipInterfaceChanged())); QSignalSpy deviceStateChangedSpy(device.data(), SIGNAL(stateChanged(NetworkManager::Device::State,NetworkManager::Device::State,NetworkManager::Device::StateChangeReason))); NetworkManager::Connection::Ptr connection = device->availableConnections().first(); QSignalSpy activeConnectionAddedSpy(NetworkManager::notifier(), SIGNAL(activeConnectionAdded(QString))); QSignalSpy activatingConnectionChangedSpy(NetworkManager::notifier(), SIGNAL(activatingConnectionChanged(QString))); QSignalSpy connectivityChangedSpy(NetworkManager::notifier(), SIGNAL(connectivityChanged(NetworkManager::Connectivity))); QSignalSpy primaryConnectionChangedSpy(NetworkManager::notifier(), SIGNAL(primaryConnectionChanged(QString))); QSignalSpy stateChangedSpy(NetworkManager::notifier(), SIGNAL(statusChanged(NetworkManager::Status))); NetworkManager::activateConnection(connection->path(), device->uni(), QString()); QVERIFY(activeConnectionAddedSpy.wait()); NetworkManager::ActiveConnection::Ptr activeConnection = NetworkManager::findActiveConnection(activeConnectionAddedSpy.at(0).at(0).toString()); QSignalSpy activeConnectionStateChangedSpy(activeConnection.data(), SIGNAL(stateChanged(NetworkManager::ActiveConnection::State))); QSignalSpy activeConnectionStateChangedReasonSpy(activeConnection.data(), SIGNAL(stateChangedReason(NetworkManager::ActiveConnection::State,NetworkManager::ActiveConnection::Reason))); QCOMPARE(activeConnection->devices().first(), device->uni()); QCOMPARE(activeConnection->state(), NetworkManager::ActiveConnection::Activating); QCOMPARE(activeConnection->uuid(), connection->uuid()); QCOMPARE(NetworkManager::activatingConnection()->uuid(), connection->uuid()); // Wait until device goes through all states (PREPARE, CONFIG, NEED_AUTH, IP_CONFIG, IP_CHECK, ACTIVATED) QTest::qWait(800); QCOMPARE(activeConnectionStateChangedSpy.count(), 1); QCOMPARE(activeConnectionStateChangedReasonSpy.count(), 1); QCOMPARE(deviceStateChangedSpy.count(), 6); QCOMPARE(device->ipInterfaceName(), device->interfaceName()); QCOMPARE(device->state(), NetworkManager::Device::Activated); QCOMPARE(deviceActiveConnectionChangedSpy.count(), 1); QCOMPARE(deviceIpInterfaceChangedSpy.count(), 1); QCOMPARE(NetworkManager::connectivity(), NetworkManager::Full); QCOMPARE(NetworkManager::primaryConnection()->uuid(), connection->uuid()); QCOMPARE(NetworkManager::status(), NetworkManager::Status::Connected); QCOMPARE(activatingConnectionChangedSpy.count(), 2); QCOMPARE(connectivityChangedSpy.count(), 1); QCOMPARE(primaryConnectionChangedSpy.count(), 1); QCOMPARE(stateChangedSpy.count(), 1); NetworkManager::deactivateConnection(activeConnection->path()); // Wait until we are disconnected QTest::qWait(300); QVERIFY(device->ipInterfaceName().isEmpty()); QCOMPARE(device->state(), NetworkManager::Device::Disconnected); QCOMPARE(NetworkManager::activeConnections().count(), 0); QCOMPARE(NetworkManager::connectivity(), NetworkManager::NoConnectivity); QVERIFY(NetworkManager::primaryConnection().isNull()); QCOMPARE(NetworkManager::status(), NetworkManager::Disconnected); } QTEST_MAIN(ActiveConnectionTest) diff --git a/autotests/activeconnectiontest.h b/autotests/activeconnectiontest.h index a28d5a0..db07076 100644 --- a/autotests/activeconnectiontest.h +++ b/autotests/activeconnectiontest.h @@ -1,40 +1,26 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_ACTIVE_CONNECTION_TEST_H #define NETWORKMANAGERQT_ACTIVE_CONNECTION_TEST_H #include #include "fakenetwork/fakenetwork.h" class ActiveConnectionTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void testActiveConnection(); private: FakeNetwork *fakeNetwork; }; #endif // NETWORKMANAGERQT_ACTIVE_CONNECTION_TEST_H diff --git a/autotests/managertest.cpp b/autotests/managertest.cpp index e936163..b260fdf 100644 --- a/autotests/managertest.cpp +++ b/autotests/managertest.cpp @@ -1,170 +1,156 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "managertest.h" #include "manager.h" #include "wireddevice.h" #include "fakenetwork/wireddevice.h" #include #include #include void ManagerTest::initTestCase() { fakeNetwork = new FakeNetwork(); } void ManagerTest::testDevices() { WiredDevice *device = new WiredDevice(); /* Device properties */ device->setAutoconnect(true); device->setCapabilities(3); device->setDeviceType(1); device->setDriver(QLatin1String("e1000e")); device->setDriverVersion(QLatin1String("2.3.2-k")); device->setFirmwareMissing(false); device->setFirmwareVersion(QLatin1String("0.13-3")); device->setInterface(QLatin1String("em1")); device->setManaged(true); device->setUdi(QLatin1String("/sys/devices/pci0000:00/0000:00:19.0/net/em1")); /* Wired device properties */ device->setCarrier(true); device->setHwAddress(QLatin1String("F0:DE:F1:FB:30:C1")); device->setPermanentHwAddress(QLatin1String("F0:DE:F1:FB:30:C1")); QSignalSpy addDeviceSpy(NetworkManager::notifier(), SIGNAL(deviceAdded(QString))); connect(NetworkManager::notifier(), &NetworkManager::Notifier::deviceAdded, this, &ManagerTest::testDeviceAdded); fakeNetwork->addDevice(device); QVERIFY(addDeviceSpy.wait()); QCOMPARE(NetworkManager::networkInterfaces().count(), 1); QCOMPARE(NetworkManager::networkInterfaces().first()->uni(), addDeviceSpy.at(0).at(0).toString()); const QString addedDevicePath = NetworkManager::networkInterfaces().first()->uni(); QSignalSpy removeDeviceSpy(NetworkManager::notifier(), SIGNAL(deviceRemoved(QString))); fakeNetwork->removeDevice(device); QVERIFY(removeDeviceSpy.wait()); QVERIFY(NetworkManager::networkInterfaces().isEmpty()); QCOMPARE(removeDeviceSpy.at(0).at(0).toString(), addedDevicePath); addDeviceSpy.clear(); fakeNetwork->addDevice(device); QVERIFY(addDeviceSpy.wait()); QCOMPARE(NetworkManager::networkInterfaces().count(), 1); QCOMPARE(NetworkManager::networkInterfaces().first()->uni(), addDeviceSpy.at(0).at(0).toString()); addDeviceSpy.clear(); removeDeviceSpy.clear(); fakeNetwork->unregisterService(); QTRY_COMPARE(removeDeviceSpy.count(), 1); fakeNetwork->registerService(); QTRY_COMPARE(addDeviceSpy.count(), 1); // Make sure deviceAdded is emitted only once addDeviceSpy.wait(100); QCOMPARE(addDeviceSpy.count(), 1); delete device; } void ManagerTest::testDeviceAdded(const QString &dev) { NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(dev); QCOMPARE(device->autoconnect(), true); QCOMPARE(device->capabilities(), 3); QCOMPARE(device->type(), NetworkManager::Device::Ethernet); QCOMPARE(device->driver(), QLatin1String("e1000e")); QCOMPARE(device->driverVersion(), QLatin1String("2.3.2-k")); QCOMPARE(device->firmwareMissing(), false); QCOMPARE(device->firmwareVersion(), QLatin1String("0.13-3")); QCOMPARE(device->interfaceName(), QLatin1String("em1")); QCOMPARE(device->managed(), true); QCOMPARE(device->udi(), QLatin1String("/sys/devices/pci0000:00/0000:00:19.0/net/em1")); NetworkManager::WiredDevice::Ptr wiredDevice = device.objectCast(); QCOMPARE(wiredDevice->carrier(), true); QCOMPARE(wiredDevice->hardwareAddress(), QLatin1String("F0:DE:F1:FB:30:C1")); QCOMPARE(wiredDevice->permanentHardwareAddress(), QLatin1String("F0:DE:F1:FB:30:C1")); } void ManagerTest::testManager() { QCOMPARE(NetworkManager::connectivity(), NetworkManager::NoConnectivity); // QCOMPARE(NetworkManager::status(), NetworkManager::Disconnected); QCOMPARE(NetworkManager::version(), QLatin1String("0.9.10.0")); QSignalSpy wirelessEnabledChanged(NetworkManager::notifier(), SIGNAL(wirelessEnabledChanged(bool))); QCOMPARE(NetworkManager::isWirelessEnabled(), true); fakeNetwork->setWirelessEnabled(false); QVERIFY(wirelessEnabledChanged.wait()); QCOMPARE(wirelessEnabledChanged.count(), 1); QVERIFY(wirelessEnabledChanged.at(0).at(0).toBool() == false); QCOMPARE(NetworkManager::isWirelessEnabled(), false); QSignalSpy wirelessHwEnabledChanged(NetworkManager::notifier(), SIGNAL(wirelessHardwareEnabledChanged(bool))); QCOMPARE(NetworkManager::isWirelessHardwareEnabled(), true); fakeNetwork->setWirelessHardwareEnabled(false); QVERIFY(wirelessHwEnabledChanged.wait()); QCOMPARE(wirelessHwEnabledChanged.count(), 1); QVERIFY(wirelessHwEnabledChanged.at(0).at(0).toBool() == false); QCOMPARE(NetworkManager::isWirelessHardwareEnabled(), false); QSignalSpy wimaxEnabledChanged(NetworkManager::notifier(), SIGNAL(wimaxEnabledChanged(bool))); QCOMPARE(NetworkManager::isWimaxEnabled(), true); fakeNetwork->setWimaxEnabled(false); QVERIFY(wimaxEnabledChanged.wait()); QCOMPARE(wimaxEnabledChanged.count(), 1); QVERIFY(wimaxEnabledChanged.at(0).at(0).toBool() == false); QCOMPARE(NetworkManager::isWimaxEnabled(), false); QSignalSpy wimaxHwEnabledChanged(NetworkManager::notifier(), SIGNAL(wimaxHardwareEnabledChanged(bool))); QCOMPARE(NetworkManager::isWimaxHardwareEnabled(), true); fakeNetwork->setWimaxHardwareEnabled(false); QVERIFY(wimaxHwEnabledChanged.wait()); QCOMPARE(wimaxHwEnabledChanged.count(), 1); QVERIFY(wimaxHwEnabledChanged.at(0).at(0).toBool() == false); QCOMPARE(NetworkManager::isWimaxHardwareEnabled(), false); QSignalSpy wwanEnabledChanged(NetworkManager::notifier(), SIGNAL(wwanEnabledChanged(bool))); QCOMPARE(NetworkManager::isWwanEnabled(), true); fakeNetwork->setWwanEnabled(false); QVERIFY(wwanEnabledChanged.wait()); QCOMPARE(wwanEnabledChanged.count(), 1); QVERIFY(wwanEnabledChanged.at(0).at(0).toBool() == false); QCOMPARE(NetworkManager::isWwanEnabled(), false); // We make it here, so we can set all values back for futher testing fakeNetwork->setWirelessEnabled(true); fakeNetwork->setWirelessHardwareEnabled(true); fakeNetwork->setWimaxEnabled(true); fakeNetwork->setWimaxHardwareEnabled(true); fakeNetwork->setWwanEnabled(true); } QTEST_MAIN(ManagerTest) diff --git a/autotests/managertest.h b/autotests/managertest.h index 7b069c6..dd402ad 100644 --- a/autotests/managertest.h +++ b/autotests/managertest.h @@ -1,42 +1,28 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MANAGER_TEST_H #define NETWORKMANAGERQT_MANAGER_TEST_H #include #include "fakenetwork/fakenetwork.h" class ManagerTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void testDevices(); void testDeviceAdded(const QString &dev); void testManager(); private: FakeNetwork *fakeNetwork; }; #endif // NETWORKMANAGERQT_MANAGER_TEST_H diff --git a/autotests/settings/8021xsettingtest.cpp b/autotests/settings/8021xsettingtest.cpp index 9af3cee..da9da59 100644 --- a/autotests/settings/8021xsettingtest.cpp +++ b/autotests/settings/8021xsettingtest.cpp @@ -1,190 +1,176 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "8021xsettingtest.h" #include "settings/security8021xsetting.h" #include #include void Security8021xSettingTest::testSetting_data() { QTest::addColumn("eap"); QTest::addColumn("identity"); QTest::addColumn("anonymousIdentity"); QTest::addColumn("pacFile"); QTest::addColumn("caCert"); QTest::addColumn("domainSuffixMatch"); QTest::addColumn("caPath"); QTest::addColumn("subjectMatch"); QTest::addColumn("altSubjectMatches"); QTest::addColumn("clientCert"); QTest::addColumn("phase1PeapVer"); QTest::addColumn("phase1PeapLabel"); QTest::addColumn("phase1FastProvisioning"); QTest::addColumn("phase2Auth"); QTest::addColumn("phase2EapAuth"); QTest::addColumn("phase2CaCert"); QTest::addColumn("phase2CaPath"); QTest::addColumn("phase2SubjectMatch"); QTest::addColumn("phase2AltSubjectMatches"); QTest::addColumn("phase2ClientCert"); QTest::addColumn("password"); QTest::addColumn("passwordFlags"); QTest::addColumn("passwordRaw"); QTest::addColumn("passwordRawFlags"); QTest::addColumn("privateKey"); QTest::addColumn("privateKeyPassword"); QTest::addColumn("privateKeyPasswordFlags"); QTest::addColumn("phase2PrivateKey"); QTest::addColumn("phase2PrivateKeyPassword"); QTest::addColumn("phase2PrivateKeyPasswordFlags"); QTest::addColumn("pin"); QTest::addColumn("pinFlags"); QTest::addColumn("systemCaCerts"); QStringList eapMethods; eapMethods << "leap" << "md5" << "tls" << "peap" << "ttls" << "fast"; QStringList altSubjectMatches; altSubjectMatches << "subject1" << "subject2"; QTest::newRow("setting1") << eapMethods // eap << QString("identity") // identity << QString("anonymousIdentity") // anonymousIdentity << QString("file://path/to/pac/file") // pacFile << QByteArray("file://path/to/ca/cert") // caCert << QString("example.com") // domainSuffixMatch << QString("file://path/to/ca/cert") // caPath << QString("subjectMatch") // subjectMatch << altSubjectMatches // altSubjectMatches << QByteArray("file://path/to/client/cert") // clientCert << QString("1") // phase1PeapVer << QString("1") // phase1PeapLabel << QString("3") // phase1FastProvisioning << QString("mschapv2") // phase2Auth << QString("tls") // phase2EapAuth << QByteArray("file://path/to/phase2/ca/cert") // phase2CaCert << QString("file://path/to/phase2/ca/cert") // phase2CaPath << QString("phase2SubjectMatch") // phase2SubjectMatch << altSubjectMatches // phase2AltSubjectMatches << QByteArray("file://path/to/phase2/client/cert") // phase2ClientCert << QString("password") // password << (quint32) 2 // passwordFlags << QByteArray("passwordRaw") // passwordRaw << (quint32) 4 // passwordFlags << QByteArray("privateKey") // privateKey << QString("privateKeyPassword") // privateKeyPassword << (quint32) 2 // privateKeyPasswordFlags << QByteArray("phase2PrivateKey") // phase2PrivateKey << QString("phase2PrivateKeyPassword") // phase2PrivateKeyPassword << (quint32) 4 // phase2PrivateKeyPasswordFlags << QString("pin") // pin << (quint32) 2 // pinFlags << true; // systemCaCerts } void Security8021xSettingTest::testSetting() { QFETCH(QStringList, eap); QFETCH(QString, identity); QFETCH(QString, anonymousIdentity); QFETCH(QString, pacFile); QFETCH(QByteArray, caCert); QFETCH(QString, domainSuffixMatch); QFETCH(QString, caPath); QFETCH(QString, subjectMatch); QFETCH(QStringList, altSubjectMatches); QFETCH(QByteArray, clientCert); QFETCH(QString, phase1PeapVer); QFETCH(QString, phase1PeapLabel); QFETCH(QString, phase1FastProvisioning); QFETCH(QString, phase2Auth); QFETCH(QString, phase2EapAuth); QFETCH(QByteArray, phase2CaCert); QFETCH(QString, phase2CaPath); QFETCH(QString, phase2SubjectMatch); QFETCH(QStringList, phase2AltSubjectMatches); QFETCH(QByteArray, phase2ClientCert); QFETCH(QString, password); QFETCH(quint32, passwordFlags); QFETCH(QByteArray, passwordRaw); QFETCH(quint32, passwordRawFlags); QFETCH(QByteArray, privateKey); QFETCH(QString, privateKeyPassword); QFETCH(quint32, privateKeyPasswordFlags); QFETCH(QByteArray, phase2PrivateKey); QFETCH(QString, phase2PrivateKeyPassword); QFETCH(quint32, phase2PrivateKeyPasswordFlags); QFETCH(QString, pin); QFETCH(quint32, pinFlags); QFETCH(bool, systemCaCerts); QVariantMap map; map.insert(QLatin1String(NM_SETTING_802_1X_EAP), eap); map.insert(QLatin1String(NM_SETTING_802_1X_IDENTITY), identity); map.insert(QLatin1String(NM_SETTING_802_1X_ANONYMOUS_IDENTITY), anonymousIdentity); map.insert(QLatin1String(NM_SETTING_802_1X_PAC_FILE), pacFile); map.insert(QLatin1String(NM_SETTING_802_1X_CA_CERT), caCert); map.insert(QLatin1String(NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH), domainSuffixMatch); map.insert(QLatin1String(NM_SETTING_802_1X_CA_PATH), caPath); map.insert(QLatin1String(NM_SETTING_802_1X_SUBJECT_MATCH), subjectMatch); map.insert(QLatin1String(NM_SETTING_802_1X_ALTSUBJECT_MATCHES), altSubjectMatches); map.insert(QLatin1String(NM_SETTING_802_1X_CLIENT_CERT), clientCert); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPVER), phase1PeapVer); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPLABEL), phase1PeapLabel); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING), phase1FastProvisioning); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_AUTH), phase2Auth); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_AUTHEAP), phase2EapAuth); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_CA_CERT), phase2CaCert); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_CA_PATH), phase2CaPath); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH), phase2SubjectMatch); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES), phase2AltSubjectMatches); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_CLIENT_CERT), phase2ClientCert); map.insert(QLatin1String(NM_SETTING_802_1X_PASSWORD), password); map.insert(QLatin1String(NM_SETTING_802_1X_PASSWORD_FLAGS), passwordFlags); map.insert(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW), passwordRaw); map.insert(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW_FLAGS), passwordRawFlags); map.insert(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY), privateKey); map.insert(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD), privateKeyPassword); map.insert(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS), privateKeyPasswordFlags); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY), phase2PrivateKey); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD), phase2PrivateKeyPassword); map.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS), phase2PrivateKeyPasswordFlags); map.insert(QLatin1String(NM_SETTING_802_1X_PIN), pin); map.insert(QLatin1String(NM_SETTING_802_1X_PIN_FLAGS), pinFlags); map.insert(QLatin1String(NM_SETTING_802_1X_SYSTEM_CA_CERTS), systemCaCerts); NetworkManager::Security8021xSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(Security8021xSettingTest) diff --git a/autotests/settings/8021xsettingtest.h b/autotests/settings/8021xsettingtest.h index c9ed5f8..7bf1fdf 100644 --- a/autotests/settings/8021xsettingtest.h +++ b/autotests/settings/8021xsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SECURITY8021XSETTING_TEST_H #define NETWORKMANAGERQT_SECURITY8021XSETTING_TEST_H #include class Security8021xSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_SECURITY8021XSETTING_TEST_H diff --git a/autotests/settings/adslsettingtest.cpp b/autotests/settings/adslsettingtest.cpp index d4539e3..aa62198 100644 --- a/autotests/settings/adslsettingtest.cpp +++ b/autotests/settings/adslsettingtest.cpp @@ -1,80 +1,66 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "adslsettingtest.h" #include "settings/adslsetting.h" #include #include void AdslSettingTest::testSetting_data() { QTest::addColumn("username"); QTest::addColumn("password"); QTest::addColumn("passwordFlags"); QTest::addColumn("protocol"); QTest::addColumn("encapsulation"); QTest::addColumn("vpi"); QTest::addColumn("vci"); QTest::newRow("setting1") << QString("username") // username << QString("password") // options << (quint32) 2 // passwordFlags << "pppoa" // protocol << "llc" // encapsulation << (quint32) 8 // vpi << (quint32) 35; // vci } void AdslSettingTest::testSetting() { QFETCH(QString, username); QFETCH(QString, password); QFETCH(quint32, passwordFlags); QFETCH(QString, protocol); QFETCH(QString, encapsulation); QFETCH(quint32, vpi); QFETCH(quint32, vci); QVariantMap map; map.insert(QLatin1String(NM_SETTING_ADSL_USERNAME), username); map.insert(QLatin1String(NM_SETTING_ADSL_PASSWORD), password); map.insert(QLatin1String(NM_SETTING_ADSL_PASSWORD_FLAGS), passwordFlags); map.insert(QLatin1String(NM_SETTING_ADSL_PROTOCOL), protocol); map.insert(QLatin1String(NM_SETTING_ADSL_ENCAPSULATION), encapsulation); map.insert(QLatin1String(NM_SETTING_ADSL_VPI), vpi); map.insert(QLatin1String(NM_SETTING_ADSL_VCI), vci); NetworkManager::AdslSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(AdslSettingTest) diff --git a/autotests/settings/adslsettingtest.h b/autotests/settings/adslsettingtest.h index 8661fa5..0945cbf 100644 --- a/autotests/settings/adslsettingtest.h +++ b/autotests/settings/adslsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_ADSLSETTING_TEST_H #define NETWORKMANAGERQT_ADSLSETTING_TEST_H #include class AdslSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_ADSLSETTING_TEST_H diff --git a/autotests/settings/bluetoothsettingtest.cpp b/autotests/settings/bluetoothsettingtest.cpp index 4cf24de..5207814 100644 --- a/autotests/settings/bluetoothsettingtest.cpp +++ b/autotests/settings/bluetoothsettingtest.cpp @@ -1,61 +1,47 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bluetoothsettingtest.h" #include "settings/bluetoothsetting.h" #include #include void BluetoothSettingTest::testSetting_data() { QTest::addColumn("address"); QTest::addColumn("type"); QTest::newRow("setting1") << QByteArray("00:02:72:00:d4:1a") // address << QString("panu"); // type } void BluetoothSettingTest::testSetting() { QFETCH(QByteArray, address); QFETCH(QString, type); QVariantMap map; map.insert(QLatin1String(NM_SETTING_BLUETOOTH_BDADDR), address); map.insert(QLatin1String(NM_SETTING_BLUETOOTH_TYPE), type); NetworkManager::BluetoothSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(BluetoothSettingTest) diff --git a/autotests/settings/bluetoothsettingtest.h b/autotests/settings/bluetoothsettingtest.h index e9b2144..ea20cdf 100644 --- a/autotests/settings/bluetoothsettingtest.h +++ b/autotests/settings/bluetoothsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BLUETOOTHSETTING_TEST_H #define NETWORKMANAGERQT_BLUETOOTHSETTING_TEST_H #include class BluetoothSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_BLUETOOTHSETTING_TEST_H diff --git a/autotests/settings/bondsettingtest.cpp b/autotests/settings/bondsettingtest.cpp index 62ce648..b4fd34c 100644 --- a/autotests/settings/bondsettingtest.cpp +++ b/autotests/settings/bondsettingtest.cpp @@ -1,68 +1,54 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bondsettingtest.h" #include "settings/bondsetting.h" #include #include void BondSettingTest::testSetting_data() { QTest::addColumn("interfaceName"); QTest::addColumn("options"); NMStringMap options; options.insert("mode", "802.3ad"); QTest::newRow("setting1") << QString("eth0") // interfaceName << options; // options } void BondSettingTest::testSetting() { QFETCH(QString, interfaceName); QFETCH(NMStringMap, options); QVariantMap map; map.insert(QLatin1String("interface-name"), interfaceName); map.insert(QLatin1String(NM_SETTING_BOND_OPTIONS), QVariant::fromValue(options)); NetworkManager::BondSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QCOMPARE(map.value(QLatin1String("interface-name")), map1.value(QLatin1String("interface-name"))); NMStringMap stringMap1 = map.value(QLatin1String(NM_SETTING_BOND_OPTIONS)).value(); NMStringMap stringMap2 = map1.value(QLatin1String(NM_SETTING_BOND_OPTIONS)).value(); NMStringMap::const_iterator it = stringMap1.constBegin(); while (it != stringMap1.constEnd()) { QCOMPARE(it.value(), stringMap2.value(it.key())); ++it; } } QTEST_MAIN(BondSettingTest) diff --git a/autotests/settings/bondsettingtest.h b/autotests/settings/bondsettingtest.h index 6d8560e..3c27e52 100644 --- a/autotests/settings/bondsettingtest.h +++ b/autotests/settings/bondsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BONDSETTING_TEST_H #define NETWORKMANAGERQT_BONDSETTING_TEST_H #include class BondSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_BONDSETTING_TEST_H diff --git a/autotests/settings/bridgeportsettingtest.cpp b/autotests/settings/bridgeportsettingtest.cpp index e6c0c1d..6336fa2 100644 --- a/autotests/settings/bridgeportsettingtest.cpp +++ b/autotests/settings/bridgeportsettingtest.cpp @@ -1,66 +1,52 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bridgeportsettingtest.h" #include "settings/bridgeportsetting.h" #include #define NM_SETTING_BRIDGE_MAC_ADDRESS "mac-address" #include void BridgePortSettingTest::testSetting_data() { QTest::addColumn("priority"); QTest::addColumn("pathCost"); QTest::addColumn("hairpinMode"); QTest::newRow("setting1") << (quint16) 60 // priority << (quint16) 30000 // pathCost << true; // hairpinMode } void BridgePortSettingTest::testSetting() { QFETCH(quint16, priority); QFETCH(quint16, pathCost); QFETCH(bool, hairpinMode); QVariantMap map; map.insert(QLatin1String(NM_SETTING_BRIDGE_PORT_PRIORITY), priority); map.insert(QLatin1String(NM_SETTING_BRIDGE_PORT_PATH_COST), pathCost); map.insert(QLatin1String(NM_SETTING_BRIDGE_PORT_PATH_COST), hairpinMode); NetworkManager::BridgePortSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(BridgePortSettingTest) diff --git a/autotests/settings/bridgeportsettingtest.h b/autotests/settings/bridgeportsettingtest.h index d787ad5..15242db 100644 --- a/autotests/settings/bridgeportsettingtest.h +++ b/autotests/settings/bridgeportsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BRIDGEPORTSETTING_TEST_H #define NETWORKMANAGERQT_BRIDGEPORTSETTING_TEST_H #include class BridgePortSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_BRIDGEPORTSETTING_TEST_H diff --git a/autotests/settings/bridgesettingtest.cpp b/autotests/settings/bridgesettingtest.cpp index d867004..8f7debb 100644 --- a/autotests/settings/bridgesettingtest.cpp +++ b/autotests/settings/bridgesettingtest.cpp @@ -1,88 +1,74 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bridgesettingtest.h" #include "settings/bridgesetting.h" #include #include void BridgeSettingTest::testSetting_data() { QTest::addColumn("interfaceName"); QTest::addColumn("stp"); QTest::addColumn("priority"); QTest::addColumn("forwardDelay"); QTest::addColumn("helloTime"); QTest::addColumn("maxAge"); QTest::addColumn("ageintTime"); QTest::addColumn("multicastSnooping"); QTest::addColumn("macAddress"); QTest::newRow("setting1") << QString("eth0") // interfaceName << false // stp << (quint16) 10 // priority << (quint16) 5 // forwardDelay << (quint16) 5 // helloTime << (quint16) 10 // maxAge << (quint32) 10000 // ageintTime << false // multicastSnooping << QByteArray("54:EE:75:53:E9:E4"); // macAddress } void BridgeSettingTest::testSetting() { QFETCH(QString, interfaceName); QFETCH(bool, stp); QFETCH(quint16, priority); QFETCH(quint16, forwardDelay); QFETCH(quint16, helloTime); QFETCH(quint16, maxAge); QFETCH(quint32, ageintTime); QFETCH(bool, multicastSnooping); QFETCH(QByteArray, macAddress); QVariantMap map; map.insert(QLatin1String("interface-name"), interfaceName); map.insert(QLatin1String(NM_SETTING_BRIDGE_STP), stp); map.insert(QLatin1String(NM_SETTING_BRIDGE_PRIORITY), priority); map.insert(QLatin1String(NM_SETTING_BRIDGE_FORWARD_DELAY), forwardDelay); map.insert(QLatin1String(NM_SETTING_BRIDGE_HELLO_TIME), helloTime); map.insert(QLatin1String(NM_SETTING_BRIDGE_MAX_AGE), maxAge); map.insert(QLatin1String(NM_SETTING_BRIDGE_AGEING_TIME), ageintTime); map.insert(QLatin1String(NM_SETTING_BRIDGE_MULTICAST_SNOOPING), multicastSnooping); map.insert(QLatin1String(NM_SETTING_BRIDGE_MAC_ADDRESS), macAddress); NetworkManager::BridgeSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(BridgeSettingTest) diff --git a/autotests/settings/bridgesettingtest.h b/autotests/settings/bridgesettingtest.h index e00a3ab..90c8103 100644 --- a/autotests/settings/bridgesettingtest.h +++ b/autotests/settings/bridgesettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BRIDGESETTING_TEST_H #define NETWORKMANAGERQT_BRIDGESETTING_TEST_H #include class BridgeSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_BRIDGESETTING_TEST_H diff --git a/autotests/settings/cdmasettingtest.cpp b/autotests/settings/cdmasettingtest.cpp index 2508b6d..3876bde 100644 --- a/autotests/settings/cdmasettingtest.cpp +++ b/autotests/settings/cdmasettingtest.cpp @@ -1,68 +1,54 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "cdmasettingtest.h" #include "settings/cdmasetting.h" #include #include void CdmaSettingTest::testSetting_data() { QTest::addColumn("number"); QTest::addColumn("username"); QTest::addColumn("password"); QTest::addColumn("passwordFlags"); QTest::newRow("setting1") << QString("#123456789") // number << QString("username") // username << QString("password") // password << (quint32) 2; // passwordFlags } void CdmaSettingTest::testSetting() { QFETCH(QString, number); QFETCH(QString, username); QFETCH(QString, password); QFETCH(quint32, passwordFlags); QVariantMap map; map.insert(QLatin1String(NM_SETTING_CDMA_NUMBER), number); map.insert(QLatin1String(NM_SETTING_CDMA_USERNAME), username); map.insert(QLatin1String(NM_SETTING_CDMA_PASSWORD), password); map.insert(QLatin1String(NM_SETTING_CDMA_PASSWORD_FLAGS), passwordFlags); NetworkManager::CdmaSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(CdmaSettingTest) diff --git a/autotests/settings/cdmasettingtest.h b/autotests/settings/cdmasettingtest.h index 3a8aeb1..c16a3a3 100644 --- a/autotests/settings/cdmasettingtest.h +++ b/autotests/settings/cdmasettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_CDMASETTING_TEST_H #define NETWORKMANAGERQT_CDMASETTING_TEST_H #include class CdmaSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_CDMASETTING_TEST_H diff --git a/autotests/settings/connectionsettingtest.cpp b/autotests/settings/connectionsettingtest.cpp index 21837cf..cb32dd4 100644 --- a/autotests/settings/connectionsettingtest.cpp +++ b/autotests/settings/connectionsettingtest.cpp @@ -1,135 +1,121 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "connectionsettingtest.h" #include "settings/connectionsettings.h" #include #if !NM_CHECK_VERSION(1, 6, 0) #define NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES "autoconnect-retries" #endif #include void ConnectionSettingTest::testSetting_data() { QTest::addColumn("id"); QTest::addColumn("uuid"); QTest::addColumn("type"); QTest::addColumn("permissions"); QTest::addColumn("autoconnect"); QTest::addColumn("timestamp"); QTest::addColumn("readOnly"); QTest::addColumn("zone"); QTest::addColumn("master"); QTest::addColumn("slaveType"); QTest::addColumn("secondaries"); QTest::addColumn("gatewayPingTimeout"); QTest::addColumn("autoconnectPriority"); QTest::addColumn("autoconnectRetries"); QTest::addColumn("autoconnectSlaves"); QTest::addColumn("lldp"); QTest::addColumn("metered"); QTest::addColumn("stableId"); QStringList permissions; permissions << "user:foo:bar"; QTest::newRow("setting1") << QString("test") // id << QString("2815492f-7e56-435e-b2e9-246bd7cdc664") // uuid << QString("802-3-ethernet") // type << permissions // permissions << false // autoconnect << (quint64) 1355945444 // timestamp << true // readOnly << QString("Home") // zone << QString("3ba0ba8c-58f3-427d-bce4-3c8200277a5c") // master << QString("bond") // slaveType << QStringList{{"2d331115-a2f4-4376-b24e-b8ba6e71abcf"}}// secondaries << (uint)10 // gatewayPingTimeout << 10 // autoconnectPriority << 5 // autoconnectRetries << 1 // autoconnectSlaves << 1 // lldp << 1 // metered << QString("${CONNECTION}/${BOOT}"); // stableId } void ConnectionSettingTest::testSetting() { QFETCH(QString, id); QFETCH(QString, uuid); QFETCH(QString, type); QFETCH(QStringList, permissions); QFETCH(bool, autoconnect); QFETCH(quint64, timestamp); QFETCH(bool, readOnly); QFETCH(QString, zone); QFETCH(QString, master); QFETCH(QString, slaveType); QFETCH(QStringList, secondaries); QFETCH(uint, gatewayPingTimeout); QFETCH(int, autoconnectPriority); QFETCH(int, autoconnectRetries); QFETCH(int, autoconnectSlaves); QFETCH(int, lldp); QFETCH(int, metered); QFETCH(QString, stableId); NMVariantMapMap mapmap; QVariantMap map; map.insert(QLatin1String(NM_SETTING_CONNECTION_ID), id); map.insert(QLatin1String(NM_SETTING_CONNECTION_UUID), uuid); map.insert(QLatin1String(NM_SETTING_CONNECTION_TYPE), type); map.insert(QLatin1String(NM_SETTING_CONNECTION_PERMISSIONS), permissions); map.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT), autoconnect); map.insert(QLatin1String(NM_SETTING_CONNECTION_TIMESTAMP), timestamp); map.insert(QLatin1String(NM_SETTING_CONNECTION_READ_ONLY), readOnly); map.insert(QLatin1String(NM_SETTING_CONNECTION_ZONE), zone); map.insert(QLatin1String(NM_SETTING_CONNECTION_MASTER), master); map.insert(QLatin1String(NM_SETTING_CONNECTION_SLAVE_TYPE), slaveType); map.insert(QLatin1String(NM_SETTING_CONNECTION_SECONDARIES), secondaries); map.insert(QLatin1String(NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT), gatewayPingTimeout); map.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY), autoconnectPriority); map.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES), autoconnectRetries); map.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES), autoconnectSlaves); map.insert(QLatin1String(NM_SETTING_CONNECTION_LLDP), lldp); map.insert(QLatin1String(NM_SETTING_CONNECTION_METERED), metered); map.insert(QLatin1String(NM_SETTING_CONNECTION_STABLE_ID), stableId); mapmap.insert(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME), map); NetworkManager::ConnectionSettings setting; setting.fromMap(mapmap); NMVariantMapMap mapmap1 = setting.toMap(); QVariantMap map1 = mapmap1.value(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME)); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(ConnectionSettingTest) diff --git a/autotests/settings/connectionsettingtest.h b/autotests/settings/connectionsettingtest.h index e5e7c86..c4eb087 100644 --- a/autotests/settings/connectionsettingtest.h +++ b/autotests/settings/connectionsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_CONNECTIONSETTING_TEST_H #define NETWORKMANAGERQT_CONNECTIONSETTING_TEST_H #include class ConnectionSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_CONNECTIONSETTING_TEST_H diff --git a/autotests/settings/dcbsettingtest.cpp b/autotests/settings/dcbsettingtest.cpp index c482eba..df071f9 100644 --- a/autotests/settings/dcbsettingtest.cpp +++ b/autotests/settings/dcbsettingtest.cpp @@ -1,144 +1,130 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "dcbsettingtest.h" #include "settings/dcbsetting.h" #include #include void DcbSettingTest::testSetting_data() { QTest::addColumn("appFcoeMode"); QTest::addColumn("appFcoePriority"); QTest::addColumn("appFipPriority"); QTest::addColumn("appIscsiPriority"); QTest::addColumn("appFcoeFlags"); QTest::addColumn("appFipFlags"); QTest::addColumn("appIscsiFlags"); QTest::addColumn("priorityGroupFlags"); QTest::addColumn("priorityFlowControlFlags"); QTest::addColumn("priorityFlowControl"); QTest::addColumn("priorityBandwidth"); QTest::addColumn("priorityGroupBandwidth"); QTest::addColumn("priorityGroupId"); QTest::addColumn("priorityStrictBandwidth"); QTest::addColumn("priorityTrafficClass"); UIntList priorityFlowControl = {1, 1, 1, 1, 1, 1, 1, 1}; UIntList priorityBandwidth = {6, 5, 6, 4, 6, 3, 6, 2}; UIntList priorityGroupBandwidth = {6, 5, 6, 4, 6, 3, 6, 2}; UIntList priorityGroupId = {6, 5, 6, 4, 6, 3, 6, 2}; UIntList priorityStrictBandwidth = {1, 1, 1, 1, 1, 1, 1, 1}; UIntList priorityTrafficClass = {6, 5, 6, 4, 6, 3, 6, 2}; QTest::newRow("setting1") << QString("vn2vn") // appFcoeMode << (qint32)2 // appFcoePriority << (qint32)2 // appFipPriority << (qint32)2 // appIscsiPriority << (qint32)2 // appFcoeFlags << (qint32)2 // appFipFlags << (qint32)2 // appIscsiFlags << (qint32)2 // priorityGroupFlags << (qint32)2 // priorityFlowControlFlags << priorityFlowControl // priorityFlowControl << priorityBandwidth // priorityBandwidth << priorityGroupBandwidth // priorityGroupBandwidth << priorityGroupId // priorityGroupId << priorityStrictBandwidth // priorityStrictBandwidth << priorityTrafficClass; // priorityTrafficClass } void DcbSettingTest::testSetting() { QFETCH(QString, appFcoeMode); QFETCH(qint32, appFcoePriority); QFETCH(qint32, appFipPriority); QFETCH(qint32, appIscsiPriority); QFETCH(qint32, appFcoeFlags); QFETCH(qint32, appFipFlags); QFETCH(qint32, appIscsiFlags); QFETCH(qint32, priorityGroupFlags); QFETCH(qint32, priorityFlowControlFlags); QFETCH(UIntList, priorityFlowControl); QFETCH(UIntList, priorityBandwidth); QFETCH(UIntList, priorityGroupBandwidth); QFETCH(UIntList, priorityGroupId); QFETCH(UIntList, priorityStrictBandwidth); QFETCH(UIntList, priorityTrafficClass); QVariantMap map; map.insert(QLatin1String(NM_SETTING_DCB_APP_FCOE_MODE), appFcoeMode); map.insert(QLatin1String(NM_SETTING_DCB_APP_FCOE_PRIORITY), appFcoePriority); map.insert(QLatin1String(NM_SETTING_DCB_APP_FIP_PRIORITY), appFipPriority); map.insert(QLatin1String(NM_SETTING_DCB_APP_ISCSI_PRIORITY), appIscsiPriority); map.insert(QLatin1String(NM_SETTING_DCB_APP_FCOE_FLAGS), appFcoeFlags); map.insert(QLatin1String(NM_SETTING_DCB_APP_FIP_FLAGS), appFipFlags); map.insert(QLatin1String(NM_SETTING_DCB_APP_ISCSI_FLAGS), appIscsiFlags); map.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_FLAGS), priorityGroupFlags); map.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS), priorityFlowControlFlags); map.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL), QVariant::fromValue(priorityFlowControl)); map.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_BANDWIDTH), QVariant::fromValue(priorityBandwidth)); map.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH), QVariant::fromValue(priorityGroupBandwidth)); map.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_ID), QVariant::fromValue(priorityGroupId)); map.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH), QVariant::fromValue(priorityStrictBandwidth)); map.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS), QVariant::fromValue(priorityTrafficClass)); NetworkManager::DcbSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { if (it.key() != QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL) && it.key() != QLatin1String(NM_SETTING_DCB_PRIORITY_BANDWIDTH) && it.key() != QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH) && it.key() != QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_ID) && it.key() != QLatin1String(NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH) && it.key() != QLatin1String(NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS)) { QCOMPARE(it.value(), map1.value(it.key())); } ++it; } QCOMPARE(map.value(QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL)).value(), map1.value(QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL)).value()); QCOMPARE(map.value(QLatin1String(NM_SETTING_DCB_PRIORITY_BANDWIDTH)).value(), map1.value(QLatin1String(NM_SETTING_DCB_PRIORITY_BANDWIDTH)).value()); QCOMPARE(map.value(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH)).value(), map1.value(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH)).value()); QCOMPARE(map.value(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_ID)).value(), map1.value(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_ID)).value()); QCOMPARE(map.value(QLatin1String(NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH)).value(), map1.value(QLatin1String(NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH)).value()); QCOMPARE(map.value(QLatin1String(NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS)).value(), map1.value(QLatin1String(NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS)).value()); } QTEST_MAIN(DcbSettingTest) diff --git a/autotests/settings/dcbsettingtest.h b/autotests/settings/dcbsettingtest.h index 0d5a0c4..3d7e080 100644 --- a/autotests/settings/dcbsettingtest.h +++ b/autotests/settings/dcbsettingtest.h @@ -1,36 +1,22 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DCBSETTING_TEST_H #define NETWORKMANAGERQT_DCBSETTING_TEST_H #include class DcbSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_DCBSETTING_TEST_H diff --git a/autotests/settings/gsmsettingtest.cpp b/autotests/settings/gsmsettingtest.cpp index 7217ef0..d63341a 100644 --- a/autotests/settings/gsmsettingtest.cpp +++ b/autotests/settings/gsmsettingtest.cpp @@ -1,110 +1,96 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "gsmsettingtest.h" #include "settings/gsmsetting.h" #include #include void GsmSettingTest::testSetting_data() { QTest::addColumn("number"); QTest::addColumn("username"); QTest::addColumn("password"); QTest::addColumn("passwordFlags"); QTest::addColumn("apn"); QTest::addColumn("networkId"); QTest::addColumn("networkType"); QTest::addColumn("pin"); QTest::addColumn("pinFlags"); QTest::addColumn("allowedBand"); QTest::addColumn("homeOnly"); QTest::addColumn("deviceId"); QTest::addColumn("simId"); QTest::addColumn("simOperatorId"); QTest::newRow("setting1") << QString("0123456789") // number << QString("foo") // username << QString("bar") // password << (qint32) 2 // passwordFlags << QString("test") // apn << QString("MCC-MNC") // networkId << (qint32) 1 // networkType << QString("1010") // pin << (qint32) 4 // pinFlags << (quint32) 0 // allowedBand << true // homeOnly << QString("someDeviceId") // deviceId << QString("someSimId") // simId << QString("someSimOperatorId"); // simOperatorId } void GsmSettingTest::testSetting() { QFETCH(QString, number); QFETCH(QString, username); QFETCH(QString, password); QFETCH(qint32, passwordFlags); QFETCH(QString, apn); QFETCH(QString, networkId); QFETCH(qint32, networkType); QFETCH(QString, pin); QFETCH(qint32, pinFlags); QFETCH(quint32, allowedBand); QFETCH(bool, homeOnly); QFETCH(QString, deviceId); QFETCH(QString, simId); QFETCH(QString, simOperatorId); QVariantMap map; map.insert(QLatin1String(NM_SETTING_GSM_NUMBER), number); map.insert(QLatin1String(NM_SETTING_GSM_USERNAME), username); map.insert(QLatin1String(NM_SETTING_GSM_PASSWORD), password); map.insert(QLatin1String(NM_SETTING_GSM_PASSWORD_FLAGS), passwordFlags); map.insert(QLatin1String(NM_SETTING_GSM_APN), apn); map.insert(QLatin1String(NM_SETTING_GSM_NETWORK_ID), networkId); map.insert(QLatin1String("network-type"), networkType); map.insert(QLatin1String("allowed-bands"), allowedBand); map.insert(QLatin1String(NM_SETTING_GSM_PIN), pin); map.insert(QLatin1String(NM_SETTING_GSM_PIN_FLAGS), pinFlags); map.insert(QLatin1String(NM_SETTING_GSM_HOME_ONLY), homeOnly); map.insert(QLatin1String(NM_SETTING_GSM_DEVICE_ID), deviceId); map.insert(QLatin1String(NM_SETTING_GSM_SIM_ID), simId); map.insert(QLatin1String(NM_SETTING_GSM_SIM_OPERATOR_ID), simOperatorId); NetworkManager::GsmSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(GsmSettingTest) diff --git a/autotests/settings/gsmsettingtest.h b/autotests/settings/gsmsettingtest.h index 13f6103..df30a85 100644 --- a/autotests/settings/gsmsettingtest.h +++ b/autotests/settings/gsmsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_GSMSETTING_TEST_H #define NETWORKMANAGERQT_GSMSETTING_TEST_H #include class GsmSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_GSMSETTING_TEST_H diff --git a/autotests/settings/infinibandsettingtest.cpp b/autotests/settings/infinibandsettingtest.cpp index aa1357b..51e206f 100644 --- a/autotests/settings/infinibandsettingtest.cpp +++ b/autotests/settings/infinibandsettingtest.cpp @@ -1,64 +1,50 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "infinibandsettingtest.h" #include "settings/infinibandsetting.h" #include #include void InfinibandSettingTest::testSetting_data() { QTest::addColumn("macAddress"); QTest::addColumn("mtu"); QTest::addColumn("transportMode"); QTest::newRow("setting1") << QByteArray("eth0") // macAddress << (quint32) 1000 // mtu << "connected"; // transportMode } void InfinibandSettingTest::testSetting() { QFETCH(QByteArray, macAddress); QFETCH(quint32, mtu); QFETCH(QString, transportMode); QVariantMap map; map.insert(QLatin1String(NM_SETTING_INFINIBAND_MAC_ADDRESS), macAddress); map.insert(QLatin1String(NM_SETTING_INFINIBAND_MTU), mtu); map.insert(QLatin1String(NM_SETTING_INFINIBAND_TRANSPORT_MODE), transportMode); NetworkManager::InfinibandSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(InfinibandSettingTest) diff --git a/autotests/settings/infinibandsettingtest.h b/autotests/settings/infinibandsettingtest.h index d0a546a..dfc8b78 100644 --- a/autotests/settings/infinibandsettingtest.h +++ b/autotests/settings/infinibandsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_INFINIBANDSETTING_TEST_H #define NETWORKMANAGERQT_INFINIBANDSETTING_TEST_H #include class InfinibandSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_INFINIBANDSETTING_TEST_H diff --git a/autotests/settings/iptunnelsettingtest.cpp b/autotests/settings/iptunnelsettingtest.cpp index 8915bd0..3b0bb7a 100644 --- a/autotests/settings/iptunnelsettingtest.cpp +++ b/autotests/settings/iptunnelsettingtest.cpp @@ -1,110 +1,96 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "iptunnelsettingtest.h" #include "settings/iptunnelsetting.h" #include #include #if !NM_CHECK_VERSION(1, 12, 0) #define NM_SETTING_IP_TUNNEL_FLAGS "flags" #endif void IpTunnelSettingTest::testSetting_data() { QTest::addColumn("mode"); QTest::addColumn("pathMtuDiscovery"); QTest::addColumn("encapsulationLimit"); QTest::addColumn("flags"); QTest::addColumn("flowLabel"); QTest::addColumn("mtu"); QTest::addColumn("tos"); QTest::addColumn("ttl"); QTest::addColumn("inputKey"); QTest::addColumn("local"); QTest::addColumn("parent"); QTest::addColumn("outputKey"); QTest::addColumn("remote"); QTest::newRow("setting1") << (quint32)2 // mode << false // pathMtuDiscovery << (quint32)1 // encapsulationLimit << (quint32)0x02 // flags << (quint32)1 // flowLabel << (quint32)1 // mtu << (quint32)1 // tos << (quint32)1 // ttl << QString("key") // inputKey << QString("abc") // local << QString("par") // parent << QString("out") // outputKey << QString("rem"); // remote } void IpTunnelSettingTest::testSetting() { QFETCH(quint32, mode); QFETCH(bool, pathMtuDiscovery); QFETCH(quint32, encapsulationLimit); QFETCH(quint32, flags); QFETCH(quint32, flowLabel); QFETCH(quint32, mtu); QFETCH(quint32, tos); QFETCH(quint32, ttl); QFETCH(QString, inputKey); QFETCH(QString, local); QFETCH(QString, parent); QFETCH(QString, outputKey); QFETCH(QString, remote); QVariantMap map; map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MODE), mode); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY), pathMtuDiscovery); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT), encapsulationLimit); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS), flags); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL), flowLabel); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MTU), mtu); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TOS), tos); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TTL), ttl); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY), inputKey); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL), local); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT), parent); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY), outputKey); map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE), remote); NetworkManager::IpTunnelSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(IpTunnelSettingTest) diff --git a/autotests/settings/iptunnelsettingtest.h b/autotests/settings/iptunnelsettingtest.h index bf71ba2..253004b 100644 --- a/autotests/settings/iptunnelsettingtest.h +++ b/autotests/settings/iptunnelsettingtest.h @@ -1,36 +1,22 @@ /* Copyright Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IP_TUNNEL_SETTING_TEST_H #define NETWORKMANAGERQT_IP_TUNNEL_SETTING_TEST_H #include class IpTunnelSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_IP_TUNNEL_SETTING_TEST_H diff --git a/autotests/settings/ipv4settingtest.cpp b/autotests/settings/ipv4settingtest.cpp index a419f86..c14e0f8 100644 --- a/autotests/settings/ipv4settingtest.cpp +++ b/autotests/settings/ipv4settingtest.cpp @@ -1,197 +1,183 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ipv4settingtest.h" #include "generictypes.h" #include "settings/ipv4setting.h" #include #include #include void IPv4SettingTest::testSetting_data() { QTest::addColumn("method"); QTest::addColumn("dns"); QTest::addColumn("dnsSearch"); QTest::addColumn("addresses"); QTest::addColumn("routes"); QTest::addColumn("routeMetric"); QTest::addColumn("ignoreAutoRoutes"); QTest::addColumn("ignoreAutoDns"); QTest::addColumn("dhcpClientId"); QTest::addColumn("dhcpSendHostname"); QTest::addColumn("dhcpHostname"); QTest::addColumn("neverDefault"); QTest::addColumn("mayFail"); QTest::addColumn("dadTimeout"); QTest::addColumn("dhcpFqdn"); QTest::addColumn("dnsOptions"); QTest::addColumn("dnsPriority"); QTest::addColumn("gateway"); QTest::addColumn("addressData"); QTest::addColumn("routeData"); QList dns; dns << inet_addr("10.0.0.1"); dns << inet_addr("10.0.1.1"); QStringList dnsSearch; dnsSearch << "foo.com"; dnsSearch << "foo.bar"; QList > addresses; QList addr; addr << inet_addr("192.168.1.1"); addr << 25; addr << 0; addresses << addr; QList > routes; QList routeAddr; routeAddr << inet_addr("192.168.1.1"); routeAddr << 25; routeAddr << inet_addr("192.169.1.1"); routeAddr << 25; routes << routeAddr; QStringList dnsOptions; dnsOptions << "opt1"; dnsOptions << "opt2"; NMVariantMapList addressData; QVariantMap addressMap; addressMap["address"] = "192.168.1.1"; addressMap["prefix"] = 25; addressData.append(addressMap); NMVariantMapList routeData; QVariantMap routeMap; routeMap["dest"] = "192.168.1.1"; routeMap["prefix"] = 25; routeData.append(routeMap); routeMap.clear(); routeMap["dest"] = "192.168.1.2"; routeMap["prefix"] = 25; routeData.append(routeMap); QTest::newRow("setting1") << QString("auto") // method << dns // dns << dnsSearch // dnsSearch << addresses // addresses << routes // routes << 100 // routeMetric << true // ignoreAutoRoutes << true // ignoreAutoDns << QString("home-test") // dhcpClientId << false // dhcpSendHostname << QString("home-test") // dhcpHostname << true // neverDefault << false // mayFail << 100 // dadTimeout << QString("foo.com") // dhcpFqdn << dnsOptions // dnsOptions << 100 // dnsPriority << QString("1.1.1.1") // gateway << addressData // addressData << routeData; // routeData } void IPv4SettingTest::testSetting() { QFETCH(QString, method); QFETCH(UIntList, dns); QFETCH(QStringList, dnsSearch); QFETCH(UIntListList, addresses); QFETCH(UIntListList, routes); QFETCH(int, routeMetric); QFETCH(bool, ignoreAutoRoutes); QFETCH(bool, ignoreAutoDns); QFETCH(QString, dhcpClientId); QFETCH(bool, dhcpSendHostname); QFETCH(QString, dhcpHostname); QFETCH(bool, neverDefault); QFETCH(bool, mayFail); QFETCH(qint32, dadTimeout); QFETCH(QString, dhcpFqdn); QFETCH(QStringList, dnsOptions); QFETCH(qint32, dnsPriority); QFETCH(QString, gateway); QFETCH(NMVariantMapList, addressData); QFETCH(NMVariantMapList, routeData); QVariantMap map; map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD), method); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS), QVariant::fromValue(dns)); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_SEARCH), dnsSearch); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESSES), QVariant::fromValue(addresses)); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTES), QVariant::fromValue(routes)); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_METRIC), routeMetric); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES), ignoreAutoRoutes); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS), ignoreAutoDns); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_CLIENT_ID), dhcpClientId); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME), dhcpSendHostname); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_HOSTNAME), dhcpHostname); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_NEVER_DEFAULT), neverDefault); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_MAY_FAIL), mayFail); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DAD_TIMEOUT), dadTimeout); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_FQDN), dhcpFqdn); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_OPTIONS), dnsOptions); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_PRIORITY), dnsPriority); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_GATEWAY), gateway); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESS_DATA), QVariant::fromValue(addressData)); map.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_DATA), QVariant::fromValue(routeData)); NetworkManager::Ipv4Setting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { if (it.key() != QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS) && it.key() != QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESSES) && it.key() != QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTES) && it.key() != QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESS_DATA) && it.key() != QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_DATA)) { QCOMPARE(it.value(), map1.value(it.key())); } ++it; } QCOMPARE(map.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).value(), map1.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).value()); QCOMPARE(map.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESSES)).value(), map1.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESSES)).value()); QCOMPARE(map.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTES)).value(), map1.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTES)).value()); QCOMPARE(qdbus_cast(map.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESS_DATA))), qdbus_cast(map1.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESS_DATA)))); QCOMPARE(qdbus_cast(map.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_DATA))), qdbus_cast(map1.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_DATA)))); } QTEST_MAIN(IPv4SettingTest) diff --git a/autotests/settings/ipv4settingtest.h b/autotests/settings/ipv4settingtest.h index b554b59..a0540a4 100644 --- a/autotests/settings/ipv4settingtest.h +++ b/autotests/settings/ipv4settingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPV4SETTING_TEST_H #define NETWORKMANAGERQT_IPV4SETTING_TEST_H #include class IPv4SettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_IPV4SETTING_TEST_H diff --git a/autotests/settings/ipv6settingtest.cpp b/autotests/settings/ipv6settingtest.cpp index 6e1deff..11e4fbf 100644 --- a/autotests/settings/ipv6settingtest.cpp +++ b/autotests/settings/ipv6settingtest.cpp @@ -1,238 +1,224 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ipv6settingtest.h" #include "generictypes.h" #include "utils.h" #include "settings/ipv6setting.h" #include #include #include #include using namespace NetworkManager; //TODO: Test DNS,IPv6Addresses and IPv6Routes void IPv6SettingTest::testSetting_data() { QTest::addColumn("method"); QTest::addColumn("dns"); QTest::addColumn("dnsSearch"); QTest::addColumn("addresses"); QTest::addColumn("routes"); QTest::addColumn("routeMetric"); QTest::addColumn("ignoreAutoRoutes"); QTest::addColumn("ignoreAutoDns"); QTest::addColumn("neverDefault"); QTest::addColumn("mayFail"); QTest::addColumn("privacy"); QTest::addColumn("dadTimeout"); QTest::addColumn("addressGenMode"); QTest::addColumn("dhcpTimeout"); QTest::addColumn("dhcpHostname"); QTest::addColumn("dhcpDuid"); QTest::addColumn("token"); QTest::addColumn("dnsOptions"); QTest::addColumn("addressData"); QTest::addColumn("routeData"); QTest::addColumn("routeTable"); QStringList dnsSearch; dnsSearch << "foo.com"; dnsSearch << "foo.bar"; IpV6DBusNameservers dns; QByteArray dnsAddr1 = ipv6AddressFromHostAddress(QHostAddress("2607:f0d0:1002:0051:0000:0000:0000:0004")); dns << dnsAddr1; IpV6DBusAddressList addresses; IpV6DBusAddress address; address.address = ipv6AddressFromHostAddress(QHostAddress("2001:0db8:0000:0000:0000::1428:57ab")); address.prefix = 64; address.gateway = ipv6AddressFromHostAddress(QHostAddress("2001:0db8:0:f101::1")); addresses << address; IpV6DBusRouteList routes; IpV6DBusRoute route; route.destination = ipv6AddressFromHostAddress(QHostAddress("2001:0db8:0000:0000:0000::1428:57ab")); route.prefix = 48; route.nexthop = ipv6AddressFromHostAddress(QHostAddress("2001:638:500:101:2e0:81ff:fe24:37c6")); route.metric = 1024; routes << route; NMVariantMapList addressData; QVariantMap addressMap; addressMap["address"] = "192.168.1.1"; addressMap["prefix"] = 25; addressData.append(addressMap); NMVariantMapList routeData; QVariantMap routeMap; routeMap["dest"] = "192.168.1.1"; routeMap["prefix"] = 25; routeData.append(routeMap); routeMap.clear(); routeMap["dest"] = "192.168.1.2"; routeMap["prefix"] = 25; routeData.append(routeMap); QTest::newRow("setting1") << QString("auto") // method << dns // dns << dnsSearch // dnsSearch << addresses // addresses << routes // routes << 100 // routeMetric << true // ignoreAutoRoutes << true // ignoreAutoDns << true // neverDefault << false // mayFail << (quint32) 0 // privacy << (quint32) 1101 // dadTimeout << (quint32) 0 // addressGenMode << (quint32) 110 // dhcpTimeout << QString("dhcp-hostname") // dhcpHostname << QString("dhcp-duid") // dhcpDuid << QString("token") // token << QStringList {QString("option1"), QString("option2")} // dnsOptions << addressData // addressData << routeData // routeData << (quint32) 1; // routeTable } void IPv6SettingTest::testSetting() { QFETCH(QString, method); QFETCH(IpV6DBusNameservers, dns); QFETCH(QStringList, dnsSearch); QFETCH(IpV6DBusAddressList, addresses); QFETCH(IpV6DBusRouteList, routes); QFETCH(int, routeMetric); QFETCH(bool, ignoreAutoRoutes); QFETCH(bool, ignoreAutoDns); QFETCH(bool, neverDefault); QFETCH(bool, mayFail); QFETCH(quint32, privacy); QFETCH(quint32, dadTimeout); QFETCH(quint32, addressGenMode); QFETCH(quint32, dhcpTimeout); QFETCH(QString, dhcpHostname); QFETCH(QString, dhcpDuid); QFETCH(QString, token); QFETCH(QStringList, dnsOptions); QFETCH(NMVariantMapList, addressData); QFETCH(NMVariantMapList, routeData); QFETCH(quint32, routeTable); QVariantMap map; map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD), method); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS), QVariant::fromValue(dns)); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS_SEARCH), dnsSearch); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESSES), QVariant::fromValue(addresses)); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTES), QVariant::fromValue(routes)); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_METRIC), routeMetric); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES), ignoreAutoRoutes); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS), ignoreAutoDns); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_NEVER_DEFAULT), neverDefault); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_MAY_FAIL), mayFail); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_IP6_PRIVACY), privacy); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DAD_TIMEOUT), dadTimeout); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_GEN_MODE), addressGenMode); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_TIMEOUT), dhcpTimeout); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_HOSTNAME), dhcpHostname); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_DUID), dhcpDuid); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_TOKEN), token); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS_OPTIONS), dnsOptions); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_DATA), QVariant::fromValue(addressData)); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_DATA), QVariant::fromValue(routeData)); map.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_TABLE), routeTable); NetworkManager::Ipv6Setting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { if (it.key() != QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS) && it.key() != QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESSES) && it.key() != QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTES) && it.key() != QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_DATA) && it.key() != QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_DATA)) { QCOMPARE(it.value(), map1.value(it.key())); } ++it; } IpV6DBusNameservers nameServers1 = map.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS)).value(); IpV6DBusNameservers nameServers2 = map1.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS)).value(); for (int i = 0; i < nameServers1.size(); i++) { QHostAddress dnsAddr1 = ipv6AddressAsHostAddress(nameServers1.at(i)); QHostAddress dnsAddr2 = ipv6AddressAsHostAddress(nameServers2.at(i)); QCOMPARE(dnsAddr1.protocol(), QAbstractSocket::IPv6Protocol); QCOMPARE(dnsAddr2.protocol(), QAbstractSocket::IPv6Protocol); QCOMPARE(dnsAddr1, dnsAddr2); } IpV6DBusAddressList addresses1 = map.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESSES)).value(); IpV6DBusAddressList addresses2 = map1.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESSES)).value(); for (int i = 0; i < addresses1.size(); i++) { QHostAddress addr1(QString(addresses1.at(i).address)); QHostAddress addr2(QString(addresses2.at(i).address)); QHostAddress gateway1(QString(addresses1.at(i).gateway)); QHostAddress gateway2(QString(addresses2.at(i).gateway)); QCOMPARE(addr1, addr2); QCOMPARE(addresses1.at(i).prefix, addresses2.at(i).prefix); QCOMPARE(gateway1, gateway2); } IpV6DBusRouteList routes1 = map.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES)).value(); IpV6DBusRouteList routes2 = map1.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES)).value(); for (int i = 0; i < routes1.size(); i++) { QHostAddress destination1(QString(routes1.at(i).destination)); QHostAddress destination2(QString(routes2.at(i).destination)); QHostAddress nexthop1(QString(routes1.at(i).nexthop)); QHostAddress nexthop2(QString(routes2.at(i).nexthop)); QCOMPARE(destination1, destination2); QCOMPARE(routes1.at(i).prefix, routes2.at(i).prefix); QCOMPARE(nexthop1, nexthop2); QCOMPARE(routes1.at(i).metric, routes2.at(i).metric); } QCOMPARE(qdbus_cast(map.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_DATA))), qdbus_cast(map1.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_DATA)))); QCOMPARE(qdbus_cast(map.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_DATA))), qdbus_cast(map1.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_DATA)))); } QTEST_MAIN(IPv6SettingTest) diff --git a/autotests/settings/ipv6settingtest.h b/autotests/settings/ipv6settingtest.h index 1eb7d0a..e34a4a0 100644 --- a/autotests/settings/ipv6settingtest.h +++ b/autotests/settings/ipv6settingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPV6SETTING_TEST_H #define NETWORKMANAGERQT_IPV6SETTING_TEST_H #include class IPv6SettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_IPV6SETTING_TEST_H diff --git a/autotests/settings/macsecsettingtest.cpp b/autotests/settings/macsecsettingtest.cpp index 5f09217..005b3fe 100644 --- a/autotests/settings/macsecsettingtest.cpp +++ b/autotests/settings/macsecsettingtest.cpp @@ -1,106 +1,92 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "macsecsettingtest.h" #include "settings/macsecsetting.h" #include #include #if !NM_CHECK_VERSION(1, 6, 0) #define NM_SETTING_MACSEC_PARENT "parent" #define NM_SETTING_MACSEC_MODE "mode" #define NM_SETTING_MACSEC_ENCRYPT "encrypt" #define NM_SETTING_MACSEC_MKA_CAK "mka-cak" #define NM_SETTING_MACSEC_MKA_CAK_FLAGS "mka-cak-flags" #define NM_SETTING_MACSEC_MKA_CKN "mka-ckn" #define NM_SETTING_MACSEC_PORT "port" #define NM_SETTING_MACSEC_VALIDATION "validation" #endif #if !NM_CHECK_VERSION(1, 12, 0) #define NM_SETTING_MACSEC_SEND_SCI "send-sci" #endif void MacsecSettingTest::testSetting_data() { QTest::addColumn("encrypt"); QTest::addColumn("mkaCak"); QTest::addColumn("mkaCkn"); QTest::addColumn("mode"); QTest::addColumn("parent"); QTest::addColumn("port"); QTest::addColumn("sendSci"); QTest::addColumn("validation"); QTest::addColumn("mkaCakFlags"); QTest::newRow("setting1") << false // encrypt << QString("abc") // mkaCak << QString("abc") // mkaCkn << (qint32) 1 // mode << QString("abc") // parent << (qint32) 666 // port << false // sendSci << (qint32) 4 // validation << (quint32) 6; // mkaCakFlags } void MacsecSettingTest::testSetting() { QFETCH(bool, encrypt); QFETCH(QString, mkaCak); QFETCH(QString, mkaCkn); QFETCH(qint32, mode); QFETCH(QString, parent); QFETCH(qint32, port); QFETCH(bool, sendSci); QFETCH(qint32, validation); QFETCH(quint32, mkaCakFlags); QVariantMap map; map.insert(QLatin1String(NM_SETTING_MACSEC_ENCRYPT), encrypt); map.insert(QLatin1String(NM_SETTING_MACSEC_MKA_CAK), mkaCak); map.insert(QLatin1String(NM_SETTING_MACSEC_MKA_CKN), mkaCkn); map.insert(QLatin1String(NM_SETTING_MACSEC_MODE), mode); map.insert(QLatin1String(NM_SETTING_MACSEC_PARENT), parent); map.insert(QLatin1String(NM_SETTING_MACSEC_PORT), port); map.insert(QLatin1String(NM_SETTING_MACSEC_SEND_SCI), sendSci); map.insert(QLatin1String(NM_SETTING_MACSEC_VALIDATION), validation); map.insert(QLatin1String(NM_SETTING_MACSEC_MKA_CAK_FLAGS), mkaCakFlags); NetworkManager::MacsecSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(MacsecSettingTest) diff --git a/autotests/settings/macsecsettingtest.h b/autotests/settings/macsecsettingtest.h index 9217c64..a55843b 100644 --- a/autotests/settings/macsecsettingtest.h +++ b/autotests/settings/macsecsettingtest.h @@ -1,36 +1,22 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MACSECSETTING_TEST_H #define NETWORKMANAGERQT_MACSECSETTING_TEST_H #include class MacsecSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_MACSECSETTING_TEST_H diff --git a/autotests/settings/matchsettingtest.cpp b/autotests/settings/matchsettingtest.cpp index bc89325..037daa5 100644 --- a/autotests/settings/matchsettingtest.cpp +++ b/autotests/settings/matchsettingtest.cpp @@ -1,63 +1,49 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "matchsettingtest.h" #include "settings/matchsetting.h" #include #include #if !NM_CHECK_VERSION(1, 14, 0) #define NM_SETTING_MATCH_INTERFACE_NAME "interface-name" #endif void MatchSettingTest::testSetting_data() { QTest::addColumn("interfaceName"); QTest::newRow("setting1") << QStringList {QString("name1"), QString("name2")}; // interfaceName } void MatchSettingTest::testSetting() { QFETCH(QStringList, interfaceName); QVariantMap map; map.insert(QLatin1String(NM_SETTING_MATCH_INTERFACE_NAME), interfaceName); NetworkManager::MatchSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(MatchSettingTest) diff --git a/autotests/settings/matchsettingtest.h b/autotests/settings/matchsettingtest.h index c38368a..a611a36 100644 --- a/autotests/settings/matchsettingtest.h +++ b/autotests/settings/matchsettingtest.h @@ -1,36 +1,22 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MATCHSETTING_TEST_H #define NETWORKMANAGERQT_MATCHSETTING_TEST_H #include class MatchSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_MATCHSETTING_TEST_H diff --git a/autotests/settings/olpcmeshsettingtest.cpp b/autotests/settings/olpcmeshsettingtest.cpp index e8d5ca3..5a16d6c 100644 --- a/autotests/settings/olpcmeshsettingtest.cpp +++ b/autotests/settings/olpcmeshsettingtest.cpp @@ -1,65 +1,51 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "olpcmeshsettingtest.h" #include "settings/olpcmeshsetting.h" #include #include void OlpcMeshSettingTest::testSetting_data() { QTest::addColumn("ssid"); QTest::addColumn("channel"); QTest::addColumn("dhcpAnycastAddress"); QTest::newRow("setting1") << QByteArray("ssid") // ssid << (quint32) 1 // channel << QByteArray("00:A0:C9:14:C8:29"); // dhcpAnycastAddress } void OlpcMeshSettingTest::testSetting() { QFETCH(QByteArray, ssid); QFETCH(quint32, channel); QFETCH(QByteArray, dhcpAnycastAddress); QVariantMap map; map.insert(QLatin1String(NM_SETTING_OLPC_MESH_SSID), ssid); map.insert(QLatin1String(NM_SETTING_OLPC_MESH_CHANNEL), channel); map.insert(QLatin1String(NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS), dhcpAnycastAddress); NetworkManager::OlpcMeshSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(OlpcMeshSettingTest) diff --git a/autotests/settings/olpcmeshsettingtest.h b/autotests/settings/olpcmeshsettingtest.h index 1d1c75b..dbf3ca3 100644 --- a/autotests/settings/olpcmeshsettingtest.h +++ b/autotests/settings/olpcmeshsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OLPCMESHSETTING_TEST_H #define NETWORKMANAGERQT_OLPCMESHSETTING_TEST_H #include class OlpcMeshSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_OLPCMESHSETTING_TEST_H diff --git a/autotests/settings/ovsbridgesettingtest.cpp b/autotests/settings/ovsbridgesettingtest.cpp index 4fb0003..66b14aa 100644 --- a/autotests/settings/ovsbridgesettingtest.cpp +++ b/autotests/settings/ovsbridgesettingtest.cpp @@ -1,79 +1,65 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ovsbridgesettingtest.h" #include "settings/ovsbridgesetting.h" #include #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_OVS_BRIDGE_SETTING_NAME "ovs-bridge" #define NM_SETTING_OVS_BRIDGE_FAIL_MODE "fail-mode" #define NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE "mcast-snooping-enable" #define NM_SETTING_OVS_BRIDGE_RSTP_ENABLE "rstp-enable" #define NM_SETTING_OVS_BRIDGE_STP_ENABLE "stp-enable" #endif void OvsBridgeSettingTest::testSetting_data() { QTest::addColumn("mcastSnoopingEnable"); QTest::addColumn("rstpEnable"); QTest::addColumn("stpEnable"); QTest::addColumn("failMode"); QTest::newRow("setting1") << true // mcastSnoopingEnable << true // rstpEnable << true // stpEnable << QString("secure"); // failMode } void OvsBridgeSettingTest::testSetting() { QFETCH(bool, mcastSnoopingEnable); QFETCH(bool, rstpEnable); QFETCH(bool, stpEnable); QFETCH(QString, failMode); QVariantMap map; map.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE), mcastSnoopingEnable); map.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_RSTP_ENABLE), rstpEnable); map.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_STP_ENABLE), stpEnable); map.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_FAIL_MODE), failMode); NetworkManager::OvsBridgeSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(OvsBridgeSettingTest) diff --git a/autotests/settings/ovsbridgesettingtest.h b/autotests/settings/ovsbridgesettingtest.h index 845c2b6..48f1692 100644 --- a/autotests/settings/ovsbridgesettingtest.h +++ b/autotests/settings/ovsbridgesettingtest.h @@ -1,36 +1,22 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_BRIDGE_SETTING_TEST_H #define NETWORKMANAGERQT_OVS_BRIDGE_SETTING_TEST_H #include class OvsBridgeSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_OVS_BRIDGE_SETTING_TEST_H diff --git a/autotests/settings/ovsinterfacesettingtest.cpp b/autotests/settings/ovsinterfacesettingtest.cpp index 5c84d0d..00bf493 100644 --- a/autotests/settings/ovsinterfacesettingtest.cpp +++ b/autotests/settings/ovsinterfacesettingtest.cpp @@ -1,62 +1,48 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ovsinterfacesettingtest.h" #include "settings/ovsinterfacesetting.h" #include #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_OVS_INTERFACE_TYPE "type" #endif void OvsInterfaceSettingTest::testSetting_data() { QTest::addColumn("type"); QTest::newRow("setting1") << QString("internal"); // type } void OvsInterfaceSettingTest::testSetting() { QFETCH(QString, type); QVariantMap map; map.insert(QLatin1String(NM_SETTING_OVS_INTERFACE_TYPE), type); NetworkManager::OvsInterfaceSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(OvsInterfaceSettingTest) diff --git a/autotests/settings/ovsinterfacesettingtest.h b/autotests/settings/ovsinterfacesettingtest.h index 0a3ebf1..0e44856 100644 --- a/autotests/settings/ovsinterfacesettingtest.h +++ b/autotests/settings/ovsinterfacesettingtest.h @@ -1,36 +1,22 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_INTERFACE_SETTING_TEST_H #define NETWORKMANAGERQT_OVS_INTERFACE_SETTING_TEST_H #include class OvsInterfaceSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_OVS_INTERFACE_SETTING_TEST_H diff --git a/autotests/settings/ovspatchsettingtest.cpp b/autotests/settings/ovspatchsettingtest.cpp index e779642..1d36ce4 100644 --- a/autotests/settings/ovspatchsettingtest.cpp +++ b/autotests/settings/ovspatchsettingtest.cpp @@ -1,62 +1,48 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ovspatchsettingtest.h" #include "settings/ovspatchsetting.h" #include #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_OVS_PATCH_PEER "peer" #endif void OvsPatchSettingTest::testSetting_data() { QTest::addColumn("peer"); QTest::newRow("setting1") << QString("abc"); // peer } void OvsPatchSettingTest::testSetting() { QFETCH(QString, peer); QVariantMap map; map.insert(QLatin1String(NM_SETTING_OVS_PATCH_PEER), peer); NetworkManager::OvsPatchSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(OvsPatchSettingTest) diff --git a/autotests/settings/ovspatchsettingtest.h b/autotests/settings/ovspatchsettingtest.h index a78eb11..914f7a6 100644 --- a/autotests/settings/ovspatchsettingtest.h +++ b/autotests/settings/ovspatchsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_PATCH_SETTING_TEST_H #define NETWORKMANAGERQT_OVS_PATCH_SETTING_TEST_H #include class OvsPatchSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_OVS_PATCH_SETTING_TEST_H diff --git a/autotests/settings/ovsportsettingtest.cpp b/autotests/settings/ovsportsettingtest.cpp index 0666d90..58cf129 100644 --- a/autotests/settings/ovsportsettingtest.cpp +++ b/autotests/settings/ovsportsettingtest.cpp @@ -1,87 +1,73 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ovsportsettingtest.h" #include "settings/ovsportsetting.h" #include #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_OVS_PORT_VLAN_MODE "vlan-mode" #define NM_SETTING_OVS_PORT_TAG "tag" #define NM_SETTING_OVS_PORT_LACP "lacp" #define NM_SETTING_OVS_PORT_BOND_MODE "bond-mode" #define NM_SETTING_OVS_PORT_BOND_UPDELAY "bond-updelay" #define NM_SETTING_OVS_PORT_BOND_DOWNDELAY "bond-downdelay" #endif void OvsPortSettingTest::testSetting_data() { QTest::addColumn("bondDowndelay"); QTest::addColumn("bondUpdelay"); QTest::addColumn("tag"); QTest::addColumn("lacp"); QTest::addColumn("bondMode"); QTest::addColumn("vlanMode"); QTest::newRow("setting1") << (quint32)1 // bondDowndelay << (quint32)1 // bondUpdelay << (quint32)1 // tag << QString("off") // lacp << QString("active-backup") // bondMode << QString("trunk"); // vlanMode } void OvsPortSettingTest::testSetting() { QFETCH(quint32, bondDowndelay); QFETCH(quint32, bondUpdelay); QFETCH(quint32, tag); QFETCH(QString, lacp); QFETCH(QString, bondMode); QFETCH(QString, vlanMode); QVariantMap map; map.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_DOWNDELAY), bondDowndelay); map.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_UPDELAY), bondUpdelay); map.insert(QLatin1String(NM_SETTING_OVS_PORT_TAG), tag); map.insert(QLatin1String(NM_SETTING_OVS_PORT_LACP), lacp); map.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_MODE), bondMode); map.insert(QLatin1String(NM_SETTING_OVS_PORT_VLAN_MODE), vlanMode); NetworkManager::OvsPortSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(OvsPortSettingTest) diff --git a/autotests/settings/ovsportsettingtest.h b/autotests/settings/ovsportsettingtest.h index 96db8cd..bd185ba 100644 --- a/autotests/settings/ovsportsettingtest.h +++ b/autotests/settings/ovsportsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_PORT_SETTING_TEST_H #define NETWORKMANAGERQT_OVS_PORT_SETTING_TEST_H #include class OvsPortSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_OVS_PORT_SETTING_TEST_H diff --git a/autotests/settings/pppoesettingtest.cpp b/autotests/settings/pppoesettingtest.cpp index 94261c9..7507094 100644 --- a/autotests/settings/pppoesettingtest.cpp +++ b/autotests/settings/pppoesettingtest.cpp @@ -1,69 +1,55 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "pppoesettingtest.h" #include "settings/pppoesetting.h" #include #include void PppoeSettingTest::testSetting_data() { QTest::addColumn("service"); QTest::addColumn("username"); QTest::addColumn("password"); QTest::addColumn("passwordFlags"); QTest::newRow("setting1") << QString("service") // service << QString("username") // username << QString("password") // password << (quint32) 3; // passwordFlags } void PppoeSettingTest::testSetting() { QFETCH(QString, service); QFETCH(QString, username); QFETCH(QString, password); QFETCH(quint32, passwordFlags); QVariantMap map; map.insert(QLatin1String(NM_SETTING_PPPOE_SERVICE), service); map.insert(QLatin1String(NM_SETTING_PPPOE_USERNAME), username); map.insert(QLatin1String(NM_SETTING_PPPOE_PASSWORD), password); map.insert(QLatin1String(NM_SETTING_PPPOE_PASSWORD_FLAGS), passwordFlags); NetworkManager::PppoeSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(PppoeSettingTest) diff --git a/autotests/settings/pppoesettingtest.h b/autotests/settings/pppoesettingtest.h index fc6d0a0..986205a 100644 --- a/autotests/settings/pppoesettingtest.h +++ b/autotests/settings/pppoesettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_PPPOESETTING_TEST_H #define NETWORKMANAGERQT_PPPOESETTING_TEST_H #include class PppoeSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_PPPOESETTING_TEST_H diff --git a/autotests/settings/pppsettingtest.cpp b/autotests/settings/pppsettingtest.cpp index b279e59..2b3aaaa 100644 --- a/autotests/settings/pppsettingtest.cpp +++ b/autotests/settings/pppsettingtest.cpp @@ -1,125 +1,111 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "pppsettingtest.h" #include "settings/pppsetting.h" #include #include void PppSettingTest::testSetting_data() { QTest::addColumn("noAuth"); QTest::addColumn("refuseEap"); QTest::addColumn("refusePap"); QTest::addColumn("refuseChap"); QTest::addColumn("refuseMschap"); QTest::addColumn("refuseMschapv2"); QTest::addColumn("noBsdComp"); QTest::addColumn("noDeflate"); QTest::addColumn("noVjCompare"); QTest::addColumn("requireMppe"); QTest::addColumn("requireMppe128"); QTest::addColumn("mppeStateful"); QTest::addColumn("cRtsCts"); QTest::addColumn("baud"); QTest::addColumn("mru"); QTest::addColumn("mtu"); QTest::addColumn("lcpEchoFailure"); QTest::addColumn("lcpEchoInterval"); QTest::newRow("setting1") << false // noAuth << true // refuseEap << true // refusePap << true // refuseChap << true // refuseMschap << true // refuseMschapv2 << true // noBsdComp << true // noDeflate << true // noVjCompare << true // requireMppe << true // requireMppe128 << true // mppeStateful << true // cRtsCts << (quint32) 1000 // baud << (quint32) 128 // mru << (quint32) 500 // mtu << (quint32) 2 // lcpEchoFailure << (quint32) 3; // lcpEchoInterval } void PppSettingTest::testSetting() { QFETCH(bool, noAuth); QFETCH(bool, refuseEap); QFETCH(bool, refusePap); QFETCH(bool, refuseChap); QFETCH(bool, refuseMschap); QFETCH(bool, refuseMschapv2); QFETCH(bool, noBsdComp); QFETCH(bool, noDeflate); QFETCH(bool, noVjCompare); QFETCH(bool, requireMppe); QFETCH(bool, requireMppe128); QFETCH(bool, mppeStateful); QFETCH(bool, cRtsCts); QFETCH(quint32, baud); QFETCH(quint32, mru); QFETCH(quint32, mtu); QFETCH(quint32, lcpEchoFailure); QFETCH(quint32, lcpEchoInterval); QVariantMap map; map.insert(QLatin1String(NM_SETTING_PPP_NOAUTH), noAuth); map.insert(QLatin1String(NM_SETTING_PPP_REFUSE_EAP), refuseEap); map.insert(QLatin1String(NM_SETTING_PPP_REFUSE_PAP), refusePap); map.insert(QLatin1String(NM_SETTING_PPP_REFUSE_CHAP), refuseChap); map.insert(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAP), refuseMschap); map.insert(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAPV2), refuseMschapv2); map.insert(QLatin1String(NM_SETTING_PPP_NOBSDCOMP), noBsdComp); map.insert(QLatin1String(NM_SETTING_PPP_NODEFLATE), noDeflate); map.insert(QLatin1String(NM_SETTING_PPP_NO_VJ_COMP), noVjCompare); map.insert(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE), requireMppe); map.insert(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE_128), requireMppe128); map.insert(QLatin1String(NM_SETTING_PPP_MPPE_STATEFUL), mppeStateful); map.insert(QLatin1String(NM_SETTING_PPP_CRTSCTS), cRtsCts); map.insert(QLatin1String(NM_SETTING_PPP_BAUD), baud); map.insert(QLatin1String(NM_SETTING_PPP_MRU), mru); map.insert(QLatin1String(NM_SETTING_PPP_MTU), mtu); map.insert(QLatin1String(NM_SETTING_PPP_LCP_ECHO_FAILURE), lcpEchoFailure); map.insert(QLatin1String(NM_SETTING_PPP_LCP_ECHO_INTERVAL), lcpEchoInterval); NetworkManager::PppSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(PppSettingTest) diff --git a/autotests/settings/pppsettingtest.h b/autotests/settings/pppsettingtest.h index 2fbc18c..e2b4629 100644 --- a/autotests/settings/pppsettingtest.h +++ b/autotests/settings/pppsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_PPPSETTING_TEST_H #define NETWORKMANAGERQT_PPPSETTING_TEST_H #include class PppSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_PPPSETTING_TEST_H diff --git a/autotests/settings/proxysettingtest.cpp b/autotests/settings/proxysettingtest.cpp index 1fbd40f..db6ea22 100644 --- a/autotests/settings/proxysettingtest.cpp +++ b/autotests/settings/proxysettingtest.cpp @@ -1,77 +1,63 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "proxysettingtest.h" #include "settings/proxysetting.h" #include #include #if !NM_CHECK_VERSION(1, 6, 0) #define NM_SETTING_PROXY_BROWSER_ONLY "browser-only" #define NM_SETTING_PROXY_METHOD "method" #define NM_SETTING_PROXY_PAC_SCRIPT "pac-script" #define NM_SETTING_PROXY_PAC_URL "pac-url" #endif void ProxySettingTest::testSetting_data() { QTest::addColumn("browserOnly"); QTest::addColumn("method"); QTest::addColumn("pacScript"); QTest::addColumn("pacUrl"); QTest::newRow("setting1") << false // browserOnly << (quint32)1 // method << QString("script") // pacScript << QString("url"); // pacUrl } void ProxySettingTest::testSetting() { QFETCH(bool, browserOnly); QFETCH(quint32, method); QFETCH(QString, pacScript); QFETCH(QString, pacUrl); QVariantMap map; map.insert(QLatin1String(NM_SETTING_PROXY_BROWSER_ONLY), browserOnly); map.insert(QLatin1String(NM_SETTING_PROXY_METHOD), method); map.insert(QLatin1String(NM_SETTING_PROXY_PAC_SCRIPT), pacScript); map.insert(QLatin1String(NM_SETTING_PROXY_PAC_URL), pacUrl); NetworkManager::ProxySetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(ProxySettingTest) diff --git a/autotests/settings/proxysettingtest.h b/autotests/settings/proxysettingtest.h index 5da5302..a927ac4 100644 --- a/autotests/settings/proxysettingtest.h +++ b/autotests/settings/proxysettingtest.h @@ -1,36 +1,22 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_PROXY_SETTING_TEST_H #define NETWORKMANAGERQT_PROXY_SETTING_TEST_H #include class ProxySettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_PROXY_SETTING_TEST_H diff --git a/autotests/settings/serialsettingtest.cpp b/autotests/settings/serialsettingtest.cpp index 3f47b1b..43470cc 100644 --- a/autotests/settings/serialsettingtest.cpp +++ b/autotests/settings/serialsettingtest.cpp @@ -1,73 +1,59 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "serialsettingtest.h" #include "settings/serialsetting.h" #include #include void SerialSettingTest::testSetting_data() { QTest::addColumn("baud"); QTest::addColumn("bits"); QTest::addColumn("parity"); QTest::addColumn("stopbits"); QTest::addColumn("sendDelay"); QTest::newRow("setting1") << (quint32) 56000 // baud << (quint32) 16 // bits << QChar('E') // parity << (quint32) 2 // stopbits << (quint64) 1000; // senddelay } void SerialSettingTest::testSetting() { QFETCH(quint32, baud); QFETCH(quint32, bits); QFETCH(QChar, parity); QFETCH(quint32, stopbits); QFETCH(quint64, sendDelay); QVariantMap map; map.insert(QLatin1String(NM_SETTING_SERIAL_BAUD), baud); map.insert(QLatin1String(NM_SETTING_SERIAL_BITS), bits); map.insert(QLatin1String(NM_SETTING_SERIAL_PARITY), parity); map.insert(QLatin1String(NM_SETTING_SERIAL_STOPBITS), stopbits); map.insert(QLatin1String(NM_SETTING_SERIAL_SEND_DELAY), sendDelay); NetworkManager::SerialSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(SerialSettingTest) diff --git a/autotests/settings/serialsettingtest.h b/autotests/settings/serialsettingtest.h index 5dbfd57..0a1dbf8 100644 --- a/autotests/settings/serialsettingtest.h +++ b/autotests/settings/serialsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SERIALSETTING_TEST_H #define NETWORKMANAGERQT_SERIALSETTING_TEST_H #include class SerialSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_SERIALSETTING_TEST_H diff --git a/autotests/settings/tcsettingtest.cpp b/autotests/settings/tcsettingtest.cpp index 42ff044..43e70d0 100644 --- a/autotests/settings/tcsettingtest.cpp +++ b/autotests/settings/tcsettingtest.cpp @@ -1,104 +1,90 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "tcsettingtest.h" #include "settings/tcsetting.h" #include #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_TC_CONFIG_QDISCS "qdiscs" #define NM_SETTING_TC_CONFIG_TFILTERS "tfilters" #endif void TcSettingTest::testSetting_data() { QTest::addColumn("qdiscs"); QTest::addColumn("tfilters"); NMVariantMapList qdiscs; QVariantMap qdisc; qdisc["one"] = "1"; qdisc["two"] = 2; qdiscs.append(qdisc); NMVariantMapList tfilters; QVariantMap tfilter; tfilter["three"] = "3"; tfilter["four"] = 4; tfilters.append(tfilter); QTest::newRow("setting1") << qdiscs // qdiscs << tfilters; // tfilters } void TcSettingTest::testSetting() { QFETCH(NMVariantMapList, tfilters); QFETCH(NMVariantMapList, qdiscs); QVariantMap map; map.insert(QLatin1String(NM_SETTING_TC_CONFIG_TFILTERS), QVariant::fromValue(tfilters)); map.insert(QLatin1String(NM_SETTING_TC_CONFIG_QDISCS), QVariant::fromValue(qdiscs)); NetworkManager::TcSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { NMVariantMapList list = it.value().value(); NMVariantMapList list1 = map1.value(it.key()).value(); QCOMPARE(list.count(), list1.count()); int comparedMaps = 0; for (int i = 0; i < list.size(); ++i) { QVariantMap varMap = list.at(i); for (int j = 0; j < list1.size(); ++j) { QVariantMap varMap1 = list1.at(j); QVariantMap::const_iterator ite = varMap.constBegin(); int comparedvals = 0; while (ite != varMap.constEnd()) { QVariantMap::const_iterator val1 = varMap1.constFind(ite.key()); if (val1 != varMap1.constEnd()) { if (varMap.value(ite.key()) == val1.value()) { ++comparedvals; } } ++ite; } if (comparedvals == varMap.size()) { comparedMaps++; } } } ++it; QCOMPARE(comparedMaps, list.count()); } } QTEST_MAIN(TcSettingTest) diff --git a/autotests/settings/tcsettingtest.h b/autotests/settings/tcsettingtest.h index df6ebbf..47cf928 100644 --- a/autotests/settings/tcsettingtest.h +++ b/autotests/settings/tcsettingtest.h @@ -1,36 +1,22 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TC_SETTING_TEST_H #define NETWORKMANAGERQT_TC_SETTING_TEST_H #include class TcSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_TC_SETTING_TEST_H diff --git a/autotests/settings/teamportsettingtest.cpp b/autotests/settings/teamportsettingtest.cpp index d224d31..533d52d 100644 --- a/autotests/settings/teamportsettingtest.cpp +++ b/autotests/settings/teamportsettingtest.cpp @@ -1,130 +1,116 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "teamportsettingtest.h" #include "settings/teamportsetting.h" #include #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_TEAM_PORT_CONFIG "config" #define NM_SETTING_TEAM_PORT_QUEUE_ID "queue-id" #define NM_SETTING_TEAM_PORT_PRIO "prio" #define NM_SETTING_TEAM_PORT_STICKY "sticky" #define NM_SETTING_TEAM_PORT_LACP_PRIO "lacp-prio" #define NM_SETTING_TEAM_PORT_LACP_KEY "lacp-key" #define NM_SETTING_TEAM_PORT_LINK_WATCHERS "link-watchers" #endif void TeamPortSettingTest::testSetting_data() { QTest::addColumn("config"); QTest::addColumn("lacpKey"); QTest::addColumn("lacpPrio"); QTest::addColumn("prio"); QTest::addColumn("queueId"); QTest::addColumn("sticky"); QTest::addColumn("linkWatchers"); NMVariantMapList linkWatchers; QVariantMap linkWatcher; linkWatcher["one"] = "1"; linkWatcher["two"] = 2; linkWatchers.append(linkWatcher); QTest::newRow("setting1") << QString("abc") // config << (qint32)1 // lacpKey << (qint32)1 // lacpPrio << (qint32)1 // prio << (qint32)1 // queueId << true // sticky << linkWatchers; // linkWatchers } void TeamPortSettingTest::testSetting() { QFETCH(QString, config); QFETCH(qint32, lacpKey); QFETCH(qint32, lacpPrio); QFETCH(qint32, prio); QFETCH(qint32, queueId); QFETCH(bool, sticky); QFETCH(NMVariantMapList, linkWatchers); QVariantMap map; map.insert(QLatin1String(NM_SETTING_TEAM_PORT_CONFIG), config); map.insert(QLatin1String(NM_SETTING_TEAM_PORT_LACP_KEY), lacpKey); map.insert(QLatin1String(NM_SETTING_TEAM_PORT_LACP_PRIO), lacpPrio); map.insert(QLatin1String(NM_SETTING_TEAM_PORT_PRIO), prio); map.insert(QLatin1String(NM_SETTING_TEAM_PORT_QUEUE_ID), queueId); map.insert(QLatin1String(NM_SETTING_TEAM_PORT_STICKY), sticky); map.insert(QLatin1String(NM_SETTING_TEAM_PORT_LINK_WATCHERS), QVariant::fromValue(linkWatchers)); NetworkManager::TeamPortSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { if (it.key() != QLatin1String(NM_SETTING_TEAM_PORT_LINK_WATCHERS)) { QCOMPARE(it.value(), map1.value(it.key())); } ++it; } NMVariantMapList list = map.value(QLatin1String(NM_SETTING_TEAM_PORT_LINK_WATCHERS)).value(); NMVariantMapList list1 = map1.value(QLatin1String(NM_SETTING_TEAM_PORT_LINK_WATCHERS)).value(); QCOMPARE(list.count(), list1.count()); int comparedMaps = 0; for (int i = 0; i < list.size(); ++i) { QVariantMap varMap = list.at(i); for (int j = 0; j < list1.size(); ++j) { QVariantMap varMap1 = list1.at(i); QVariantMap::const_iterator ite = varMap.constBegin(); int comparedvals = 0; while (ite != varMap.constEnd()) { QVariantMap::const_iterator val1 = varMap1.constFind(ite.key()); if (val1 != varMap1.constEnd()) { if (varMap.value(ite.key()) == val1.value()) { ++comparedvals; } } ++ite; } if (comparedvals == varMap.size()) { comparedMaps++; } } } ++it; QCOMPARE(comparedMaps, list.count()); } QTEST_MAIN(TeamPortSettingTest) diff --git a/autotests/settings/teamportsettingtest.h b/autotests/settings/teamportsettingtest.h index e8daff0..aad42af 100644 --- a/autotests/settings/teamportsettingtest.h +++ b/autotests/settings/teamportsettingtest.h @@ -1,36 +1,22 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TEAMPORTSETTING_TEST_H #define NETWORKMANAGERQT_TEAMPORTSETTING_TEST_H #include class TeamPortSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_TEAMPORTSETTING_TEST_H diff --git a/autotests/settings/tunsettingtest.cpp b/autotests/settings/tunsettingtest.cpp index 1578b0d..b4318a1 100644 --- a/autotests/settings/tunsettingtest.cpp +++ b/autotests/settings/tunsettingtest.cpp @@ -1,80 +1,66 @@ /* - Copyright 2016 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2016 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "tunsettingtest.h" #include "settings/tunsetting.h" #include #include void TunSettingTest::testSetting_data() { QTest::addColumn("group"); QTest::addColumn("mode"); QTest::addColumn("multiQueue"); QTest::addColumn("owner"); QTest::addColumn("pi"); QTest::addColumn("vnetHdr"); QTest::newRow("setting1") << QString("randomGroup") // group << (quint32)2 // mode << true // multi-queue << QString("randomOwner") // owner << true // pi << true; // vnet-hdr } void TunSettingTest::testSetting() { QFETCH(QString, group); QFETCH(quint32, mode); QFETCH(bool, multiQueue); QFETCH(QString, owner); QFETCH(bool, pi); QFETCH(bool, vnetHdr); QVariantMap map; map.insert(QLatin1String(NM_SETTING_TUN_GROUP), group); map.insert(QLatin1String(NM_SETTING_TUN_MODE), mode); map.insert(QLatin1String(NM_SETTING_TUN_MULTI_QUEUE), multiQueue); map.insert(QLatin1String(NM_SETTING_TUN_OWNER), owner); map.insert(QLatin1String(NM_SETTING_TUN_PI), pi); map.insert(QLatin1String(NM_SETTING_TUN_VNET_HDR), vnetHdr); NetworkManager::TunSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(TunSettingTest) diff --git a/autotests/settings/tunsettingtest.h b/autotests/settings/tunsettingtest.h index abab17c..b8f2629 100644 --- a/autotests/settings/tunsettingtest.h +++ b/autotests/settings/tunsettingtest.h @@ -1,36 +1,22 @@ /* - Copyright 2016 Jan Grulich + SPDX-FileCopyrightText: 2016 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TUNSETTING_TEST_H #define NETWORKMANAGERQT_TUNSETTING_TEST_H #include class TunSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_TUNSETTING_TEST_H diff --git a/autotests/settings/usersettingtest.cpp b/autotests/settings/usersettingtest.cpp index 518bde1..86a5678 100644 --- a/autotests/settings/usersettingtest.cpp +++ b/autotests/settings/usersettingtest.cpp @@ -1,67 +1,53 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "usersettingtest.h" #include "settings/usersetting.h" #include #include #if !NM_CHECK_VERSION(1, 8, 0) #define NM_SETTING_USER_DATA "data" #endif void UserSettingTest::testSetting_data() { QTest::addColumn("data"); NMStringMap data; data.insert("dat", "abc"); QTest::newRow("setting1") << data; // data } void UserSettingTest::testSetting() { QFETCH(NMStringMap, data); QVariantMap map; map.insert(QLatin1String(NM_SETTING_USER_DATA), QVariant::fromValue(data)); NetworkManager::UserSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); NMStringMap stringMap1 = map.value(QLatin1String(NM_SETTING_USER_DATA)).value(); NMStringMap stringMap2 = map1.value(QLatin1String(NM_SETTING_USER_DATA)).value(); NMStringMap::const_iterator it = stringMap1.constBegin(); while (it != stringMap1.constEnd()) { QCOMPARE(it.value(), stringMap2.value(it.key())); ++it; } } QTEST_MAIN(UserSettingTest) diff --git a/autotests/settings/usersettingtest.h b/autotests/settings/usersettingtest.h index aacb476..7e6a5a7 100644 --- a/autotests/settings/usersettingtest.h +++ b/autotests/settings/usersettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2018 Pranav Gade + SPDX-FileCopyrightText: 2018 Pranav Gade - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_USER_SETTING_TEST_H #define NETWORKMANAGERQT_USER_SETTING_TEST_H #include class UserSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_USER_SETTING_TEST_H diff --git a/autotests/settings/vlansettingtest.cpp b/autotests/settings/vlansettingtest.cpp index 92551cf..4219340 100644 --- a/autotests/settings/vlansettingtest.cpp +++ b/autotests/settings/vlansettingtest.cpp @@ -1,80 +1,66 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "vlansettingtest.h" #include "settings/vlansetting.h" #include #include void VlanSettingTest::testSetting_data() { QTest::addColumn("interfaceName"); QTest::addColumn("parent"); QTest::addColumn("id"); QTest::addColumn("flags"); QTest::addColumn("ingressPriorityMap"); QTest::addColumn("egressPriorityMap"); QStringList mapping; mapping << "7:3"; mapping << "8:4"; QTest::newRow("setting1") << QString("eth2.1") // interfaceName << QString("2815492f-7e56-435e-b2e9-246bd7cdc668") // parent << (quint32) 2 // id << (quint32) 0x02 // flags << mapping // ingressPriorityMap << mapping; // egressPriorityMap } void VlanSettingTest::testSetting() { QFETCH(QString, interfaceName); QFETCH(QString, parent); QFETCH(quint32, id); QFETCH(quint32, flags); QFETCH(QStringList, ingressPriorityMap); QFETCH(QStringList, egressPriorityMap); QVariantMap map; map.insert(QLatin1String("interface-name"), interfaceName); map.insert(QLatin1String(NM_SETTING_VLAN_PARENT), parent); map.insert(QLatin1String(NM_SETTING_VLAN_ID), id); map.insert(QLatin1String(NM_SETTING_VLAN_FLAGS), flags); map.insert(QLatin1String(NM_SETTING_VLAN_INGRESS_PRIORITY_MAP), ingressPriorityMap); map.insert(QLatin1String(NM_SETTING_VLAN_EGRESS_PRIORITY_MAP), egressPriorityMap); NetworkManager::VlanSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(VlanSettingTest) diff --git a/autotests/settings/vlansettingtest.h b/autotests/settings/vlansettingtest.h index 2d75ae1..51c8cf2 100644 --- a/autotests/settings/vlansettingtest.h +++ b/autotests/settings/vlansettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VLANSETTING_TEST_H #define NETWORKMANAGERQT_VLANSETTING_TEST_H #include class VlanSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_VLANSETTING_TEST_H diff --git a/autotests/settings/vpnsettingtest.cpp b/autotests/settings/vpnsettingtest.cpp index 6d9d47a..13fc32f 100644 --- a/autotests/settings/vpnsettingtest.cpp +++ b/autotests/settings/vpnsettingtest.cpp @@ -1,78 +1,64 @@ /* - Copyright 2017 Jan Grulich + SPDX-FileCopyrightText: 2017 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "vpnsettingtest.h" #include "settings/vpnsetting.h" #include #include void VpnSettingTest::testSetting_data() { QTest::addColumn("data"); QTest::addColumn("persistent"); QTest::addColumn("secrets"); QTest::addColumn("serviceType"); QTest::addColumn("timeout"); QTest::addColumn("userName"); QTest::newRow("setting1") << NMStringMap{{"gateway", "kde.org"}} // data << true // persistent << NMStringMap{{"password", "kde"}} // secrets << QString("openvpn") // service-type << (uint) 30 // timeout << QString("test-user"); // user-name } void VpnSettingTest::testSetting() { QFETCH(NMStringMap, data); QFETCH(bool, persistent); QFETCH(NMStringMap, secrets); QFETCH(QString, serviceType); QFETCH(uint, timeout); QFETCH(QString, userName); QVariantMap map; map.insert(QLatin1String(NM_SETTING_VPN_DATA), QVariant::fromValue(data)); map.insert(QLatin1String(NM_SETTING_VPN_PERSISTENT), persistent); map.insert(QLatin1String(NM_SETTING_VPN_SECRETS), QVariant::fromValue(secrets)); map.insert(QLatin1String(NM_SETTING_VPN_SERVICE_TYPE), serviceType); map.insert(QLatin1String(NM_SETTING_VPN_TIMEOUT), timeout); map.insert(QLatin1String(NM_SETTING_VPN_USER_NAME), userName); NetworkManager::VpnSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(VpnSettingTest) diff --git a/autotests/settings/vpnsettingtest.h b/autotests/settings/vpnsettingtest.h index 1d4c4f8..074575b 100644 --- a/autotests/settings/vpnsettingtest.h +++ b/autotests/settings/vpnsettingtest.h @@ -1,37 +1,23 @@ /* - Copyright 2017 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2017 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VPNSETTING_TEST_H #define NETWORKMANAGERQT_VPNSETTING_TEST_H #include class VpnSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_VPNSETTING_TEST_H diff --git a/autotests/settings/vxlansettingtest.cpp b/autotests/settings/vxlansettingtest.cpp index 06edd6f..99b4198 100644 --- a/autotests/settings/vxlansettingtest.cpp +++ b/autotests/settings/vxlansettingtest.cpp @@ -1,116 +1,102 @@ /* - Copyright 2018 Billy Laws + SPDX-FileCopyrightText: 2018 Billy Laws - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "vxlansettingtest.h" #include "settings/vxlansetting.h" #include #include void VxlanSettingTest::testSetting_data() { QTest::addColumn("ageing"); QTest::addColumn("destinationPort"); QTest::addColumn("id"); QTest::addColumn("l2Miss"); QTest::addColumn("l3Miss"); QTest::addColumn("learning"); QTest::addColumn("limit"); QTest::addColumn("local"); QTest::addColumn("parent"); QTest::addColumn("proxy"); QTest::addColumn("remote"); QTest::addColumn("rsc"); QTest::addColumn("sourcePortMax"); QTest::addColumn("sourcePortMin"); QTest::addColumn("tos"); QTest::addColumn("ttl"); QTest::newRow("setting1") << (quint32) 2 // ageing << (quint32) 334 // destinationPort << (quint32) 2 // id << (bool) true // l2Miss << (bool) true // l3Miss << (bool) false // learning << (quint32) 2 // limit << QString("foo") // local << QString("bar") // parent << (bool) true // proxy << QString("foo") // remote << (bool) true // rsc << (quint32) 2 // sourcePortMax << (quint32) 2 // sourcePortMin << (quint32) 2 // tos << (quint32) 2; // ttl } void VxlanSettingTest::testSetting() { QFETCH(quint32, ageing); QFETCH(quint32, destinationPort); QFETCH(quint32, id); QFETCH(bool, l2Miss); QFETCH(bool, l3Miss); QFETCH(bool, learning); QFETCH(quint32, limit); QFETCH(QString, local); QFETCH(QString, parent); QFETCH(bool, proxy); QFETCH(QString, remote); QFETCH(bool, rsc); QFETCH(quint32, sourcePortMax); QFETCH(quint32, sourcePortMin); QFETCH(quint32, tos); QFETCH(quint32, ttl); QVariantMap map; map.insert(QLatin1String(NM_SETTING_VXLAN_AGEING), ageing); map.insert(QLatin1String(NM_SETTING_VXLAN_DESTINATION_PORT), destinationPort); map.insert(QLatin1String(NM_SETTING_VXLAN_ID), id); map.insert(QLatin1String(NM_SETTING_VXLAN_L2_MISS), l2Miss); map.insert(QLatin1String(NM_SETTING_VXLAN_L3_MISS), l3Miss); map.insert(QLatin1String(NM_SETTING_VXLAN_LEARNING), learning); map.insert(QLatin1String(NM_SETTING_VXLAN_LIMIT), limit); map.insert(QLatin1String(NM_SETTING_VXLAN_LOCAL), local); map.insert(QLatin1String(NM_SETTING_VXLAN_PARENT), parent); map.insert(QLatin1String(NM_SETTING_VXLAN_PROXY), proxy); map.insert(QLatin1String(NM_SETTING_VXLAN_REMOTE), remote); map.insert(QLatin1String(NM_SETTING_VXLAN_RSC), rsc); map.insert(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MAX), sourcePortMax); map.insert(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MIN), sourcePortMin); map.insert(QLatin1String(NM_SETTING_VXLAN_TOS), tos); map.insert(QLatin1String(NM_SETTING_VXLAN_TTL), ttl); NetworkManager::VxlanSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(VxlanSettingTest) diff --git a/autotests/settings/vxlansettingtest.h b/autotests/settings/vxlansettingtest.h index 24f521d..e9b8a4c 100644 --- a/autotests/settings/vxlansettingtest.h +++ b/autotests/settings/vxlansettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2018 Billy Laws + SPDX-FileCopyrightText: 2018 Billy Laws - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VXLANSETTING_TEST_H #define NETWORKMANAGERQT_VXLANSETTING_TEST_H #include class VxlanSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_VXLANSETTING_TEST_H diff --git a/autotests/settings/wimaxsettingtest.cpp b/autotests/settings/wimaxsettingtest.cpp index 5d96b11..8420531 100644 --- a/autotests/settings/wimaxsettingtest.cpp +++ b/autotests/settings/wimaxsettingtest.cpp @@ -1,61 +1,47 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wimaxsettingtest.h" #include "settings/wimaxsetting.h" #include #include void WimaxSettingTest::testSetting_data() { QTest::addColumn("networkName"); QTest::addColumn("macAddress"); QTest::newRow("setting1") << QString("networkname") // networkName << QByteArray("01:23:45:67:89:ab"); // macAddress } void WimaxSettingTest::testSetting() { QFETCH(QString, networkName); QFETCH(QByteArray, macAddress); QVariantMap map; map.insert(QLatin1String(NM_SETTING_WIMAX_NETWORK_NAME), networkName); map.insert(QLatin1String(NM_SETTING_WIMAX_MAC_ADDRESS), macAddress); NetworkManager::WimaxSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(WimaxSettingTest) diff --git a/autotests/settings/wimaxsettingtest.h b/autotests/settings/wimaxsettingtest.h index 23cb7ef..ef4abc7 100644 --- a/autotests/settings/wimaxsettingtest.h +++ b/autotests/settings/wimaxsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIMAXSETTING_TEST_H #define NETWORKMANAGERQT_WIMAXSETTING_TEST_H #include class WimaxSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_WIMAXSETTING_TEST_H diff --git a/autotests/settings/wiredsettingtest.cpp b/autotests/settings/wiredsettingtest.cpp index cdd74ed..bca3152 100644 --- a/autotests/settings/wiredsettingtest.cpp +++ b/autotests/settings/wiredsettingtest.cpp @@ -1,125 +1,111 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wiredsettingtest.h" #include "generictypes.h" #include "settings/wiredsetting.h" #include #include void WiredSettingTest::testSetting_data() { QTest::addColumn("port"); QTest::addColumn("speed"); QTest::addColumn("duplex"); QTest::addColumn("autoNegotiate"); QTest::addColumn("generateMacAddressMask"); QTest::addColumn("macAddress"); QTest::addColumn("clonedMacAddress"); QTest::addColumn("macAddressBlacklist"); QTest::addColumn("mtu"); QTest::addColumn("s390Subchannels"); QTest::addColumn("s390NetType"); QTest::addColumn("s390Options"); QTest::addColumn("wakeOnLan"); QTest::addColumn("wakeOnLanPassword"); QStringList macAddressBlacklist; macAddressBlacklist << "00:08:C7:1B:8C:02"; QStringList s390Subchannels; s390Subchannels << "0.0.09a0"; s390Subchannels << "0.0.09a1"; s390Subchannels << "0.0.09a2"; QMap s390Options; s390Options.insert("portno", "0"); QTest::newRow("setting1") << QString("tp") // port << (quint32) 100 // speed << QString("full") // duplex << false // autoNegotiate << QString("FE:FF:FF:00:00:00 68:F7:28:00:00:00") // generateMacAddressMask << QByteArray("00-B0-D0-86-BB-F7") // macAddress << QByteArray("00-14-22-01-23-4") // clonedMacAddress << macAddressBlacklist // macAddressBlacklist << (quint32) 200 // mtu << s390Subchannels // s390Subchannels << QString("qeth") // s390NetType << s390Options // s390Options << (uint)(NetworkManager::WiredSetting::WakeOnLanMulticast | NetworkManager::WiredSetting::WakeOnLanMagic) // wakeOnLan << QString("password"); // wakeOnLanPassword } void WiredSettingTest::testSetting() { QFETCH(QString, port); QFETCH(quint32, speed); QFETCH(QString, duplex); QFETCH(bool, autoNegotiate); QFETCH(QString, generateMacAddressMask); QFETCH(QByteArray, macAddress); QFETCH(QByteArray, clonedMacAddress); QFETCH(QStringList, macAddressBlacklist); QFETCH(quint32, mtu); QFETCH(QStringList, s390Subchannels); QFETCH(QString, s390NetType); QFETCH(NMStringMap, s390Options); QFETCH(uint, wakeOnLan); QFETCH(QString, wakeOnLanPassword); QVariantMap map; map.insert(QLatin1String(NM_SETTING_WIRED_PORT), port); map.insert(QLatin1String(NM_SETTING_WIRED_SPEED), speed); map.insert(QLatin1String(NM_SETTING_WIRED_DUPLEX), duplex); map.insert(QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE), autoNegotiate); map.insert(QLatin1String(NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK), generateMacAddressMask); map.insert(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS), macAddress); map.insert(QLatin1String(NM_SETTING_WIRED_CLONED_MAC_ADDRESS), clonedMacAddress); map.insert(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST), macAddressBlacklist); map.insert(QLatin1String(NM_SETTING_WIRED_MTU), mtu); map.insert(QLatin1String(NM_SETTING_WIRED_S390_SUBCHANNELS), s390Subchannels); map.insert(QLatin1String(NM_SETTING_WIRED_S390_NETTYPE), s390NetType); map.insert(QLatin1String(NM_SETTING_WIRED_S390_OPTIONS), QVariant::fromValue(s390Options)); map.insert(QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN), wakeOnLan); map.insert(QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD), wakeOnLanPassword); NetworkManager::WiredSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { if (it.key() != QLatin1String(NM_SETTING_WIRED_S390_OPTIONS)) { QCOMPARE(it.value(), map1.value(it.key())); } ++it; } QCOMPARE(map.value(QLatin1String(NM_SETTING_WIRED_S390_OPTIONS)).value(), map1.value(QLatin1String(NM_SETTING_WIRED_S390_OPTIONS)).value()); } QTEST_MAIN(WiredSettingTest) diff --git a/autotests/settings/wiredsettingtest.h b/autotests/settings/wiredsettingtest.h index 6455eb2..e5a1537 100644 --- a/autotests/settings/wiredsettingtest.h +++ b/autotests/settings/wiredsettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIREDSETTING_TEST_H #define NETWORKMANAGERQT_WIREDSETTING_TEST_H #include class WiredSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_WIREDSETTING_TEST_H diff --git a/autotests/settings/wireguardsettingtest.cpp b/autotests/settings/wireguardsettingtest.cpp index 5cc50a5..d309e87 100644 --- a/autotests/settings/wireguardsettingtest.cpp +++ b/autotests/settings/wireguardsettingtest.cpp @@ -1,141 +1,127 @@ /* - Copyright 2019 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2019 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wireguardsettingtest.h" #include "settings/wireguardsetting.h" #include #include #if !NM_CHECK_VERSION(1, 16, 0) #define NM_SETTING_WIREGUARD_FWMARK "fwmark" #define NM_SETTING_WIREGUARD_LISTEN_PORT "listen-port" #define NM_SETTING_WIREGUARD_PRIVATE_KEY "private-key" #define NM_SETTING_WIREGUARD_PRIVATE_KEY_FLAGS "private-key-flags" #define NM_SETTING_WIREGUARD_PEERS "peers" #define NM_SETTING_WIREGUARD_MTU "mtu" #define NM_SETTING_WIREGUARD_PEER_ROUTES "peer-routes" #define NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY "preshared-key" #define NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY_FLAGS "preshared-key-flags" #define NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY "public-key" #endif void WireGuardSettingTest::testSetting_data() { QTest::addColumn("fwmark"); QTest::addColumn("listenPort"); QTest::addColumn("mtu"); QTest::addColumn("peerRoutes"); QTest::addColumn("peers"); QTest::addColumn("privateKey"); QTest::addColumn("privateKeyFlags"); NMVariantMapList peers; QVariantMap map; map.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY), "preshared-key"); map.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY_FLAGS), (uint) 2); map.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY), "public-key"); peers << map; QVariantMap map1; map1.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY), "preshared-key1"); map1.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY_FLAGS), (uint) 3); map1.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY), "public-key1"); peers << map1; QTest::newRow("setting1") << (qint32) 100 // fwmark << (qint32) 101 // listenPort << (qint32) 102 // mtu << false // peerRoutes << peers // peers << QString("private-key") // privateKey << (quint32) 2; // privateKeyFlags } void WireGuardSettingTest::testSetting() { QFETCH(qint32, fwmark); QFETCH(qint32, listenPort); QFETCH(qint32, mtu); QFETCH(bool, peerRoutes); QFETCH(NMVariantMapList, peers); QFETCH(QString, privateKey); QFETCH(quint32, privateKeyFlags); QVariantMap map; map.insert(QLatin1String(NM_SETTING_WIREGUARD_FWMARK), fwmark); map.insert(QLatin1String(NM_SETTING_WIREGUARD_LISTEN_PORT), listenPort); map.insert(QLatin1String(NM_SETTING_WIREGUARD_MTU), mtu); map.insert(QLatin1String(NM_SETTING_WIREGUARD_PEER_ROUTES), peerRoutes); map.insert(QLatin1String(NM_SETTING_WIREGUARD_PEERS), QVariant::fromValue(peers)); map.insert(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY), privateKey); map.insert(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY_FLAGS), privateKeyFlags); NetworkManager::WireGuardSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { if (it.key() != QLatin1String(NM_SETTING_WIREGUARD_PEERS)) { QCOMPARE(it.value(), map1.value(it.key())); } ++it; } NMVariantMapList list = map.value(QLatin1String(NM_SETTING_WIREGUARD_PEERS)).value(); NMVariantMapList list1 = map1.value(QLatin1String(NM_SETTING_WIREGUARD_PEERS)).value(); QCOMPARE(list.count(), list1.count()); int comparedMaps = 0; for (int i = 0; i < list.size(); ++i) { QVariantMap varMap = list.at(i); for (int j = 0; j < list1.size(); ++j) { QVariantMap varMap1 = list1.at(j); QVariantMap::const_iterator ite = varMap.constBegin(); int comparedvals = 0; while (ite != varMap.constEnd()) { QVariantMap::const_iterator val1 = varMap1.constFind(ite.key()); if (val1 != varMap1.constEnd()) { if (varMap.value(ite.key()) == val1.value()) { ++comparedvals; } } ++ite; } if (comparedvals == varMap.size()) { comparedMaps++; } } } QCOMPARE(comparedMaps, list.count()); } QTEST_MAIN(WireGuardSettingTest) diff --git a/autotests/settings/wireguardsettingtest.h b/autotests/settings/wireguardsettingtest.h index 3586942..eda8a8e 100644 --- a/autotests/settings/wireguardsettingtest.h +++ b/autotests/settings/wireguardsettingtest.h @@ -1,37 +1,23 @@ /* - Copyright 2019 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2019 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIREGUARDSETTING_TEST_H #define NETWORKMANAGERQT_WIREGUARDSETTING_TEST_H #include class WireGuardSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_WIREGUARDSETTING_TEST_H diff --git a/autotests/settings/wirelesssecuritysettingtest.cpp b/autotests/settings/wirelesssecuritysettingtest.cpp index 7483de4..525cbb1 100644 --- a/autotests/settings/wirelesssecuritysettingtest.cpp +++ b/autotests/settings/wirelesssecuritysettingtest.cpp @@ -1,134 +1,120 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wirelesssecuritysettingtest.h" #include #include "settings/wirelesssecuritysetting.h" #include void WirelessSecuritySettingTest::testSetting_data() { QTest::addColumn("keyMgmt"); QTest::addColumn("wepTxKeyidx"); QTest::addColumn("authAlg"); QTest::addColumn("proto"); QTest::addColumn("pairwise"); QTest::addColumn("group"); QTest::addColumn("leapUsername"); QTest::addColumn("wepKey0"); QTest::addColumn("wepKey1"); QTest::addColumn("wepKey2"); QTest::addColumn("wepKey3"); QTest::addColumn("wepKeyFlags"); QTest::addColumn("wepKeyType"); QTest::addColumn("psk"); QTest::addColumn("pskFlags"); QTest::addColumn("leapPassword"); QTest::addColumn("leapPasswordFlags"); QStringList proto; proto << "wpa"; proto << "rsn"; QStringList pairwise; pairwise << "wep40"; pairwise << "ccmp"; QStringList group; group << "wep104"; group << "tkip"; QTest::newRow("setting1") << QString("none") // keyMgmt << (quint32) 1 // wepTxKeyIdx << QString("open") // authAlg << proto // proto << pairwise // pairwise << group // group << QString("login") // leapUsername << QString("abcde") // wepKey0 << QString("fghij") // wepKey1 << QString("klmno") // wepKey2 << QString("pqrst") // wepKey3 << (quint32) 1 // wepKeyFlags << (quint32) 1 // wepKeyType << QString("12345678") // psk << (quint32) 2 // pskFlags << QString("leappass") // leapPassword << (quint32) 4; // leapPasswordFlags } void WirelessSecuritySettingTest::testSetting() { QFETCH(QString, keyMgmt); QFETCH(quint32, wepTxKeyidx); QFETCH(QString, authAlg); QFETCH(QStringList, proto); QFETCH(QStringList, pairwise); QFETCH(QStringList, group); QFETCH(QString, leapUsername); QFETCH(QString, wepKey0); QFETCH(QString, wepKey1); QFETCH(QString, wepKey2); QFETCH(QString, wepKey3); QFETCH(quint32, wepKeyFlags); QFETCH(quint32, wepKeyType); QFETCH(QString, psk); QFETCH(quint32, pskFlags); QFETCH(QString, leapPassword); QFETCH(quint32, leapPasswordFlags); QVariantMap map; map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), keyMgmt); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), wepTxKeyidx); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), authAlg); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PROTO), proto); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PAIRWISE), pairwise); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_GROUP), group); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), leapUsername); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), wepKey0); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), wepKey1); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), wepKey2); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), wepKey3); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS), wepKeyFlags); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE), wepKeyType); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK), psk); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS), pskFlags); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), leapPassword); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS), leapPasswordFlags); NetworkManager::WirelessSecuritySetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(WirelessSecuritySettingTest) diff --git a/autotests/settings/wirelesssecuritysettingtest.h b/autotests/settings/wirelesssecuritysettingtest.h index 88326e2..de7b83e 100644 --- a/autotests/settings/wirelesssecuritysettingtest.h +++ b/autotests/settings/wirelesssecuritysettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRELESSSECURITYSETTING_TEST_H #define NETWORKMANAGERQT_WIRELESSSECURITYSETTING_TEST_H #include class WirelessSecuritySettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_WIRELESSSECURITYSETTING_TEST_H diff --git a/autotests/settings/wirelesssettingtest.cpp b/autotests/settings/wirelesssettingtest.cpp index d879b62..338eb3d 100644 --- a/autotests/settings/wirelesssettingtest.cpp +++ b/autotests/settings/wirelesssettingtest.cpp @@ -1,131 +1,117 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wirelesssettingtest.h" #include "settings/wirelesssetting.h" #include #define NM_SETTING_WIRELESS_ASSIGNED_MAC_ADDRESS "assigned-mac-address" #include void WirelessSettingTest::testSetting_data() { QTest::addColumn("ssid"); QTest::addColumn("mode"); QTest::addColumn("band"); QTest::addColumn("channel"); QTest::addColumn("bssid"); QTest::addColumn("rate"); QTest::addColumn("txPower"); QTest::addColumn("macAddress"); QTest::addColumn("generateMacAddressMask"); QTest::addColumn("macAddressBlacklist"); QTest::addColumn("macAddressRandomization"); QTest::addColumn("mtu"); QTest::addColumn("seenBssids"); QTest::addColumn("powerSave"); QTest::addColumn("security"); QTest::addColumn("hidden"); QTest::addColumn("assignedMacAddress"); QStringList macAddressBlacklist; macAddressBlacklist << "00:08:C7:1B:8C:02"; QStringList seenBssids; seenBssids << "0005.9a3e.7c0f"; QTest::newRow("setting1") << QByteArray("test") // ssid << QString("adhoc") // mode << QString("bg") // band << (quint32)1 // channel << QByteArray("0011.2161.b7c0") // bssid << (quint32)2 // rate << (quint32)3 // txPower << QByteArray("00-B0-D0-86-BB-F7") // macAddress << QString("FE:FF:FF:00:00:00 68:F7:28:00:00:00") // generateMacAddressMask << macAddressBlacklist // macAddressBlacklist << (uint) 1 // macAddressRandomization << (quint32)4 // mtu << seenBssids // seenBssids << (uint) 2 // powerSave << QString("802-11-wireless-security") // security << true // hidden << QString("random"); // assignedMacAddress } void WirelessSettingTest::testSetting() { QFETCH(QByteArray, ssid); QFETCH(QString, mode); QFETCH(QString, band); QFETCH(quint32, channel); QFETCH(QByteArray, bssid); QFETCH(quint32, rate); QFETCH(quint32, txPower); QFETCH(QByteArray, macAddress); QFETCH(QString, generateMacAddressMask); QFETCH(QStringList, macAddressBlacklist); QFETCH(uint, macAddressRandomization); QFETCH(quint32, mtu); QFETCH(QStringList, seenBssids); QFETCH(uint, powerSave); QFETCH(QString, security); QFETCH(bool, hidden); QFETCH(QString, assignedMacAddress); QVariantMap map; map.insert(QLatin1String(NM_SETTING_WIRELESS_SSID), ssid); map.insert(QLatin1String(NM_SETTING_WIRELESS_MODE), mode); map.insert(QLatin1String(NM_SETTING_WIRELESS_BAND), band); map.insert(QLatin1String(NM_SETTING_WIRELESS_CHANNEL), channel); map.insert(QLatin1String(NM_SETTING_WIRELESS_BSSID), bssid); map.insert(QLatin1String(NM_SETTING_WIRELESS_RATE), rate); map.insert(QLatin1String(NM_SETTING_WIRELESS_TX_POWER), txPower); map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS), macAddress); map.insert(QLatin1String(NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK), generateMacAddressMask); map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST), macAddressBlacklist); map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION), macAddressRandomization); map.insert(QLatin1String(NM_SETTING_WIRELESS_MTU), mtu); map.insert(QLatin1String(NM_SETTING_WIRELESS_SEEN_BSSIDS), seenBssids); map.insert(QLatin1String(NM_SETTING_WIRELESS_POWERSAVE), powerSave); map.insert(QLatin1String("security"), security); map.insert(QLatin1String(NM_SETTING_WIRELESS_HIDDEN), hidden); map.insert(QLatin1String(NM_SETTING_WIRELESS_ASSIGNED_MAC_ADDRESS), assignedMacAddress); NetworkManager::WirelessSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } } QTEST_MAIN(WirelessSettingTest) diff --git a/autotests/settings/wirelesssettingtest.h b/autotests/settings/wirelesssettingtest.h index 3d93890..97e57b0 100644 --- a/autotests/settings/wirelesssettingtest.h +++ b/autotests/settings/wirelesssettingtest.h @@ -1,35 +1,21 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRELESSSETTING_TEST_H #define NETWORKMANAGERQT_WIRELESSSETTING_TEST_H #include class WirelessSettingTest : public QObject { Q_OBJECT private Q_SLOTS: void testSetting_data(); void testSetting(); }; #endif // NETWORKMANAGERQT_WIRELESSSETTING_TEST_H diff --git a/autotests/settingstest.cpp b/autotests/settingstest.cpp index 52e4778..fb84269 100644 --- a/autotests/settingstest.cpp +++ b/autotests/settingstest.cpp @@ -1,100 +1,86 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "settingstest.h" #include "settings.h" #include "settings/ipv4setting.h" #include "settings/ipv6setting.h" #include "settings/wiredsetting.h" #include "fakenetwork/settings.h" #include #include #include void SettingsTest::initTestCase() { fakeNetwork = new FakeNetwork(); } void SettingsTest::testConnections() { NetworkManager::ConnectionSettings::Ptr connectionSettings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wired)); connectionSettings->setId("Wired connection"); connectionSettings->setUuid(QLatin1String("39af79a5-b053-4893-9378-7342a5a30d06")); NetworkManager::Ipv4Setting::Ptr ipv4Setting = connectionSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast(); ipv4Setting->setInitialized(true); ipv4Setting->setMethod(NetworkManager::Ipv4Setting::Automatic); NetworkManager::Ipv6Setting::Ptr ipv6Setting = connectionSettings->setting(NetworkManager::Setting::Ipv6).dynamicCast(); ipv6Setting->setInitialized(true); ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic); NetworkManager::WiredSetting::Ptr wiredSetting = connectionSettings->setting(NetworkManager::Setting::Wired).dynamicCast(); wiredSetting->setInitialized(true); // Something needs to be set to not use default values, when using default values we get an empty map wiredSetting->setAutoNegotiate(false); wiredSetting->setSpeed(100); wiredSetting->setDuplexType(NetworkManager::WiredSetting::Full); NetworkManager::addConnection(connectionSettings->toMap()); connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionAdded, this, &SettingsTest::testConnectionAdded); QSignalSpy connectionAddedSpy(NetworkManager::settingsNotifier(), SIGNAL(connectionAdded(QString))); QVERIFY(connectionAddedSpy.wait()); QCOMPARE(NetworkManager::listConnections().count(), 1); QCOMPARE(NetworkManager::listConnections().first()->path(), connectionAddedSpy.at(0).at(0).toString()); NetworkManager::Connection::Ptr connection = NetworkManager::listConnections().first(); QSignalSpy connectionRemovedSpy(NetworkManager::settingsNotifier(), SIGNAL(connectionRemoved(QString))); connection->remove(); QVERIFY(connectionRemovedSpy.wait()); QCOMPARE(NetworkManager::listConnections().count(), 0); QCOMPARE(connection->path(), connectionRemovedSpy.at(0).at(0).toString()); // Compare hostname we set in fake network QCOMPARE(NetworkManager::hostname(), QLatin1String("fake-hostname")); } void SettingsTest::testConnectionAdded(const QString &connection) { NetworkManager::Connection::Ptr addedConnection = NetworkManager::findConnection(connection); QCOMPARE(addedConnection->uuid(), QLatin1String("39af79a5-b053-4893-9378-7342a5a30d06")); QCOMPARE(addedConnection->path(), connection); NetworkManager::ConnectionSettings::Ptr connectionSettings = addedConnection->settings(); NetworkManager::Ipv4Setting::Ptr ipv4Setting = connectionSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast(); QCOMPARE(ipv4Setting->method(), NetworkManager::Ipv4Setting::Automatic); NetworkManager::Ipv6Setting::Ptr ipv6Setting = connectionSettings->setting(NetworkManager::Setting::Ipv6).dynamicCast(); QCOMPARE(ipv6Setting->method(), NetworkManager::Ipv6Setting::Automatic); NetworkManager::WiredSetting::Ptr wiredSetting = connectionSettings->setting(NetworkManager::Setting::Wired).dynamicCast(); QVERIFY(wiredSetting->autoNegotiate() == false); QVERIFY(wiredSetting->speed() == 100); QVERIFY(wiredSetting->duplexType() == NetworkManager::WiredSetting::Full); wiredSetting->setSpeed(10); wiredSetting->setDuplexType(NetworkManager::WiredSetting::Half); addedConnection->update(connectionSettings->toMap()); QSignalSpy connectionUpdatedSpy(addedConnection.data(), SIGNAL(updated())); QVERIFY(connectionUpdatedSpy.wait()); QVERIFY(wiredSetting->speed() == 10); QVERIFY(wiredSetting->duplexType() == NetworkManager::WiredSetting::Half); } QTEST_MAIN(SettingsTest) diff --git a/autotests/settingstest.h b/autotests/settingstest.h index 0494082..dd1293a 100644 --- a/autotests/settingstest.h +++ b/autotests/settingstest.h @@ -1,41 +1,27 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SETTINGS_TEST_H #define NETWORKMANAGERQT_SETTINGS_TEST_H #include #include "fakenetwork/fakenetwork.h" class SettingsTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void testConnections(); void testConnectionAdded(const QString &connection); private: FakeNetwork *fakeNetwork; }; #endif // NETWORKMANAGERQT_SETTINGS_TEST_H diff --git a/cmake/FindNetworkManager.cmake b/cmake/FindNetworkManager.cmake index e5f114d..775bc64 100644 --- a/cmake/FindNetworkManager.cmake +++ b/cmake/FindNetworkManager.cmake @@ -1,63 +1,41 @@ # - Try to find NetworkManager # Once done this will define # # NETWORKMANAGER_FOUND - system has NetworkManager # NETWORKMANAGER_INCLUDE_DIRS - the NetworkManager include directories # NETWORKMANAGER_LIBRARIES - the libraries needed to use NetworkManager # NETWORKMANAGER_CFLAGS - Compiler switches required for using NetworkManager # NETWORKMANAGER_VERSION - version number of NetworkManager -# Copyright (c) 2006, Alexander Neundorf, -# Copyright (c) 2007, Will Stephenson, -# Copyright (c) 2015-2018, Jan Grulich, - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. +# SPDX-FileCopyrightText: 2006 Alexander Neundorf +# SPDX-FileCopyrightText: 2007 Will Stephenson +# SPDX-FileCopyrightText: 2015-2018 Jan Grulich # -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. +# SPDX-License-Identifier: BSD-3-Clause IF (NETWORKMANAGER_INCLUDE_DIRS) # in cache already SET(NetworkManager_FIND_QUIETLY TRUE) ENDIF (NETWORKMANAGER_INCLUDE_DIRS) IF (NOT WIN32) # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls find_package(PkgConfig) PKG_SEARCH_MODULE(NETWORKMANAGER libnm) IF (NETWORKMANAGER_FOUND) IF (NetworkManager_FIND_VERSION AND ("${NETWORKMANAGER_VERSION}" VERSION_LESS "${NetworkManager_FIND_VERSION}")) MESSAGE(FATAL_ERROR "NetworkManager ${NETWORKMANAGER_VERSION} is too old, need at least ${NetworkManager_FIND_VERSION}") ELSE () IF (NOT NetworkManager_FIND_QUIETLY) MESSAGE(STATUS "Found NetworkManager: ${NETWORKMANAGER_LIBRARY_DIRS}") ENDIF () ENDIF () ELSE () MESSAGE(FATAL_ERROR "Could NOT find NetworkManager, check FindPkgConfig output above!") ENDIF () ENDIF (NOT WIN32) MARK_AS_ADVANCED(NETWORKMANAGER_INCLUDE_DIRS) diff --git a/examples/createconnection/main.cpp b/examples/createconnection/main.cpp index 2b6481f..6addbb0 100644 --- a/examples/createconnection/main.cpp +++ b/examples/createconnection/main.cpp @@ -1,130 +1,116 @@ /* - Copyright 2012 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace NetworkManager; int main() { qDBusRegisterMetaType(); QTextStream qout(stdout, QIODevice::WriteOnly); QTextStream qin(stdin, QIODevice::ReadOnly); NetworkManager::ConnectionSettings *settings = new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless); Device::List deviceList = NetworkManager::networkInterfaces(); WirelessDevice::Ptr wifiDevice; // We have to find some wireless device Q_FOREACH (Device::Ptr dev, deviceList) { if (dev->type() == Device::Wifi) { wifiDevice = qobject_cast(dev); break; } } if (!wifiDevice) { return 1; } QStringList accessPointList = wifiDevice->accessPoints(); QString ssid; QString result; QString accessPointPath; // Check for available accesspoint Q_FOREACH (const QString & ap, accessPointList) { AccessPoint accessPoint(ap); // For simplification we use APs only with Wep security or without any security if (accessPoint.wpaFlags().testFlag(AccessPoint::PairWep40) || accessPoint.wpaFlags().testFlag(AccessPoint::PairWep104) || accessPoint.wpaFlags().testFlag(AccessPoint::GroupWep40) || accessPoint.wpaFlags().testFlag(AccessPoint::GroupWep104) || !accessPoint.wpaFlags()) { qout << "Do you want to connect to " << accessPoint.ssid() << "?" << endl; qout << "Yes/No: " << flush; qin >> result; if (result.toLower() == "yes" || result == "y") { ssid = accessPoint.ssid(); accessPointPath = ap; break; } } } // Now we will prepare our new connection, we have to specify ID and create new UUID settings->setId(ssid); settings->setUuid(QUuid::createUuid().toString().mid(1, QUuid::createUuid().toString().length() - 2)); // For wireless setting we have to specify SSID NetworkManager::WirelessSetting::Ptr wirelessSetting = settings->setting(Setting::Wireless).dynamicCast(); wirelessSetting->setSsid(ssid.toUtf8()); NetworkManager::Ipv4Setting::Ptr ipv4Setting = settings->setting(Setting::Ipv4).dynamicCast(); ipv4Setting->setMethod(NetworkManager::Ipv4Setting::Automatic); // Optional password setting. Can be skipped if you do not need encryption. NetworkManager::WirelessSecuritySetting::Ptr wifiSecurity = settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk); wifiSecurity->setPsk("12345678"); wifiSecurity->setInitialized(true); wirelessSetting->setSecurity("802-11-wireless-security"); // We try to add and activate our new wireless connection QDBusPendingReply reply = NetworkManager::addAndActivateConnection(settings->toMap(), wifiDevice->uni(), accessPointPath); reply.waitForFinished(); // Check if this connection was added successfuly if (reply.isValid()) { // Now our connection should be added in NetworkManager and we can print all settings pre-filled from NetworkManager NetworkManager::Connection connection(reply.value().path()); NetworkManager::ConnectionSettings::Ptr newSettings = connection.settings(); // Print resulting settings qDebug() << (*newSettings.data()); // Continue with adding secrets NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting = newSettings->setting(Setting::WirelessSecurity).dynamicCast(); if (!wirelessSecuritySetting->needSecrets().isEmpty()) { qDebug() << "Need secrets: " << wirelessSecuritySetting->needSecrets(); // TODO: fill missing secrets } } else { qDebug() << "Connection failed: " << reply.error(); } } diff --git a/examples/main.cpp b/examples/main.cpp index 972bdc0..3afe6cf 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -1,127 +1,113 @@ /* -Copyright 2011-2013 Lamarque V. Souza - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of -the License or (at your option) version 3 or any later version -accepted by the membership of KDE e.V. (or its successor approved -by the membership of KDE e.V.), which shall act as a proxy -defined in Section 14 of version 3 of the license. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ #include #include #include #include #include #include QString typeAsString(const int type) { switch (type) { case 0x0: return QString("Unknown"); case 0x1: return QString("Ethernet"); case 0x2: return QString("Wifi"); case 0x3: return QString("Unused1"); case 0x4: return QString("Unused2"); case 0x5: return QString("Bluetooth"); case 0x6: return QString("OlpcMesh"); case 0x7: return QString("Wimax"); case 0x8: return QString("Modem"); } return QString("Unknown"); } int main() { QTextStream qout(stdout, QIODevice::WriteOnly); NetworkManager::Device::List list = NetworkManager::networkInterfaces(); // List device configuration, not including vpn connections, which do not // have a real device tied to them. Q_FOREACH (NetworkManager::Device::Ptr dev, list) { qout << "\n=====\n"; qout << dev->uni() << "\n"; qout << "type: " << typeAsString(dev->type()) << "\n"; qout << "managed: " << dev->managed() << "\n"; qout << "interface name: " << dev->interfaceName() << "\n"; NetworkManager::IpConfig ipConfig = dev->ipV4Config(); if (ipConfig.isValid()) { // static IPv4 configuration. if (ipConfig.addresses().isEmpty()) { qout << "ip address: \n"; } else { NetworkManager::IpAddress address = ipConfig.addresses().at(0); qout << "ip address: " << address.ip().toString() << "\n"; qout << "gateway: " << address.gateway().toString() << "\n"; qout << "ip address (raw): " << dev->ipV4Address().toString() << "\n"; // Static routes. if (ipConfig.routes().isEmpty()) { qout << "routers: \n"; } else { qout << "routers: " << ipConfig.routes().at(0).ip().toString() << "\n"; } if (ipConfig.nameservers().isEmpty()) { qout << "nameserver: \n"; } else { qout << "nameserver: " << ipConfig.nameservers().at(0).toString() << "\n"; } } // DHCPv4 configuration. NetworkManager::Dhcp4Config::Ptr dhcp4Config = dev->dhcp4Config(); if (!dhcp4Config) { qout << "dhcp info unavailable\n"; } else { qout << "Dhcp4 options (" << dhcp4Config->path() << "): "; QVariantMap options = dhcp4Config->options(); QVariantMap::ConstIterator it = options.constBegin(); QVariantMap::ConstIterator end = options.constEnd(); for (; it != end; ++it) { qout << it.key() << "=" << it.value().toString() << " "; } qout << "\n"; qout << "(dhcp) ip address: " << dhcp4Config->optionValue("ip_address") << "\n"; qout << "(dhcp) network: " << dhcp4Config->optionValue("network_number") << '/' << dhcp4Config->optionValue("subnet_cidr") << " (" << dhcp4Config->optionValue("subnet_mask") << ")\n"; if (dhcp4Config->optionValue("routers").isEmpty()) { qout << "(dhcp) gateway(s): \n"; } else { qout << "(dhcp) gateway(s): " << dhcp4Config->optionValue("routers") << "\n"; } if (dhcp4Config->optionValue("domain_name_servers").isEmpty()) { qout << "(dhcp) domain name server(s): \n"; } else { qout << "(dhcp) domain name server(s): " << dhcp4Config->optionValue("domain_name_servers") << "\n"; } } } NetworkManager::Connection::List connections = dev->availableConnections(); qout << "available connections: "; Q_FOREACH (NetworkManager::Connection::Ptr con, connections) { qout << "con"; NetworkManager::ConnectionSettings::Ptr settings = con->settings(); qout << "\"" << settings->id() << "\" "; } } qout << "\n"; } diff --git a/src/accesspoint.cpp b/src/accesspoint.cpp index 5acdb5a..c38cc32 100644 --- a/src/accesspoint.cpp +++ b/src/accesspoint.cpp @@ -1,230 +1,216 @@ /* - Copyright 2008 Will Stephenson - Copyright 2013 Daniel Nicoletti - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008 Will Stephenson + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "accesspoint_p.h" #include "manager_p.h" #include "wirelessdevice.h" #include "nmdebug.h" NetworkManager::AccessPointPrivate::AccessPointPrivate(const QString &path, AccessPoint *q) #ifdef NMQT_STATIC : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , capabilities(AccessPoint::None) , wpaFlags() , rsnFlags() , frequency(0) , maxBitRate(0) , mode(AccessPoint::Unknown) , signalStrength(0) , lastSeen(-1) , q_ptr(q) { uni = path; } NetworkManager::AccessPoint::Capabilities NetworkManager::AccessPointPrivate::convertCapabilities(int caps) { NetworkManager::AccessPoint::Capabilities capFlags; if (caps & NM_802_11_AP_FLAGS_PRIVACY) { capFlags |= AccessPoint::Privacy; } return capFlags; } NetworkManager::AccessPoint::WpaFlags NetworkManager::AccessPointPrivate::convertWpaFlags(uint theirFlags) { return (AccessPoint::WpaFlags)theirFlags; } NetworkManager::AccessPoint::AccessPoint(const QString &path, QObject *parent) : QObject(parent) , d_ptr(new AccessPointPrivate(path, this)) { Q_D(AccessPoint); // Get all AccessPoint's properties at once QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::AccessPoint::~AccessPoint() { Q_D(AccessPoint); delete d; } QString NetworkManager::AccessPoint::uni() const { Q_D(const AccessPoint); return d->uni; } QString NetworkManager::AccessPoint::hardwareAddress() const { Q_D(const AccessPoint); return d->hardwareAddress; } NetworkManager::AccessPoint::Capabilities NetworkManager::AccessPoint::capabilities() const { Q_D(const AccessPoint); return d->capabilities; } NetworkManager::AccessPoint::WpaFlags NetworkManager::AccessPoint::wpaFlags() const { Q_D(const AccessPoint); return d->wpaFlags; } NetworkManager::AccessPoint::WpaFlags NetworkManager::AccessPoint::rsnFlags() const { Q_D(const AccessPoint); return d->rsnFlags; } QString NetworkManager::AccessPoint::ssid() const { Q_D(const AccessPoint); return d->ssid; } QByteArray NetworkManager::AccessPoint::rawSsid() const { Q_D(const AccessPoint); return d->rawSsid; } uint NetworkManager::AccessPoint::frequency() const { Q_D(const AccessPoint); return d->frequency; } uint NetworkManager::AccessPoint::maxBitRate() const { Q_D(const AccessPoint); return d->maxBitRate; } NetworkManager::AccessPoint::OperationMode NetworkManager::AccessPoint::mode() const { Q_D(const AccessPoint); return d->mode; } int NetworkManager::AccessPoint::signalStrength() const { Q_D(const AccessPoint); return d->signalStrength; } int NetworkManager::AccessPoint::lastSeen() const { Q_D(const AccessPoint); return d->lastSeen; } NetworkManager::AccessPoint::OperationMode NetworkManager::AccessPoint::convertOperationMode(uint mode) { NetworkManager::AccessPoint::OperationMode ourMode = NetworkManager::AccessPoint::Unknown; switch (mode) { case NM_802_11_MODE_UNKNOWN: ourMode = NetworkManager::AccessPoint::Unknown; break; case NM_802_11_MODE_ADHOC: ourMode = NetworkManager::AccessPoint::Adhoc; break; case NM_802_11_MODE_INFRA: ourMode = NetworkManager::AccessPoint::Infra; break; case NM_802_11_MODE_AP: ourMode = NetworkManager::AccessPoint::ApMode; break; default: qCDebug(NMQT) << Q_FUNC_INFO << "Unhandled mode" << mode; } return ourMode; } void NetworkManager::AccessPointPrivate::dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties) { Q_UNUSED(invalidatedProperties); if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.AccessPoint")) { propertiesChanged(properties); } } void NetworkManager::AccessPointPrivate::propertiesChanged(const QVariantMap &properties) { Q_Q(AccessPoint); // qCDebug(NMQT) << Q_FUNC_INFO << properties; QVariantMap::const_iterator it = properties.constBegin(); while (it != properties.constEnd()) { const QString property = it.key(); if (property == QLatin1String("Flags")) { capabilities = convertCapabilities(it->toUInt()); Q_EMIT q->capabilitiesChanged(capabilities); } else if (property == QLatin1String("WpaFlags")) { wpaFlags = convertWpaFlags(it->toUInt()); Q_EMIT q->wpaFlagsChanged(wpaFlags); } else if (property == QLatin1String("RsnFlags")) { rsnFlags = convertWpaFlags(it->toUInt()); Q_EMIT q->rsnFlagsChanged(rsnFlags); } else if (property == QLatin1String("Ssid")) { rawSsid = it->toByteArray(); ssid = QString::fromUtf8(rawSsid); Q_EMIT q->ssidChanged(ssid); } else if (property == QLatin1String("Frequency")) { frequency = it->toUInt(); Q_EMIT q->frequencyChanged(frequency); } else if (property == QLatin1String("HwAddress")) { hardwareAddress = it->toString(); } else if (property == QLatin1String("Mode")) { mode = q->convertOperationMode(it->toUInt()); } else if (property == QLatin1String("MaxBitrate")) { maxBitRate = it->toUInt(); Q_EMIT q->bitRateChanged(maxBitRate); } else if (property == QLatin1String("Strength")) { signalStrength = it->toInt(); Q_EMIT q->signalStrengthChanged(signalStrength); } else if (property == QLatin1String("LastSeen")) { lastSeen = it->toInt(); Q_EMIT q->lastSeenChanged(lastSeen); } else { qCDebug(NMQT) << Q_FUNC_INFO << "Unhandled property" << property; } ++it; } } diff --git a/src/accesspoint.h b/src/accesspoint.h index faafefd..7e90710 100644 --- a/src/accesspoint.h +++ b/src/accesspoint.h @@ -1,205 +1,191 @@ /* - Copyright 2008 Will Stephenson - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_ACCESSPOINT_H #define NETWORKMANAGERQT_ACCESSPOINT_H #include #include #include #include #include namespace NetworkManager { class AccessPointPrivate; /** * Represents an access point */ class NETWORKMANAGERQT_EXPORT AccessPoint : public QObject { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; /** * The access point's current operating mode */ enum OperationMode { Unknown = 0, /**< not associated with a network */ Adhoc, /**< part of an adhoc network */ Infra, /**< a station in an infrastructure wireless network */ ApMode /**< access point in an infrastructure network */ }; /** * General capabilities of an access point */ enum Capability { None = 0x0, /**< Null capability - says nothing about the access point */ Privacy = 0x1 /**< Access point supports privacy measures */ }; /** * Flags describing the access point's capabilities according to WPA (Wifi Protected Access) */ enum WpaFlag { PairWep40 = 0x1, PairWep104 = 0x2, PairTkip = 0x4, PairCcmp = 0x8, GroupWep40 = 0x10, GroupWep104 = 0x20, GroupTkip = 0x40, GroupCcmp = 0x80, KeyMgmtPsk = 0x100, KeyMgmt8021x = 0x200, KeyMgmtSAE = 0x400 }; Q_DECLARE_FLAGS(Capabilities, Capability) Q_FLAG(Capabilities) Q_DECLARE_FLAGS(WpaFlags, WpaFlag) Q_FLAG(WpaFlags) explicit AccessPoint(const QString &path, QObject *parent = nullptr); virtual ~AccessPoint(); /** * @return path of the access point */ QString uni() const; /** * @return capabilities of an access point */ Capabilities capabilities() const; /** * @return flags describing the access point's capabilities according to WPA (Wifi Protected Access). * @see WpaFlag */ AccessPoint::WpaFlags wpaFlags() const; /** * @return Flags describing the access point's capabilities according to the RSN (Robust Secure Network) protocol. * @see WpaFlag */ AccessPoint::WpaFlags rsnFlags() const; /** * @return The Service Set Identifier identifying the access point. */ QString ssid() const; /** * @return raw SSID, encoded as a byte array */ QByteArray rawSsid() const; /** * @return The radio channel frequency in use by the access point, in MHz. */ uint frequency() const; /** * @return The hardware address (BSSID) of the access point. */ QString hardwareAddress() const; /** * @return The maximum bitrate this access point is capable of, in kilobits/second (Kb/s). */ uint maxBitRate() const; /** * @return Describes the operating mode of the access point. */ OperationMode mode() const; /** * @return The current signal quality of the access point, in percent. */ int signalStrength() const; /** * @return The timestamp (in CLOCK_BOOTTIME seconds) for the last time the access point * was found in scan results. A value of -1 means the access point has never been found in scan results. * @since 5.14.0 */ int lastSeen() const; /** * Helper method to convert wire representation of operation @p mode to enum */ static OperationMode convertOperationMode(uint mode); Q_SIGNALS: /** * This signal is emitted when the signal strength of this network has changed. * * @param strength the new signal strength value for this network */ void signalStrengthChanged(int strength); /** * This signal is emitted when the bitrate of this network has changed. * * @param bitrate the new bitrate value for this network */ void bitRateChanged(int bitrate); /** * This signal is emitted when the capabilities of this network have changed. * * @param caps the new capabilities */ void capabilitiesChanged(AccessPoint::Capabilities caps); /** * This signal is emitted when the WPA flags in use by this access point change * * @param flags the new flags */ void wpaFlagsChanged(AccessPoint::WpaFlags flags); /** * This signal is emitted when the RSN(WPA2) flags in use by this access point change * * @param flags the new flags */ void rsnFlagsChanged(AccessPoint::WpaFlags flags); /** * This signal is emitted when the ssid of this Access Point changes * * @param ssid the new SSID */ void ssidChanged(const QString &ssid); /** * This signal is emitted when the frequency used by this Access Point changes * * @param frequency the new frequency */ void frequencyChanged(uint frequency); /** * This signal is emitted when the timestamp for the last time the access point was found * in scan results changes * * @param lastSeen the timestamp for the last time the access point was found in scan results. * @since 5.14.0 * @see lastSeen */ void lastSeenChanged(int lastSeen); private: Q_DECLARE_PRIVATE(AccessPoint) AccessPointPrivate *const d_ptr; }; Q_DECLARE_OPERATORS_FOR_FLAGS(AccessPoint::WpaFlags) } #endif diff --git a/src/accesspoint_p.h b/src/accesspoint_p.h index 21d3813..8da46ac 100644 --- a/src/accesspoint_p.h +++ b/src/accesspoint_p.h @@ -1,65 +1,51 @@ /* - Copyright 2008 Will Stephenson - Copyright 2013 Daniel Nicoletti - Copyright 2013-2014 Jan Grulich + SPDX-FileCopyrightText: 2008 Will Stephenson + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2013-2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_ACCESSPOINT_P_H #define NETWORKMANAGERQT_ACCESSPOINT_P_H #include "accesspoint.h" #include "dbus/accesspointinterface.h" namespace NetworkManager { class AccessPointPrivate : public QObject { Q_OBJECT public: AccessPointPrivate(const QString &path, AccessPoint *q); OrgFreedesktopNetworkManagerAccessPointInterface iface; QString uni; AccessPoint::Capabilities capabilities; AccessPoint::WpaFlags wpaFlags; AccessPoint::WpaFlags rsnFlags; QString ssid; QByteArray rawSsid; uint frequency; QString hardwareAddress; uint maxBitRate; AccessPoint::OperationMode mode; int signalStrength; int lastSeen; NetworkManager::AccessPoint::Capabilities convertCapabilities(int caps); NetworkManager::AccessPoint::WpaFlags convertWpaFlags(uint theirFlags); Q_DECLARE_PUBLIC(AccessPoint) AccessPoint *q_ptr; private Q_SLOTS: void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); void propertiesChanged(const QVariantMap &properties); }; } // namespace NetworkManager #endif // NETWORKMANAGERQT_ACCESSPOINT_P_H diff --git a/src/activeconnection.cpp b/src/activeconnection.cpp index 1507aef..0c81b16 100644 --- a/src/activeconnection.cpp +++ b/src/activeconnection.cpp @@ -1,427 +1,413 @@ /* - Copyright 2011 Ilia Kats - Copyright 2013 Daniel Nicoletti - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "activeconnection.h" #include "activeconnection_p.h" #include "connection.h" #include "device.h" #include "nmdebug.h" #include "manager.h" #include "settings.h" #include #include "manager_p.h" NetworkManager::ActiveConnectionPrivate::ActiveConnectionPrivate(const QString &dbusPath, ActiveConnection *q) #ifdef NMQT_STATIC : iface(NetworkManagerPrivate::DBUS_SERVICE, dbusPath, QDBusConnection::sessionBus()) #else : iface(NetworkManagerPrivate::DBUS_SERVICE, dbusPath, QDBusConnection::systemBus()) #endif , dhcp4Config(nullptr) , dhcp6Config(nullptr) , state(ActiveConnection::Unknown) , q_ptr(q) { path = dbusPath; } NetworkManager::ActiveConnectionPrivate::~ActiveConnectionPrivate() { } NetworkManager::ActiveConnection::State NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(uint state) { return (NetworkManager::ActiveConnection::State)state; } NetworkManager::ActiveConnection::Reason NetworkManager::ActiveConnectionPrivate::convertActiveConnectionReason(uint reason) { return (NetworkManager::ActiveConnection::Reason)reason; } NetworkManager::ActiveConnection::ActiveConnection(const QString &path, QObject *parent) : QObject(parent), d_ptr(new ActiveConnectionPrivate(path, this)) { Q_D(ActiveConnection); // Get all ActiveConnection's at once QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } #ifndef NMQT_STATIC QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, d->iface.staticInterfaceName(), QLatin1String("StateChanged"), d, SLOT(stateChanged(uint,uint))); #endif #ifdef NMQT_STATIC connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::PropertiesChanged, d, &ActiveConnectionPrivate::propertiesChanged); connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::StateChanged, d, &ActiveConnectionPrivate::stateChanged); #endif #ifndef NMQT_STATIC /* * Workaround: Re-check connection state before we watch changes in case it gets changed too quickly * BUG:352326 */ d->recheckProperties(); #endif } NetworkManager::ActiveConnection::ActiveConnection(ActiveConnectionPrivate &dd, QObject *parent) : QObject(parent), d_ptr(&dd) { Q_D(ActiveConnection); #ifndef NMQT_STATIC QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, d->iface.staticInterfaceName(), QLatin1String("StateChanged"), d, SLOT(stateChanged(uint,uint))); #endif #ifdef NMQT_STATIC connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::PropertiesChanged, d, &ActiveConnectionPrivate::propertiesChanged); connect(&d->iface, &OrgFreedesktopNetworkManagerConnectionActiveInterface::StateChanged, d, &ActiveConnectionPrivate::stateChanged); #endif #ifndef NMQT_STATIC /* * Workaround: Re-check connection state before we watch changes in case it gets changed too quickly * BUG:352326 */ d->recheckProperties(); #endif } NetworkManager::ActiveConnection::~ActiveConnection() { delete d_ptr; } bool NetworkManager::ActiveConnection::isValid() const { Q_D(const ActiveConnection); return !d->connection.isNull(); } NetworkManager::Connection::Ptr NetworkManager::ActiveConnection::connection() const { Q_D(const ActiveConnection); return d->connection; } QString NetworkManager::ActiveConnection::path() const { Q_D(const ActiveConnection); return d->path; } bool NetworkManager::ActiveConnection::default4() const { Q_D(const ActiveConnection); return d->default4; } bool NetworkManager::ActiveConnection::default6() const { Q_D(const ActiveConnection); return d->default6; } NetworkManager::Dhcp4Config::Ptr NetworkManager::ActiveConnection::dhcp4Config() const { Q_D(const ActiveConnection); if (!d->dhcp4Config && !d->dhcp4ConfigPath.isNull()) { d->dhcp4Config = NetworkManager::Dhcp4Config::Ptr(new Dhcp4Config(d->dhcp4ConfigPath), &QObject::deleteLater); } return d->dhcp4Config; } NetworkManager::Dhcp6Config::Ptr NetworkManager::ActiveConnection::dhcp6Config() const { Q_D(const ActiveConnection); if (!d->dhcp6Config && !d->dhcp6ConfigPath.isNull()) { d->dhcp6Config = NetworkManager::Dhcp6Config::Ptr(new Dhcp6Config(d->dhcp6ConfigPath), &QObject::deleteLater); } return d->dhcp6Config; } NetworkManager::IpConfig NetworkManager::ActiveConnection::ipV4Config() const { Q_D(const ActiveConnection); if (!d->ipV4Config.isValid() && !d->ipV4ConfigPath.isNull()) { d->ipV4Config.setIPv4Path(d->ipV4ConfigPath); } return d->ipV4Config; } NetworkManager::IpConfig NetworkManager::ActiveConnection::ipV6Config() const { Q_D(const ActiveConnection); if (!d->ipV6Config.isValid() && !d->ipV6ConfigPath.isNull()) { d->ipV6Config.setIPv6Path(d->ipV6ConfigPath); } return d->ipV6Config; } QString NetworkManager::ActiveConnection::id() const { Q_D(const ActiveConnection); return d->id; } NetworkManager::ConnectionSettings::ConnectionType NetworkManager::ActiveConnection::type() const { Q_D(const ActiveConnection); return NetworkManager::ConnectionSettings::typeFromString(d->type); } QString NetworkManager::ActiveConnection::master() const { Q_D(const ActiveConnection); return d->master; } QString NetworkManager::ActiveConnection::specificObject() const { Q_D(const ActiveConnection); return d->specificObject; } NetworkManager::ActiveConnection::State NetworkManager::ActiveConnection::state() const { Q_D(const ActiveConnection); return d->state; } bool NetworkManager::ActiveConnection::vpn() const { Q_D(const ActiveConnection); return d->vpn; } QString NetworkManager::ActiveConnection::uuid() const { Q_D(const ActiveConnection); return d->uuid; } QStringList NetworkManager::ActiveConnection::devices() const { Q_D(const ActiveConnection); return d->devices; } void NetworkManager::ActiveConnectionPrivate::recheckProperties() { Q_Q(ActiveConnection); /* * Workaround: Re-check connection state before we watch changes in case it gets changed too quickly * BUG:352326 */ QStringList properties; const QDBusObjectPath ip4ConfigObjectPath = iface.ip4Config(); const QDBusObjectPath ip6ConfigObjectPath = iface.ip6Config(); const QDBusObjectPath dhcp4ConfigObjectPath = iface.dhcp4Config(); const QDBusObjectPath dhcp6ConfigObjectPath = iface.dhcp6Config(); if (state != NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(iface.state())) { properties << QLatin1String("State"); } if (!ip4ConfigObjectPath.path().isNull() && ip4ConfigObjectPath.path() != ipV4ConfigPath) { properties << QLatin1String("Ip4Config"); } if (!ip6ConfigObjectPath.path().isNull() && ip6ConfigObjectPath.path() != ipV6ConfigPath) { properties << QLatin1String("Ip6Config"); } if (!dhcp4ConfigObjectPath.path().isNull() && dhcp4ConfigObjectPath.path() != dhcp4ConfigPath) { properties << QLatin1String("Dhcp4Config"); } if (!dhcp6ConfigObjectPath.path().isNull() && dhcp6ConfigObjectPath.path() != dhcp6ConfigPath) { properties << QLatin1String("Dhcp6Config"); } Q_FOREACH (const QString &property, properties) { QDBusMessage message = QDBusMessage::createMethodCall(NetworkManager::NetworkManagerPrivate::DBUS_SERVICE, NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH, NetworkManager::NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("Get")); message << iface.staticInterfaceName() << property; QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(message); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this); connect(watcher, &QDBusPendingCallWatcher::finished, [watcher, q, this, property] () { watcher->deleteLater(); if (property == QLatin1String("State")) { state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(iface.state()); Q_EMIT q->stateChanged(state); } if (property == QLatin1String("Ip4Config")) { ipV4ConfigPath = iface.ip4Config().path(); Q_EMIT q->ipV4ConfigChanged(); } else if (property == QLatin1String("Ip6Config")) { ipV6ConfigPath = iface.ip6Config().path(); Q_EMIT q->ipV6ConfigChanged(); } else if (property == QLatin1String("Dhcp4Config")) { dhcp4ConfigPath = iface.dhcp4Config().path(); Q_EMIT q->dhcp4ConfigChanged(); } else if (property == QLatin1String("Dhcp6Config")) { dhcp6ConfigPath = iface.dhcp6Config().path(); Q_EMIT q->dhcp6ConfigChanged(); } }); } } void NetworkManager::ActiveConnectionPrivate::dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties) { Q_UNUSED(invalidatedProperties); if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.Connection.Active")) { propertiesChanged(properties); } } void NetworkManager::ActiveConnectionPrivate::propertiesChanged(const QVariantMap &properties) { // qCDebug(NMQT) << Q_FUNC_INFO << properties; QVariantMap::const_iterator it = properties.constBegin(); while (it != properties.constEnd()) { propertyChanged(it.key(), it.value()); ++it; } } void NetworkManager::ActiveConnectionPrivate::stateChanged(uint state, uint reason) { Q_Q(ActiveConnection); Q_EMIT q->stateChangedReason(convertActiveConnectionState(state), convertActiveConnectionReason(reason)); } void NetworkManager::ActiveConnectionPrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(ActiveConnection); // qCDebug(NMQT) << property << " - " << value; if (property == QLatin1String("Connection")) { connection = NetworkManager::findConnection(qdbus_cast(value).path()); Q_EMIT q->connectionChanged(connection); const QString tmpId = connection->settings()->id(); const QString tmpType = connection->settings()->typeAsString(connection->settings()->connectionType()); if (tmpId != id) { id = tmpId; Q_EMIT q->idChanged(id); } if (tmpType != type) { Q_EMIT q->typeChanged(NetworkManager::ConnectionSettings::typeFromString(type)); } } else if (property == QLatin1String("Default")) { default4 = value.toBool(); Q_EMIT q->default4Changed(default4); } else if (property == QLatin1String("Default6")) { default6 = value.toBool(); Q_EMIT q->default6Changed(default6); } else if (property == QLatin1String("Dhcp4Config")) { QDBusObjectPath dhcp4ConfigPathTmp = (value).value(); if (dhcp4ConfigPathTmp.path().isNull()) { dhcp4Config.clear(); dhcp4ConfigPath.clear(); } else if (!dhcp4Config || dhcp4Config->path() != dhcp4ConfigPathTmp.path()) { dhcp4Config.clear(); dhcp4ConfigPath = dhcp4ConfigPathTmp.path(); } Q_EMIT q->dhcp4ConfigChanged(); } else if (property == QLatin1String("Dhcp6Config")) { QDBusObjectPath dhcp6ConfigPathTmp = (value).value(); if (dhcp6ConfigPathTmp.path().isNull()) { dhcp6Config.clear(); dhcp6ConfigPath.clear(); } else if (!dhcp6Config || dhcp6Config->path() != dhcp6ConfigPathTmp.path()) { dhcp6Config.clear(); dhcp6ConfigPath = dhcp6ConfigPathTmp.path(); } Q_EMIT q->dhcp6ConfigChanged(); } else if (property == QLatin1String("Ip4Config")) { QDBusObjectPath ip4ConfigObjectPathTmp = (value).value(); if (ip4ConfigObjectPathTmp.path().isNull() || ip4ConfigObjectPathTmp.path() == QLatin1String("/")) { ipV4ConfigPath.clear(); } else { ipV4ConfigPath = ip4ConfigObjectPathTmp.path(); } ipV4Config = IpConfig(); Q_EMIT q->ipV4ConfigChanged(); } else if (property == QLatin1String("Ip6Config")) { QDBusObjectPath ip6ConfigObjectPathTmp = (value).value(); if (ip6ConfigObjectPathTmp.path().isNull() || ip6ConfigObjectPathTmp.path() == QLatin1String("/")) { ipV6ConfigPath.clear(); } else { ipV6ConfigPath = ip6ConfigObjectPathTmp.path(); } ipV6Config = IpConfig(); Q_EMIT q->ipV6ConfigChanged(); } else if (property == QLatin1String("Id")) { id = value.toString(); Q_EMIT q->idChanged(id); } else if (property == QLatin1String("Type")) { type = value.toString(); Q_EMIT q->typeChanged(NetworkManager::ConnectionSettings::typeFromString(type)); } else if (property == QLatin1String("Master")) { master = qdbus_cast(value).path(); Q_EMIT q->masterChanged(master); } else if (property == QLatin1String("SpecificObject")) { specificObject = qdbus_cast(value).path(); Q_EMIT q->specificObjectChanged(specificObject); } else if (property == QLatin1String("State")) { state = NetworkManager::ActiveConnectionPrivate::convertActiveConnectionState(value.toUInt()); Q_EMIT q->stateChanged(state); } else if (property == QLatin1String("Vpn")) { vpn = value.toBool(); Q_EMIT q->vpnChanged(vpn); } else if (property == QLatin1String("Uuid")) { uuid = value.toString(); Q_EMIT q->uuidChanged(uuid); } else if (property == QLatin1String("Devices")) { devices.clear(); Q_FOREACH (const QDBusObjectPath & path, qdbus_cast< QList >(value)) { devices.append(path.path()); } Q_EMIT q->devicesChanged(); } else { qCDebug(NMQT) << Q_FUNC_INFO << "Unhandled property" << property; } } diff --git a/src/activeconnection.h b/src/activeconnection.h index ec37db6..b905973 100644 --- a/src/activeconnection.h +++ b/src/activeconnection.h @@ -1,247 +1,233 @@ /* - Copyright 2011 Ilia Kats - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_ACTIVECONNECTION_H #define NETWORKMANAGERQT_ACTIVECONNECTION_H #include #include #include #include #include "connection.h" #include "dhcp4config.h" #include "dhcp6config.h" #include "ipconfig.h" namespace NetworkManager { class ActiveConnectionPrivate; /** * An active connection */ class NETWORKMANAGERQT_EXPORT ActiveConnection : public QObject { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; /** * Enum describing possible active connection states */ enum State { Unknown = 0, /**< The active connection is in an unknown state */ Activating, /**< The connection is activating */ Activated, /**< The connection is activated */ Deactivating, /**< The connection is being torn down and cleaned up */ Deactivated /**< The connection is no longer active */ }; enum Reason { UknownReason = 0, /**< The reason for the active connection state change is unknown */ None, /**< No reason was given for the active connection state change */ UserDisconnected, /**< The active connection changed state because the user disconnected it */ DeviceDisconnected, /**< The active connection changed state because the device it was using was disconnected */ ServiceStopped, /**< The service providing the VPN connection was stopped */ IpConfigInvalid, /**< The IP config of the active connection was invalid */ ConnectTimeout, /**< The connection attempt to the VPN service timed out */ ServiceStartTimeout,/**< A timeout occurred while starting the service providing the VPN connection */ ServiceStartFailed, /**< Starting the service providing the VPN connection failed */ NoSecrets, /**< Necessary secrets for the connection were not provided */ LoginFailed, /**< Authentication to the server failed */ ConnectionRemoved, /**< The connection was deleted from settings */ DependencyFailed, /**< Master connection of this connection failed to activate */ DeviceRealizeFailed,/**< Could not create the software device link */ DeviceRemoved /**< The device this connection depended on disappeared */ }; /** * Creates a new ActiveConnection object. * * @param path the DBus path of the device */ explicit ActiveConnection(const QString &path, QObject *parent = nullptr); explicit ActiveConnection(ActiveConnectionPrivate &dd, QObject *parent = nullptr); /** * Destroys an ActiveConnection object. */ virtual ~ActiveConnection(); /** * Returns true is this object holds a valid connection */ bool isValid() const; /** * Return path of the connection object */ QString path() const; /** * Returns a valid NetworkManager::Connection object */ Connection::Ptr connection() const; /** * Whether this connection has the default IPv4 route */ bool default4() const; /** * Whether this connection has the default IPv6 route */ bool default6() const; /** * The Ip4Config object describing the configuration of the * connection. Only valid when the connection is in the * NM_ACTIVE_CONNECTION_STATE_ACTIVATED state */ IpConfig ipV4Config() const; /** * The Ip6Config object describing the configuration of the * connection. Only valid when the connection is in the * NM_ACTIVE_CONNECTION_STATE_ACTIVATED state */ IpConfig ipV6Config() const; /** * The Dhcp4Config object describing the DHCP options * returned by the DHCP server (assuming the connection used DHCP). Only * valid when the connection is in the NM_ACTIVE_CONNECTION_STATE_ACTIVATED * state */ Dhcp4Config::Ptr dhcp4Config() const; /** * The Dhcp6Config object describing the DHCP options * returned by the DHCP server (assuming the connection used DHCP). Only * valid when the connection is in the NM_ACTIVE_CONNECTION_STATE_ACTIVATED * state */ Dhcp6Config::Ptr dhcp6Config() const; /** * The Id of the connection */ QString id() const; /** * The type of the connection */ NetworkManager::ConnectionSettings::ConnectionType type() const; /** * Returns the uni of master device if the connection is a slave. */ QString master() const; /** * The path of the specific object associated with the connection. */ QString specificObject() const; /** * The current state of the connection */ NetworkManager::ActiveConnection::State state() const; /** * Whether this is a VPN connection */ bool vpn() const; /** * The UUID of the connection. */ QString uuid() const; /** * List of devices UNIs which are part of this connection. */ QStringList devices() const; Q_SIGNALS: /** * This signal is emitted when the connection path has changed */ void connectionChanged(const NetworkManager::Connection::Ptr &connection); /** * The state of the default IPv4 route changed */ void default4Changed(bool isDefault); /** * The state of the default IPv6 route changed */ void default6Changed(bool isDefault); /** * Emitted when the DHCP configuration for IPv4 of this network has changed. */ void dhcp4ConfigChanged(); /** * Emitted when the DHCP configuration for IPv6 of this network has changed. */ void dhcp6ConfigChanged(); /** * Emitted when the IPv4 configuration of this network has changed. */ void ipV4ConfigChanged(); /** * Emitted when the IPv6 configuration of this network has changed. */ void ipV6ConfigChanged(); /** * The @p id changed */ void idChanged(const QString &id); /** * The @p type changed */ void typeChanged(NetworkManager::ConnectionSettings::ConnectionType type); /** * The master device changed. */ void masterChanged(const QString &uni); /** * The @p path to the specific object changed */ void specificObjectChanged(const QString &path); /** * The @p state changed */ void stateChanged(NetworkManager::ActiveConnection::State state); /** * The @p state changed because of reason @p reason * (never emitted in runtime NM < 1.8.0) */ void stateChangedReason(NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason); /** * The VPN property changed. */ void vpnChanged(bool isVpn); /** * The @p uuid changed. */ void uuidChanged(const QString &uuid); /** * The list of devices changed. */ void devicesChanged(); protected: ActiveConnectionPrivate *const d_ptr; private: Q_DECLARE_PRIVATE(ActiveConnection) }; } // namespace NetworkManager #endif // NETWORKMANAGERQT_ACTIVECONNECTION_H diff --git a/src/activeconnection_p.h b/src/activeconnection_p.h index e39bd99..70a6f77 100644 --- a/src/activeconnection_p.h +++ b/src/activeconnection_p.h @@ -1,84 +1,70 @@ /* - Copyright 2011 Ilia Kats + SPDX-FileCopyrightText: 2011 Ilia Kats - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_ACTIVECONNECTION_P_H #define NETWORKMANAGERQT_ACTIVECONNECTION_P_H #include "activeconnection.h" #include "activeconnectioninterface.h" namespace NetworkManager { class ActiveConnectionPrivate : public QObject { Q_OBJECT public: explicit ActiveConnectionPrivate(const QString &, ActiveConnection *q); virtual ~ActiveConnectionPrivate(); static NetworkManager::ActiveConnection::State convertActiveConnectionState(uint); static NetworkManager::ActiveConnection::Reason convertActiveConnectionReason(uint); NetworkManager::Connection::Ptr connection; QString path; bool default4; bool default6; QStringList devices; OrgFreedesktopNetworkManagerConnectionActiveInterface iface; mutable Dhcp4Config::Ptr dhcp4Config; QString dhcp4ConfigPath; mutable Dhcp6Config::Ptr dhcp6Config; QString dhcp6ConfigPath; mutable IpConfig ipV4Config; QString ipV4ConfigPath; mutable IpConfig ipV6Config; QString ipV6ConfigPath; QString id; QString type; QString specificObject; ActiveConnection::State state; bool vpn; QString uuid; QString master; Q_DECLARE_PUBLIC(ActiveConnection) ActiveConnection *q_ptr; /* * Workaround: Re-check connection state before we watch changes in case it gets changed too quickly * BUG:352326 */ void recheckProperties(); public: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ virtual void propertyChanged(const QString &property, const QVariant &value); public Q_SLOTS: void propertiesChanged(const QVariantMap &properties); void stateChanged(uint state, uint reason); private Q_SLOTS: void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); }; } #endif diff --git a/src/adsldevice.cpp b/src/adsldevice.cpp index fc81305..c0879d5 100644 --- a/src/adsldevice.cpp +++ b/src/adsldevice.cpp @@ -1,79 +1,65 @@ /* - Copyright 2012-2013 Jan Grulich - Copyright 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Daniel Nicoletti - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "adsldevice_p.h" NetworkManager::AdslDevicePrivate::AdslDevicePrivate(const QString &path, AdslDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , carrier(false) { } NetworkManager::AdslDevice::~AdslDevice() { } NetworkManager::AdslDevice::AdslDevice(const QString &path, QObject *parent) : Device(*new AdslDevicePrivate(path, this), parent) { Q_D(AdslDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::AdslDevicePrivate::~AdslDevicePrivate() { } NetworkManager::Device::Type NetworkManager::AdslDevice::type() const { return NetworkManager::Device::Adsl; } bool NetworkManager::AdslDevice::carrier() const { Q_D(const AdslDevice); return d->carrier; } void NetworkManager::AdslDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(AdslDevice); if (property == QLatin1String("Carrier")) { carrier = value.toBool(); Q_EMIT q->carrierChanged(carrier); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/adsldevice.h b/src/adsldevice.h index 3482e66..c1694c5 100644 --- a/src/adsldevice.h +++ b/src/adsldevice.h @@ -1,63 +1,49 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_ADSL_DEVICE_H #define NETWORKMANAGERQT_ADSL_DEVICE_H #include "device.h" #include namespace NetworkManager { class AdslDevicePrivate; /** * An adsl device interface */ class NETWORKMANAGERQT_EXPORT AdslDevice : public Device { Q_OBJECT Q_PROPERTY(bool carrier READ carrier NOTIFY carrierChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit AdslDevice(const QString &path, QObject *parent = nullptr); ~AdslDevice() override; Type type() const override; /** * Indicates whether the physical carrier is found */ bool carrier() const; Q_SIGNALS: /** * Emitted when the carrier of this device has changed */ void carrierChanged(bool plugged); private: Q_DECLARE_PRIVATE(AdslDevice) }; } #endif diff --git a/src/adsldevice_p.h b/src/adsldevice_p.h index 9e87851..3f74ba5 100644 --- a/src/adsldevice_p.h +++ b/src/adsldevice_p.h @@ -1,53 +1,39 @@ /* - Copyright 2012-2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_ADSL_DEVICE_P_H #define NETWORKMANAGERQT_ADSL_DEVICE_P_H #include "adsldevice.h" #include "device_p.h" #include "manager.h" #include "manager_p.h" #include "adsldeviceinterface.h" namespace NetworkManager { class AdslDevicePrivate : public DevicePrivate { Q_OBJECT public: AdslDevicePrivate(const QString &path, AdslDevice *q); virtual ~AdslDevicePrivate(); OrgFreedesktopNetworkManagerDeviceAdslInterface iface; bool carrier; Q_DECLARE_PUBLIC(AdslDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/bluetoothdevice.cpp b/src/bluetoothdevice.cpp index de6c22a..8b192cf 100644 --- a/src/bluetoothdevice.cpp +++ b/src/bluetoothdevice.cpp @@ -1,93 +1,79 @@ /* - Copyright 2011 Lamarque Souza - Copyright 2011 Will Stephenson + SPDX-FileCopyrightText: 2011 Lamarque Souza + SPDX-FileCopyrightText: 2011 Will Stephenson - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bluetoothdevice.h" #include "bluetoothdevice_p.h" #include "manager_p.h" #include "nmdebug.h" NetworkManager::BluetoothDevicePrivate::BluetoothDevicePrivate(const QString &path, BluetoothDevice *q) : ModemDevicePrivate(path, q) #ifdef NMQT_STATIC , btIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , btIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::BluetoothDevice::BluetoothDevice(const QString &path, QObject *parent) : ModemDevice(*new BluetoothDevicePrivate(path, this), parent) { Q_D(BluetoothDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->btIface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::BluetoothDevice::~BluetoothDevice() { } NetworkManager::Device::Type NetworkManager::BluetoothDevice::type() const { return NetworkManager::Device::Bluetooth; } void NetworkManager::BluetoothDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(BluetoothDevice); if (property == QLatin1String("Name")) { name = value.toString(); Q_EMIT q->nameChanged(name); } else if (property == QLatin1String("HwAddress")) { hardwareAddress = value.toString(); } else if (property == QLatin1String("BtCapabilities")) { btCapabilities = static_cast(value.toUInt()); } else { DevicePrivate::propertyChanged(property, value); } } NetworkManager::BluetoothDevice::Capabilities NetworkManager::BluetoothDevice::bluetoothCapabilities() const { Q_D(const BluetoothDevice); return d->btCapabilities; } QString NetworkManager::BluetoothDevice::hardwareAddress() const { Q_D(const BluetoothDevice); return d->hardwareAddress; } QString NetworkManager::BluetoothDevice::name() const { Q_D(const BluetoothDevice); return d->name; } diff --git a/src/bluetoothdevice.h b/src/bluetoothdevice.h index b37ca38..6d42af7 100644 --- a/src/bluetoothdevice.h +++ b/src/bluetoothdevice.h @@ -1,100 +1,86 @@ /* - Copyright 2011 Lamarque Souza - Copyright 2011 Will Stephenson - Copyright 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2011 Lamarque Souza + SPDX-FileCopyrightText: 2011 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "modemdevice.h" #ifndef NETWORKMANAGERQT_BLUETOOTH_DEVICE_H #define NETWORKMANAGERQT_BLUETOOTH_DEVICE_H #include namespace NetworkManager { class BluetoothDevicePrivate; /** * A bluetooth device interface */ class NETWORKMANAGERQT_EXPORT BluetoothDevice: public ModemDevice { Q_OBJECT Q_PROPERTY(uint bluetoothCapabilities READ bluetoothCapabilities) Q_PROPERTY(QString hardwareAddress READ hardwareAddress) Q_PROPERTY(QString name READ name) public: typedef QSharedPointer Ptr; typedef QList List; /** * Capabilities of the Bluetooth device */ enum Capability { NoCapability = 0x0, /**< No special capability */ Dun = 0x1, /**< Dial Up Networking profile */ Pan = 0x2 /**< Personal Area Network profile */ }; Q_DECLARE_FLAGS(Capabilities, Capability) Q_FLAG(Capabilities) /** * Creates a new BluetoothDevice object. */ explicit BluetoothDevice(const QString &path, QObject *parent = nullptr); /** * Destroys a BluetoothDevice object. */ ~BluetoothDevice() override; /** * Retrieves the capabilities supported by this device. * * @return the capabilities of the device * @see NetworkManager::BluetoothDevice::Capability */ Capabilities bluetoothCapabilities() const; /** * The hardware address assigned to the bluetooth interface */ QString hardwareAddress() const; /** * Name of the bluetooth interface */ QString name() const; /** * The NetworkInterface type. * * @return the NetworkManager::Device::Type. This always returns NetworkManager::Device::Bluetooth */ Type type() const override; Q_SIGNALS: /** * Emitted when the BT device @p name changes */ void nameChanged(const QString &name); private: Q_DECLARE_PRIVATE(BluetoothDevice) }; } #endif diff --git a/src/bluetoothdevice_p.h b/src/bluetoothdevice_p.h index 2fd1279..5d8864f 100644 --- a/src/bluetoothdevice_p.h +++ b/src/bluetoothdevice_p.h @@ -1,49 +1,36 @@ /* - Copyright 2011 Lamarque Souza + SPDX-FileCopyrightText: 2011 Lamarque Souza - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ + #ifndef NETWORKMANAGERQT_BLUETOOTH_DEVICE_P_H #define NETWORKMANAGERQT_BLUETOOTH_DEVICE_P_H #include "modemdevice_p.h" #include "dbus/bluetoothdeviceinterface.h" namespace NetworkManager { class BluetoothDevicePrivate : public ModemDevicePrivate { Q_OBJECT public: explicit BluetoothDevicePrivate(const QString &path, BluetoothDevice *q); OrgFreedesktopNetworkManagerDeviceBluetoothInterface btIface; BluetoothDevice::Capabilities btCapabilities; QString hardwareAddress; QString name; Q_DECLARE_PUBLIC(BluetoothDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif // NETWORKMANAGERQT__BLUETOOTH_DEVICE_P_H diff --git a/src/bonddevice.cpp b/src/bonddevice.cpp index 9b89590..ca02685 100644 --- a/src/bonddevice.cpp +++ b/src/bonddevice.cpp @@ -1,105 +1,91 @@ /* - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bonddevice_p.h" #include "device_p.h" #include "manager.h" #include "manager_p.h" NetworkManager::BondDevicePrivate::BondDevicePrivate(const QString &path, BondDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , carrier(false) { } NetworkManager::BondDevice::~BondDevice() { } NetworkManager::BondDevice::BondDevice(const QString &path, QObject *parent): Device(*new BondDevicePrivate(path, this), parent) { Q_D(BondDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::BondDevicePrivate::~BondDevicePrivate() { } NetworkManager::Device::Type NetworkManager::BondDevice::type() const { return NetworkManager::Device::Bond; } bool NetworkManager::BondDevice::carrier() const { Q_D(const BondDevice); return d->carrier; } QString NetworkManager::BondDevice::hwAddress() const { Q_D(const BondDevice); return d->hwAddress; } QStringList NetworkManager::BondDevice::slaves() const { Q_D(const BondDevice); return d->slaves; } void NetworkManager::BondDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(BondDevice); if (property == QLatin1String("Carrier")) { carrier = value.toBool(); Q_EMIT q->carrierChanged(carrier); } else if (property == QLatin1String("HwAddress")) { hwAddress = value.toString(); Q_EMIT q->hwAddressChanged(hwAddress); } else if (property == QLatin1String("Slaves")) { QStringList list; Q_FOREACH (const QDBusObjectPath & op, qdbus_cast< QList >(value)) { list << op.path(); } slaves = list; Q_EMIT q->slavesChanged(slaves); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/bonddevice.h b/src/bonddevice.h index 82f0c9d..804ce11 100644 --- a/src/bonddevice.h +++ b/src/bonddevice.h @@ -1,83 +1,69 @@ /* - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BOND_DEVICE_H #define NETWORKMANAGERQT_BOND_DEVICE_H #include "device.h" #include namespace NetworkManager { class BondDevicePrivate; /** * A bond device interface */ class NETWORKMANAGERQT_EXPORT BondDevice : public Device { Q_OBJECT Q_PROPERTY(bool carrier READ carrier NOTIFY carrierChanged) Q_PROPERTY(QString hwAddress READ hwAddress NOTIFY hwAddressChanged) Q_PROPERTY(QStringList slaves READ slaves NOTIFY slavesChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit BondDevice(const QString &path, QObject *parent = nullptr); ~BondDevice() override; Type type() const override; /** * Indicates whether the physical carrier is found */ bool carrier() const; /** * Hardware address of the device */ QString hwAddress() const; /** * Array of object paths representing devices which are currently slaved to this device */ QStringList slaves() const; Q_SIGNALS: /** * Emitted when the carrier of this device has changed */ void carrierChanged(bool plugged); /** * Emitted when the hardware address of this device has changed */ void hwAddressChanged(const QString &address); /** * Emitted when the slaves of this device have changed */ void slavesChanged(const QStringList &slaves); private: Q_DECLARE_PRIVATE(BondDevice) }; } #endif diff --git a/src/bonddevice_p.h b/src/bonddevice_p.h index f3d4028..6246061 100644 --- a/src/bonddevice_p.h +++ b/src/bonddevice_p.h @@ -1,51 +1,37 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BOND_DEVICE_P_H #define NETWORKMANAGERQT_BOND_DEVICE_P_H #include "bonddevice.h" #include "device_p.h" #include "dbus/bonddeviceinterface.h" namespace NetworkManager { class BondDevicePrivate : public DevicePrivate { Q_OBJECT public: BondDevicePrivate(const QString &path, BondDevice *q); virtual ~BondDevicePrivate(); OrgFreedesktopNetworkManagerDeviceBondInterface iface; bool carrier; QString hwAddress; QStringList slaves; Q_DECLARE_PUBLIC(BondDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif // NETWORKMANAGERQT__BLUETOOTH_DEVICE_P_H diff --git a/src/bridgedevice.cpp b/src/bridgedevice.cpp index 6266707..35a593b 100644 --- a/src/bridgedevice.cpp +++ b/src/bridgedevice.cpp @@ -1,103 +1,89 @@ /* - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bridgedevice_p.h" #include "manager_p.h" NetworkManager::BridgeDevicePrivate::BridgeDevicePrivate(const QString &path, BridgeDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , carrier(false) { } NetworkManager::BridgeDevicePrivate::~BridgeDevicePrivate() { } NetworkManager::BridgeDevice::BridgeDevice(const QString &path, QObject *parent): Device(*new BridgeDevicePrivate(path, this), parent) { Q_D(BridgeDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::BridgeDevice::~BridgeDevice() { } NetworkManager::Device::Type NetworkManager::BridgeDevice::type() const { return NetworkManager::Device::Bridge; } bool NetworkManager::BridgeDevice::carrier() const { Q_D(const BridgeDevice); return d->carrier; } QString NetworkManager::BridgeDevice::hwAddress() const { Q_D(const BridgeDevice); return d->hwAddress; } QStringList NetworkManager::BridgeDevice::slaves() const { Q_D(const BridgeDevice); return d->slaves; } void NetworkManager::BridgeDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(BridgeDevice); if (property == QLatin1String("Carrier")) { carrier = value.toBool(); Q_EMIT q->carrierChanged(carrier); } else if (property == QLatin1String("HwAddress")) { hwAddress = value.toString(); Q_EMIT q->hwAddressChanged(hwAddress); } else if (property == QLatin1String("Slaves")) { QStringList list; Q_FOREACH (const QDBusObjectPath & op, qdbus_cast< QList >(value)) { list << op.path(); } slaves = list; Q_EMIT q->slavesChanged(slaves); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/bridgedevice.h b/src/bridgedevice.h index 377c599..3c4758e 100644 --- a/src/bridgedevice.h +++ b/src/bridgedevice.h @@ -1,83 +1,69 @@ /* - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BRIDGE_DEVICE_H #define NETWORKMANAGERQT_BRIDGE_DEVICE_H #include "device.h" #include namespace NetworkManager { class BridgeDevicePrivate; /** * A bridge device interface */ class NETWORKMANAGERQT_EXPORT BridgeDevice : public Device { Q_OBJECT Q_PROPERTY(bool carrier READ carrier NOTIFY carrierChanged) Q_PROPERTY(QString hwAddress READ hwAddress NOTIFY hwAddressChanged) Q_PROPERTY(QStringList slaves READ slaves NOTIFY slavesChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit BridgeDevice(const QString &path, QObject *parent = nullptr); ~BridgeDevice() override; Type type() const override; /** * Indicates whether the physical carrier is found */ bool carrier() const; /** * Hardware address of the device */ QString hwAddress() const; /** * Array of object paths representing devices which are currently slaved to this device */ QStringList slaves() const; Q_SIGNALS: /** * Emitted when the carrier of this device has changed */ void carrierChanged(bool plugged); /** * Emitted when the hardware address of this device has changed */ void hwAddressChanged(const QString &address); /** * Emitted when the slaves of this device have changed */ void slavesChanged(const QStringList &slaves); private: Q_DECLARE_PRIVATE(BridgeDevice) }; } #endif diff --git a/src/bridgedevice_p.h b/src/bridgedevice_p.h index 42aa09f..9f51f3f 100644 --- a/src/bridgedevice_p.h +++ b/src/bridgedevice_p.h @@ -1,53 +1,39 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BRIDGE_DEVICE_P_H #define NETWORKMANAGERQT_BRIDGE_DEVICE_P_H #include "bridgedevice.h" #include "device_p.h" #include "manager.h" #include "bridgedeviceinterface.h" namespace NetworkManager { class BridgeDevicePrivate : public DevicePrivate { public: BridgeDevicePrivate(const QString &path, BridgeDevice *q); virtual ~BridgeDevicePrivate(); OrgFreedesktopNetworkManagerDeviceBridgeInterface iface; bool carrier; QString hwAddress; QStringList slaves; Q_DECLARE_PUBLIC(BridgeDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/connection.cpp b/src/connection.cpp index bc05855..3b5df30 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -1,210 +1,196 @@ /* - Copyright 2008,2009 Will Stephenson - Copyright 2011 Ilia Kats - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2009 Will Stephenson + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "connection_p.h" #undef signals #include #define signals Q_SIGNALS #include #include #include #include "nmdebug.h" NetworkManager::ConnectionPrivate::ConnectionPrivate(const QString &path, Connection *q) #ifdef NMQT_STATIC : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , q_ptr(q) { } NetworkManager::Connection::Connection(const QString &path, QObject *parent) : QObject(parent) , d_ptr(new ConnectionPrivate(path, this)) { Q_D(Connection); qDBusRegisterMetaType(); QDBusReply reply = d->iface.GetSettings(); if (reply.isValid()) { d->updateSettings(reply.value()); } else { d->updateSettings(); } d->path = path; //qCDebug(NMQT) << m_connection; connect(&d->iface, &OrgFreedesktopNetworkManagerSettingsConnectionInterface::Updated, d, &ConnectionPrivate::onConnectionUpdated); connect(&d->iface, &OrgFreedesktopNetworkManagerSettingsConnectionInterface::Removed, d, &ConnectionPrivate::onConnectionRemoved); d->unsaved = d->iface.unsaved(); QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::Connection::~Connection() { delete d_ptr; } bool NetworkManager::Connection::isValid() const { Q_D(const Connection); return d->iface.isValid(); } QString NetworkManager::Connection::uuid() const { Q_D(const Connection); return d->uuid; } QString NetworkManager::Connection::name() const { Q_D(const Connection); return d->id; } bool NetworkManager::Connection::isUnsaved() const { Q_D(const Connection); return d->unsaved; } NetworkManager::ConnectionSettings::Ptr NetworkManager::Connection::settings() { Q_D(Connection); if (d->connection.isNull()) { d->connection = ConnectionSettings::Ptr(new ConnectionSettings(d->settings)); } return d->connection; } QDBusPendingReply NetworkManager::Connection::secrets(const QString &setting) { Q_D(Connection); return d->iface.GetSecrets(setting); } QDBusPendingReply<> NetworkManager::Connection::update(const NMVariantMapMap &settings) { Q_D(Connection); return d->iface.Update(settings); } QDBusPendingReply<> NetworkManager::Connection::updateUnsaved(const NMVariantMapMap &settings) { Q_D(Connection); return d->iface.UpdateUnsaved(settings); } QDBusPendingReply<> NetworkManager::Connection::save() { Q_D(Connection); return d->iface.Save(); } QDBusPendingReply<> NetworkManager::Connection::clearSecrets() { Q_D(Connection); return d->iface.ClearSecrets(); } QDBusPendingReply<> NetworkManager::Connection::remove() { Q_D(Connection); return d->iface.Delete(); } QString NetworkManager::Connection::path() const { Q_D(const Connection); return d->path; } void NetworkManager::ConnectionPrivate::onConnectionUpdated() { Q_Q(Connection); QDBusReply reply = iface.GetSettings(); if (reply.isValid()) { updateSettings(reply.value()); } else { updateSettings(); } Q_EMIT q->updated(); } void NetworkManager::ConnectionPrivate::onConnectionRemoved() { Q_Q(Connection); QString tmpPath = path; updateSettings(); Q_EMIT q->removed(tmpPath); } void NetworkManager::ConnectionPrivate::dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties) { Q_UNUSED(invalidatedProperties); if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.Settings.Connection")) { onPropertiesChanged(properties); } } void NetworkManager::ConnectionPrivate::onPropertiesChanged(const QVariantMap &properties) { Q_Q(Connection); QVariantMap::const_iterator it = properties.constBegin(); while (it != properties.constEnd()) { const QString property = it.key(); if (property == QLatin1String("Unsaved")) { unsaved = it->toBool(); Q_EMIT q->unsavedChanged(unsaved); } else { qCWarning(NMQT) << Q_FUNC_INFO << "Unhandled property" << property; } ++it; } } void NetworkManager::ConnectionPrivate::updateSettings(const NMVariantMapMap &newSettings) { settings = newSettings; if (settings.contains(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME))) { QVariantMap connectionSetting = settings.value(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME)); if (connectionSetting.contains(QLatin1String(NM_SETTING_CONNECTION_UUID))) { uuid = connectionSetting.value(QLatin1String(NM_SETTING_CONNECTION_UUID)).toString(); } if (connectionSetting.contains(QLatin1String(NM_SETTING_CONNECTION_ID))) { id = connectionSetting.value(QLatin1String(NM_SETTING_CONNECTION_ID)).toString(); } } else if (newSettings.isEmpty()) { uuid.clear(); id.clear(); } connection.clear(); } diff --git a/src/connection.h b/src/connection.h index 19bfa72..eaa1388 100644 --- a/src/connection.h +++ b/src/connection.h @@ -1,165 +1,151 @@ /* - Copyright 2008,2009 Will Stephenson - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2009 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SETTINGS_CONNECTION_H #define NETWORKMANAGERQT_SETTINGS_CONNECTION_H #include #include "generictypes.h" #include "connectionsettings.h" #include #include #include class QDBusPendingCallWatcher; namespace NetworkManager { class ConnectionPrivate; /** * This class represents a single network connection configuration. */ class NETWORKMANAGERQT_EXPORT Connection : public QObject { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; /** * Constructs a connection object for the given path */ explicit Connection(const QString &path, QObject *parent = nullptr); ~Connection(); /** * Returns if this connection is valid */ bool isValid() const; /** * Returns the unique identifier of this connection */ QString uuid() const; /** * Returns the path (DBus) of this connection */ QString path() const; /** * Returns the name of this connection */ QString name() const; /** * If set, indicates that the in-memory state of the * connection does not match the on-disk state. This flag * will be set when updateUnsaved() is called or when any * connection details change, and cleared when the connection * is saved to disk via save() or from internal operations. * * @since 0.9.9.0 */ bool isUnsaved() const; /** * Returns the settings of this connection */ ConnectionSettings::Ptr settings(); /** * Retrieves this connections's secrets (passwords and / or encryption keys). * * @param setting the setting identifier. */ QDBusPendingReply secrets(const QString &setting); /** * Update the connection with new @p settings and properties, replacing all previous settings and properties. * Secrets may be part of the update request, and will be either stored in persistent storage or given to a Secret Agent for storage, * depending on the request. */ QDBusPendingReply<> update(const NMVariantMapMap &settings); /** * Update the connection with new @p settings and properties (replacing * all previous settings and properties) but do not immediately save * the connection to disk. Secrets may be part of the update request * and may sent to a Secret Agent for storage, depending on the * flags associated with each secret. * * Use the save() method to save these changes to disk. Note * that unsaved changes will be lost if the connection is * reloaded from disk (either automatically on file change or * due to an explicit reloadConnections() call). * * @since 0.9.9.0 */ QDBusPendingReply<> updateUnsaved(const NMVariantMapMap &settings); /** * Saves a "dirty" connection (that had previously been * updated with updateUnsaved()) to persistent storage. * * @since 0.9.9.0 */ QDBusPendingReply<> save(); /** * Clear the secrets belonging to this network connection profile. * @since 5.8.0 */ QDBusPendingReply<> clearSecrets(); /** * Removes the connection from NetworkManager database, * this operation does not ask for confirmation but * a policykit rule might prevent it from being removed * without the proper password. */ QDBusPendingReply<> remove(); Q_SIGNALS: /** * Emitted when the connection settings changes */ void updated(); /** * Emitted when the connection was removed * @param path connections's path. */ void removed(const QString &path); /** * Emitted when the connection unsaved state changes */ void unsavedChanged(bool unsaved); private: Q_DECLARE_PRIVATE(Connection) ConnectionPrivate *const d_ptr; }; } #endif // CONNECTION_H diff --git a/src/connection_p.h b/src/connection_p.h index 678cfd6..6af982f 100644 --- a/src/connection_p.h +++ b/src/connection_p.h @@ -1,63 +1,49 @@ /* - Copyright 2008,2009 Will Stephenson - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013-2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2009 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013-2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SETTINGS_CONNECTION_P_H #define NETWORKMANAGERQT_SETTINGS_CONNECTION_P_H #include "connection.h" #include "device.h" #include "manager_p.h" #include "connectioninterface.h" #include "generictypes.h" class QDBusPendingCallWatcher; namespace NetworkManager { class ConnectionPrivate : public QObject { Q_OBJECT public: ConnectionPrivate(const QString &path, Connection *q); void updateSettings(const NMVariantMapMap &newSettings = NMVariantMapMap()); bool unsaved; QString uuid; QString id; NMVariantMapMap settings; ConnectionSettings::Ptr connection; QString path; OrgFreedesktopNetworkManagerSettingsConnectionInterface iface; Q_DECLARE_PUBLIC(Connection) Connection *q_ptr; private Q_SLOTS: void onConnectionUpdated(); void onConnectionRemoved(); void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); void onPropertiesChanged(const QVariantMap &properties); }; } #endif diff --git a/src/device.cpp b/src/device.cpp index 565240c..e289ccc 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -1,639 +1,625 @@ /* - Copyright 2008,2010 Will Stephenson - Copyright 2013 Daniel Nicoletti - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2010 Will Stephenson + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "device_p.h" #include "manager.h" #include "manager_p.h" #include "connection.h" #include "settings.h" #include "nmdebug.h" #include #include // logging category for this framework, default: log stuff >= warning Q_LOGGING_CATEGORY(NMQT, "networkmanager-qt", QtWarningMsg) namespace NetworkManager { class DeviceStateReasonPrivate { public: DeviceStateReasonPrivate(Device::State st, Device::StateChangeReason rsn) : state(st) , reason(rsn) {} DeviceStateReasonPrivate() : state(Device::UnknownState) , reason(Device::UnknownReason) {} Device::State state; Device::StateChangeReason reason; }; } NetworkManager::DeviceStateReason::DeviceStateReason(Device::State state, Device::StateChangeReason reason) : d_ptr(new DeviceStateReasonPrivate(state, reason)) { } NetworkManager::DeviceStateReason::DeviceStateReason(const NetworkManager::DeviceStateReason &other) : d_ptr(new DeviceStateReasonPrivate(*other.d_ptr)) { } NetworkManager::DeviceStateReason::~DeviceStateReason() { delete d_ptr; } NetworkManager::Device::State NetworkManager::DeviceStateReason::state() const { Q_D(const DeviceStateReason); return d->state; } NetworkManager::Device::StateChangeReason NetworkManager::DeviceStateReason::reason() const { Q_D(const DeviceStateReason); return d->reason; } NetworkManager::DeviceStateReason &NetworkManager::DeviceStateReason::operator=(const NetworkManager::DeviceStateReason &other) { if (&other != this) { *d_ptr = *other.d_ptr; } return *this; } NetworkManager::DevicePrivate::DevicePrivate(const QString &path, NetworkManager::Device *q) #ifdef NMQT_STATIC : deviceIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else : deviceIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , uni(path) , designSpeed(0) , dhcp4Config(nullptr) , dhcp6Config(nullptr) , mtu(0) , q_ptr(q) { } NetworkManager::DevicePrivate::~DevicePrivate() { } void NetworkManager::DevicePrivate::init() { qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); // This needs to be initialized as soon as possible, because based on this property // we initialize the device type deviceType = convertType(deviceIface.deviceType()); deviceStatistics = DeviceStatistics::Ptr(new NetworkManager::DeviceStatistics(uni), &QObject::deleteLater); // Get all Device's properties at once QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(deviceIface.staticInterfaceName(), uni); if (!initialProperties.isEmpty()) { propertiesChanged(initialProperties); } QObject::connect(&deviceIface, &OrgFreedesktopNetworkManagerDeviceInterface::StateChanged, this, &DevicePrivate::deviceStateChanged); } NetworkManager::Device::MeteredStatus NetworkManager::DevicePrivate::convertMeteredStatus(uint metered) { NetworkManager::Device::MeteredStatus ourMeteredStatus = (NetworkManager::Device::MeteredStatus) metered; return ourMeteredStatus; } NetworkManager::Device::Capabilities NetworkManager::DevicePrivate::convertCapabilities(uint theirCaps) { NetworkManager::Device::Capabilities ourCaps = (NetworkManager::Device::Capabilities) theirCaps; return ourCaps; } NetworkManager::Device::State NetworkManager::DevicePrivate::convertState(uint theirState) { NetworkManager::Device::State ourState = static_cast(theirState); return ourState; } NetworkManager::Device::StateChangeReason NetworkManager::DevicePrivate::convertReason(uint theirReason) { NetworkManager::Device::StateChangeReason ourReason = (NetworkManager::Device::StateChangeReason)theirReason; return ourReason; } NetworkManager::Device::Type NetworkManager::DevicePrivate::convertType(uint type) { // These are identical to NM enums if (type <= NM_DEVICE_TYPE_TEAM) { return (NetworkManager::Device::Type)type; } switch (type) { case 16: // NM_DEVICE_TYPE_TUN return NetworkManager::Device::Tun; case 17: // NM_DEVICE_TYPE_IP_TUNNEL return NetworkManager::Device::IpTunnel; case 18: // NM_DEVICE_TYPE_MACVLAN return NetworkManager::Device::MacVlan; case 19: // NM_DEVICE_TYPE_VXLAN return NetworkManager::Device::VxLan; case 20: // NM_DEVICE_TYPE_VETH return NetworkManager::Device::Veth; case 21: // NM_DEVICE_TYPE_MACSEC return NetworkManager::Device::MacSec; case 22: // NM_DEVICE_TYPE_DUMMY return NetworkManager::Device::Dummy; case 23: // NM_DEVICE_TYPE_PPP return NetworkManager::Device::Ppp; case 24: // NM_DEVICE_TYPE_OVS_INTERFACE return NetworkManager::Device::OvsInterface; case 25: // NM_DEVICE_TYPE_OVS_PORT return NetworkManager::Device::OvsPort; case 26: // NM_DEVICE_TYPE_OVS_BRIDGE return NetworkManager::Device::OvsBridge; case 27: // NM_DEVICE_TYPE_WPAN return NetworkManager::Device::Wpan; case 28: // NM_DEVICE_TYPE_6LOWPAN return NetworkManager::Device::Lowpan; case 29: // NM_DEVICE_TYPE_NM_DEVICE_TYPE_WIREGUARD return NetworkManager::Device::WireGuard; case 30: // NM_DEVICE_TYPE_WIFI_P2P return NetworkManager::Device::WifiP2P; } return NetworkManager::Device::UnknownType; } NetworkManager::Device::Device(const QString &path, QObject *parent) : QObject(parent) , d_ptr(new DevicePrivate(path, this)) { Q_D(Device); d->init(); } NetworkManager::Device::Device(DevicePrivate &dd, QObject *parent) : QObject(parent) , d_ptr(&dd) { Q_D(Device); d->init(); } void NetworkManager::DevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(Device); // qCDebug(NMQT) << property << " - " << value; if (property == QLatin1String("ActiveConnection")) { // FIXME workaround, because NM doesn't Q_EMIT correct value // d->activeConnection = value.value.path(); activeConnection = deviceIface.activeConnection().path(); Q_EMIT q->activeConnectionChanged(); } else if (property == QLatin1String("Autoconnect")) { autoconnect = value.toBool(); Q_EMIT q->autoconnectChanged(); } else if (property == QLatin1String("AvailableConnections")) { QStringList newAvailableConnections; QList availableConnectionsTmp = qdbus_cast< QList >(value); Q_FOREACH (const QDBusObjectPath & availableConnection, availableConnectionsTmp) { newAvailableConnections << availableConnection.path(); if (!availableConnections.contains(availableConnection.path())) { availableConnections << availableConnection.path(); Q_EMIT q->availableConnectionAppeared(availableConnection.path()); } } Q_FOREACH (const QString & availableConnection, availableConnections) { if (!newAvailableConnections.contains(availableConnection)) { availableConnections.removeOne(availableConnection); Q_EMIT q->availableConnectionDisappeared(availableConnection); } } Q_EMIT q->availableConnectionChanged(); } else if (property == QLatin1String("Capabilities")) { capabilities = NetworkManager::DevicePrivate::convertCapabilities(value.toUInt()); Q_EMIT q->capabilitiesChanged(); } else if (property == QLatin1String("DeviceType")) { deviceType = static_cast(value.toUInt()); } else if (property == QLatin1String("Dhcp4Config")) { QDBusObjectPath dhcp4ConfigPathTmp = value.value(); if (dhcp4ConfigPathTmp.path().isNull()) { dhcp4Config.clear(); dhcp4ConfigPath.clear(); } else if (!dhcp4Config || dhcp4Config->path() != dhcp4ConfigPathTmp.path()) { dhcp4Config.clear(); dhcp4ConfigPath = dhcp4ConfigPathTmp.path(); } Q_EMIT q->dhcp4ConfigChanged(); } else if (property == QLatin1String("Dhcp6Config")) { QDBusObjectPath dhcp6ConfigPathTmp = value.value(); if (dhcp6ConfigPathTmp.path().isNull()) { dhcp6Config.clear(); dhcp6ConfigPath.clear(); } else if (!dhcp6Config || dhcp6Config->path() != dhcp6ConfigPathTmp.path()) { dhcp6Config.clear(); dhcp6ConfigPath = dhcp6ConfigPathTmp.path(); } Q_EMIT q->dhcp6ConfigChanged(); } else if (property == QLatin1String("Driver")) { driver = value.toString(); Q_EMIT q->driverChanged(); } else if (property == QLatin1String("DriverVersion")) { driverVersion = value.toString(); Q_EMIT q->driverVersionChanged(); } else if (property == QLatin1String("FirmwareMissing")) { firmwareMissing = value.toBool(); Q_EMIT q->firmwareMissingChanged(); } else if (property == QLatin1String("FirmwareVersion")) { firmwareVersion = value.toString(); Q_EMIT q->firmwareVersionChanged(); } else if (property == QLatin1String("Interface")) { interfaceName = value.toString(); Q_EMIT q->interfaceNameChanged(); } else if (property == QLatin1String("Ip4Address")) { ipV4Address = QHostAddress(ntohl(value.toUInt())); Q_EMIT q->ipV4AddressChanged(); } else if (property == QLatin1String("Ip4Config")) { QDBusObjectPath ip4ConfigObjectPathTmp = value.value(); if (ip4ConfigObjectPathTmp.path().isNull() || ip4ConfigObjectPathTmp.path() == QLatin1String("/")) { ipV4ConfigPath.clear(); } else { ipV4ConfigPath = ip4ConfigObjectPathTmp.path(); } ipV4Config = IpConfig(); Q_EMIT q->ipV4ConfigChanged(); } else if (property == QLatin1String("Ip6Config")) { QDBusObjectPath ip6ConfigObjectPathTmp = value.value(); if (ip6ConfigObjectPathTmp.path().isNull() || ip6ConfigObjectPathTmp.path() == QLatin1String("/")) { ipV6ConfigPath.clear(); } else { ipV6ConfigPath = ip6ConfigObjectPathTmp.path(); } ipV6Config = IpConfig(); Q_EMIT q->ipV6ConfigChanged(); } else if (property == QLatin1String("IpInterface")) { ipInterface = value.toString(); Q_EMIT q->ipInterfaceChanged(); } else if (property == QLatin1String("Managed")) { managed = value.toBool(); Q_EMIT q->managedChanged(); } else if (property == QLatin1String("State")) { connectionState = NetworkManager::DevicePrivate::convertState(value.toUInt()); // FIXME NetworkManager 0.9.8 (maybe greater) doesn't // update ActiveConnection when disconnected // This is fixed in NM 73d128bbd17120225bb4986e3f05566f10fab581 if (connectionState == NetworkManager::Device::Disconnected && activeConnection != QLatin1String("/")) { activeConnection = QLatin1Char('/'); Q_EMIT q->activeConnectionChanged(); } Q_EMIT q->connectionStateChanged(); } else if (property == QLatin1String("StateReason")) { // just extracting the reason reason = NetworkManager::DevicePrivate::convertReason(qdbus_cast(value).reason); Q_EMIT q->stateReasonChanged(); } else if (property == QLatin1String("Udi")) { udi = value.toString(); Q_EMIT q->udiChanged(); } else if (property == QLatin1String("PhysicalPortId")) { physicalPortId = value.toString(); Q_EMIT q->physicalPortIdChanged(); } else if (property == QLatin1String("Mtu")) { mtu = value.toUInt(); Q_EMIT q->mtuChanged(); } else if (property == QLatin1String("NmPluginMissing")) { nmPluginMissing = value.toBool(); Q_EMIT q->nmPluginMissingChanged(nmPluginMissing); } else if (property == QLatin1String("Metered")) { metered = NetworkManager::DevicePrivate::convertMeteredStatus(value.toUInt()); Q_EMIT q->meteredChanged(metered); } else { qCDebug(NMQT) << Q_FUNC_INFO << "Unhandled property" << property; } } NetworkManager::Device::~Device() { Q_D(Device); delete d; } QString NetworkManager::Device::uni() const { Q_D(const Device); return d->uni; } QString NetworkManager::Device::interfaceName() const { Q_D(const Device); return d->interfaceName; } QString NetworkManager::Device::ipInterfaceName() const { Q_D(const Device); return d->ipInterface; } QString NetworkManager::Device::driver() const { Q_D(const Device); return d->driver; } QString NetworkManager::Device::driverVersion() const { Q_D(const Device); return d->driverVersion; } QString NetworkManager::Device::firmwareVersion() const { Q_D(const Device); return d->firmwareVersion; } NetworkManager::ActiveConnection::Ptr NetworkManager::Device::activeConnection() const { Q_D(const Device); return NetworkManager::findActiveConnection(d->activeConnection); } NetworkManager::Connection::List NetworkManager::Device::availableConnections() { Q_D(const Device); NetworkManager::Connection::List list; Q_FOREACH (const QString & availableConnection, d->availableConnections) { NetworkManager::Connection::Ptr connection = NetworkManager::findConnection(availableConnection); if (connection) { list << connection; } } return list; } bool NetworkManager::Device::firmwareMissing() const { Q_D(const Device); return d->firmwareMissing; } bool NetworkManager::Device::autoconnect() const { Q_D(const Device); return d->autoconnect; } void NetworkManager::Device::setAutoconnect(bool autoconnect) { Q_D(Device); d->deviceIface.setAutoconnect(autoconnect); } QString NetworkManager::Device::udi() const { Q_D(const Device); return d->udi; } QString NetworkManager::Device::physicalPortId() const { Q_D(const Device); return d->physicalPortId; } QHostAddress NetworkManager::Device::ipV4Address() const { Q_D(const Device); return d->ipV4Address; } NetworkManager::DeviceStateReason NetworkManager::Device::stateReason() const { Q_D(const Device); return DeviceStateReason(d->connectionState, d->reason); } NetworkManager::IpConfig NetworkManager::Device::ipV4Config() const { Q_D(const Device); if (!d->ipV4Config.isValid() && !d->ipV4ConfigPath.isNull()) { d->ipV4Config.setIPv4Path(d->ipV4ConfigPath); } return d->ipV4Config; } NetworkManager::IpConfig NetworkManager::Device::ipV6Config() const { Q_D(const Device); if (!d->ipV6Config.isValid() && !d->ipV6ConfigPath.isNull()) { d->ipV6Config.setIPv6Path(d->ipV6ConfigPath); } return d->ipV6Config; } NetworkManager::Dhcp4Config::Ptr NetworkManager::Device::dhcp4Config() const { Q_D(const Device); if (!d->dhcp4Config && !d->dhcp4ConfigPath.isNull()) { d->dhcp4Config = NetworkManager::Dhcp4Config::Ptr(new Dhcp4Config(d->dhcp4ConfigPath), &QObject::deleteLater); } return d->dhcp4Config; } NetworkManager::Dhcp6Config::Ptr NetworkManager::Device::dhcp6Config() const { Q_D(const Device); if (!d->dhcp6Config && !d->dhcp6ConfigPath.isNull()) { d->dhcp6Config = NetworkManager::Dhcp6Config::Ptr(new Dhcp6Config(d->dhcp6ConfigPath), &QObject::deleteLater); } return d->dhcp6Config; } bool NetworkManager::Device::isActive() const { Q_D(const Device); return !(d->connectionState == NetworkManager::Device::Unavailable || d->connectionState == NetworkManager::Device::Unmanaged || d->connectionState == NetworkManager::Device::Disconnected || d->connectionState == NetworkManager::Device::Failed); } bool NetworkManager::Device::isValid() const { Q_D(const Device); return d->deviceIface.isValid(); } bool NetworkManager::Device::managed() const { Q_D(const Device); return d->managed; } uint NetworkManager::Device::mtu() const { Q_D(const Device); return d->mtu; } bool NetworkManager::Device::nmPluginMissing() const { Q_D(const Device); return d->nmPluginMissing; } NetworkManager::Device::MeteredStatus NetworkManager::Device::metered() const { Q_D(const Device); return d->metered; } QDBusPendingReply<> NetworkManager::Device::reapplyConnection(const NMVariantMapMap &connection, qulonglong version_id, uint flags) { Q_D(Device); return d->deviceIface.Reapply(connection, version_id, flags); } QDBusPendingReply<> NetworkManager::Device::disconnectInterface() { Q_D(Device); return d->deviceIface.Disconnect(); } QDBusPendingReply<> NetworkManager::Device::deleteInterface() { if (NetworkManager::checkVersion(1, 0, 0)) { Q_D(Device); return d->deviceIface.Delete(); } else { return QDBusPendingReply<>(); } } NetworkManager::Device::State NetworkManager::Device::state() const { Q_D(const Device); return d->connectionState; } int NetworkManager::Device::designSpeed() const { Q_D(const Device); return d->designSpeed; } NetworkManager::Device::Capabilities NetworkManager::Device::capabilities() const { Q_D(const Device); return d->capabilities; } QVariant NetworkManager::Device::capabilitiesV() const { Q_D(const Device); return QVariant(d->capabilities); } NetworkManager::DeviceStatistics::Ptr NetworkManager::Device::deviceStatistics() const { Q_D(const Device); return d->deviceStatistics; } void NetworkManager::DevicePrivate::deviceStateChanged(uint newState, uint oldState, uint reason) { Q_Q(Device); connectionState = NetworkManager::DevicePrivate::convertState(newState); reason = NetworkManager::DevicePrivate::convertReason(reason); Q_EMIT q->stateChanged(connectionState, NetworkManager::DevicePrivate::convertState(oldState), NetworkManager::DevicePrivate::convertReason(reason)); } void NetworkManager::DevicePrivate::dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties) { Q_UNUSED(invalidatedProperties); if (interfaceName.contains(QLatin1String("org.freedesktop.NetworkManager.Device")) && interfaceName != QLatin1String("org.freedesktop.NetworkManager.Device.Statistics")) { propertiesChanged(properties); } } void NetworkManager::DevicePrivate::propertiesChanged(const QVariantMap &properties) { // qCDebug(NMQT) << Q_FUNC_INFO << properties; QVariantMap::const_iterator it = properties.constBegin(); while (it != properties.constEnd()) { propertyChanged(it.key(), it.value()); ++it; } // FIXME workaround, we need to get a path to updated IPv[46]Config, // because NM doesn't Q_EMIT the updated value when the device is activated // BUG: https://bugzilla.gnome.org/show_bug.cgi?id=725657 if (properties.contains(QLatin1String("State")) && connectionState == NetworkManager::Device::Activated) { propertyChanged(QLatin1String("Ip4Config"), QVariant::fromValue(deviceIface.ip4Config())); propertyChanged(QLatin1String("Ip6Config"), QVariant::fromValue(deviceIface.ip6Config())); } } NetworkManager::Device::Type NetworkManager::Device::type() const { Q_D(const Device); return d->deviceType; } diff --git a/src/device.h b/src/device.h index ae322bc..b0635e4 100644 --- a/src/device.h +++ b/src/device.h @@ -1,592 +1,578 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Daniel Nicoletti - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DEVICE_H #define NETWORKMANAGERQT_DEVICE_H #include #include #include #include "generictypes.h" #include "ipconfig.h" #include "dhcp4config.h" #include "dhcp6config.h" #include "activeconnection.h" #include "devicestatistics.h" namespace NetworkManager { class DevicePrivate; class DeviceStateReason; class DeviceStateReasonPrivate; /** * This class represents a common device interface */ class NETWORKMANAGERQT_EXPORT Device : public QObject { Q_OBJECT Q_PROPERTY(QString uni READ uni) Q_PROPERTY(QString interfaceName READ interfaceName) Q_PROPERTY(QString ipInterfaceName READ ipInterfaceName) Q_PROPERTY(QString driver READ driver) Q_PROPERTY(QString driverVersion READ driverVersion) Q_PROPERTY(QString firmwareVersion READ firmwareVersion) Q_PROPERTY(QVariant genericCapabilities READ capabilitiesV) Q_PROPERTY(QHostAddress ipV4Address READ ipV4Address) Q_PROPERTY(bool managed READ managed) Q_PROPERTY(uint mtu READ mtu) Q_PROPERTY(bool nmPluginMissing READ nmPluginMissing) Q_PROPERTY(MeteredStatus metered READ metered) Q_PROPERTY(QString udi READ udi) Q_PROPERTY(bool firmwareMissing READ firmwareMissing) Q_PROPERTY(bool autoconnect READ autoconnect WRITE setAutoconnect) Q_PROPERTY(DeviceStateReason stateReason READ stateReason) Q_PROPERTY(State state READ state) Q_PROPERTY(NetworkManager::DeviceStatistics::Ptr deviceStatistics READ deviceStatistics) public: typedef QSharedPointer Ptr; typedef QList List; /** * Device connection states describe the possible states of a * network connection from the user's point of view. For * simplicity, states from several different layers are present - * this is a high level view */ enum State { UnknownState = 0, /**< The device is in an unknown state */ Unmanaged = 10, /**< The device is recognized but not managed by NetworkManager */ Unavailable = 20, /**< The device cannot be used (carrier off, rfkill, etc) */ Disconnected = 30, /**< The device is not connected */ Preparing = 40, /**< The device is preparing to connect */ ConfiguringHardware = 50, /**< The device is being configured */ NeedAuth = 60, /**< The device is awaiting secrets necessary to continue connection */ ConfiguringIp = 70, /**< The IP settings of the device are being requested and configured */ CheckingIp = 80, /**< The device's IP connectivity ability is being determined */ WaitingForSecondaries = 90, /**< The device is waiting for secondary connections to be activated */ Activated = 100, /**< The device is active */ Deactivating = 110, /**< The device's network connection is being torn down */ Failed = 120 /**< The device is in a failure state following an attempt to activate it */ }; Q_ENUM(State) /** * Enums describing the reason for a connection state change * @note StateChangeReasons NewActivation, ParentChanged, ParentManagedChanged are available in runtime NM >= 1.0.4 */ enum StateChangeReason { UnknownReason = 0, NoReason = 1 , NowManagedReason = 2, NowUnmanagedReason = 3, ConfigFailedReason = 4, ConfigUnavailableReason = 5, ConfigExpiredReason = 6, NoSecretsReason = 7, AuthSupplicantDisconnectReason = 8, AuthSupplicantConfigFailedReason = 9, AuthSupplicantFailedReason = 10, AuthSupplicantTimeoutReason = 11, PppStartFailedReason = 12, PppDisconnectReason = 13, PppFailedReason = 14, DhcpStartFailedReason = 15, DhcpErrorReason = 16, DhcpFailedReason = 17, SharedStartFailedReason = 18, SharedFailedReason = 19, AutoIpStartFailedReason = 20, AutoIpErrorReason = 21, AutoIpFailedReason = 22, ModemBusyReason = 23, ModemNoDialToneReason = 24, ModemNoCarrierReason = 25, ModemDialTimeoutReason = 26, ModemDialFailedReason = 27, ModemInitFailedReason = 28, GsmApnSelectFailedReason = 29, GsmNotSearchingReason = 30, GsmRegistrationDeniedReason = 31, GsmRegistrationTimeoutReason = 32, GsmRegistrationFailedReason = 33, GsmPinCheckFailedReason = 34, FirmwareMissingReason = 35, DeviceRemovedReason = 36, SleepingReason = 37, ConnectionRemovedReason = 38, UserRequestedReason = 39, CarrierReason = 40, ConnectionAssumedReason = 41, SupplicantAvailableReason = 42, ModemNotFoundReason = 43, BluetoothFailedReason = 44, GsmSimNotInserted = 45, GsmSimPinRequired = 46, GsmSimPukRequired = 47, GsmSimWrong = 48 , InfiniBandMode = 49, DependencyFailed = 50, Br2684Failed = 51, ModemManagerUnavailable = 52, SsidNotFound = 53, SecondaryConnectionFailed = 54, DcbFcoeFailed = 55, TeamdControlFailed = 56, ModemFailed = 57, ModemAvailable = 58, SimPinIncorrect = 59, NewActivation = 60, ParentChanged = 61, ParentManagedChanged = 62, Reserved = 65536 }; Q_ENUM(StateChangeReason) enum MeteredStatus { UnknownStatus = 0, /**< The device metered status is unknown. */ Yes = 1, /**< The device is metered and the value was statically set. */ No = 2, /**< The device is not metered and the value was statically set. */ GuessYes = 3, /**< The device is metered and the value was guessed. */ GuessNo = 4 /**< The device is not metered and the value was guessed. */ }; Q_ENUM(MeteredStatus) /** * Possible device capabilities */ enum Capability { IsManageable = 0x1, /**< denotes that the device can be controlled by this API */ SupportsCarrierDetect = 0x2 /**< the device informs us when it is plugged in to the medium */ }; Q_ENUM(Capability) Q_DECLARE_FLAGS(Capabilities, Capability) Q_FLAG(Capabilities) /** * Device type */ enum Type { UnknownType = NM_DEVICE_TYPE_UNKNOWN, /**< Unknown device type */ Ethernet = NM_DEVICE_TYPE_ETHERNET, /**< Ieee8023 wired ethernet */ Wifi = NM_DEVICE_TYPE_WIFI, /**< the Ieee80211 family of wireless networks */ Unused1 = NM_DEVICE_TYPE_UNUSED1, /**< Currently unused */ Unused2 = NM_DEVICE_TYPE_UNUSED2, /**< Currently unused */ Bluetooth = NM_DEVICE_TYPE_BT, /**< network bluetooth device (usually a cell phone) */ OlpcMesh = NM_DEVICE_TYPE_OLPC_MESH, /**< OLPC Mesh networking device */ Wimax = NM_DEVICE_TYPE_WIMAX, /**< WiMax WWAN technology */ Modem = NM_DEVICE_TYPE_MODEM, /**< POTS, GSM, CDMA or LTE modems */ InfiniBand = NM_DEVICE_TYPE_INFINIBAND, /**< Infiniband network device */ Bond = NM_DEVICE_TYPE_BOND, /**< Bond virtual device */ Vlan = NM_DEVICE_TYPE_VLAN, /**< Vlan virtual device */ Adsl = NM_DEVICE_TYPE_ADSL, /**< ADSL modem device */ Bridge = NM_DEVICE_TYPE_BRIDGE, /**< Bridge virtual device */ Generic = NM_DEVICE_TYPE_GENERIC, /**< Generic device @since 1.0.0 */ Team = NM_DEVICE_TYPE_TEAM, /**< Team master device @since 1.0.0 */ Gre, /**< Gre virtual device @since 1.2.0, @deprecated use IpTunnel instead*/ MacVlan, /**< MacVlan virtual device @since 1.2.0 */ Tun, /**< Tun virtual device @since 1.2.0 */ Veth, /**< Veth virtual device @since 1.2.0 */ IpTunnel, /**< IP Tunneling Device @since 1.2.0 */ VxLan, /**< Vxlan Device @since 1.2.0 */ MacSec, /**< MacSec Device @since 1.6.0 */ Dummy, /**< Dummy Device @since 1.8.0 */ Ppp, /**< Ppp Device @since 1.10 */ OvsInterface, /**< OvsInterface Device @since 1.10 */ OvsPort, /**< OvsPort Device @since 1.10 */ OvsBridge, /**< OvsBridge Device @since 1.10 */ Wpan, /**< Wpan Device @since 1.14 */ Lowpan, /**< Lowpan Device @since 1.14 */ WireGuard, /**< WireGuard Device @since 1.14 */ WifiP2P /**< WifiP2P Device @since 1.16 */ }; Q_ENUM(Type) Q_DECLARE_FLAGS(Types, Type) Q_FLAG(Types) /** * Creates a new device object. * * @param path UNI of the device */ explicit Device(const QString &path, QObject *parent = nullptr); Device(DevicePrivate &dd, QObject *parent); /** * Destroys a device object. */ virtual ~Device(); /** * Retrieves the interface type. This is a virtual function that will return the * proper type of all sub-classes. * * @returns the NetworkManager::Device::Type that corresponds to this device. */ virtual Type type() const; /** * Retrieves the Unique Network Identifier (UNI) of the device. * This identifier is unique for each network and network interface in the system. * * @returns the Unique Network Identifier of the current device */ QString uni() const; /** * The current active connection for this device * * @returns A valid ActiveConnection object or NULL if no active connection was found */ NetworkManager::ActiveConnection::Ptr activeConnection() const; /** * Returns available connections for this device * * @returns List of availables connection */ Connection::List availableConnections(); /** * The system name for the network device */ QString interfaceName() const; /** * The name of the device's data interface when available. This property * may not refer to the actual data interface until the device has * successfully established a data connection, indicated by the device's * state() becoming ACTIVATED. */ QString ipInterfaceName() const; /** * Handle for the system driver controlling this network interface */ QString driver() const; /** * The driver version. */ QString driverVersion() const; /** * The firmware version. */ QString firmwareVersion() const; /** * Reapplies connection settings on the interface. */ QDBusPendingReply<> reapplyConnection(const NMVariantMapMap &connection, qulonglong version_id, uint flags); /** * Disconnects a device and prevents the device from automatically * activating further connections without user intervention. */ QDBusPendingReply<> disconnectInterface(); /** * Deletes a software device from NetworkManager and removes the interface from the system. * The method returns an error when called for a hardware device. * * @since 5.8.0 * */ QDBusPendingReply<> deleteInterface(); /** * returns the current IPv4 address without the prefix * \sa ipV4Config() * \sa ipV6Config() * @deprecated */ QHostAddress ipV4Address() const; /** * Get the current IPv4 configuration of this device. * Only valid when device is Activated. */ IpConfig ipV4Config() const; /** * Get the current IPv6 configuration of this device. * Only valid when device is Activated. */ IpConfig ipV6Config() const; /** * Get the DHCP options returned by the DHCP server * or a null pointer if the device is not Activated or does not * use DHCP configuration. */ Dhcp4Config::Ptr dhcp4Config() const; /** * Get the DHCP options returned by the DHCP server * or a null pointer if the device is not Activated or does not * use DHCP configuration. */ Dhcp6Config::Ptr dhcp6Config() const; /** * Retrieves the activation status of this network interface. * * @return true if this network interface is active, false otherwise */ bool isActive() const; /** * Retrieves the device is valid. * * @return true if this device interface is valid, false otherwise */ bool isValid() const; /** * Retrieves the current state of the device. * This is a high level view of the device. It is user oriented, so * actually it provides state coming from different layers. * * @return the current connection state * @see Device::State */ State state() const; /** * Retrieves the maximum speed as reported by the device. * Note that this is only a design related piece of information, and that * the device might not reach this maximum. * * @return the device's maximum speed */ int designSpeed() const; /** * Retrieves the capabilities supported by this device. * * @return the capabilities of the device */ Capabilities capabilities() const; QVariant capabilitiesV() const; /** * Is the device currently being managed by NetworkManager? */ bool managed() const; /** * Is the firmware needed by the device missing? */ bool firmwareMissing() const; /** * If the device is allowed to autoconnect. */ bool autoconnect() const; /** * The current state and reason for changing to that state. */ DeviceStateReason stateReason() const; /** * Retrieves the Unique Device Identifier (UDI) of the device. * This identifier is unique for each device in the system. */ QString udi() const; /** * @return If non-empty, an (opaque) indicator of the physical network * port associated with the device. This can be used to recognize * when two seemingly-separate hardware devices are actually just * different virtual interfaces to the same physical port. * * @since 0.9.9.0 */ QString physicalPortId() const; /** * The device MTU (maximum transmission unit) * @since 0.9.9.0 * */ uint mtu() const; /** * @return If TRUE, indicates the NetworkManager plugin for the device is likely * missing or misconfigured. * @since 5.14.0 */ bool nmPluginMissing() const; /** * @return Whether the amount of traffic flowing through the device is * subject to limitations, for example set by service providers. * @since 5.14.0 */ MeteredStatus metered() const; /** * If true, indicates the device is allowed to autoconnect. * If false, manual intervention is required before the device * will automatically connect to a known network, such as activating * a connection using the device, or setting this property to @p true. */ void setAutoconnect(bool autoconnect); /** * Returns Device Statistics interface */ DeviceStatistics::Ptr deviceStatistics() const; /** * Retrieves a specialized interface to interact with the device corresponding * to a given device interface. * * @returns a pointer to the device interface if it exists, @p 0 otherwise */ template DevIface *as() { return qobject_cast(this); } /** * Retrieves a specialized interface to interact with the device corresponding * to a given device interface. * * @returns a pointer to the device interface if it exists, 0 otherwise */ template const DevIface *as() const { return qobject_cast(this); } Q_SIGNALS: /** * This signal is emitted when the device's link status changed. * * @param newstate the new state of the connection * @param oldstate the previous state of the connection * @param reason the reason for the state change, if any. ReasonNone where the backend * provides no reason. * @see Device::State * @see Device::StateChangeReason */ void stateChanged(NetworkManager::Device::State newstate, NetworkManager::Device::State oldstate, NetworkManager::Device::StateChangeReason reason); /** * Emitted when the autoconnect of this network has changed. */ void activeConnectionChanged(); /** * Emitted when the autoconnect of this network has changed. */ void autoconnectChanged(); /** * Emitted when the list of avaiable connections of this network has changed. */ void availableConnectionChanged(); /** * Emitted when a new connection is available */ void availableConnectionAppeared(const QString &connection); /** * Emitted when the connection is no longer available */ void availableConnectionDisappeared(const QString &connection); /** * Emitted when the capabilities of this network has changed. */ void capabilitiesChanged(); /** * Emitted when the DHCP configuration for IPv4 of this network has changed. */ void dhcp4ConfigChanged(); /** * Emitted when the DHCP configuration for IPv6 of this network has changed. */ void dhcp6ConfigChanged(); /** * Emitted when the driver of this network has changed. */ void driverChanged(); /** * Emitted when the driver version of this network has changed. */ void driverVersionChanged(); /** * Emitted when the firmware missing state of this network has changed. */ void firmwareMissingChanged(); /** * Emitted when the firmware version of this network has changed. */ void firmwareVersionChanged(); /** * Emitted when the interface name of this network has changed. */ void interfaceNameChanged(); /** * Emitted when the IPv4 address of this network has changed. */ void ipV4AddressChanged(); /** * Emitted when the IPv4 configuration of this network has changed. */ void ipV4ConfigChanged(); /** * Emitted when the IPv6 configuration of this network has changed. */ void ipV6ConfigChanged(); /** * Emitted when the ip interface name of this network has changed. */ void ipInterfaceChanged(); /** * Emitted when the managed state of this network has changed. */ void managedChanged(); /** * Emitted when the physical port ID changes. * @see physicalPortId() * @since 0.9.9.0 */ void physicalPortIdChanged(); /** * Emitted when the maximum transmission unit has changed * @since 0.9.9.0 */ void mtuChanged(); /** * Emitted when NmPluginMissing property has changed * @since 5.14.0 * @see nmPluginMissing */ void nmPluginMissingChanged(bool nmPluginMissing); /** * Emitted when metered property has changed * @since 5.14.0 * @see metered */ void meteredChanged(MeteredStatus metered); /** * Emitted when the connection state of this network has changed. */ void connectionStateChanged(); /** * Emitted when the state reason of this network has changed. */ void stateReasonChanged(); /** * Emitted when the Unique Device Identifier of this device has changed. */ void udiChanged(); protected: DevicePrivate *const d_ptr; private: Q_DECLARE_PRIVATE(Device) }; Q_DECLARE_OPERATORS_FOR_FLAGS(Device::Capabilities) Q_DECLARE_OPERATORS_FOR_FLAGS(Device::Types) class NETWORKMANAGERQT_EXPORT DeviceStateReason { public: DeviceStateReason(Device::State state, Device::StateChangeReason reason); DeviceStateReason(const DeviceStateReason &); ~DeviceStateReason(); Device::State state() const; Device::StateChangeReason reason() const; DeviceStateReason &operator=(const DeviceStateReason &); private: Q_DECLARE_PRIVATE(DeviceStateReason) DeviceStateReasonPrivate *const d_ptr; }; } #endif diff --git a/src/device_p.h b/src/device_p.h index 994c48f..e1810f4 100644 --- a/src/device_p.h +++ b/src/device_p.h @@ -1,96 +1,82 @@ /* - Copyright 2008,2011 Will Stephenson + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DEVICE_P_H #define NETWORKMANAGERQT_DEVICE_P_H #include "dbus/deviceinterface.h" #include "device.h" namespace NetworkManager { class NetworkManagerPrivate; class DevicePrivate : public QObject { Q_OBJECT public: explicit DevicePrivate(const QString &path, Device *q); virtual ~DevicePrivate(); void init(); OrgFreedesktopNetworkManagerDeviceInterface deviceIface; Device::Capabilities capabilities; QString uni; QString udi; QString activeConnection; int designSpeed; Device::Type deviceType; Device::State connectionState; bool managed; mutable IpConfig ipV4Config; QString ipV4ConfigPath; mutable IpConfig ipV6Config; QString ipV6ConfigPath; QString driver; QHostAddress ipV4Address; QString interfaceName; QString ipInterface; bool firmwareMissing; mutable Dhcp4Config::Ptr dhcp4Config; QString dhcp4ConfigPath; mutable Dhcp6Config::Ptr dhcp6Config; QString dhcp6ConfigPath; QString driverVersion; QString firmwareVersion; QStringList availableConnections; bool autoconnect; Device::StateChangeReason reason; QString physicalPortId; uint mtu; bool nmPluginMissing; Device::MeteredStatus metered; DeviceStatistics::Ptr deviceStatistics; static NetworkManager::Device::MeteredStatus convertMeteredStatus(uint); static NetworkManager::Device::Capabilities convertCapabilities(uint); static NetworkManager::Device::State convertState(uint); static NetworkManager::Device::StateChangeReason convertReason(uint); static NetworkManager::Device::Type convertType(uint); Q_DECLARE_PUBLIC(Device) Device *q_ptr; public: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ virtual void propertyChanged(const QString &property, const QVariant &value); public Q_SLOTS: void deviceStateChanged(uint, uint, uint); void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); void propertiesChanged(const QVariantMap &properties); }; } // namespace NetworkManager #endif diff --git a/src/devicestatistics.cpp b/src/devicestatistics.cpp index eaf875d..77e550e 100644 --- a/src/devicestatistics.cpp +++ b/src/devicestatistics.cpp @@ -1,115 +1,101 @@ /* - Copyright 2017 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2017 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "devicestatistics_p.h" #include "manager_p.h" #include "nmdebug.h" NetworkManager::DeviceStatisticsPrivate::DeviceStatisticsPrivate(const QString &path, DeviceStatistics *q) #ifdef NMQT_STATIC : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , refreshRateMs(0) , rxBytes(0) , txBytes(0) , q_ptr(q) { uni = path; } NetworkManager::DeviceStatistics::DeviceStatistics(const QString &path, QObject *parent) : QObject(parent) , d_ptr(new DeviceStatisticsPrivate(path, this)) { Q_D(DeviceStatistics); // Refresh rate by default is 0, // as soon as the refresh rate is changed, we'll get the rest of properties initialised // Get all DeviceStatistics's properties at once QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::DeviceStatistics::~DeviceStatistics() { Q_D(DeviceStatistics); delete d; } uint NetworkManager::DeviceStatistics::refreshRateMs() const { Q_D(const DeviceStatistics); return d->refreshRateMs; } void NetworkManager::DeviceStatistics::setRefreshRateMs(uint refreshRate) { Q_D(DeviceStatistics); d->iface.setRefreshRateMs(refreshRate); } qulonglong NetworkManager::DeviceStatistics::rxBytes() const { Q_D(const DeviceStatistics); return d->rxBytes; } qulonglong NetworkManager::DeviceStatistics::txBytes() const { Q_D(const DeviceStatistics); return d->txBytes; } void NetworkManager::DeviceStatisticsPrivate::dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties) { Q_UNUSED(invalidatedProperties); if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.Device.Statistics")) { propertiesChanged(properties); } } void NetworkManager::DeviceStatisticsPrivate::propertiesChanged(const QVariantMap &properties) { Q_Q(DeviceStatistics); // qCDebug(NMQT) << Q_FUNC_INFO << properties; QVariantMap::const_iterator it = properties.constBegin(); while (it != properties.constEnd()) { const QString property = it.key(); if (property == QLatin1String("RefreshRateMs")) { refreshRateMs = it->toUInt(); Q_EMIT q->refreshRateMsChanged(refreshRateMs); } else if (property == QLatin1String("RxBytes")) { rxBytes = it->toULongLong(); Q_EMIT q->rxBytesChanged(rxBytes); } else if (property == QLatin1String("TxBytes")) { txBytes = it->toULongLong(); Q_EMIT q->txBytesChanged(txBytes); } else { qCWarning(NMQT) << Q_FUNC_INFO << "Unhandled property" << property; } ++it; } } diff --git a/src/devicestatistics.h b/src/devicestatistics.h index 20a3aa2..88b98c9 100644 --- a/src/devicestatistics.h +++ b/src/devicestatistics.h @@ -1,91 +1,77 @@ /* - Copyright 2017 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2017 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DEVICE_STATISTICS_H #define NETWORKMANAGERQT_DEVICE_STATISTICS_H #include #include #include #include namespace NetworkManager { class DeviceStatisticsPrivate; /** * Represents device statistics interface */ class NETWORKMANAGERQT_EXPORT DeviceStatistics : public QObject { Q_OBJECT Q_PROPERTY(uint refreshRateMs READ refreshRateMs WRITE setRefreshRateMs NOTIFY refreshRateMsChanged) Q_PROPERTY(qulonglong txBytes READ txBytes NOTIFY txBytesChanged) Q_PROPERTY(qulonglong rxBytes READ rxBytes NOTIFY rxBytesChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit DeviceStatistics(const QString &path, QObject *parent = nullptr); virtual ~DeviceStatistics(); /** * Refresh rate of the rest of properties of this interface. The properties are guaranteed to be refreshed * each RefreshRateMs milliseconds in case the underlying counter has changed too. If zero, there is no guaranteed * refresh rate of the properties. */ uint refreshRateMs() const; void setRefreshRateMs(uint refreshRate); /** * Number of received bytes */ qulonglong rxBytes() const; /** * Number of transmitted bytes */ qulonglong txBytes() const; Q_SIGNALS: /** * Emitted when the refresh rate has changed */ void refreshRateMsChanged(uint refreshRate); /** * Emitted when the received bytes has changed */ void rxBytesChanged(qulonglong rxBytes); /** * Emitted when the transmitted bytes has changed */ void txBytesChanged(qulonglong txBytes); private: Q_DECLARE_PRIVATE(DeviceStatistics) DeviceStatisticsPrivate *const d_ptr; }; } #endif diff --git a/src/devicestatistics_p.h b/src/devicestatistics_p.h index 225b6db..15246a5 100644 --- a/src/devicestatistics_p.h +++ b/src/devicestatistics_p.h @@ -1,51 +1,37 @@ /* - Copyright 2017 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2017 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DEVICE_STATISTICS_P_H #define NETWORKMANAGERQT_DEVICE_STATISTICS_P_H #include "devicestatistics.h" #include "dbus/devicestatisticsinterface.h" namespace NetworkManager { class DeviceStatisticsPrivate : public QObject { Q_OBJECT public: DeviceStatisticsPrivate(const QString &path, DeviceStatistics *q); OrgFreedesktopNetworkManagerDeviceStatisticsInterface iface; QString uni; uint refreshRateMs; qulonglong rxBytes; qulonglong txBytes; Q_DECLARE_PUBLIC(DeviceStatistics) DeviceStatistics *q_ptr; private Q_SLOTS: void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); void propertiesChanged(const QVariantMap &properties); }; } // namespace NetworkManager #endif // NETWORKMANAGERQT_DEVICE_STATISTICS_P_H diff --git a/src/dhcp4config.cpp b/src/dhcp4config.cpp index d98fe90..6efe5d6 100644 --- a/src/dhcp4config.cpp +++ b/src/dhcp4config.cpp @@ -1,103 +1,89 @@ /* - Copyright 2011 Lamarque V. Souza - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2011 Lamarque V. Souza + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "dhcp4config.h" #include "dhcp4config_p.h" #include "manager_p.h" #include "nmdebug.h" NetworkManager::Dhcp4ConfigPrivate::Dhcp4ConfigPrivate(const QString &path, Dhcp4Config *q) #ifdef NMQT_STATIC : dhcp4Iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else : dhcp4Iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , myPath(path) , q_ptr(q) { } NetworkManager::Dhcp4ConfigPrivate::~Dhcp4ConfigPrivate() { } NetworkManager::Dhcp4Config::Dhcp4Config(const QString &path, QObject *owner) : d_ptr(new Dhcp4ConfigPrivate(path, this)) { Q_D(Dhcp4Config); Q_UNUSED(owner); QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->myPath, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); d->options = d->dhcp4Iface.options(); } NetworkManager::Dhcp4Config::~Dhcp4Config() { delete d_ptr; } QString NetworkManager::Dhcp4Config::path() const { Q_D(const Dhcp4Config); return d->myPath; } QVariantMap NetworkManager::Dhcp4Config::options() const { Q_D(const Dhcp4Config); return d->options; } QString NetworkManager::Dhcp4Config::optionValue(const QString &key) const { Q_D(const Dhcp4Config); QString value; if (d->options.contains(key)) { value = d->options.value(key).toString(); } return value; } void NetworkManager::Dhcp4ConfigPrivate::dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties) { Q_UNUSED(invalidatedProperties); if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.DHCP4Config")) { dhcp4PropertiesChanged(properties); } } void NetworkManager::Dhcp4ConfigPrivate::dhcp4PropertiesChanged(const QVariantMap &properties) { Q_Q(Dhcp4Config); QVariantMap::const_iterator it = properties.constBegin(); while (it != properties.constEnd()) { const QString property = it.key(); if (property == QLatin1String("Options")) { options = it.value().toMap(); Q_EMIT q->optionsChanged(options); } else { qCWarning(NMQT) << Q_FUNC_INFO << "Unhandled property" << property; } ++it; } } diff --git a/src/dhcp4config.h b/src/dhcp4config.h index b5d10ff..88b1ca0 100644 --- a/src/dhcp4config.h +++ b/src/dhcp4config.h @@ -1,64 +1,50 @@ /* - Copyright 2011-2013 Lamarque V. Souza - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DHCP4CONFIG_H #define NETWORKMANAGERQT_DHCP4CONFIG_H #include "generictypes.h" #include #include namespace NetworkManager { class Dhcp4ConfigPrivate; /** * This class represents dhcp4 configuration */ class NETWORKMANAGERQT_EXPORT Dhcp4Config: public QObject { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; explicit Dhcp4Config(const QString &path, QObject *owner = nullptr); ~Dhcp4Config(); QString path() const; QVariantMap options() const; QString optionValue(const QString &key) const; Q_SIGNALS: void optionsChanged(const QVariantMap &); private: Q_DECLARE_PRIVATE(Dhcp4Config) Dhcp4ConfigPrivate *const d_ptr; }; } // namespace NetworkManager #endif // NETWORKMANAGERQT_DHCP4CONFIG_H diff --git a/src/dhcp4config_p.h b/src/dhcp4config_p.h index 8569aca..8c8685c 100644 --- a/src/dhcp4config_p.h +++ b/src/dhcp4config_p.h @@ -1,50 +1,36 @@ /* - Copyright 2011 Lamarque V. Souza - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Lamarque V. Souza + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DHCP4CONFIG_P_H #define NETWORKMANAGERQT_DHCP4CONFIG_P_H #include "dhcp4config.h" #include "dbus/dhcp4configinterface.h" namespace NetworkManager { class Dhcp4ConfigPrivate : public QObject { Q_OBJECT public: Dhcp4ConfigPrivate(const QString &path, Dhcp4Config *q); virtual ~Dhcp4ConfigPrivate(); OrgFreedesktopNetworkManagerDHCP4ConfigInterface dhcp4Iface; QString myPath; QVariantMap options; Q_DECLARE_PUBLIC(Dhcp4Config) Dhcp4Config *q_ptr; protected Q_SLOTS: void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); void dhcp4PropertiesChanged(const QVariantMap &); }; } // namespace NetworkManager #endif diff --git a/src/dhcp6config.cpp b/src/dhcp6config.cpp index 70ecb8c..037c451 100644 --- a/src/dhcp6config.cpp +++ b/src/dhcp6config.cpp @@ -1,104 +1,90 @@ /* - Copyright 2011 Lamarque V. Souza - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2011 Lamarque V. Souza + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "dhcp6config_p.h" #include "manager_p.h" #include "nmdebug.h" NetworkManager::Dhcp6ConfigPrivate::Dhcp6ConfigPrivate(const QString &path, Dhcp6Config *q) #ifdef NMQT_STATIC : dhcp6Iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else : dhcp6Iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , path(path) , q_ptr(q) { } NetworkManager::Dhcp6ConfigPrivate::~Dhcp6ConfigPrivate() { } NetworkManager::Dhcp6Config::Dhcp6Config(const QString &path, QObject *owner) : d_ptr(new Dhcp6ConfigPrivate(path, this)) { Q_D(Dhcp6Config); Q_UNUSED(owner); QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); d->options = d->dhcp6Iface.options(); } NetworkManager::Dhcp6Config::~Dhcp6Config() { delete d_ptr; } QString NetworkManager::Dhcp6Config::path() const { Q_D(const Dhcp6Config); return d->path; } QVariantMap NetworkManager::Dhcp6Config::options() const { Q_D(const Dhcp6Config); return d->options; } QString NetworkManager::Dhcp6Config::optionValue(const QString &key) const { Q_D(const Dhcp6Config); QString value; if (d->options.contains(key)) { value = d->options.value(key).toString(); } return value; } void NetworkManager::Dhcp6ConfigPrivate::dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties) { Q_UNUSED(invalidatedProperties); if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.DHCP6Config")) { dhcp6PropertiesChanged(properties); } } void NetworkManager::Dhcp6ConfigPrivate::dhcp6PropertiesChanged(const QVariantMap &properties) { Q_Q(Dhcp6Config); QVariantMap::const_iterator it = properties.constBegin(); while (it != properties.constEnd()) { const QString property = it.key(); if (property == QLatin1String("Options")) { options = it.value().toMap(); Q_EMIT q->optionsChanged(options); } else { qCWarning(NMQT) << Q_FUNC_INFO << "Unhandled property" << property; } ++it; } } diff --git a/src/dhcp6config.h b/src/dhcp6config.h index 436da55..f890566 100644 --- a/src/dhcp6config.h +++ b/src/dhcp6config.h @@ -1,64 +1,50 @@ /* - Copyright 2011-2013 Lamarque V. Souza - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DHCP6CONFIG_H #define NETWORKMANAGERQT_DHCP6CONFIG_H #include "generictypes.h" #include #include namespace NetworkManager { class Dhcp6ConfigPrivate; /** * This class represents dhcp4 configuration */ class NETWORKMANAGERQT_EXPORT Dhcp6Config: public QObject { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; explicit Dhcp6Config(const QString &path, QObject *owner = nullptr); ~Dhcp6Config(); QString path() const; QVariantMap options() const; QString optionValue(const QString &key) const; Q_SIGNALS: void optionsChanged(const QVariantMap &); private: Q_DECLARE_PRIVATE(Dhcp6Config) Dhcp6ConfigPrivate *const d_ptr; }; } // namespace NetworkManager #endif // NETWORKMANAGERQT_DHCP6CONFIG_H diff --git a/src/dhcp6config_p.h b/src/dhcp6config_p.h index e2edf0d..23bcf42 100644 --- a/src/dhcp6config_p.h +++ b/src/dhcp6config_p.h @@ -1,50 +1,36 @@ /* - Copyright 2011 Lamarque V. Souza - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Lamarque V. Souza + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DHCP6CONFIG_P_H #define NETWORKMANAGERQT_DHCP6CONFIG_P_H #include "dhcp6config.h" #include "dbus/dhcp6configinterface.h" namespace NetworkManager { class Dhcp6ConfigPrivate : public QObject { Q_OBJECT public: Dhcp6ConfigPrivate(const QString &path, Dhcp6Config *q); virtual ~Dhcp6ConfigPrivate(); OrgFreedesktopNetworkManagerDHCP6ConfigInterface dhcp6Iface; QString path; QVariantMap options; Q_DECLARE_PUBLIC(Dhcp6Config) Dhcp6Config *q_ptr; protected Q_SLOTS: void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); void dhcp6PropertiesChanged(const QVariantMap &); }; } // namespace NetworkManager #endif diff --git a/src/dnsconfiguration.cpp b/src/dnsconfiguration.cpp index 8cc9da2..6eff0d8 100644 --- a/src/dnsconfiguration.cpp +++ b/src/dnsconfiguration.cpp @@ -1,153 +1,139 @@ /* - Copyright 2018 Aleksander Morgado - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Aleksander Morgado + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ipconfig.h" #include #include "dnsconfiguration.h" namespace NetworkManager { class NetworkManager::DnsConfiguration::Private { public: Private(const QStringList &theSearches, const QStringList &theOptions, const QList theDomains) : searches(theSearches) , options(theOptions) , domains(theDomains) {} Private() {} QStringList searches; QStringList options; QList domains; }; } NetworkManager::DnsConfiguration::DnsConfiguration(const QStringList &searches, const QStringList &options, const QList domains) : d(new Private(searches, options, domains)) { } NetworkManager::DnsConfiguration::DnsConfiguration() : d(new Private()) { } NetworkManager::DnsConfiguration::DnsConfiguration(const DnsConfiguration &other) : d(new Private) { *this = other; } NetworkManager::DnsConfiguration::~DnsConfiguration() { delete d; } QStringList NetworkManager::DnsConfiguration::searches() const { return d->searches; } void NetworkManager::DnsConfiguration::setSearches(const QStringList &searches) { d->searches = searches; } QStringList NetworkManager::DnsConfiguration::options() const { return d->options; } void NetworkManager::DnsConfiguration::setOptions(const QStringList &options) { d->options = options; } QList NetworkManager::DnsConfiguration::domains() const { return d->domains; } void NetworkManager::DnsConfiguration::setDomains(const QList &domains) { d->domains = domains; } QVariantMap NetworkManager::DnsConfiguration::toMap() const { QVariantMap map; map["searches"] = d->searches; map["options"] = d->options; QVariantMap domains; Q_FOREACH (const NetworkManager::DnsDomain &domain, d->domains) { QVariantMap contents; QStringList serversList; Q_FOREACH (const QHostAddress &address, domain.servers()) serversList.append(address.toString()); contents["servers"] = serversList; contents["options"] = domain.options(); domains[domain.name()] = contents; } map["domains"] = domains; return map; } void NetworkManager::DnsConfiguration::fromMap (const QVariantMap &map) { d->searches = map["searches"].toStringList(); d->options = map["options"].toStringList(); d->domains = QList(); QVariantMap domains = map["domains"].toMap(); QVariantMap::const_iterator i = domains.constBegin(); while (i != domains.constEnd()) { QVariantMap contents = i.value().toMap(); QList addressList; Q_FOREACH (const QString &server, contents["servers"].toStringList()) addressList.append(QHostAddress(server)); NetworkManager::DnsDomain domain(i.key(), addressList, contents["options"].toStringList()); d->domains.append(domain); ++i; } } NetworkManager::DnsConfiguration &NetworkManager::DnsConfiguration::operator=(const DnsConfiguration &other) { if (this == &other) { return *this; } *d = *other.d; return *this; } diff --git a/src/dnsconfiguration.h b/src/dnsconfiguration.h index 6350a21..da6b659 100644 --- a/src/dnsconfiguration.h +++ b/src/dnsconfiguration.h @@ -1,119 +1,105 @@ /* - Copyright 2018 Aleksander Morgado - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Aleksander Morgado + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DNSCONFIGURATION_H #define NETWORKMANAGERQT_DNSCONFIGURATION_H #include #include "dnsdomain.h" // To prevent signals in glib2 be defined by QT #undef signals #include #include #define signals Q_SIGNALS #include namespace NetworkManager { /** * This class represents IP configuration */ class NETWORKMANAGERQT_EXPORT DnsConfiguration { public: /** * Constructs an initialized DnsConfiguration object */ DnsConfiguration(const QStringList &searches, const QStringList &options, const QList domains); /** * Constructs an empty DnsConfiguration object */ DnsConfiguration(); /** * Destroys this DnsConfiguration object. */ ~DnsConfiguration(); /** * Constructs a DnsConfiguration object that is a copy of the object @p other. */ DnsConfiguration(const DnsConfiguration &other); /** * Returns the list of search domains */ QStringList searches() const; /** * Sets the list of search domains */ void setSearches(const QStringList &list); /** * Returns the list of resolver options */ QStringList options() const; /** * Sets the list of resolver options */ void setOptions(const QStringList &list); /** * Returns the list of domains */ QList domains() const; /** * Sets the list of domains */ void setDomains(const QList &domains); /** * Marshall into a map */ QVariantMap toMap() const; /** * De-marshall from a map */ void fromMap (const QVariantMap &map); /** * Makes a copy of the DnsConfiguration object @p other. */ DnsConfiguration &operator=(const DnsConfiguration &other); private: class Private; Private *const d; }; } // namespace NetworkManager #endif // NETWORKMANAGERQT_DNSCONFIGURATION_H diff --git a/src/dnsdomain.cpp b/src/dnsdomain.cpp index 43a1c34..7ecea87 100644 --- a/src/dnsdomain.cpp +++ b/src/dnsdomain.cpp @@ -1,110 +1,96 @@ /* - Copyright 2018 Aleksander Morgado - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Aleksander Morgado + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ipconfig.h" #include #include "dnsdomain.h" namespace NetworkManager { class NetworkManager::DnsDomain::Private { public: Private(const QString &theName, const QList &theServers, const QStringList &theOptions) : name(theName) , servers(theServers) , options(theOptions) {} Private() {} QString name; QList servers; QStringList options; }; } NetworkManager::DnsDomain::DnsDomain(const QString &name, const QList &servers, const QStringList &options) : d(new Private(name, servers, options)) { } NetworkManager::DnsDomain::DnsDomain() : d(new Private()) { } NetworkManager::DnsDomain::DnsDomain(const DnsDomain &other) : d(new Private) { *this = other; } NetworkManager::DnsDomain::~DnsDomain() { delete d; } QString NetworkManager::DnsDomain::name() const { return d->name; } void NetworkManager::DnsDomain::setName(const QString &name) { d->name = name; } QList NetworkManager::DnsDomain::servers() const { return d->servers; } void NetworkManager::DnsDomain::setServers(const QList &servers) { d->servers = servers; } QStringList NetworkManager::DnsDomain::options() const { return d->options; } void NetworkManager::DnsDomain::setOptions(const QStringList &options) { d->options = options; } NetworkManager::DnsDomain &NetworkManager::DnsDomain::operator=(const DnsDomain &other) { if (this == &other) { return *this; } *d = *other.d; return *this; } diff --git a/src/dnsdomain.h b/src/dnsdomain.h index b66c4ba..6fa0964 100644 --- a/src/dnsdomain.h +++ b/src/dnsdomain.h @@ -1,110 +1,96 @@ /* - Copyright 2018 Aleksander Morgado - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Aleksander Morgado + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DNSDOMAIN_H #define NETWORKMANAGERQT_DNSDOMAIN_H #include #include "ipaddress.h" #include "iproute.h" // To prevent signals in glib2 be defined by QT #undef signals #include #include #define signals Q_SIGNALS #include namespace NetworkManager { /** * This class represents the configuration for a DNS domain */ class NETWORKMANAGERQT_EXPORT DnsDomain { public: /** * Constructs a DnsDomain object with a list of */ DnsDomain(const QString &name, const QList &servers, const QStringList &options); /** * Constructs a DnsDomain object */ DnsDomain(); /** * Destroys this DnsDomain object. */ ~DnsDomain(); /** * Constructs a DnsDomain object that is a copy of the object @p other. */ DnsDomain(const DnsDomain &other); /** * Returns the domain name */ QString name() const; /** * Sets the domain name */ void setName(const QString &name); /** * Returns the list of servers */ QList servers() const; /** * Sets the list of servers */ void setServers(const QList &list); /** * Returns the list of resolver options */ QStringList options() const; /** * Sets the list of resolver options */ void setOptions(const QStringList &list); /** * Makes a copy of the DnsDomain object @p other. */ DnsDomain &operator=(const DnsDomain &other); private: class Private; Private *const d; }; } // namespace NetworkManager #endif // NETWORKMANAGERQT_DNSDOMAIN_H diff --git a/src/fakenetwork/accesspoint.cpp b/src/fakenetwork/accesspoint.cpp index 2e88fd9..51988fe 100644 --- a/src/fakenetwork/accesspoint.cpp +++ b/src/fakenetwork/accesspoint.cpp @@ -1,137 +1,123 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "accesspoint.h" AccessPoint::AccessPoint(QObject *parent) : QObject(parent) , m_flags(0) , m_frequency(0) , m_maxBitrate(0) , m_mode(0) , m_rsnFlags(0) , m_strength(0) , m_wpaFlags(0) { } AccessPoint::~AccessPoint() { } uint AccessPoint::flags() const { return m_flags; } uint AccessPoint::frequency() const { return m_frequency; } QString AccessPoint::hwAddress() const { return m_hwAddress; } uint AccessPoint::maxBitrate() const { return m_maxBitrate; } uint AccessPoint::mode() const { return m_mode; } uint AccessPoint::rsnFlags() const { return m_rsnFlags; } QByteArray AccessPoint::ssid() const { return m_ssid; } uchar AccessPoint::strength() const { return m_strength; } uint AccessPoint::wpaFlags() const { return m_wpaFlags; } QString AccessPoint::accessPointPath() const { return m_apPath; } void AccessPoint::setAccessPointPath(const QString &path) { m_apPath = path; } void AccessPoint::setFlags(uint flags) { m_flags = flags; } void AccessPoint::setFrequency(uint frequency) { m_frequency = frequency; } void AccessPoint::setHwAddress(const QString &hwAddress) { m_hwAddress = hwAddress; } void AccessPoint::setMaxBitrate(uint bitrate) { m_maxBitrate = bitrate; } void AccessPoint::setMode(uint mode) { m_mode = mode; } void AccessPoint::setRsnFlags(uint flags) { m_rsnFlags = flags; } void AccessPoint::setSsid(const QByteArray &ssid) { m_ssid = ssid; } void AccessPoint::setStrength(uchar strength) { m_strength = strength; } void AccessPoint::setWpaFlags(uint flags) { m_wpaFlags = flags; } diff --git a/src/fakenetwork/accesspoint.h b/src/fakenetwork/accesspoint.h index 1b373b7..e471f36 100644 --- a/src/fakenetwork/accesspoint.h +++ b/src/fakenetwork/accesspoint.h @@ -1,87 +1,73 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_FAKE_NETWORK_ACCESS_POINT_H #define NETWORKMANAGERQT_FAKE_NETWORK_ACCESS_POINT_H #include #include #include "../generictypes.h" class AccessPoint : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.fakenetwork.AccessPoint") public: explicit AccessPoint(QObject *parent = nullptr); virtual ~AccessPoint(); Q_PROPERTY(uint Flags READ flags) Q_PROPERTY(uint Frequency READ frequency) Q_PROPERTY(QString HwAddress READ hwAddress) Q_PROPERTY(uint MaxBitrate READ maxBitrate) Q_PROPERTY(uint Mode READ mode) Q_PROPERTY(uint RsnFlags READ rsnFlags) Q_PROPERTY(QByteArray Ssid READ ssid) Q_PROPERTY(uchar Strength READ strength) Q_PROPERTY(uint WpaFlags READ wpaFlags) uint flags() const; uint frequency() const; QString hwAddress() const; uint maxBitrate() const; uint mode() const; uint rsnFlags() const; QByteArray ssid() const; uchar strength() const; uint wpaFlags() const; /* Not part of DBus interface */ QString accessPointPath() const; void setAccessPointPath(const QString &path); void setFlags(uint flags); void setFrequency(uint frequency); void setHwAddress(const QString &hwAddress); void setMaxBitrate(uint bitrate); void setMode(uint mode); void setRsnFlags(uint flags); void setSsid(const QByteArray &ssid); void setStrength(uchar strength); void setWpaFlags(uint flags); Q_SIGNALS: Q_SCRIPTABLE void PropertiesChanged(const QVariantMap &properties); private: QString m_apPath; uint m_flags; uint m_frequency; QString m_hwAddress; uint m_maxBitrate; uint m_mode; uint m_rsnFlags; QByteArray m_ssid; uchar m_strength; uint m_wpaFlags; }; #endif diff --git a/src/fakenetwork/activeconnection.cpp b/src/fakenetwork/activeconnection.cpp index e6a5cc0..970b4ab 100644 --- a/src/fakenetwork/activeconnection.cpp +++ b/src/fakenetwork/activeconnection.cpp @@ -1,216 +1,202 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "activeconnection.h" #include "connection.h" #include ActiveConnection::ActiveConnection(QObject *parent) : QObject(parent) , m_connection(QDBusObjectPath("/")) , m_default4(false) , m_default6(false) , m_dhcp4Config(QDBusObjectPath("/")) , m_dhcp6Config(QDBusObjectPath("/")) , m_ip4Config(QDBusObjectPath("/")) , m_ip6Config(QDBusObjectPath("/")) , m_master(QDBusObjectPath("/")) , m_specificObject(QDBusObjectPath("/")) , m_state(0) , m_vpn(false) { } ActiveConnection::~ActiveConnection() { } QDBusObjectPath ActiveConnection::connection() const { return m_connection; } bool ActiveConnection::default4() const { return m_default4; } bool ActiveConnection::default6() const { return m_default6; } QList< QDBusObjectPath > ActiveConnection::devices() const { return m_devices; } QDBusObjectPath ActiveConnection::dhcp4Config() const { return m_dhcp4Config; } QDBusObjectPath ActiveConnection::dhcp6Config() const { return m_dhcp6Config; } QString ActiveConnection::id() const { return m_id; } QDBusObjectPath ActiveConnection::ip4Config() const { return m_ip4Config; } QDBusObjectPath ActiveConnection::ip6Config() const { return m_ip6Config; } QDBusObjectPath ActiveConnection::master() const { return m_master; } QDBusObjectPath ActiveConnection::specificObject() const { return m_specificObject; } uint ActiveConnection::state() const { return m_state; } QString ActiveConnection::type() const { return m_type; } bool ActiveConnection::vpn() const { return m_vpn; } QString ActiveConnection::uuid() const { return m_uuid; } void ActiveConnection::addDevice(const QDBusObjectPath &device) { m_devices << device; } void ActiveConnection::removeDevice(const QDBusObjectPath &device) { m_devices.removeAll(device); } QString ActiveConnection::activeConnectionPath() const { return m_activeConnectionPath; } void ActiveConnection::setActiveConnectionPath(const QString &path) { m_activeConnectionPath = path; } void ActiveConnection::setConnection(const QDBusObjectPath &connection) { m_connection = connection; Connection *usedConnection = static_cast(QDBusConnection::sessionBus().objectRegisteredAt(connection.path())); if (usedConnection) { NMVariantMapMap settings = usedConnection->GetSettings(); setId(settings.value(QLatin1String("connection")).value(QLatin1String("id")).toString()); setUuid(settings.value(QLatin1String("connection")).value(QLatin1String("uuid")).toString()); setType(settings.value(QLatin1String("connection")).value(QLatin1String("type")).toString()); } } void ActiveConnection::setDefault4(bool default4) { m_default4 = default4; } void ActiveConnection::setDefault6(bool default6) { m_default6 = default6; } void ActiveConnection::setDhcp4Config(const QDBusObjectPath &dhcp4Config) { m_dhcp4Config = dhcp4Config; } void ActiveConnection::setDhcp6Config(const QDBusObjectPath &dhcp6Config) { m_dhcp6Config = dhcp6Config; } void ActiveConnection::setId(const QString &id) { m_id = id; } void ActiveConnection::setIpv4Config(const QDBusObjectPath &ipv4Config) { m_ip4Config = ipv4Config; } void ActiveConnection::setIpv6Config(const QDBusObjectPath &ipv6Config) { m_ip6Config = ipv6Config; } void ActiveConnection::setMaster(const QDBusObjectPath &master) { m_master = master; } void ActiveConnection::setSpecificObject(const QDBusObjectPath &specificObject) { m_specificObject = specificObject; } void ActiveConnection::setState(uint state) { m_state = state; } void ActiveConnection::setType(const QString &type) { m_type = type; if (type == QLatin1String("vpn")) { m_vpn = true; } } void ActiveConnection::setUuid(const QString &uuid) { m_uuid = uuid; } diff --git a/src/fakenetwork/activeconnection.h b/src/fakenetwork/activeconnection.h index 695ffec..c0427be 100644 --- a/src/fakenetwork/activeconnection.h +++ b/src/fakenetwork/activeconnection.h @@ -1,116 +1,102 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_FAKE_NETWORK_SETTINGS_ACTIVE_CONNECTION_H #define NETWORKMANAGERQT_FAKE_NETWORK_SETTINGS_ACTIVE_CONNECTION_H #include #include #include "../device.h" #include "device.h" class ActiveConnection : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.fakenetwork.Connection.Active") public: explicit ActiveConnection(QObject *parent = nullptr); virtual ~ActiveConnection(); Q_PROPERTY(QDBusObjectPath Connection READ connection) Q_PROPERTY(bool Default READ default4) Q_PROPERTY(bool Default6 READ default6) Q_PROPERTY(QList Devices READ devices) Q_PROPERTY(QDBusObjectPath Dhcp4Config READ dhcp4Config) Q_PROPERTY(QDBusObjectPath Dhcp6Config READ dhcp6Config) Q_PROPERTY(QDBusObjectPath Ip4Config READ ip4Config) Q_PROPERTY(QDBusObjectPath Ip6Config READ ip6Config) Q_PROPERTY(QDBusObjectPath Master READ master) Q_PROPERTY(QDBusObjectPath SpecificObject READ specificObject) Q_PROPERTY(uint State READ state) Q_PROPERTY(QString Id READ id) Q_PROPERTY(QString Uuid READ uuid) Q_PROPERTY(QString Type READ type) Q_PROPERTY(bool Vpn READ vpn) QDBusObjectPath connection() const; bool default4() const; bool default6() const; QList devices() const; QDBusObjectPath dhcp4Config() const; QDBusObjectPath dhcp6Config() const; QDBusObjectPath ip4Config() const; QDBusObjectPath ip6Config() const; QDBusObjectPath master() const; QDBusObjectPath specificObject() const; uint state() const; QString id() const; QString uuid() const; QString type() const; bool vpn() const; /* Not part of DBus interface */ void addDevice(const QDBusObjectPath &path); void removeDevice(const QDBusObjectPath &device); QString activeConnectionPath() const; void setActiveConnectionPath(const QString &path); void setConnection(const QDBusObjectPath &connection); void setDefault4(bool default4); void setDefault6(bool default6); void setDhcp4Config(const QDBusObjectPath &dhcp4Config); void setDhcp6Config(const QDBusObjectPath &dhcp6Config); void setIpv4Config(const QDBusObjectPath &ipv4Config); void setIpv6Config(const QDBusObjectPath &ipv6Config); void setMaster(const QDBusObjectPath &master); void setSpecificObject(const QDBusObjectPath &specificObject); void setState(uint state); void setId(const QString &id); void setUuid(const QString &uuid); void setType(const QString &type); Q_SIGNALS: Q_SCRIPTABLE void PropertiesChanged(const QVariantMap &properties); Q_SCRIPTABLE void StateChanged(uint state, uint reason); private: QDBusObjectPath m_connection; bool m_default4; bool m_default6; QList m_devices; QDBusObjectPath m_dhcp4Config; QDBusObjectPath m_dhcp6Config; QDBusObjectPath m_ip4Config; QDBusObjectPath m_ip6Config; QDBusObjectPath m_master; QDBusObjectPath m_specificObject; uint m_state; QString m_id; QString m_uuid; QString m_type; bool m_vpn; /* Not part of DBus interface */ QString m_activeConnectionPath; }; #endif diff --git a/src/fakenetwork/connection.cpp b/src/fakenetwork/connection.cpp index e2fdf4c..e206e56 100644 --- a/src/fakenetwork/connection.cpp +++ b/src/fakenetwork/connection.cpp @@ -1,90 +1,76 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "connection.h" #include Connection::Connection(QObject *parent, const NMVariantMapMap &settings) : QObject(parent) , m_unsaved(false) , m_settings(settings) { qDBusRegisterMetaType(); } Connection::~Connection() { } bool Connection::unsaved() const { return m_unsaved; } void Connection::Delete() { // From some reason signal Removed is not send over DBus when using only Q_EMIT QDBusMessage message = QDBusMessage::createSignal(m_connectionPath, QLatin1String("org.kde.fakenetwork.Settings.Connection"), QLatin1String("Removed")); QDBusConnection::sessionBus().send(message); // Q_EMIT Removed(); // Send it for FakeNetwork as well Q_EMIT connectionRemoved(QDBusObjectPath(m_connectionPath)); } NMVariantMapMap Connection::GetSecrets(const QString &setting_name) { // TODO return NMVariantMapMap(); } NMVariantMapMap Connection::GetSettings() { // TODO: return settings without secrets return m_settings; } void Connection::Save() { // TODO } void Connection::Update(const NMVariantMapMap &properties) { m_settings = properties; Q_EMIT Updated(); } void Connection::UpdateUnsaved(const NMVariantMapMap &properties) { // TODO } QString Connection::connectionPath() const { return m_connectionPath; } void Connection::setConnectionPath(const QString &path) { m_connectionPath = path; } diff --git a/src/fakenetwork/connection.h b/src/fakenetwork/connection.h index cf3f2c7..fda5247 100644 --- a/src/fakenetwork/connection.h +++ b/src/fakenetwork/connection.h @@ -1,68 +1,54 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_FAKE_NETWORK_SETTINGS_CONNECTION_H #define NETWORKMANAGERQT_FAKE_NETWORK_SETTINGS_CONNECTION_H #include #include #include "../generictypes.h" class Connection : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.fakenetwork.Settings.Connection") public: explicit Connection(QObject *parent = nullptr, const NMVariantMapMap &settings = NMVariantMapMap()); virtual ~Connection(); Q_PROPERTY(bool Unsaved READ unsaved) bool unsaved() const; /* Not part of DBus interface */ QString connectionPath() const; void setConnectionPath(const QString &path); public Q_SLOTS: // METHODS Q_SCRIPTABLE void Delete(); Q_SCRIPTABLE NMVariantMapMap GetSecrets(const QString &setting_name); Q_SCRIPTABLE NMVariantMapMap GetSettings(); Q_SCRIPTABLE void Save(); Q_SCRIPTABLE void Update(const NMVariantMapMap &properties); Q_SCRIPTABLE void UpdateUnsaved(const NMVariantMapMap &properties); Q_SIGNALS: void connectionRemoved(const QDBusObjectPath &path); Q_SCRIPTABLE void Removed(); Q_SCRIPTABLE void Updated(); Q_SCRIPTABLE void PropertiesChanged(const QVariantMap &properties); private: bool m_unsaved; NMVariantMapMap m_settings; /* Not part of DBus interface */ QString m_connectionPath; }; #endif diff --git a/src/fakenetwork/device.cpp b/src/fakenetwork/device.cpp index 7fce377..1bf50dd 100644 --- a/src/fakenetwork/device.cpp +++ b/src/fakenetwork/device.cpp @@ -1,295 +1,281 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "activeconnection.h" #include "device.h" #include #include Device::Device(QObject *parent) : QObject(parent) , m_activeConnection(QDBusObjectPath("/")) , m_autoconnect(true) , m_capabilities(0) , m_deviceType(0) , m_dhcp4Config(QDBusObjectPath("/")) , m_dhcp6Config(QDBusObjectPath("/")) , m_firmwareMissing(false) , m_ip4Address(0) , m_ip4Config(QDBusObjectPath("/")) , m_ip6Config(QDBusObjectPath("/")) , m_managed(true) , m_mtu(0) , m_state(30) { qDBusRegisterMetaType(); } Device::~Device() { } QDBusObjectPath Device::activeConnection() const { return m_activeConnection; } bool Device::autoconnect() const { return m_autoconnect; } void Device::setAutoconnect(bool autoconnect) { m_autoconnect = autoconnect; } QList< QDBusObjectPath > Device::availableConnections() const { return m_availableConnections; } uint Device::capabilities() const { return m_capabilities; } QString Device::deviceInterface() const { if (m_deviceType == NetworkManager::Device::Ethernet) { return QLatin1String("org.kde.fakenetwork.Device.Wired"); } else if (m_deviceType == NetworkManager::Device::Wifi) { return QLatin1String("org.kde.fakenetwork.Device.Wireless"); } return QLatin1String("org.kde.fakenetwork.Device.Wired"); } QString Device::devicePath() const { return m_devicePath; } void Device::setDevicePath(const QString &devicePath) { m_devicePath = devicePath; } uint Device::deviceType() const { return m_deviceType; } QDBusObjectPath Device::dhcp4Config() const { return m_dhcp4Config; } QDBusObjectPath Device::dhcp6Config() const { return m_dhcp6Config; } QString Device::driver() const { return m_driver; } QString Device::driverVersion() const { return m_driverVersion; } bool Device::firmwareMissing() const { return m_firmwareMissing; } QString Device::firmwareVersion() const { return m_firmwareVersion; } QString Device::interface() const { return m_interface; } int Device::ip4Address() const { return m_ip4Address; } QDBusObjectPath Device::ip4Config() const { return m_ip4Config; } QDBusObjectPath Device::ip6Config() const { return m_ip6Config; } QString Device::ipInterface() const { return m_ipInterface; } bool Device::managed() const { return m_managed; } uint Device::mtu() const { return m_mtu; } uint Device::state() const { return m_state; } DeviceDBusStateReason Device::stateReason() const { return m_stateReason; } QString Device::udi() const { return m_udi; } void Device::addAvailableConnection(const QDBusObjectPath &availableConnection) { m_availableConnections << availableConnection; } void Device::removeAvailableConnection(const QDBusObjectPath &availableConnection) { m_availableConnections.removeAll(availableConnection); } void Device::setActiveConnection(const QString &activeConnection) { m_activeConnection = QDBusObjectPath(activeConnection); } void Device::setCapabilities(uint capabilities) { m_capabilities = capabilities; } void Device::setDeviceType(uint deviceType) { m_deviceType = deviceType; } void Device::setDhcp4Config(const QString &config) { m_dhcp4Config = QDBusObjectPath(config); } void Device::setDhcp6Config(const QString &config) { m_dhcp6Config = QDBusObjectPath(config); } void Device::setDriver(const QString &driver) { m_driver = driver; } void Device::setDriverVersion(const QString &driverVersion) { m_driverVersion = driverVersion; } void Device::setFirmwareMissing(bool firmwareMissing) { m_firmwareMissing = firmwareMissing; } void Device::setFirmwareVersion(const QString &firmwareVersion) { m_firmwareVersion = firmwareVersion; } void Device::setInterface(const QString &interface) { m_interface = interface; } void Device::setIp4Config(const QString &config) { m_ip4Config = QDBusObjectPath(config); } void Device::setIp6Config(const QString &config) { m_ip6Config = QDBusObjectPath(config); } void Device::setIpv4Address(int address) { m_ip4Address = address; } void Device::setIpInterface(const QString &interface) { m_ipInterface = interface; } void Device::setManaged(bool managed) { m_managed = managed; } void Device::setMtu(uint mtu) { m_mtu = mtu; } void Device::setState(uint state) { uint previousState = m_state; m_state = state; m_stateReason.state = state; QDBusMessage message = QDBusMessage::createSignal(m_devicePath, QLatin1String("org.kde.fakenetwork.Device"), QLatin1String("StateChanged")); message << previousState << state << m_stateReason.reason; QDBusConnection::sessionBus().send(message); } void Device::setStateReason(const DeviceDBusStateReason &reason) { m_stateReason = reason; } void Device::setUdi(const QString &udi) { m_udi = udi; } void Device::Disconnect() { // TODO } diff --git a/src/fakenetwork/device.h b/src/fakenetwork/device.h index 7feeb8e..584b6e9 100644 --- a/src/fakenetwork/device.h +++ b/src/fakenetwork/device.h @@ -1,143 +1,129 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_FAKE_NETWORK_DEVICE_H #define NETWORKMANAGERQT_FAKE_NETWORK_DEVICE_H #include #include #include "../generictypes.h" #include "../device.h" class Device : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.fakenetwork.Device") public: explicit Device(QObject *parent = nullptr); virtual ~Device(); Q_PROPERTY(QDBusObjectPath ActiveConnection READ activeConnection) Q_PROPERTY(bool Autoconnect READ autoconnect WRITE setAutoconnect) Q_PROPERTY(QList AvailableConnections READ availableConnections) Q_PROPERTY(uint Capabilities READ capabilities) Q_PROPERTY(uint DeviceType READ deviceType) Q_PROPERTY(QDBusObjectPath Dhcp4Config READ dhcp4Config) Q_PROPERTY(QDBusObjectPath Dhcp6Config READ dhcp6Config) Q_PROPERTY(QString Driver READ driver) Q_PROPERTY(QString DriverVersion READ driverVersion) Q_PROPERTY(bool FirmwareMissing READ firmwareMissing) Q_PROPERTY(QString FirmwareVersion READ firmwareVersion) Q_PROPERTY(QString Interface READ interface) Q_PROPERTY(int Ip4Address READ ip4Address) Q_PROPERTY(QDBusObjectPath Ip4Config READ ip4Config) Q_PROPERTY(QDBusObjectPath Ip6Config READ ip6Config) Q_PROPERTY(QString IpInterface READ ipInterface) Q_PROPERTY(bool Managed READ managed) Q_PROPERTY(uint Mtu READ mtu) Q_PROPERTY(uint State READ state) Q_PROPERTY(DeviceDBusStateReason StateReason READ stateReason) Q_PROPERTY(QString Udi READ udi) QDBusObjectPath activeConnection() const; bool autoconnect() const; void setAutoconnect(bool autoconnect); QList availableConnections() const; uint capabilities() const; uint deviceType() const; QDBusObjectPath dhcp4Config() const; QDBusObjectPath dhcp6Config() const; QString driver() const; QString driverVersion() const; bool firmwareMissing() const; QString firmwareVersion() const; QString interface() const; int ip4Address() const; QDBusObjectPath ip4Config() const; QDBusObjectPath ip6Config() const; QString ipInterface() const; bool managed() const; uint mtu() const; uint state() const; DeviceDBusStateReason stateReason() const; QString udi() const; /* Not part of DBus interface */ void addAvailableConnection(const QDBusObjectPath &availableConnection); void removeAvailableConnection(const QDBusObjectPath &availableConnection); void setActiveConnection(const QString &activeConnection); void setCapabilities(uint capabilities); QString deviceInterface() const; QString devicePath() const; void setDevicePath(const QString &devicePath); void setDeviceType(uint deviceType); void setDhcp4Config(const QString &config); void setDhcp6Config(const QString &config); void setDriver(const QString &driver); void setDriverVersion(const QString &driverVersion); void setFirmwareMissing(bool firmwareMissing); void setFirmwareVersion(const QString &firmwareVersion); void setInterface(const QString &interface); void setIpv4Address(int address); void setIp4Config(const QString &config); void setIp6Config(const QString &config); void setIpInterface(const QString &interface); void setManaged(bool managed); void setMtu(uint mtu); virtual void setState(uint state); void setStateReason(const DeviceDBusStateReason &reason); void setUdi(const QString &udi); public Q_SLOTS: Q_SCRIPTABLE void Disconnect(); Q_SIGNALS: void activeConnectionRemoved(const QDBusObjectPath &activeConnection); Q_SCRIPTABLE void StateChanged(uint new_state, uint old_state, uint reason); private: QDBusObjectPath m_activeConnection; bool m_autoconnect; QList m_availableConnections; uint m_capabilities; QString m_devicePath; uint m_deviceType; QDBusObjectPath m_dhcp4Config; QDBusObjectPath m_dhcp6Config; QString m_driver; QString m_driverVersion; bool m_firmwareMissing; QString m_firmwareVersion; QString m_interface; int m_ip4Address; QDBusObjectPath m_ip4Config; QDBusObjectPath m_ip6Config; QString m_ipInterface; bool m_managed; uint m_mtu; QString m_physicalPortId; uint m_state; DeviceDBusStateReason m_stateReason; QString m_udi; }; #endif diff --git a/src/fakenetwork/fakenetwork.cpp b/src/fakenetwork/fakenetwork.cpp index 4d952a1..655140b 100644 --- a/src/fakenetwork/fakenetwork.cpp +++ b/src/fakenetwork/fakenetwork.cpp @@ -1,470 +1,456 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "connection.h" #include "fakenetwork.h" #include "wireddevice.h" #include "wirelessdevice.h" #include #include #include "connectionsettings.h" #include "../manager.h" FakeNetwork::FakeNetwork(QObject *parent) : QObject(parent) , m_activatingConnection(QDBusObjectPath("/")) , m_connectivity(NetworkManager::Connectivity::NoConnectivity) , m_networkingEnabled(true) , m_primaryConnection(QDBusObjectPath("/")) , m_state(20) , m_version(QLatin1String("0.9.10.0")) , m_wimaxEnabled(true) , m_wimaxHardwareEnabled(true) , m_wirelessEnabled(true) , m_wirelessHardwareEnabled(true) , m_wwanEnabled(true) , m_wwanHardwareEnabled(true) , m_activeConnectionsCounter(0) , m_deviceCounter(0) , m_settings(new Settings(this)) { registerService(); connect(m_settings, &Settings::connectionAdded, this, &FakeNetwork::onConnectionAdded); connect(m_settings, &Settings::connectionRemoved, this, &FakeNetwork::onConnectionRemoved); } FakeNetwork::~FakeNetwork() { unregisterService(); qDeleteAll(m_devices); delete m_settings; } QDBusObjectPath FakeNetwork::activatingConnection() const { return m_activatingConnection; } QList< QDBusObjectPath > FakeNetwork::activeConnections() const { return m_activeConnections.keys(); } uint FakeNetwork::connectivity() const { return m_connectivity; } QList< QDBusObjectPath > FakeNetwork::devices() const { return m_devices.keys(); } bool FakeNetwork::networkingEnabled() const { return m_networkingEnabled; } QDBusObjectPath FakeNetwork::primaryConnection() const { return m_primaryConnection; } uint FakeNetwork::state() const { return m_state; } QString FakeNetwork::version() const { return m_version; } bool FakeNetwork::wimaxEnabled() const { return m_wimaxEnabled; } void FakeNetwork::setWimaxEnabled(bool enabled) { m_wimaxEnabled = enabled; QVariantMap map; map.insert(QLatin1String("WimaxEnabled"), m_wimaxEnabled); Q_EMIT PropertiesChanged(map); } bool FakeNetwork::wimaxHardwareEnabled() const { return m_wimaxHardwareEnabled; } void FakeNetwork::setWimaxHardwareEnabled(bool enabled) { m_wimaxHardwareEnabled = enabled; QVariantMap map; map.insert(QLatin1String("WimaxHardwareEnabled"), m_wimaxHardwareEnabled); Q_EMIT PropertiesChanged(map); } bool FakeNetwork::wirelessEnabled() const { return m_wirelessEnabled; } void FakeNetwork::setWirelessEnabled(bool enabled) { m_wirelessEnabled = enabled; QVariantMap map; map.insert(QLatin1String("WirelessEnabled"), m_wirelessEnabled); Q_EMIT PropertiesChanged(map); } bool FakeNetwork::wirelessHardwareEnabled() const { return m_wirelessHardwareEnabled; } void FakeNetwork::setWirelessHardwareEnabled(bool enabled) { m_wirelessHardwareEnabled = enabled; QVariantMap map; map.insert(QLatin1String("WirelessHardwareEnabled"), m_wirelessHardwareEnabled); Q_EMIT PropertiesChanged(map); } bool FakeNetwork::wwanEnabled() const { return m_wwanEnabled; } void FakeNetwork::setWwanEnabled(bool enabled) { m_wwanEnabled = enabled; QVariantMap map; map.insert(QLatin1String("WwanEnabled"), m_wwanEnabled); Q_EMIT PropertiesChanged(map); } bool FakeNetwork::wwanHardwareEnabled() const { return m_wwanHardwareEnabled; } void FakeNetwork::addDevice(Device *device) { QString newDevicePath = QString("/org/kde/fakenetwork/Devices/") + QString::number(m_deviceCounter++); device->setDevicePath(newDevicePath); m_devices.insert(QDBusObjectPath(newDevicePath), device); QDBusConnection::sessionBus().registerObject(newDevicePath, device, QDBusConnection::ExportScriptableContents); Q_EMIT DeviceAdded(QDBusObjectPath(newDevicePath)); } void FakeNetwork::removeDevice(Device *device) { m_devices.remove(QDBusObjectPath(device->devicePath())); QDBusConnection::sessionBus().unregisterObject(device->devicePath()); Q_EMIT DeviceRemoved(QDBusObjectPath(device->devicePath())); } void FakeNetwork::registerService() { QDBusConnection::sessionBus().registerService(QLatin1String("org.kde.fakenetwork")); QDBusConnection::sessionBus().registerObject(QLatin1String("/org/kde/fakenetwork"), this, QDBusConnection::ExportScriptableContents); QDBusConnection::sessionBus().registerObject(QLatin1String("/org/kde/fakenetwork/Settings"), m_settings, QDBusConnection::ExportScriptableContents); Q_FOREACH (const QDBusObjectPath & devicePath, m_devices.keys()) { QDBusConnection::sessionBus().registerObject(devicePath.path(), m_devices.value(devicePath), QDBusConnection::ExportScriptableContents); Q_EMIT DeviceAdded(devicePath); } } void FakeNetwork::unregisterService() { Q_FOREACH (const QDBusObjectPath & devicePath, m_devices.keys()) { QDBusConnection::sessionBus().unregisterObject(devicePath.path()); Q_EMIT DeviceRemoved(devicePath); } QDBusConnection::sessionBus().unregisterObject(QLatin1String("/org/kde/fakenetwork/Settings")); QDBusConnection::sessionBus().unregisterObject(QLatin1String("/org/kde/fakenetwork")); QDBusConnection::sessionBus().unregisterService(QLatin1String("org.kde.fakenetwork")); } QDBusObjectPath FakeNetwork::ActivateConnection(const QDBusObjectPath &connection, const QDBusObjectPath &device, const QDBusObjectPath &specific_object) { QString newActiveConnectionPath = QString("/org/kde/fakenetwork/ActiveConnection/") + QString::number(m_activeConnectionsCounter++); ActiveConnection *newActiveConnection = new ActiveConnection(this); newActiveConnection->addDevice(device); newActiveConnection->setActiveConnectionPath(newActiveConnectionPath); newActiveConnection->setConnection(connection); newActiveConnection->setSpecificObject(specific_object); newActiveConnection->setState(NetworkManager::ActiveConnection::Activating); m_activeConnections.insert(QDBusObjectPath(newActiveConnectionPath), newActiveConnection); QDBusConnection::sessionBus().registerObject(newActiveConnectionPath, newActiveConnection, QDBusConnection::ExportScriptableContents); m_activatingConnection = QDBusObjectPath(newActiveConnectionPath); QVariantMap map; map.insert(QLatin1String("ActiveConnections"), QVariant::fromValue >(m_activeConnections.keys())); map.insert(QLatin1String("ActivatingConnection"), QVariant::fromValue(QDBusObjectPath(newActiveConnectionPath))); Q_EMIT PropertiesChanged(map); Device *usedDevice = static_cast(QDBusConnection::sessionBus().objectRegisteredAt(device.path())); if (usedDevice) { m_activatedDevice = usedDevice->devicePath(); // Start simulation of activation usedDevice->setActiveConnection(newActiveConnectionPath); usedDevice->setState(NetworkManager::Device::Preparing); QTimer::singleShot(100, this, SLOT(updateConnectingState())); } return QDBusObjectPath(newActiveConnectionPath); } void FakeNetwork::updateConnectingState() { QVariantMap deviceMap; Device *device = m_devices.value(QDBusObjectPath(m_activatedDevice)); if (device->state() == NetworkManager::Device::Preparing) { device->setState(NetworkManager::Device::ConfiguringHardware); } else if (device->state() == NetworkManager::Device::ConfiguringHardware) { device->setState(NetworkManager::Device::NeedAuth); } else if (device->state() == NetworkManager::Device::NeedAuth) { device->setState(NetworkManager::Device::ConfiguringIp); } else if (device->state() == NetworkManager::Device::ConfiguringIp) { device->setState(NetworkManager::Device::CheckingIp); } else if (device->state() == NetworkManager::Device::CheckingIp) { device->setState(NetworkManager::Device::Activated); ActiveConnection *activeConnection = static_cast(QDBusConnection::sessionBus().objectRegisteredAt(device->activeConnection().path())); if (activeConnection) { QVariantMap activeConnectionMap; activeConnectionMap.insert(QLatin1String("State"), NetworkManager::ActiveConnection::Activated); activeConnection->setState(NetworkManager::ActiveConnection::Activated); QDBusMessage message = QDBusMessage::createSignal(activeConnection->activeConnectionPath(), QLatin1String("org.kde.fakenetwork.Connection.Active"), QLatin1String("PropertiesChanged")); message << activeConnectionMap; QDBusConnection::sessionBus().send(message); QDBusMessage message2 = QDBusMessage::createSignal(activeConnection->activeConnectionPath(), QLatin1String("org.kde.fakenetwork.Connection.Active"), QLatin1String("StateChanged")); message2 << (uint)2 << (uint)1; // NM_ACTIVE_CONNECTION_STATE_ACTIVATED << NM_ACTIVE_CONNECTION_STATE_REASON_NONE QDBusConnection::sessionBus().send(message2); } // TODO: set dhcp4Config, dhcp6Config, ip4Config, ip6Config // IP Interface is usually same as interface device->setIpInterface(device->interface()); // Set some IP address device->setIpv4Address(1763189258); deviceMap.insert(QLatin1String("IpInterface"), device->ipInterface()); deviceMap.insert(QLatin1String("Ip4Address"), device->ip4Address()); deviceMap.insert(QLatin1String("ActiveConnection"), m_activatingConnection.path()); // Update FakeNetwork state, connectivity, primary connection m_connectivity = NetworkManager::Connectivity::Full; m_primaryConnection = m_activatingConnection; m_activatingConnection = QDBusObjectPath("/"); m_state = 70; QVariantMap networkMap; networkMap.insert(QLatin1String("ActivatingConnection"), QVariant::fromValue(m_activatingConnection)); networkMap.insert(QLatin1String("Connectivity"), NetworkManager::Connectivity::Full); networkMap.insert(QLatin1String("PrimaryConnection"), QVariant::fromValue(m_primaryConnection)); networkMap.insert(QLatin1String("State"), m_state); QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/org/kde/fakenetwork"), QLatin1String("org.kde.fakenetwork"), QLatin1String("PropertiesChanged")); message << networkMap; QDBusConnection::sessionBus().send(message); Q_EMIT StateChanged(m_state); } deviceMap.insert(QLatin1String("State"), device->state()); QDBusMessage message = QDBusMessage::createSignal(device->devicePath(), device->deviceInterface(), QLatin1String("PropertiesChanged")); message << deviceMap; QDBusConnection::sessionBus().send(message); if (device->state() != NetworkManager::Device::Activated) { QTimer::singleShot(100, this, SLOT(updateConnectingState())); } } uint FakeNetwork::CheckConnectivity() const { return m_connectivity; } void FakeNetwork::DeactivateConnection(const QDBusObjectPath &active_connection) { ActiveConnection *activeConnection = m_activeConnections.value(active_connection); if (activeConnection) { activeConnection->setState(NetworkManager::ActiveConnection::Deactivating); QVariantMap activeConnectionMap; activeConnectionMap.insert(QLatin1String("State"), NetworkManager::ActiveConnection::Deactivating); activeConnection->setState(NetworkManager::ActiveConnection::Activated); QDBusMessage message = QDBusMessage::createSignal(activeConnection->activeConnectionPath(), QLatin1String("org.kde.fakenetwork.Connection.Active"), QLatin1String("PropertiesChanged")); message << activeConnectionMap; QDBusConnection::sessionBus().send(message); QDBusMessage message2 = QDBusMessage::createSignal(activeConnection->activeConnectionPath(), QLatin1String("org.kde.fakenetwork.Connection.Active"), QLatin1String("StateChanged")); message2 << (uint)4 << (uint)2; // NM_ACTIVE_CONNECTION_STATE_DEACTIVATED << NM_ACTIVE_CONNECTION_STATE_REASON_USER_DISCONNECTED QDBusConnection::sessionBus().send(message2); Device *device = m_devices.value(activeConnection->devices().first()); if (device) { m_deactivatedDevice = device->devicePath(); device->setState(NetworkManager::Device::Deactivating); QTimer::singleShot(100, this, SLOT(updateDeactivatingState())); } // Update FakeNetwork state, connectivity, primary connection m_connectivity = NetworkManager::Connectivity::NoConnectivity; m_primaryConnection = QDBusObjectPath("/"); m_state = 20; QVariantMap networkMap; networkMap.insert(QLatin1String("Connectivity"), m_connectivity); networkMap.insert(QLatin1String("PrimaryConnection"), QVariant::fromValue(m_primaryConnection)); networkMap.insert(QLatin1String("State"), m_state); message = QDBusMessage::createSignal(QLatin1String("/org/kde/fakenetwork"), QLatin1String("org.kde.fakenetwork"), QLatin1String("PropertiesChanged")); message << networkMap; QDBusConnection::sessionBus().send(message); Q_EMIT StateChanged(m_state); } } void FakeNetwork::updateDeactivatingState() { QVariantMap deviceMap; Device *device = m_devices.value(QDBusObjectPath(m_deactivatedDevice)); ActiveConnection *activeConnection = static_cast(QDBusConnection::sessionBus().objectRegisteredAt(device->activeConnection().path())); if (activeConnection) { QVariantMap activeConnectionMap; activeConnectionMap.insert(QLatin1String("State"), NetworkManager::ActiveConnection::Deactivated); activeConnection->setState(NetworkManager::ActiveConnection::Activated); QDBusMessage message = QDBusMessage::createSignal(activeConnection->activeConnectionPath(), QLatin1String("org.kde.fakenetwork.Connection.Active"), QLatin1String("PropertiesChanged")); message << activeConnectionMap; QDBusConnection::sessionBus().send(message); QDBusMessage message2 = QDBusMessage::createSignal(activeConnection->activeConnectionPath(), QLatin1String("org.kde.fakenetwork.Connection.Active"), QLatin1String("StateChanged")); message2 << (uint)3 << (uint)2; // NM_ACTIVE_CONNECTION_STATE_DEACTIVATING << NM_ACTIVE_CONNECTION_STATE_REASON_USER_DISCONNECTED QDBusConnection::sessionBus().send(message2); removeActiveConnection(QDBusObjectPath(activeConnection->activeConnectionPath())); } device->setActiveConnection(QLatin1String("/")); device->setState(NetworkManager::Device::Disconnected); // TODO: set dhcp4Config, dhcp6Config, ip4Config, ip6Config // IP Interface is usually same as interface device->setIpInterface(""); // Set some IP address device->setIpv4Address(0); deviceMap.insert(QLatin1String("ActiveConnection"), device->activeConnection().path()); deviceMap.insert(QLatin1String("IpInterface"), device->ipInterface()); deviceMap.insert(QLatin1String("Ip4Address"), device->ip4Address()); deviceMap.insert(QLatin1String("State"), device->state()); QDBusMessage message = QDBusMessage::createSignal(device->devicePath(), device->deviceInterface(), QLatin1String("PropertiesChanged")); message << deviceMap; QDBusConnection::sessionBus().send(message); } QDBusObjectPath FakeNetwork::GetDeviceByIpIface(const QString &iface) { // TODO return QDBusObjectPath(); } QList< QDBusObjectPath > FakeNetwork::GetDevices() const { return m_devices.keys(); } void FakeNetwork::onConnectionAdded(const QDBusObjectPath &connection) { Connection *newConnection = static_cast(QDBusConnection::sessionBus().objectRegisteredAt(connection.path())); if (newConnection) { NMVariantMapMap settings = newConnection->GetSettings(); NetworkManager::ConnectionSettings::ConnectionType type = NetworkManager::ConnectionSettings::typeFromString(settings.value(QLatin1String("connection")).value(QLatin1String("type")).toString()); if (!m_devices.isEmpty()) { Device *selectedDevice = nullptr; Q_FOREACH (Device * device, m_devices.values()) { if (type == NetworkManager::ConnectionSettings::Wired && device->deviceType() == NetworkManager::Device::Ethernet) { selectedDevice = device; device->addAvailableConnection(connection); break; } else if (type == NetworkManager::ConnectionSettings::Wireless && device->deviceType() == NetworkManager::Device::Wifi) { selectedDevice = device; // TODO break; } } if (selectedDevice) { QVariantMap map; map.insert(QLatin1String("AvailableConnections"), QVariant::fromValue >(selectedDevice->availableConnections())); QDBusMessage message = QDBusMessage::createSignal(selectedDevice->devicePath(), selectedDevice->deviceInterface(), QLatin1String("PropertiesChanged")); message << map; QDBusConnection::sessionBus().send(message); } } } } void FakeNetwork::onConnectionRemoved(const QDBusObjectPath &connection) { Q_FOREACH (Device * device, m_devices.values()) { if (device && device->availableConnections().contains(connection)) { device->removeAvailableConnection(connection); QVariantMap map; map.insert(QLatin1String("AvailableConnections"), QVariant::fromValue >(device->availableConnections())); QDBusMessage message = QDBusMessage::createSignal(device->devicePath(), device->deviceInterface(), QLatin1String("PropertiesChanged")); message << map; QDBusConnection::sessionBus().send(message); } } } void FakeNetwork::removeActiveConnection(const QDBusObjectPath &activeConnection) { delete m_activeConnections.value(activeConnection); m_activeConnections.remove(activeConnection); QDBusConnection::sessionBus().unregisterObject(activeConnection.path()); QVariantMap map; map.insert(QLatin1String("ActiveConnections"), QVariant::fromValue >(m_activeConnections.keys())); Q_EMIT PropertiesChanged(map); } diff --git a/src/fakenetwork/fakenetwork.h b/src/fakenetwork/fakenetwork.h index aff3e53..8de5635 100644 --- a/src/fakenetwork/fakenetwork.h +++ b/src/fakenetwork/fakenetwork.h @@ -1,128 +1,114 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_FAKE_NETWORK_H #define NETWORKMANAGERQT_FAKE_NETWORK_H #include #include #include "../generictypes.h" #include "../device.h" #include "activeconnection.h" #include "device.h" #include "settings.h" class FakeNetwork : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.fakenetwork") public: explicit FakeNetwork(QObject *parent = nullptr); virtual ~FakeNetwork(); Q_PROPERTY(QDBusObjectPath ActivatingConnection READ activatingConnection) Q_PROPERTY(QList ActiveConnections READ activeConnections) Q_PROPERTY(uint Connectivity READ connectivity) Q_PROPERTY(QList Devices READ devices) Q_PROPERTY(bool NetworkingEnabled READ networkingEnabled) Q_PROPERTY(QDBusObjectPath PrimaryConnection READ primaryConnection) Q_PROPERTY(uint State READ state) Q_PROPERTY(QString Version READ version) Q_PROPERTY(bool WimaxEnabled READ wimaxEnabled WRITE setWimaxEnabled) Q_PROPERTY(bool WimaxHardwareEnabled READ wimaxHardwareEnabled) Q_PROPERTY(bool WirelessEnabled READ wirelessEnabled WRITE setWirelessEnabled) Q_PROPERTY(bool WirelessHardwareEnabled READ wirelessHardwareEnabled) Q_PROPERTY(bool WwanEnabled READ wwanEnabled WRITE setWwanEnabled) Q_PROPERTY(bool WwanHardwareEnabled READ wwanHardwareEnabled) QDBusObjectPath activatingConnection() const; QList activeConnections() const; uint connectivity() const; QList devices() const; bool networkingEnabled() const; QDBusObjectPath primaryConnection() const; uint state() const; QString version() const; bool wimaxEnabled() const; void setWimaxEnabled(bool enabled); bool wimaxHardwareEnabled() const; void setWimaxHardwareEnabled(bool enabled); bool wirelessEnabled() const; void setWirelessEnabled(bool enabled); bool wirelessHardwareEnabled() const; void setWirelessHardwareEnabled(bool enabled); bool wwanEnabled() const; void setWwanEnabled(bool enabled); bool wwanHardwareEnabled() const; /* Not part of DBus interface */ void addDevice(Device *device); void removeDevice(Device *device); void registerService(); void unregisterService(); private Q_SLOTS: void onConnectionAdded(const QDBusObjectPath &connection); void onConnectionRemoved(const QDBusObjectPath &connection); void removeActiveConnection(const QDBusObjectPath &activeConnection); void updateConnectingState(); void updateDeactivatingState(); public Q_SLOTS: Q_SCRIPTABLE QDBusObjectPath ActivateConnection(const QDBusObjectPath &connection, const QDBusObjectPath &device, const QDBusObjectPath &specific_object); Q_SCRIPTABLE uint CheckConnectivity() const; Q_SCRIPTABLE void DeactivateConnection(const QDBusObjectPath &active_connection); Q_SCRIPTABLE QDBusObjectPath GetDeviceByIpIface(const QString &iface); Q_SCRIPTABLE QList GetDevices() const; Q_SIGNALS: Q_SCRIPTABLE void DeviceAdded(const QDBusObjectPath &device_path); Q_SCRIPTABLE void DeviceRemoved(const QDBusObjectPath &device_path); Q_SCRIPTABLE void PropertiesChanged(const QVariantMap &properties); Q_SCRIPTABLE void StateChanged(uint state); private: QDBusObjectPath m_activatingConnection; QMap m_activeConnections; uint m_connectivity; QMap m_devices; bool m_networkingEnabled; QDBusObjectPath m_primaryConnection; uint m_state; QString m_version; bool m_wimaxEnabled; bool m_wimaxHardwareEnabled; bool m_wirelessEnabled; bool m_wirelessHardwareEnabled; bool m_wwanEnabled; bool m_wwanHardwareEnabled; /* Not part of DBus interface */ QString m_activatedDevice; QString m_deactivatedDevice; int m_activeConnectionsCounter; int m_deviceCounter; Settings *m_settings; }; #endif diff --git a/src/fakenetwork/settings.cpp b/src/fakenetwork/settings.cpp index c7d9ecd..6c7b4e7 100644 --- a/src/fakenetwork/settings.cpp +++ b/src/fakenetwork/settings.cpp @@ -1,110 +1,96 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "settings.h" #include Settings::Settings(QObject *parent) : QObject(parent) , m_canModify(true) , m_hostname(QLatin1String("fake-hostname")) , m_connectionCounter(0) { qDBusRegisterMetaType(); } Settings::~Settings() { Q_FOREACH (const QDBusObjectPath & connection, m_connections.keys()) { QDBusConnection::sessionBus().unregisterObject(connection.path()); Q_EMIT ConnectionRemoved(connection); } qDeleteAll(m_connections); } bool Settings::canModify() const { return m_canModify; } QList< QDBusObjectPath > Settings::connections() const { return m_connections.keys(); } QString Settings::hostname() const { return m_hostname; } QDBusObjectPath Settings::AddConnection(const NMVariantMapMap &connection) { Connection *newConnection = new Connection(this, connection); QString newConnectionPath = QString("/org/kde/fakenetwork/Settings/") + QString::number(m_connectionCounter++); newConnection->setConnectionPath(newConnectionPath); m_connections.insert(QDBusObjectPath(newConnectionPath), newConnection); QDBusConnection::sessionBus().registerObject(newConnectionPath, newConnection, QDBusConnection::ExportScriptableContents); connect(newConnection, &Connection::connectionRemoved, this, &Settings::onConnectionRemoved); Q_EMIT NewConnection(QDBusObjectPath(newConnectionPath)); // Send it for FakeNetwork separately to get AvailableConnections signal after NewConnection Q_EMIT connectionAdded(QDBusObjectPath(newConnectionPath)); return QDBusObjectPath(newConnectionPath); } QDBusObjectPath Settings::AddConnectionUnsaved(const NMVariantMapMap &connection) { // TODO return QDBusObjectPath(); } QDBusObjectPath Settings::GetConnectionByUuid(const QString &uuid) { // TODO return QDBusObjectPath(); } QList< QDBusObjectPath > Settings::ListConnections() { return m_connections.keys(); } void Settings::SaveHostname(const QString &hostname) { m_hostname = hostname; } void Settings::onConnectionRemoved(const QDBusObjectPath &connectionPath) { Connection *connection = m_connections.value(connectionPath); if (connection) { QDBusConnection::sessionBus().unregisterObject(connectionPath.path()); Q_EMIT ConnectionRemoved(connectionPath); // Send it for FakeNetwork separately to get AvailableConnections signal after ConnectionRemoved Q_EMIT connectionRemoved(connectionPath); m_connections.remove(QDBusObjectPath(connectionPath)); delete connection; } } diff --git a/src/fakenetwork/settings.h b/src/fakenetwork/settings.h index 3a33cdd..b4a8668 100644 --- a/src/fakenetwork/settings.h +++ b/src/fakenetwork/settings.h @@ -1,73 +1,59 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_FAKE_NETWORK_SETTINGS_H #define NETWORKMANAGERQT_FAKE_NETWORK_SETTINGS_H #include #include #include "../generictypes.h" #include "connection.h" class Settings : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.fakenetwork.Settings") public: explicit Settings(QObject *parent = nullptr); virtual ~Settings(); Q_PROPERTY(bool CanModify READ canModify) Q_PROPERTY(QList Connections READ connections) Q_PROPERTY(QString Hostname READ hostname) bool canModify() const; QList connections() const; QString hostname() const; private Q_SLOTS: void onConnectionRemoved(const QDBusObjectPath &connectionPath); public Q_SLOTS: // METHODS Q_SCRIPTABLE QDBusObjectPath AddConnection(const NMVariantMapMap &connection); Q_SCRIPTABLE QDBusObjectPath AddConnectionUnsaved(const NMVariantMapMap &connection); Q_SCRIPTABLE QDBusObjectPath GetConnectionByUuid(const QString &uuid); Q_SCRIPTABLE QList ListConnections(); Q_SCRIPTABLE void SaveHostname(const QString &hostname); Q_SIGNALS: void connectionAdded(const QDBusObjectPath &connection); void connectionRemoved(const QDBusObjectPath &connection); Q_SCRIPTABLE void ConnectionRemoved(const QDBusObjectPath &connection); Q_SCRIPTABLE void NewConnection(const QDBusObjectPath &connection); Q_SCRIPTABLE void PropertiesChanged(const QVariantMap &properties); private: bool m_canModify; QMap m_connections; QString m_hostname; /* Not part of DBus interface */ int m_connectionCounter; }; #endif diff --git a/src/fakenetwork/wireddevice.cpp b/src/fakenetwork/wireddevice.cpp index ecd99b5..c41c990 100644 --- a/src/fakenetwork/wireddevice.cpp +++ b/src/fakenetwork/wireddevice.cpp @@ -1,80 +1,66 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wireddevice.h" WiredDevice::WiredDevice(QObject *parent) : Device(parent) { } WiredDevice::~WiredDevice() { QVariantMap map; map.insert(QLatin1String("AvailableConnections"), QVariant::fromValue >(QList())); Q_EMIT PropertiesChanged(map); } bool WiredDevice::carrier() const { return m_carrier; } QString WiredDevice::hwAddress() const { return m_hwAddress; } QString WiredDevice::permHwAddress() const { return m_permHwAddress; } uint WiredDevice::speed() const { return m_speed; } void WiredDevice::setCarrier(bool carrier) { m_carrier = carrier; } void WiredDevice::setHwAddress(const QString &hwAddress) { m_hwAddress = hwAddress; } void WiredDevice::setPermanentHwAddress(const QString &permanentHwAddress) { m_permHwAddress = permanentHwAddress; } void WiredDevice::setSpeed(uint speed) { m_speed = speed; } void WiredDevice::setState(uint state) { Device::setState(state); // set speed } diff --git a/src/fakenetwork/wireddevice.h b/src/fakenetwork/wireddevice.h index 2da6e13..64d2b54 100644 --- a/src/fakenetwork/wireddevice.h +++ b/src/fakenetwork/wireddevice.h @@ -1,68 +1,54 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_FAKE_NETWORK_WIRED_DEVICE_H #define NETWORKMANAGERQT_FAKE_NETWORK_WIRED_DEVICE_H #include #include #include "../generictypes.h" #include "../device.h" #include "device.h" class WiredDevice : public Device { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.fakenetwork.Device.Wired") public: explicit WiredDevice(QObject *parent = nullptr); virtual ~WiredDevice(); Q_PROPERTY(bool Carrier READ carrier) Q_PROPERTY(QString HwAddress READ hwAddress) Q_PROPERTY(QString PermHwAddress READ permHwAddress) Q_PROPERTY(uint Speed READ speed) bool carrier() const; QString hwAddress() const; QString permHwAddress() const; uint speed() const; /* Not part of DBus interface */ void setCarrier(bool carrier); void setHwAddress(const QString &hwAddress); void setPermanentHwAddress(const QString &permanentHwAddress); void setSpeed(uint speed); void setState(uint state) override; Q_SIGNALS: Q_SCRIPTABLE void PropertiesChanged(const QVariantMap &properties); private: bool m_carrier; QString m_hwAddress; QString m_permHwAddress; uint m_speed; }; #endif diff --git a/src/fakenetwork/wirelessdevice.cpp b/src/fakenetwork/wirelessdevice.cpp index e910591..9e93e57 100644 --- a/src/fakenetwork/wirelessdevice.cpp +++ b/src/fakenetwork/wirelessdevice.cpp @@ -1,151 +1,137 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wirelessdevice.h" #include WirelessDevice::WirelessDevice(QObject *parent) : Device(parent) , m_activeAccessPoint(QDBusObjectPath("/")) , m_bitrate(0) , m_mode(2) , m_wirelessCapabilities(0) , m_accessPointCounter(0) { } WirelessDevice::~WirelessDevice() { Q_FOREACH (const QDBusObjectPath & ap, m_accessPoints.keys()) { QDBusConnection::sessionBus().unregisterObject(ap.path()); Q_EMIT AccessPointRemoved(ap); } qDeleteAll(m_accessPoints); QVariantMap map; map.insert(QLatin1String("AvailableConnections"), QVariant::fromValue >(QList())); Q_EMIT PropertiesChanged(map); } QList< QDBusObjectPath > WirelessDevice::accessPoints() const { return m_accessPoints.keys(); } QDBusObjectPath WirelessDevice::activeAccessPoint() const { return m_activeAccessPoint; } uint WirelessDevice::bitrate() const { return m_bitrate; } QString WirelessDevice::hwAddress() const { return m_hwAddress; } uint WirelessDevice::mode() const { return m_mode; } QString WirelessDevice::permHwAddress() const { return m_permHwAddress; } uint WirelessDevice::wirelessCapabilities() const { return m_wirelessCapabilities; } void WirelessDevice::addAccessPoint(AccessPoint *accessPoint) { QString newApPath = QString("/org/kde/fakenetwork/AccessPoints/") + QString::number(m_accessPointCounter++); accessPoint->setAccessPointPath(newApPath); m_accessPoints.insert(QDBusObjectPath(newApPath), accessPoint); QDBusConnection::sessionBus().registerObject(newApPath, accessPoint, QDBusConnection::ExportScriptableContents); Q_EMIT AccessPointAdded(QDBusObjectPath(newApPath)); } void WirelessDevice::removeAccessPoint(AccessPoint *accessPoint) { m_accessPoints.remove(QDBusObjectPath(accessPoint->accessPointPath())); Q_EMIT AccessPointRemoved(QDBusObjectPath(accessPoint->accessPointPath())); } void WirelessDevice::setActiveAccessPoint(const QString &activeAccessPoint) { m_activeAccessPoint = QDBusObjectPath(activeAccessPoint); } void WirelessDevice::setBitrate(uint bitrate) { m_bitrate = bitrate; } void WirelessDevice::setHwAddress(const QString &hwAddress) { m_hwAddress = hwAddress; } void WirelessDevice::setMode(uint mode) { m_mode = mode; } void WirelessDevice::setPermHwAddress(const QString &permHwAddress) { m_permHwAddress = permHwAddress; } void WirelessDevice::setState(uint state) { Device::setState(state); // TODO: set speed, etc. } void WirelessDevice::setWirelessCapabilities(uint capabilities) { m_wirelessCapabilities = capabilities; } QList< QDBusObjectPath > WirelessDevice::GetAccessPoints() { return m_accessPoints.keys(); } QList< QDBusObjectPath > WirelessDevice::GetAllAccessPoints() { return m_accessPoints.keys(); } void WirelessDevice::RequestScan(const QVariantMap &options) { Q_UNUSED(options); } diff --git a/src/fakenetwork/wirelessdevice.h b/src/fakenetwork/wirelessdevice.h index 3567550..a59a943 100644 --- a/src/fakenetwork/wirelessdevice.h +++ b/src/fakenetwork/wirelessdevice.h @@ -1,92 +1,78 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_FAKE_NETWORK_WIRELESS_DEVICE_H #define NETWORKMANAGERQT_FAKE_NETWORK_WIRELESS_DEVICE_H #include #include #include "../generictypes.h" #include "../device.h" #include "accesspoint.h" #include "device.h" class WirelessDevice : public Device { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.fakenetwork.Device.Wireless") public: explicit WirelessDevice(QObject *parent = nullptr); virtual ~WirelessDevice(); Q_PROPERTY(QList AccessPoints READ accessPoints) Q_PROPERTY(QDBusObjectPath ActiveAccessPoint READ activeAccessPoint) Q_PROPERTY(uint Bitrate READ bitrate) Q_PROPERTY(QString HwAddress READ hwAddress) Q_PROPERTY(uint Mode READ mode) Q_PROPERTY(QString PermHwAddress READ permHwAddress) Q_PROPERTY(uint WirelessCapabilities READ wirelessCapabilities) QList accessPoints() const; QDBusObjectPath activeAccessPoint() const; uint bitrate() const; QString hwAddress() const; uint mode() const; QString permHwAddress() const; uint wirelessCapabilities() const; /* Not part of DBus interface */ void addAccessPoint(AccessPoint *accessPoint); void removeAccessPoint(AccessPoint *accessPoint); void setActiveAccessPoint(const QString &activeAccessPoint); void setBitrate(uint bitrate); void setHwAddress(const QString &hwAddress); void setMode(uint mode); void setPermHwAddress(const QString &permHwAddress); void setState(uint state) override; void setWirelessCapabilities(uint capabilities); public Q_SLOTS: Q_SCRIPTABLE QList GetAccessPoints(); Q_SCRIPTABLE QList GetAllAccessPoints(); Q_SCRIPTABLE void RequestScan(const QVariantMap &options); Q_SIGNALS: Q_SCRIPTABLE void AccessPointAdded(const QDBusObjectPath &access_point); Q_SCRIPTABLE void AccessPointRemoved(const QDBusObjectPath &access_point); Q_SCRIPTABLE void PropertiesChanged(const QVariantMap &properties); private: QMap m_accessPoints; QDBusObjectPath m_activeAccessPoint; uint m_bitrate; QString m_hwAddress; uint m_mode; QString m_permHwAddress; uint m_wirelessCapabilities; /* Not part of DBus interface */ int m_accessPointCounter; }; #endif diff --git a/src/genericdevice.cpp b/src/genericdevice.cpp index edcc056..aa6780e 100644 --- a/src/genericdevice.cpp +++ b/src/genericdevice.cpp @@ -1,87 +1,73 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "genericdevice_p.h" #include "manager.h" #include "nmdebug.h" NetworkManager::GenericDevicePrivate::GenericDevicePrivate(const QString &path, GenericDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::GenericDevicePrivate::~GenericDevicePrivate() { } NetworkManager::GenericDevice::GenericDevice(const QString &path, QObject *parent) : Device(*new NetworkManager::GenericDevicePrivate(path, this), parent) { Q_D(GenericDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::GenericDevice::~GenericDevice() { } NetworkManager::Device::Type NetworkManager::GenericDevice::type() const { return NetworkManager::Device::Generic; } QString NetworkManager::GenericDevice::hardwareAddress() const { Q_D(const GenericDevice); return d->hwAddress; } QString NetworkManager::GenericDevice::typeDescription() const { Q_D(const GenericDevice); return d->typeDescription; } void NetworkManager::GenericDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(GenericDevice); if (property == QLatin1String("HwAddress")) { hwAddress = value.toString(); Q_EMIT q->hardwareAddressChanged(hwAddress); } else if (property == QLatin1String("TypeDescription")) { typeDescription = value.toString(); Q_EMIT q->permanentHardwareAddressChanged(typeDescription); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/genericdevice.h b/src/genericdevice.h index 0b60a6b..6adb168 100644 --- a/src/genericdevice.h +++ b/src/genericdevice.h @@ -1,77 +1,63 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_GENERICDEVICE_H #define NETWORKMANAGERQT_GENERICDEVICE_H #include #include "device.h" namespace NetworkManager { class GenericDevicePrivate; /** * A generic device interface */ class NETWORKMANAGERQT_EXPORT GenericDevice : public Device { Q_OBJECT Q_PROPERTY(QString hardwareAddress READ hardwareAddress) Q_PROPERTY(QString typeDescription READ typeDescription) public: typedef QSharedPointer Ptr; typedef QList List; explicit GenericDevice(const QString &path, QObject *parent = nullptr); ~GenericDevice() override; /** * Return the type */ Type type() const override; /** * Active hardware address of the device */ QString hardwareAddress() const; /** * A (non-localized) description of the interface type, if known. */ QString typeDescription() const; Q_SIGNALS: /** * Emitted when the hardware address of this device has changed */ void hardwareAddressChanged(const QString &hwAddress); /** * Emitted when the type description this device has changed */ void permanentHardwareAddressChanged(const QString &permHwAddress); private: Q_DECLARE_PRIVATE(GenericDevice) }; } #endif // NETWORKMANAGERQT_GENERICDEVICE_H diff --git a/src/genericdevice_p.h b/src/genericdevice_p.h index b470f61..0e4b508 100644 --- a/src/genericdevice_p.h +++ b/src/genericdevice_p.h @@ -1,54 +1,40 @@ /* - Copyright 2012-2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_GENERIC_DEVICE_P_H #define NETWORKMANAGERQT_GENERIC_DEVICE_P_H #include "device_p.h" #include "genericdevice.h" #include "manager_p.h" #include "genericdeviceinterface.h" namespace NetworkManager { class GenericDevicePrivate : public DevicePrivate { Q_OBJECT public: GenericDevicePrivate(const QString &path, GenericDevice *q); virtual ~GenericDevicePrivate(); OrgFreedesktopNetworkManagerDeviceGenericInterface iface; QString hwAddress; QString typeDescription; Q_DECLARE_PUBLIC(GenericDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/generictypes.cpp b/src/generictypes.cpp index 834dc79..ff0dc72 100644 --- a/src/generictypes.cpp +++ b/src/generictypes.cpp @@ -1,103 +1,89 @@ /* - Copyright 2011 Ilia Kats - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "generictypes.h" QDBusArgument &operator<<(QDBusArgument &argument, const IpV6DBusAddress &address) { argument.beginStructure(); argument << address.address << address.prefix << address.gateway; argument.endStructure(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, IpV6DBusAddress &address) { argument.beginStructure(); argument >> address.address >> address.prefix >> address.gateway; argument.endStructure(); return argument; } QDBusArgument &operator<<(QDBusArgument &argument, const IpV6DBusRoute &route) { argument.beginStructure(); argument << route.destination << route.prefix << route.nexthop << route.metric; argument.endStructure(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, IpV6DBusRoute &route) { argument.beginStructure(); argument >> route.destination >> route.prefix >> route.nexthop >> route.metric; argument.endStructure(); return argument; } QDBusArgument &operator<<(QDBusArgument &argument, const NMStringMap &mydict) { argument.beginMap(QVariant::String, QVariant::String); QMapIterator i(mydict); while (i.hasNext()) { i.next(); argument.beginMapEntry(); argument << i.key() << i.value(); argument.endMapEntry(); } argument.endMap(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, NMStringMap &mydict) { argument.beginMap(); mydict.clear(); while (!argument.atEnd()) { QString key; QString value; argument.beginMapEntry(); argument >> key >> value; argument.endMapEntry(); mydict.insert(key, value); } argument.endMap(); return argument; } QDBusArgument &operator<<(QDBusArgument &argument, const DeviceDBusStateReason &reason) { argument.beginStructure(); argument << reason.state << reason.reason; argument.endStructure(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, DeviceDBusStateReason &reason) { argument.beginStructure(); argument >> reason.state >> reason.reason; argument.endStructure(); return argument; } diff --git a/src/generictypes.h b/src/generictypes.h index 4dcb7d9..7edd489 100644 --- a/src/generictypes.h +++ b/src/generictypes.h @@ -1,90 +1,76 @@ /* This file is part of the KDE project - Copyright 2008 Will Stephenson - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008 Will Stephenson + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef GENERIC_TYPES_H #define GENERIC_TYPES_H #include #include #include typedef QList > UIntListList; Q_DECLARE_METATYPE(UIntListList) typedef QList UIntList; Q_DECLARE_METATYPE(UIntList) typedef QMap NMVariantMapMap; Q_DECLARE_METATYPE(NMVariantMapMap) typedef QList NMVariantMapList; Q_DECLARE_METATYPE(NMVariantMapList) typedef QMap NMStringMap; typedef QMapIterator NMStringMapIterator; Q_DECLARE_METATYPE(NMStringMap) NETWORKMANAGERQT_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const NMStringMap &mydict); NETWORKMANAGERQT_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, NMStringMap &mydict); typedef struct { QByteArray address; uint prefix; QByteArray gateway; } IpV6DBusAddress; Q_DECLARE_METATYPE(IpV6DBusAddress) typedef QList IpV6DBusAddressList; Q_DECLARE_METATYPE(IpV6DBusAddressList) NETWORKMANAGERQT_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const IpV6DBusAddress &address); NETWORKMANAGERQT_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, IpV6DBusAddress &address); typedef struct { QByteArray destination; uint prefix; QByteArray nexthop; uint metric; } IpV6DBusRoute; Q_DECLARE_METATYPE(IpV6DBusRoute) typedef QList IpV6DBusRouteList; Q_DECLARE_METATYPE(IpV6DBusRouteList) NETWORKMANAGERQT_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const IpV6DBusRoute &route); NETWORKMANAGERQT_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, IpV6DBusRoute &route); // ipv6 nameservers typedef QList IpV6DBusNameservers; Q_DECLARE_METATYPE(IpV6DBusNameservers) typedef struct { uint state; uint reason; } DeviceDBusStateReason; Q_DECLARE_METATYPE(DeviceDBusStateReason) NETWORKMANAGERQT_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const DeviceDBusStateReason &reason); NETWORKMANAGERQT_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, DeviceDBusStateReason &reason); #endif // GENERIC_TYPES_H diff --git a/src/gredevice.cpp b/src/gredevice.cpp index f9e6985..85abb83 100644 --- a/src/gredevice.cpp +++ b/src/gredevice.cpp @@ -1,160 +1,146 @@ /* - Copyright 2013 Lukáš Tinkl - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2013 Lukáš Tinkl + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "gredevice_p.h" #include "device_p.h" #include "manager.h" NetworkManager::GreDevicePrivate::GreDevicePrivate(const QString &path, GreDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::GreDevicePrivate::~GreDevicePrivate() { } NetworkManager::GreDevice::GreDevice(const QString &path, QObject *parent): Device(*new GreDevicePrivate(path, this), parent) { Q_D(GreDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::GreDevice::~GreDevice() { } NetworkManager::Device::Type NetworkManager::GreDevice::type() const { return NetworkManager::Device::Gre; } ushort NetworkManager::GreDevice::inputFlags() const { Q_D(const GreDevice); return d->inputFlags; } ushort NetworkManager::GreDevice::outputFlags() const { Q_D(const GreDevice); return d->outputFlags; } uint NetworkManager::GreDevice::inputKey() const { Q_D(const GreDevice); return d->inputKey; } uint NetworkManager::GreDevice::outputKey() const { Q_D(const GreDevice); return d->outputKey; } QString NetworkManager::GreDevice::localEnd() const { Q_D(const GreDevice); return d->localEnd; } QString NetworkManager::GreDevice::remoteEnd() const { Q_D(const GreDevice); return d->remoteEnd; } QString NetworkManager::GreDevice::parent() const { Q_D(const GreDevice); return d->parent; } bool NetworkManager::GreDevice::pathMtuDiscovery() const { Q_D(const GreDevice); return d->pathMtuDiscovery; } uchar NetworkManager::GreDevice::tos() const { Q_D(const GreDevice); return d->tos; } uchar NetworkManager::GreDevice::ttl() const { Q_D(const GreDevice); return d->ttl; } void NetworkManager::GreDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(GreDevice); if (property == QLatin1String("InputFlags")) { inputFlags = static_cast(value.toUInt()); Q_EMIT q->inputFlagsChanged(inputFlags); } else if (property == QLatin1String("OutputFlags")) { outputFlags = static_cast(value.toUInt()); Q_EMIT q->outputFlagsChanged(outputFlags); } else if (property == QLatin1String("InputKey")) { inputKey = value.toUInt(); Q_EMIT q->inputKeyChanged(inputKey); } else if (property == QLatin1String("OutputKey")) { outputKey = value.toUInt(); Q_EMIT q->outputKeyChanged(outputKey); } else if (property == QLatin1String("Local")) { localEnd = value.toString(); Q_EMIT q->localEndChanged(localEnd); } else if (property == QLatin1String("Remote")) { remoteEnd = value.toString(); Q_EMIT q->remoteEndChanged(remoteEnd); } else if (property == QLatin1String("Parent")) { parent = value.toString(); Q_EMIT q->parentChanged(parent); } else if (property == QLatin1String("PathMtuDiscovery")) { pathMtuDiscovery = value.toBool(); Q_EMIT q->pathMtuDiscoveryChanged(pathMtuDiscovery); } else if (property == QLatin1String("Tos")) { tos = static_cast(value.toUInt()); Q_EMIT q->tosChanged(tos); } else if (property == QLatin1String("Ttl")) { ttl = static_cast(value.toUInt()); Q_EMIT q->ttlChanged(ttl); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/gredevice.h b/src/gredevice.h index 862a5a6..21fd402 100644 --- a/src/gredevice.h +++ b/src/gredevice.h @@ -1,88 +1,74 @@ /* - Copyright 2013 Lukáš Tinkl - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2013 Lukáš Tinkl + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_GRE_DEVICE_H #define NETWORKMANAGERQT_GRE_DEVICE_H #include "device.h" #include namespace NetworkManager { class GreDevicePrivate; /** * A gre device interface * @deprecated renamed to IpTunnelDevice */ class NETWORKMANAGERQT_EXPORT GreDevice : public Device { Q_OBJECT Q_PROPERTY(ushort inputFlags READ inputFlags NOTIFY inputFlagsChanged) Q_PROPERTY(ushort outputFlags READ outputFlags NOTIFY outputFlagsChanged) Q_PROPERTY(uint inputKey READ inputKey NOTIFY inputKeyChanged) Q_PROPERTY(uint outputKey READ outputKey NOTIFY outputKeyChanged) Q_PROPERTY(QString localEnd READ localEnd NOTIFY localEndChanged) Q_PROPERTY(QString remoteEnd READ remoteEnd NOTIFY remoteEndChanged) Q_PROPERTY(QString parent READ parent NOTIFY parentChanged) Q_PROPERTY(bool pathMtuDiscovery READ pathMtuDiscovery NOTIFY pathMtuDiscoveryChanged) Q_PROPERTY(uchar tos READ tos NOTIFY tosChanged) Q_PROPERTY(uchar ttl READ ttl NOTIFY ttlChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit GreDevice(const QString &path, QObject *parent = nullptr); ~GreDevice() override; Type type() const override; ushort inputFlags() const; ushort outputFlags() const; uint inputKey() const; uint outputKey() const; QString localEnd() const; QString remoteEnd() const; QString parent() const; bool pathMtuDiscovery() const; uchar tos() const; uchar ttl() const; Q_SIGNALS: void inputFlagsChanged(ushort inputflags); void outputFlagsChanged(ushort outputFlags); void inputKeyChanged(uint inputKey); void outputKeyChanged(uint outputKey); void localEndChanged(const QString &localEnd); void remoteEndChanged(const QString &remoteEnd); void parentChanged(const QString &parent); void pathMtuDiscoveryChanged(bool pathMtuDiscovery); void tosChanged(uchar tos); void ttlChanged(uchar ttl); private: Q_DECLARE_PRIVATE(GreDevice) }; } #endif diff --git a/src/gredevice_p.h b/src/gredevice_p.h index 17c5a53..2823dd5 100644 --- a/src/gredevice_p.h +++ b/src/gredevice_p.h @@ -1,64 +1,50 @@ /* - Copyright 2012-2014 Jan Grulich + SPDX-FileCopyrightText: 2012-2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_GRE_DEVICE_P_H #define NETWORKMANAGERQT_GRE_DEVICE_P_H #include "gredevice.h" #include "device_p.h" #include "manager.h" #include "manager_p.h" #include "gredeviceinterface.h" namespace NetworkManager { class GreDevicePrivate : public DevicePrivate { Q_OBJECT public: GreDevicePrivate(const QString &path, GreDevice *q); virtual ~GreDevicePrivate(); OrgFreedesktopNetworkManagerDeviceGreInterface iface; ushort inputFlags; ushort outputFlags; uint inputKey; uint outputKey; QString localEnd; QString remoteEnd; QString parent; bool pathMtuDiscovery; uchar tos; uchar ttl; Q_DECLARE_PUBLIC(GreDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/infinibanddevice.cpp b/src/infinibanddevice.cpp index d9e8726..0e685b9 100644 --- a/src/infinibanddevice.cpp +++ b/src/infinibanddevice.cpp @@ -1,91 +1,77 @@ /* - Copyright 2013 Jan Grulich - Copyright 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Daniel Nicoletti - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "infinibanddevice_p.h" #include "device_p.h" #include "manager.h" NetworkManager::InfinibandDevicePrivate::InfinibandDevicePrivate(const QString &path, InfinibandDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , carrier(false) { } NetworkManager::InfinibandDevice::~InfinibandDevice() { } NetworkManager::InfinibandDevice::InfinibandDevice(const QString &path, QObject *parent) : Device(*new InfinibandDevicePrivate(path, this), parent) { Q_D(InfinibandDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::InfinibandDevicePrivate::~InfinibandDevicePrivate() { } NetworkManager::Device::Type NetworkManager::InfinibandDevice::type() const { return NetworkManager::Device::InfiniBand; } bool NetworkManager::InfinibandDevice::carrier() const { Q_D(const InfinibandDevice); return d->carrier; } QString NetworkManager::InfinibandDevice::hwAddress() const { Q_D(const InfinibandDevice); return d->hwAddress; } void NetworkManager::InfinibandDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(InfinibandDevice); if (property == QLatin1String("Carrier")) { carrier = value.toBool(); Q_EMIT q->carrierChanged(carrier); } else if (property == QLatin1String("HwAddress")) { hwAddress = value.toString(); Q_EMIT q->hwAddressChanged(hwAddress); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/infinibanddevice.h b/src/infinibanddevice.h index 47d046f..cda9b74 100644 --- a/src/infinibanddevice.h +++ b/src/infinibanddevice.h @@ -1,74 +1,60 @@ /* - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_INFINIBAND_DEVICE_H #define NETWORKMANAGERQT_INFINIBAND_DEVICE_H #include "device.h" #include namespace NetworkManager { class InfinibandDevicePrivate; /** * An infiniband device interface */ class NETWORKMANAGERQT_EXPORT InfinibandDevice : public Device { Q_OBJECT Q_PROPERTY(bool carrier READ carrier NOTIFY carrierChanged) Q_PROPERTY(QString hwAddress READ hwAddress NOTIFY hwAddressChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit InfinibandDevice(const QString &path, QObject *parent = nullptr); ~InfinibandDevice() override; Type type() const override; /** * Indicates whether the physical carrier is found */ bool carrier() const; /** * Hardware address of the device */ QString hwAddress() const; Q_SIGNALS: /** * Emitted when the carrier of this device has changed */ void carrierChanged(bool plugged); /** * Emitted when the hardware address of this device has changed */ void hwAddressChanged(const QString &address); private: Q_DECLARE_PRIVATE(InfinibandDevice) }; } #endif diff --git a/src/infinibanddevice_p.h b/src/infinibanddevice_p.h index 53e9ecf..a838a7e 100644 --- a/src/infinibanddevice_p.h +++ b/src/infinibanddevice_p.h @@ -1,55 +1,41 @@ /* - Copyright 2012-2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_INFINIBAND_DEVICE_P_H #define NETWORKMANAGERQT_INFINIBAND_DEVICE_P_H #include "device_p.h" #include "infinibanddevice.h" #include "manager_p.h" #include "infinibanddeviceinterface.h" namespace NetworkManager { class InfinibandDevicePrivate : public DevicePrivate { Q_OBJECT public: InfinibandDevicePrivate(const QString &path, InfinibandDevice *q); virtual ~InfinibandDevicePrivate(); OrgFreedesktopNetworkManagerDeviceInfinibandInterface iface; bool carrier; QString hwAddress; Q_DECLARE_PUBLIC(InfinibandDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/ipaddress.cpp b/src/ipaddress.cpp index d7c33d8..2f75a1c 100644 --- a/src/ipaddress.cpp +++ b/src/ipaddress.cpp @@ -1,77 +1,63 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Daniel Nicoletti - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ipaddress.h" namespace NetworkManager { class IpAddress::Private { public: QHostAddress gateway; }; } NetworkManager::IpAddress::IpAddress() : d(new Private) { } NetworkManager::IpAddress::~IpAddress() { delete d; } NetworkManager::IpAddress::IpAddress(const NetworkManager::IpAddress &other) : QNetworkAddressEntry(other) , d(new Private) { *this = other; } bool NetworkManager::IpAddress::isValid() const { return !ip().isNull(); } void NetworkManager::IpAddress::setGateway(const QHostAddress &gateway) { d->gateway = gateway; } QHostAddress NetworkManager::IpAddress::gateway() const { return d->gateway; } NetworkManager::IpAddress &NetworkManager::IpAddress::operator=(const NetworkManager::IpAddress &other) { if (this == &other) { return *this; } QNetworkAddressEntry::operator =(other); *d = *other.d; return *this; } diff --git a/src/ipaddress.h b/src/ipaddress.h index ce7b589..ee47e4b 100644 --- a/src/ipaddress.h +++ b/src/ipaddress.h @@ -1,81 +1,67 @@ /* - * Copyright 2008,2011 Will Stephenson - * Copyright 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Daniel Nicoletti - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPADDRESS_H #define NETWORKMANAGERQT_IPADDRESS_H #include #include namespace NetworkManager { /** * This class represents IP address */ class NETWORKMANAGERQT_EXPORT IpAddress : public QNetworkAddressEntry { public: /** * Constructs an empty IpAddress object. */ IpAddress(); /** * Constructs an IpAddress object that is a copy of the object other. */ IpAddress(const IpAddress &other); /** * Destroys this IpAddress object. */ ~IpAddress(); /** * Return if the IP address is defined. */ bool isValid() const; /** * Defines the default @p gateway of this object. */ void setGateway(const QHostAddress &gateway); /** * Returns the default gateway of this object. */ QHostAddress gateway() const; /** * Makes a copy of the IpAddress object @p other. */ IpAddress &operator=(const IpAddress &other); private: class Private; Private *const d; }; typedef QList IpAddresses; } // namespace NetworkManager #endif // NETWORKMANAGERQT_IPADDRESS_H diff --git a/src/ipconfig.cpp b/src/ipconfig.cpp index 170c2a2..c84d8ae 100644 --- a/src/ipconfig.cpp +++ b/src/ipconfig.cpp @@ -1,321 +1,307 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ipconfig.h" #include "manager.h" #include "manager_p.h" #include #include "dbus/ip4configinterface.h" #include "dbus/ip6configinterface.h" namespace NetworkManager { class NetworkManager::IpConfig::Private { public: Private(const QList &theAddresses, const QList &theNameservers, const QStringList &theDomains, const QList &theRoutes) : addresses(theAddresses) , nameservers(theNameservers) , domains(theDomains) , routes(theRoutes) {} Private() {} IpAddresses addresses; QString gateway; QStringList searches; QList nameservers; QStringList domains; IpRoutes routes; QStringList dnsOptions; }; } NetworkManager::IpConfig::IpConfig(const IpAddresses &addresses, const QList &nameservers, const QStringList &domains, const IpRoutes &routes) : d(new Private(addresses, nameservers, domains, routes)) { } NetworkManager::IpConfig::IpConfig() : d(new Private()) { } NetworkManager::IpConfig::IpConfig(const IpConfig &other) : d(new Private) { *this = other; } void NetworkManager::IpConfig::setIPv4Path(const QString &path) { OrgFreedesktopNetworkManagerIP4ConfigInterface iface(NetworkManagerPrivate::DBUS_SERVICE, path, #ifdef NMQT_STATIC QDBusConnection::sessionBus()); #else QDBusConnection::systemBus()); #endif // TODO - watch propertiesChanged signal QList addressObjects; QList routeObjects; if (NetworkManager::checkVersion(1, 0, 0)) { NMVariantMapList addresses = iface.addressData(); Q_FOREACH (const QVariantMap &addressList, addresses) { if (addressList.contains(QLatin1String("address")) && addressList.contains(QLatin1String("prefix"))) { NetworkManager::IpAddress address; address.setIp(QHostAddress(addressList.value(QLatin1String("address")).toString())); address.setPrefixLength(addressList.value(QLatin1String("prefix")).toUInt()); if (addressList.contains(QLatin1String("gateway"))) { address.setGateway(QHostAddress(addressList.value(QLatin1String("gateway")).toString())); } addressObjects << address; } } NMVariantMapList routes = iface.routeData(); Q_FOREACH (const QVariantMap &routeList, routes) { if (routeList.contains(QLatin1String("address")) && routeList.contains(QLatin1String("prefix"))) { NetworkManager::IpRoute route; route.setIp(QHostAddress(routeList.value(QLatin1String("address")).toString())); route.setPrefixLength(routeList.value(QLatin1String("prefix")).toUInt()); if (routeList.contains(QLatin1String("next-hop"))) { route.setNextHop(QHostAddress(routeList.value(QLatin1String("next-hop")).toString())); } if (routeList.contains(QLatin1String("metric"))) { route.setMetric(routeList.value(QLatin1String("metric")).toUInt()); } routeObjects << route; } } } else { //convert ipaddresses into object UIntListList addresses = iface.addresses(); Q_FOREACH (const UIntList & addressList, addresses) { if (addressList.count() == 3) { NetworkManager::IpAddress address; address.setIp(QHostAddress(ntohl(addressList[0]))); address.setPrefixLength(addressList[1]); address.setGateway(QHostAddress(ntohl(addressList[2]))); addressObjects << address; } } //convert routes into objects UIntListList routes = iface.routes(); Q_FOREACH (const UIntList & routeList, routes) { if (routeList.count() == 4) { NetworkManager::IpRoute route; route.setIp(QHostAddress(ntohl(routeList[0]))); route.setPrefixLength(routeList[1]); route.setNextHop(QHostAddress(ntohl(routeList[2]))); route.setMetric(ntohl(routeList[3])); routeObjects << route; } } } // nameservers' IP addresses are always in network byte order QList nameservers; Q_FOREACH (uint nameserver, iface.nameservers()) { nameservers << QHostAddress(ntohl(nameserver)); } d->addresses = addressObjects; d->routes = routeObjects; d->nameservers = nameservers; d->gateway = iface.gateway(); d->searches = iface.searches(); d->domains = iface.domains(); if (NetworkManager::checkVersion(1, 2, 0)) { d->dnsOptions = iface.dnsOptions(); } } void NetworkManager::IpConfig::setIPv6Path(const QString &path) { // ask the daemon for the details OrgFreedesktopNetworkManagerIP6ConfigInterface iface(NetworkManagerPrivate::DBUS_SERVICE, path, #ifdef NMQT_STATIC QDBusConnection::sessionBus()); #else QDBusConnection::systemBus()); #endif // TODO - watch propertiesChanged signal QList addressObjects; QList routeObjects; if (NetworkManager::checkVersion(1, 0, 0)) { NMVariantMapList addresses = iface.addressData(); Q_FOREACH (const QVariantMap &addressList, addresses) { if (addressList.contains(QLatin1String("address")) && addressList.contains(QLatin1String("prefix"))) { NetworkManager::IpAddress address; address.setIp(QHostAddress(addressList.value(QLatin1String("address")).toString())); address.setPrefixLength(addressList.value(QLatin1String("prefix")).toUInt()); if (addressList.contains(QLatin1String("gateway"))) { address.setGateway(QHostAddress(addressList.value(QLatin1String("gateway")).toString())); } addressObjects << address; } } NMVariantMapList routes = iface.routeData(); Q_FOREACH (const QVariantMap &routeList, routes) { if (routeList.contains(QLatin1String("address")) && routeList.contains(QLatin1String("prefix"))) { NetworkManager::IpRoute route; route.setIp(QHostAddress(routeList.value(QLatin1String("address")).toString())); route.setPrefixLength(routeList.value(QLatin1String("prefix")).toUInt()); if (routeList.contains(QLatin1String("next-hop"))) { route.setNextHop(QHostAddress(routeList.value(QLatin1String("next-hop")).toString())); } if (routeList.contains(QLatin1String("metric"))) { route.setMetric(routeList.value(QLatin1String("metric")).toUInt()); } routeObjects << route; } } } else { IpV6DBusAddressList addresses = iface.addresses(); Q_FOREACH (const IpV6DBusAddress & address, addresses) { Q_IPV6ADDR addr; Q_IPV6ADDR gateway; for (int i = 0; i < 16; i++) { addr[i] = address.address[i]; } for (int i = 0; i < 16; i++) { gateway[i] = address.gateway[i]; } NetworkManager::IpAddress addressEntry; addressEntry.setIp(QHostAddress(addr)); addressEntry.setPrefixLength(address.prefix); addressEntry.setGateway(QHostAddress(gateway)); addressObjects << addressEntry; } IpV6DBusRouteList routes = iface.routes(); Q_FOREACH (const IpV6DBusRoute & route, routes) { Q_IPV6ADDR dest; Q_IPV6ADDR nexthop; for (int i = 0; i < 16; i++) { dest[i] = route.destination[i]; } for (int i = 0; i < 16; i++) { nexthop[i] = route.nexthop[i]; } NetworkManager::IpRoute routeEntry; routeEntry.setIp(QHostAddress(dest)); routeEntry.setPrefixLength(route.prefix); routeEntry.setNextHop(QHostAddress(nexthop)); routeEntry.setMetric(route.metric); routeObjects << routeEntry; } } QList nameservers; Q_FOREACH (const QByteArray & nameserver, iface.nameservers()) { Q_IPV6ADDR address; for (int i = 0; i < 16; i++) { address[i] = static_cast(nameserver[i]); } nameservers << QHostAddress(address); } d->addresses = addressObjects; d->routes = routeObjects; d->nameservers = nameservers; d->gateway = iface.gateway(); d->searches = iface.searches(); d->domains = iface.domains(); if (NetworkManager::checkVersion(1, 2, 0)) { d->dnsOptions = iface.dnsOptions(); } } NetworkManager::IpConfig::~IpConfig() { delete d; } NetworkManager::IpAddresses NetworkManager::IpConfig::addresses() const { return d->addresses; } QString NetworkManager::IpConfig::gateway() const { return d->gateway; } QList NetworkManager::IpConfig::nameservers() const { return d->nameservers; } QStringList NetworkManager::IpConfig::domains() const { return d->domains; } QList NetworkManager::IpConfig::routes() const { return d->routes; } QStringList NetworkManager::IpConfig::searches() const { return d->searches; } QStringList NetworkManager::IpConfig::dnsOptions() const { return d->dnsOptions; } NetworkManager::IpConfig &NetworkManager::IpConfig::operator=(const IpConfig &other) { if (this == &other) { return *this; } *d = *other.d; return *this; } bool NetworkManager::IpConfig::isValid() const { return !d->addresses.isEmpty(); } diff --git a/src/ipconfig.h b/src/ipconfig.h index e65471a..b5014fc 100644 --- a/src/ipconfig.h +++ b/src/ipconfig.h @@ -1,138 +1,124 @@ /* - * Copyright 2008,2011 Will Stephenson - * Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPCONFIG_H #define NETWORKMANAGERQT_IPCONFIG_H #include #include "ipaddress.h" #include "iproute.h" // To prevent signals in glib2 be defined by QT #undef signals #include #define signals Q_SIGNALS #include namespace NetworkManager { /** * This class represents IP configuration */ class NETWORKMANAGERQT_EXPORT IpConfig { public: /** * Constructs an IP config object with a list of @p addresses, @p nameservers, @p domains and @p routes. */ IpConfig(const IpAddresses &addresses, const QList &nameservers, const QStringList &domains, const IpRoutes &routes); /** * Constructs an empty IpConfig object. */ IpConfig(); /** * Destroys this IpConfig object. */ ~IpConfig(); /** * Constructs an IpConfig object that is a copy of the object @p other. */ IpConfig(const IpConfig &other); /** * Configure this class using the information on the following @p path */ void setIPv4Path(const QString &path); /** * Configure this class using the information on the following @p path */ void setIPv6Path(const QString &path); /** * Returns a list of IP addresses and gateway related to this configuration. * Use IpAddress::ip() to access the IP address and IpAddress::gateway() * to access the gateway address. */ NetworkManager::IpAddresses addresses() const; /** * Returns a list of domains related to this configuration. */ QStringList domains() const; /** * Returns the gateway in use * * @since 0.9.9.0 */ QString gateway() const; /** * Returns a list of nameservers related to this configuration. */ QList nameservers() const; /** * Returns a list of static routes (not the default gateway) related to this configuration. * Use @ref addresses() to retrieve the default gateway. */ IpRoutes routes() const; /** * Returns a list of DNS searches. * * @since 0.9.9.0 */ QStringList searches() const; /** * Returns a list of DNS options that modify the behaviour of the DNS resolver. * @since 5.14.0 */ QStringList dnsOptions() const; /** * Makes a copy of the IpConfig object @p other. */ IpConfig &operator=(const IpConfig &other); /** * Returns false if the list of IP addresses is empty */ bool isValid() const; private: class Private; Private *const d; }; } // namespace NetworkManager #endif // NETWORKMANAGERQT_IPCONFIG_H diff --git a/src/iproute.cpp b/src/iproute.cpp index a674e0c..7147d96 100644 --- a/src/iproute.cpp +++ b/src/iproute.cpp @@ -1,90 +1,76 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ipconfig.h" namespace NetworkManager { class NetworkManager::IpRoute::Private { public: Private() : metric(0) {} QHostAddress nextHop; quint32 metric; }; } NetworkManager::IpRoute::IpRoute() : d(new Private) { } NetworkManager::IpRoute::~IpRoute() { delete d; } NetworkManager::IpRoute::IpRoute(const NetworkManager::IpRoute &other) : QNetworkAddressEntry(other) , d(new Private) { *this = other; } void NetworkManager::IpRoute::setNextHop(const QHostAddress &nextHop) const { d->nextHop = nextHop; } QHostAddress NetworkManager::IpRoute::nextHop() const { return d->nextHop; } void NetworkManager::IpRoute::setMetric(quint32 metric) { d->metric = metric; } quint32 NetworkManager::IpRoute::metric() const { return d->metric; } NetworkManager::IpRoute &NetworkManager::IpRoute::operator=(const NetworkManager::IpRoute &other) { if (this == &other) { return *this; } QNetworkAddressEntry::operator =(other); *d = *other.d; return *this; } bool NetworkManager::IpRoute::isValid() const { return !ip().isNull(); } diff --git a/src/iproute.h b/src/iproute.h index 1150e94..8489730 100644 --- a/src/iproute.h +++ b/src/iproute.h @@ -1,93 +1,79 @@ /* - * Copyright 2008,2011 Will Stephenson - * Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPROUTE_H #define NETWORKMANAGERQT_IPROUTE_H #include #include "ipaddress.h" #include namespace NetworkManager { /** * This class represents IP route */ class NETWORKMANAGERQT_EXPORT IpRoute : public QNetworkAddressEntry { public: /** * Constructs an empty IpRoute object. */ IpRoute(); /** * Constructs an IpRoute object that is a copy of the object @p other. */ IpRoute(const IpRoute &other); /** * Destroys this IpRoute object. */ ~IpRoute(); /** * Returns true if the route IP is defined. */ bool isValid() const; /** * Defines the next hop of the given route. */ void setNextHop(const QHostAddress &nextHop) const; /** * Returns the next hop of the given route. */ QHostAddress nextHop() const; /** * Defines the @p metric of the given route, * lower values have higher priority. */ void setMetric(quint32 metric); /** * Returns the route metric number of the given route. */ quint32 metric() const; /** * Makes a copy of the IpRoute object @p other. */ IpRoute &operator=(const IpRoute &other); private: class Private; Private *const d; }; typedef QList IpRoutes; } // namespace NetworkManager #endif // NETWORKMANAGERQT_IPROUTE_H diff --git a/src/iptunneldevice.cpp b/src/iptunneldevice.cpp index a997899..32c1f8a 100644 --- a/src/iptunneldevice.cpp +++ b/src/iptunneldevice.cpp @@ -1,168 +1,154 @@ /* - Copyright 2017 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser Genecral Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2017 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "iptunneldevice_p.h" #include "device_p.h" #include "manager.h" NetworkManager::IpTunnelDevicePrivate::IpTunnelDevicePrivate(const QString &path, IpTunnelDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::IpTunnelDevicePrivate::~IpTunnelDevicePrivate() { } NetworkManager::IpTunnelDevice::IpTunnelDevice(const QString &path, QObject *parent): Device(*new IpTunnelDevicePrivate(path, this), parent) { Q_D(IpTunnelDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::IpTunnelDevice::~IpTunnelDevice() { } NetworkManager::Device::Type NetworkManager::IpTunnelDevice::type() const { return NetworkManager::Device::IpTunnel; } uchar NetworkManager::IpTunnelDevice::encapsulationLimit() const { Q_D(const IpTunnelDevice); return d->encapsulationLimit; } uint NetworkManager::IpTunnelDevice::flowLabel() const { Q_D(const IpTunnelDevice); return d->flowLabel; } QString NetworkManager::IpTunnelDevice::inputKey() const { Q_D(const IpTunnelDevice); return d->inputKey; } QString NetworkManager::IpTunnelDevice::local() const { Q_D(const IpTunnelDevice); return d->local; } uint NetworkManager::IpTunnelDevice::mode() const { Q_D(const IpTunnelDevice); return d->mode; } QString NetworkManager::IpTunnelDevice::outputKey() const { Q_D(const IpTunnelDevice); return d->outputKey; } NetworkManager::Device::Ptr NetworkManager::IpTunnelDevice::parent() const { Q_D(const IpTunnelDevice); return NetworkManager::findNetworkInterface(d->parent); } bool NetworkManager::IpTunnelDevice::pathMtuDiscovery() const { Q_D(const IpTunnelDevice); return d->pathMtuDiscovery; } QString NetworkManager::IpTunnelDevice::remote() const { Q_D(const IpTunnelDevice); return d->remote; } uchar NetworkManager::IpTunnelDevice::tos() const { Q_D(const IpTunnelDevice); return d->tos; } uchar NetworkManager::IpTunnelDevice::ttl() const { Q_D(const IpTunnelDevice); return d->ttl; } void NetworkManager::IpTunnelDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(IpTunnelDevice); if (property == QLatin1String("EncapsulationLimit")) { encapsulationLimit = static_cast(value.toUInt()); Q_EMIT q->encapsulationLimitChanged(encapsulationLimit); } else if (property == QLatin1String("FlowLabel")) { flowLabel = value.toUInt(); Q_EMIT q->flowLabelChanged(flowLabel); } else if (property == QLatin1String("InputKey")) { inputKey = value.toString(); Q_EMIT q->inputKeyChanged(inputKey); } else if (property == QLatin1String("Local")) { local = value.toString(); Q_EMIT q->localChanged(local); } else if (property == QLatin1String("Mode")) { mode = value.toUInt(); Q_EMIT q->modeChanged(mode); } else if (property == QLatin1String("OutputKey")) { outputKey = value.toString(); Q_EMIT q->outputKeyChanged(outputKey); } else if (property == QLatin1String("Parent")) { parent = value.toString(); Q_EMIT q->parentChanged(parent); } else if (property == QLatin1String("PathMtuDiscovery")) { pathMtuDiscovery = value.toBool(); Q_EMIT q->pathMtuDiscoveryChanged(pathMtuDiscovery); } else if (property == QLatin1String("Remote")) { remote = value.toString(); Q_EMIT q->remoteChanged(remote); } else if (property == QLatin1String("Tos")) { tos = static_cast(value.toUInt()); Q_EMIT q->tosChanged(tos); } else if (property == QLatin1String("Ttl")) { ttl = static_cast(value.toUInt()); Q_EMIT q->ttlChanged(ttl); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/iptunneldevice.h b/src/iptunneldevice.h index 8053d80..48669e7 100644 --- a/src/iptunneldevice.h +++ b/src/iptunneldevice.h @@ -1,156 +1,142 @@ /* - Copyright 2017 Jan Grulich + SPDX-FileCopyrightText: 2017 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPTUNNEL_DEVICE_H #define NETWORKMANAGERQT_IPTUNNEL_DEVICE_H #include "device.h" #include namespace NetworkManager { class IpTunnelDevicePrivate; /** * A Ip Tunnel device interface */ class NETWORKMANAGERQT_EXPORT IpTunnelDevice : public Device { Q_OBJECT Q_PROPERTY(uchar encapsulationLimit READ encapsulationLimit NOTIFY encapsulationLimitChanged) Q_PROPERTY(uint flowLabel READ flowLabel NOTIFY flowLabelChanged) Q_PROPERTY(QString inputKey READ inputKey NOTIFY inputKeyChanged) Q_PROPERTY(QString local READ local NOTIFY localChanged) Q_PROPERTY(uint mode READ mode NOTIFY modeChanged) Q_PROPERTY(QString outputKey READ outputKey NOTIFY outputKeyChanged) Q_PROPERTY(NetworkManager::Device::Ptr parent READ parent NOTIFY parentChanged) Q_PROPERTY(bool pathMtuDiscovery READ pathMtuDiscovery NOTIFY pathMtuDiscoveryChanged) Q_PROPERTY(QString remote READ remote NOTIFY remoteChanged) Q_PROPERTY(uchar tos READ tos NOTIFY tosChanged) Q_PROPERTY(uchar ttl READ ttl NOTIFY ttlChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit IpTunnelDevice(const QString &path, QObject *parent = nullptr); ~IpTunnelDevice() override; Type type() const override; /** * How many additional levels of encapsulation are permitted to be prepended to packets. * This property applies only to IPv6 tunnels. */ uchar encapsulationLimit() const; /** * The flow label to assign to tunnel packets. This property applies only to IPv6 tunnels. */ uint flowLabel() const; /** * The key used for incoming packets. */ QString inputKey() const; /** * The local endpoint of the tunnel. */ QString local() const; /** * The tunneling mode. */ uint mode() const; /** * The key used for outgoing packets. */ QString outputKey() const; /** * The object path of the parent device. */ NetworkManager::Device::Ptr parent() const; /** * Whether path MTU discovery is enabled on this tunnel. */ bool pathMtuDiscovery() const; /** * The remote endpoint of the tunnel. */ QString remote() const; /** * The type of service (IPv4) or traffic class (IPv6) assigned to tunneled packets. */ uchar tos() const; /** * The TTL assigned to tunneled packets. 0 is a special value meaning that packets inherit the TTL value */ uchar ttl() const; Q_SIGNALS: /** * Emitted when the encapsulation limit has changed */ void encapsulationLimitChanged(uchar limit); /** * Emitted when the flow label has changed */ void flowLabelChanged(uint flowLabel); /** * Emitted when the key used for incoming packets has changed */ void inputKeyChanged(const QString &inputKey); /** * Emitted when the local endpoint of the tunnel has changed */ void localChanged(const QString &local); /** * Emitted when the tunneling mode has changed */ void modeChanged(uint mode); /** * Emitted when the key used for outgoing packets has changed */ void outputKeyChanged(const QString &outputKey); /** * Emitted when the parent of this device has changed */ void parentChanged(const QString &parent); /** * Emitted when the path MTU discovery enablemened has changed */ void pathMtuDiscoveryChanged(bool pathMtuDiscovery); /** * Emitted when the remote endpoint of the tunnel has changed */ void remoteChanged(const QString &remote); /** * Emitted when the type of service or traffic class assigned to tunneled packets has changed */ void tosChanged(uchar tos); /** * Emitted when the TTL assigned to tunneled packets has changed */ void ttlChanged(uchar ttl); private: Q_DECLARE_PRIVATE(IpTunnelDevice) }; } #endif diff --git a/src/iptunneldevice_p.h b/src/iptunneldevice_p.h index 97768da..2158fe8 100644 --- a/src/iptunneldevice_p.h +++ b/src/iptunneldevice_p.h @@ -1,65 +1,51 @@ /* - Copyright 2017 Jan Grulich + SPDX-FileCopyrightText: 2017 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPTUNNEL_DEVICE_P_H #define NETWORKMANAGERQT_IPTUNNEL_DEVICE_P_H #include "iptunneldevice.h" #include "device_p.h" #include "manager.h" #include "manager_p.h" #include "iptunneldeviceinterface.h" namespace NetworkManager { class IpTunnelDevicePrivate : public DevicePrivate { Q_OBJECT public: IpTunnelDevicePrivate(const QString &path, IpTunnelDevice *q); virtual ~IpTunnelDevicePrivate(); OrgFreedesktopNetworkManagerDeviceIPTunnelInterface iface; uchar encapsulationLimit; uint flowLabel; QString inputKey; QString local; uint mode; QString outputKey; QString parent; bool pathMtuDiscovery; QString remote; uchar tos; uchar ttl; Q_DECLARE_PUBLIC(IpTunnelDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/macros.h b/src/macros.h index 1e2e906..440b199 100644 --- a/src/macros.h +++ b/src/macros.h @@ -1,85 +1,71 @@ /* - Copyright 2011 Will Stephenson + SPDX-FileCopyrightText: 2011 Will Stephenson - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MACROS_H #define NETWORKMANAGERQT_MACROS_H # define NM_GLOBAL_STATIC_STRUCT_NAME(NAME) typedef void (*NmCleanUpFunction)(); class NmCleanUpGlobalStatic { public: NmCleanUpFunction func; inline ~NmCleanUpGlobalStatic() { func(); } }; #define NM_GLOBAL_STATIC(TYPE, NAME) NM_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ()) #define NM_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ static QBasicAtomicPointer _nm_static_##NAME = Q_BASIC_ATOMIC_INITIALIZER(0); \ static bool _nm_static_##NAME##_destroyed; \ static struct NM_GLOBAL_STATIC_STRUCT_NAME(NAME) \ { \ inline bool isDestroyed() const \ { \ return _nm_static_##NAME##_destroyed; \ } \ inline bool exists() const \ { \ return _nm_static_##NAME != 0; \ } \ inline operator TYPE*() \ { \ return operator->(); \ } \ inline TYPE *operator->() \ { \ if (!_nm_static_##NAME) { \ if (isDestroyed()) { \ qFatal("Fatal Error: Accessed global static '%s *%s()' after destruction. " \ "Defined at %s:%d", #TYPE, #NAME, __FILE__, __LINE__); \ } \ TYPE *x = new TYPE ARGS; \ if (!_nm_static_##NAME.testAndSetOrdered(0, x) \ && _nm_static_##NAME != x ) { \ delete x; \ } else { \ static NmCleanUpGlobalStatic cleanUpObject = { destroy }; \ } \ } \ return _nm_static_##NAME; \ } \ inline TYPE &operator*() \ { \ return *operator->(); \ } \ static void destroy() \ { \ _nm_static_##NAME##_destroyed = true; \ TYPE *x = _nm_static_##NAME; \ _nm_static_##NAME = 0; \ delete x; \ } \ } NAME; #endif diff --git a/src/macvlandevice.cpp b/src/macvlandevice.cpp index 3ea1524..30dc126 100644 --- a/src/macvlandevice.cpp +++ b/src/macvlandevice.cpp @@ -1,96 +1,82 @@ /* - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "macvlandevice_p.h" #include "device_p.h" #include "manager.h" NetworkManager::MacVlanDevicePrivate::MacVlanDevicePrivate(const QString &path, MacVlanDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::MacVlanDevicePrivate::~MacVlanDevicePrivate() { } NetworkManager::MacVlanDevice::MacVlanDevice(const QString &path, QObject *parent): Device(*new MacVlanDevicePrivate(path, this), parent) { Q_D(MacVlanDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::MacVlanDevice::~MacVlanDevice() { } NetworkManager::Device::Type NetworkManager::MacVlanDevice::type() const { return NetworkManager::Device::MacVlan; } QString NetworkManager::MacVlanDevice::mode() const { Q_D(const MacVlanDevice); return d->mode; } bool NetworkManager::MacVlanDevice::noPromisc() const { Q_D(const MacVlanDevice); return d->noPromisc; } QString NetworkManager::MacVlanDevice::parent() const { Q_D(const MacVlanDevice); return d->parent; } void NetworkManager::MacVlanDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(MacVlanDevice); if (property == QLatin1String("Mode")) { mode = value.toString(); Q_EMIT q->modeChanged(mode); } else if (property == QLatin1String("NoPromisc")) { noPromisc = value.toBool(); Q_EMIT q->noPromiscChanged(noPromisc); } else if (property == QLatin1String("Parent")) { parent = value.toString(); Q_EMIT q->parentChanged(parent); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/macvlandevice.h b/src/macvlandevice.h index 97b830c..47a817a 100644 --- a/src/macvlandevice.h +++ b/src/macvlandevice.h @@ -1,65 +1,51 @@ /* - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MACVLAN_DEVICE_H #define NETWORKMANAGERQT_MACVLAN_DEVICE_H #include "device.h" #include namespace NetworkManager { class MacVlanDevicePrivate; /** * A macvlan device interface */ class NETWORKMANAGERQT_EXPORT MacVlanDevice : public Device { Q_OBJECT Q_PROPERTY(QString mode READ mode NOTIFY modeChanged) Q_PROPERTY(bool noPromisc READ noPromisc NOTIFY noPromiscChanged) Q_PROPERTY(QString parent READ parent NOTIFY parentChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit MacVlanDevice(const QString &path, QObject *parent = nullptr); ~MacVlanDevice() override; Type type() const override; QString mode() const; bool noPromisc() const; QString parent() const; Q_SIGNALS: void modeChanged(const QString &mode); void noPromiscChanged(bool noPromisc); void parentChanged(const QString &parent); private: Q_DECLARE_PRIVATE(MacVlanDevice) }; } #endif diff --git a/src/macvlandevice_p.h b/src/macvlandevice_p.h index 02c60a6..efc1d6f 100644 --- a/src/macvlandevice_p.h +++ b/src/macvlandevice_p.h @@ -1,55 +1,41 @@ /* - Copyright 2012-2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MACVLAN_DEVICE_P_H #define NETWORKMANAGERQT_MACVLAN_DEVICE_P_H #include "device_p.h" #include "macvlandevice.h" #include "manager_p.h" #include "macvlandeviceinterface.h" namespace NetworkManager { class MacVlanDevicePrivate: public DevicePrivate { Q_OBJECT public: MacVlanDevicePrivate(const QString &path, MacVlanDevice *q); virtual ~MacVlanDevicePrivate(); OrgFreedesktopNetworkManagerDeviceMacvlanInterface iface; QString mode; bool noPromisc; QString parent; Q_DECLARE_PUBLIC(MacVlanDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/manager.cpp b/src/manager.cpp index 44d3937..1f3d726 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -1,1167 +1,1153 @@ /* - Copyright 2008,2010 Will Stephenson - Copyright 2011-2013 Lamarque Souza - Copyright 2013 Daniel Nicoletti - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2010 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque Souza + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "manager.h" #include "manager_p.h" #include "macros.h" #undef signals #include #define signals Q_SIGNALS #include "activeconnection.h" #include "adsldevice.h" #include "bluetoothdevice.h" #include "bonddevice.h" #include "bridgedevice.h" #include "infinibanddevice.h" #include "iptunneldevice.h" #include "genericdevice.h" #include "modemdevice.h" #include "olpcmeshdevice.h" #include "settings.h" #include "settings_p.h" #include "vpnconnection.h" #include "vlandevice.h" #include "wireddevice.h" #include "wirelessdevice.h" #include "wimaxdevice.h" #include "gredevice.h" #include "macvlandevice.h" #include "tundevice.h" #include "vethdevice.h" #include "wireguarddevice.h" #include "nmdebug.h" #define DBUS_OBJECT_MANAGER "org.freedesktop.DBus.ObjectManager" #define DBUS_PROPERTIES "org.freedesktop.DBus.Properties" #ifdef NMQT_STATIC const QString NetworkManager::NetworkManagerPrivate::DBUS_SERVICE(QString::fromLatin1("org.kde.fakenetwork")); const QString NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH(QString::fromLatin1("/org/kde/fakenetwork")); const QString NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_INTERFACE(QString::fromLatin1("org.kde.fakenetwork")); const QString NetworkManager::NetworkManagerPrivate::DBUS_SETTINGS_PATH(QString::fromLatin1("/org/kde/fakenetwork/Settings")); #else const QString NetworkManager::NetworkManagerPrivate::DBUS_SERVICE(QString::fromLatin1(NM_DBUS_SERVICE)); const QString NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH(QString::fromLatin1(NM_DBUS_PATH)); const QString NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_INTERFACE(QString::fromLatin1(NM_DBUS_INTERFACE)); const QString NetworkManager::NetworkManagerPrivate::DBUS_SETTINGS_PATH(QString::fromLatin1(NM_DBUS_PATH_SETTINGS)); #endif const QString NetworkManager::NetworkManagerPrivate::FDO_DBUS_PROPERTIES(QString::fromLatin1(DBUS_PROPERTIES)); const QString NetworkManager::NetworkManagerPrivate::FDO_DBUS_OBJECT_MANAGER(QString::fromLatin1(DBUS_OBJECT_MANAGER)); Q_GLOBAL_STATIC(NetworkManager::NetworkManagerPrivate, globalNetworkManager) NetworkManager::NetworkManagerPrivate::NetworkManagerPrivate() #ifdef NMQT_STATIC : watcher(DBUS_SERVICE, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForUnregistration, this) , iface(NetworkManager::NetworkManagerPrivate::DBUS_SERVICE, NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH, QDBusConnection::sessionBus()) #else : watcher(DBUS_SERVICE, QDBusConnection::systemBus(), QDBusServiceWatcher::WatchForUnregistration, this) , iface(NetworkManager::NetworkManagerPrivate::DBUS_SERVICE, NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH, QDBusConnection::systemBus()) #endif , nmState(NetworkManager::Unknown) , m_connectivity(NetworkManager::UnknownConnectivity) , m_isNetworkingEnabled(false) , m_isWimaxEnabled(false) , m_isWimaxHardwareEnabled(false) , m_isWirelessEnabled(false) , m_isWirelessHardwareEnabled(false) , m_isWwanEnabled(false) , m_isWwanHardwareEnabled(false) , m_globalDnsConfiguration(NetworkManager::DnsConfiguration()) , m_supportedInterfaceTypes(NetworkManager::Device::UnknownType) { connect(&iface, &OrgFreedesktopNetworkManagerInterface::DeviceAdded, this, &NetworkManagerPrivate::onDeviceAdded); connect(&iface, &OrgFreedesktopNetworkManagerInterface::DeviceRemoved, this, &NetworkManagerPrivate::onDeviceRemoved); #ifndef NMQT_STATIC QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, NetworkManagerPrivate::DBUS_DAEMON_PATH, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), this, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); #else connect(&iface, &OrgFreedesktopNetworkManagerInterface::PropertiesChanged, this, &NetworkManagerPrivate::propertiesChanged); #endif iface.connection().connect(NetworkManagerPrivate::DBUS_SERVICE, "/org/freedesktop", NetworkManagerPrivate::FDO_DBUS_OBJECT_MANAGER, QLatin1String("InterfacesAdded"), this, SLOT(dbusInterfacesAdded(QDBusObjectPath,QVariantMap))); connect(&watcher, &QDBusServiceWatcher::serviceUnregistered, this, &NetworkManagerPrivate::daemonUnregistered); init(); } void NetworkManager::NetworkManagerPrivate::parseVersion(const QString &version) { const QStringList sl = version.split('.'); if (sl.size() > 2) { m_x = sl[0].toInt(); m_y = sl[1].toInt(); m_z = sl[2].toInt(); } else { m_x = -1; m_y = -1; m_z = -1; } } void NetworkManager::NetworkManagerPrivate::init() { qDBusRegisterMetaType(); qDBusRegisterMetaType(); // qDBusRegisterMetaType(); // qDBusRegisterMetaType(); // qDBusRegisterMetaType(); // qDBusRegisterMetaType(); // qDBusRegisterMetaType(); qDBusRegisterMetaType >(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); m_version = iface.version(); parseVersion(m_version); m_supportedInterfaceTypes = static_cast( NetworkManager::Device::Ethernet | NetworkManager::Device::Wifi | NetworkManager::Device::Modem | (checkVersion(1, 2, 0) ? 0 : NetworkManager::Device::Wimax) | NetworkManager::Device::Bluetooth | NetworkManager::Device::OlpcMesh | NetworkManager::Device::InfiniBand | NetworkManager::Device::Bond | NetworkManager::Device::Vlan | NetworkManager::Device::Adsl | NetworkManager::Device::Bridge | NetworkManager::Device::Generic | NetworkManager::Device::Team | NetworkManager::Device::MacVlan | NetworkManager::Device::Tun | NetworkManager::Device::Veth | NetworkManager::Device::IpTunnel | NetworkManager::Device::WireGuard ); // Get all Manager's properties async QVariantMap initialProperties = retrieveInitialProperties(iface.staticInterfaceName(), DBUS_DAEMON_PATH); if (!initialProperties.isEmpty()) { propertiesChanged(initialProperties); } QTimer::singleShot(0, [] { qobject_cast(settingsNotifier())->init(); }); if (iface.isValid()) { QList devices = iface.devices(); qCDebug(NMQT) << "Device list"; Q_FOREACH (const QDBusObjectPath & op, devices) { networkInterfaceMap.insert(op.path(), Device::Ptr()); Q_EMIT deviceAdded(op.path()); qCDebug(NMQT) << " " << op.path(); } } } NetworkManager::NetworkManagerPrivate::~NetworkManagerPrivate() { } QString NetworkManager::NetworkManagerPrivate::version() const { return m_version; } int NetworkManager::NetworkManagerPrivate::compareVersion(const QString &version) { int x, y, z; const auto sl = version.splitRef('.'); if (sl.size() > 2) { x = sl[0].toInt(); y = sl[1].toInt(); z = sl[2].toInt(); } else { x = -1; y = -1; z = -1; } return compareVersion(x, y, z); } int NetworkManager::NetworkManagerPrivate::compareVersion(const int x, const int y, const int z) const { if (m_x > x) { return 1; } else if (m_x < x) { return -1; } else if (m_y > y) { return 1; } else if (m_y < y) { return -1; } else if (m_z > z) { return 1; } else if (m_z < z) { return -1; } return 0; } bool NetworkManager::NetworkManagerPrivate::checkVersion(const int x, const int y, const int z) const { return 0 <= compareVersion(x, y, z); } NetworkManager::Device::Types NetworkManager::NetworkManagerPrivate::supportedInterfaceTypes() const { return m_supportedInterfaceTypes; } QVariantMap NetworkManager::NetworkManagerPrivate::retrieveInitialProperties(const QString &interfaceName, const QString &path) { QDBusMessage message = QDBusMessage::createMethodCall(DBUS_SERVICE, path, FDO_DBUS_PROPERTIES, QLatin1String("GetAll")); message << interfaceName; #ifdef NMQT_STATIC QDBusMessage resultMessage = QDBusConnection::sessionBus().call(message); #else QDBusMessage resultMessage = QDBusConnection::systemBus().call(message); #endif if (resultMessage.type() == QDBusMessage::ReplyMessage) { QVariantMap result; QDBusArgument dbusArgument = resultMessage.arguments().at(0).value(); while (!dbusArgument.atEnd()) { dbusArgument >> result; } return result; } return QVariantMap(); } NetworkManager::Device::Ptr NetworkManager::NetworkManagerPrivate::findRegisteredNetworkInterface(const QString &uni) { NetworkManager::Device::Ptr networkInterface; auto it = networkInterfaceMap.constFind(uni); if (it != networkInterfaceMap.constEnd()) { if (*it) { networkInterface = *it; } else { networkInterface = createNetworkInterface(uni); networkInterfaceMap[uni] = networkInterface; } } return networkInterface; } NetworkManager::ActiveConnection::Ptr NetworkManager::NetworkManagerPrivate::findRegisteredActiveConnection(const QString &uni) { NetworkManager::ActiveConnection::Ptr activeConnection; if (!uni.isEmpty() && uni != QLatin1String("/")) { const auto it = m_activeConnections.constFind(uni); const bool contains = it != m_activeConnections.constEnd(); if (contains && *it) { activeConnection = *it; } else { activeConnection = NetworkManager::ActiveConnection::Ptr(new NetworkManager::VpnConnection(uni), &QObject::deleteLater); if (activeConnection->connection()) { m_activeConnections[uni] = activeConnection; if (!contains) { Q_EMIT activeConnectionAdded(uni); } } else { activeConnection.clear(); } } } return activeConnection; } NetworkManager::Device::Ptr NetworkManager::NetworkManagerPrivate::createNetworkInterface(const QString &uni) { //qCDebug(NMQT); Device::Ptr createdInterface; Device::Ptr device(new Device(uni)); switch (device->type()) { case Device::Ethernet: createdInterface = Device::Ptr(new NetworkManager::WiredDevice(uni), &QObject::deleteLater); break; case Device::Wifi: createdInterface = Device::Ptr(new NetworkManager::WirelessDevice(uni), &QObject::deleteLater); break; case Device::Modem: createdInterface = Device::Ptr(new NetworkManager::ModemDevice(uni), &QObject::deleteLater); break; case Device::Bluetooth: createdInterface = Device::Ptr(new NetworkManager::BluetoothDevice(uni), &QObject::deleteLater); break; case Device::Wimax: createdInterface = Device::Ptr(new NetworkManager::WimaxDevice(uni), &QObject::deleteLater); break; case Device::OlpcMesh: createdInterface = Device::Ptr(new NetworkManager::OlpcMeshDevice(uni), &QObject::deleteLater); break; case Device::InfiniBand: createdInterface = Device::Ptr(new NetworkManager::InfinibandDevice(uni), &QObject::deleteLater); break; case Device::Bond: createdInterface = Device::Ptr(new NetworkManager::BondDevice(uni), &QObject::deleteLater); break; case Device::Vlan: createdInterface = Device::Ptr(new NetworkManager::VlanDevice(uni), &QObject::deleteLater); break; case Device::Adsl: createdInterface = Device::Ptr(new NetworkManager::AdslDevice(uni), &QObject::deleteLater); break; case Device::Bridge: createdInterface = Device::Ptr(new NetworkManager::BridgeDevice(uni), &QObject::deleteLater); break; //No need to check checkVersion, because we can't get Generic, Gre, MacVlan, Tun & Veth values in incompatible runtime case Device::Generic: createdInterface = Device::Ptr(new NetworkManager::GenericDevice(uni), &QObject::deleteLater); break; case Device::Gre: createdInterface = Device::Ptr(new NetworkManager::GreDevice(uni), &QObject::deleteLater); break; case Device::MacVlan: createdInterface = Device::Ptr(new NetworkManager::MacVlanDevice(uni), &QObject::deleteLater); break; case Device::Tun: createdInterface = Device::Ptr(new NetworkManager::TunDevice(uni), &QObject::deleteLater); break; case Device::Veth: createdInterface = Device::Ptr(new NetworkManager::VethDevice(uni), &QObject::deleteLater); break; case Device::IpTunnel: createdInterface = Device::Ptr(new NetworkManager::IpTunnelDevice(uni), &QObject::deleteLater); break; case Device::WireGuard: createdInterface = Device::Ptr(new NetworkManager::WireGuardDevice(uni), &QObject::deleteLater); break; default: createdInterface = device; if (uni != QLatin1String("any")) { // VPN connections use "any" as uni for the network interface. qCDebug(NMQT) << "Can't create device of type " << device->type() << "for" << uni; } break; } return createdInterface; } NetworkManager::Status NetworkManager::NetworkManagerPrivate::status() const { return nmState; } NetworkManager::Device::List NetworkManager::NetworkManagerPrivate::networkInterfaces() { Device::List list; QMap::const_iterator i; for (i = networkInterfaceMap.constBegin(); i != networkInterfaceMap.constEnd(); ++i) { Device::Ptr networkInterface = findRegisteredNetworkInterface(i.key()); if (!networkInterface.isNull()) { list.append(networkInterface); } else { qCWarning(NMQT) << "warning: null network Interface for" << i.key(); } } return list; } NetworkManager::Device::Ptr NetworkManager::NetworkManagerPrivate::findDeviceByIpIface(const QString &iface) { QMap::const_iterator i; for (i = networkInterfaceMap.constBegin(); i != networkInterfaceMap.constEnd(); ++i) { Device::Ptr networkInterface = findRegisteredNetworkInterface(i.key()); if (networkInterface && networkInterface->udi() == iface) { return networkInterface; } } return Device::Ptr(); } bool NetworkManager::NetworkManagerPrivate::isNetworkingEnabled() const { return m_isNetworkingEnabled; } bool NetworkManager::NetworkManagerPrivate::isWirelessEnabled() const { return m_isWirelessEnabled; } bool NetworkManager::NetworkManagerPrivate::isWirelessHardwareEnabled() const { return m_isWirelessHardwareEnabled; } bool NetworkManager::NetworkManagerPrivate::isWwanEnabled() const { return m_isWwanEnabled; } bool NetworkManager::NetworkManagerPrivate::isWwanHardwareEnabled() const { return m_isWwanHardwareEnabled; } bool NetworkManager::NetworkManagerPrivate::isWimaxEnabled() const { return checkVersion(1, 2, 0) ? false : m_isWimaxEnabled; } bool NetworkManager::NetworkManagerPrivate::isWimaxHardwareEnabled() const { return checkVersion(1, 2, 0) ? false : m_isWimaxHardwareEnabled; } QDBusPendingReply NetworkManager::NetworkManagerPrivate::activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter) { QString extra_connection_parameter = connectionParameter; QString extra_interface_parameter = interfaceUni; if (extra_connection_parameter.isEmpty()) { extra_connection_parameter = QLatin1String("/"); } if (extra_interface_parameter.isEmpty()) { extra_interface_parameter = QLatin1String("/"); } // TODO store error code QDBusObjectPath connPath(connectionUni); QDBusObjectPath interfacePath(interfaceUni); // qCDebug(NMQT) << "Activating connection" << connPath.path() << "on interface" << interfacePath.path() << "with extra" << extra_connection_parameter; return iface.ActivateConnection(connPath, QDBusObjectPath(extra_interface_parameter), QDBusObjectPath(extra_connection_parameter)); } QDBusPendingReply NetworkManager::NetworkManagerPrivate::addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter) { QString extra_connection_parameter = connectionParameter; if (extra_connection_parameter.isEmpty()) { extra_connection_parameter = QLatin1String("/"); } // TODO store error code QDBusObjectPath interfacePath(interfaceUni); return iface.AddAndActivateConnection(connection, interfacePath, QDBusObjectPath(extra_connection_parameter)); } QDBusPendingReply NetworkManager::NetworkManagerPrivate::addAndActivateConnection2(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter, const QVariantMap &options) { QString extra_connection_parameter = connectionParameter; if (extra_connection_parameter.isEmpty()) { extra_connection_parameter = QLatin1String("/"); } // TODO store error code QDBusObjectPath interfacePath(interfaceUni); return iface.AddAndActivateConnection2(connection, interfacePath, QDBusObjectPath(extra_connection_parameter), options); } QDBusPendingReply<> NetworkManager::NetworkManagerPrivate::deactivateConnection(const QString &activeConnectionPath) { return iface.DeactivateConnection(QDBusObjectPath(activeConnectionPath)); } void NetworkManager::NetworkManagerPrivate::setNetworkingEnabled(bool enabled) { iface.Enable(enabled); } void NetworkManager::NetworkManagerPrivate::setWirelessEnabled(bool enabled) { iface.setWirelessEnabled(enabled); } void NetworkManager::NetworkManagerPrivate::setWwanEnabled(bool enabled) { iface.setWwanEnabled(enabled); } void NetworkManager::NetworkManagerPrivate::setWimaxEnabled(bool enabled) { if (!checkVersion(1, 2, 0)) iface.setWimaxEnabled(enabled); } void NetworkManager::NetworkManagerPrivate::sleep(bool sleep) { iface.Sleep(sleep); } void NetworkManager::NetworkManagerPrivate::setLogging(NetworkManager::LogLevel level, NetworkManager::LogDomains domains) { QString logLevel; QStringList logDomains; switch (level) { case NetworkManager::Error: logLevel = QLatin1String("ERR"); break; case NetworkManager::Warning: logLevel = QLatin1String("WARN"); break; case NetworkManager::Info: logLevel = QLatin1String("INFO"); break; case NetworkManager::Debug: logLevel = QLatin1String("DEBUG"); break; case NetworkManager::Trace: logLevel = QLatin1String("TRACE"); break; } if (!domains.testFlag(NoChange)) { if (domains.testFlag(NetworkManager::None)) { logDomains << QLatin1String("NONE"); } if (domains.testFlag(NetworkManager::Hardware)) { logDomains << QLatin1String("PLATFORM"); } if (domains.testFlag(NetworkManager::RFKill)) { logDomains << QLatin1String("RFKILL"); } if (domains.testFlag(NetworkManager::Ethernet)) { logDomains << QLatin1String("ETHER"); } if (domains.testFlag(NetworkManager::WiFi)) { logDomains << QLatin1String("WIFI"); } if (domains.testFlag(NetworkManager::Bluetooth)) { logDomains << QLatin1String("BT"); } if (domains.testFlag(NetworkManager::MobileBroadBand)) { logDomains << QLatin1String("MB"); } if (domains.testFlag(NetworkManager::DHCP4)) { logDomains << QLatin1String("DHCP4"); } if (domains.testFlag(NetworkManager::DHCP6)) { logDomains << QLatin1String("DHCP6"); } if (domains.testFlag(NetworkManager::PPP)) { logDomains << QLatin1String("PPP"); } if (domains.testFlag(NetworkManager::WiFiScan)) { logDomains << QLatin1String("WIFI_SCAN"); } if (domains.testFlag(NetworkManager::IPv4)) { logDomains << QLatin1String("IP4"); } if (domains.testFlag(NetworkManager::IPv6)) { logDomains << QLatin1String("IP6"); } if (domains.testFlag(NetworkManager::AutoIPv4)) { logDomains << QLatin1String("AUTOIP4"); } if (domains.testFlag(NetworkManager::DNS)) { logDomains << QLatin1String("DNS"); } if (domains.testFlag(NetworkManager::VPN)) { logDomains << QLatin1String("VPN"); } if (domains.testFlag(NetworkManager::Sharing)) { logDomains << QLatin1String("SHARING"); } if (domains.testFlag(NetworkManager::Supplicant)) { logDomains << QLatin1String("SUPPLICANT"); } if (domains.testFlag(NetworkManager::UserSet)) { logDomains << QLatin1String("USER_SET"); } if (domains.testFlag(NetworkManager::SysSet)) { logDomains << QLatin1String("SYS_SET"); } if (domains.testFlag(NetworkManager::Suspend)) { logDomains << QLatin1String("SUSPEND"); } if (domains.testFlag(NetworkManager::Core)) { logDomains << QLatin1String("CORE"); } if (domains.testFlag(NetworkManager::Devices)) { logDomains << QLatin1String("DEVICE"); } if (domains.testFlag(NetworkManager::OLPC)) { logDomains << QLatin1String("OLPC"); } if (domains.testFlag(NetworkManager::Wimax)) { logDomains << QLatin1String("WIMAX"); } if (domains.testFlag(NetworkManager::Infiniband)) { logDomains << QLatin1String("INFINIBAND"); } if (domains.testFlag(NetworkManager::Firewall)) { logDomains << QLatin1String("FIREWALL"); } if (domains.testFlag(NetworkManager::Adsl)) { logDomains << QLatin1String("ADSL"); } if (domains.testFlag(NetworkManager::Bond)) { logDomains << QLatin1String("BOND"); } if (domains.testFlag(NetworkManager::Vlan)) { logDomains << QLatin1String("VLAN"); } if (domains.testFlag(NetworkManager::Agents)) { logDomains << QLatin1String("AGENTS"); } if (domains.testFlag(NetworkManager::Settings)) { logDomains << QLatin1String("SETTINGS"); } if (domains.testFlag(NetworkManager::DbusProps)) { logDomains << QLatin1String("DBUS_PROPS"); } if (domains.testFlag(NetworkManager::Team)) { logDomains << QLatin1String("TEAM"); } if (domains.testFlag(NetworkManager::ConCheck)) { logDomains << QLatin1String("CONCHECK"); } if (domains.testFlag(NetworkManager::Dcb)) { logDomains << QLatin1String("DCB"); } if (domains.testFlag(NetworkManager::Dispatch)) { logDomains << QLatin1String("DISPATCH"); } } iface.SetLogging(logLevel, logDomains.join(QLatin1Char(','))); } NMStringMap NetworkManager::NetworkManagerPrivate::permissions() { return iface.GetPermissions(); } NetworkManager::Connectivity NetworkManager::NetworkManagerPrivate::connectivity() const { return m_connectivity; } QDBusPendingReply NetworkManager::NetworkManagerPrivate::checkConnectivity() { return iface.CheckConnectivity(); } NetworkManager::ActiveConnection::Ptr NetworkManager::NetworkManagerPrivate::primaryConnection() { return findRegisteredActiveConnection(m_primaryConnection); } NetworkManager::ActiveConnection::Ptr NetworkManager::NetworkManagerPrivate::activatingConnection() { return findRegisteredActiveConnection(m_activatingConnection); } NetworkManager::ConnectionSettings::ConnectionType NetworkManager::NetworkManagerPrivate::primaryConnectionType() { return checkVersion(1, 0, 0) ? m_primaryConnectionType : NetworkManager::ConnectionSettings::Unknown; } bool NetworkManager::NetworkManagerPrivate::isStartingUp() const { return iface.startup(); } NetworkManager::Device::MeteredStatus NetworkManager::NetworkManagerPrivate::metered() const { return checkVersion(1, 0, 6) ? m_metered : NetworkManager::Device::UnknownStatus; } NetworkManager::DnsConfiguration NetworkManager::NetworkManagerPrivate::globalDnsConfiguration() const { return m_globalDnsConfiguration; } void NetworkManager::NetworkManagerPrivate::setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration) { m_globalDnsConfiguration = configuration; iface.setGlobalDnsConfiguration(m_globalDnsConfiguration.toMap()); } void NetworkManager::NetworkManagerPrivate::onDeviceAdded(const QDBusObjectPath &objpath) { // qCDebug(NMQT); if (!networkInterfaceMap.contains(objpath.path())) { networkInterfaceMap.insert(objpath.path(), Device::Ptr()); Q_EMIT deviceAdded(objpath.path()); } } void NetworkManager::NetworkManagerPrivate::onDeviceRemoved(const QDBusObjectPath &objpath) { // qCDebug(NMQT); networkInterfaceMap.remove(objpath.path()); Q_EMIT deviceRemoved(objpath.path()); } void NetworkManager::NetworkManagerPrivate::connectivityChanged(uint connectivity) { NetworkManager::Connectivity newConnectivity = convertConnectivity(connectivity); if (m_connectivity != newConnectivity) { m_connectivity = newConnectivity; Q_EMIT Notifier::connectivityChanged(newConnectivity); } } void NetworkManager::NetworkManagerPrivate::stateChanged(uint state) { NetworkManager::Status newStatus = convertNMState(state); if (nmState != newStatus) { nmState = newStatus; Q_EMIT Notifier::statusChanged(newStatus); } } void NetworkManager::NetworkManagerPrivate::dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties) { Q_UNUSED(invalidatedProperties); if (interfaceName == QLatin1String("org.freedesktop.NetworkManager")) { propertiesChanged(properties); } } void NetworkManager::NetworkManagerPrivate::propertiesChanged(const QVariantMap &changedProperties) { // qCDebug(NMQT) << Q_FUNC_INFO << changedProperties; QVariantMap::const_iterator it = changedProperties.constBegin(); while (it != changedProperties.constEnd()) { const QString property = it.key(); if (property == QLatin1String("ActiveConnections")) { QList activePaths = qdbus_cast< QList >(*it); if (activePaths.isEmpty()) { QMap::const_iterator it = m_activeConnections.constBegin(); while (it != m_activeConnections.constEnd()) { Q_EMIT activeConnectionRemoved(it.key()); ++it; } m_activeConnections.clear(); } else { QStringList knownConnections = m_activeConnections.keys(); Q_FOREACH (const QDBusObjectPath & ac, activePaths) { if (!m_activeConnections.contains(ac.path())) { m_activeConnections.insert(ac.path(), NetworkManager::ActiveConnection::Ptr()); Q_EMIT activeConnectionAdded(ac.path()); } else { knownConnections.removeOne(ac.path()); } // qCDebug(NMQT) << " " << ac.path(); } Q_FOREACH (const QString & path, knownConnections) { m_activeConnections.remove(path); Q_EMIT activeConnectionRemoved(path); } } Q_EMIT activeConnectionsChanged(); } else if (property == QLatin1String("NetworkingEnabled")) { m_isNetworkingEnabled = it->toBool(); qCDebug(NMQT) << property << m_isNetworkingEnabled; Q_EMIT networkingEnabledChanged(m_isNetworkingEnabled); } else if (property == QLatin1String("WirelessHardwareEnabled")) { m_isWirelessHardwareEnabled = it->toBool(); qCDebug(NMQT) << property << m_isWirelessHardwareEnabled; Q_EMIT wirelessHardwareEnabledChanged(m_isWirelessHardwareEnabled); } else if (property == QLatin1String("WirelessEnabled")) { m_isWirelessEnabled = it->toBool(); qCDebug(NMQT) << property << m_isWirelessEnabled; Q_EMIT wirelessEnabledChanged(m_isWirelessEnabled); } else if (property == QLatin1String("WwanHardwareEnabled")) { m_isWwanHardwareEnabled = it->toBool(); qCDebug(NMQT) << property << m_isWwanHardwareEnabled; Q_EMIT wwanHardwareEnabledChanged(m_isWwanHardwareEnabled); } else if (property == QLatin1String("WwanEnabled")) { m_isWwanEnabled = it->toBool(); qCDebug(NMQT) << property << m_isWwanEnabled; Q_EMIT wwanEnabledChanged(m_isWwanEnabled); } else if (property == QLatin1String("WimaxHardwareEnabled")) { m_isWimaxHardwareEnabled = it->toBool(); qCDebug(NMQT) << property << m_isWimaxHardwareEnabled; Q_EMIT wimaxHardwareEnabledChanged(m_isWimaxHardwareEnabled); } else if (property == QLatin1String("WimaxEnabled")) { m_isWimaxEnabled = it->toBool(); qCDebug(NMQT) << property << m_isWimaxEnabled; Q_EMIT wimaxEnabledChanged(m_isWimaxEnabled); } else if (property == QLatin1String("Version")) { m_version = it->toString(); parseVersion(m_version); } else if (property == QLatin1String("State")) { stateChanged(it->toUInt()); } else if (property == QLatin1String("Connectivity")) { connectivityChanged(it->toUInt()); } else if (property == QLatin1String("PrimaryConnection")) { m_primaryConnection = it->value().path(); Q_EMIT primaryConnectionChanged(m_primaryConnection); } else if (property == QLatin1String("ActivatingConnection")) { m_activatingConnection = it->value().path(); Q_EMIT activatingConnectionChanged(m_activatingConnection); } else if (property == QLatin1String("PrimaryConnectionType")) { m_primaryConnectionType = NetworkManager::ConnectionSettings::typeFromString(it->toString()); Q_EMIT primaryConnectionTypeChanged(m_primaryConnectionType); } else if (property == QLatin1String("Startup")) { Q_EMIT isStartingUpChanged(); } else if (property == QLatin1String("Metered")) { m_metered = (NetworkManager::Device::MeteredStatus)it->toUInt(); Q_EMIT meteredChanged(m_metered); } else if (property == QLatin1String("GlobalDnsConfiguration")) { m_globalDnsConfiguration.fromMap(qdbus_cast(*it)); Q_EMIT globalDnsConfigurationChanged(m_globalDnsConfiguration); } else { qCDebug(NMQT) << Q_FUNC_INFO << "Unhandled property" << property; } ++it; } } NetworkManager::Connectivity NetworkManager::NetworkManagerPrivate::convertConnectivity(uint connectivity) { NetworkManager::Connectivity convertedConnectivity = NetworkManager::UnknownConnectivity; switch (connectivity) { case NM_CONNECTIVITY_UNKNOWN: convertedConnectivity = NetworkManager::UnknownConnectivity; break; case NM_CONNECTIVITY_NONE: convertedConnectivity = NetworkManager::NoConnectivity; break; case NM_CONNECTIVITY_PORTAL: convertedConnectivity = NetworkManager::Portal; break; case NM_CONNECTIVITY_LIMITED: convertedConnectivity = NetworkManager::Limited; break; case NM_CONNECTIVITY_FULL: convertedConnectivity = NetworkManager::Full; break; } return convertedConnectivity; } NetworkManager::Status NetworkManager::NetworkManagerPrivate::convertNMState(uint state) { NetworkManager::Status status = NetworkManager::Unknown; switch (state) { case NM_STATE_UNKNOWN: status = NetworkManager::Unknown; break; case NM_STATE_ASLEEP: status = NetworkManager::Asleep; break; case NM_STATE_DISCONNECTED: status = NetworkManager::Disconnected; break; case NM_STATE_DISCONNECTING: status = NetworkManager::Disconnecting; break; case NM_STATE_CONNECTING: status = NetworkManager::Connecting; break; case NM_STATE_CONNECTED_LOCAL: status = NetworkManager::ConnectedLinkLocal; break; case NM_STATE_CONNECTED_SITE: status = NetworkManager::ConnectedSiteOnly; break; case NM_STATE_CONNECTED_GLOBAL: status = NetworkManager::Connected; break; } return status; } void NetworkManager::NetworkManagerPrivate::interfacesAdded(const QDBusObjectPath &path, const QVariantMap &addedInterfaces) { Q_UNUSED(path); if(!addedInterfaces.contains(NetworkManagerPrivate::DBUS_DAEMON_INTERFACE)) return; init(); Q_EMIT serviceAppeared(); } void NetworkManager::NetworkManagerPrivate::daemonUnregistered() { stateChanged(NM_STATE_UNKNOWN); QMap::const_iterator i = networkInterfaceMap.constBegin(); while (i != networkInterfaceMap.constEnd()) { Q_EMIT deviceRemoved(i.key()); ++i; } networkInterfaceMap.clear(); QMap::const_iterator it = m_activeConnections.constBegin(); while (it != m_activeConnections.constEnd()) { Q_EMIT activeConnectionRemoved(it.key()); ++it; } m_activeConnections.clear(); qobject_cast(settingsNotifier())->daemonUnregistered(); Q_EMIT activeConnectionsChanged(); Q_EMIT serviceDisappeared(); } NetworkManager::ActiveConnection::List NetworkManager::NetworkManagerPrivate::activeConnections() { NetworkManager::ActiveConnection::List list; // We do not use const_iterator here because // findRegisteredActiveConnection() changes m_activeConnections. foreach (const QString &key, m_activeConnections.keys()) { NetworkManager::ActiveConnection::Ptr activeConnection = findRegisteredActiveConnection(key); if (activeConnection) { list << activeConnection; } } return list; } QStringList NetworkManager::NetworkManagerPrivate::activeConnectionsPaths() const { return m_activeConnections.keys(); } QDBusPendingReply< QString, QString > NetworkManager::NetworkManagerPrivate::getLogging() { return iface.GetLogging(); } QString NetworkManager::version() { return globalNetworkManager->version(); } int NetworkManager::compareVersion(const QString &version) { return globalNetworkManager->compareVersion(version); } int NetworkManager::compareVersion(const int x, const int y, const int z) { return globalNetworkManager->compareVersion(x, y, z); } bool NetworkManager::checkVersion(const int x, const int y, const int z) { return globalNetworkManager->checkVersion(x, y, z); } NetworkManager::Status NetworkManager::status() { return globalNetworkManager->status(); } NetworkManager::ActiveConnection::List NetworkManager::activeConnections() { return globalNetworkManager->activeConnections(); } QStringList NetworkManager::activeConnectionsPaths() { return globalNetworkManager->activeConnectionsPaths(); } NetworkManager::ActiveConnection::Ptr NetworkManager::findActiveConnection(const QString &uni) { return globalNetworkManager->findRegisteredActiveConnection(uni); } NetworkManager::Device::List NetworkManager::networkInterfaces() { return globalNetworkManager->networkInterfaces(); } bool NetworkManager::isNetworkingEnabled() { return globalNetworkManager->isNetworkingEnabled(); } bool NetworkManager::isWirelessEnabled() { return globalNetworkManager->isWirelessEnabled(); } bool NetworkManager::isWirelessHardwareEnabled() { return globalNetworkManager->isWirelessHardwareEnabled(); } NetworkManager::Device::Ptr NetworkManager::findNetworkInterface(const QString &uni) { return globalNetworkManager->findRegisteredNetworkInterface(uni); } NetworkManager::Device::Ptr NetworkManager::findDeviceByIpFace(const QString &iface) { return globalNetworkManager->findDeviceByIpIface(iface); } QDBusPendingReply NetworkManager::addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter) { return globalNetworkManager->addAndActivateConnection(connection, interfaceUni, connectionParameter); } QDBusPendingReply NetworkManager::addAndActivateConnection2(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter, const QVariantMap &options) { if (checkVersion(1, 16, 0)) { return globalNetworkManager->addAndActivateConnection2(connection, interfaceUni, connectionParameter, options); } else { return globalNetworkManager->addAndActivateConnection(connection, interfaceUni, connectionParameter); } } QDBusPendingReply NetworkManager::activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter) { return globalNetworkManager->activateConnection(connectionUni, interfaceUni, connectionParameter); } QDBusPendingReply<> NetworkManager::deactivateConnection(const QString &activeConnectionPath) { return globalNetworkManager->deactivateConnection(activeConnectionPath); } QDBusPendingReply< QString, QString > NetworkManager::getLogging() { return globalNetworkManager->getLogging(); } void NetworkManager::setNetworkingEnabled(bool enabled) { globalNetworkManager->setNetworkingEnabled(enabled); } void NetworkManager::setWirelessEnabled(bool enabled) { globalNetworkManager->setWirelessEnabled(enabled); } bool NetworkManager::isWwanEnabled() { return globalNetworkManager->isWwanEnabled(); } bool NetworkManager::isWwanHardwareEnabled() { return globalNetworkManager->isWwanHardwareEnabled(); } void NetworkManager::setWwanEnabled(bool enabled) { globalNetworkManager->setWwanEnabled(enabled); } bool NetworkManager::isWimaxEnabled() { return globalNetworkManager->isWimaxEnabled(); } bool NetworkManager::isWimaxHardwareEnabled() { return globalNetworkManager->isWimaxHardwareEnabled(); } void NetworkManager::setWimaxEnabled(bool enabled) { globalNetworkManager->setWimaxEnabled(enabled); } void NetworkManager::sleep(bool sleep) { globalNetworkManager->sleep(sleep); } void NetworkManager::setLogging(NetworkManager::LogLevel level, NetworkManager::LogDomains domains) { globalNetworkManager->setLogging(level, domains); } NMStringMap NetworkManager::permissions() { return globalNetworkManager->permissions(); } NetworkManager::Device::Types NetworkManager::supportedInterfaceTypes() { return globalNetworkManager->supportedInterfaceTypes(); } NetworkManager::Connectivity NetworkManager::connectivity() { return globalNetworkManager->connectivity(); } QDBusPendingReply NetworkManager::checkConnectivity() { return globalNetworkManager->checkConnectivity(); } NetworkManager::ActiveConnection::Ptr NetworkManager::primaryConnection() { return globalNetworkManager->primaryConnection(); } NetworkManager::ActiveConnection::Ptr NetworkManager::activatingConnection() { return globalNetworkManager->activatingConnection(); } NetworkManager::ConnectionSettings::ConnectionType NetworkManager::primaryConnectionType() { return globalNetworkManager->primaryConnectionType(); } bool NetworkManager::isStartingUp() { return globalNetworkManager->isStartingUp(); } NetworkManager::Device::MeteredStatus NetworkManager::metered() { return globalNetworkManager->metered(); } NetworkManager::DnsConfiguration NetworkManager::globalDnsConfiguration() { return globalNetworkManager->globalDnsConfiguration(); } void NetworkManager::setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration) { globalNetworkManager->setGlobalDnsConfiguration(configuration); } NetworkManager::Notifier *NetworkManager::notifier() { return globalNetworkManager; } diff --git a/src/manager.h b/src/manager.h index 653fea3..9f20717 100644 --- a/src/manager.h +++ b/src/manager.h @@ -1,459 +1,445 @@ /* - Copyright 2008,2010,2011 Will Stephenson - Copyright 2011-2013 Lamarque Souza - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2008, 2010, 2011 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque Souza + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_NETWORKMANAGER_H #define NETWORKMANAGERQT_NETWORKMANAGER_H #include #include "device.h" #include "activeconnection.h" #include "dnsconfiguration.h" /** * This class allows querying the underlying system to discover the available * network interfaces and reachable networks. It has also the * responsibility to notify when a network interface appears or disappears. * * It is the unique entry point for network management. Applications should use * it to find network interfaces, or to be notified about network related changes. * * Note that it is implemented as a singleton */ namespace NetworkManager { Q_NAMESPACE enum Status { Unknown, /**< the networking system is not active or unable to report its status - proceed with caution */ Asleep, /**< networking is inactive and all devices are disabled */ Disconnected,/**< the system is not connected to any network */ Disconnecting, /**< the system is breaking the connection */ Connecting, /**< the system is not connected to any network */ ConnectedLinkLocal, /**< a network device is connected, but there is only link-local connectivity */ ConnectedSiteOnly, /**< a network device is connected, but there is only site-local connectivity */ Connected /**< the system is currently connected to a network */ }; enum LogLevel { Error, Warning, Info, Debug, Trace/**< = Debug in runtime NM < 0.9.10*/ }; enum LogDomain {NoChange, None, Hardware, RFKill, Ethernet, WiFi, Bluetooth, MobileBroadBand, DHCP4, DHCP6, PPP, WiFiScan, IPv4, IPv6, AutoIPv4, DNS, VPN, Sharing, Supplicant, UserSet, SysSet, Suspend, Core, Devices, OLPC, Wimax/*TODO: mark it deprecated somehow?*/, Infiniband, Firewall, Adsl, Bond, Vlan , Agents, Settings, Bridge, DbusProps, Team, ConCheck, Dcb, Dispatch }; Q_DECLARE_FLAGS(LogDomains, LogDomain) Q_FLAGS(LogDomain) /** * Describes the network connectivity state. * @since 0.9.9.0 */ enum Connectivity { UnknownConnectivity = 0, /**< Network connectivity is unknown. */ NoConnectivity = 1, /**< The host is not connected to any network. */ Portal = 2, /**< The host is behind a captive portal and cannot reach the full Internet. */ Limited = 3, /**< The host is connected to a network, but does not appear to be able to reach the full Internet. */ Full = 4 /**< The host is connected to a network, and appears to be able to reach the full Internet. */ }; class NETWORKMANAGERQT_EXPORT Notifier : public QObject { Q_OBJECT Q_SIGNALS: /** * This signal is emitted when the system's connection state changes */ void statusChanged(NetworkManager::Status status); /** * This signal is emitted when a new network interface is available. * * @param uni the network interface identifier */ void deviceAdded(const QString &uni); /** * This signal is emitted when a network interface is not available anymore. * * @param uni the network interface identifier */ void deviceRemoved(const QString &uni); /** * This signal is emitted when the status of the wireless changed */ void wirelessEnabledChanged(bool); /** * This signal is emitted when the status of the wireless changed */ void wwanEnabledChanged(bool); /** * This signal is emitted when the status of the wimax changed * * @deprecated Wimax support was removed from NetworkManager 1.2 * (never emitted in runtime NM >= 1.2.0). */ void wimaxEnabledChanged(bool); /** * This signal is emitted when the status of the wireless changed */ void wirelessHardwareEnabledChanged(bool); /** * This signal is emitted when the status of the wireless changed */ void wwanHardwareEnabledChanged(bool); /** * This signal is emitted when the status of the wimax hardware changed * * @deprecated Wimax support was removed from NetworkManager 1.2 * (never emitted in runtime NM >= 1.2.0). */ void wimaxHardwareEnabledChanged(bool); /** * This signal is emitted when the status of overall networking changed */ void networkingEnabledChanged(bool); /** * This signal is emitted when a new connection was made active * * @param path the path of the new connection */ void activeConnectionAdded(const QString &path); /** * This signal is emitted when an active connection is no longer active * * @param path the path of the removed connection */ void activeConnectionRemoved(const QString &path); /** * This signal is emitted when the set of active connections changes */ void activeConnectionsChanged(); /** * This signal is emitted when the NetworkManager DBus service goes away */ void serviceDisappeared(); /** * This signal is emitted when the NetworkManager DBus service appears */ void serviceAppeared(); /** * Emitted when the global connectivity changes. * @since 0.9.9.0 */ void connectivityChanged(NetworkManager::Connectivity connectivity); /** * Emitted when the primary connection changes. * @param uni path of the new primary connection * @since 0.9.9.0 */ void primaryConnectionChanged(const QString &uni); /** * Emitted when the activating connection changes. * @param uni path of the new activating connection * @since 0.9.9.0 */ void activatingConnectionChanged(const QString &uni); /** * Emitted when the primary connection type changes. * @param connection type of the new primary connection * @since 5.8.0 */ void primaryConnectionTypeChanged(NetworkManager::ConnectionSettings::ConnectionType type); /** * Emitted when NM has started/finished its startup sequence * @since 0.9.9.0 */ void isStartingUpChanged(); /** * Emitted when metered property has changed * @since 5.14.0 * @see metered */ void meteredChanged(NetworkManager::Device::MeteredStatus metered); /** * Emitted when the global DNS configuration has changed * @since 5.45.0 * @see globalDnsConfiguration */ void globalDnsConfigurationChanged(const NetworkManager::DnsConfiguration &configuration); }; /** * Get the NetworkManager version */ NETWORKMANAGERQT_EXPORT QString version(); /** * Compares NetworkManager's version to the parameter version. * returns 1, -1 or 0 if NetworkManager's version is greater, less or equal to parameter. */ NETWORKMANAGERQT_EXPORT int compareVersion(const QString &version); /** * Compares NetworkManager version to x.y.z. * returns 1, -1 or 0 if NetworkManager's version is greater, less or equal to x.y.z. */ NETWORKMANAGERQT_EXPORT int compareVersion(const int x, const int y, const int z); /** * Checks if NetworkManager version is at least x.y.z * @return true if NetworkManager's version is greater or equal, false otherwise **/ NETWORKMANAGERQT_EXPORT bool checkVersion(const int x, const int y, const int z); /** * Get the manager connection state */ NETWORKMANAGERQT_EXPORT NetworkManager::Status status(); /** * Retrieves the list of all the network interfaces in the system. * It includes both hardware and virtual devices. * * @return the list of network interfaces available in this system */ NETWORKMANAGERQT_EXPORT Device::List networkInterfaces(); /** * Find a new NetworkInterface object given its UNI. This pointer is owned by the Solid * infrastructure. * * @param uni the identifier of the network interface to find * @return a valid NetworkInterface object if there's a device having the given UNI, an invalid one otherwise */ NETWORKMANAGERQT_EXPORT Device::Ptr findNetworkInterface(const QString &uni); /** * Return the network device referenced by its IP interface name. * This is not system independent so programs that will use this method will not be portable. */ NETWORKMANAGERQT_EXPORT Device::Ptr findDeviceByIpFace(const QString &iface); /** * Retrieves the status of networking (as a whole) in the system. * This is distinct from whether the system's networking is online or offline. * To check that, see @ref status(). * * @return true if this networking is enabled, false otherwise */ NETWORKMANAGERQT_EXPORT bool isNetworkingEnabled(); /** * Retrieves the activation status of wireless networking in the system. * * @return true if this wireless networking is enabled, false otherwise */ NETWORKMANAGERQT_EXPORT bool isWirelessEnabled(); /** * Retrieves the status of wireless hardware in the system. This is typically * controlled by a physical switch so there is no way to set this in software. * * @return true if this wireless networking is enabled, false otherwise */ NETWORKMANAGERQT_EXPORT bool isWirelessHardwareEnabled(); /** * Retrieves the status of wireless broadband (Wireless WAN) in the system. * * @return true if this type of wireless networking is enabled, false otherwise */ NETWORKMANAGERQT_EXPORT bool isWwanEnabled(); /** * Retrieves the status of wireless broadband (Wireless WAN) hardware in the system. This is typically * controlled by a physical switch so there is no way to set this in software. * * @return true if this broddband hardware is enabled, false otherwise */ NETWORKMANAGERQT_EXPORT bool isWwanHardwareEnabled(); /** * Retrieves the activation status of wimax networking in the system. * * @return true if this wimax networking is enabled, false otherwise * * @deprecated Wimax support was removed from NetworkManager 1.2 * (always returns false in runtime NM >= 1.2.0). */ NETWORKMANAGERQT_EXPORT bool isWimaxEnabled(); /** * Retrieves the status of wimax hardware in the system. This is typically * controlled by a physical switch so there is no way to set this in software. * * @return true if wimax HW networking is enabled, false otherwise * * @deprecated Wimax support was removed from NetworkManager 1.2 * (always returns false in runtime NM >= 1.2.0). */ NETWORKMANAGERQT_EXPORT bool isWimaxHardwareEnabled(); /** * Activate a connection using the supplied device. * * @param connectionUni unique identifier for the connection to be activated * @param interfaceUni unique identifier of the network interface to be activated * @param connectionParameter can be used to specify extra parameters not specific to the NetworkInterface or the connection, eg which AP to use when several present with same ESSID in range (because ESSID does not guarantee that the AP is part of the network you want to join!) */ NETWORKMANAGERQT_EXPORT QDBusPendingReply activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter); /** * Adds a new connection using the given details (if any) as a template (automatically filling in missing settings with the capabilities of the given device and specific object), then activate the new connection. * Cannot be used for VPN connections at this time. * * @param connection connection definition to be added and activated * @param interfaceUni unique identifier of the network interface to be activated * @param connectionParameter can be used to specify extra parameters not specific to the NetworkInterface or the connection, eg which AP to use when several present with same ESSID in range (because ESSID does not guarantee that the AP is part of the network you want to join!) */ NETWORKMANAGERQT_EXPORT QDBusPendingReply addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter); /** * Adds a new connection using the given details (if any) as a template (automatically filling in missing settings with the capabilities of the given device and specific object), then activate the new connection. * Cannot be used for VPN connections at this time. * * @param connection connection definition to be added and activated * @param interfaceUni unique identifier of the network interface to be activated * @param connectionParameter can be used to specify extra parameters not specific to the NetworkInterface or the connection, eg which AP to use when several present with same ESSID in range (because ESSID does not guarantee that the AP is part of the network you want to join!) * @param options further options for the method call. * * This method extends AddAndActivateConnection to allow passing further * parameters. At this time the following options are supported: * * * persist: A string value of either "disk" (default), "memory" or "volatile". If "memory" is passed, the connection will not be saved to disk. If "volatile" is passed, the connection will not be saved to disk and will be destroyed when disconnected. * * bind-activation: Bind the activation lifetime. Set to "dbus-name" to automatically disconnect when the requesting process disappears from the bus. The default of "none" means the connection is kept activated normally. * * NOTE: will call AddAndActivateConnection(connection, interfaceUni, connectionParameter) instead when NetworkManager is older than 1.16, which means that the options property is ignored */ NETWORKMANAGERQT_EXPORT QDBusPendingReply addAndActivateConnection2(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter, const QVariantMap &options); /** * Deactivate this network interface, if active * * @param activeConnection identifier of the connection to deactivate */ NETWORKMANAGERQT_EXPORT QDBusPendingReply<> deactivateConnection(const QString &activeConnection); /** * Access the list of any active connections * * @return a list of valid ActiveConnection objects */ NETWORKMANAGERQT_EXPORT ActiveConnection::List activeConnections(); /** * Access the list of any active connections paths * * @return a list of valid ActiveConnection paths */ NETWORKMANAGERQT_EXPORT QStringList activeConnectionsPaths(); /** * Get current logging verbosity level and operations domains */ NETWORKMANAGERQT_EXPORT QDBusPendingReply getLogging(); /** * @return the network connectivity state * @since 0.9.9.0 */ NETWORKMANAGERQT_EXPORT Connectivity connectivity(); /** * Re-check the network connectivity state. * @see connectivity() * @since 0.9.9.0 */ NETWORKMANAGERQT_EXPORT QDBusPendingReply checkConnectivity(); /** * @return the "primary" active connection being used * to access the network. In particular, if there is no VPN * active, or the VPN does not have the default route, then this * indicates the connection that has the default route. If there * is a VPN active with the default route, then this indicates * the connection that contains the route to the VPN endpoint. * @since 0.9.9.0 */ NETWORKMANAGERQT_EXPORT ActiveConnection::Ptr primaryConnection(); /** * @return an active connection that is currently * being activated and which is expected to become the new * primaryConnection() when it finishes activating. * @since 0.9.9.0 */ NETWORKMANAGERQT_EXPORT ActiveConnection::Ptr activatingConnection(); /** * @return The connection type of the "primary" active connection being * used to access the network. This is the same as the Type * property on the object indicated by PrimaryConnection. * @since 5.8.0 */ NETWORKMANAGERQT_EXPORT NetworkManager::ConnectionSettings::ConnectionType primaryConnectionType(); /** * Indicates whether NM is still starting up; this becomes @p false * when NM has finished attempting to activate every connection * that it might be able to activate at startup. * @since 0.9.9.0 */ NETWORKMANAGERQT_EXPORT bool isStartingUp(); /** * @return Indicates whether the connectivity is metered. * @since 5.14.0 */ NETWORKMANAGERQT_EXPORT NetworkManager::Device::MeteredStatus metered(); /** * @return Gets the global DNS configuration. * @since 5.45.0 */ NETWORKMANAGERQT_EXPORT NetworkManager::DnsConfiguration globalDnsConfiguration(); /** * @return Sets the global DNS configuration. * @since 5.45.0 */ NETWORKMANAGERQT_EXPORT void setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration); /** * Find an ActiveConnection object for an active connection id * * @param uni the id of the ActiveConnection * @return a valid ActiveConnection object */ NETWORKMANAGERQT_EXPORT ActiveConnection::Ptr findActiveConnection(const QString &uni); /** * Retrieves the interface types supported by this network manager. * * @return the interface types supported by the network manager */ NETWORKMANAGERQT_EXPORT Device::Types supportedInterfaceTypes(); NETWORKMANAGERQT_EXPORT void setNetworkingEnabled(bool enabled); // implemented in Notifier NETWORKMANAGERQT_EXPORT void setWirelessEnabled(bool enabled); NETWORKMANAGERQT_EXPORT void setWwanEnabled(bool enabled); /** * @deprecated Wimax support was removed from NetworkManager 1.2 * (it is a noop in runtime NM >= 1.2.0). */ NETWORKMANAGERQT_EXPORT void setWimaxEnabled(bool enabled); NETWORKMANAGERQT_EXPORT void sleep(bool sleep); NETWORKMANAGERQT_EXPORT void setLogging(LogLevel, LogDomains); NETWORKMANAGERQT_EXPORT NMStringMap permissions(); NETWORKMANAGERQT_EXPORT Notifier *notifier(); } #endif diff --git a/src/manager_p.h b/src/manager_p.h index 6c5abc0..4367c1e 100644 --- a/src/manager_p.h +++ b/src/manager_p.h @@ -1,145 +1,131 @@ /* - Copyright 2008,2010 Will Stephenson - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2008, 2010 Will Stephenson + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_NETWORKMANAGER_P_H #define NETWORKMANAGERQT_NETWORKMANAGER_P_H #include #include #include "dbus/networkmanagerinterface.h" #include "device.h" #include "activeconnection.h" #include "manager.h" namespace NetworkManager { class Device; class ActiveConnection; class NetworkManagerPrivate : public NetworkManager::Notifier { Q_OBJECT public: static const QString DBUS_SERVICE; static const QString DBUS_DAEMON_INTERFACE; static const QString DBUS_DAEMON_PATH; static const QString DBUS_SETTINGS_PATH; static const QString FDO_DBUS_PROPERTIES; static const QString FDO_DBUS_OBJECT_MANAGER; // Functions useful also for other classes static QVariantMap retrieveInitialProperties(const QString &interfaceName, const QString &path); NetworkManagerPrivate(); ~NetworkManagerPrivate(); QDBusServiceWatcher watcher; OrgFreedesktopNetworkManagerInterface iface; NetworkManager::Status nmState; Connectivity m_connectivity; bool m_isNetworkingEnabled; bool m_isWimaxEnabled; //TODO: mark it deprecated somehow? bool m_isWimaxHardwareEnabled; bool m_isWirelessEnabled; bool m_isWirelessHardwareEnabled; bool m_isWwanEnabled; bool m_isWwanHardwareEnabled; QString m_activatingConnection; QString m_primaryConnection; NetworkManager::ConnectionSettings::ConnectionType m_primaryConnectionType; NetworkManager::Device::MeteredStatus m_metered; NetworkManager::DnsConfiguration m_globalDnsConfiguration; QString m_version; // to store NetworkManager's version. int m_x; int m_y; int m_z; void parseVersion(const QString &version); int compareVersion(const QString &version); int compareVersion(const int x, const int y, const int z) const; bool checkVersion(const int x, const int y, const int z) const; NetworkManager::Device::Types m_supportedInterfaceTypes; NetworkManager::Device::Types supportedInterfaceTypes() const; QMap m_activeConnections; ActiveConnection::Ptr findRegisteredActiveConnection(const QString &); // manage device children Device::Ptr findRegisteredNetworkInterface(const QString &uni); Device::Ptr createNetworkInterface(const QString &uni); QMap networkInterfaceMap; // for frontend to call QString version() const; NetworkManager::Status status() const; Device::List networkInterfaces(); Device::Ptr findNetworkInterface(const QString &uni); Device::Ptr findDeviceByIpIface(const QString &iface); bool isNetworkingEnabled() const; bool isWirelessEnabled() const; bool isWirelessHardwareEnabled() const; bool isWwanEnabled() const; bool isWwanHardwareEnabled() const; bool isWimaxEnabled() const; //TODO: mark it deprecated somehow? bool isWimaxHardwareEnabled() const; QDBusPendingReply activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter); QDBusPendingReply addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter); QDBusPendingReply addAndActivateConnection2(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter, const QVariantMap &options); QDBusPendingReply<> deactivateConnection(const QString &activeConnection); ActiveConnection::List activeConnections(); QStringList activeConnectionsPaths() const; QDBusPendingReply getLogging(); void setNetworkingEnabled(bool enabled); void setWirelessEnabled(bool enabled); void setWwanEnabled(bool enabled); //TODO: mark it deprecated somehow? void setWimaxEnabled(bool enabled); void sleep(bool sleep); void setLogging(NetworkManager::LogLevel, NetworkManager::LogDomains); NMStringMap permissions(); Connectivity connectivity() const; QDBusPendingReply checkConnectivity(); ActiveConnection::Ptr primaryConnection(); ActiveConnection::Ptr activatingConnection(); NetworkManager::ConnectionSettings::ConnectionType primaryConnectionType(); bool isStartingUp() const; NetworkManager::Device::MeteredStatus metered() const; NetworkManager::DnsConfiguration globalDnsConfiguration() const; void setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration); protected Q_SLOTS: void init(); void onDeviceAdded(const QDBusObjectPath &state); void onDeviceRemoved(const QDBusObjectPath &state); void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); void propertiesChanged(const QVariantMap &changedProperties); void interfacesAdded(const QDBusObjectPath &path, const QVariantMap &addedInterfaces); void daemonUnregistered(); private: void connectivityChanged(uint connectivity); void stateChanged(uint state); static NetworkManager::Connectivity convertConnectivity(uint connectivity); static NetworkManager::Status convertNMState(uint state); }; } #endif diff --git a/src/modemdevice.cpp b/src/modemdevice.cpp index 82f0db5..18913f4 100644 --- a/src/modemdevice.cpp +++ b/src/modemdevice.cpp @@ -1,102 +1,88 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2011-2013 Lamarque Souza - Copyright 2013 Daniel Nicoletti - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque Souza + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "modemdevice.h" #include "modemdevice_p.h" #include "manager_p.h" NetworkManager::ModemDevice::Capabilities convertModemCapabilities(uint theirCaps) { NetworkManager::ModemDevice::Capabilities ourCaps = (NetworkManager::ModemDevice::Capabilities) theirCaps; return ourCaps; } NetworkManager::ModemDevicePrivate::ModemDevicePrivate(const QString &path, ModemDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , modemIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , modemIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::ModemDevice::ModemDevice(const QString &path, QObject *parent) : Device(*new ModemDevicePrivate(path, this), parent) { Q_D(ModemDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->modemIface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::ModemDevice::ModemDevice(NetworkManager::ModemDevicePrivate &dd, QObject *parent) : Device(dd, parent) { Q_D(ModemDevice); QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::ModemDevice::~ModemDevice() { } NetworkManager::Device::Type NetworkManager::ModemDevice::type() const { return NetworkManager::Device::Modem; } NetworkManager::ModemDevice::Capabilities NetworkManager::ModemDevice::currentCapabilities() const { Q_D(const ModemDevice); return d->currentCapabilities; } NetworkManager::ModemDevice::Capabilities NetworkManager::ModemDevice::modemCapabilities() const { Q_D(const ModemDevice); return d->modemCapabilities; } void NetworkManager::ModemDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(ModemDevice); if (property == QLatin1String("CurrentCapabilities")) { currentCapabilities = convertModemCapabilities(value.toUInt()); Q_EMIT q->currentCapabilitiesChanged(currentCapabilities); } else if (property == QLatin1String("ModemCapabilities")) { modemCapabilities = convertModemCapabilities(value.toUInt()); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/modemdevice.h b/src/modemdevice.h index 1ce8703..249940a 100644 --- a/src/modemdevice.h +++ b/src/modemdevice.h @@ -1,79 +1,65 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MODEMDEVICE_H #define NETWORKMANAGERQT_MODEMDEVICE_H #include "device.h" #include namespace NetworkManager { class ModemDevicePrivate; /** * Represents a generic modem device, generally defined by the modemCapabilities() it exposes and at * the current point in time by the currentCapabilities(). */ class NETWORKMANAGERQT_EXPORT ModemDevice : public Device { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; enum Capability { NoCapability = 0x0, Pots = 0x1, CdmaEvdo = 0x2, GsmUmts = 0x4, Lte = 0x8 }; Q_DECLARE_FLAGS(Capabilities, Capability) explicit ModemDevice(const QString &path, QObject *parent = nullptr); explicit ModemDevice(ModemDevicePrivate &dd, QObject *parent = nullptr); ~ModemDevice() override; /** * Return the type */ Type type() const override; /** * The generic family of access technologies the modem supports. Not all capabilities are * available at the same time however; some modems require a firmware reload or other * reinitialization to switch between eg CDMA/EVDO and GSM/UMTS. */ Capabilities modemCapabilities() const; /** * The generic family of access technologies the modem currently supports without a firmware * reload or reinitialization. */ Capabilities currentCapabilities() const; Q_SIGNALS: /** * This signal is emitted when the capabilities of the device change */ void currentCapabilitiesChanged(Capabilities); private: Q_DECLARE_PRIVATE(ModemDevice) }; Q_DECLARE_OPERATORS_FOR_FLAGS(ModemDevice::Capabilities) } // namespace NetworkManager #endif diff --git a/src/modemdevice_p.h b/src/modemdevice_p.h index d1e39b4..d56eec0 100644 --- a/src/modemdevice_p.h +++ b/src/modemdevice_p.h @@ -1,53 +1,39 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MODEMDEVICE_P_H #define NETWORKMANAGERQT_MODEMDEVICE_P_H #include "device_p.h" #include "dbus/modemdeviceinterface.h" namespace NetworkManager { class ModemDevicePrivate : public DevicePrivate { Q_OBJECT public: explicit ModemDevicePrivate(const QString &path, ModemDevice *q); void initModemProperties(); OrgFreedesktopNetworkManagerDeviceModemInterface modemIface; NetworkManager::ModemDevice::Capabilities modemCapabilities; NetworkManager::ModemDevice::Capabilities currentCapabilities; Q_DECLARE_PUBLIC(ModemDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } // namespace NetworkManager #endif diff --git a/src/nmdebug.h b/src/nmdebug.h index 6db2d03..1151980 100644 --- a/src/nmdebug.h +++ b/src/nmdebug.h @@ -1,28 +1,14 @@ /* - Copyright 2011-2013 Lamarque Souza + SPDX-FileCopyrightText: 2011-2013 Lamarque Souza - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_NMDEBUG_H #define NETWORKMANAGERQT_NMDEBUG_H #include Q_DECLARE_LOGGING_CATEGORY(NMQT) #endif diff --git a/src/olpcmeshdevice.cpp b/src/olpcmeshdevice.cpp index 1997ccf..438e902 100644 --- a/src/olpcmeshdevice.cpp +++ b/src/olpcmeshdevice.cpp @@ -1,95 +1,81 @@ /* - Copyright 2011 Ilia Kats - Copyright 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2013 Daniel Nicoletti - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "olpcmeshdevice.h" #include "olpcmeshdevice_p.h" #include "manager_p.h" #include "wimaxnsp.h" NetworkManager::OlpcMeshDevicePrivate::OlpcMeshDevicePrivate(const QString &path, OlpcMeshDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::OlpcMeshDevice::OlpcMeshDevice(const QString &path, QObject *parent) : Device(*new OlpcMeshDevicePrivate(path, this), parent) { Q_D(OlpcMeshDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::OlpcMeshDevice::~OlpcMeshDevice() { } NetworkManager::Device::Type NetworkManager::OlpcMeshDevice::type() const { return NetworkManager::Device::OlpcMesh; } QString NetworkManager::OlpcMeshDevice::hardwareAddress() const { Q_D(const OlpcMeshDevice); return d->hardwareAddress; } uint NetworkManager::OlpcMeshDevice::activeChannel() const { Q_D(const OlpcMeshDevice); return d->activeChannel; } NetworkManager::Device::Ptr NetworkManager::OlpcMeshDevice::companionDevice() const { Q_D(const OlpcMeshDevice); return NetworkManager::findNetworkInterface(d->companion); } void NetworkManager::OlpcMeshDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(OlpcMeshDevice); if (property == QLatin1String("ActiveChannel")) { activeChannel = value.toUInt(); Q_EMIT q->activeChannelChanged(activeChannel); } else if (property == QLatin1String("HwAddress")) { hardwareAddress = value.toString(); Q_EMIT q->hardwareAddressChanged(hardwareAddress); } else if (property == QLatin1String("Companion")) { companion = qdbus_cast(value).path(); Q_EMIT q->companionChanged(NetworkManager::findNetworkInterface(companion)); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/olpcmeshdevice.h b/src/olpcmeshdevice.h index 0ef415f..d9fc6c8 100644 --- a/src/olpcmeshdevice.h +++ b/src/olpcmeshdevice.h @@ -1,93 +1,79 @@ /* - Copyright 2011 Ilia Kats - Copyright 2011-2013 Lamarque Souza + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2011-2013 Lamarque Souza - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OLPCMESHDEVICE_H #define NETWORKMANAGERQT_OLPCMESHDEVICE_H #include "device.h" #include #include namespace NetworkManager { class OlpcMeshDevicePrivate; /** * A OLPC mesh interface */ class NETWORKMANAGERQT_EXPORT OlpcMeshDevice : public Device { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; /** * Creates a new OlpcMeshDevice object. * * @param path the DBus path of the device */ explicit OlpcMeshDevice(const QString &path, QObject *parent = nullptr); /** * Destroys a OlpcMeshDevice object. */ ~OlpcMeshDevice() override; /** * Return the type */ Type type() const override; /** * Currently active channel. */ uint activeChannel() const; /** * The hardware address currently used by the network interface */ QString hardwareAddress() const; /** * The current companion device. */ Device::Ptr companionDevice() const; Q_SIGNALS: /** * The active channel changed. */ void activeChannelChanged(uint); /** * The companion changed. */ void companionChanged(const Device::Ptr &device); /** * The device changed its hardware address */ void hardwareAddressChanged(const QString &); private: Q_DECLARE_PRIVATE(OlpcMeshDevice) }; } // namespace NetworkManager #endif //NETWORKMANAGERQT_OLPCMESHDEVICE_H diff --git a/src/olpcmeshdevice_p.h b/src/olpcmeshdevice_p.h index 48b5219..7343d7f 100644 --- a/src/olpcmeshdevice_p.h +++ b/src/olpcmeshdevice_p.h @@ -1,52 +1,38 @@ /* - Copyright 2011 Ilia Kats - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Ilia Kats + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OLPCMESHDEVICE_P_H #define NETWORKMANAGERQT_OLPCMESHDEVICE_P_H #include "device_p.h" #include "dbus/olpcmeshdeviceinterface.h" namespace NetworkManager { class OlpcMeshDevicePrivate : public DevicePrivate { Q_OBJECT public: explicit OlpcMeshDevicePrivate(const QString &path, OlpcMeshDevice *q); OrgFreedesktopNetworkManagerDeviceOlpcMeshInterface iface; uint activeChannel; QString companion; QString hardwareAddress; Q_DECLARE_PUBLIC(OlpcMeshDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/secretagent.cpp b/src/secretagent.cpp index 7776ac3..7502ea5 100644 --- a/src/secretagent.cpp +++ b/src/secretagent.cpp @@ -1,133 +1,119 @@ /* - Copyright 2011 Ilia Kats - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Ilia Kats + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "secretagent.h" #include "secretagent_p.h" #include "manager_p.h" #include "nmdebug.h" #undef signals #include #include #define signals Q_SIGNALS #include #include "agentmanagerinterface.h" #include "secretagentadaptor.h" NetworkManager::SecretAgentPrivate::SecretAgentPrivate(const QString &id, NetworkManager::SecretAgent *parent) : q_ptr(parent) , agent(parent) #ifdef NMQT_STATIC , agentManager(NetworkManagerPrivate::DBUS_SERVICE, QLatin1String(NM_DBUS_PATH_AGENT_MANAGER), QDBusConnection::sessionBus(), parent) #else , agentManager(NetworkManagerPrivate::DBUS_SERVICE, QLatin1String(NM_DBUS_PATH_AGENT_MANAGER), QDBusConnection::systemBus(), parent) #endif , agentId(id) { Q_Q(SecretAgent); qRegisterMetaType("NMVariantMapMap"); qDBusRegisterMetaType(); agentManager.connection().connect(NetworkManagerPrivate::DBUS_SERVICE, "/org/freedesktop", NetworkManagerPrivate::FDO_DBUS_OBJECT_MANAGER, QLatin1String("InterfacesAdded"), q, SLOT(dbusInterfacesAdded(QDBusObjectPath,QVariantMap))); agentManager.connection().registerObject(QLatin1String(NM_DBUS_PATH_SECRET_AGENT), &agent, QDBusConnection::ExportAllSlots); registerAgent(); } NetworkManager::SecretAgentPrivate::~SecretAgentPrivate() { agentManager.Unregister(); } void NetworkManager::SecretAgentPrivate::dbusInterfacesAdded(const QDBusObjectPath &path, const QVariantMap &interfaces) { Q_UNUSED(path); if(!interfaces.contains(QString::fromLatin1(agentManager.staticInterfaceName()))) return; registerAgent(); } void NetworkManager::SecretAgentPrivate::registerAgent() { agentManager.Register(agentId); } NetworkManager::SecretAgent::SecretAgent(const QString &id, QObject *parent) : QObject(parent) , QDBusContext() , d_ptr(new NetworkManager::SecretAgentPrivate(id, this)) { } NetworkManager::SecretAgent::~SecretAgent() { Q_D(SecretAgent); delete d; } void NetworkManager::SecretAgent::sendError(NetworkManager::SecretAgent::Error error, const QString &explanation, const QDBusMessage &callMessage) const { Q_D(const SecretAgent); QString errorString; switch (error) { case NotAuthorized: errorString = QStringLiteral(NM_DBUS_INTERFACE_SECRET_AGENT) % QStringLiteral(".NotAuthorized"); break; case InvalidConnection: errorString = QStringLiteral(NM_DBUS_INTERFACE_SECRET_AGENT) % QStringLiteral(".InvalidConnection"); break; case UserCanceled: errorString = QStringLiteral(NM_DBUS_INTERFACE_SECRET_AGENT) % QStringLiteral(".UserCanceled"); break; case AgentCanceled: errorString = QStringLiteral(NM_DBUS_INTERFACE_SECRET_AGENT) % QStringLiteral(".AgentCanceled"); break; case InternalError: errorString = QStringLiteral(NM_DBUS_INTERFACE_SECRET_AGENT) % QStringLiteral(".InternalError"); break; case NoSecrets: errorString = QStringLiteral(NM_DBUS_INTERFACE_SECRET_AGENT) % QStringLiteral(".NoSecrets"); break; default: errorString = QStringLiteral(NM_DBUS_INTERFACE_SECRET_AGENT) % QStringLiteral(".Unknown"); break; } QDBusMessage reply; if (callMessage.type() == QDBusMessage::InvalidMessage) { reply = message().createErrorReply(errorString, explanation); } else { reply = callMessage.createErrorReply(errorString, explanation); } if (!d->agentManager.connection().send(reply)) { qCDebug(NMQT) << "Failed to put error message on DBus queue" << errorString << explanation; } } #include "moc_secretagent.cpp" diff --git a/src/secretagent.h b/src/secretagent.h index f40bf27..78de4a7 100644 --- a/src/secretagent.h +++ b/src/secretagent.h @@ -1,142 +1,128 @@ /* - Copyright 2011 Ilia Kats - Copyright 2011-2013 Lamarque Souza - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2011-2013 Lamarque Souza + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SECRETAGENT_H #define NETWORKMANAGERQT_SECRETAGENT_H #include #include #include #include #include #include "generictypes.h" namespace NetworkManager { class SecretAgentPrivate; /** * Implementation of a private D-Bus interface used by secret agents that store and provide secrets to NetworkManager. * If an agent provides secrets to NetworkManager as part of connection creation, and the some of those secrets are "agent owned" * the agent should store those secrets itself and should not expect its SaveSecrets() method to be called. * SaveSecrets() will be called eg if some program other than the agent itself (like a connection editor) changes the secrets out of band. */ class NETWORKMANAGERQT_EXPORT SecretAgent : public QObject, protected QDBusContext { Q_OBJECT public: enum Error { NotAuthorized, InvalidConnection, UserCanceled, AgentCanceled, InternalError, NoSecrets }; /** * Flags modifying the behavior of GetSecrets request. */ enum GetSecretsFlag { None = 0, /**< No special behavior; by default no user interaction is allowed and requests for secrets are fulfilled from persistent storage, or if no secrets are available an error is returned. */ AllowInteraction = 0x01, /**< Allows the request to interact with the user, possibly prompting via UI for secrets if any are required, or if none are found in persistent storage. */ RequestNew = 0x02, /**< Explicitly prompt for new secrets from the user. This flag signals that NetworkManager thinks any existing secrets are invalid or wrong. This flag implies that interaction is allowed. */ UserRequested = 0x04 /**< Set if the request was initiated by user-requested action via the D-Bus interface, as opposed to automatically initiated by NetworkManager in response to (for example) scan results or carrier changes. */ }; Q_DECLARE_FLAGS(GetSecretsFlags, GetSecretsFlag) /** * Registers a SecretAgent with the \p id on NetworkManager */ explicit SecretAgent(const QString &id, QObject *parent = nullptr); virtual ~SecretAgent(); /** * Send to NetworkManager the \p error the subclass has * found, the \p explanation is useful for debugging purposes, * and the \p callMessage is ONLY needed if \ref setDelayedReply() * was set to @p true when the method was called. */ void sendError(Error error, const QString &explanation, const QDBusMessage &callMessage = QDBusMessage()) const; public Q_SLOTS: /** * Called when the subclass should retrieve and return secrets. * If the request is canceled, called function should call * \ref sendError(), in this case the return value is ignored. * * @param connection Nested settings maps containing the connection for which secrets are being requested. * This may contain system-owned secrets if the agent has successfully authenticated to modify system network settings * and the GetSecrets request flags allow user interaction. * @param connection_path Object path of the connection for which secrets are being requested. * @param setting_name Setting name for which secrets are being requested. * @param hints Array of strings of key names in the requested setting for which NetworkManager thinks a secrets may be required, * and/or well-known identifiers and data that may be useful to the client in processing the secrets request. Note that it's not * always possible to determine which secret is required, so in some cases no hints may be given. The Agent should return any * secrets it has, or that it thinks are required, regardless of what hints NetworkManager sends in this request. * @param flags Flags which modify the behavior of the secrets request (see @ref GetSecretsFlag) */ virtual NMVariantMapMap GetSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path, const QString &setting_name, const QStringList &hints, uint flags) = 0; /** * Called when the subclass should cancel an outstanding request to * get secrets for a given connection. * Cancelling the request MUST \ref sendError() with the original * DBus message using \ref AgentCanceled param as the error type. * * @param connection_path Object path of the connection for which, if secrets for the given 'setting_name' are being requested, the request should be canceled. * @param setting_name Setting name for which secrets for this connection were originally being requested. */ virtual void CancelGetSecrets(const QDBusObjectPath &connection_path, const QString &setting_name) = 0; /** * Called when the subclass should save the secrets contained in the * connection to backing storage. * * @param connection Nested settings maps containing the connection for which secrets are being saved. * This may contain system-owned secrets if the agent has successfully authenticated to modify system network settings * and the GetSecrets request flags allow user interaction. * @param connection_path Object path of the connection for which the agent should save secrets to backing storage. */ virtual void SaveSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path) = 0; /** * Called when the subclass should delete the secrets contained in the * connection from backing storage. * * @param connection Nested settings maps containing the connection properties (sans secrets), * for which the agent should delete the secrets from backing storage. * @param connection_path Object path of the connection for which the agent should delete secrets from backing storage. */ virtual void DeleteSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path) = 0; private: Q_DECLARE_PRIVATE(SecretAgent) Q_PRIVATE_SLOT(d_func(), void registerAgent()) Q_PRIVATE_SLOT(d_func(), void dbusInterfacesAdded(const QDBusObjectPath &path, const QVariantMap &interfaces)) SecretAgentPrivate *const d_ptr; }; } Q_DECLARE_OPERATORS_FOR_FLAGS(NetworkManager::SecretAgent::GetSecretsFlags) #endif // NETWORKMANAGERQT_SECRETAGENT_H diff --git a/src/secretagent_p.h b/src/secretagent_p.h index ec2cc5a..e5b9a9d 100644 --- a/src/secretagent_p.h +++ b/src/secretagent_p.h @@ -1,48 +1,34 @@ /* - Copyright 2011 Ilia Kats + SPDX-FileCopyrightText: 2011 Ilia Kats - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SECRETAGENT_P_H #define NETWORKMANAGERQT_SECRETAGENT_P_H #include "agentmanagerinterface.h" #include "secretagentadaptor.h" namespace NetworkManager { class SecretAgent; class SecretAgentPrivate { Q_DECLARE_PUBLIC(SecretAgent) public: explicit SecretAgentPrivate(const QString &, SecretAgent *parent = nullptr); virtual ~SecretAgentPrivate(); private Q_SLOTS: void dbusInterfacesAdded(const QDBusObjectPath &path, const QVariantMap &interfaces); void registerAgent(); private: SecretAgent *q_ptr; SecretAgentAdaptor agent; OrgFreedesktopNetworkManagerAgentManagerInterface agentManager; QString agentId; }; } #endif // NETWORKMANAGERQT_SECRETAGENT_P_H diff --git a/src/settings.cpp b/src/settings.cpp index 4fdc63f..cbbebdf 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,275 +1,261 @@ /* - Copyright 2011-2013 Lamarque Souza - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011-2013 Lamarque Souza + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "settings.h" #include "settings_p.h" #include "macros.h" #include "connection.h" #include "manager_p.h" #include #include #include "nmdebug.h" //NM_GLOBAL_STATIC(NetworkManager::SettingsPrivate, globalSettings) Q_GLOBAL_STATIC(NetworkManager::SettingsPrivate, globalSettings) NetworkManager::SettingsPrivate::SettingsPrivate() #ifdef NMQT_STATIC : iface(NetworkManagerPrivate::DBUS_SERVICE, NetworkManagerPrivate::DBUS_SETTINGS_PATH, QDBusConnection::sessionBus()) #else : iface(NetworkManagerPrivate::DBUS_SERVICE, NetworkManagerPrivate::DBUS_SETTINGS_PATH, QDBusConnection::systemBus()) #endif , m_canModify(true) { QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, NetworkManagerPrivate::DBUS_SETTINGS_PATH, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), this, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); connect(&iface, &OrgFreedesktopNetworkManagerSettingsInterface::NewConnection, this, &SettingsPrivate::onConnectionAdded); connect(&iface, &OrgFreedesktopNetworkManagerSettingsInterface::ConnectionRemoved, this, static_cast(&SettingsPrivate::onConnectionRemoved)); init(); // This class is a friend of NetworkManagerPrivate thus initted there too // because of the init chain we must follow, // But if this class is used first we need to make sure the // NetworkManagerPrivate also get created so we have its signals for // when the daemon dies, we just can not call it directly here or // we will have a constructor infinite loop QTimer::singleShot(0, this, SLOT(initNotifier())); } void NetworkManager::SettingsPrivate::init() { QList connectionList = iface.connections(); qCDebug(NMQT) << "Connections list"; Q_FOREACH (const QDBusObjectPath & connection, connectionList) { if (!connections.contains(connection.path())) { connections.insert(connection.path(), Connection::Ptr()); Q_EMIT connectionAdded(connection.path()); qCDebug(NMQT) << " " << connection.path(); } } // Get all Setting's properties at once QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(iface.staticInterfaceName(), NetworkManagerPrivate::DBUS_SETTINGS_PATH); if (!initialProperties.isEmpty()) { propertiesChanged(initialProperties); } } NetworkManager::Connection::List NetworkManager::SettingsPrivate::listConnections() { NetworkManager::Connection::List list; QMap::const_iterator i = connections.constBegin(); while (i != connections.constEnd()) { NetworkManager::Connection::Ptr connection = findRegisteredConnection(i.key()); if (connection) { list << connection; } ++i; } return list; } NetworkManager::Connection::Ptr NetworkManager::SettingsPrivate::findConnectionByUuid(const QString &uuid) { QMap::const_iterator i = connections.constBegin(); while (i != connections.constEnd()) { NetworkManager::Connection::Ptr connection = findRegisteredConnection(i.key()); if (connection && connection->uuid() == uuid) { return connection; } ++i; } return NetworkManager::Connection::Ptr(); } QString NetworkManager::SettingsPrivate::hostname() const { return m_hostname; } bool NetworkManager::SettingsPrivate::canModify() const { return m_canModify; } QDBusPendingReply NetworkManager::SettingsPrivate::addConnection(const NMVariantMapMap &connection) { return iface.AddConnection(connection); } QDBusPendingReply NetworkManager::SettingsPrivate::addConnectionUnsaved(const NMVariantMapMap &connection) { return iface.AddConnectionUnsaved(connection); } QDBusPendingReply NetworkManager::SettingsPrivate::loadConnections(const QStringList &filenames) { return iface.LoadConnections(filenames); } QDBusPendingReply NetworkManager::SettingsPrivate::reloadConnections() { return iface.ReloadConnections(); } void NetworkManager::SettingsPrivate::initNotifier() { notifier(); } void NetworkManager::SettingsPrivate::saveHostname(const QString &hostname) { iface.SaveHostname(hostname); } void NetworkManager::SettingsPrivate::dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties) { Q_UNUSED(invalidatedProperties); if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.Settings")) { propertiesChanged(properties); } } void NetworkManager::SettingsPrivate::propertiesChanged(const QVariantMap &properties) { QVariantMap::const_iterator it = properties.constBegin(); while (it != properties.constEnd()) { const QString property = it.key(); if (property == QLatin1String("CanModify")) { m_canModify = it->toBool(); Q_EMIT canModifyChanged(m_canModify); } else if (property == QLatin1String("Hostname")) { m_hostname = it->toString(); Q_EMIT hostnameChanged(m_hostname); } else if (property == QLatin1String("Connections")) { //will never get here in runtime NM < 0.9.10 // TODO some action?? } else { qCWarning(NMQT) << Q_FUNC_INFO << "Unhandled property" << property; } ++it; } } void NetworkManager::SettingsPrivate::onConnectionAdded(const QDBusObjectPath &path) { const QString id = path.path(); if (connections.contains(id)) { return; } connections.insert(id, Connection::Ptr()); Q_EMIT connectionAdded(id); } NetworkManager::Connection::Ptr NetworkManager::SettingsPrivate::findRegisteredConnection(const QString &path) { Connection::Ptr ret; if (!path.isEmpty()) { bool contains = connections.contains(path); if (contains && connections.value(path)) { ret = connections.value(path); } else { ret = Connection::Ptr(new Connection(path), &QObject::deleteLater); connections[path] = ret; connect(ret.data(), SIGNAL(removed(QString)), this, SLOT(onConnectionRemoved(QString))); if (!contains) { Q_EMIT connectionAdded(path); } } } return ret; } void NetworkManager::SettingsPrivate::onConnectionRemoved(const QDBusObjectPath &path) { onConnectionRemoved(path.path()); } void NetworkManager::SettingsPrivate::onConnectionRemoved(const QString &path) { connections.remove(path); Q_EMIT connectionRemoved(path); } void NetworkManager::SettingsPrivate::daemonUnregistered() { connections.clear(); } NetworkManager::Connection::List NetworkManager::listConnections() { return globalSettings->listConnections(); } NetworkManager::Connection::Ptr NetworkManager::findConnectionByUuid(const QString &uuid) { return globalSettings->findConnectionByUuid(uuid); } NetworkManager::Connection::Ptr NetworkManager::findConnection(const QString &path) { return globalSettings->findRegisteredConnection(path); } QDBusPendingReply NetworkManager::addConnection(const NMVariantMapMap &connection) { return globalSettings->addConnection(connection); } QDBusPendingReply NetworkManager::addConnectionUnsaved(const NMVariantMapMap &connection) { return globalSettings->addConnectionUnsaved(connection); } QDBusPendingReply< bool, QStringList > NetworkManager::loadConnections(const QStringList &filenames) { return globalSettings->loadConnections(filenames); } QDBusPendingReply< bool > NetworkManager::reloadConnections() { return globalSettings->reloadConnections(); } void NetworkManager::saveHostname(const QString &hostname) { globalSettings->saveHostname(hostname); } bool NetworkManager::canModify() { return globalSettings->canModify(); } QString NetworkManager::hostname() { return globalSettings->hostname(); } NetworkManager::SettingsNotifier *NetworkManager::settingsNotifier() { return globalSettings; } diff --git a/src/settings.h b/src/settings.h index 9b347be..d7aa55a 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,180 +1,166 @@ /* - Copyright 2011 Ilia Kats - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SETTINGS_H #define NETWORKMANAGERQT_SETTINGS_H #include #include #include "generictypes.h" #include "manager.h" #include "connection.h" #include namespace NetworkManager { /** * This class manages provides access to connections and notify about new ones */ class NETWORKMANAGERQT_EXPORT SettingsNotifier : public QObject { Q_OBJECT Q_SIGNALS: /** * Emitted when the settings are modifiable by user * @param canModify @p true if the user can modify the settings */ void canModifyChanged(bool canModify); /** * Emitted when the hostname has changed * @param hostname new hostname */ void hostnameChanged(const QString &hostname); /** * Emitted when a new connection is added * * \note This signal is not emitted when the Network Manager * daemon starts, if you are interested in keeping an * updated listing of connections you must also watch for * NetworkManager::Notifier::serviceAppeared() and * NetworkManager::Notifier::serviceDisappeared() signals */ void connectionAdded(const QString &path); /** * Emitted when a new connection is removed * * \note This signal is not emitted when the Network Manager * daemon starts, if you are interested in keeping an * updated listing of connections you must also watch for * NetworkManager::Notifier::serviceAppeared() and * NetworkManager::Notifier::serviceDisappeared() signals */ void connectionRemoved(const QString &path); }; /** * Retrieves the list of connections. */ NETWORKMANAGERQT_EXPORT NetworkManager::Connection::List listConnections(); /** * Retrieves the connection for the given path, returns null if not found */ NETWORKMANAGERQT_EXPORT NetworkManager::Connection::Ptr findConnection(const QString &path); /** * Add new connection and save it to disk. This operation does not start * the network connection unless (1) device is idle and able to connect to * the network described by the new connection, and (2) the connection * is allowed to be started automatically. * Once the connection has been added, you will get a notification through * SettingsNotifier::connectionAddComplete() * * @returns Uuid of the new connection that was just added. * * @since 0.9.9.0 */ NETWORKMANAGERQT_EXPORT QDBusPendingReply addConnection(const NMVariantMapMap &settings); /** * Add new connection but do not save it to disk immediately. This * operation does not start the network connection unless (1) device is * idle and able to connect to the network described by the new connection, * and (2) the connection is allowed to be started automatically. * * Use the 'Save' method on the connection to save these changes * to disk. Note that unsaved changes will be lost if the * connection is reloaded from disk (either automatically on file * change or due to an explicit ReloadConnections call). * * Once the connection has been added, you will get a notification through * SettingsNotifier::connectionAddComplete() * * @returns Uuid of the new connection that was just added. * * @since 0.9.9.0 */ NETWORKMANAGERQT_EXPORT QDBusPendingReply addConnectionUnsaved(const NMVariantMapMap &settings); /** * Retrieves the connection for the given @p uuid, returns null if not found */ NETWORKMANAGERQT_EXPORT NetworkManager::Connection::Ptr findConnectionByUuid(const QString &uuid); /** * Loads or reloads the indicated connections from disk. You * should call this after making changes directly to an on-disk * connection file to make sure that NetworkManager sees the * changes. (If "monitor-connection-files" in NetworkManager.conf * is "true", then this will have no real effect, but is * harmless.) As with AddConnection(), this operation does not * necessarily start the network connection. * * @returns Success or failure of the operation as a whole. True if * NetworkManager at least tried to load the indicated * connections, even if it did not succeed. False if an error * occurred before trying to load the connections (eg, * permission denied). * * @returns Paths of connection files that could not be loaded. * * @since 0.9.9.0 */ NETWORKMANAGERQT_EXPORT QDBusPendingReply loadConnections(const QStringList &filenames); /** * Tells NetworkManager to reload all connection files from disk, * including noticing any added or deleted connection files. By * default, connections are re-read automatically any time they * change, so you only need to use this command if you have set * "monitor-connection-files=false" in NetworkManager.conf. * * @returns Success or failure. * * @since 0.9.9.0 */ NETWORKMANAGERQT_EXPORT QDBusPendingReply reloadConnections(); /** * Configure the following hostname */ NETWORKMANAGERQT_EXPORT void saveHostname(const QString &hostname); /** * Returns @p true if the user can modify the settings */ NETWORKMANAGERQT_EXPORT bool canModify(); /** * Returns hostname of the machine */ NETWORKMANAGERQT_EXPORT QString hostname(); /** * Notifier object for connecting signals */ NETWORKMANAGERQT_EXPORT SettingsNotifier *settingsNotifier(); } #endif diff --git a/src/settings/adslsetting.cpp b/src/settings/adslsetting.cpp index 8af9a03..b214614 100644 --- a/src/settings/adslsetting.cpp +++ b/src/settings/adslsetting.cpp @@ -1,287 +1,273 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "adslsetting.h" #include "adslsetting_p.h" #include #include NetworkManager::AdslSettingPrivate::AdslSettingPrivate() : name(NM_SETTING_ADSL_SETTING_NAME) , passwordFlags(Setting::None) , protocol(AdslSetting::UnknownProtocol) , encapsulation(AdslSetting::UnknownEncapsulation) , vpi(0) , vci(0) { } NetworkManager::AdslSetting::AdslSetting(): Setting(Setting::Adsl), d_ptr(new AdslSettingPrivate()) { } NetworkManager::AdslSetting::AdslSetting(const AdslSetting::Ptr &other) : Setting(other) , d_ptr(new AdslSettingPrivate()) { setUsername(other->username()); setPassword(other->password()); setProtocol(other->protocol()); setPasswordFlags(other->passwordFlags()); setProtocol(other->protocol()); setEncapsulation(other->encapsulation()); setVpi(other->vpi()); setVci(other->vci()); } NetworkManager::AdslSetting::~AdslSetting() { delete d_ptr; } QString NetworkManager::AdslSetting::name() const { Q_D(const AdslSetting); return d->name; } void NetworkManager::AdslSetting::setUsername(const QString &username) { Q_D(AdslSetting); d->username = username; } QString NetworkManager::AdslSetting::username() const { Q_D(const AdslSetting); return d->username; } void NetworkManager::AdslSetting::setPassword(const QString &password) { Q_D(AdslSetting); d->password = password; } QString NetworkManager::AdslSetting::password() const { Q_D(const AdslSetting); return d->password; } void NetworkManager::AdslSetting::setPasswordFlags(NetworkManager::Setting::SecretFlags flags) { Q_D(AdslSetting); d->passwordFlags = flags; } NetworkManager::Setting::SecretFlags NetworkManager::AdslSetting::passwordFlags() const { Q_D(const AdslSetting); return d->passwordFlags; } void NetworkManager::AdslSetting::setProtocol(NetworkManager::AdslSetting::Protocol protocol) { Q_D(AdslSetting); d->protocol = protocol; } NetworkManager::AdslSetting::Protocol NetworkManager::AdslSetting::protocol() const { Q_D(const AdslSetting); return d->protocol; } void NetworkManager::AdslSetting::setEncapsulation(NetworkManager::AdslSetting::Encapsulation encapsulation) { Q_D(AdslSetting); d->encapsulation = encapsulation; } NetworkManager::AdslSetting::Encapsulation NetworkManager::AdslSetting::encapsulation() const { Q_D(const AdslSetting); return d->encapsulation; } void NetworkManager::AdslSetting::setVpi(quint32 vpi) { Q_D(AdslSetting); d->vpi = vpi; } quint32 NetworkManager::AdslSetting::vpi() const { Q_D(const AdslSetting); return d->vpi; } void NetworkManager::AdslSetting::setVci(quint32 vci) { Q_D(AdslSetting); d->vci = vci; } quint32 NetworkManager::AdslSetting::vci() const { Q_D(const AdslSetting); return d->vci; } QStringList NetworkManager::AdslSetting::needSecrets(bool requestNew) const { QStringList secrets; if ((password().isEmpty() || requestNew) && !passwordFlags().testFlag(NotRequired)) { secrets << QLatin1String(NM_SETTING_ADSL_PASSWORD); } return secrets; } void NetworkManager::AdslSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_ADSL_USERNAME))) { setUsername(setting.value(QLatin1String(NM_SETTING_ADSL_USERNAME)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_ADSL_PASSWORD))) { setPassword(setting.value(QLatin1String(NM_SETTING_ADSL_PASSWORD)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_ADSL_PASSWORD_FLAGS))) { setPasswordFlags((Setting::SecretFlags)setting.value(QLatin1String(NM_SETTING_ADSL_PASSWORD_FLAGS)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_ADSL_PROTOCOL))) { const QString protocol = setting.value(QLatin1String(NM_SETTING_ADSL_PROTOCOL)).toString(); if (protocol == QLatin1String(NM_SETTING_ADSL_PROTOCOL_PPPOA)) { setProtocol(Pppoa); } else if (protocol == QLatin1String(NM_SETTING_ADSL_PROTOCOL_PPPOE)) { setProtocol(Pppoe); } else if (protocol == QLatin1String(NM_SETTING_ADSL_PROTOCOL_IPOATM)) { setProtocol(Ipoatm); } } if (setting.contains(QLatin1String(NM_SETTING_ADSL_ENCAPSULATION))) { const QString encapsulation = setting.value(QLatin1String(NM_SETTING_ADSL_ENCAPSULATION)).toString(); if (encapsulation == QLatin1String(NM_SETTING_ADSL_ENCAPSULATION_VCMUX)) { setEncapsulation(Vcmux); } else if (encapsulation == QLatin1String(NM_SETTING_ADSL_ENCAPSULATION_LLC)) { setEncapsulation(Llc); } } if (setting.contains(QLatin1String(NM_SETTING_ADSL_VPI))) { setVpi(setting.value(QLatin1String(NM_SETTING_ADSL_VPI)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_ADSL_VCI))) { setVci(setting.value(QLatin1String(NM_SETTING_ADSL_VCI)).toUInt()); } } QVariantMap NetworkManager::AdslSetting::toMap() const { QVariantMap setting; if (!username().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_ADSL_USERNAME), username()); } if (!password().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_ADSL_PASSWORD), password()); } if (passwordFlags() != None) { setting.insert(QLatin1String(NM_SETTING_ADSL_PASSWORD_FLAGS), (int)passwordFlags()); } switch (protocol()) { case Pppoa: setting.insert(QLatin1String(NM_SETTING_ADSL_PROTOCOL), QLatin1String(NM_SETTING_ADSL_PROTOCOL_PPPOA)); break; case Pppoe: setting.insert(QLatin1String(NM_SETTING_ADSL_PROTOCOL), QLatin1String(NM_SETTING_ADSL_PROTOCOL_PPPOE)); break; case Ipoatm: setting.insert(QLatin1String(NM_SETTING_ADSL_PROTOCOL), QLatin1String(NM_SETTING_ADSL_PROTOCOL_IPOATM)); break; case UnknownProtocol: break; } switch (encapsulation()) { case Vcmux: setting.insert(QLatin1String(NM_SETTING_ADSL_ENCAPSULATION), QLatin1String(NM_SETTING_ADSL_ENCAPSULATION_VCMUX)); break; case Llc: setting.insert(QLatin1String(NM_SETTING_ADSL_ENCAPSULATION), QLatin1String(NM_SETTING_ADSL_ENCAPSULATION_LLC)); break; case UnknownEncapsulation: break; } if (vpi()) { setting.insert(QLatin1String(NM_SETTING_ADSL_VPI), vpi()); } if (vci()) { setting.insert(QLatin1String(NM_SETTING_ADSL_VCI), vci()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::AdslSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_ADSL_USERNAME << ": " << setting.username() << '\n'; dbg.nospace() << NM_SETTING_ADSL_PASSWORD << ": " << setting.password() << '\n'; dbg.nospace() << NM_SETTING_ADSL_PASSWORD_FLAGS << ": " << setting.passwordFlags() << '\n'; dbg.nospace() << NM_SETTING_ADSL_PROTOCOL << ": " << setting.protocol() << '\n'; dbg.nospace() << NM_SETTING_ADSL_ENCAPSULATION << ": " << setting.encapsulation() << '\n'; dbg.nospace() << NM_SETTING_ADSL_VPI << ": " << setting.vpi() << '\n'; dbg.nospace() << NM_SETTING_ADSL_VCI << ": " << setting.vci() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/adslsetting.h b/src/settings/adslsetting.h index b795353..29551d8 100644 --- a/src/settings/adslsetting.h +++ b/src/settings/adslsetting.h @@ -1,89 +1,75 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_ADSL_SETTING_H #define NETWORKMANAGERQT_ADSL_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class AdslSettingPrivate; /** * Represents adsl setting */ class NETWORKMANAGERQT_EXPORT AdslSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum Protocol {UnknownProtocol = 0, Pppoa, Pppoe, Ipoatm}; enum Encapsulation {UnknownEncapsulation = 0, Vcmux, Llc}; AdslSetting(); explicit AdslSetting(const Ptr &other); ~AdslSetting() override; QString name() const override; void setUsername(const QString &username); QString username() const; void setPassword(const QString &password); QString password() const; void setPasswordFlags(SecretFlags flags); SecretFlags passwordFlags() const; void setProtocol(Protocol protocol); Protocol protocol() const; void setEncapsulation(Encapsulation encapsulation); Encapsulation encapsulation() const; void setVpi(quint32 vpi); quint32 vpi() const; void setVci(quint32 vci); quint32 vci() const; QStringList needSecrets(bool requestNew = false) const override; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: AdslSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(AdslSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const AdslSetting &setting); } #endif // NETWORKMANAGERQT_ADSL_SETTING_H diff --git a/src/settings/adslsetting_p.h b/src/settings/adslsetting_p.h index 927f1e4..aca57f3 100644 --- a/src/settings/adslsetting_p.h +++ b/src/settings/adslsetting_p.h @@ -1,46 +1,32 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_ADSL_SETTING_P_H #define NETWORKMANAGERQT_ADSL_SETTING_P_H #include namespace NetworkManager { class AdslSettingPrivate { public: AdslSettingPrivate(); QString name; QString username; QString password; NetworkManager::Setting::SecretFlags passwordFlags; NetworkManager::AdslSetting::Protocol protocol; NetworkManager::AdslSetting::Encapsulation encapsulation; quint32 vpi; quint32 vci; }; } #endif // NETWORKMANAGERQT_ADSL_SETTING_P_H diff --git a/src/settings/bluetoothsetting.cpp b/src/settings/bluetoothsetting.cpp index 2c8657d..9e38bc0 100644 --- a/src/settings/bluetoothsetting.cpp +++ b/src/settings/bluetoothsetting.cpp @@ -1,132 +1,118 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bluetoothsetting.h" #include "bluetoothsetting_p.h" #include NetworkManager::BluetoothSettingPrivate::BluetoothSettingPrivate() : name(NM_SETTING_BLUETOOTH_SETTING_NAME) , profileType(BluetoothSetting::Unknown) { } NetworkManager::BluetoothSetting::BluetoothSetting() : Setting(Setting::Bluetooth) , d_ptr(new BluetoothSettingPrivate()) { } NetworkManager::BluetoothSetting::BluetoothSetting(const Ptr &other) : Setting(other) , d_ptr(new BluetoothSettingPrivate()) { setBluetoothAddress(other->bluetoothAddress()); setProfileType(other->profileType()); } NetworkManager::BluetoothSetting::~BluetoothSetting() { delete d_ptr; } QString NetworkManager::BluetoothSetting::name() const { Q_D(const BluetoothSetting); return d->name; } void NetworkManager::BluetoothSetting::setBluetoothAddress(const QByteArray &address) { Q_D(BluetoothSetting); d->bdaddr = address; } QByteArray NetworkManager::BluetoothSetting::bluetoothAddress() const { Q_D(const BluetoothSetting); return d->bdaddr; } void NetworkManager::BluetoothSetting::setProfileType(NetworkManager::BluetoothSetting::ProfileType type) { Q_D(BluetoothSetting); d->profileType = type; } NetworkManager::BluetoothSetting::ProfileType NetworkManager::BluetoothSetting::profileType() const { Q_D(const BluetoothSetting); return d->profileType; } void NetworkManager::BluetoothSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_BLUETOOTH_BDADDR))) { setBluetoothAddress(setting.value(QLatin1String(NM_SETTING_BLUETOOTH_BDADDR)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_BLUETOOTH_TYPE))) { const QString type = setting.value(QLatin1String(NM_SETTING_BLUETOOTH_TYPE)).toString(); if (type == QLatin1String(NM_SETTING_BLUETOOTH_TYPE_DUN)) { setProfileType(Dun); } else if (type == QLatin1String(NM_SETTING_BLUETOOTH_TYPE_PANU)) { setProfileType(Panu); } } } QVariantMap NetworkManager::BluetoothSetting::toMap() const { QVariantMap setting; if (!bluetoothAddress().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_BLUETOOTH_BDADDR), bluetoothAddress()); } switch (profileType()) { case Dun: setting.insert(QLatin1String(NM_SETTING_BLUETOOTH_TYPE), QLatin1String(NM_SETTING_BLUETOOTH_TYPE_DUN)); break; case Panu: setting.insert(QLatin1String(NM_SETTING_BLUETOOTH_TYPE), QLatin1String(NM_SETTING_BLUETOOTH_TYPE_PANU)); break; case Unknown: break; } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::BluetoothSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_BLUETOOTH_BDADDR << ": " << setting.bluetoothAddress() << '\n'; dbg.nospace() << NM_SETTING_BLUETOOTH_TYPE << ": " << setting.profileType() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/bluetoothsetting.h b/src/settings/bluetoothsetting.h index f042edc..7b41e50 100644 --- a/src/settings/bluetoothsetting.h +++ b/src/settings/bluetoothsetting.h @@ -1,71 +1,57 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BLUETOOTH_SETTING_H #define NETWORKMANAGERQT_BLUETOOTH_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class BluetoothSettingPrivate; /** * Represents bluetooth setting */ class NETWORKMANAGERQT_EXPORT BluetoothSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum ProfileType {Unknown = 0, Dun, Panu}; BluetoothSetting(); explicit BluetoothSetting(const Ptr &other); ~BluetoothSetting() override; QString name() const override; void setBluetoothAddress(const QByteArray &address); QByteArray bluetoothAddress() const; void setProfileType(ProfileType type); ProfileType profileType() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: BluetoothSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(BluetoothSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const BluetoothSetting &setting); } #endif // NETWORKMANAGERQT_SETTINGS_BLUETOOTH_H diff --git a/src/settings/bluetoothsetting_p.h b/src/settings/bluetoothsetting_p.h index 2930355..dcdb5ba 100644 --- a/src/settings/bluetoothsetting_p.h +++ b/src/settings/bluetoothsetting_p.h @@ -1,41 +1,27 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BLUETOOTH_SETTING_P_H #define NETWORKMANAGERQT_BLUETOOTH_SETTING_P_H #include namespace NetworkManager { class BluetoothSettingPrivate { public: BluetoothSettingPrivate(); QString name; QByteArray bdaddr; NetworkManager::BluetoothSetting::ProfileType profileType; }; } #endif // NETWORKMANAGERQT_BLUETOOTH_SETTING_P_H diff --git a/src/settings/bondsetting.cpp b/src/settings/bondsetting.cpp index 71dc33e..998a87f 100644 --- a/src/settings/bondsetting.cpp +++ b/src/settings/bondsetting.cpp @@ -1,125 +1,111 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bondsetting.h" #include "bondsetting_p.h" #define NM_SETTING_BOND_INTERFACE_NAME "interface-name" #include NetworkManager::BondSettingPrivate::BondSettingPrivate() : name(NM_SETTING_BOND_SETTING_NAME) { } NetworkManager::BondSetting::BondSetting() : Setting(Setting::Bond) , d_ptr(new BondSettingPrivate()) { } NetworkManager::BondSetting::BondSetting(const Ptr &other) : Setting(other) , d_ptr(new BondSettingPrivate()) { setInterfaceName(other->interfaceName()); setOptions(other->options()); } NetworkManager::BondSetting::~BondSetting() { delete d_ptr; } QString NetworkManager::BondSetting::name() const { Q_D(const BondSetting); return d->name; } void NetworkManager::BondSetting::setInterfaceName(const QString &name) { Q_D(BondSetting); d->interfaceName = name; } QString NetworkManager::BondSetting::interfaceName() const { Q_D(const BondSetting); return d->interfaceName; } void NetworkManager::BondSetting::addOption(const QString &option, const QString &value) { Q_D(BondSetting); d->options.insert(option, value); } void NetworkManager::BondSetting::setOptions(const NMStringMap &options) { Q_D(BondSetting); d->options = options; } NMStringMap NetworkManager::BondSetting::options() const { Q_D(const BondSetting); return d->options; } void NetworkManager::BondSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_BOND_INTERFACE_NAME))) { setInterfaceName(setting.value(QLatin1String(NM_SETTING_BOND_INTERFACE_NAME)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_BOND_OPTIONS))) { setOptions(qdbus_cast(setting.value(QLatin1String(NM_SETTING_BOND_OPTIONS)))); } } QVariantMap NetworkManager::BondSetting::toMap() const { QVariantMap setting; if (!interfaceName().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_BOND_INTERFACE_NAME), interfaceName()); } if (!options().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_BOND_OPTIONS), QVariant::fromValue(options())); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::BondSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_BOND_INTERFACE_NAME << ": " << setting.interfaceName() << '\n'; dbg.nospace() << NM_SETTING_BOND_OPTIONS << ": " << setting.options() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/bondsetting.h b/src/settings/bondsetting.h index 336a2b3..832eec5 100644 --- a/src/settings/bondsetting.h +++ b/src/settings/bondsetting.h @@ -1,71 +1,57 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BOND_SETTING_H #define NETWORKMANAGERQT_BOND_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class BondSettingPrivate; /** * Represents bond setting */ class NETWORKMANAGERQT_EXPORT BondSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; BondSetting(); explicit BondSetting(const Ptr &other); ~BondSetting() override; QString name() const override; /// @deprecated in favor of connection.interface-name in NM 1.0.0 void setInterfaceName(const QString &name); QString interfaceName() const; void addOption(const QString &option, const QString &value); void setOptions(const NMStringMap &options); NMStringMap options() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: BondSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(BondSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const BondSetting &setting); } #endif // NETWORKMANAGERQT_BOND_SETTING_H diff --git a/src/settings/bondsetting_p.h b/src/settings/bondsetting_p.h index 13bf757..7d1a3cf 100644 --- a/src/settings/bondsetting_p.h +++ b/src/settings/bondsetting_p.h @@ -1,41 +1,27 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BOND_SETTING_P_H #define NETWORKMANAGERQT_BOND_SETTING_P_H #include namespace NetworkManager { class BondSettingPrivate { public: BondSettingPrivate(); QString name; QString interfaceName; NMStringMap options; }; } #endif // NETWORKMANAGERQT_BOND_SETTING_P_H diff --git a/src/settings/bridgeportsetting.cpp b/src/settings/bridgeportsetting.cpp index e4a08f7..17ebd6f 100644 --- a/src/settings/bridgeportsetting.cpp +++ b/src/settings/bridgeportsetting.cpp @@ -1,145 +1,131 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bridgeportsetting.h" #include "bridgeportsetting_p.h" #include NetworkManager::BridgePortSettingPrivate::BridgePortSettingPrivate() : name(NM_SETTING_BRIDGE_PORT_SETTING_NAME) , priority(32) , pathCost(100) , hairpinMode(false) { } NetworkManager::BridgePortSetting::BridgePortSetting() : Setting(Setting::BridgePort) , d_ptr(new BridgePortSettingPrivate()) { } NetworkManager::BridgePortSetting::BridgePortSetting(const NetworkManager::BridgePortSetting::Ptr &other) : Setting(other) , d_ptr(new BridgePortSettingPrivate()) { setPriority(other->priority()); setPathCost(other->pathCost()); setHairpinMode(other->hairpinMode()); } NetworkManager::BridgePortSetting::~BridgePortSetting() { delete d_ptr; } QString NetworkManager::BridgePortSetting::name() const { Q_D(const BridgePortSetting); return d->name; } void NetworkManager::BridgePortSetting::setPriority(quint32 priority) { Q_D(BridgePortSetting); d->priority = priority; } quint32 NetworkManager::BridgePortSetting::priority() const { Q_D(const BridgePortSetting); return d->priority; } void NetworkManager::BridgePortSetting::setPathCost(quint32 cost) { Q_D(BridgePortSetting); d->pathCost = cost; } quint32 NetworkManager::BridgePortSetting::pathCost() const { Q_D(const BridgePortSetting); return d->pathCost; } void NetworkManager::BridgePortSetting::setHairpinMode(bool enable) { Q_D(BridgePortSetting); d->hairpinMode = enable; } bool NetworkManager::BridgePortSetting::hairpinMode() const { Q_D(const BridgePortSetting); return d->hairpinMode; } void NetworkManager::BridgePortSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_PORT_PRIORITY))) { setPriority(setting.value(QLatin1String(NM_SETTING_BRIDGE_PORT_PRIORITY)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_PORT_PATH_COST))) { setPathCost(setting.value(QLatin1String(NM_SETTING_BRIDGE_PORT_PATH_COST)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE))) { setHairpinMode(setting.value(QLatin1String(NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE)).toBool()); } } QVariantMap NetworkManager::BridgePortSetting::toMap() const { QVariantMap setting; if (priority() != 32) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_PORT_PRIORITY), priority()); } if (pathCost() != 100) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_PORT_PATH_COST), pathCost()); } if (hairpinMode()) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_PORT_PATH_COST), hairpinMode()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::BridgePortSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_PORT_PRIORITY << ": " << setting.priority() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_PORT_PATH_COST << ": " << setting.pathCost() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_PORT_PATH_COST << ": " << setting.hairpinMode() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/bridgeportsetting.h b/src/settings/bridgeportsetting.h index 9d9f2d6..c665698 100644 --- a/src/settings/bridgeportsetting.h +++ b/src/settings/bridgeportsetting.h @@ -1,72 +1,58 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BRIDGEPORT_SETTING_H #define NETWORKMANAGERQT_BRIDGEPORT_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class BridgePortSettingPrivate; /** * Represents bridge port setting */ class NETWORKMANAGERQT_EXPORT BridgePortSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; BridgePortSetting(); explicit BridgePortSetting(const Ptr &other); ~BridgePortSetting() override; QString name() const override; void setPriority(quint32 priority); quint32 priority() const; void setPathCost(quint32 cost); quint32 pathCost() const; void setHairpinMode(bool enable); bool hairpinMode() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: BridgePortSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(BridgePortSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const BridgePortSetting &setting); } #endif // NETWORKMANAGERQT_BRIDGEPORT_SETTING_H diff --git a/src/settings/bridgeportsetting_p.h b/src/settings/bridgeportsetting_p.h index 7e53cb2..08a8e9b 100644 --- a/src/settings/bridgeportsetting_p.h +++ b/src/settings/bridgeportsetting_p.h @@ -1,42 +1,28 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BRIDGEPORT_SETTING_P_H #define NETWORKMANAGERQT_BRIDGEPORT_SETTING_P_H #include namespace NetworkManager { class BridgePortSettingPrivate { public: BridgePortSettingPrivate(); QString name; quint32 priority; quint32 pathCost; bool hairpinMode; }; } #endif // NETWORKMANAGERQT_BRIDGEPORT_SETTING_P_H diff --git a/src/settings/bridgesetting.cpp b/src/settings/bridgesetting.cpp index d26a23f..9b7a980 100644 --- a/src/settings/bridgesetting.cpp +++ b/src/settings/bridgesetting.cpp @@ -1,293 +1,279 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "bridgesetting.h" #include "bridgesetting_p.h" #define NM_SETTING_BRIDGE_INTERFACE_NAME "interface-name" #include NetworkManager::BridgeSettingPrivate::BridgeSettingPrivate() : name(NM_SETTING_BRIDGE_SETTING_NAME) , multicastSnooping(true) , stp(true) , priority(128) , forwardDelay(15) , helloTime(2) , maxAge(20) , agingTime(300) { } NetworkManager::BridgeSetting::BridgeSetting() : Setting(Setting::Bridge) , d_ptr(new BridgeSettingPrivate()) { } NetworkManager::BridgeSetting::BridgeSetting(const Ptr &other) : Setting(other) , d_ptr(new BridgeSettingPrivate()) { setInterfaceName(other->interfaceName()); setStp(other->stp()); setPriority(other->priority()); setForwardDelay(other->forwardDelay()); setHelloTime(other->helloTime()); setMaxAge(other->maxAge()); setAgingTime(other->agingTime()); setMulticastSnooping(other->multicastSnooping()); setMacAddress(other->macAddress()); } NetworkManager::BridgeSetting::~BridgeSetting() { delete d_ptr; } QString NetworkManager::BridgeSetting::name() const { Q_D(const BridgeSetting); return d->name; } void NetworkManager::BridgeSetting::setInterfaceName(const QString &name) { Q_D(BridgeSetting); d->interfaceName = name; } QString NetworkManager::BridgeSetting::interfaceName() const { Q_D(const BridgeSetting); return d->interfaceName; } void NetworkManager::BridgeSetting::setStp(bool enabled) { Q_D(BridgeSetting); d->stp = enabled; } bool NetworkManager::BridgeSetting::stp() const { Q_D(const BridgeSetting); return d->stp; } void NetworkManager::BridgeSetting::setPriority(quint32 priority) { Q_D(BridgeSetting); d->priority = priority; } quint32 NetworkManager::BridgeSetting::priority() const { Q_D(const BridgeSetting); return d->priority; } void NetworkManager::BridgeSetting::setForwardDelay(quint32 delay) { Q_D(BridgeSetting); d->forwardDelay = delay; } quint32 NetworkManager::BridgeSetting::forwardDelay() const { Q_D(const BridgeSetting); return d->forwardDelay; } void NetworkManager::BridgeSetting::setHelloTime(quint32 time) { Q_D(BridgeSetting); d->helloTime = time; } quint32 NetworkManager::BridgeSetting::helloTime() const { Q_D(const BridgeSetting); return d->helloTime; } void NetworkManager::BridgeSetting::setMaxAge(quint32 age) { Q_D(BridgeSetting); d->maxAge = age; } quint32 NetworkManager::BridgeSetting::maxAge() const { Q_D(const BridgeSetting); return d->maxAge; } void NetworkManager::BridgeSetting::setAgingTime(quint32 time) { Q_D(BridgeSetting); d->agingTime = time; } quint32 NetworkManager::BridgeSetting::agingTime() const { Q_D(const BridgeSetting); return d->agingTime; } void NetworkManager::BridgeSetting::setMulticastSnooping(bool snooping) { Q_D(BridgeSetting); d->multicastSnooping = snooping; } bool NetworkManager::BridgeSetting::multicastSnooping() const { Q_D(const BridgeSetting); return d->multicastSnooping; } void NetworkManager::BridgeSetting::setMacAddress(const QByteArray& address) { Q_D(BridgeSetting); d->macAddress = address; } QByteArray NetworkManager::BridgeSetting::macAddress() const { Q_D(const BridgeSetting); return d->macAddress; } void NetworkManager::BridgeSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_INTERFACE_NAME))) { setInterfaceName(setting.value(QLatin1String(NM_SETTING_BRIDGE_INTERFACE_NAME)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_STP))) { setStp(setting.value(QLatin1String(NM_SETTING_BRIDGE_STP)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_PRIORITY))) { setPriority(setting.value(QLatin1String(NM_SETTING_BRIDGE_PRIORITY)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_FORWARD_DELAY))) { setForwardDelay(setting.value(QLatin1String(NM_SETTING_BRIDGE_FORWARD_DELAY)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_HELLO_TIME))) { setHelloTime(setting.value(QLatin1String(NM_SETTING_BRIDGE_HELLO_TIME)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_MAX_AGE))) { setMaxAge(setting.value(QLatin1String(NM_SETTING_BRIDGE_MAX_AGE)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_AGEING_TIME))) { setAgingTime(setting.value(QLatin1String(NM_SETTING_BRIDGE_AGEING_TIME)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_MULTICAST_SNOOPING))) { setMulticastSnooping(setting.value(QLatin1String(NM_SETTING_BRIDGE_MULTICAST_SNOOPING)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_MAC_ADDRESS))) { setMacAddress(setting.value(QLatin1String(NM_SETTING_BRIDGE_MAC_ADDRESS)).toByteArray()); } } QVariantMap NetworkManager::BridgeSetting::toMap() const { QVariantMap setting; if (!interfaceName().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_INTERFACE_NAME), interfaceName()); } if (!stp()) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_STP), stp()); } if (priority() != 128) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_PRIORITY), priority()); } if (forwardDelay() != 15) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_FORWARD_DELAY), forwardDelay()); } if (helloTime() != 2) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_HELLO_TIME), helloTime()); } if (maxAge() != 20) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_MAX_AGE), maxAge()); } if (agingTime() != 300) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_AGEING_TIME), agingTime()); } if (!multicastSnooping()) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_MULTICAST_SNOOPING), multicastSnooping()); } if (!macAddress().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_BRIDGE_MAC_ADDRESS), macAddress()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::BridgeSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_INTERFACE_NAME << ": " << setting.interfaceName() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_STP << ": " << setting.stp() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_PRIORITY << ": " << setting.priority() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_FORWARD_DELAY << ": " << setting.forwardDelay() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_HELLO_TIME << ": " << setting.helloTime() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_MAX_AGE << ": " << setting.maxAge() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_AGEING_TIME << ": " << setting.agingTime() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_MULTICAST_SNOOPING << ": " << setting.multicastSnooping() << '\n'; dbg.nospace() << NM_SETTING_BRIDGE_MAC_ADDRESS << ": " << setting.macAddress() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/bridgesetting.h b/src/settings/bridgesetting.h index ae8add3..8585700 100644 --- a/src/settings/bridgesetting.h +++ b/src/settings/bridgesetting.h @@ -1,91 +1,77 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BRIDGE_SETTING_H #define NETWORKMANAGERQT_BRIDGE_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class BridgeSettingPrivate; /** * Represents bridge setting */ class NETWORKMANAGERQT_EXPORT BridgeSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; BridgeSetting(); explicit BridgeSetting(const Ptr &other); ~BridgeSetting() override; QString name() const override; // Deprecated in favor of connection.interface-name in NM 1.0.0 void setInterfaceName(const QString &name); QString interfaceName() const; void setStp(bool enabled); bool stp() const; void setPriority(quint32 priority); quint32 priority() const; void setForwardDelay(quint32 delay); quint32 forwardDelay() const; void setHelloTime(quint32 time); quint32 helloTime() const; void setMaxAge(quint32 age); quint32 maxAge() const; void setAgingTime(quint32 time); quint32 agingTime() const; void setMulticastSnooping(bool snooping); bool multicastSnooping() const; void setMacAddress(const QByteArray &address); QByteArray macAddress() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: BridgeSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(BridgeSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const BridgeSetting &setting); } #endif // NETWORKMANAGERQT_BRIDGE_SETTING_H diff --git a/src/settings/bridgesetting_p.h b/src/settings/bridgesetting_p.h index 5eab116..3628e45 100644 --- a/src/settings/bridgesetting_p.h +++ b/src/settings/bridgesetting_p.h @@ -1,48 +1,34 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_BRIDGE_SETTING_P_H #define NETWORKMANAGERQT_BRIDGE_SETTING_P_H #include namespace NetworkManager { class BridgeSettingPrivate { public: BridgeSettingPrivate(); QString name; QString interfaceName; bool multicastSnooping; bool stp; quint32 priority; quint32 forwardDelay; quint32 helloTime; quint32 maxAge; quint32 agingTime; QByteArray macAddress; }; } #endif // NETWORKMANAGERQT_BRIDGE_SETTING_P_H diff --git a/src/settings/cdmasetting.cpp b/src/settings/cdmasetting.cpp index e02e9f3..6bd757d 100644 --- a/src/settings/cdmasetting.cpp +++ b/src/settings/cdmasetting.cpp @@ -1,199 +1,185 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "cdmasetting.h" #include "cdmasetting_p.h" #include NetworkManager::CdmaSettingPrivate::CdmaSettingPrivate(): name(NM_SETTING_CDMA_SETTING_NAME), passwordFlags(Setting::None) { } NetworkManager::CdmaSetting::CdmaSetting() : Setting(Setting::Cdma) , d_ptr(new CdmaSettingPrivate()) { } NetworkManager::CdmaSetting::CdmaSetting(const Ptr &other) : Setting(other) , d_ptr(new CdmaSettingPrivate()) { setUsername(other->username()); setNumber(other->number()); setPassword(other->password()); setPasswordFlags(other->passwordFlags()); } NetworkManager::CdmaSetting::~CdmaSetting() { delete d_ptr; } QString NetworkManager::CdmaSetting::name() const { Q_D(const CdmaSetting); return d->name; } void NetworkManager::CdmaSetting::setNumber(const QString &number) { Q_D(CdmaSetting); d->number = number; } QString NetworkManager::CdmaSetting::number() const { Q_D(const CdmaSetting); return d->number; } void NetworkManager::CdmaSetting::setUsername(const QString &username) { Q_D(CdmaSetting); d->username = username; } QString NetworkManager::CdmaSetting::username() const { Q_D(const CdmaSetting); return d->username; } void NetworkManager::CdmaSetting::setPassword(const QString &password) { Q_D(CdmaSetting); d->password = password; } QString NetworkManager::CdmaSetting::password() const { Q_D(const CdmaSetting); return d->password; } void NetworkManager::CdmaSetting::setPasswordFlags(NetworkManager::Setting::SecretFlags flags) { Q_D(CdmaSetting); d->passwordFlags = flags; } NetworkManager::Setting::SecretFlags NetworkManager::CdmaSetting::passwordFlags() const { Q_D(const CdmaSetting); return d->passwordFlags; } QStringList NetworkManager::CdmaSetting::needSecrets(bool requestNew) const { QStringList secrets; if (!username().isEmpty()) { if ((password().isEmpty() || requestNew) && !passwordFlags().testFlag(NotRequired)) { secrets << QLatin1String(NM_SETTING_CDMA_PASSWORD); } } return secrets; } void NetworkManager::CdmaSetting::secretsFromMap(const QVariantMap &secrets) { if (secrets.contains(QLatin1String(NM_SETTING_CDMA_PASSWORD))) { setPassword(secrets.value(QLatin1String(NM_SETTING_CDMA_PASSWORD)).toString()); } } QVariantMap NetworkManager::CdmaSetting::secretsToMap() const { QVariantMap secrets; if (!password().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_CDMA_PASSWORD), password()); } return secrets; } void NetworkManager::CdmaSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_CDMA_NUMBER))) { setNumber(setting.value(QLatin1String(NM_SETTING_CDMA_NUMBER)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_CDMA_USERNAME))) { setUsername(setting.value(QLatin1String(NM_SETTING_CDMA_USERNAME)).toString()); } // SECRETS if (setting.contains(QLatin1String(NM_SETTING_CDMA_PASSWORD))) { setPassword(setting.value(QLatin1String(NM_SETTING_CDMA_PASSWORD)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_CDMA_PASSWORD_FLAGS))) { setPasswordFlags((Setting::SecretFlags)setting.value(QLatin1String(NM_SETTING_CDMA_PASSWORD_FLAGS)).toInt()); } } QVariantMap NetworkManager::CdmaSetting::toMap() const { QVariantMap setting; if (!number().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_CDMA_NUMBER), number()); } if (!username().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_CDMA_USERNAME), username()); } // SECRETS if (!password().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_CDMA_PASSWORD), password()); } if (passwordFlags() != None) { setting.insert(QLatin1String(NM_SETTING_CDMA_PASSWORD_FLAGS), (int)passwordFlags()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::CdmaSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_CDMA_NUMBER << ": " << setting.number() << '\n'; dbg.nospace() << NM_SETTING_CDMA_USERNAME << ": " << setting.username() << '\n'; dbg.nospace() << NM_SETTING_CDMA_PASSWORD << ": " << setting.password() << '\n'; dbg.nospace() << NM_SETTING_CDMA_PASSWORD_FLAGS << ": " << setting.passwordFlags() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/cdmasetting.h b/src/settings/cdmasetting.h index e40654e..078b661 100644 --- a/src/settings/cdmasetting.h +++ b/src/settings/cdmasetting.h @@ -1,81 +1,67 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_CDMA_SETTINGS_H #define NETWORKMANAGERQT_CDMA_SETTINGS_H #include #include "setting.h" #include namespace NetworkManager { class CdmaSettingPrivate; /** * Represents cdma setting */ class NETWORKMANAGERQT_EXPORT CdmaSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; CdmaSetting(); explicit CdmaSetting(const Ptr &other); ~CdmaSetting() override; QString name() const override; void setNumber(const QString &number); QString number() const; void setUsername(const QString &username); QString username() const; void setPassword(const QString &password); QString password() const; void setPasswordFlags(SecretFlags flags); SecretFlags passwordFlags() const; QStringList needSecrets(bool requestNew = false) const override; void secretsFromMap(const QVariantMap &secrets) override; QVariantMap secretsToMap() const override; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: CdmaSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(CdmaSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const CdmaSetting &setting); } #endif // NETWORKMANAGERQT_CDMA_SETTINGS_H diff --git a/src/settings/cdmasetting_p.h b/src/settings/cdmasetting_p.h index 1b9eb09..20bec22 100644 --- a/src/settings/cdmasetting_p.h +++ b/src/settings/cdmasetting_p.h @@ -1,43 +1,29 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_CDMA_SETTING_P_H #define NETWORKMANAGERQT_CDMA_SETTING_P_H #include namespace NetworkManager { class CdmaSettingPrivate { public: CdmaSettingPrivate(); QString name; QString number; QString username; QString password; NetworkManager::Setting::SecretFlags passwordFlags; }; } #endif // NETWORKMANAGERQT_CDMA_SETTINGS_P_H diff --git a/src/settings/connectionsettings.cpp b/src/settings/connectionsettings.cpp index 2f46500..26fb61b 100644 --- a/src/settings/connectionsettings.cpp +++ b/src/settings/connectionsettings.cpp @@ -1,1119 +1,1105 @@ /* - Copyright 2012-2013 Jan Grulich - Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "connectionsettings.h" #include "connectionsettings_p.h" #include "wiredsetting.h" #include "olpcmeshsetting.h" #include "wirelesssetting.h" #include "wirelesssecuritysetting.h" #include "security8021xsetting.h" #include "adslsetting.h" #include "bluetoothsetting.h" #include "bondsetting.h" #include "bridgesetting.h" #include "bridgeportsetting.h" #include "gsmsetting.h" #include "cdmasetting.h" #include "infinibandsetting.h" #include "iptunnelsetting.h" #include "ipv4setting.h" #include "ipv6setting.h" #include "pppsetting.h" #include "pppoesetting.h" #include "serialsetting.h" #include "tunsetting.h" #include "vlansetting.h" #include "vpnsetting.h" #include "wimaxsetting.h" #include "wireguardsetting.h" #undef signals #include #if !NM_CHECK_VERSION(1, 6, 0) #define NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES "autoconnect-retries" #endif #if !NM_CHECK_VERSION(1, 16, 0) #define NM_SETTING_WIREGUARD_SETTING_NAME "wireguard" #endif #include "teamsetting.h" #include "genericsetting.h" #include namespace NetworkManager { extern int checkVersion(const int x, const int y, const int z); } NetworkManager::ConnectionSettingsPrivate::ConnectionSettingsPrivate(ConnectionSettings *q) : name(NM_SETTING_CONNECTION_SETTING_NAME) , uuid(QUuid().toString()) , type(ConnectionSettings::Wired) , autoconnect(true) , readOnly(false) , gatewayPingTimeout(0) , autoconnectPriority(0) , autoconnectRetries(-1) , autoconnectSlaves(ConnectionSettings::SlavesDefault) , lldp(ConnectionSettings::LldpDefault) , metered(ConnectionSettings::MeteredUnknown) , q_ptr(q) { } void NetworkManager::ConnectionSettingsPrivate::addSetting(const NetworkManager::Setting::Ptr &setting) { settings.push_back(setting); } void NetworkManager::ConnectionSettingsPrivate::clearSettings() { settings.clear(); } void NetworkManager::ConnectionSettingsPrivate::initSettings(NMBluetoothCapabilities bt_cap) { clearSettings(); switch (type) { case ConnectionSettings::Adsl: addSetting(Setting::Ptr(new AdslSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); break; case ConnectionSettings::Bond: addSetting(Setting::Ptr(new BondSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); break; case ConnectionSettings::Bluetooth: addSetting(Setting::Ptr(new BluetoothSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); //addSetting(Setting::Ptr(new Ipv6Setting())); if (bt_cap == NM_BT_CAPABILITY_DUN) { addSetting(Setting::Ptr(new GsmSetting())); addSetting(Setting::Ptr(new PppSetting())); addSetting(Setting::Ptr(new SerialSetting())); } break; case ConnectionSettings::Bridge: addSetting(Setting::Ptr(new BridgeSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); break; case ConnectionSettings::Cdma: addSetting(Setting::Ptr(new CdmaSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); if (NetworkManager::checkVersion(1, 0, 0)) { addSetting(Setting::Ptr(new Ipv6Setting())); } addSetting(Setting::Ptr(new PppSetting())); break; case ConnectionSettings::Gsm: addSetting(Setting::Ptr(new GsmSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); if (NetworkManager::checkVersion(1, 0, 0)) { addSetting(Setting::Ptr(new Ipv6Setting())); } addSetting(Setting::Ptr(new PppSetting())); break; case ConnectionSettings::Infiniband: addSetting(Setting::Ptr(new InfinibandSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); break; case ConnectionSettings::OLPCMesh: addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); addSetting(Setting::Ptr(new OlpcMeshSetting())); break; case ConnectionSettings::Pppoe: addSetting(Setting::Ptr(new Ipv4Setting())); //addSetting(new Ipv6Setting())); addSetting(Setting::Ptr(new PppSetting())); addSetting(Setting::Ptr(new PppoeSetting())); addSetting(Setting::Ptr(new WiredSetting())); break; case ConnectionSettings::Vlan: addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); addSetting(Setting::Ptr(new VlanSetting())); break; case ConnectionSettings::Vpn: addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); addSetting(Setting::Ptr(new VpnSetting())); break; case ConnectionSettings::Wimax: addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); addSetting(Setting::Ptr(new WimaxSetting())); break; case ConnectionSettings::Wired: addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); addSetting(Setting::Ptr(new Security8021xSetting())); addSetting(Setting::Ptr(new WiredSetting())); break; case ConnectionSettings::Wireless: addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); addSetting(Setting::Ptr(new Security8021xSetting())); addSetting(Setting::Ptr(new WirelessSetting())); addSetting(Setting::Ptr(new WirelessSecuritySetting())); break; case ConnectionSettings::Team: addSetting(Setting::Ptr(new TeamSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); break; case ConnectionSettings::Generic: addSetting(Setting::Ptr(new GenericSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); break; case ConnectionSettings::Tun: addSetting(Setting::Ptr(new TunSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); break; case ConnectionSettings::IpTunnel: addSetting(Setting::Ptr(new IpTunnelSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); break; case ConnectionSettings::WireGuard: addSetting(Setting::Ptr(new WireGuardSetting())); addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); break; case ConnectionSettings::Unknown: default: break; } } void NetworkManager::ConnectionSettingsPrivate::initSettings(const NetworkManager::ConnectionSettings::Ptr &connectionSettings) { Q_Q(ConnectionSettings); clearSettings(); switch (type) { case ConnectionSettings::Adsl: addSetting(connectionSettings->setting(Setting::Adsl)); addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); break; case ConnectionSettings::Bond: addSetting(connectionSettings->setting(Setting::Bond)); addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); break; case ConnectionSettings::Bluetooth: addSetting(connectionSettings->setting(Setting::Bluetooth)); addSetting(connectionSettings->setting(Setting::Ipv4)); if (NetworkManager::checkVersion(1, 0, 0)) { addSetting(connectionSettings->setting(Setting::Ipv6)); } if (q->setting(Setting::Gsm) && q->setting(Setting::Ppp) && q->setting(Setting::Serial)) { addSetting(connectionSettings->setting(Setting::Gsm)); addSetting(connectionSettings->setting(Setting::Ppp)); addSetting(connectionSettings->setting(Setting::Serial)); } break; case ConnectionSettings::Bridge: addSetting(connectionSettings->setting(Setting::Bridge)); addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); break; case ConnectionSettings::Cdma: addSetting(connectionSettings->setting(Setting::Cdma)); addSetting(connectionSettings->setting(Setting::Ipv4)); if (NetworkManager::checkVersion(1, 0, 0)) { addSetting(connectionSettings->setting(Setting::Ipv6)); } addSetting(connectionSettings->setting(Setting::Ppp)); break; case ConnectionSettings::Gsm: addSetting(connectionSettings->setting(Setting::Gsm)); addSetting(connectionSettings->setting(Setting::Ipv4)); if (NetworkManager::checkVersion(1, 0, 0)) { addSetting(connectionSettings->setting(Setting::Ipv6)); } addSetting(connectionSettings->setting(Setting::Ppp)); break; case ConnectionSettings::Infiniband: addSetting(connectionSettings->setting(Setting::Infiniband)); addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); break; case ConnectionSettings::OLPCMesh: addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); addSetting(connectionSettings->setting(Setting::OlpcMesh)); break; case ConnectionSettings::Pppoe: addSetting(connectionSettings->setting(Setting::Ipv4)); //addSetting(Ipv6Setting(connectionSettings->setting(Setting::Ipv6)); addSetting(connectionSettings->setting(Setting::Ppp)); addSetting(connectionSettings->setting(Setting::Pppoe)); addSetting(connectionSettings->setting(Setting::Wired)); break; case ConnectionSettings::Vlan: addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); addSetting(connectionSettings->setting(Setting::Vlan)); break; case ConnectionSettings::Vpn: addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); addSetting(connectionSettings->setting(Setting::Vpn)); break; case ConnectionSettings::Wimax: addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); addSetting(connectionSettings->setting(Setting::Wimax)); break; case ConnectionSettings::Wired: addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); addSetting(connectionSettings->setting(Setting::Security8021x)); addSetting(connectionSettings->setting(Setting::Wired)); break; case ConnectionSettings::Wireless: addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); addSetting(connectionSettings->setting(Setting::Security8021x)); addSetting(connectionSettings->setting(Setting::Wireless)); addSetting(connectionSettings->setting(Setting::WirelessSecurity)); break; case ConnectionSettings::Team: addSetting(connectionSettings->setting(Setting::Team)); addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); break; case ConnectionSettings::Generic: addSetting(connectionSettings->setting(Setting::Generic)); addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); break; case ConnectionSettings::Tun: addSetting(connectionSettings->setting(Setting::Tun)); addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); break; case ConnectionSettings::IpTunnel: addSetting(connectionSettings->setting(Setting::IpTunnel)); addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); break; case ConnectionSettings::WireGuard: addSetting(connectionSettings->setting(Setting::WireGuard)); addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); break; case ConnectionSettings::Unknown: default: break; } } NetworkManager::ConnectionSettings::ConnectionType NetworkManager::ConnectionSettings::typeFromString(const QString &typeString) { ConnectionSettings::ConnectionType type = Wired; if (typeString == QLatin1String(NM_SETTING_ADSL_SETTING_NAME)) { type = Adsl; } else if (typeString == QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME)) { type = Bluetooth; } else if (typeString == QLatin1String(NM_SETTING_BOND_SETTING_NAME)) { type = Bond; } else if (typeString == QLatin1String(NM_SETTING_BRIDGE_SETTING_NAME)) { type = Bridge; } else if (typeString == QLatin1String(NM_SETTING_CDMA_SETTING_NAME)) { type = Cdma; } else if (typeString == QLatin1String(NM_SETTING_GSM_SETTING_NAME)) { type = Gsm; } else if (typeString == QLatin1String(NM_SETTING_INFINIBAND_SETTING_NAME)) { type = Infiniband; } else if (typeString == QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME)) { type = OLPCMesh; } else if (typeString == QLatin1String(NM_SETTING_PPPOE_SETTING_NAME)) { type = Pppoe; } else if (typeString == QLatin1String(NM_SETTING_VLAN_SETTING_NAME)) { type = Vlan; } else if (typeString == QLatin1String(NM_SETTING_VPN_SETTING_NAME)) { type = Vpn; } else if (typeString == QLatin1String(NM_SETTING_WIMAX_SETTING_NAME)) { type = Wimax; } else if (typeString == QLatin1String(NM_SETTING_WIRED_SETTING_NAME)) { type = Wired; } else if (typeString == QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME)) { type = Wireless; } else if (typeString == QLatin1String(NM_SETTING_TEAM_SETTING_NAME)) { type = Team; } else if (typeString == QLatin1String(NM_SETTING_GENERIC_SETTING_NAME)) { type = Generic; } else if (typeString == QLatin1String(NM_SETTING_TUN_SETTING_NAME)) { type = Tun; } else if (typeString == QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME)) { type = IpTunnel; } else if (typeString == QLatin1String(NM_SETTING_WIREGUARD_SETTING_NAME)) { type = WireGuard; } return type; } QString NetworkManager::ConnectionSettings::typeAsString(NetworkManager::ConnectionSettings::ConnectionType type) { QString typeString; switch (type) { case Adsl: typeString = QLatin1String(NM_SETTING_ADSL_SETTING_NAME); break; case Bond: typeString = QLatin1String(NM_SETTING_BOND_SETTING_NAME); break; case Bluetooth: typeString = QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME); break; case Bridge: typeString = QLatin1String(NM_SETTING_BRIDGE_SETTING_NAME); break; case Cdma: typeString = QLatin1String(NM_SETTING_CDMA_SETTING_NAME); break; case Gsm: typeString = QLatin1String(NM_SETTING_GSM_SETTING_NAME); break; case Infiniband: typeString = QLatin1String(NM_SETTING_INFINIBAND_SETTING_NAME); break; case OLPCMesh: typeString = QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME); break; case Pppoe: typeString = QLatin1String(NM_SETTING_PPPOE_SETTING_NAME); break; case Vlan: typeString = QLatin1String(NM_SETTING_VLAN_SETTING_NAME); break; case Vpn: typeString = QLatin1String(NM_SETTING_VPN_SETTING_NAME); break; case Wimax: typeString = QLatin1String(NM_SETTING_WIMAX_SETTING_NAME); break; case Wired: typeString = QLatin1String(NM_SETTING_WIRED_SETTING_NAME); break; case Wireless: typeString = QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME); break; case Team: typeString = QLatin1String(NM_SETTING_TEAM_SETTING_NAME); break; case Generic: typeString = QLatin1String(NM_SETTING_GENERIC_SETTING_NAME); break; case Tun: typeString = QLatin1String(NM_SETTING_TUN_SETTING_NAME); break; case IpTunnel: typeString = QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME); break; case WireGuard: typeString = QLatin1String(NM_SETTING_WIREGUARD_SETTING_NAME); break; default: break; }; return typeString; } QString NetworkManager::ConnectionSettings::createNewUuid() { return QUuid::createUuid().toString().mid(1, QUuid::createUuid().toString().length() - 2); } NetworkManager::ConnectionSettings::ConnectionSettings() : d_ptr(new ConnectionSettingsPrivate(this)) { } NetworkManager::ConnectionSettings::ConnectionSettings(NetworkManager::ConnectionSettings::ConnectionType type, NMBluetoothCapabilities bt_cap) : d_ptr(new ConnectionSettingsPrivate(this)) { setConnectionType(type, bt_cap); } NetworkManager::ConnectionSettings::ConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &other) : d_ptr(new ConnectionSettingsPrivate(this)) { Q_D(ConnectionSettings); setId(other->id()); setUuid(other->uuid()); setInterfaceName(other->interfaceName()); setConnectionType(other->connectionType()); setPermissions(other->permissions()); setAutoconnect(other->autoconnect()); setAutoconnectPriority(other->autoconnectPriority()); setTimestamp(other->timestamp()); setReadOnly(other->readOnly()); setZone(other->zone()); setMaster(other->master()); setSlaveType(other->slaveType()); setGatewayPingTimeout(other->gatewayPingTimeout()); setAutoconnectRetries(other->autoconnectRetries()); setAutoconnectSlaves(other->autoconnectSlaves()); setLldp(other->lldp()); setMetered(other->metered()); setStableId(other->stableId()); d->initSettings(other); } NetworkManager::ConnectionSettings::ConnectionSettings(const NMVariantMapMap &map) : d_ptr(new ConnectionSettingsPrivate(this)) { fromMap(map); } NetworkManager::ConnectionSettings::~ConnectionSettings() { d_ptr->clearSettings(); delete d_ptr; } void NetworkManager::ConnectionSettings::fromMap(const NMVariantMapMap &map) { QVariantMap connectionSettings = map.value(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME)); setId(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_ID)).toString()); setUuid(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_UUID)).toString()); setConnectionType(typeFromString(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_TYPE)).toString())); if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_INTERFACE_NAME))) { setInterfaceName(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_INTERFACE_NAME)).toString()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_PERMISSIONS))) { QStringList permissions = connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_PERMISSIONS)).toStringList(); Q_FOREACH (const QString & permission, permissions) { #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) const QStringList split = permission.split(QLatin1Char(':'), QString::KeepEmptyParts); #else const QStringList split = permission.split(QLatin1Char(':'), Qt::KeepEmptyParts); #endif addToPermissions(split.at(1), split.at(2)); } } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT))) { setAutoconnect(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT)).toBool()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY))) { setAutoconnectPriority(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY)).toInt()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_TIMESTAMP))) { const int timestamp = connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_TIMESTAMP)).toInt(); setTimestamp(QDateTime::fromSecsSinceEpoch(timestamp)); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_READ_ONLY))) { setReadOnly(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_READ_ONLY)).toBool()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_ZONE))) { setZone(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_ZONE)).toString()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_MASTER))) { setMaster(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_MASTER)).toString()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_SLAVE_TYPE))) { setSlaveType(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_SLAVE_TYPE)).toString()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_SECONDARIES))) { setSecondaries(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_SECONDARIES)).toStringList()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT))) { setGatewayPingTimeout(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT)).toUInt()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES))) { setAutoconnectRetries(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES)).toInt()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES))) { setAutoconnectSlaves((NetworkManager::ConnectionSettings::AutoconnectSlaves)connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES)).toInt()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_LLDP))) { setLldp((NetworkManager::ConnectionSettings::Lldp)connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_LLDP)).toInt()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_METERED))) { setMetered((NetworkManager::ConnectionSettings::Metered)connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_METERED)).toInt()); } if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_STABLE_ID))) { setStableId(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_STABLE_ID)).toString()); } Q_FOREACH (const Setting::Ptr & setting, settings()) { if (map.contains(setting->name())) { setting->fromMap(map.value(setting->name())); setting->setInitialized(true); } else { setting->setInitialized(false); } } } NMVariantMapMap NetworkManager::ConnectionSettings::toMap() const { NMVariantMapMap result; QVariantMap connectionSetting; if (!id().isEmpty()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_ID), id()); } if (!uuid().isEmpty()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_UUID), uuid()); } if (connectionType()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_TYPE), typeAsString(connectionType())); } if (!interfaceName().isEmpty()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_INTERFACE_NAME), interfaceName()); } if (!permissions().isEmpty()) { QStringList perm; QHash perms = permissions(); QHash::const_iterator it = perms.constBegin(); while (it != perms.constEnd()) { const QString tmp = "user:" + it.key() + ':' + it.value(); perm << tmp; ++it; } connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_PERMISSIONS), perm); } if (!autoconnect()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT), autoconnect()); } if (autoconnectPriority()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY), autoconnectPriority()); } if (timestamp().isValid()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_TIMESTAMP), timestamp().toSecsSinceEpoch()); } if (readOnly()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_READ_ONLY), readOnly()); } if (!zone().isEmpty()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_ZONE), zone()); } if (!master().isEmpty()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_MASTER), master()); } if (!slaveType().isEmpty()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_SLAVE_TYPE), slaveType()); } if (!secondaries().isEmpty()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_SECONDARIES), secondaries()); } if (gatewayPingTimeout()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT), gatewayPingTimeout()); } if (autoconnectRetries() >= 0) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES), autoconnectRetries()); } connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES), autoconnectSlaves()); connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_LLDP), lldp()); connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_METERED), metered()); if (!stableId().isEmpty()) { connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_STABLE_ID), stableId()); } result.insert(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME), connectionSetting); Q_FOREACH (const Setting::Ptr & setting, settings()) { QVariantMap map = setting->toMap(); if (!setting->isNull()) { result.insert(setting->name(), map); } } return result; } QString NetworkManager::ConnectionSettings::name() const { Q_D(const ConnectionSettings); return d->name; } void NetworkManager::ConnectionSettings::setId(const QString &id) { Q_D(ConnectionSettings); d->id = id; } QString NetworkManager::ConnectionSettings::id() const { Q_D(const ConnectionSettings); return d->id; } void NetworkManager::ConnectionSettings::setUuid(const QString &uuid) { Q_D(ConnectionSettings); d->uuid = uuid; } QString NetworkManager::ConnectionSettings::uuid() const { Q_D(const ConnectionSettings); return d->uuid; } void NetworkManager::ConnectionSettings::setInterfaceName(const QString &interfaceName) { Q_D(ConnectionSettings); d->interfaceName = interfaceName; } QString NetworkManager::ConnectionSettings::interfaceName() const { Q_D(const ConnectionSettings); return d->interfaceName; } void NetworkManager::ConnectionSettings::setConnectionType(NetworkManager::ConnectionSettings::ConnectionType type, NMBluetoothCapabilities bt_cap) { Q_D(ConnectionSettings); d->type = type; d->initSettings(bt_cap); } NetworkManager::ConnectionSettings::ConnectionType NetworkManager::ConnectionSettings::connectionType() const { Q_D(const ConnectionSettings); return d->type; } void NetworkManager::ConnectionSettings::addToPermissions(const QString &user, const QString &type) { Q_D(ConnectionSettings); d->permissions.insert(user, type); } void NetworkManager::ConnectionSettings::setPermissions(const QHash< QString, QString > &perm) { Q_D(ConnectionSettings); d->permissions = perm; } QHash< QString, QString > NetworkManager::ConnectionSettings::permissions() const { Q_D(const ConnectionSettings); return d->permissions; } void NetworkManager::ConnectionSettings::setAutoconnect(bool autoconnect) { Q_D(ConnectionSettings); d->autoconnect = autoconnect; } bool NetworkManager::ConnectionSettings::autoconnect() const { Q_D(const ConnectionSettings); return d->autoconnect; } void NetworkManager::ConnectionSettings::setAutoconnectPriority(int priority) { Q_D(ConnectionSettings); d->autoconnectPriority = priority; } int NetworkManager::ConnectionSettings::autoconnectPriority() const { Q_D(const ConnectionSettings); return d->autoconnectPriority; } void NetworkManager::ConnectionSettings::setTimestamp(const QDateTime ×tamp) { Q_D(ConnectionSettings); d->timestamp = timestamp; } QDateTime NetworkManager::ConnectionSettings::timestamp() const { Q_D(const ConnectionSettings); return d->timestamp; } void NetworkManager::ConnectionSettings::setReadOnly(bool readonly) { Q_D(ConnectionSettings); d->readOnly = readonly; } bool NetworkManager::ConnectionSettings::readOnly() const { Q_D(const ConnectionSettings); return d->readOnly; } void NetworkManager::ConnectionSettings::setZone(const QString &zone) { Q_D(ConnectionSettings); d->zone = zone; } QString NetworkManager::ConnectionSettings::zone() const { Q_D(const ConnectionSettings); return d->zone; } bool NetworkManager::ConnectionSettings::isSlave() const { Q_D(const ConnectionSettings); return !d->master.isEmpty() && !d->slaveType.isEmpty(); } void NetworkManager::ConnectionSettings::setMaster(const QString &master) { Q_D(ConnectionSettings); d->master = master; } QString NetworkManager::ConnectionSettings::master() const { Q_D(const ConnectionSettings); return d->master; } void NetworkManager::ConnectionSettings::setSlaveType(const QString &type) { Q_D(ConnectionSettings); d->slaveType = type; } QString NetworkManager::ConnectionSettings::slaveType() const { Q_D(const ConnectionSettings); return d->slaveType; } void NetworkManager::ConnectionSettings::setSecondaries(const QStringList &secondaries) { Q_D(ConnectionSettings); d->secondaries = secondaries; } QStringList NetworkManager::ConnectionSettings::secondaries() const { Q_D(const ConnectionSettings); return d->secondaries; } void NetworkManager::ConnectionSettings::setGatewayPingTimeout(quint32 timeout) { Q_D(ConnectionSettings); d->gatewayPingTimeout = timeout; } quint32 NetworkManager::ConnectionSettings::gatewayPingTimeout() const { Q_D(const ConnectionSettings); return d->gatewayPingTimeout; } int NetworkManager::ConnectionSettings::autoconnectRetries() const { Q_D(const ConnectionSettings); return d->autoconnectRetries; } void NetworkManager::ConnectionSettings::setAutoconnectRetries(int retries) { Q_D(ConnectionSettings); d->autoconnectRetries = retries; } NetworkManager::ConnectionSettings::AutoconnectSlaves NetworkManager::ConnectionSettings::autoconnectSlaves() const { Q_D(const ConnectionSettings); return d->autoconnectSlaves; } void NetworkManager::ConnectionSettings::setAutoconnectSlaves(NetworkManager::ConnectionSettings::AutoconnectSlaves autoconnectSlaves) { Q_D(ConnectionSettings); d->autoconnectSlaves = autoconnectSlaves; } NetworkManager::ConnectionSettings::Lldp NetworkManager::ConnectionSettings::lldp() const { Q_D(const ConnectionSettings); return d->lldp; } void NetworkManager::ConnectionSettings::setLldp(NetworkManager::ConnectionSettings::Lldp lldp) { Q_D(ConnectionSettings); d->lldp = lldp; } NetworkManager::ConnectionSettings::Metered NetworkManager::ConnectionSettings::metered() const { Q_D(const ConnectionSettings); return d->metered; } void NetworkManager::ConnectionSettings::setMetered(NetworkManager::ConnectionSettings::Metered metered) { Q_D(ConnectionSettings); d->metered = metered; } QString NetworkManager::ConnectionSettings::stableId() const { Q_D(const ConnectionSettings); return d->stableId; } void NetworkManager::ConnectionSettings::setStableId(const QString &stableId) { Q_D(ConnectionSettings); d->stableId = stableId; } NetworkManager::Setting::Ptr NetworkManager::ConnectionSettings::setting(Setting::SettingType type) const { Q_FOREACH (const Setting::Ptr & setting, settings()) { if (setting->type() == type) { return setting; } } return Setting::Ptr(); } NetworkManager::Setting::Ptr NetworkManager::ConnectionSettings::setting(const QString &type) const { return setting(Setting::typeFromString(type)); } NetworkManager::Setting::List NetworkManager::ConnectionSettings::settings() const { Q_D(const ConnectionSettings); return d->settings; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::ConnectionSettings &setting) { dbg.nospace() << "CONNECTION SETTINGS\n"; dbg.nospace() << "===================\n"; dbg.nospace() << NM_SETTING_CONNECTION_ID << ": " << setting.id() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_UUID << ": " << setting.uuid() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_INTERFACE_NAME << ": " << setting.interfaceName() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_TYPE << ": " << setting.typeAsString(setting.connectionType()) << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_PERMISSIONS << ": " << setting.permissions() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_AUTOCONNECT << ": " << setting.autoconnect() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY << ": " << setting.autoconnectPriority() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_TIMESTAMP << ": " << setting.timestamp().toSecsSinceEpoch() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_READ_ONLY << ": " << setting.readOnly() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_ZONE << ": " << setting.zone() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_MASTER << ": " << setting.master() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_SLAVE_TYPE << ": " << setting.slaveType() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_SECONDARIES << ": " << setting.secondaries() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT << ": " << setting.gatewayPingTimeout() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES << ": " << setting.autoconnectRetries() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES << ": " << setting.autoconnectSlaves() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_LLDP << ": " << setting.lldp() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_METERED << ": " << setting.metered() << '\n'; dbg.nospace() << NM_SETTING_CONNECTION_STABLE_ID << ": " << setting.stableId() << '\n'; dbg.nospace() << "===================\n"; Q_FOREACH (const Setting::Ptr & settingPtr, setting.settings()) { dbg.nospace() << settingPtr->typeAsString(settingPtr->type()).toUpper() << " SETTINGS\n"; dbg.nospace() << "---------------------------\n"; switch (settingPtr->type()) { case Setting::Adsl: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Bond: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Bluetooth: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Bridge: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::BridgePort: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Cdma: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Gsm: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Infiniband: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Ipv4: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Ipv6: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::OlpcMesh: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Ppp: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Pppoe: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Security8021x: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Serial: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Vlan: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Vpn: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Wimax: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Wired: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Wireless: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::WirelessSecurity: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Team: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::Tun: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::IpTunnel: dbg.nospace() << *(settingPtr.staticCast().data()); break; case Setting::WireGuard: dbg.nospace() << *(settingPtr.staticCast().data()); break; default: dbg.nospace() << *settingPtr.data(); } dbg.nospace() << '\n'; } return dbg.maybeSpace(); } diff --git a/src/settings/connectionsettings.h b/src/settings/connectionsettings.h index 0057d45..72b5a63 100644 --- a/src/settings/connectionsettings.h +++ b/src/settings/connectionsettings.h @@ -1,188 +1,174 @@ /* - Copyright 2012-2013 Jan Grulich - Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_CONNECTION_SETTINGS_H #define NETWORKMANAGERQT_CONNECTION_SETTINGS_H #include #include "setting.h" #undef signals #include #define signals Q_SIGNALS #include #include #include namespace NetworkManager { class ConnectionSettingsPrivate; /** * Represents collection of all connection settings */ class NETWORKMANAGERQT_EXPORT ConnectionSettings { Q_ENUMS(ConnectionType) public: typedef QSharedPointer Ptr; typedef QList List; enum ConnectionType { Unknown = 0, Adsl, Bluetooth, Bond, Bridge, Cdma, Gsm, Infiniband, OLPCMesh, Pppoe, Vlan, Vpn, Wimax, Wired, Wireless, Team, Generic, Tun, IpTunnel, WireGuard }; enum AutoconnectSlaves { SlavesDefault = -1, DoNotConnectSlaves = 0, ConnectAllSlaves = 1 }; enum Lldp { LldpDefault = -1, LldpDisable = 0, LldpEnableRx = 1, }; // FIXME same enum as in device.h, unfortunately it's not possible to use that one // maybe in future move all enums into one header so they can be used across all classes enum Metered { MeteredUnknown = 0, MeteredYes = 1, MeteredNo = 2, MeteredGuessYes = 3, MeteredGuessNo = 4 }; static ConnectionType typeFromString(const QString &typeString); static QString typeAsString(const ConnectionType type); static QString createNewUuid(); ConnectionSettings(); explicit ConnectionSettings(ConnectionType type, NMBluetoothCapabilities bt_cap = NM_BT_CAPABILITY_DUN); explicit ConnectionSettings(const ConnectionSettings::Ptr &other); explicit ConnectionSettings(const NMVariantMapMap &map); virtual ~ConnectionSettings(); QString name() const; void fromMap(const NMVariantMapMap &map); NMVariantMapMap toMap() const; void setId(const QString &id); QString id() const; void setUuid(const QString &uuid); QString uuid() const; void setInterfaceName(const QString &interfaceName); QString interfaceName() const; void setConnectionType(ConnectionType type, NMBluetoothCapabilities bt_cap = NM_BT_CAPABILITY_DUN); ConnectionType connectionType() const; void addToPermissions(const QString &user, const QString &type); void setPermissions(const QHash &perm); QHash permissions() const; void setAutoconnect(bool autoconnect); bool autoconnect() const; void setAutoconnectPriority(int priority); int autoconnectPriority() const; void setTimestamp(const QDateTime ×tamp); QDateTime timestamp() const; void setReadOnly(bool readonly); bool readOnly() const; void setZone(const QString &zone); QString zone() const; bool isSlave() const; void setMaster(const QString &master); QString master() const; void setSlaveType(const QString &type); QString slaveType() const; void setSecondaries(const QStringList &secondaries); QStringList secondaries() const; void setGatewayPingTimeout(quint32 timeout); quint32 gatewayPingTimeout() const; void setAutoconnectRetries(int retries); int autoconnectRetries() const; void setAutoconnectSlaves(AutoconnectSlaves autoconnectSlaves); AutoconnectSlaves autoconnectSlaves() const; void setLldp(Lldp lldp); Lldp lldp() const; void setMetered(Metered metered); Metered metered() const; void setStableId(const QString &stableId); QString stableId() const; Setting::Ptr setting(Setting::SettingType type) const; Setting::Ptr setting(const QString &type) const; Setting::List settings() const; protected: ConnectionSettingsPrivate *d_ptr; private: Q_DECLARE_PRIVATE(ConnectionSettings) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const ConnectionSettings &setting); } #endif // NETWORKMANAGERQT_CONNECTION_SETTINGS_H diff --git a/src/settings/connectionsettings_p.h b/src/settings/connectionsettings_p.h index ed33faf..d74b909 100644 --- a/src/settings/connectionsettings_p.h +++ b/src/settings/connectionsettings_p.h @@ -1,72 +1,58 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_CONNECTION_SETTINGS_P_H #define NETWORKMANAGERQT_CONNECTION_SETTINGS_P_H #include "setting.h" #include #include #include namespace NetworkManager { class ConnectionSettingsPrivate { public: Q_DECLARE_PUBLIC(ConnectionSettings) explicit ConnectionSettingsPrivate(ConnectionSettings *q); void addSetting(const NetworkManager::Setting::Ptr &setting); void clearSettings(); void initSettings(NMBluetoothCapabilities bt_cap); void initSettings(const NetworkManager::ConnectionSettings::Ptr &connectionSettings); QString name; QString id; QString uuid; QString interfaceName; NetworkManager::ConnectionSettings::ConnectionType type; QHash permissions; bool autoconnect; QDateTime timestamp; bool readOnly; QString zone; QString master; QString slaveType; QStringList secondaries; quint32 gatewayPingTimeout; int autoconnectPriority; int autoconnectRetries; NetworkManager::ConnectionSettings::AutoconnectSlaves autoconnectSlaves; NetworkManager::ConnectionSettings::Lldp lldp; NetworkManager::ConnectionSettings::Metered metered; QString stableId; Setting::List settings; ConnectionSettings *q_ptr; }; } #endif // NETWORKMANAGERQT_CONNECTION_SETTINGS_P_H diff --git a/src/settings/dcbsetting.cpp b/src/settings/dcbsetting.cpp index 57952d8..edd0c9e 100644 --- a/src/settings/dcbsetting.cpp +++ b/src/settings/dcbsetting.cpp @@ -1,553 +1,539 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "dcbsetting.h" #include "dcbsetting_p.h" #include NetworkManager::DcbSettingPrivate::DcbSettingPrivate() : name(NM_SETTING_DCB_SETTING_NAME) , appFcoeMode(NM_SETTING_DCB_FCOE_MODE_FABRIC) , appFcoePriority(-1) , appFipPriority(-1) , appIscsiPriority(-1) , priorityFlowControl({0, 0, 0, 0, 0, 0, 0, 0}) , priorityBandwidth({0, 0, 0, 0, 0, 0, 0, 0}) , priorityGroupBandwidth({0, 0, 0, 0, 0, 0, 0, 0}) , priorityGroupId({0, 0, 0, 0, 0, 0, 0, 0}) , priorityStrictBandwidth({0, 0, 0, 0, 0, 0, 0, 0}) , priorityTrafficClass({0, 0, 0, 0, 0, 0, 0, 0}) { } NetworkManager::DcbSetting::DcbSetting() : Setting(Setting::Dcb) , d_ptr(new DcbSettingPrivate()) { } NetworkManager::DcbSetting::DcbSetting(const Ptr &other) : Setting(other) , d_ptr(new DcbSettingPrivate()) { setAppFcoeMode(other->appFcoeMode()); setAppFcoePriority(other->appFcoePriority()); setAppFipPriority(other->appFipPriority()); setAppIscsiPriority(other->appIscsiPriority()); setAppFcoeFlags(other->appFcoeFlags()); setAppFipFlags(other->appFipFlags()); setAppIscsiFlags(other->appIscsiFlags()); setPriorityGroupFlags(other->priorityGroupFlags()); setPriorityFlowControlFlags(other->priorityFlowControlFlags()); setPriorityFlowControl(other->priorityFlowControl()); setPriorityBandwidth(other->priorityBandwidth()); setPriorityGroupBandwidth(other->priorityGroupBandwidth()); setPriorityGroupId(other->priorityGroupId()); setPriorityStrictBandwidth(other->priorityStrictBandwidth()); setPriorityTrafficClass(other->priorityTrafficClass()); } NetworkManager::DcbSetting::~DcbSetting() { delete d_ptr; } QString NetworkManager::DcbSetting::name() const { Q_D(const DcbSetting); return d->name; } void NetworkManager::DcbSetting::setAppFcoeMode(const QString &mode) { Q_D(DcbSetting); d->appFcoeMode = mode; } QString NetworkManager::DcbSetting::appFcoeMode() const { Q_D(const DcbSetting); return d->appFcoeMode; } void NetworkManager::DcbSetting::setAppFcoePriority(qint32 priority) { Q_D(DcbSetting); d->appFcoePriority = priority; } qint32 NetworkManager::DcbSetting::appFcoePriority() const { Q_D(const DcbSetting); return d->appFcoePriority; } void NetworkManager::DcbSetting::setAppFipPriority(qint32 priority) { Q_D(DcbSetting); d->appFipPriority = priority; } qint32 NetworkManager::DcbSetting::appFipPriority() const { Q_D(const DcbSetting); return d->appFipPriority; } void NetworkManager::DcbSetting::setAppIscsiPriority(qint32 priority) { Q_D(DcbSetting); d->appIscsiPriority = priority; } qint32 NetworkManager::DcbSetting::appIscsiPriority() const { Q_D(const DcbSetting); return d->appIscsiPriority; } void NetworkManager::DcbSetting::setAppFcoeFlags(NetworkManager::DcbSetting::DcbFlags flags) { Q_D(DcbSetting); d->appFcoeFlags = flags; } NetworkManager::DcbSetting::DcbFlags NetworkManager::DcbSetting::appFcoeFlags() const { Q_D(const DcbSetting); return d->appFcoeFlags; } void NetworkManager::DcbSetting::setAppFipFlags(NetworkManager::DcbSetting::DcbFlags flags) { Q_D(DcbSetting); d->appFipFlags = flags; } NetworkManager::DcbSetting::DcbFlags NetworkManager::DcbSetting::appFipFlags() const { Q_D(const DcbSetting); return d->appFipFlags; } void NetworkManager::DcbSetting::setAppIscsiFlags(NetworkManager::DcbSetting::DcbFlags flags) { Q_D(DcbSetting); d->appIscsiFlags = flags; } NetworkManager::DcbSetting::DcbFlags NetworkManager::DcbSetting::appIscsiFlags() const { Q_D(const DcbSetting); return d->appIscsiFlags; } void NetworkManager::DcbSetting::setPriorityGroupFlags(NetworkManager::DcbSetting::DcbFlags flags) { Q_D(DcbSetting); d->priorityGroupFlags = flags; } NetworkManager::DcbSetting::DcbFlags NetworkManager::DcbSetting::priorityGroupFlags() const { Q_D(const DcbSetting); return d->priorityGroupFlags; } void NetworkManager::DcbSetting::setPriorityFlowControlFlags(NetworkManager::DcbSetting::DcbFlags flags) { Q_D(DcbSetting); d->priorityFlowControlFlags = flags; } NetworkManager::DcbSetting::DcbFlags NetworkManager::DcbSetting::priorityFlowControlFlags() const { Q_D(const DcbSetting); return d->priorityFlowControlFlags; } void NetworkManager::DcbSetting::setPriorityFlowControl(quint32 userPriority, bool enabled) { Q_D(DcbSetting); if (userPriority < 8) { d->priorityFlowControl[userPriority] = enabled; } } bool NetworkManager::DcbSetting::priorityFlowControl(quint32 userPriority) const { Q_D(const DcbSetting); if (userPriority < 8) { return d->priorityFlowControl.value(userPriority); } return false; } void NetworkManager::DcbSetting::setPriorityFlowControl(const UIntList &list) { Q_D(DcbSetting); d->priorityFlowControl = list; } UIntList NetworkManager::DcbSetting::priorityFlowControl() const { Q_D(const DcbSetting); return d->priorityFlowControl; } void NetworkManager::DcbSetting::setPriorityBandwidth(quint32 userPriority, quint32 bandwidthPercent) { Q_D(DcbSetting); if (userPriority < 8) { d->priorityBandwidth[userPriority] = bandwidthPercent; } } quint32 NetworkManager::DcbSetting::priorityBandwidth(quint32 userPriority) const { Q_D(const DcbSetting); if (userPriority < 8) { return d->priorityBandwidth.value(userPriority); } return 0; } void NetworkManager::DcbSetting::setPriorityBandwidth(const UIntList &list) { Q_D(DcbSetting); d->priorityBandwidth = list; } UIntList NetworkManager::DcbSetting::priorityBandwidth() const { Q_D(const DcbSetting); return d->priorityBandwidth; } void NetworkManager::DcbSetting::setPriorityGroupBandwidth(quint32 groupId, quint32 bandwidthPercent) { Q_D(DcbSetting); if (groupId < 8) { d->priorityGroupBandwidth[groupId] = bandwidthPercent; } } quint32 NetworkManager::DcbSetting::priorityGroupBandwidth(quint32 groupId) const { Q_D(const DcbSetting); if (groupId < 8) { return d->priorityGroupBandwidth.value(groupId); } return 0; } void NetworkManager::DcbSetting::setPriorityGroupBandwidth(const UIntList &list) { Q_D(DcbSetting); d->priorityGroupBandwidth = list; } UIntList NetworkManager::DcbSetting::priorityGroupBandwidth() const { Q_D(const DcbSetting); return d->priorityGroupBandwidth; } void NetworkManager::DcbSetting::setPriorityGroupId(quint32 userPriority, quint32 groupId) { Q_D(DcbSetting); if (userPriority < 8) { d->priorityGroupId[userPriority] = groupId; } } quint32 NetworkManager::DcbSetting::priorityGroupId(quint32 userPriority) const { Q_D(const DcbSetting); if (userPriority < 8) { return d->priorityGroupId.value(userPriority); } return 0; } void NetworkManager::DcbSetting::setPriorityGroupId(const UIntList &list) { Q_D(DcbSetting); d->priorityGroupId = list; } UIntList NetworkManager::DcbSetting::priorityGroupId() const { Q_D(const DcbSetting); return d->priorityGroupId; } void NetworkManager::DcbSetting::setPriorityStrictBandwidth(quint32 userPriority, bool strict) { Q_D(DcbSetting); if (userPriority < 8) { d->priorityStrictBandwidth[userPriority] = strict; } } bool NetworkManager::DcbSetting::priorityStrictBandwidth(quint32 userPriority) const { Q_D(const DcbSetting); if (userPriority < 8) { return d->priorityStrictBandwidth.value(userPriority); } return false; } void NetworkManager::DcbSetting::setPriorityStrictBandwidth(const UIntList &list) { Q_D(DcbSetting); d->priorityStrictBandwidth = list; } UIntList NetworkManager::DcbSetting::priorityStrictBandwidth() const { Q_D(const DcbSetting); return d->priorityStrictBandwidth; } void NetworkManager::DcbSetting::setPriorityTrafficClass(quint32 userPriority, quint32 trafficClass) { Q_D(DcbSetting); if (userPriority < 8) { d->priorityTrafficClass[userPriority] = trafficClass; } } quint32 NetworkManager::DcbSetting::priorityTrafficClass(quint32 userPriority) const { Q_D(const DcbSetting); if (userPriority < 8) { return d->priorityTrafficClass.value(userPriority); } return 0; } void NetworkManager::DcbSetting::setPriorityTrafficClass(const UIntList &list) { Q_D(DcbSetting); d->priorityTrafficClass = list; } UIntList NetworkManager::DcbSetting::priorityTrafficClass() const { Q_D(const DcbSetting); return d->priorityTrafficClass; } void NetworkManager::DcbSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_DCB_APP_FCOE_MODE))) { setAppFcoeMode(setting.value(QLatin1String(NM_SETTING_DCB_APP_FCOE_MODE)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_DCB_APP_FCOE_PRIORITY))) { setAppFcoePriority(setting.value(QLatin1String(NM_SETTING_DCB_APP_FCOE_PRIORITY)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_DCB_APP_FIP_PRIORITY))) { setAppFipPriority(setting.value(QLatin1String(NM_SETTING_DCB_APP_FIP_PRIORITY)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_DCB_APP_ISCSI_PRIORITY))) { setAppIscsiPriority(setting.value(QLatin1String(NM_SETTING_DCB_APP_ISCSI_PRIORITY)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_DCB_APP_FCOE_FLAGS))) { setAppFcoeFlags(static_cast(setting.value(QLatin1String(NM_SETTING_DCB_APP_FCOE_FLAGS)).toUInt())); } if (setting.contains(QLatin1String(NM_SETTING_DCB_APP_FIP_FLAGS))) { setAppFipFlags(static_cast(setting.value(QLatin1String(NM_SETTING_DCB_APP_FIP_FLAGS)).toUInt())); } if (setting.contains(QLatin1String(NM_SETTING_DCB_APP_ISCSI_FLAGS))) { setAppIscsiFlags(static_cast(setting.value(QLatin1String(NM_SETTING_DCB_APP_ISCSI_FLAGS)).toUInt())); } if (setting.contains(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_FLAGS))) { setPriorityGroupFlags(static_cast(setting.value(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_FLAGS)).toUInt())); } if (setting.contains(QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS))) { setPriorityFlowControlFlags(static_cast(setting.value(QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS)).toUInt())); } if (setting.contains(QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL))) { setPriorityFlowControl(qdbus_cast(setting.value(QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL)))); } if (setting.contains(QLatin1String(NM_SETTING_DCB_PRIORITY_BANDWIDTH))) { setPriorityBandwidth(qdbus_cast(setting.value(QLatin1String(NM_SETTING_DCB_PRIORITY_BANDWIDTH)))); } if (setting.contains(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH))) { setPriorityGroupBandwidth(qdbus_cast(setting.value(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH)))); } if (setting.contains(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_ID))) { setPriorityGroupId(qdbus_cast(setting.value(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_ID)))); } if (setting.contains(QLatin1String(NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH))) { setPriorityStrictBandwidth(qdbus_cast(setting.value(QLatin1String(NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH)))); } if (setting.contains(QLatin1String(NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS))) { setPriorityTrafficClass(qdbus_cast(setting.value(QLatin1String(NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS)))); } } QVariantMap NetworkManager::DcbSetting::toMap() const { QVariantMap setting; if (!appFcoeMode().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_DCB_APP_FCOE_MODE), appFcoeMode()); } if (appFcoePriority() >= 0) { setting.insert(QLatin1String(NM_SETTING_DCB_APP_FCOE_PRIORITY), appFcoePriority()); } if (appFipPriority() >= 0) { setting.insert(QLatin1String(NM_SETTING_DCB_APP_FIP_PRIORITY), appFipPriority()); } if (appIscsiPriority() >= 0) { setting.insert(QLatin1String(NM_SETTING_DCB_APP_ISCSI_PRIORITY), appIscsiPriority()); } setting.insert(QLatin1String(NM_SETTING_DCB_APP_FCOE_FLAGS), (int)appFcoeFlags()); setting.insert(QLatin1String(NM_SETTING_DCB_APP_FIP_FLAGS), (int)appFipFlags()); setting.insert(QLatin1String(NM_SETTING_DCB_APP_ISCSI_FLAGS), (int)appIscsiFlags()); setting.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_FLAGS), (int)priorityGroupFlags()); setting.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS), (int)priorityFlowControlFlags()); setting.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL), QVariant::fromValue(priorityFlowControl())); setting.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_BANDWIDTH), QVariant::fromValue(priorityBandwidth())); setting.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH), QVariant::fromValue(priorityGroupBandwidth())); setting.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_GROUP_ID), QVariant::fromValue(priorityGroupId())); setting.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH), QVariant::fromValue(priorityStrictBandwidth())); setting.insert(QLatin1String(NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS), QVariant::fromValue(priorityTrafficClass())); return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::DcbSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_DCB_APP_FCOE_MODE << ": " << setting.appFcoeMode() << '\n'; dbg.nospace() << NM_SETTING_DCB_APP_FCOE_PRIORITY << ": " << setting.appFcoePriority() << '\n'; dbg.nospace() << NM_SETTING_DCB_APP_FIP_PRIORITY << ": " << setting.appFipPriority() << '\n'; dbg.nospace() << NM_SETTING_DCB_APP_ISCSI_PRIORITY << ": " << setting.appIscsiPriority() << '\n'; dbg.nospace() << NM_SETTING_DCB_APP_FCOE_FLAGS << ": " << setting.appFcoeFlags() << '\n'; dbg.nospace() << NM_SETTING_DCB_APP_FIP_FLAGS << ": " << setting.appFipFlags() << '\n'; dbg.nospace() << NM_SETTING_DCB_APP_ISCSI_FLAGS << ": " << setting.appIscsiFlags() << '\n'; dbg.nospace() << NM_SETTING_DCB_PRIORITY_GROUP_FLAGS << ": " << setting.priorityGroupFlags() << '\n'; dbg.nospace() << NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS << ": " << setting.priorityFlowControlFlags() << '\n'; dbg.nospace() << NM_SETTING_DCB_PRIORITY_FLOW_CONTROL << ": "; Q_FOREACH (const quint32 enabled, setting.priorityFlowControl()) { dbg.nospace() << enabled << ' '; } dbg.nospace() << '\n'; dbg.nospace() << NM_SETTING_DCB_PRIORITY_BANDWIDTH << ": "; Q_FOREACH (const quint32 bandwidthPercent, setting.priorityBandwidth()) { dbg.nospace() << bandwidthPercent << ' '; } dbg.nospace() << '\n'; dbg.nospace() << NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH << ": "; Q_FOREACH (const quint32 bandwidthPercent, setting.priorityGroupBandwidth()) { dbg.nospace() << bandwidthPercent << ' '; } dbg.nospace() << '\n'; dbg.nospace() << NM_SETTING_DCB_PRIORITY_GROUP_ID << ": "; Q_FOREACH (const quint32 groupId, setting.priorityGroupId()) { dbg.nospace() << groupId << ' '; } dbg.nospace() << '\n'; dbg.nospace() << NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH << ": "; Q_FOREACH (const quint32 strict, setting.priorityStrictBandwidth()) { dbg.nospace() << strict << ' '; } dbg.nospace() << '\n'; dbg.nospace() << NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS << ": "; Q_FOREACH (const quint32 trafficClass, setting.priorityTrafficClass()) { dbg.nospace() << trafficClass << ' '; } dbg.nospace() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/dcbsetting.h b/src/settings/dcbsetting.h index c9b2b41..4babfaa 100644 --- a/src/settings/dcbsetting.h +++ b/src/settings/dcbsetting.h @@ -1,130 +1,116 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DCBSETTING_H #define NETWORKMANAGERQT_DCBSETTING_H #include #include "setting.h" #include namespace NetworkManager { class DcbSettingPrivate; /** * Represents Dcb setting */ class NETWORKMANAGERQT_EXPORT DcbSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum DcbFlagType { None = 0, Enable = 0x01, Advertise = 0x02, Willing = 0x04 }; Q_DECLARE_FLAGS(DcbFlags, DcbFlagType) DcbSetting(); explicit DcbSetting(const Ptr &other); ~DcbSetting() override; QString name() const override; void setAppFcoeMode(const QString &mode); QString appFcoeMode() const; void setAppFcoePriority(qint32 priority); qint32 appFcoePriority() const; void setAppFipPriority(qint32 priority); qint32 appFipPriority() const; void setAppIscsiPriority(qint32 priority); qint32 appIscsiPriority() const; void setAppFcoeFlags(DcbFlags flags); DcbFlags appFcoeFlags() const; void setAppFipFlags(DcbFlags flags); DcbFlags appFipFlags() const; void setAppIscsiFlags(DcbFlags flags); DcbFlags appIscsiFlags() const; void setPriorityGroupFlags(DcbFlags flags); DcbFlags priorityGroupFlags() const; void setPriorityFlowControlFlags(DcbFlags flags); DcbFlags priorityFlowControlFlags() const; void setPriorityFlowControl(quint32 userPriority, bool enabled); bool priorityFlowControl(quint32 userPriority) const; void setPriorityFlowControl(const UIntList &list); UIntList priorityFlowControl() const; void setPriorityBandwidth(quint32 userPriority, quint32 bandwidthPercent); quint32 priorityBandwidth(quint32 userPriority) const; void setPriorityBandwidth(const UIntList &list); UIntList priorityBandwidth() const; void setPriorityGroupBandwidth(quint32 groupId, quint32 bandwidthPercent); quint32 priorityGroupBandwidth(quint32 groupId) const; void setPriorityGroupBandwidth(const UIntList &list); UIntList priorityGroupBandwidth() const; void setPriorityGroupId(quint32 userPriority, quint32 groupId); quint32 priorityGroupId(quint32 userPriority) const; void setPriorityGroupId(const UIntList &list); UIntList priorityGroupId() const; void setPriorityStrictBandwidth(quint32 userPriority, bool strict); bool priorityStrictBandwidth(quint32 userPriority) const; void setPriorityStrictBandwidth(const UIntList &list); UIntList priorityStrictBandwidth() const; void setPriorityTrafficClass(quint32 userPriority, quint32 trafficClass); quint32 priorityTrafficClass(quint32 userPriority) const; void setPriorityTrafficClass(const UIntList &list); UIntList priorityTrafficClass() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: DcbSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(DcbSetting) }; Q_DECLARE_OPERATORS_FOR_FLAGS(DcbSetting::DcbFlags) NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const DcbSetting &setting); } #endif // NETWORKMANAGERQT_DCBSETTING_H diff --git a/src/settings/dcbsetting_p.h b/src/settings/dcbsetting_p.h index 0f8e981..668ea4d 100644 --- a/src/settings/dcbsetting_p.h +++ b/src/settings/dcbsetting_p.h @@ -1,55 +1,41 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_DCBSETTING_P_H #define NETWORKMANAGERQT_DCBSETTING_P_H #include namespace NetworkManager { class DcbSettingPrivate { public: DcbSettingPrivate(); QString name; QString appFcoeMode; qint32 appFcoePriority; qint32 appFipPriority; qint32 appIscsiPriority; NetworkManager::DcbSetting::DcbFlags appFcoeFlags; NetworkManager::DcbSetting::DcbFlags appFipFlags; NetworkManager::DcbSetting::DcbFlags appIscsiFlags; NetworkManager::DcbSetting::DcbFlags priorityGroupFlags; NetworkManager::DcbSetting::DcbFlags priorityFlowControlFlags; UIntList priorityFlowControl; UIntList priorityBandwidth; UIntList priorityGroupBandwidth; UIntList priorityGroupId; UIntList priorityStrictBandwidth; UIntList priorityTrafficClass; }; } #endif // NETWORKMANAGERQT_DCBSETTING_P_H diff --git a/src/settings/genericsetting.cpp b/src/settings/genericsetting.cpp index 2c98dcc..11c7e6f 100644 --- a/src/settings/genericsetting.cpp +++ b/src/settings/genericsetting.cpp @@ -1,71 +1,57 @@ /* - Copyright 2015 Jan Grulich + SPDX-FileCopyrightText: 2015 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "genericsetting.h" #include "genericsetting_p.h" #include "nmdebug.h" NetworkManager::GenericSettingPrivate::GenericSettingPrivate() : name(NM_SETTING_GENERIC_SETTING_NAME) { } NetworkManager::GenericSetting::GenericSetting() : Setting(Setting::Generic) , d_ptr(new GenericSettingPrivate()) { } NetworkManager::GenericSetting::GenericSetting(const Ptr &other) : Setting(other) , d_ptr(new GenericSettingPrivate()) { } NetworkManager::GenericSetting::~GenericSetting() { delete d_ptr; } QString NetworkManager::GenericSetting::name() const { Q_D(const GenericSetting); return d->name; } void NetworkManager::GenericSetting::fromMap(const QVariantMap &setting) { Q_UNUSED(setting); } QVariantMap NetworkManager::GenericSetting::toMap() const { QVariantMap setting; return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::GenericSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/genericsetting.h b/src/settings/genericsetting.h index e905609..64e6e7a 100644 --- a/src/settings/genericsetting.h +++ b/src/settings/genericsetting.h @@ -1,63 +1,49 @@ /* - Copyright 2015 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2015 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_GENERIC_SETTING_H #define NETWORKMANAGERQT_GENERIC_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class GenericSettingPrivate; /** * Represents generic setting */ class NETWORKMANAGERQT_EXPORT GenericSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; GenericSetting(); explicit GenericSetting(const Ptr &other); ~GenericSetting(); QString name() const override; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: GenericSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(GenericSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const GenericSetting &setting); } #endif // NETWORKMANAGERQT_GENERIC_SETTING_H diff --git a/src/settings/genericsetting_p.h b/src/settings/genericsetting_p.h index e28b349..3b4c8de 100644 --- a/src/settings/genericsetting_p.h +++ b/src/settings/genericsetting_p.h @@ -1,39 +1,25 @@ /* - Copyright 2015 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2015 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_GENERIC_SETTING_P_H #define NETWORKMANAGERQT_GENERIC_SETTING_P_H #include namespace NetworkManager { class GenericSettingPrivate { public: GenericSettingPrivate(); QString name; }; } #endif // NETWORKMANAGERQT_GENERIC_SETTING_P_H diff --git a/src/settings/gsmsetting.cpp b/src/settings/gsmsetting.cpp index 38269a7..96d88ae 100644 --- a/src/settings/gsmsetting.cpp +++ b/src/settings/gsmsetting.cpp @@ -1,453 +1,439 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "gsmsetting.h" #include "gsmsetting_p.h" #define NM_SETTING_GSM_NETWORK_TYPE "network-type" #define NM_SETTING_GSM_ALLOWED_BANDS "allowed-bands" #include NetworkManager::GsmSettingPrivate::GsmSettingPrivate() : name(NM_SETTING_GSM_SETTING_NAME) , passwordFlags(NetworkManager::GsmSetting::None) , networkType(NetworkManager::GsmSetting::Any) , pinFlags(NetworkManager::GsmSetting::None) , allowedBand(1) , homeOnly(false) { } NetworkManager::GsmSetting::GsmSetting() : Setting(Setting::Gsm) , d_ptr(new GsmSettingPrivate()) { } NetworkManager::GsmSetting::GsmSetting(const Ptr &other) : Setting(other) , d_ptr(new GsmSettingPrivate()) { setNumber(other->number()); setUsername(other->username()); setPassword(other->password()); setPasswordFlags(other->passwordFlags()); setApn(other->apn()); setNetworkId(other->networkId()); setNetworkType(other->networkType()); setPin(other->pin()); setPinFlags(other->pinFlags()); setAllowedBand(other->allowedBand()); setHomeOnly(other->homeOnly()); setDeviceId(other->deviceId()); setSimId(other->simId()); setSimOperatorId(other->simOperatorId()); } NetworkManager::GsmSetting::~GsmSetting() { delete d_ptr; } QString NetworkManager::GsmSetting::name() const { Q_D(const GsmSetting); return d->name; } void NetworkManager::GsmSetting::setNumber(const QString &number) { Q_D(GsmSetting); d->number = number; } QString NetworkManager::GsmSetting::number() const { Q_D(const GsmSetting); return d->number; } void NetworkManager::GsmSetting::setUsername(const QString &username) { Q_D(GsmSetting); d->username = username; } QString NetworkManager::GsmSetting::username() const { Q_D(const GsmSetting); return d->username; } void NetworkManager::GsmSetting::setPassword(const QString &password) { Q_D(GsmSetting); d->password = password; } QString NetworkManager::GsmSetting::password() const { Q_D(const GsmSetting); return d->password; } void NetworkManager::GsmSetting::setPasswordFlags(GsmSetting::SecretFlags flags) { Q_D(GsmSetting); d->passwordFlags = flags; } NetworkManager::GsmSetting::SecretFlags NetworkManager::GsmSetting::passwordFlags() const { Q_D(const GsmSetting); return d->passwordFlags; } void NetworkManager::GsmSetting::setApn(const QString &apn) { Q_D(GsmSetting); d->apn = apn; } QString NetworkManager::GsmSetting::apn() const { Q_D(const GsmSetting); return d->apn; } void NetworkManager::GsmSetting::setNetworkId(const QString &id) { Q_D(GsmSetting); d->networkId = id; } QString NetworkManager::GsmSetting::networkId() const { Q_D(const GsmSetting); return d->networkId; } void NetworkManager::GsmSetting::setNetworkType(NetworkType type) { Q_D(GsmSetting); d->networkType = type; } NetworkManager::GsmSetting::NetworkType NetworkManager::GsmSetting::networkType() const { Q_D(const GsmSetting); return d->networkType; } void NetworkManager::GsmSetting::setPin(const QString &pin) { Q_D(GsmSetting); d->pin = pin; } QString NetworkManager::GsmSetting::pin() const { Q_D(const GsmSetting); return d->pin; } void NetworkManager::GsmSetting::setPinFlags(GsmSetting::SecretFlags flags) { Q_D(GsmSetting); d->pinFlags = flags; } NetworkManager::GsmSetting::SecretFlags NetworkManager::GsmSetting::pinFlags() const { Q_D(const GsmSetting); return d->pinFlags; } void NetworkManager::GsmSetting::setAllowedBand(quint32 band) { Q_D(GsmSetting); d->allowedBand = band; } quint32 NetworkManager::GsmSetting::allowedBand() const { Q_D(const GsmSetting); return d->allowedBand; } void NetworkManager::GsmSetting::setHomeOnly(bool homeOnly) { Q_D(GsmSetting); d->homeOnly = homeOnly; } bool NetworkManager::GsmSetting::homeOnly() const { Q_D(const GsmSetting); return d->homeOnly; } void NetworkManager::GsmSetting::setDeviceId(const QString &id) { Q_D(GsmSetting); d->deviceId = id; } QString NetworkManager::GsmSetting::deviceId() const { Q_D(const GsmSetting); return d->deviceId; } void NetworkManager::GsmSetting::setSimId(const QString &id) { Q_D(GsmSetting); d->simId = id; } QString NetworkManager::GsmSetting::simId() const { Q_D(const GsmSetting); return d->simId; } void NetworkManager::GsmSetting::setSimOperatorId(const QString &id) { Q_D(GsmSetting); d->simOperatorId = id; } QString NetworkManager::GsmSetting::simOperatorId() const { Q_D(const GsmSetting); return d->simOperatorId; } void NetworkManager::GsmSetting::secretsFromMap(const QVariantMap &secrets) { if (secrets.contains(QLatin1String(NM_SETTING_GSM_PASSWORD))) { setPassword(secrets.value(QLatin1String(NM_SETTING_GSM_PASSWORD)).toString()); } if (secrets.contains(QLatin1String(NM_SETTING_GSM_PIN))) { setPin(secrets.value(QLatin1String(NM_SETTING_GSM_PIN)).toString()); } } QVariantMap NetworkManager::GsmSetting::secretsToMap() const { QVariantMap secrets; if (!password().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_GSM_PASSWORD), password()); } if (!pin().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_GSM_PIN), pin()); } return secrets; } QStringList NetworkManager::GsmSetting::needSecrets(bool requestNew) const { QStringList list; if ((password().isEmpty() || requestNew) && !passwordFlags().testFlag(NotRequired)) { list << QLatin1String(NM_SETTING_GSM_PASSWORD); } if ((pin().isEmpty() || requestNew) && !pinFlags().testFlag(NotRequired)) { list << QLatin1String(NM_SETTING_GSM_PIN); } return list; } void NetworkManager::GsmSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_GSM_NUMBER))) { setNumber(setting.value(QLatin1String(NM_SETTING_GSM_NUMBER)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_USERNAME))) { setUsername(setting.value(QLatin1String(NM_SETTING_GSM_USERNAME)).toString()); } // Secrets if (setting.contains(QLatin1String(NM_SETTING_GSM_PASSWORD))) { setPassword(setting.value(QLatin1String(NM_SETTING_GSM_PASSWORD)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_PASSWORD_FLAGS))) { setPasswordFlags((SecretFlags)setting.value(QLatin1String(NM_SETTING_GSM_PASSWORD_FLAGS)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_APN))) { setApn(setting.value(QLatin1String(NM_SETTING_GSM_APN)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_NETWORK_ID))) { setNetworkId(setting.value(QLatin1String(NM_SETTING_GSM_NETWORK_ID)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_NETWORK_TYPE))) { setNetworkType((NetworkType)setting.value(QLatin1String(NM_SETTING_GSM_NETWORK_TYPE)).toInt()); } // Secrets if (setting.contains(QLatin1String(NM_SETTING_GSM_PIN))) { setPin(setting.value(QLatin1String(NM_SETTING_GSM_PIN)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_PIN_FLAGS))) { setPinFlags((SecretFlags)setting.value(QLatin1String(NM_SETTING_GSM_PIN_FLAGS)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_ALLOWED_BANDS))) { setAllowedBand(setting.value(QLatin1String(NM_SETTING_GSM_ALLOWED_BANDS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_HOME_ONLY))) { setHomeOnly(setting.value(QLatin1String(NM_SETTING_GSM_HOME_ONLY)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_DEVICE_ID))) { setDeviceId(setting.value(QLatin1String(NM_SETTING_GSM_DEVICE_ID)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_SIM_ID))) { setSimId(setting.value(QLatin1String(NM_SETTING_GSM_SIM_ID)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_GSM_SIM_OPERATOR_ID))) { setSimOperatorId(setting.value(QLatin1String(NM_SETTING_GSM_SIM_OPERATOR_ID)).toString()); } } QVariantMap NetworkManager::GsmSetting::toMap() const { QVariantMap setting; if (!number().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_GSM_NUMBER), number()); } if (!username().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_GSM_USERNAME), username()); } // Secrets if (!password().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_GSM_PASSWORD), password()); } setting.insert(QLatin1String(NM_SETTING_GSM_PASSWORD_FLAGS), (int)passwordFlags()); if (!apn().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_GSM_APN), apn()); } if (!networkId().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_GSM_NETWORK_ID), networkId()); } if (networkType() != -1) { setting.insert(QLatin1String(NM_SETTING_GSM_NETWORK_TYPE), networkType()); } // Secrets if (!pin().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_GSM_PIN), pin()); } setting.insert(QLatin1String(NM_SETTING_GSM_PIN_FLAGS), (int)pinFlags()); if (allowedBand() != 1) { setting.insert(QLatin1String(NM_SETTING_GSM_ALLOWED_BANDS), allowedBand()); } if (homeOnly()) { setting.insert(QLatin1String(NM_SETTING_GSM_HOME_ONLY), homeOnly()); } if (!deviceId().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_GSM_DEVICE_ID), deviceId()); } if (!simId().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_GSM_SIM_ID), simId()); } if (!simOperatorId().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_GSM_SIM_OPERATOR_ID), simOperatorId()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::GsmSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_GSM_NUMBER << ": " << setting.number() << '\n'; dbg.nospace() << NM_SETTING_GSM_USERNAME << ": " << setting.username() << '\n'; dbg.nospace() << NM_SETTING_GSM_PASSWORD << ": " << setting.password() << '\n'; dbg.nospace() << NM_SETTING_GSM_PASSWORD_FLAGS << ": " << setting.passwordFlags() << '\n'; dbg.nospace() << NM_SETTING_GSM_APN << ": " << setting.apn() << '\n'; dbg.nospace() << NM_SETTING_GSM_NETWORK_ID << ": " << setting.networkId() << '\n'; dbg.nospace() << NM_SETTING_GSM_NETWORK_TYPE << ": " << setting.networkType() << '\n'; dbg.nospace() << NM_SETTING_GSM_ALLOWED_BANDS << ": " << setting.allowedBand() << '\n'; dbg.nospace() << NM_SETTING_GSM_PIN << ": " << setting.pin() << '\n'; dbg.nospace() << NM_SETTING_GSM_PIN_FLAGS << ": " << setting.pinFlags() << '\n'; dbg.nospace() << NM_SETTING_GSM_HOME_ONLY << ": " << setting.homeOnly() << '\n'; dbg.nospace() << NM_SETTING_GSM_DEVICE_ID << ": " << setting.deviceId() << '\n'; dbg.nospace() << NM_SETTING_GSM_SIM_ID << ": " << setting.simId() << '\n'; dbg.nospace() << NM_SETTING_GSM_SIM_OPERATOR_ID << ": " << setting.simOperatorId() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/gsmsetting.h b/src/settings/gsmsetting.h index ad60c4b..3eb7497 100644 --- a/src/settings/gsmsetting.h +++ b/src/settings/gsmsetting.h @@ -1,115 +1,101 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_GSM_SETTING_H #define NETWORKMANAGERQT_GSM_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class GsmSettingPrivate; /** * Represents gsm setting */ class NETWORKMANAGERQT_EXPORT GsmSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum NetworkType { Any = -1, Only3G, GprsEdgeOnly, Prefer3G, Prefer2G, Prefer4GLte, Only4GLte }; GsmSetting(); explicit GsmSetting(const Ptr &other); ~GsmSetting() override; QString name() const override; void setNumber(const QString &number); QString number() const; void setUsername(const QString &username); QString username() const; void setPassword(const QString &password); QString password() const; void setPasswordFlags(SecretFlags flags); SecretFlags passwordFlags() const; void setApn(const QString &apn); QString apn() const; void setNetworkId(const QString &id); QString networkId() const; /// @deprecated since NM 1.0.0 void setNetworkType(NetworkType type); NetworkType networkType() const; void setPin(const QString &pin); QString pin() const; void setPinFlags(SecretFlags flags); SecretFlags pinFlags() const; /// @deprecated since NM 1.0.0 void setAllowedBand(quint32 band); quint32 allowedBand() const; void setHomeOnly(bool homeOnly); bool homeOnly() const; void setDeviceId(const QString &id); QString deviceId() const; void setSimId(const QString &id); QString simId() const; void setSimOperatorId(const QString &id); QString simOperatorId() const; void secretsFromMap(const QVariantMap &secrets) override; QVariantMap secretsToMap() const override; QStringList needSecrets(bool requestNew = false) const override; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: GsmSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(GsmSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const GsmSetting &setting); } #endif // NETWORKMANAGERQT_GSM_SETTING_H diff --git a/src/settings/gsmsetting_p.h b/src/settings/gsmsetting_p.h index 170953b..18524e4 100644 --- a/src/settings/gsmsetting_p.h +++ b/src/settings/gsmsetting_p.h @@ -1,53 +1,39 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_GSM_SETTING_P_H #define NETWORKMANAGERQT_GSM_SETTING_P_H #include namespace NetworkManager { class GsmSettingPrivate { public: GsmSettingPrivate(); QString name; QString number; QString username; QString password; NetworkManager::Setting::SecretFlags passwordFlags; QString apn; QString networkId; NetworkManager::GsmSetting::NetworkType networkType; QString pin; NetworkManager::Setting::SecretFlags pinFlags; quint32 allowedBand; bool homeOnly; QString deviceId; QString simId; QString simOperatorId; }; } #endif // NETWORKMANAGERQT_GSM_SETTING_P_H diff --git a/src/settings/infinibandsetting.cpp b/src/settings/infinibandsetting.cpp index ef9eb57..07ec2fd 100644 --- a/src/settings/infinibandsetting.cpp +++ b/src/settings/infinibandsetting.cpp @@ -1,203 +1,189 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "infinibandsetting.h" #include "infinibandsetting_p.h" #include NetworkManager::InfinibandSettingPrivate::InfinibandSettingPrivate() : name(NM_SETTING_INFINIBAND_SETTING_NAME) , mtu(0) , transportMode(InfinibandSetting::Unknown) , pKey(-1) { } NetworkManager::InfinibandSetting::InfinibandSetting() : Setting(Setting::Infiniband) , d_ptr(new InfinibandSettingPrivate()) { } NetworkManager::InfinibandSetting::InfinibandSetting(const NetworkManager::InfinibandSetting::Ptr &other) : Setting(other) , d_ptr(new InfinibandSettingPrivate()) { setMacAddress(other->macAddress()); setMtu(other->mtu()); setTransportMode(other->transportMode()); setPKey(other->pKey()); setParent(other->parent()); } NetworkManager::InfinibandSetting::~InfinibandSetting() { delete d_ptr; } QString NetworkManager::InfinibandSetting::name() const { Q_D(const InfinibandSetting); return d->name; } void NetworkManager::InfinibandSetting::setMacAddress(const QByteArray &address) { Q_D(InfinibandSetting); d->macAddress = address; } QByteArray NetworkManager::InfinibandSetting::macAddress() const { Q_D(const InfinibandSetting); return d->macAddress; } void NetworkManager::InfinibandSetting::setMtu(quint32 mtu) { Q_D(InfinibandSetting); d->mtu = mtu; } quint32 NetworkManager::InfinibandSetting::mtu() const { Q_D(const InfinibandSetting); return d->mtu; } void NetworkManager::InfinibandSetting::setTransportMode(NetworkManager::InfinibandSetting::TransportMode mode) { Q_D(InfinibandSetting); d->transportMode = mode; } NetworkManager::InfinibandSetting::TransportMode NetworkManager::InfinibandSetting::transportMode() const { Q_D(const InfinibandSetting); return d->transportMode; } void NetworkManager::InfinibandSetting::setPKey(qint32 key) { Q_D(InfinibandSetting); d->pKey = key; } qint32 NetworkManager::InfinibandSetting::pKey() const { Q_D(const InfinibandSetting); return d->pKey; } void NetworkManager::InfinibandSetting::setParent(const QString &parent) { Q_D(InfinibandSetting); d->parent = parent; } QString NetworkManager::InfinibandSetting::parent() const { Q_D(const InfinibandSetting); return d->parent; } void NetworkManager::InfinibandSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_INFINIBAND_MAC_ADDRESS))) { setMacAddress(setting.value(QLatin1String(NM_SETTING_INFINIBAND_MAC_ADDRESS)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_INFINIBAND_MTU))) { setMtu(setting.value(QLatin1String(NM_SETTING_INFINIBAND_MTU)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_INFINIBAND_TRANSPORT_MODE))) { QString mode = setting.value(QLatin1String(NM_SETTING_INFINIBAND_TRANSPORT_MODE)).toString(); if (mode == "datagram") { setTransportMode(Datagram); } else if (mode == "connected") { setTransportMode(Connected); } } if (setting.contains(QLatin1String(NM_SETTING_INFINIBAND_P_KEY))) { setPKey(setting.value(QLatin1String(NM_SETTING_INFINIBAND_P_KEY)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_INFINIBAND_PARENT))) { setParent(setting.value(QLatin1String(NM_SETTING_INFINIBAND_PARENT)).toString()); } } QVariantMap NetworkManager::InfinibandSetting::toMap() const { QVariantMap setting; if (!macAddress().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_INFINIBAND_MAC_ADDRESS), macAddress()); } if (mtu()) { setting.insert(QLatin1String(NM_SETTING_INFINIBAND_MTU), mtu()); } if (transportMode() != Unknown) { if (transportMode() == Datagram) { setting.insert(QLatin1String(NM_SETTING_INFINIBAND_TRANSPORT_MODE), "datagram"); } else if (transportMode() == Connected) { setting.insert(QLatin1String(NM_SETTING_INFINIBAND_TRANSPORT_MODE), "connected"); } } if (pKey() != -1) { setting.insert(QLatin1String(NM_SETTING_INFINIBAND_P_KEY), pKey()); } if (!parent().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_INFINIBAND_PARENT), parent()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::InfinibandSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_INFINIBAND_MAC_ADDRESS << ": " << setting.macAddress() << '\n'; dbg.nospace() << NM_SETTING_INFINIBAND_MTU << ": " << setting.mtu() << '\n'; dbg.nospace() << NM_SETTING_INFINIBAND_TRANSPORT_MODE << ": " << setting.transportMode() << '\n'; dbg.nospace() << NM_SETTING_INFINIBAND_P_KEY << ": " << setting.pKey() << '\n'; dbg.nospace() << NM_SETTING_INFINIBAND_PARENT << ": " << setting.parent() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/infinibandsetting.h b/src/settings/infinibandsetting.h index e451959..5c06c8a 100644 --- a/src/settings/infinibandsetting.h +++ b/src/settings/infinibandsetting.h @@ -1,80 +1,66 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_INFINIBAND_SETTING_H #define NETWORKMANAGERQT_INFINIBAND_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class InfinibandSettingPrivate; /** * Represents infiniband setting */ class NETWORKMANAGERQT_EXPORT InfinibandSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum TransportMode {Unknown = 0, Datagram, Connected}; InfinibandSetting(); explicit InfinibandSetting(const Ptr &other); ~InfinibandSetting() override; QString name() const override; void setMacAddress(const QByteArray &address); QByteArray macAddress() const; void setMtu(quint32 mtu); quint32 mtu() const; void setTransportMode(TransportMode mode); TransportMode transportMode() const; void setPKey(qint32 key); qint32 pKey() const; void setParent(const QString &parent); QString parent() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: InfinibandSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(InfinibandSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const InfinibandSetting &setting); } #endif // NETWORKMANAGERQT_INFINIBAND_SETTING_H diff --git a/src/settings/infinibandsetting_p.h b/src/settings/infinibandsetting_p.h index de53b90..8ef5d35 100644 --- a/src/settings/infinibandsetting_p.h +++ b/src/settings/infinibandsetting_p.h @@ -1,45 +1,31 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_INFINIBAND_SETTING_P_H #define NETWORKMANAGERQT_INFINIBAND_SETTING_P_H #include namespace NetworkManager { class InfinibandSettingPrivate { public: InfinibandSettingPrivate(); QString name; QByteArray macAddress; quint32 mtu; NetworkManager::InfinibandSetting::TransportMode transportMode; qint32 pKey; QString parent; }; } #endif // NETWORKMANAGERQT_INFINIBAND_SETTING_P_H diff --git a/src/settings/iptunnelsetting.cpp b/src/settings/iptunnelsetting.cpp index 3c5d0b1..b6d5277 100644 --- a/src/settings/iptunnelsetting.cpp +++ b/src/settings/iptunnelsetting.cpp @@ -1,392 +1,378 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "iptunnelsetting.h" #include "iptunnelsetting_p.h" #include #if !NM_CHECK_VERSION(1, 12, 0) #define NM_SETTING_IP_TUNNEL_FLAGS "flags" #endif NetworkManager::IpTunnelSettingPrivate::IpTunnelSettingPrivate() : name(NM_SETTING_IP_TUNNEL_SETTING_NAME) , mode(IpTunnelSetting::Unknown) , pathMtuDiscovery(true) , encapsulationLimit(0) , flags(IpTunnelSetting::None) , flowLabel(0) , mtu(0) , tos(0) , ttl(0) { } NetworkManager::IpTunnelSetting::IpTunnelSetting() : Setting(Setting::IpTunnel) , d_ptr(new IpTunnelSettingPrivate()) { } NetworkManager::IpTunnelSetting::IpTunnelSetting(const Ptr &other) : Setting(other) , d_ptr(new IpTunnelSettingPrivate()) { setMode(other->mode()); setPathMtuDiscovery(other->pathMtuDiscovery()); setEncapsulationLimit(other->encapsulationLimit()); setFlags(other->flags()); setFlowLabel(other->flowLabel()); setMtu(other->mtu()); setTos(other->tos()); setTtl(other->ttl()); setInputKey(other->inputKey()); setLocal(other->local()); setOutputKey(other->outputKey()); setParent(other->parent()); setRemote(other->remote()); } NetworkManager::IpTunnelSetting::~IpTunnelSetting() { delete d_ptr; } QString NetworkManager::IpTunnelSetting::name() const { Q_D(const IpTunnelSetting); return d->name; } void NetworkManager::IpTunnelSetting::setMode(NetworkManager::IpTunnelSetting::Mode mode) { Q_D(IpTunnelSetting); d->mode = mode; } NetworkManager::IpTunnelSetting::Mode NetworkManager::IpTunnelSetting::mode() const { Q_D(const IpTunnelSetting); return d->mode; } void NetworkManager::IpTunnelSetting::setPathMtuDiscovery(bool discovery) { Q_D(IpTunnelSetting); d->pathMtuDiscovery = discovery; } bool NetworkManager::IpTunnelSetting::pathMtuDiscovery() const { Q_D(const IpTunnelSetting); return d->pathMtuDiscovery; } void NetworkManager::IpTunnelSetting::setEncapsulationLimit(quint32 limit) { Q_D(IpTunnelSetting); d->encapsulationLimit = limit; } quint32 NetworkManager::IpTunnelSetting::encapsulationLimit() const { Q_D(const IpTunnelSetting); return d->encapsulationLimit; } void NetworkManager::IpTunnelSetting::setFlags(NetworkManager::IpTunnelSetting::Flags flags) { Q_D(IpTunnelSetting); d->flags = flags; } NetworkManager::IpTunnelSetting::Flags NetworkManager::IpTunnelSetting::flags() const { Q_D(const IpTunnelSetting); return d->flags; } void NetworkManager::IpTunnelSetting::setFlowLabel(quint32 label) { Q_D(IpTunnelSetting); d->flowLabel = label; } quint32 NetworkManager::IpTunnelSetting::flowLabel() const { Q_D(const IpTunnelSetting); return d->flowLabel; } void NetworkManager::IpTunnelSetting::setMtu(quint32 mtu) { Q_D(IpTunnelSetting); d->mtu = mtu; } quint32 NetworkManager::IpTunnelSetting::mtu() const { Q_D(const IpTunnelSetting); return d->mtu; } void NetworkManager::IpTunnelSetting::setTos(quint32 tos) { Q_D(IpTunnelSetting); d->tos = tos; } quint32 NetworkManager::IpTunnelSetting::tos() const { Q_D(const IpTunnelSetting); return d->tos; } void NetworkManager::IpTunnelSetting::setTtl(quint32 ttl) { Q_D(IpTunnelSetting); d->ttl = ttl; } quint32 NetworkManager::IpTunnelSetting::ttl() const { Q_D(const IpTunnelSetting); return d->ttl; } void NetworkManager::IpTunnelSetting::setInputKey(const QString &key) { Q_D(IpTunnelSetting); d->inputKey = key; } QString NetworkManager::IpTunnelSetting::inputKey() const { Q_D(const IpTunnelSetting); return d->inputKey; } void NetworkManager::IpTunnelSetting::setLocal(const QString &local) { Q_D(IpTunnelSetting); d->local = local; } QString NetworkManager::IpTunnelSetting::local() const { Q_D(const IpTunnelSetting); return d->local; } void NetworkManager::IpTunnelSetting::setParent(const QString &parent) { Q_D(IpTunnelSetting); d->parent = parent; } QString NetworkManager::IpTunnelSetting::parent() const { Q_D(const IpTunnelSetting); return d->parent; } void NetworkManager::IpTunnelSetting::setOutputKey(const QString &key) { Q_D(IpTunnelSetting); d->outputKey = key; } QString NetworkManager::IpTunnelSetting::outputKey() const { Q_D(const IpTunnelSetting); return d->outputKey; } void NetworkManager::IpTunnelSetting::setRemote(const QString &remote) { Q_D(IpTunnelSetting); d->remote = remote; } QString NetworkManager::IpTunnelSetting::remote() const { Q_D(const IpTunnelSetting); return d->remote; } void NetworkManager::IpTunnelSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_MODE))) { setMode((Mode)setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_MODE)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY))) { setPathMtuDiscovery(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT))) { setEncapsulationLimit(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS))) { setFlags((Flag)setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL))) { setFlowLabel(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_MTU))) { setMtu(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_MTU)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_TOS))) { setTos(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_TOS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_TTL))) { setTtl(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_TTL)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY))) { setInputKey(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL))) { setLocal(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT))) { setParent(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY))) { setOutputKey(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE))) { setRemote(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE)).toString()); } } QVariantMap NetworkManager::IpTunnelSetting::toMap() const { QVariantMap setting; setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY), pathMtuDiscovery()); if (mode() != Unknown) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MODE), (int)mode()); } if (encapsulationLimit() > 0) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT), encapsulationLimit()); } if (flags() > None) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS), (int)flags()); } if (flowLabel() > 0) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL), flowLabel()); } if (mtu() > 0) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MTU), mtu()); } if (tos() > 0) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TOS), tos()); } if (ttl() > 0) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TTL), ttl()); } if (!inputKey().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY), inputKey()); } if (!local().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL), local()); } if (!parent().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT), parent()); } if (!outputKey().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY), outputKey()); } if (!remote().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE), remote()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::IpTunnelSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_MODE << ": " << setting.mode() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY << ": " << setting.pathMtuDiscovery() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT << ": " << setting.encapsulationLimit() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_FLAGS << ": " << setting.flags() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_FLOW_LABEL << ": " << setting.flowLabel() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_MTU << ": " << setting.mtu() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_TOS << ": " << setting.tos() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_TTL << ": " << setting.ttl() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_INPUT_KEY << ": " << setting.inputKey() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_LOCAL << ": " << setting.local() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_PARENT << ": " << setting.parent() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_OUTPUT_KEY << ": " << setting.outputKey() << '\n'; dbg.nospace() << NM_SETTING_IP_TUNNEL_REMOTE << ": " << setting.remote() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/iptunnelsetting.h b/src/settings/iptunnelsetting.h index 45cf628..8837c3d 100644 --- a/src/settings/iptunnelsetting.h +++ b/src/settings/iptunnelsetting.h @@ -1,126 +1,112 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPTUNNEL_SETTING_H #define NETWORKMANAGERQT_IPTUNNEL_SETTING_H #include #include "setting.h" namespace NetworkManager { class IpTunnelSettingPrivate; /** * Represents IpTunnel setting */ class NETWORKMANAGERQT_EXPORT IpTunnelSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum Mode { Unknown = NM_IP_TUNNEL_MODE_UNKNOWN, Ipip = NM_IP_TUNNEL_MODE_IPIP, Gre = NM_IP_TUNNEL_MODE_GRE, Sit = NM_IP_TUNNEL_MODE_SIT, Isatap = NM_IP_TUNNEL_MODE_ISATAP, Vti = NM_IP_TUNNEL_MODE_VTI, Ip6ip6 = NM_IP_TUNNEL_MODE_IP6IP6, Ipip6 = NM_IP_TUNNEL_MODE_IPIP6, Ip6gre = NM_IP_TUNNEL_MODE_IP6GRE, Vti6 = NM_IP_TUNNEL_MODE_VTI }; enum Flag { None = 0x0, Ip6IgnEncapLimit = 0x1, Ip6UseOrigTclass = 0x2, Ip6UseOrigFlowlabel = 0x4, Ip6Mip6Dev = 0x8, Ip6RcvDscpCopy = 0x10, Ip6UseOrigFwmark = 0x20 }; Q_DECLARE_FLAGS(Flags, Flag) IpTunnelSetting(); explicit IpTunnelSetting(const Ptr &other); ~IpTunnelSetting() override; QString name() const override; void setMode(Mode mode); Mode mode() const; void setPathMtuDiscovery(bool discovery); bool pathMtuDiscovery() const; void setEncapsulationLimit(quint32 limit); quint32 encapsulationLimit() const; void setFlags(Flags flags); Flags flags() const; void setFlowLabel(quint32 label); quint32 flowLabel() const; void setMtu(quint32 mtu); quint32 mtu() const; void setTos(quint32 tos); quint32 tos() const; void setTtl(quint32 ttl); quint32 ttl() const; void setInputKey(const QString &key); QString inputKey() const; void setLocal(const QString &local); QString local() const; void setParent(const QString &parent); QString parent() const; void setOutputKey(const QString &key); QString outputKey() const; void setRemote(const QString &remote); QString remote() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: IpTunnelSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(IpTunnelSetting) }; Q_DECLARE_OPERATORS_FOR_FLAGS(IpTunnelSetting::Flags) NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const IpTunnelSetting &setting); } #endif // NETWORKMANAGERQT_IP_TUNNEL_SETTING_H diff --git a/src/settings/iptunnelsetting_p.h b/src/settings/iptunnelsetting_p.h index a032148..e86887d 100644 --- a/src/settings/iptunnelsetting_p.h +++ b/src/settings/iptunnelsetting_p.h @@ -1,54 +1,40 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IP_TUNNEL_SETTING_P_H #define NETWORKMANAGERQT_IP_TUNNEL_SETTING_P_H #include namespace NetworkManager { class IpTunnelSettingPrivate { public: IpTunnelSettingPrivate(); QString name; NetworkManager::IpTunnelSetting::Mode mode; bool pathMtuDiscovery; quint32 encapsulationLimit; NetworkManager::IpTunnelSetting::Flags flags; quint32 flowLabel; quint32 mtu; quint32 tos; quint32 ttl; QString inputKey; QString local; QString outputKey; QString parent; QString remote; }; } #endif // NETWORKMANAGERQT_IP_TUNNEL_SETTING_P_H diff --git a/src/settings/ipv4setting.cpp b/src/settings/ipv4setting.cpp index 0638cfd..c4d02f2 100644 --- a/src/settings/ipv4setting.cpp +++ b/src/settings/ipv4setting.cpp @@ -1,696 +1,682 @@ /* - Copyright 2012-2013 Jan Grulich - Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ipv4setting.h" #include "ipv4setting_p.h" #include "generictypes.h" #include #include NetworkManager::Ipv4SettingPrivate::Ipv4SettingPrivate() : name(NMQT_SETTING_IP4_CONFIG_SETTING_NAME) , method(NetworkManager::Ipv4Setting::Automatic) , routeMetric(-1) , ignoreAutoRoutes(false) , ignoreAutoDns(false) , dhcpSendHostname(true) , neverDefault(false) , mayFail(true) , dadTimeout(-1) , dnsPriority(0) { } NetworkManager::Ipv4Setting::Ipv4Setting() : Setting(Setting::Ipv4) , d_ptr(new Ipv4SettingPrivate()) { } NetworkManager::Ipv4Setting::Ipv4Setting(const Ptr &other) : Setting(other) , d_ptr(new Ipv4SettingPrivate()) { setMethod(other->method()); setDns(other->dns()); setDnsSearch(other->dnsSearch()); setAddresses(other->addresses()); setRoutes(other->routes()); setRouteMetric(other->routeMetric()); setIgnoreAutoRoutes(other->ignoreAutoRoutes()); setIgnoreAutoDns(other->ignoreAutoDns()); setDhcpClientId(other->dhcpClientId()); setDhcpSendHostname(other->dhcpSendHostname()); setDhcpHostname(other->dhcpHostname()); setNeverDefault(other->neverDefault()); setMayFail(other->mayFail()); setDadTimeout(other->dadTimeout()); setDhcpFqdn(other->dhcpFqdn()); setDnsOptions(other->dnsOptions()); setDnsPriority(other->dnsPriority()); setAddressData(other->addressData()); setRouteData(other->routeData()); } NetworkManager::Ipv4Setting::~Ipv4Setting() { delete d_ptr; } QString NetworkManager::Ipv4Setting::name() const { Q_D(const Ipv4Setting); return d->name; } void NetworkManager::Ipv4Setting::setMethod(NetworkManager::Ipv4Setting::ConfigMethod type) { Q_D(Ipv4Setting); d->method = type; } NetworkManager::Ipv4Setting::ConfigMethod NetworkManager::Ipv4Setting::method() const { Q_D(const Ipv4Setting); return d->method; } void NetworkManager::Ipv4Setting::setDns(const QList &dns) { Q_D(Ipv4Setting); d->dns = dns; } QList NetworkManager::Ipv4Setting::dns() const { Q_D(const Ipv4Setting); return d->dns; } void NetworkManager::Ipv4Setting::setDnsSearch(const QStringList &domains) { Q_D(Ipv4Setting); d->dnsSearch = domains; } QStringList NetworkManager::Ipv4Setting::dnsSearch() const { Q_D(const Ipv4Setting); return d->dnsSearch; } void NetworkManager::Ipv4Setting::setAddresses(const QList &ipv4addresses) { Q_D(Ipv4Setting); d->addresses = ipv4addresses; } QList< NetworkManager::IpAddress > NetworkManager::Ipv4Setting::addresses() const { Q_D(const Ipv4Setting); return d->addresses; } void NetworkManager::Ipv4Setting::setRoutes(const QList &ipv4routes) { Q_D(Ipv4Setting); d->routes = ipv4routes; } QList< NetworkManager::IpRoute > NetworkManager::Ipv4Setting::routes() const { Q_D(const Ipv4Setting); return d->routes; } void NetworkManager::Ipv4Setting::setRouteMetric(int metric) { Q_D(Ipv4Setting); d->routeMetric = metric; } int NetworkManager::Ipv4Setting::routeMetric() const { Q_D(const Ipv4Setting); return d->routeMetric; } void NetworkManager::Ipv4Setting::setIgnoreAutoRoutes(bool ignore) { Q_D(Ipv4Setting); d->ignoreAutoRoutes = ignore; } bool NetworkManager::Ipv4Setting::ignoreAutoRoutes() const { Q_D(const Ipv4Setting); return d->ignoreAutoRoutes; } void NetworkManager::Ipv4Setting::setIgnoreAutoDns(bool ignore) { Q_D(Ipv4Setting); d->ignoreAutoDns = ignore; } bool NetworkManager::Ipv4Setting::ignoreAutoDns() const { Q_D(const Ipv4Setting); return d->ignoreAutoDns; } void NetworkManager::Ipv4Setting::setDhcpClientId(const QString &id) { Q_D(Ipv4Setting); d->dhcpClientId = id; } QString NetworkManager::Ipv4Setting::dhcpClientId() const { Q_D(const Ipv4Setting); return d->dhcpClientId; } void NetworkManager::Ipv4Setting::setDhcpSendHostname(bool send) { Q_D(Ipv4Setting); d->dhcpSendHostname = send; } bool NetworkManager::Ipv4Setting::dhcpSendHostname() const { Q_D(const Ipv4Setting); return d->dhcpSendHostname; } void NetworkManager::Ipv4Setting::setDhcpHostname(const QString &hostname) { Q_D(Ipv4Setting); d->dhcpHostname = hostname; } QString NetworkManager::Ipv4Setting::dhcpHostname() const { Q_D(const Ipv4Setting); return d->dhcpHostname; } void NetworkManager::Ipv4Setting::setNeverDefault(bool neverDefault) { Q_D(Ipv4Setting); d->neverDefault = neverDefault; } bool NetworkManager::Ipv4Setting::neverDefault() const { Q_D(const Ipv4Setting); return d->neverDefault; } void NetworkManager::Ipv4Setting::setMayFail(bool mayFail) { Q_D(Ipv4Setting); d->mayFail = mayFail; } bool NetworkManager::Ipv4Setting::mayFail() const { Q_D(const Ipv4Setting); return d->mayFail; } void NetworkManager::Ipv4Setting::setDadTimeout(qint32 timeout) { Q_D(Ipv4Setting); d->dadTimeout = timeout; } qint32 NetworkManager::Ipv4Setting::dadTimeout() const { Q_D(const Ipv4Setting); return d->dadTimeout; } void NetworkManager::Ipv4Setting::setDhcpFqdn(const QString &fqdn) { Q_D(Ipv4Setting); d->dhcpFqdn = fqdn; } QString NetworkManager::Ipv4Setting::dhcpFqdn() const { Q_D(const Ipv4Setting); return d->dhcpFqdn; } void NetworkManager::Ipv4Setting::setDnsOptions(const QStringList &options) { Q_D(Ipv4Setting); d->dnsOptions = options; } QStringList NetworkManager::Ipv4Setting::dnsOptions() const { Q_D(const Ipv4Setting); return d->dnsOptions; } void NetworkManager::Ipv4Setting::setDnsPriority(qint32 priority) { Q_D(Ipv4Setting); d->dnsPriority = priority; } qint32 NetworkManager::Ipv4Setting::dnsPriority() const { Q_D(const Ipv4Setting); return d->dnsPriority; } void NetworkManager::Ipv4Setting::setGateway(const QString &gateway) { Q_D(Ipv4Setting); d->gateway = gateway; } QString NetworkManager::Ipv4Setting::gateway() const { Q_D(const Ipv4Setting); return d->gateway; } void NetworkManager::Ipv4Setting::setAddressData(const NMVariantMapList &addressData) { Q_D(Ipv4Setting); d->addressData = addressData; } NMVariantMapList NetworkManager::Ipv4Setting::addressData() const { Q_D(const Ipv4Setting); return d->addressData; } void NetworkManager::Ipv4Setting::setRouteData(const NMVariantMapList &routeData) { Q_D(Ipv4Setting); d->routeData = routeData; } NMVariantMapList NetworkManager::Ipv4Setting::routeData() const { Q_D(const Ipv4Setting); return d->routeData; } void NetworkManager::Ipv4Setting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD))) { const QString methodType = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD)).toString(); if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_AUTO)) { setMethod(Automatic); } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) { setMethod(LinkLocal); } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_MANUAL)) { setMethod(Manual); } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_SHARED)) { setMethod(Shared); } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_DISABLED)) { setMethod(Disabled); } else { setMethod(Automatic); } } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS))) { QList dbusDns; QList temp; if (setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).canConvert()) { QDBusArgument dnsArg = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).value(); temp = qdbus_cast >(dnsArg); } else { temp = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).value >(); } Q_FOREACH (const uint utmp, temp) { QHostAddress tmpHost(ntohl(utmp)); dbusDns << tmpHost; } setDns(dbusDns); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_SEARCH))) { setDnsSearch(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_SEARCH)).toStringList()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESSES))) { QList addresses; QList > temp; if (setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESSES)).canConvert< QDBusArgument>()) { QDBusArgument addressArg = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESSES)).value(); temp = qdbus_cast > >(addressArg); } else { temp = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESSES)).value > >(); } Q_FOREACH (const QList &uintList, temp) { if (uintList.count() != 3) { continue; } NetworkManager::IpAddress address; address.setIp(QHostAddress(ntohl(uintList.at(0)))); address.setPrefixLength(uintList.at(1)); address.setGateway(QHostAddress(ntohl(uintList.at(2)))); if (!address.isValid()) { continue; } addresses << address; } setAddresses(addresses); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTES))) { QList routes; QList > temp; if (setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTES)).canConvert< QDBusArgument>()) { QDBusArgument routeArg = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTES)).value(); temp = qdbus_cast > >(routeArg); } else { temp = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTES)).value > >(); } Q_FOREACH (const QList &uintList, temp) { if (uintList.count() != 4) { continue; } NetworkManager::IpRoute route; route.setIp(QHostAddress(ntohl(uintList.at(0)))); route.setPrefixLength(uintList.at(1)); route.setNextHop(QHostAddress(ntohl(uintList.at(2)))); route.setMetric((quint32)uintList.at(3)); if (!route.isValid()) { continue; } routes << route; } if (!routes.isEmpty()) { setRoutes(routes); } } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_METRIC))) { setRouteMetric(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_METRIC)).toInt()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES))) { setIgnoreAutoRoutes(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES)).toBool()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS))) { setIgnoreAutoDns(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS)).toBool()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_CLIENT_ID))) { setDhcpClientId(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_CLIENT_ID)).toString()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME))) { setDhcpSendHostname(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME)).toBool()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_HOSTNAME))) { setDhcpHostname(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_HOSTNAME)).toString()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_NEVER_DEFAULT))) { setNeverDefault(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_NEVER_DEFAULT)).toBool()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_MAY_FAIL))) { setMayFail(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_MAY_FAIL)).toBool()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DAD_TIMEOUT))) { setDadTimeout(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DAD_TIMEOUT)).toUInt()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_FQDN))) { setDhcpFqdn(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_FQDN)).toString()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_OPTIONS))) { setDnsOptions(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_OPTIONS)).toStringList()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_PRIORITY))) { setDnsPriority(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_PRIORITY)).toInt()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_GATEWAY))) { setGateway(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_GATEWAY)).toString()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_DATA))) { setRouteData(qdbus_cast(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_DATA)))); } if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESS_DATA))) { setAddressData(qdbus_cast(setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESS_DATA)))); } } QVariantMap NetworkManager::Ipv4Setting::toMap() const { QVariantMap setting; if (method() == Automatic) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD), QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_AUTO)); } else if (method() == LinkLocal) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD), QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)); } else if (method() == Manual) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD), QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_MANUAL)); } else if (method() == Shared) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD), QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_SHARED)); } else if (method() == Disabled) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD), QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_DISABLED)); } if (!dns().isEmpty()) { QList dbusDns; Q_FOREACH (const QHostAddress & dns, dns()) { dbusDns << htonl(dns.toIPv4Address()); } setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS), QVariant::fromValue(dbusDns)); } if (!dnsSearch().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_SEARCH), dnsSearch()); } if (!addresses().isEmpty()) { QList > dbusAddresses; Q_FOREACH (const NetworkManager::IpAddress & addr, addresses()) { QList dbusAddress; dbusAddress << htonl(addr.ip().toIPv4Address()) << addr.prefixLength() << htonl(addr.gateway().toIPv4Address()); dbusAddresses << dbusAddress; } setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESSES), QVariant::fromValue(dbusAddresses)); } if (!routes().isEmpty()) { QList > dbusRoutes; Q_FOREACH (const NetworkManager::IpRoute & route, routes()) { QList dbusRoute; dbusRoute << htonl(route.ip().toIPv4Address()) << route.prefixLength() << htonl(route.nextHop().toIPv4Address()) << route.metric(); dbusRoutes << dbusRoute; } setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTES), QVariant::fromValue(dbusRoutes)); } if(routeMetric() >= 0) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_METRIC), routeMetric()); } if (ignoreAutoRoutes()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES), ignoreAutoRoutes()); } if (ignoreAutoDns()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS), ignoreAutoDns()); } if (!dhcpClientId().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_CLIENT_ID), dhcpClientId()); } if (!dhcpSendHostname()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME), dhcpSendHostname()); } if (!dhcpHostname().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_HOSTNAME), dhcpHostname()); } if (neverDefault()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_NEVER_DEFAULT), neverDefault()); } if (!mayFail()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_MAY_FAIL), mayFail()); } if (dadTimeout() >= 0) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DAD_TIMEOUT), dadTimeout()); } if (!dhcpFqdn().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DHCP_FQDN), dhcpFqdn()); } if (!dnsOptions().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_OPTIONS), dnsOptions()); } if (dnsPriority() != 0) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS_PRIORITY), dnsPriority()); } if (!gateway().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_GATEWAY), gateway()); } if (!addressData().empty()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_ADDRESS_DATA), QVariant::fromValue(addressData())); } if (!routeData().empty()) { setting.insert(QLatin1String(NMQT_SETTING_IP4_CONFIG_ROUTE_DATA), QVariant::fromValue(routeData())); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::Ipv4Setting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_METHOD << ": " << setting.method() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_DNS << ":\n"; Q_FOREACH (const QHostAddress & address, setting.dns()) { dbg.nospace() << address.toString() << '\n'; } dbg.nospace() << NMQT_SETTING_IP4_CONFIG_DNS_SEARCH << ": " << setting.dnsSearch() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_ADDRESSES << '\n'; Q_FOREACH (const NetworkManager::IpAddress & address, setting.addresses()) { dbg.nospace() << address.ip() << ": " << address.gateway() << ": " << address.netmask() << '\n'; } dbg.nospace() << NMQT_SETTING_IP4_CONFIG_ROUTES << '\n'; Q_FOREACH (const NetworkManager::IpRoute & route, setting.routes()) { dbg.nospace() << route.ip() << ": " << route.netmask() << ": " << route.nextHop() << ": " << route.metric() << '\n'; } dbg.nospace() << NMQT_SETTING_IP4_CONFIG_ROUTE_METRIC << ":" << setting.routeMetric() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES << ": " << setting.ignoreAutoRoutes() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS << ": " << setting.ignoreAutoDns() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_DHCP_CLIENT_ID << ": " << setting.dhcpClientId() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME << ": " << setting.dhcpSendHostname() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_DHCP_HOSTNAME << ": " << setting.dhcpHostname() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_NEVER_DEFAULT << ": " << setting.neverDefault() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_MAY_FAIL << ": " << setting.mayFail() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_DAD_TIMEOUT << ": " << setting.dadTimeout() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_DHCP_FQDN << ": " << setting.dhcpFqdn() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_DNS_OPTIONS << ": " << setting.dnsOptions() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_DNS_PRIORITY << ": " << setting.dnsPriority() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_GATEWAY << ": " << setting.gateway() << '\n'; dbg.nospace() << NMQT_SETTING_IP4_CONFIG_ADDRESS_DATA << ": " << '\n'; Q_FOREACH (const QVariantMap & addressData, setting.addressData()) { QVariantMap::const_iterator i = addressData.constBegin(); while (i != addressData.constEnd()) { dbg.nospace() << i.key() << ": " << i.value() << '\n'; } } dbg.nospace() << NMQT_SETTING_IP4_CONFIG_ROUTE_DATA << ": " << '\n'; Q_FOREACH (const QVariantMap & routeData, setting.routeData()) { QVariantMap::const_iterator i = routeData.constBegin(); while (i != routeData.constEnd()) { dbg.nospace() << i.key() << ": " << i.value() << '\n'; } } return dbg.maybeSpace(); } diff --git a/src/settings/ipv4setting.h b/src/settings/ipv4setting.h index 466a627..fa6d94e 100644 --- a/src/settings/ipv4setting.h +++ b/src/settings/ipv4setting.h @@ -1,156 +1,142 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPV4_SETTING_H #define NETWORKMANAGERQT_IPV4_SETTING_H #include "ipconfig.h" #include #include "setting.h" #include #include #define NMQT_SETTING_IP4_CONFIG_SETTING_NAME NM_SETTING_IP4_CONFIG_SETTING_NAME #define NMQT_SETTING_IP4_CONFIG_METHOD NM_SETTING_IP_CONFIG_METHOD #define NMQT_SETTING_IP4_CONFIG_DNS NM_SETTING_IP_CONFIG_DNS #define NMQT_SETTING_IP4_CONFIG_DNS_SEARCH NM_SETTING_IP_CONFIG_DNS_SEARCH #define NMQT_SETTING_IP4_CONFIG_ADDRESSES NM_SETTING_IP_CONFIG_ADDRESSES #define NMQT_SETTING_IP4_CONFIG_GATEWAY NM_SETTING_IP_CONFIG_GATEWAY #define NMQT_SETTING_IP4_CONFIG_ROUTES NM_SETTING_IP_CONFIG_ROUTES #define NMQT_SETTING_IP4_CONFIG_ROUTE_METRIC NM_SETTING_IP_CONFIG_ROUTE_METRIC #define NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES #define NMQT_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS #define NMQT_SETTING_IP4_CONFIG_DHCP_HOSTNAME NM_SETTING_IP_CONFIG_DHCP_HOSTNAME #define NMQT_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME #define NMQT_SETTING_IP4_CONFIG_NEVER_DEFAULT NM_SETTING_IP_CONFIG_NEVER_DEFAULT #define NMQT_SETTING_IP4_CONFIG_MAY_FAIL NM_SETTING_IP_CONFIG_MAY_FAIL #define NMQT_SETTING_IP4_CONFIG_DHCP_CLIENT_ID NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID #define NMQT_SETTING_IP4_CONFIG_METHOD_AUTO NM_SETTING_IP4_CONFIG_METHOD_AUTO #define NMQT_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL #define NMQT_SETTING_IP4_CONFIG_METHOD_MANUAL NM_SETTING_IP4_CONFIG_METHOD_MANUAL #define NMQT_SETTING_IP4_CONFIG_METHOD_SHARED NM_SETTING_IP4_CONFIG_METHOD_SHARED #define NMQT_SETTING_IP4_CONFIG_METHOD_DISABLED NM_SETTING_IP4_CONFIG_METHOD_DISABLED #define NMQT_SETTING_IP4_CONFIG_DAD_TIMEOUT NM_SETTING_IP_CONFIG_DAD_TIMEOUT #define NMQT_SETTING_IP4_CONFIG_DHCP_FQDN NM_SETTING_IP4_CONFIG_DHCP_FQDN #define NMQT_SETTING_IP4_CONFIG_DNS_OPTIONS NM_SETTING_IP_CONFIG_DNS_OPTIONS #define NMQT_SETTING_IP4_CONFIG_DNS_PRIORITY NM_SETTING_IP_CONFIG_DNS_PRIORITY #define NMQT_SETTING_IP4_CONFIG_GATEWAY NM_SETTING_IP_CONFIG_GATEWAY #define NMQT_SETTING_IP4_CONFIG_ROUTE_DATA "route-data" #define NMQT_SETTING_IP4_CONFIG_ADDRESS_DATA "address-data" namespace NetworkManager { class Ipv4SettingPrivate; /** * Represents ipv4 setting */ class NETWORKMANAGERQT_EXPORT Ipv4Setting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum ConfigMethod {Automatic, LinkLocal, Manual, Shared, Disabled}; Ipv4Setting(); explicit Ipv4Setting(const Ptr &other); ~Ipv4Setting() override; QString name() const override; void setMethod(ConfigMethod method); ConfigMethod method() const; void setDns(const QList &dns); QList dns() const; void setDnsSearch(const QStringList &domains); QStringList dnsSearch() const; void setAddresses(const QList &ipv4addresses); QList addresses() const; void setRoutes(const QList &ipv4routes); QList routes() const; void setRouteMetric(int metric); int routeMetric() const; void setIgnoreAutoRoutes(bool ignore); bool ignoreAutoRoutes() const; void setIgnoreAutoDns(bool ignore); bool ignoreAutoDns() const; void setDhcpClientId(const QString &id); QString dhcpClientId() const; void setDhcpSendHostname(bool send); bool dhcpSendHostname() const; void setDhcpHostname(const QString &hostname); QString dhcpHostname() const; void setNeverDefault(bool neverDefault); bool neverDefault() const; void setMayFail(bool mayFail); bool mayFail() const; void setDadTimeout(qint32 timeout); qint32 dadTimeout() const; void setDhcpFqdn(const QString &fqdn); QString dhcpFqdn() const; void setDnsOptions(const QStringList &options); QStringList dnsOptions() const; void setDnsPriority(qint32 priority); qint32 dnsPriority() const; void setGateway(const QString &gateway); QString gateway() const; void setAddressData(const NMVariantMapList &addressData); NMVariantMapList addressData() const; void setRouteData(const NMVariantMapList &routeData); NMVariantMapList routeData() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: Ipv4SettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(Ipv4Setting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Ipv4Setting &setting); } #endif // NETWORKMANAGERQT_IPV4_SETTING_H diff --git a/src/settings/ipv4setting_p.h b/src/settings/ipv4setting_p.h index ba0f9e9..f3c2bd7 100644 --- a/src/settings/ipv4setting_p.h +++ b/src/settings/ipv4setting_p.h @@ -1,62 +1,48 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPV4_SETTING_P_H #define NETWORKMANAGERQT_IPV4_SETTING_P_H #include "../ipconfig.h" #include #include #include namespace NetworkManager { class Ipv4SettingPrivate { public: Ipv4SettingPrivate(); QString name; NetworkManager::Ipv4Setting::ConfigMethod method; QList dns; QStringList dnsSearch; QList addresses; QList routes; int routeMetric; bool ignoreAutoRoutes; bool ignoreAutoDns; QString dhcpClientId; bool dhcpSendHostname; QString dhcpHostname; bool neverDefault; bool mayFail; qint32 dadTimeout; QString dhcpFqdn; QStringList dnsOptions; qint32 dnsPriority; QString gateway; NMVariantMapList addressData; NMVariantMapList routeData; }; } #endif // NETWORKMANAGERQT_IPV4_SETTING_P_H diff --git a/src/settings/ipv6setting.cpp b/src/settings/ipv6setting.cpp index e1efcd8..e6ae04e 100644 --- a/src/settings/ipv6setting.cpp +++ b/src/settings/ipv6setting.cpp @@ -1,716 +1,702 @@ /* - Copyright 2012-2013 Jan Grulich - Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ipv6setting.h" #include "ipv6setting_p.h" #include "utils.h" #include "generictypes.h" #include "../ipconfig.h" #include NetworkManager::Ipv6SettingPrivate::Ipv6SettingPrivate() : name(NMQT_SETTING_IP6_CONFIG_SETTING_NAME) , method(NetworkManager::Ipv6Setting::Automatic) , routeMetric(-1) , ignoreAutoRoutes(false) , ignoreAutoDns(false) , neverDefault(false) , mayFail(true) , privacy(NetworkManager::Ipv6Setting::Unknown) , dadTimeout(-1) , addressGenMode(NetworkManager::Ipv6Setting::StablePrivacy) , dhcpTimeout(0) , routeTable(0) { } NetworkManager::Ipv6Setting::Ipv6Setting() : Setting(Setting::Ipv6) , d_ptr(new Ipv6SettingPrivate()) { } NetworkManager::Ipv6Setting::Ipv6Setting(const Ptr &other) : Setting(other) , d_ptr(new Ipv6SettingPrivate()) { setMethod(other->method()); setDns(other->dns()); setDnsSearch(other->dnsSearch()); setAddresses(other->addresses()); setRoutes(other->routes()); setRouteMetric(other->routeMetric()); setIgnoreAutoRoutes(other->ignoreAutoRoutes()); setIgnoreAutoDns(other->ignoreAutoDns()); setNeverDefault(other->neverDefault()); setMayFail(other->mayFail()); setDadTimeout(other->dadTimeout()); setAddressGenMode(other->addressGenMode()); setDhcpTimeout(other->dhcpTimeout()); setDhcpHostname(other->dhcpHostname()); setDhcpDuid(other->dhcpDuid()); setToken(other->token()); setDnsOptions(other->dnsOptions()); setAddressData(other->addressData()); setRouteData(other->routeData()); setRouteTable(other->routeTable()); } NetworkManager::Ipv6Setting::~Ipv6Setting() { delete d_ptr; } QString NetworkManager::Ipv6Setting::name() const { Q_D(const Ipv6Setting); return d->name; } void NetworkManager::Ipv6Setting::setMethod(NetworkManager::Ipv6Setting::ConfigMethod type) { Q_D(Ipv6Setting); d->method = type; } NetworkManager::Ipv6Setting::ConfigMethod NetworkManager::Ipv6Setting::method() const { Q_D(const Ipv6Setting); return d->method; } void NetworkManager::Ipv6Setting::setDns(const QList &dns) { Q_D(Ipv6Setting); d->dns = dns; } QList NetworkManager::Ipv6Setting::dns() const { Q_D(const Ipv6Setting); return d->dns; } void NetworkManager::Ipv6Setting::setDnsSearch(const QStringList &domains) { Q_D(Ipv6Setting); d->dnsSearch = domains; } QStringList NetworkManager::Ipv6Setting::dnsSearch() const { Q_D(const Ipv6Setting); return d->dnsSearch; } void NetworkManager::Ipv6Setting::setAddresses(const QList ipv6addresses) { Q_D(Ipv6Setting); d->addresses = ipv6addresses; } QList< NetworkManager::IpAddress > NetworkManager::Ipv6Setting::addresses() const { Q_D(const Ipv6Setting); return d->addresses; } void NetworkManager::Ipv6Setting::setRoutes(const QList< NetworkManager::IpRoute > ipv6routes) { Q_D(Ipv6Setting); d->routes = ipv6routes; } QList NetworkManager::Ipv6Setting::routes() const { Q_D(const Ipv6Setting); return d->routes; } void NetworkManager::Ipv6Setting::setRouteMetric(int metric) { Q_D(Ipv6Setting); d->routeMetric = metric; } int NetworkManager::Ipv6Setting::routeMetric() const { Q_D(const Ipv6Setting); return d->routeMetric; } void NetworkManager::Ipv6Setting::setIgnoreAutoRoutes(bool ignore) { Q_D(Ipv6Setting); d->ignoreAutoRoutes = ignore; } bool NetworkManager::Ipv6Setting::ignoreAutoRoutes() const { Q_D(const Ipv6Setting); return d->ignoreAutoRoutes; } void NetworkManager::Ipv6Setting::setIgnoreAutoDns(bool ignore) { Q_D(Ipv6Setting); d->ignoreAutoDns = ignore; } bool NetworkManager::Ipv6Setting::ignoreAutoDns() const { Q_D(const Ipv6Setting); return d->ignoreAutoDns; } void NetworkManager::Ipv6Setting::setNeverDefault(bool neverDefault) { Q_D(Ipv6Setting); d->neverDefault = neverDefault; } bool NetworkManager::Ipv6Setting::neverDefault() const { Q_D(const Ipv6Setting); return d->neverDefault; } void NetworkManager::Ipv6Setting::setMayFail(bool mayFail) { Q_D(Ipv6Setting); d->mayFail = mayFail; } bool NetworkManager::Ipv6Setting::mayFail() const { Q_D(const Ipv6Setting); return d->mayFail; } void NetworkManager::Ipv6Setting::setPrivacy(IPv6Privacy privacy) { Q_D(Ipv6Setting); d->privacy = privacy; } NetworkManager::Ipv6Setting::IPv6Privacy NetworkManager::Ipv6Setting::privacy() const { Q_D(const Ipv6Setting); return d->privacy; } void NetworkManager::Ipv6Setting::setDadTimeout(qint32 timeout) { Q_D(Ipv6Setting); d->dadTimeout = timeout; } qint32 NetworkManager::Ipv6Setting::dadTimeout() const { Q_D(const Ipv6Setting); return d->dadTimeout; } void NetworkManager::Ipv6Setting::setDhcpTimeout(qint32 timeout) { Q_D(Ipv6Setting); d->dhcpTimeout = timeout; } qint32 NetworkManager::Ipv6Setting::dhcpTimeout() const { Q_D(const Ipv6Setting); return d->dhcpTimeout; } void NetworkManager::Ipv6Setting::setDhcpHostname(const QString &hostname) { Q_D(Ipv6Setting); d->dhcpHostname = hostname; } QString NetworkManager::Ipv6Setting::dhcpHostname() const { Q_D(const Ipv6Setting); return d->dhcpHostname; } void NetworkManager::Ipv6Setting::setDhcpDuid(const QString &duid) { Q_D(Ipv6Setting); d->dhcpDuid = duid; } QString NetworkManager::Ipv6Setting::dhcpDuid() const { Q_D(const Ipv6Setting); return d->dhcpDuid; } void NetworkManager::Ipv6Setting::setDnsOptions(const QStringList &options) { Q_D(Ipv6Setting); d->dnsOptions = options; } QStringList NetworkManager::Ipv6Setting::dnsOptions() const { Q_D(const Ipv6Setting); return d->dnsOptions; } void NetworkManager::Ipv6Setting::setAddressData(const NMVariantMapList &addressData) { Q_D(Ipv6Setting); d->addressData = addressData; } NMVariantMapList NetworkManager::Ipv6Setting::addressData() const { Q_D(const Ipv6Setting); return d->addressData; } void NetworkManager::Ipv6Setting::setAddressGenMode(IPv6AddressGenMode mode) { Q_D(Ipv6Setting); d->addressGenMode = mode; } NetworkManager::Ipv6Setting::IPv6AddressGenMode NetworkManager::Ipv6Setting::addressGenMode() const { Q_D(const Ipv6Setting); return d->addressGenMode; } void NetworkManager::Ipv6Setting::setRouteData(const NMVariantMapList &routeData) { Q_D(Ipv6Setting); d->routeData = routeData; } NMVariantMapList NetworkManager::Ipv6Setting::routeData() const { Q_D(const Ipv6Setting); return d->routeData; } void NetworkManager::Ipv6Setting::setToken(const QString &token) { Q_D(Ipv6Setting); d->token = token; } QString NetworkManager::Ipv6Setting::token() const { Q_D(const Ipv6Setting); return d->token; } void NetworkManager::Ipv6Setting::setRouteTable(quint32 routeTable) { Q_D(Ipv6Setting); d->routeTable = routeTable; } quint32 NetworkManager::Ipv6Setting::routeTable() const { Q_D(const Ipv6Setting); return d->routeTable; } void NetworkManager::Ipv6Setting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD))) { const QString methodType = setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD)).toString(); if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD_AUTO)) { setMethod(Automatic); } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD_DHCP)) { setMethod(Dhcp); } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) { setMethod(LinkLocal); } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD_MANUAL)) { setMethod(Manual); } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD_IGNORE)) { setMethod(Ignored); } else { setMethod(Automatic); } } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS))) { QList dbusDns; QList temp; if (setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS)).canConvert()) { QDBusArgument dnsArg = setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS)).value< QDBusArgument>(); temp = qdbus_cast >(dnsArg); } else { temp = setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS)).value >(); } Q_FOREACH (const QByteArray & utmp, temp) { dbusDns << ipv6AddressAsHostAddress(utmp); } setDns(dbusDns); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS_SEARCH))) { setDnsSearch(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS_SEARCH)).toStringList()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESSES))) { QList temp; if (setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS)).canConvert()) { QDBusArgument addressArg = setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESSES)).value< QDBusArgument>(); temp = qdbus_cast >(addressArg); } else { temp = setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESSES)).value >(); } QList addresses; Q_FOREACH (const IpV6DBusAddress & addressMap, temp) { if (addressMap.address.isEmpty() || !addressMap.prefix || addressMap.gateway.isEmpty()) { continue; } NetworkManager::IpAddress address; address.setIp(ipv6AddressAsHostAddress(addressMap.address)); address.setPrefixLength(addressMap.prefix); address.setGateway(ipv6AddressAsHostAddress(addressMap.gateway)); if (!address.isValid()) { continue; } addresses << address; } setAddresses(addresses); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTES))) { QList temp; if (setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTES)).canConvert()) { QDBusArgument routeArg = setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTES)).value< QDBusArgument>(); temp = qdbus_cast >(routeArg); } else { temp = setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTES)).value >(); } QList routes; Q_FOREACH (const IpV6DBusRoute & routeMap, temp) { if (routeMap.destination.isEmpty() || !routeMap.prefix || routeMap.nexthop.isEmpty() || !routeMap.metric) { continue; } NetworkManager::IpRoute route; route.setIp(ipv6AddressAsHostAddress(routeMap.destination)); route.setPrefixLength(routeMap.prefix); route.setNextHop(ipv6AddressAsHostAddress(routeMap.nexthop)); route.setMetric(routeMap.metric); if (!route.isValid()) { continue; } routes << route; } setRoutes(routes); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_METRIC))) { setRouteMetric(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_METRIC)).toInt()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES))) { setIgnoreAutoRoutes(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES)).toBool()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS))) { setIgnoreAutoDns(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS)).toBool()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_NEVER_DEFAULT))) { setNeverDefault(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_NEVER_DEFAULT)).toBool()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_MAY_FAIL))) { setMayFail(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_MAY_FAIL)).toBool()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_IP6_PRIVACY))) { setPrivacy((IPv6Privacy)setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_IP6_PRIVACY)).toUInt()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_DAD_TIMEOUT))) { setDadTimeout(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DAD_TIMEOUT)).toUInt()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_TIMEOUT))) { setDhcpTimeout(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_TIMEOUT)).toUInt()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_GEN_MODE))) { setAddressGenMode(static_cast(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_GEN_MODE)).toUInt())); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_HOSTNAME))) { setDhcpHostname(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_HOSTNAME)).toString()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_DUID))) { setDhcpDuid(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_DUID)).toString()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_TOKEN))) { setToken(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_TOKEN)).toString()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS_OPTIONS))) { setDnsOptions(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS_OPTIONS)).toStringList()); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_DATA))) { setRouteData(qdbus_cast(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_DATA)))); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_DATA))) { setAddressData(qdbus_cast(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_DATA)))); } if (setting.contains(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_TABLE))) { setRouteTable(setting.value(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_TABLE)).toUInt()); } } QVariantMap NetworkManager::Ipv6Setting::toMap() const { QVariantMap setting; if (method() == Automatic) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD), QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD_AUTO)); } else if (method() == Dhcp) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD), QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD_DHCP)); } else if (method() == LinkLocal) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD), QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)); } else if (method() == Manual) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD), QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD_MANUAL)); } else if (method() == Ignored) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD), QLatin1String(NMQT_SETTING_IP6_CONFIG_METHOD_IGNORE)); } if (!dns().isEmpty()) { QList dbusDns; Q_FOREACH (const QHostAddress & dns, dns()) { dbusDns << ipv6AddressFromHostAddress(dns); } setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS), QVariant::fromValue(dbusDns)); } if (!dnsSearch().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS_SEARCH), dnsSearch()); } if (!addresses().isEmpty()) { QList dbusAddresses; Q_FOREACH (const NetworkManager::IpAddress & addr, addresses()) { IpV6DBusAddress dbusAddress; dbusAddress.address = ipv6AddressFromHostAddress(addr.ip()); dbusAddress.prefix = addr.prefixLength(); dbusAddress.gateway = ipv6AddressFromHostAddress(addr.gateway()); dbusAddresses << dbusAddress; } setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESSES), QVariant::fromValue(dbusAddresses)); } if (!routes().isEmpty()) { QList dbusRoutes; Q_FOREACH (const NetworkManager::IpRoute & route, routes()) { IpV6DBusRoute dbusRoute; dbusRoute.destination = ipv6AddressFromHostAddress(route.ip()); dbusRoute.prefix = route.prefixLength(); dbusRoute.nexthop = ipv6AddressFromHostAddress(route.nextHop()); dbusRoute.metric = route.metric(); dbusRoutes << dbusRoute; } setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTES), QVariant::fromValue(dbusRoutes)); } if(routeMetric() >= 0) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_METRIC), routeMetric()); } if (ignoreAutoRoutes()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES), ignoreAutoRoutes()); } if (ignoreAutoDns()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS), ignoreAutoDns()); } if (neverDefault()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_NEVER_DEFAULT), neverDefault()); } if (!mayFail()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_MAY_FAIL), mayFail()); } if (privacy() != Unknown) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_IP6_PRIVACY), privacy()); } if (dadTimeout() >= 0) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DAD_TIMEOUT), dadTimeout()); } setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_GEN_MODE), addressGenMode()); if (dhcpTimeout() > 0) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_TIMEOUT), dhcpTimeout()); } if (!dhcpHostname().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_HOSTNAME), dhcpHostname()); } if (!dhcpDuid().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DHCP_DUID), dhcpDuid()); } if (!token().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_TOKEN), token()); } if (!dnsOptions().isEmpty()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_DNS_OPTIONS), dnsOptions()); } if (!addressData().empty()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ADDRESS_DATA), QVariant::fromValue(addressData())); } if (!routeData().empty()) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_DATA), QVariant::fromValue(routeData())); } if (routeTable() > 0) { setting.insert(QLatin1String(NMQT_SETTING_IP6_CONFIG_ROUTE_TABLE), routeTable()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::Ipv6Setting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_METHOD << ": " << setting.method() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_DNS << '\n'; Q_FOREACH (const QHostAddress & address, setting.dns()) { dbg.nospace() << address.toString() << '\n'; } dbg.nospace() << NMQT_SETTING_IP6_CONFIG_DNS_SEARCH << ": " << setting.dnsSearch() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_ADDRESSES << '\n'; Q_FOREACH (const NetworkManager::IpAddress & address, setting.addresses()) { dbg.nospace() << address.ip().toString() << ": " << address.gateway().toString() << ": " << address.netmask() << '\n'; } dbg.nospace() << NMQT_SETTING_IP6_CONFIG_ROUTES << '\n'; Q_FOREACH (const NetworkManager::IpRoute & route, setting.routes()) { dbg.nospace() << route.ip().toString() << ": " << route.metric() << ": " << route.nextHop().toString() << ": " << route.metric() << '\n'; } dbg.nospace() << NMQT_SETTING_IP6_CONFIG_ROUTE_METRIC << ":" << setting.routeMetric() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES << ": " << setting.ignoreAutoRoutes() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS << ": " << setting.ignoreAutoDns() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_NEVER_DEFAULT << ": " << setting.neverDefault() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_MAY_FAIL << ": " << setting.mayFail() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_IP6_PRIVACY << ": " << setting.privacy() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_DAD_TIMEOUT << ": " << setting.dadTimeout() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_ADDRESS_GEN_MODE << ": " << setting.addressGenMode() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_DHCP_TIMEOUT << ": " << setting.dhcpTimeout() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_DHCP_HOSTNAME << ": " << setting.dhcpHostname() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_DHCP_DUID << ": " << setting.dhcpDuid() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_TOKEN << ": " << setting.token() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_DNS_OPTIONS << ": " << setting.dnsOptions() << '\n'; dbg.nospace() << NMQT_SETTING_IP6_CONFIG_ADDRESS_DATA << ": " << '\n'; Q_FOREACH (const QVariantMap & addressData, setting.addressData()) { QVariantMap::const_iterator i = addressData.constBegin(); while (i != addressData.constEnd()) { dbg.nospace() << i.key() << ": " << i.value() << '\n'; } } dbg.nospace() << NMQT_SETTING_IP6_CONFIG_ROUTE_DATA << ": " << '\n'; Q_FOREACH (const QVariantMap & routeData, setting.routeData()) { QVariantMap::const_iterator i = routeData.constBegin(); while (i != routeData.constEnd()) { dbg.nospace() << i.key() << ": " << i.value() << '\n'; } } dbg.nospace() << NMQT_SETTING_IP6_CONFIG_ROUTE_TABLE << ": " << setting.routeTable() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/ipv6setting.h b/src/settings/ipv6setting.h index 918b0f0..cf05166 100644 --- a/src/settings/ipv6setting.h +++ b/src/settings/ipv6setting.h @@ -1,173 +1,159 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPV6_SETTING_H #define NETWORKMANAGERQT_IPV6_SETTING_H #include "ipconfig.h" #include #include "setting.h" #include #include #define NMQT_SETTING_IP6_CONFIG_SETTING_NAME NM_SETTING_IP6_CONFIG_SETTING_NAME #define NMQT_SETTING_IP6_CONFIG_METHOD NM_SETTING_IP_CONFIG_METHOD #define NMQT_SETTING_IP6_CONFIG_DNS NM_SETTING_IP_CONFIG_DNS #define NMQT_SETTING_IP6_CONFIG_DNS_SEARCH NM_SETTING_IP_CONFIG_DNS_SEARCH #define NMQT_SETTING_IP6_CONFIG_ADDRESSES NM_SETTING_IP_CONFIG_ADDRESSES #define NMQT_SETTING_IP6_CONFIG_GATEWAY NM_SETTING_IP_CONFIG_GATEWAY #define NMQT_SETTING_IP6_CONFIG_ROUTES NM_SETTING_IP_CONFIG_ROUTES #define NMQT_SETTING_IP6_CONFIG_ROUTE_METRIC NM_SETTING_IP_CONFIG_ROUTE_METRIC #define NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES #define NMQT_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS #define NMQT_SETTING_IP6_CONFIG_DHCP_HOSTNAME NM_SETTING_IP_CONFIG_DHCP_HOSTNAME #define NMQT_SETTING_IP6_CONFIG_DHCP_SEND_HOSTNAME NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME #define NMQT_SETTING_IP6_CONFIG_NEVER_DEFAULT NM_SETTING_IP_CONFIG_NEVER_DEFAULT #define NMQT_SETTING_IP6_CONFIG_MAY_FAIL NM_SETTING_IP_CONFIG_MAY_FAIL #define NMQT_SETTING_IP6_CONFIG_DHCP_CLIENT_ID NM_SETTING_IP6_CONFIG_DHCP_CLIENT_ID #define NMQT_SETTING_IP6_CONFIG_IP6_PRIVACY NM_SETTING_IP6_CONFIG_IP6_PRIVACY #define NMQT_SETTING_IP6_CONFIG_METHOD_IGNORE NM_SETTING_IP6_CONFIG_METHOD_IGNORE #define NMQT_SETTING_IP6_CONFIG_METHOD_AUTO NM_SETTING_IP6_CONFIG_METHOD_AUTO #define NMQT_SETTING_IP6_CONFIG_METHOD_DHCP NM_SETTING_IP6_CONFIG_METHOD_DHCP #define NMQT_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL #define NMQT_SETTING_IP6_CONFIG_METHOD_MANUAL NM_SETTING_IP6_CONFIG_METHOD_MANUAL #define NMQT_SETTING_IP6_CONFIG_METHOD_SHARED NM_SETTING_IP6_CONFIG_METHOD_SHARED #define NMQT_SETTING_IP6_CONFIG_DAD_TIMEOUT NM_SETTING_IP_CONFIG_DAD_TIMEOUT #define NMQT_SETTING_IP6_CONFIG_DHCP_TIMEOUT NM_SETTING_IP_CONFIG_DHCP_TIMEOUT #define NMQT_SETTING_IP6_CONFIG_DHCP_HOSTNAME NM_SETTING_IP_CONFIG_DHCP_HOSTNAME #define NMQT_SETTING_IP6_CONFIG_ADDRESS_GEN_MODE NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE #if NM_CHECK_VERSION(1, 12, 0) #define NMQT_SETTING_IP6_CONFIG_DHCP_DUID NM_SETTING_IP6_CONFIG_DHCP_DUID #else #define NMQT_SETTING_IP6_CONFIG_DHCP_DUID "dhcp-duid" #endif #define NMQT_SETTING_IP6_CONFIG_TOKEN NM_SETTING_IP6_CONFIG_TOKEN #define NMQT_SETTING_IP6_CONFIG_DNS_OPTIONS NM_SETTING_IP_CONFIG_DNS_OPTIONS #define NMQT_SETTING_IP6_CONFIG_ROUTE_DATA "route-data" #define NMQT_SETTING_IP6_CONFIG_ADDRESS_DATA "address-data" #if NM_CHECK_VERSION(1, 10, 0) #define NMQT_SETTING_IP6_CONFIG_ROUTE_TABLE NM_SETTING_IP_CONFIG_ROUTE_TABLE #else #define NMQT_SETTING_IP6_CONFIG_ROUTE_TABLE "route-table" #endif namespace NetworkManager { class Ipv6SettingPrivate; /** * Represents ipv6 setting */ class NETWORKMANAGERQT_EXPORT Ipv6Setting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum ConfigMethod {Automatic, Dhcp, LinkLocal, Manual, Ignored}; enum IPv6Privacy {Unknown = -1, Disabled, PreferPublic, PreferTemporary}; enum IPv6AddressGenMode {Eui64, StablePrivacy}; Ipv6Setting(); explicit Ipv6Setting(const Ptr &other); ~Ipv6Setting() override; QString name() const override; void setMethod(ConfigMethod method); ConfigMethod method() const; void setDns(const QList &dns); QList dns() const; void setDnsSearch(const QStringList &domains); QStringList dnsSearch() const; void setAddresses(const QList ipv6addresses); QList addresses() const; void setRoutes(const QList ipv6routes); QList routes() const; void setRouteMetric(int metric); int routeMetric() const; void setIgnoreAutoRoutes(bool ignore); bool ignoreAutoRoutes() const; void setIgnoreAutoDns(bool ignore); bool ignoreAutoDns() const; void setNeverDefault(bool neverDefault); bool neverDefault() const; void setMayFail(bool mayFail); bool mayFail() const; void setPrivacy(IPv6Privacy privacy); IPv6Privacy privacy() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; void setDadTimeout(qint32 timeout); qint32 dadTimeout() const; void setAddressGenMode(IPv6AddressGenMode mode); IPv6AddressGenMode addressGenMode() const; void setDhcpTimeout(qint32 timeout); qint32 dhcpTimeout() const; void setDhcpHostname(const QString &hostname); QString dhcpHostname() const; void setDhcpDuid(const QString &duid); QString dhcpDuid() const; void setToken(const QString &token); QString token() const; void setDnsOptions(const QStringList &options); QStringList dnsOptions() const; void setAddressData(const NMVariantMapList &addressData); NMVariantMapList addressData() const; void setRouteData(const NMVariantMapList &routeData); NMVariantMapList routeData() const; void setRouteTable(quint32 routeTable); quint32 routeTable() const; protected: Ipv6SettingPrivate *const d_ptr; private: Q_DECLARE_PRIVATE(Ipv6Setting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Ipv6Setting &setting); } #endif // NETWORKMANAGERQT_IPV6_SETTING_H diff --git a/src/settings/ipv6setting_p.h b/src/settings/ipv6setting_p.h index c1f62b6..87cdbf3 100644 --- a/src/settings/ipv6setting_p.h +++ b/src/settings/ipv6setting_p.h @@ -1,62 +1,48 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_IPV6_SETTING_P_H #define NETWORKMANAGERQT_IPV6_SETTING_P_H #include "../ipconfig.h" #include #include namespace NetworkManager { class Ipv6SettingPrivate { public: Ipv6SettingPrivate(); QString name; NetworkManager::Ipv6Setting::ConfigMethod method; QList dns; QStringList dnsSearch; QList addresses; QList routes; int routeMetric; bool ignoreAutoRoutes; bool ignoreAutoDns; bool neverDefault; bool mayFail; NetworkManager::Ipv6Setting::IPv6Privacy privacy; qint32 dadTimeout; NetworkManager::Ipv6Setting::IPv6AddressGenMode addressGenMode; qint32 dhcpTimeout; QString dhcpHostname; QString dhcpDuid; QString token; QStringList dnsOptions; NMVariantMapList addressData; NMVariantMapList routeData; qint32 routeTable; }; } #endif // NETWORKMANAGERQT_IPV6_SETTING_P_H diff --git a/src/settings/macsecsetting.cpp b/src/settings/macsecsetting.cpp index 3d1a094..78a8e8b 100644 --- a/src/settings/macsecsetting.cpp +++ b/src/settings/macsecsetting.cpp @@ -1,336 +1,322 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "macsecsetting.h" #include "macsecsetting_p.h" #include #if !NM_CHECK_VERSION(1, 6, 0) #define NM_SETTING_MACSEC_SETTING_NAME "macsec" #define NM_SETTING_MACSEC_PARENT "parent" #define NM_SETTING_MACSEC_MODE "mode" #define NM_SETTING_MACSEC_ENCRYPT "encrypt" #define NM_SETTING_MACSEC_MKA_CAK "mka-cak" #define NM_SETTING_MACSEC_MKA_CAK_FLAGS "mka-cak-flags" #define NM_SETTING_MACSEC_MKA_CKN "mka-ckn" #define NM_SETTING_MACSEC_PORT "port" #define NM_SETTING_MACSEC_VALIDATION "validation" #endif #if !NM_CHECK_VERSION(1, 12, 0) #define NM_SETTING_MACSEC_SEND_SCI "send-sci" #endif NetworkManager::MacsecSettingPrivate::MacsecSettingPrivate() : name(NM_SETTING_MACSEC_SETTING_NAME) , encrypt(true) , mode(NetworkManager::MacsecSetting::Psk) , port(1) , sendSci(true) , validation(NetworkManager::MacsecSetting::Strict) { } NetworkManager::MacsecSetting::MacsecSetting() : Setting(Setting::Macsec) , d_ptr(new MacsecSettingPrivate()) { } NetworkManager::MacsecSetting::MacsecSetting(const Ptr &other) : Setting(other) , d_ptr(new MacsecSettingPrivate()) { setEncrypt(other->encrypt()); setMkaCak(other->mkaCak()); setMkaCkn(other->mkaCkn()); setMode(other->mode()); setParent(other->parent()); setPort(other->port()); setSendSci(other->sendSci()); setValidation(other->validation()); setMkaCakFlags(other->mkaCakFlags()); } NetworkManager::MacsecSetting::~MacsecSetting() { delete d_ptr; } QString NetworkManager::MacsecSetting::name() const { Q_D(const MacsecSetting); return d->name; } void NetworkManager::MacsecSetting::setEncrypt(bool encrypt) { Q_D(MacsecSetting); d->encrypt = encrypt; } bool NetworkManager::MacsecSetting::encrypt() const { Q_D(const MacsecSetting); return d->encrypt; } void NetworkManager::MacsecSetting::setMkaCak(const QString &mkaCak) { Q_D(MacsecSetting); d->mkaCak = mkaCak; } QString NetworkManager::MacsecSetting::mkaCak() const { Q_D(const MacsecSetting); return d->mkaCak; } void NetworkManager::MacsecSetting::setMkaCkn(const QString &mkaCkn) { Q_D(MacsecSetting); d->mkaCkn = mkaCkn; } QString NetworkManager::MacsecSetting::mkaCkn() const { Q_D(const MacsecSetting); return d->mkaCkn; } void NetworkManager::MacsecSetting::setMode(Mode mode) { Q_D(MacsecSetting); d->mode = mode; } NetworkManager::MacsecSetting::Mode NetworkManager::MacsecSetting::mode() const { Q_D(const MacsecSetting); return d->mode; } void NetworkManager::MacsecSetting::setParent(const QString &parent) { Q_D(MacsecSetting); d->parent = parent; } QString NetworkManager::MacsecSetting::parent() const { Q_D(const MacsecSetting); return d->parent; } void NetworkManager::MacsecSetting::setPort(qint32 port) { Q_D(MacsecSetting); d->port = port; } qint32 NetworkManager::MacsecSetting::port() const { Q_D(const MacsecSetting); return d->port; } void NetworkManager::MacsecSetting::setSendSci(bool sendSci) { Q_D(MacsecSetting); d->sendSci = sendSci; } bool NetworkManager::MacsecSetting::sendSci() const { Q_D(const MacsecSetting); return d->sendSci; } void NetworkManager::MacsecSetting::setValidation(Validation validation) { Q_D(MacsecSetting); d->validation = validation; } NetworkManager::MacsecSetting::Validation NetworkManager::MacsecSetting::validation() const { Q_D(const MacsecSetting); return d->validation; } void NetworkManager::MacsecSetting::setMkaCakFlags(NetworkManager::Setting::SecretFlags flags) { Q_D(MacsecSetting); d->mkaCakFlags = flags; } NetworkManager::Setting::SecretFlags NetworkManager::MacsecSetting::mkaCakFlags() const { Q_D(const MacsecSetting); return d->mkaCakFlags; } QStringList NetworkManager::MacsecSetting::needSecrets(bool requestNew) const { QStringList secrets; if ((mkaCak().isEmpty() || requestNew) && !mkaCakFlags().testFlag(Setting::NotRequired)) { secrets << QLatin1String(NM_SETTING_MACSEC_MKA_CAK); } return secrets; } void NetworkManager::MacsecSetting::secretsFromMap(const QVariantMap &secrets) { if (secrets.contains(QLatin1String(NM_SETTING_MACSEC_MKA_CAK))) { setMkaCak(secrets.value(QLatin1String(NM_SETTING_MACSEC_MKA_CAK)).toString()); } } QVariantMap NetworkManager::MacsecSetting::secretsToMap() const { QVariantMap secrets; if (!mkaCak().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_MACSEC_MKA_CAK), mkaCak()); } return secrets; } void NetworkManager::MacsecSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_MACSEC_ENCRYPT))) { setEncrypt(setting.value(QLatin1String(NM_SETTING_MACSEC_ENCRYPT)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_MACSEC_MKA_CAK))) { setMkaCak(setting.value(QLatin1String(NM_SETTING_MACSEC_MKA_CAK)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_MACSEC_MKA_CKN))) { setMkaCkn(setting.value(QLatin1String(NM_SETTING_MACSEC_MKA_CKN)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_MACSEC_MODE))) { setMode((Mode)setting.value(QLatin1String(NM_SETTING_MACSEC_MODE)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_MACSEC_PARENT))) { setParent(setting.value(QLatin1String(NM_SETTING_MACSEC_PARENT)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_MACSEC_PORT))) { setPort(setting.value(QLatin1String(NM_SETTING_MACSEC_PORT)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_MACSEC_SEND_SCI))) { setSendSci(setting.value(QLatin1String(NM_SETTING_MACSEC_SEND_SCI)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_MACSEC_VALIDATION))) { setValidation((Validation)setting.value(QLatin1String(NM_SETTING_MACSEC_VALIDATION)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_MACSEC_MKA_CAK_FLAGS))) { setMkaCakFlags((Setting::SecretFlags)setting.value(QLatin1String(NM_SETTING_MACSEC_MKA_CAK_FLAGS)).toUInt()); } } QVariantMap NetworkManager::MacsecSetting::toMap() const { QVariantMap setting; if (!encrypt()) { setting.insert(QLatin1String(NM_SETTING_MACSEC_ENCRYPT), encrypt()); } if (!mkaCak().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_MACSEC_MKA_CAK), mkaCak()); } if (!mkaCkn().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_MACSEC_MKA_CKN), mkaCkn()); } if (mode() > NetworkManager::MacsecSetting::Psk) { setting.insert(QLatin1String(NM_SETTING_MACSEC_MODE), (int)mode()); } if (!parent().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_MACSEC_PARENT), parent()); } if (port() > 1) { setting.insert(QLatin1String(NM_SETTING_MACSEC_PORT), port()); } if (!sendSci()) { setting.insert(QLatin1String(NM_SETTING_MACSEC_SEND_SCI), sendSci()); } if (validation() != NetworkManager::MacsecSetting::Strict) { setting.insert(QLatin1String(NM_SETTING_MACSEC_VALIDATION), (int)validation()); } setting.insert(QLatin1String(NM_SETTING_MACSEC_MKA_CAK_FLAGS), (int)mkaCakFlags()); return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::MacsecSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_MACSEC_ENCRYPT << ": " << setting.encrypt() << '\n'; dbg.nospace() << NM_SETTING_MACSEC_MKA_CAK << ": " << setting.mkaCak() << '\n'; dbg.nospace() << NM_SETTING_MACSEC_MKA_CKN << ": " << setting.mkaCkn() << '\n'; dbg.nospace() << NM_SETTING_MACSEC_MODE << ": " << setting.mode() << '\n'; dbg.nospace() << NM_SETTING_MACSEC_PARENT << ": " << setting.parent() << '\n'; dbg.nospace() << NM_SETTING_MACSEC_PORT << ": " << setting.port() << '\n'; dbg.nospace() << NM_SETTING_MACSEC_SEND_SCI << ": " << setting.sendSci() << '\n'; dbg.nospace() << NM_SETTING_MACSEC_VALIDATION << ": " << setting.validation() << '\n'; dbg.nospace() << NM_SETTING_MACSEC_MKA_CAK_FLAGS << ": " << setting.mkaCakFlags() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/macsecsetting.h b/src/settings/macsecsetting.h index 2ad19d8..ad1f193 100644 --- a/src/settings/macsecsetting.h +++ b/src/settings/macsecsetting.h @@ -1,100 +1,86 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MACSECSETTING_H #define NETWORKMANAGERQT_MACSECSETTING_H #include #include "setting.h" namespace NetworkManager { class MacsecSettingPrivate; /** * Represents Macsec setting */ class NETWORKMANAGERQT_EXPORT MacsecSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum Mode {Psk, Eap}; enum Validation {Disable, Check, Strict}; MacsecSetting(); explicit MacsecSetting(const Ptr &other); ~MacsecSetting() override; QString name() const override; void setEncrypt(bool encrypt); bool encrypt() const; void setMkaCak(const QString &mkaCak); QString mkaCak() const; void setMkaCkn(const QString &mkaCkn); QString mkaCkn() const; void setMode(Mode mode); Mode mode() const; void setParent(const QString &parent); QString parent() const; void setPort(qint32 port); qint32 port() const; void setSendSci(bool sendSci); bool sendSci() const; void setValidation(Validation validation); Validation validation() const; void setMkaCakFlags(Setting::SecretFlags flags); Setting::SecretFlags mkaCakFlags() const; QStringList needSecrets(bool requestNew = false) const override; void secretsFromMap(const QVariantMap &secrets) override; QVariantMap secretsToMap() const override; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: MacsecSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(MacsecSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const MacsecSetting &setting); } #endif // NETWORKMANAGERQT_MACSECSETTING_H diff --git a/src/settings/macsecsetting_p.h b/src/settings/macsecsetting_p.h index 5e611cb..54debb3 100644 --- a/src/settings/macsecsetting_p.h +++ b/src/settings/macsecsetting_p.h @@ -1,50 +1,36 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MACSECSETTING_P_H #define NETWORKMANAGERQT_MACSECSETTING_P_H #include namespace NetworkManager { class MacsecSettingPrivate { public: MacsecSettingPrivate(); QString name; bool encrypt; QString mkaCak; QString mkaCkn; NetworkManager::MacsecSetting::Mode mode; QString parent; qint32 port; bool sendSci; NetworkManager::MacsecSetting::Validation validation; NetworkManager::Setting::SecretFlags mkaCakFlags; }; } #endif // NETWORKMANAGERQT_MACSECSETTING_P_H diff --git a/src/settings/matchsetting.cpp b/src/settings/matchsetting.cpp index 2275b18..44f3036 100644 --- a/src/settings/matchsetting.cpp +++ b/src/settings/matchsetting.cpp @@ -1,99 +1,85 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "matchsetting.h" #include "matchsetting_p.h" #include #if !NM_CHECK_VERSION(1, 14, 0) #define NM_SETTING_MATCH_SETTING_NAME "match" #define NM_SETTING_MATCH_INTERFACE_NAME "interface-name" #endif NetworkManager::MatchSettingPrivate::MatchSettingPrivate() : name(NM_SETTING_MATCH_SETTING_NAME) { } NetworkManager::MatchSetting::MatchSetting() : Setting(Setting::Match) , d_ptr(new MatchSettingPrivate()) { } NetworkManager::MatchSetting::MatchSetting(const Ptr &other) : Setting(other) , d_ptr(new MatchSettingPrivate()) { setInterfaceName(other->interfaceName()); } NetworkManager::MatchSetting::~MatchSetting() { delete d_ptr; } QString NetworkManager::MatchSetting::name() const { Q_D(const MatchSetting); return d->name; } void NetworkManager::MatchSetting::setInterfaceName(const QStringList &name) { Q_D(MatchSetting); d->interfaceName = name; } QStringList NetworkManager::MatchSetting::interfaceName() const { Q_D(const MatchSetting); return d->interfaceName; } void NetworkManager::MatchSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_MATCH_INTERFACE_NAME))) { setInterfaceName(setting.value(QLatin1String(NM_SETTING_MATCH_INTERFACE_NAME)).toStringList()); } } QVariantMap NetworkManager::MatchSetting::toMap() const { QVariantMap setting; if (!interfaceName().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_MATCH_INTERFACE_NAME), interfaceName()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::MatchSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_MATCH_INTERFACE_NAME << ": " << setting.interfaceName() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/matchsetting.h b/src/settings/matchsetting.h index 62498d0..9ee82aa 100644 --- a/src/settings/matchsetting.h +++ b/src/settings/matchsetting.h @@ -1,66 +1,52 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MATCH_SETTING_H #define NETWORKMANAGERQT_MATCH_SETTING_H #include #include "setting.h" namespace NetworkManager { class MatchSettingPrivate; /** * Represents Match setting */ class NETWORKMANAGERQT_EXPORT MatchSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; MatchSetting(); explicit MatchSetting(const Ptr &other); ~MatchSetting() override; QString name() const override; void setInterfaceName(const QStringList &name); QStringList interfaceName() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: MatchSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(MatchSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const MatchSetting &setting); } #endif // NETWORKMANAGERQT_MATCH_SETTING_H diff --git a/src/settings/matchsetting_p.h b/src/settings/matchsetting_p.h index 2040b2c..8e06d1b 100644 --- a/src/settings/matchsetting_p.h +++ b/src/settings/matchsetting_p.h @@ -1,42 +1,28 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_MATCH_SETTING_P_H #define NETWORKMANAGERQT_MATCH_SETTING_P_H #include namespace NetworkManager { class MatchSettingPrivate { public: MatchSettingPrivate(); QString name; QStringList interfaceName; }; } #endif // NETWORKMANAGERQT_MATCH_SETTING_P_H diff --git a/src/settings/olpcmeshsetting.cpp b/src/settings/olpcmeshsetting.cpp index dfb1b8b..992d076 100644 --- a/src/settings/olpcmeshsetting.cpp +++ b/src/settings/olpcmeshsetting.cpp @@ -1,143 +1,129 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "olpcmeshsetting.h" #include "olpcmeshsetting_p.h" #include NetworkManager::OlpcMeshSettingPrivate::OlpcMeshSettingPrivate() : name(NM_SETTING_OLPC_MESH_SETTING_NAME) , channel(0) { } NetworkManager::OlpcMeshSetting::OlpcMeshSetting() : Setting(Setting::Bond) , d_ptr(new OlpcMeshSettingPrivate()) { } NetworkManager::OlpcMeshSetting::OlpcMeshSetting(const Ptr &other) : Setting(other) , d_ptr(new OlpcMeshSettingPrivate()) { setSsid(other->ssid()); setChannel(other->channel()); setDhcpAnycastAddress(other->dhcpAnycastAddress()); } NetworkManager::OlpcMeshSetting::~OlpcMeshSetting() { delete d_ptr; } QString NetworkManager::OlpcMeshSetting::name() const { Q_D(const OlpcMeshSetting); return d->name; } void NetworkManager::OlpcMeshSetting::setSsid(const QByteArray &ssid) { Q_D(OlpcMeshSetting); d->ssid = ssid; } QByteArray NetworkManager::OlpcMeshSetting::ssid() const { Q_D(const OlpcMeshSetting); return d->ssid; } void NetworkManager::OlpcMeshSetting::setChannel(quint32 channel) { Q_D(OlpcMeshSetting); d->channel = channel; } quint32 NetworkManager::OlpcMeshSetting::channel() const { Q_D(const OlpcMeshSetting); return d->channel; } void NetworkManager::OlpcMeshSetting::setDhcpAnycastAddress(const QByteArray &address) { Q_D(OlpcMeshSetting); d->dhcpAnycastAddress = address; } QByteArray NetworkManager::OlpcMeshSetting::dhcpAnycastAddress() const { Q_D(const OlpcMeshSetting); return d->dhcpAnycastAddress; } void NetworkManager::OlpcMeshSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_OLPC_MESH_SSID))) { setSsid(setting.value(QLatin1String(NM_SETTING_OLPC_MESH_SSID)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_OLPC_MESH_CHANNEL))) { setChannel(setting.value(QLatin1String(NM_SETTING_OLPC_MESH_CHANNEL)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS))) { setDhcpAnycastAddress(setting.value(QLatin1String(NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS)).toByteArray()); } } QVariantMap NetworkManager::OlpcMeshSetting::toMap() const { QVariantMap setting; if (!ssid().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_OLPC_MESH_SSID), ssid()); } if (channel()) { setting.insert(QLatin1String(NM_SETTING_OLPC_MESH_CHANNEL), channel()); } if (!dhcpAnycastAddress().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS), dhcpAnycastAddress()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::OlpcMeshSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_OLPC_MESH_SSID << ": " << setting.ssid() << '\n'; dbg.nospace() << NM_SETTING_OLPC_MESH_CHANNEL << ": " << setting.channel() << '\n'; dbg.nospace() << NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS << ": " << setting.dhcpAnycastAddress() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/olpcmeshsetting.h b/src/settings/olpcmeshsetting.h index ecbed5e..d18e44b 100644 --- a/src/settings/olpcmeshsetting.h +++ b/src/settings/olpcmeshsetting.h @@ -1,72 +1,58 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OLPCMESH_SETTING_H #define NETWORKMANAGERQT_OLPCMESH_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class OlpcMeshSettingPrivate; /** * Represents olpc mesh setting */ class NETWORKMANAGERQT_EXPORT OlpcMeshSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; OlpcMeshSetting(); explicit OlpcMeshSetting(const Ptr &other); ~OlpcMeshSetting() override; QString name() const override; void setSsid(const QByteArray &ssid); QByteArray ssid() const; void setChannel(quint32 channel); quint32 channel() const; void setDhcpAnycastAddress(const QByteArray &address); QByteArray dhcpAnycastAddress() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: OlpcMeshSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(OlpcMeshSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const OlpcMeshSetting &setting); } #endif // NETWORKMANAGERQT_OLPCMESH_SETTING_H diff --git a/src/settings/olpcmeshsetting_p.h b/src/settings/olpcmeshsetting_p.h index e820cdc..7216f62 100644 --- a/src/settings/olpcmeshsetting_p.h +++ b/src/settings/olpcmeshsetting_p.h @@ -1,42 +1,28 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OLPCMESH_SETTING_P_H #define NETWORKMANAGERQT_OLPCMESH_SETTING_P_H #include namespace NetworkManager { class OlpcMeshSettingPrivate { public: OlpcMeshSettingPrivate(); QString name; QByteArray ssid; quint32 channel; QByteArray dhcpAnycastAddress; }; } #endif // NETWORKMANAGERQT_OLPCMESH_SETTING_P_H diff --git a/src/settings/ovsbridgesetting.cpp b/src/settings/ovsbridgesetting.cpp index df25bf6..a4bdd35 100644 --- a/src/settings/ovsbridgesetting.cpp +++ b/src/settings/ovsbridgesetting.cpp @@ -1,169 +1,155 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ovsbridgesetting.h" #include "ovsbridgesetting_p.h" #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_OVS_BRIDGE_SETTING_NAME "ovs-bridge" #define NM_SETTING_OVS_BRIDGE_FAIL_MODE "fail-mode" #define NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE "mcast-snooping-enable" #define NM_SETTING_OVS_BRIDGE_RSTP_ENABLE "rstp-enable" #define NM_SETTING_OVS_BRIDGE_STP_ENABLE "stp-enable" #endif NetworkManager::OvsBridgeSettingPrivate::OvsBridgeSettingPrivate() : name(NM_SETTING_OVS_BRIDGE_SETTING_NAME) , mcastSnoopingEnable(false) , rstpEnable(false) , stpEnable(false) { } NetworkManager::OvsBridgeSetting::OvsBridgeSetting() : Setting(Setting::OvsBridge) , d_ptr(new OvsBridgeSettingPrivate()) { } NetworkManager::OvsBridgeSetting::OvsBridgeSetting(const Ptr &other) : Setting(other) , d_ptr(new OvsBridgeSettingPrivate()) { setFailMode(other->failMode()); setMcastSnoopingEnable(other->mcastSnoopingEnable()); setRstpEnable(other->rstpEnable()); setStpEnable(other->stpEnable()); } NetworkManager::OvsBridgeSetting::~OvsBridgeSetting() { delete d_ptr; } QString NetworkManager::OvsBridgeSetting::name() const { Q_D(const OvsBridgeSetting); return d->name; } void NetworkManager::OvsBridgeSetting::setMcastSnoopingEnable(bool mcastSnoopingEnable) { Q_D(OvsBridgeSetting); d->mcastSnoopingEnable = mcastSnoopingEnable; } bool NetworkManager::OvsBridgeSetting::mcastSnoopingEnable() const { Q_D(const OvsBridgeSetting); return d->mcastSnoopingEnable; } void NetworkManager::OvsBridgeSetting::setRstpEnable(bool rstpEnable) { Q_D(OvsBridgeSetting); d->rstpEnable = rstpEnable; } bool NetworkManager::OvsBridgeSetting::rstpEnable() const { Q_D(const OvsBridgeSetting); return d->rstpEnable; } void NetworkManager::OvsBridgeSetting::setStpEnable(bool stpEnable) { Q_D(OvsBridgeSetting); d->stpEnable = stpEnable; } bool NetworkManager::OvsBridgeSetting::stpEnable() const { Q_D(const OvsBridgeSetting); return d->stpEnable; } void NetworkManager::OvsBridgeSetting::setFailMode(const QString &mode) { Q_D(OvsBridgeSetting); d->failMode = mode; } QString NetworkManager::OvsBridgeSetting::failMode() const { Q_D(const OvsBridgeSetting); return d->failMode; } void NetworkManager::OvsBridgeSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE))) { setMcastSnoopingEnable(setting.value(QLatin1String(NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_OVS_BRIDGE_RSTP_ENABLE))) { setRstpEnable(setting.value(QLatin1String(NM_SETTING_OVS_BRIDGE_RSTP_ENABLE)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_OVS_BRIDGE_STP_ENABLE))) { setStpEnable(setting.value(QLatin1String(NM_SETTING_OVS_BRIDGE_STP_ENABLE)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_OVS_BRIDGE_FAIL_MODE))) { setFailMode(setting.value(QLatin1String(NM_SETTING_OVS_BRIDGE_FAIL_MODE)).toString()); } } QVariantMap NetworkManager::OvsBridgeSetting::toMap() const { QVariantMap setting; setting.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE), mcastSnoopingEnable()); setting.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_RSTP_ENABLE), rstpEnable()); setting.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_STP_ENABLE), stpEnable()); if (!failMode().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_OVS_BRIDGE_FAIL_MODE), failMode()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::OvsBridgeSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE << ": " << setting.mcastSnoopingEnable() << '\n'; dbg.nospace() << NM_SETTING_OVS_BRIDGE_RSTP_ENABLE << ": " << setting.rstpEnable() << '\n'; dbg.nospace() << NM_SETTING_OVS_BRIDGE_STP_ENABLE << ": " << setting.stpEnable() << '\n'; dbg.nospace() << NM_SETTING_OVS_BRIDGE_FAIL_MODE << ": " << setting.failMode() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/ovsbridgesetting.h b/src/settings/ovsbridgesetting.h index 4676a85..1eb1fbc 100644 --- a/src/settings/ovsbridgesetting.h +++ b/src/settings/ovsbridgesetting.h @@ -1,76 +1,62 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_BRIDGE_SETTING_H #define NETWORKMANAGERQT_OVS_BRIDGE_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class OvsBridgeSettingPrivate; /** * Represents ovs-bridge setting */ class NETWORKMANAGERQT_EXPORT OvsBridgeSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; OvsBridgeSetting(); explicit OvsBridgeSetting(const Ptr &other); ~OvsBridgeSetting() override; QString name() const override; void setMcastSnoopingEnable(bool mcastSnoopingEnable); bool mcastSnoopingEnable() const; void setRstpEnable(bool rstpEnable); bool rstpEnable() const; void setStpEnable(bool stpEnable); bool stpEnable() const; void setFailMode(const QString &mode); QString failMode() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: OvsBridgeSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(OvsBridgeSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const OvsBridgeSetting &setting); } #endif // NETWORKMANAGERQT_OVS_BRIDGE_SETTING_H diff --git a/src/settings/ovsbridgesetting_p.h b/src/settings/ovsbridgesetting_p.h index 609ddec..75750b5 100644 --- a/src/settings/ovsbridgesetting_p.h +++ b/src/settings/ovsbridgesetting_p.h @@ -1,45 +1,31 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_BRIDGE_SETTING_P_H #define NETWORKMANAGERQT_OVS_BRIDGE_SETTING_P_H #include namespace NetworkManager { class OvsBridgeSettingPrivate { public: OvsBridgeSettingPrivate(); QString name; bool mcastSnoopingEnable; bool rstpEnable; bool stpEnable; QString failMode; }; } #endif // NETWORKMANAGERQT_OVS_BRIDGE_SETTING_P_H diff --git a/src/settings/ovsinterfacesetting.cpp b/src/settings/ovsinterfacesetting.cpp index 552556a..fe84701 100644 --- a/src/settings/ovsinterfacesetting.cpp +++ b/src/settings/ovsinterfacesetting.cpp @@ -1,100 +1,86 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ovsinterfacesetting.h" #include "ovsinterfacesetting_p.h" #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_OVS_INTERFACE_SETTING_NAME "ovs-interface" #define NM_SETTING_OVS_INTERFACE_TYPE "type" #endif NetworkManager::OvsInterfaceSettingPrivate::OvsInterfaceSettingPrivate() : name(NM_SETTING_OVS_INTERFACE_SETTING_NAME) { } NetworkManager::OvsInterfaceSetting::OvsInterfaceSetting() : Setting(Setting::OvsInterface) , d_ptr(new OvsInterfaceSettingPrivate()) { } NetworkManager::OvsInterfaceSetting::OvsInterfaceSetting(const Ptr &other) : Setting(other) , d_ptr(new OvsInterfaceSettingPrivate()) { setInterfaceType(other->interfaceType()); } NetworkManager::OvsInterfaceSetting::~OvsInterfaceSetting() { delete d_ptr; } QString NetworkManager::OvsInterfaceSetting::name() const { Q_D(const OvsInterfaceSetting); return d->name; } void NetworkManager::OvsInterfaceSetting::setInterfaceType(const QString &type) { Q_D(OvsInterfaceSetting); d->type = type; } QString NetworkManager::OvsInterfaceSetting::interfaceType() const { Q_D(const OvsInterfaceSetting); return d->type; } void NetworkManager::OvsInterfaceSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_OVS_INTERFACE_TYPE))) { setInterfaceType(setting.value(QLatin1String(NM_SETTING_OVS_INTERFACE_TYPE)).toString()); } } QVariantMap NetworkManager::OvsInterfaceSetting::toMap() const { QVariantMap setting; if (!interfaceType().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_OVS_INTERFACE_TYPE), interfaceType()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::OvsInterfaceSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_OVS_INTERFACE_TYPE << ": " << setting.type() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/ovsinterfacesetting.h b/src/settings/ovsinterfacesetting.h index 5797812..687b006 100644 --- a/src/settings/ovsinterfacesetting.h +++ b/src/settings/ovsinterfacesetting.h @@ -1,67 +1,53 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_INTERFACE_SETTING_H #define NETWORKMANAGERQT_OVS_INTERFACE_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class OvsInterfaceSettingPrivate; /** * Represents ovs-interface setting */ class NETWORKMANAGERQT_EXPORT OvsInterfaceSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; OvsInterfaceSetting(); explicit OvsInterfaceSetting(const Ptr &other); ~OvsInterfaceSetting() override; QString name() const override; void setInterfaceType(const QString &type); QString interfaceType() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: OvsInterfaceSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(OvsInterfaceSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const OvsInterfaceSetting &setting); } #endif // NETWORKMANAGERQT_OVS_INTERFACE_SETTING_H diff --git a/src/settings/ovsinterfacesetting_p.h b/src/settings/ovsinterfacesetting_p.h index 1b19235..ec89cba 100644 --- a/src/settings/ovsinterfacesetting_p.h +++ b/src/settings/ovsinterfacesetting_p.h @@ -1,42 +1,28 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_INTERFACE_SETTING_P_H #define NETWORKMANAGERQT_OVS_INTERFACE_SETTING_P_H #include namespace NetworkManager { class OvsInterfaceSettingPrivate { public: OvsInterfaceSettingPrivate(); QString name; QString type; }; } #endif // NETWORKMANAGERQT_OVS_INTERFACE_SETTING_P_H diff --git a/src/settings/ovspatchsetting.cpp b/src/settings/ovspatchsetting.cpp index 2e2578d..cb107ca 100644 --- a/src/settings/ovspatchsetting.cpp +++ b/src/settings/ovspatchsetting.cpp @@ -1,99 +1,85 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ovspatchsetting.h" #include "ovspatchsetting_p.h" #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_OVS_PATCH_SETTING_NAME "ovs-patch" #define NM_SETTING_OVS_PATCH_PEER "peer" #endif NetworkManager::OvsPatchSettingPrivate::OvsPatchSettingPrivate() : name(NM_SETTING_OVS_PATCH_SETTING_NAME) { } NetworkManager::OvsPatchSetting::OvsPatchSetting() : Setting(Setting::OvsPatch) , d_ptr(new OvsPatchSettingPrivate()) { } NetworkManager::OvsPatchSetting::OvsPatchSetting(const Ptr &other) : Setting(other) , d_ptr(new OvsPatchSettingPrivate()) { setPeer(other->peer()); } NetworkManager::OvsPatchSetting::~OvsPatchSetting() { delete d_ptr; } QString NetworkManager::OvsPatchSetting::name() const { Q_D(const OvsPatchSetting); return d->name; } void NetworkManager::OvsPatchSetting::setPeer(const QString &peer) { Q_D(OvsPatchSetting); d->peer = peer; } QString NetworkManager::OvsPatchSetting::peer() const { Q_D(const OvsPatchSetting); return d->peer; } void NetworkManager::OvsPatchSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_OVS_PATCH_PEER))) { setPeer(setting.value(QLatin1String(NM_SETTING_OVS_PATCH_PEER)).toString()); } } QVariantMap NetworkManager::OvsPatchSetting::toMap() const { QVariantMap setting; if (!peer().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_OVS_PATCH_PEER), peer()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::OvsPatchSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_OVS_PATCH_PEER << ": " << setting.peer() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/ovspatchsetting.h b/src/settings/ovspatchsetting.h index 8c1ea1b..45c8a91 100644 --- a/src/settings/ovspatchsetting.h +++ b/src/settings/ovspatchsetting.h @@ -1,67 +1,53 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_PATCH_SETTING_H #define NETWORKMANAGERQT_OVS_PATCH_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class OvsPatchSettingPrivate; /** * Represents OvsPatch setting */ class NETWORKMANAGERQT_EXPORT OvsPatchSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; OvsPatchSetting(); explicit OvsPatchSetting(const Ptr &other); ~OvsPatchSetting() override; QString name() const override; void setPeer(const QString &peer); QString peer() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: OvsPatchSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(OvsPatchSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const OvsPatchSetting &setting); } #endif // NETWORKMANAGERQT_OVS_PATCH_SETTING_H diff --git a/src/settings/ovspatchsetting_p.h b/src/settings/ovspatchsetting_p.h index 6ec61dd..ece6e41 100644 --- a/src/settings/ovspatchsetting_p.h +++ b/src/settings/ovspatchsetting_p.h @@ -1,42 +1,28 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_PATCH_SETTING_P_H #define NETWORKMANAGERQT_OVS_PATCH_SETTING_P_H #include namespace NetworkManager { class OvsPatchSettingPrivate { public: OvsPatchSettingPrivate(); QString name; QString peer; }; } #endif // NETWORKMANAGERQT_OVS_PATCH_SETTING_P_H diff --git a/src/settings/ovsportsetting.cpp b/src/settings/ovsportsetting.cpp index f098984..e2b451f 100644 --- a/src/settings/ovsportsetting.cpp +++ b/src/settings/ovsportsetting.cpp @@ -1,227 +1,213 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "ovsportsetting.h" #include "ovsportsetting_p.h" #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_OVS_PORT_SETTING_NAME "ovs-port" #define NM_SETTING_OVS_PORT_VLAN_MODE "vlan-mode" #define NM_SETTING_OVS_PORT_TAG "tag" #define NM_SETTING_OVS_PORT_LACP "lacp" #define NM_SETTING_OVS_PORT_BOND_MODE "bond-mode" #define NM_SETTING_OVS_PORT_BOND_UPDELAY "bond-updelay" #define NM_SETTING_OVS_PORT_BOND_DOWNDELAY "bond-downdelay" #endif NetworkManager::OvsPortSettingPrivate::OvsPortSettingPrivate() : name(NM_SETTING_OVS_PORT_SETTING_NAME) , bondDowndelay(0) , bondUpdelay(0) , tag(0) { } NetworkManager::OvsPortSetting::OvsPortSetting() : Setting(Setting::OvsPort) , d_ptr(new OvsPortSettingPrivate()) { } NetworkManager::OvsPortSetting::OvsPortSetting(const Ptr &other) : Setting(other) , d_ptr(new OvsPortSettingPrivate()) { setBondDowndelay(other->bondDowndelay()); setBondUpdelay(other->bondUpdelay()); setTag(other->tag()); setBondMode(other->bondMode()); setLacp(other->lacp()); setVlanMode(other->vlanMode()); } NetworkManager::OvsPortSetting::~OvsPortSetting() { delete d_ptr; } QString NetworkManager::OvsPortSetting::name() const { Q_D(const OvsPortSetting); return d->name; } void NetworkManager::OvsPortSetting::setBondDowndelay(quint32 delay) { Q_D(OvsPortSetting); d->bondDowndelay = delay; } quint32 NetworkManager::OvsPortSetting::bondDowndelay() const { Q_D(const OvsPortSetting); return d->bondDowndelay; } void NetworkManager::OvsPortSetting::setBondUpdelay(quint32 delay) { Q_D(OvsPortSetting); d->bondUpdelay = delay; } quint32 NetworkManager::OvsPortSetting::bondUpdelay() const { Q_D(const OvsPortSetting); return d->bondUpdelay; } void NetworkManager::OvsPortSetting::setTag(quint32 tag) { Q_D(OvsPortSetting); d->tag = tag; } quint32 NetworkManager::OvsPortSetting::tag() const { Q_D(const OvsPortSetting); return d->tag; } void NetworkManager::OvsPortSetting::setBondMode(const QString &mode) { Q_D(OvsPortSetting); d->bondMode = mode; } QString NetworkManager::OvsPortSetting::bondMode() const { Q_D(const OvsPortSetting); return d->bondMode; } void NetworkManager::OvsPortSetting::setLacp(const QString &lacp) { Q_D(OvsPortSetting); d->lacp = lacp; } QString NetworkManager::OvsPortSetting::lacp() const { Q_D(const OvsPortSetting); return d->lacp; } void NetworkManager::OvsPortSetting::setVlanMode(const QString &mode) { Q_D(OvsPortSetting); d->vlanMode = mode; } QString NetworkManager::OvsPortSetting::vlanMode() const { Q_D(const OvsPortSetting); return d->vlanMode; } void NetworkManager::OvsPortSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_BOND_UPDELAY))) { setBondUpdelay(setting.value(QLatin1String(NM_SETTING_OVS_PORT_BOND_UPDELAY)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_BOND_DOWNDELAY))) { setBondDowndelay(setting.value(QLatin1String(NM_SETTING_OVS_PORT_BOND_DOWNDELAY)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_TAG))) { setTag(setting.value(QLatin1String(NM_SETTING_OVS_PORT_TAG)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_BOND_MODE))) { setBondMode(setting.value(QLatin1String(NM_SETTING_OVS_PORT_BOND_MODE)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_LACP))) { setLacp(setting.value(QLatin1String(NM_SETTING_OVS_PORT_LACP)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_OVS_PORT_VLAN_MODE))) { setVlanMode(setting.value(QLatin1String(NM_SETTING_OVS_PORT_VLAN_MODE)).toString()); } } QVariantMap NetworkManager::OvsPortSetting::toMap() const { QVariantMap setting; if (bondUpdelay() > 0) { setting.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_UPDELAY), bondUpdelay()); } if (bondDowndelay() > 0) { setting.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_DOWNDELAY), bondDowndelay()); } if (tag() > 0) { setting.insert(QLatin1String(NM_SETTING_OVS_PORT_TAG), tag()); } if (!bondMode().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_OVS_PORT_BOND_MODE), bondMode()); } if (!lacp().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_OVS_PORT_LACP), lacp()); } if (!vlanMode().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_OVS_PORT_VLAN_MODE), vlanMode()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::OvsPortSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_OVS_PORT_BOND_UPDELAY << ": " << setting.bondUpdelay() << '\n'; dbg.nospace() << NM_SETTING_OVS_PORT_BOND_DOWNDELAY << ": " << setting.bondDowndelay() << '\n'; dbg.nospace() << NM_SETTING_OVS_PORT_TAG << ": " << setting.tag() << '\n'; dbg.nospace() << NM_SETTING_OVS_PORT_BOND_MODE << ": " << setting.bondMode() << '\n'; dbg.nospace() << NM_SETTING_OVS_PORT_LACP << ": " << setting.lacp() << '\n'; dbg.nospace() << NM_SETTING_OVS_PORT_VLAN_MODE << ": " << setting.vlanMode() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/ovsportsetting.h b/src/settings/ovsportsetting.h index 15d5463..95ec66c 100644 --- a/src/settings/ovsportsetting.h +++ b/src/settings/ovsportsetting.h @@ -1,80 +1,66 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQTOVS_PORT_SETTING_H #define NETWORKMANAGERQTOVS_PORT_SETTING_H #include #include "setting.h" namespace NetworkManager { class OvsPortSettingPrivate; /** * Represents OvsPort setting */ class NETWORKMANAGERQT_EXPORT OvsPortSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; OvsPortSetting(); explicit OvsPortSetting(const Ptr &other); ~OvsPortSetting() override; QString name() const override; void setBondDowndelay(quint32 delay); quint32 bondDowndelay() const; void setBondUpdelay(quint32 delay); quint32 bondUpdelay() const; void setTag(quint32 tag); quint32 tag() const; void setBondMode(const QString &mode); QString bondMode() const; void setLacp(const QString &lacp); QString lacp() const; void setVlanMode(const QString &mode); QString vlanMode() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: OvsPortSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(OvsPortSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const OvsPortSetting &setting); } #endif // NETWORKMANAGERQT_OVS_PORT_SETTING_H diff --git a/src/settings/ovsportsetting_p.h b/src/settings/ovsportsetting_p.h index 44bd7e4..a81aa4a 100644 --- a/src/settings/ovsportsetting_p.h +++ b/src/settings/ovsportsetting_p.h @@ -1,47 +1,33 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_OVS_PORT_SETTING_P_H #define NETWORKMANAGERQT_OVS_PORT_SETTING_P_H #include namespace NetworkManager { class OvsPortSettingPrivate { public: OvsPortSettingPrivate(); QString name; quint32 bondDowndelay; quint32 bondUpdelay; quint32 tag; QString bondMode; QString lacp; QString vlanMode; }; } #endif // NETWORKMANAGERQT_OVS_PORT_SETTING_P_H diff --git a/src/settings/pppoesetting.cpp b/src/settings/pppoesetting.cpp index 5383f2c..5f6cc73 100644 --- a/src/settings/pppoesetting.cpp +++ b/src/settings/pppoesetting.cpp @@ -1,196 +1,182 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "pppoesetting.h" #include "pppoesetting_p.h" #include NetworkManager::PppoeSettingPrivate::PppoeSettingPrivate() : name(NM_SETTING_PPPOE_SETTING_NAME) , passwordFlags(Setting::None) { } NetworkManager::PppoeSetting::PppoeSetting() : Setting(Setting::Pppoe) , d_ptr(new PppoeSettingPrivate()) { } NetworkManager::PppoeSetting::PppoeSetting(const Ptr &other) : Setting(other) , d_ptr(new PppoeSettingPrivate()) { setService(other->service()); setUsername(other->username()); setPassword(other->password()); setPasswordFlags(other->passwordFlags()); } NetworkManager::PppoeSetting::~PppoeSetting() { delete d_ptr; } QString NetworkManager::PppoeSetting::name() const { Q_D(const PppoeSetting); return d->name; } void NetworkManager::PppoeSetting::setService(const QString &service) { Q_D(PppoeSetting); d->service = service; } QString NetworkManager::PppoeSetting::service() const { Q_D(const PppoeSetting); return d->service; } void NetworkManager::PppoeSetting::setUsername(const QString &username) { Q_D(PppoeSetting); d->username = username; } QString NetworkManager::PppoeSetting::username() const { Q_D(const PppoeSetting); return d->username; } void NetworkManager::PppoeSetting::setPassword(const QString &password) { Q_D(PppoeSetting); d->password = password; } QString NetworkManager::PppoeSetting::password() const { Q_D(const PppoeSetting); return d->password; } void NetworkManager::PppoeSetting::setPasswordFlags(NetworkManager::Setting::SecretFlags flags) { Q_D(PppoeSetting); d->passwordFlags = flags; } NetworkManager::Setting::SecretFlags NetworkManager::PppoeSetting::passwordFlags() const { Q_D(const PppoeSetting); return d->passwordFlags; } QStringList NetworkManager::PppoeSetting::needSecrets(bool requestNew) const { QStringList secrets; if ((password().isEmpty() || requestNew) && !passwordFlags().testFlag(Setting::NotRequired)) { secrets << QLatin1String(NM_SETTING_PPPOE_PASSWORD); } return secrets; } void NetworkManager::PppoeSetting::secretsFromMap(const QVariantMap &secrets) { if (secrets.contains(QLatin1String(NM_SETTING_PPPOE_PASSWORD))) { setPassword(secrets.value(QLatin1String(NM_SETTING_PPPOE_PASSWORD)).toString()); } } QVariantMap NetworkManager::PppoeSetting::secretsToMap() const { QVariantMap secrets; if (!password().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_PPPOE_PASSWORD), password()); } return secrets; } void NetworkManager::PppoeSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_PPPOE_SERVICE))) { setService(setting.value(QLatin1String(NM_SETTING_PPPOE_SERVICE)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_PPPOE_USERNAME))) { setUsername(setting.value(QLatin1String(NM_SETTING_PPPOE_USERNAME)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_PPPOE_PASSWORD))) { setPassword(setting.value(QLatin1String(NM_SETTING_PPPOE_PASSWORD)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_PPPOE_PASSWORD_FLAGS))) { setPasswordFlags((Setting::SecretFlags)setting.value(QLatin1String(NM_SETTING_PPPOE_PASSWORD_FLAGS)).toUInt()); } } QVariantMap NetworkManager::PppoeSetting::toMap() const { QVariantMap setting; if (!service().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_PPPOE_SERVICE), service()); } if (!username().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_PPPOE_USERNAME), username()); } if (!password().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_PPPOE_PASSWORD), password()); } if (passwordFlags()) { setting.insert(QLatin1String(NM_SETTING_PPPOE_PASSWORD_FLAGS), (int)passwordFlags()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::PppoeSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_PPPOE_SERVICE << ": " << setting.service() << '\n'; dbg.nospace() << NM_SETTING_PPPOE_USERNAME << ": " << setting.username() << '\n'; dbg.nospace() << NM_SETTING_PPPOE_PASSWORD << ": " << setting.password() << '\n'; dbg.nospace() << NM_SETTING_PPPOE_PASSWORD_FLAGS << ": " << setting.passwordFlags() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/pppoesetting.h b/src/settings/pppoesetting.h index f40d495..e51e58e 100644 --- a/src/settings/pppoesetting.h +++ b/src/settings/pppoesetting.h @@ -1,81 +1,67 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_PPPOE_SETTING_H #define NETWORKMANAGERQT_PPPOE_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class PppoeSettingPrivate; /** * Represents pppoe setting */ class NETWORKMANAGERQT_EXPORT PppoeSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; PppoeSetting(); explicit PppoeSetting(const Ptr &other); ~PppoeSetting() override; QString name() const override; void setService(const QString &service); QString service() const; void setUsername(const QString &username); QString username() const; void setPassword(const QString &password); QString password() const; void setPasswordFlags(Setting::SecretFlags flags); Setting::SecretFlags passwordFlags() const; QStringList needSecrets(bool requestNew = false) const override; void secretsFromMap(const QVariantMap &secrets) override; QVariantMap secretsToMap() const override; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: PppoeSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(PppoeSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const PppoeSetting &setting); } #endif // NETWORKMANAGERQT_PPPOE_SETTING_H diff --git a/src/settings/pppoesetting_p.h b/src/settings/pppoesetting_p.h index 35ca144..2d7b1c0 100644 --- a/src/settings/pppoesetting_p.h +++ b/src/settings/pppoesetting_p.h @@ -1,43 +1,29 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_PPPOE_SETTING_P_H #define NETWORKMANAGERQT_PPPOE_SETTING_P_H #include namespace NetworkManager { class PppoeSettingPrivate { public: PppoeSettingPrivate(); QString name; QString service; QString username; QString password; NetworkManager::Setting::SecretFlags passwordFlags; }; } #endif // NETWORKMANAGERQT_PPPOE_SETTING_P_H diff --git a/src/settings/pppsetting.cpp b/src/settings/pppsetting.cpp index 898c64a..08ba1e9 100644 --- a/src/settings/pppsetting.cpp +++ b/src/settings/pppsetting.cpp @@ -1,520 +1,506 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "pppsetting.h" #include "pppsetting_p.h" #include NetworkManager::PppSettingPrivate::PppSettingPrivate() : name(NM_SETTING_PPP_SETTING_NAME) , noauth(true) , refuseEap(false) , refusePap(false) , refuseChap(false) , refuseMschap(false) , refuseMschapv2(false) , nobsdcomp(false) , nodeflate(false) , noVjComp(false) , requireMppe(false) , requireMppe128(false) , mppeStateful(false) , crtscts(false) , baud(0) , mru(0) , mtu(0) , lcpEchoFailure(0) , lcpEchoInterval(0) { } NetworkManager::PppSetting::PppSetting() : Setting(Setting::Ppp) , d_ptr(new PppSettingPrivate()) { } NetworkManager::PppSetting::PppSetting(const Ptr &other) : Setting(other) , d_ptr(new PppSettingPrivate()) { setNoAuth(other->noAuth()); setRefuseEap(other->refuseEap()); setRefusePap(other->refusePap()); setRefuseChap(other->refuseChap()); setRefuseMschap(other->refuseMschap()); setRefuseMschapv2(other->refuseMschapv2()); setNoBsdComp(other->noBsdComp()); setNoDeflate(other->noDeflate()); setNoVjComp(other->noVjComp()); setRequireMppe(other->requireMppe()); setRequireMppe128(other->requireMppe128()); setMppeStateful(other->mppeStateful()); setCRtsCts(other->cRtsCts()); setBaud(other->baud()); setMru(other->mru()); setMtu(other->mtu()); setLcpEchoFailure(other->lcpEchoFailure()); setLcpEchoInterval(other->lcpEchoInterval()); } NetworkManager::PppSetting::~PppSetting() { delete d_ptr; } QString NetworkManager::PppSetting::name() const { Q_D(const PppSetting); return d->name; } void NetworkManager::PppSetting::setNoAuth(bool require) { Q_D(PppSetting); d->noauth = require; } bool NetworkManager::PppSetting::noAuth() const { Q_D(const PppSetting); return d->noauth; } void NetworkManager::PppSetting::setRefuseEap(bool refuse) { Q_D(PppSetting); d->refuseEap = refuse; } bool NetworkManager::PppSetting::refuseEap() const { Q_D(const PppSetting); return d->refuseEap; } void NetworkManager::PppSetting::setRefusePap(bool refuse) { Q_D(PppSetting); d->refusePap = refuse; } bool NetworkManager::PppSetting::refusePap() const { Q_D(const PppSetting); return d->refusePap; } void NetworkManager::PppSetting::setRefuseChap(bool refuse) { Q_D(PppSetting); d->refuseChap = refuse; } bool NetworkManager::PppSetting::refuseChap() const { Q_D(const PppSetting); return d->refuseChap; } void NetworkManager::PppSetting::setRefuseMschap(bool refuse) { Q_D(PppSetting); d->refuseMschap = refuse; } bool NetworkManager::PppSetting::refuseMschap() const { Q_D(const PppSetting); return d->refuseMschap; } void NetworkManager::PppSetting::setRefuseMschapv2(bool refuse) { Q_D(PppSetting); d->refuseMschapv2 = refuse; } bool NetworkManager::PppSetting::refuseMschapv2() const { Q_D(const PppSetting); return d->refuseMschapv2; } void NetworkManager::PppSetting::setNoBsdComp(bool require) { Q_D(PppSetting); d->nobsdcomp = require; } bool NetworkManager::PppSetting::noBsdComp() const { Q_D(const PppSetting); return d->nobsdcomp; } void NetworkManager::PppSetting::setNoDeflate(bool require) { Q_D(PppSetting); d->nodeflate = require; } bool NetworkManager::PppSetting::noDeflate() const { Q_D(const PppSetting); return d->nodeflate; } void NetworkManager::PppSetting::setNoVjComp(bool require) { Q_D(PppSetting); d->noVjComp = require; } bool NetworkManager::PppSetting::noVjComp() const { Q_D(const PppSetting); return d->noVjComp; } void NetworkManager::PppSetting::setRequireMppe(bool require) { Q_D(PppSetting); d->requireMppe = require; } bool NetworkManager::PppSetting::requireMppe() const { Q_D(const PppSetting); return d->requireMppe; } void NetworkManager::PppSetting::setRequireMppe128(bool require) { Q_D(PppSetting); d->requireMppe128 = require; } bool NetworkManager::PppSetting::requireMppe128() const { Q_D(const PppSetting); return d->requireMppe128; } void NetworkManager::PppSetting::setMppeStateful(bool used) { Q_D(PppSetting); d->mppeStateful = used; } bool NetworkManager::PppSetting::mppeStateful() const { Q_D(const PppSetting); return d->mppeStateful; } void NetworkManager::PppSetting::setCRtsCts(bool control) { Q_D(PppSetting); d->crtscts = control; } bool NetworkManager::PppSetting::cRtsCts() const { Q_D(const PppSetting); return d->crtscts; } void NetworkManager::PppSetting::setBaud(quint32 baud) { Q_D(PppSetting); d->baud = baud; } quint32 NetworkManager::PppSetting::baud() const { Q_D(const PppSetting); return d->baud; } void NetworkManager::PppSetting::setMru(quint32 mru) { Q_D(PppSetting); d->mru = mru; } quint32 NetworkManager::PppSetting::mru() const { Q_D(const PppSetting); return d->mru; } void NetworkManager::PppSetting::setMtu(quint32 mtu) { Q_D(PppSetting); d->mtu = mtu; } quint32 NetworkManager::PppSetting::mtu() const { Q_D(const PppSetting); return d->mtu; } void NetworkManager::PppSetting::setLcpEchoFailure(quint32 number) { Q_D(PppSetting); d->lcpEchoFailure = number; } quint32 NetworkManager::PppSetting::lcpEchoFailure() const { Q_D(const PppSetting); return d->lcpEchoFailure; } void NetworkManager::PppSetting::setLcpEchoInterval(quint32 interval) { Q_D(PppSetting); d->lcpEchoInterval = interval; } quint32 NetworkManager::PppSetting::lcpEchoInterval() const { Q_D(const PppSetting); return d->lcpEchoInterval; } void NetworkManager::PppSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_PPP_NOAUTH))) { setNoAuth(setting.value(QLatin1String(NM_SETTING_PPP_NOAUTH)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_REFUSE_EAP))) { setRefuseEap(setting.value(QLatin1String(NM_SETTING_PPP_REFUSE_EAP)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_REFUSE_PAP))) { setRefusePap(setting.value(QLatin1String(NM_SETTING_PPP_REFUSE_PAP)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_REFUSE_CHAP))) { setRefuseChap(setting.value(QLatin1String(NM_SETTING_PPP_REFUSE_CHAP)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAP))) { setRefuseMschap(setting.value(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAP)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAPV2))) { setRefuseMschapv2(setting.value(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAPV2)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_NOBSDCOMP))) { setNoBsdComp(setting.value(QLatin1String(NM_SETTING_PPP_NOBSDCOMP)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_NODEFLATE))) { setNoDeflate(setting.value(QLatin1String(NM_SETTING_PPP_NODEFLATE)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_NO_VJ_COMP))) { setNoVjComp(setting.value(QLatin1String(NM_SETTING_PPP_NO_VJ_COMP)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE))) { setRequireMppe(setting.value(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE_128))) { setRequireMppe128(setting.value(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE_128)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_MPPE_STATEFUL))) { setMppeStateful(setting.value(QLatin1String(NM_SETTING_PPP_MPPE_STATEFUL)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_CRTSCTS))) { setCRtsCts(setting.value(QLatin1String(NM_SETTING_PPP_CRTSCTS)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_BAUD))) { setBaud(setting.value(QLatin1String(NM_SETTING_PPP_BAUD)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_MRU))) { setMru(setting.value(QLatin1String(NM_SETTING_PPP_MRU)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_MTU))) { setMtu(setting.value(QLatin1String(NM_SETTING_PPP_MTU)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_LCP_ECHO_FAILURE))) { setLcpEchoFailure(setting.value(QLatin1String(NM_SETTING_PPP_LCP_ECHO_FAILURE)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_PPP_LCP_ECHO_INTERVAL))) { setLcpEchoInterval(setting.value(QLatin1String(NM_SETTING_PPP_LCP_ECHO_INTERVAL)).toUInt()); } } QVariantMap NetworkManager::PppSetting::toMap() const { QVariantMap setting; if (!noAuth()) { setting.insert(QLatin1String(NM_SETTING_PPP_NOAUTH), noAuth()); } if (refuseEap()) { setting.insert(QLatin1String(NM_SETTING_PPP_REFUSE_EAP), refuseEap()); } if (refusePap()) { setting.insert(QLatin1String(NM_SETTING_PPP_REFUSE_PAP), refusePap()); } if (refuseChap()) { setting.insert(QLatin1String(NM_SETTING_PPP_REFUSE_CHAP), refuseChap()); } if (refuseMschap()) { setting.insert(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAP), refuseMschap()); } if (refuseMschapv2()) { setting.insert(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAPV2), refuseMschapv2()); } if (noBsdComp()) { setting.insert(QLatin1String(NM_SETTING_PPP_NOBSDCOMP), noBsdComp()); } if (noDeflate()) { setting.insert(QLatin1String(NM_SETTING_PPP_NODEFLATE), noDeflate()); } if (noVjComp()) { setting.insert(QLatin1String(NM_SETTING_PPP_NO_VJ_COMP), noVjComp()); } if (requireMppe()) { setting.insert(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE), requireMppe()); } if (requireMppe128()) { setting.insert(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE_128), requireMppe128()); } if (mppeStateful()) { setting.insert(QLatin1String(NM_SETTING_PPP_MPPE_STATEFUL), mppeStateful()); } if (cRtsCts()) { setting.insert(QLatin1String(NM_SETTING_PPP_CRTSCTS), cRtsCts()); } if (baud()) { setting.insert(QLatin1String(NM_SETTING_PPP_BAUD), baud()); } if (mru()) { setting.insert(QLatin1String(NM_SETTING_PPP_MRU), mru()); } if (mtu()) { setting.insert(QLatin1String(NM_SETTING_PPP_MTU), mtu()); } if (lcpEchoFailure()) { setting.insert(QLatin1String(NM_SETTING_PPP_LCP_ECHO_FAILURE), lcpEchoFailure()); } if (lcpEchoInterval()) { setting.insert(QLatin1String(NM_SETTING_PPP_LCP_ECHO_INTERVAL), lcpEchoInterval()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::PppSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_PPP_NOAUTH << ": " << setting.noAuth() << '\n'; dbg.nospace() << NM_SETTING_PPP_REFUSE_EAP << ": " << setting.refuseEap() << '\n'; dbg.nospace() << NM_SETTING_PPP_REFUSE_PAP << ": " << setting.refusePap() << '\n'; dbg.nospace() << NM_SETTING_PPP_REFUSE_CHAP << ": " << setting.refuseChap() << '\n'; dbg.nospace() << NM_SETTING_PPP_REFUSE_MSCHAP << ": " << setting.refuseMschap() << '\n'; dbg.nospace() << NM_SETTING_PPP_REFUSE_MSCHAPV2 << ": " << setting.refuseMschapv2() << '\n'; dbg.nospace() << NM_SETTING_PPP_NOBSDCOMP << ": " << setting.noBsdComp() << '\n'; dbg.nospace() << NM_SETTING_PPP_NODEFLATE << ": " << setting.noDeflate() << '\n'; dbg.nospace() << NM_SETTING_PPP_NO_VJ_COMP << ": " << setting.noVjComp() << '\n'; dbg.nospace() << NM_SETTING_PPP_REQUIRE_MPPE << ": " << setting.requireMppe() << '\n'; dbg.nospace() << NM_SETTING_PPP_REQUIRE_MPPE_128 << ": " << setting.requireMppe128() << '\n'; dbg.nospace() << NM_SETTING_PPP_MPPE_STATEFUL << ": " << setting.mppeStateful() << '\n'; dbg.nospace() << NM_SETTING_PPP_CRTSCTS << ": " << setting.cRtsCts() << '\n'; dbg.nospace() << NM_SETTING_PPP_BAUD << ": " << setting.baud() << '\n'; dbg.nospace() << NM_SETTING_PPP_MRU << ": " << setting.mru() << '\n'; dbg.nospace() << NM_SETTING_PPP_MTU << ": " << setting.mtu() << '\n'; dbg.nospace() << NM_SETTING_PPP_LCP_ECHO_FAILURE << ": " << setting.lcpEchoFailure() << '\n'; dbg.nospace() << NM_SETTING_PPP_LCP_ECHO_INTERVAL << ": " << setting.lcpEchoInterval() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/pppsetting.h b/src/settings/pppsetting.h index 87fd157..715dd96 100644 --- a/src/settings/pppsetting.h +++ b/src/settings/pppsetting.h @@ -1,117 +1,103 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_PPP_SETTING_H #define NETWORKMANAGERQT_PPP_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class PppSettingPrivate; /** * Represents ppp setting */ class NETWORKMANAGERQT_EXPORT PppSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; PppSetting(); explicit PppSetting(const Ptr &other); ~PppSetting() override; QString name() const override; void setNoAuth(bool require); bool noAuth() const; void setRefuseEap(bool refuse); bool refuseEap() const; void setRefusePap(bool refuse); bool refusePap() const; void setRefuseChap(bool refuse); bool refuseChap() const; void setRefuseMschap(bool refuse); bool refuseMschap() const; void setRefuseMschapv2(bool refuse); bool refuseMschapv2() const; void setNoBsdComp(bool require); bool noBsdComp() const; void setNoDeflate(bool require); bool noDeflate() const; void setNoVjComp(bool require); bool noVjComp() const; void setRequireMppe(bool require); bool requireMppe() const; void setRequireMppe128(bool require); bool requireMppe128() const; void setMppeStateful(bool used); bool mppeStateful() const; void setCRtsCts(bool control); bool cRtsCts() const; void setBaud(quint32 baud); quint32 baud() const; void setMru(quint32 mru); quint32 mru() const; void setMtu(quint32 mtu); quint32 mtu() const; void setLcpEchoFailure(quint32 number); quint32 lcpEchoFailure() const; void setLcpEchoInterval(quint32 interval); quint32 lcpEchoInterval() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: PppSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(PppSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const PppSetting &setting); } #endif // NETWORKMANAGERQT_PPP_SETTING_H diff --git a/src/settings/pppsetting_p.h b/src/settings/pppsetting_p.h index ceb3805..6a16851 100644 --- a/src/settings/pppsetting_p.h +++ b/src/settings/pppsetting_p.h @@ -1,57 +1,43 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_PPP_SETTING_P_H #define NETWORKMANAGERQT_PPP_SETTING_P_H #include namespace NetworkManager { class PppSettingPrivate { public: PppSettingPrivate(); QString name; bool noauth; bool refuseEap; bool refusePap; bool refuseChap; bool refuseMschap; bool refuseMschapv2; bool nobsdcomp; bool nodeflate; bool noVjComp; bool requireMppe; bool requireMppe128; bool mppeStateful; bool crtscts; quint32 baud; quint32 mru; quint32 mtu; quint32 lcpEchoFailure; quint32 lcpEchoInterval; }; } #endif // NETWORKMANAGERQT_PPP_SETTING_P_H diff --git a/src/settings/proxysetting.cpp b/src/settings/proxysetting.cpp index 78f3306..8a1a632 100644 --- a/src/settings/proxysetting.cpp +++ b/src/settings/proxysetting.cpp @@ -1,174 +1,160 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "proxysetting.h" #include "proxysetting_p.h" #include #if !NM_CHECK_VERSION(1, 6, 0) #define NM_SETTING_PROXY_SETTING_NAME "proxy" #define NM_SETTING_PROXY_BROWSER_ONLY "browser-only" #define NM_SETTING_PROXY_METHOD "method" #define NM_SETTING_PROXY_PAC_SCRIPT "pac-script" #define NM_SETTING_PROXY_PAC_URL "pac-url" #endif NetworkManager::ProxySettingPrivate::ProxySettingPrivate() : name(NM_SETTING_PROXY_SETTING_NAME) , browserOnly(false) , method(ProxySetting::None) { } NetworkManager::ProxySetting::ProxySetting() : Setting(Setting::Proxy) , d_ptr(new ProxySettingPrivate()) { } NetworkManager::ProxySetting::ProxySetting(const Ptr &other) : Setting(other) , d_ptr(new ProxySettingPrivate()) { setBrowserOnly(other->browserOnly()); setMethod(other->method()); setPacScript(other->pacScript()); setPacUrl(other->pacUrl()); } NetworkManager::ProxySetting::~ProxySetting() { delete d_ptr; } QString NetworkManager::ProxySetting::name() const { Q_D(const ProxySetting); return d->name; } void NetworkManager::ProxySetting::setBrowserOnly(bool browserOnly) { Q_D(ProxySetting); d->browserOnly = browserOnly; } bool NetworkManager::ProxySetting::browserOnly() const { Q_D(const ProxySetting); return d->browserOnly; } void NetworkManager::ProxySetting::setMethod(NetworkManager::ProxySetting::Mode method) { Q_D(ProxySetting); d->method = method; } NetworkManager::ProxySetting::Mode NetworkManager::ProxySetting::method() const { Q_D(const ProxySetting); return d->method; } void NetworkManager::ProxySetting::setPacScript(const QString &script) { Q_D(ProxySetting); d->pacScript = script; } QString NetworkManager::ProxySetting::pacScript() const { Q_D(const ProxySetting); return d->pacScript; } void NetworkManager::ProxySetting::setPacUrl(const QString &url) { Q_D(ProxySetting); d->pacUrl = url; } QString NetworkManager::ProxySetting::pacUrl() const { Q_D(const ProxySetting); return d->pacUrl; } void NetworkManager::ProxySetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_PROXY_BROWSER_ONLY))) { setBrowserOnly(setting.value(QLatin1String(NM_SETTING_PROXY_BROWSER_ONLY)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_PROXY_METHOD))) { setMethod((Mode)setting.value(QLatin1String(NM_SETTING_PROXY_METHOD)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_PROXY_PAC_SCRIPT))) { setPacScript(setting.value(QLatin1String(NM_SETTING_PROXY_PAC_SCRIPT)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_PROXY_PAC_URL))) { setPacUrl(setting.value(QLatin1String(NM_SETTING_PROXY_PAC_URL)).toString()); } } QVariantMap NetworkManager::ProxySetting::toMap() const { QVariantMap setting; setting.insert(QLatin1String(NM_SETTING_PROXY_BROWSER_ONLY), browserOnly()); if (method() > 0) { setting.insert(QLatin1String(NM_SETTING_PROXY_METHOD), (int)method()); } if (!pacScript().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_PROXY_PAC_SCRIPT), pacScript()); } if (!pacUrl().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_PROXY_PAC_URL), pacUrl()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::ProxySetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_PROXY_BROWSER_ONLY << ": " << setting.browserOnly() << '\n'; dbg.nospace() << NM_SETTING_PROXY_METHOD << ": " << setting.method() << '\n'; dbg.nospace() << NM_SETTING_PROXY_PAC_SCRIPT << ": " << setting.pacScript() << '\n'; dbg.nospace() << NM_SETTING_PROXY_PAC_URL << ": " << setting.pacUrl() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/proxysetting.h b/src/settings/proxysetting.h index 4b7434c..ec46ca5 100644 --- a/src/settings/proxysetting.h +++ b/src/settings/proxysetting.h @@ -1,81 +1,67 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_PROXY_SETTING_H #define NETWORKMANAGERQT_PROXY_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class ProxySettingPrivate; /** * Represents proxy setting */ class NETWORKMANAGERQT_EXPORT ProxySetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum Mode { None = 0, Auto = 1 }; ProxySetting(); explicit ProxySetting(const Ptr &other); ~ProxySetting() override; QString name() const override; void setBrowserOnly(bool browserOnly); bool browserOnly() const; void setMethod(Mode method); Mode method() const; void setPacScript(const QString &script); QString pacScript() const; void setPacUrl(const QString &url); QString pacUrl() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: ProxySettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(ProxySetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const ProxySetting &setting); } #endif // NETWORKMANAGERQT_PROXY_SETTING_H diff --git a/src/settings/proxysetting_p.h b/src/settings/proxysetting_p.h index 33a1e82..db90da1 100644 --- a/src/settings/proxysetting_p.h +++ b/src/settings/proxysetting_p.h @@ -1,45 +1,31 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_PROXY_SETTING_P_H #define NETWORKMANAGERQT_PROXY_SETTING_P_H #include namespace NetworkManager { class ProxySettingPrivate { public: ProxySettingPrivate(); QString name; bool browserOnly; NetworkManager::ProxySetting::Mode method; QString pacScript; QString pacUrl; }; } #endif // NETWORKMANAGERQT_PROXY_SETTING_P_H diff --git a/src/settings/security8021xsetting.cpp b/src/settings/security8021xsetting.cpp index c9d89e5..9fa96bc 100644 --- a/src/settings/security8021xsetting.cpp +++ b/src/settings/security8021xsetting.cpp @@ -1,1129 +1,1115 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "security8021xsetting.h" #include "security8021xsetting_p.h" #include NetworkManager::Security8021xSettingPrivate::Security8021xSettingPrivate() : name(NM_SETTING_802_1X_SETTING_NAME) , phase1PeapVer(Security8021xSetting::PeapVersionUnknown) , phase1PeapLabel(Security8021xSetting::PeapLabelUnknown) , phase1FastProvisioning(Security8021xSetting::FastProvisioningUnknown) , phase2AuthMethod(Security8021xSetting::AuthMethodUnknown) , phase2AuthEapMethod(Security8021xSetting::AuthEapMethodUnknown) , passwordFlags(NetworkManager::Setting::None) , passwordRawFlags(NetworkManager::Setting::None) , privateKeyPasswordFlags(NetworkManager::Setting::None) , phase2PrivateKeyPasswordFlags(NetworkManager::Setting::None) , pinFlags(NetworkManager::Setting::None) , systemCaCerts(false) { } NetworkManager::Security8021xSetting::Security8021xSetting() : Setting(Setting::Security8021x) , d_ptr(new Security8021xSettingPrivate()) { } NetworkManager::Security8021xSetting::Security8021xSetting(const Ptr &other) : Setting(other) , d_ptr(new Security8021xSettingPrivate()) { setEapMethods(other->eapMethods()); setIdentity(other->identity()); setDomainSuffixMatch(other->domainSuffixMatch()); setAnonymousIdentity(other->anonymousIdentity()); setPacFile(other->pacFile()); setCaCertificate(other->caCertificate()); setCaPath(other->caPath()); setSubjectMatch(other->subjectMatch()); setAltSubjectMatches(other->altSubjectMatches()); setClientCertificate(other->clientCertificate()); setPhase1PeapVersion(other->phase1PeapVersion()); setPhase1PeapLabel(other->phase1PeapLabel()); setPhase1FastProvisioning(other->phase1FastProvisioning()); setPhase2AuthMethod(other->phase2AuthMethod()); setPhase2AuthEapMethod(other->phase2AuthEapMethod()); setPhase2CaCertificate(other->phase2CaCertificate()); setPhase2CaPath(other->phase2CaPath()); setPhase2SubjectMatch(other->phase2SubjectMatch()); setPhase2AltSubjectMatches(other->phase2AltSubjectMatches()); setPassword(other->password()); setPasswordFlags(other->passwordFlags()); setPasswordRaw(other->passwordRaw()); setPasswordRawFlags(other->passwordRawFlags()); setPrivateKey(other->privateKey()); setPrivateKeyPassword(other->privateKeyPassword()); setPrivateKeyPasswordFlags(other->privateKeyPasswordFlags()); setPhase2PrivateKey(other->phase2PrivateKey()); setPhase2PrivateKeyPassword(other->phase2PrivateKeyPassword()); setPhase2PrivateKeyPasswordFlags(other->phase2PrivateKeyPasswordFlags()); setSystemCaCertificates(other->systemCaCertificates()); } NetworkManager::Security8021xSetting::~Security8021xSetting() { delete d_ptr; } QString NetworkManager::Security8021xSetting::name() const { Q_D(const Security8021xSetting); return d->name; } void NetworkManager::Security8021xSetting::setEapMethods(const QList< NetworkManager::Security8021xSetting::EapMethod > &methods) { Q_D(Security8021xSetting); d->eap = methods; } QList< NetworkManager::Security8021xSetting::EapMethod > NetworkManager::Security8021xSetting::eapMethods() const { Q_D(const Security8021xSetting); return d->eap; } void NetworkManager::Security8021xSetting::setIdentity(const QString &identity) { Q_D(Security8021xSetting); d->identity = identity; } QString NetworkManager::Security8021xSetting::identity() const { Q_D(const Security8021xSetting); return d->identity; } void NetworkManager::Security8021xSetting::setAnonymousIdentity(const QString &identity) { Q_D(Security8021xSetting); d->anonymousIdentity = identity; } QString NetworkManager::Security8021xSetting::anonymousIdentity() const { Q_D(const Security8021xSetting); return d->anonymousIdentity; } void NetworkManager::Security8021xSetting::setDomainSuffixMatch(const QString &domain) { Q_D(Security8021xSetting); d->domainSuffixMatch = domain; } QString NetworkManager::Security8021xSetting::domainSuffixMatch() const { Q_D(const Security8021xSetting); return d->domainSuffixMatch; } void NetworkManager::Security8021xSetting::setPacFile(const QString &filePath) { Q_D(Security8021xSetting); d->pacFile = filePath; } QString NetworkManager::Security8021xSetting::pacFile() const { Q_D(const Security8021xSetting); return d->pacFile; } void NetworkManager::Security8021xSetting::setCaCertificate(const QByteArray &certificate) { Q_D(Security8021xSetting); d->caCert = certificate; } QByteArray NetworkManager::Security8021xSetting::caCertificate() const { Q_D(const Security8021xSetting); return d->caCert; } void NetworkManager::Security8021xSetting::setCaPath(const QString &path) { Q_D(Security8021xSetting); d->caPath = path; } QString NetworkManager::Security8021xSetting::caPath() const { Q_D(const Security8021xSetting); return d->caPath; } void NetworkManager::Security8021xSetting::setSubjectMatch(const QString &substring) { Q_D(Security8021xSetting); d->subjectMatch = substring; } QString NetworkManager::Security8021xSetting::subjectMatch() const { Q_D(const Security8021xSetting); return d->subjectMatch; } void NetworkManager::Security8021xSetting::setAltSubjectMatches(const QStringList &strings) { Q_D(Security8021xSetting); d->altSubjectMatches = strings; } QStringList NetworkManager::Security8021xSetting::altSubjectMatches() const { Q_D(const Security8021xSetting); return d->altSubjectMatches; } void NetworkManager::Security8021xSetting::setClientCertificate(const QByteArray &certificate) { Q_D(Security8021xSetting); d->clientCert = certificate; } QByteArray NetworkManager::Security8021xSetting::clientCertificate() const { Q_D(const Security8021xSetting); return d->clientCert; } void NetworkManager::Security8021xSetting::setPhase1PeapVersion(NetworkManager::Security8021xSetting::PeapVersion version) { Q_D(Security8021xSetting); d->phase1PeapVer = version; } NetworkManager::Security8021xSetting::PeapVersion NetworkManager::Security8021xSetting::phase1PeapVersion() const { Q_D(const Security8021xSetting); return d->phase1PeapVer; } void NetworkManager::Security8021xSetting::setPhase1PeapLabel(NetworkManager::Security8021xSetting::PeapLabel label) { Q_D(Security8021xSetting); d->phase1PeapLabel = label; } NetworkManager::Security8021xSetting::PeapLabel NetworkManager::Security8021xSetting::phase1PeapLabel() const { Q_D(const Security8021xSetting); return d->phase1PeapLabel; } void NetworkManager::Security8021xSetting::setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioning provisioning) { Q_D(Security8021xSetting); d->phase1FastProvisioning = provisioning; } NetworkManager::Security8021xSetting::FastProvisioning NetworkManager::Security8021xSetting::phase1FastProvisioning() const { Q_D(const Security8021xSetting); return d->phase1FastProvisioning; } void NetworkManager::Security8021xSetting::setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethod method) { Q_D(Security8021xSetting); d->phase2AuthMethod = method; } NetworkManager::Security8021xSetting::AuthMethod NetworkManager::Security8021xSetting::phase2AuthMethod() const { Q_D(const Security8021xSetting); return d->phase2AuthMethod; } void NetworkManager::Security8021xSetting::setPhase2AuthEapMethod(NetworkManager::Security8021xSetting::AuthEapMethod method) { Q_D(Security8021xSetting); d->phase2AuthEapMethod = method; } NetworkManager::Security8021xSetting::AuthEapMethod NetworkManager::Security8021xSetting::phase2AuthEapMethod() const { Q_D(const Security8021xSetting); return d->phase2AuthEapMethod; } void NetworkManager::Security8021xSetting::setPhase2CaCertificate(const QByteArray &certificate) { Q_D(Security8021xSetting); d->phase2CaCert = certificate; } QByteArray NetworkManager::Security8021xSetting::phase2CaCertificate() const { Q_D(const Security8021xSetting); return d->phase2CaCert; } void NetworkManager::Security8021xSetting::setPhase2CaPath(const QString &path) { Q_D(Security8021xSetting); d->phase2CaPath = path; } QString NetworkManager::Security8021xSetting::phase2CaPath() const { Q_D(const Security8021xSetting); return d->phase2CaPath; } void NetworkManager::Security8021xSetting::setPhase2SubjectMatch(const QString &substring) { Q_D(Security8021xSetting); d->phase2SubjectMatch = substring; } QString NetworkManager::Security8021xSetting::phase2SubjectMatch() const { Q_D(const Security8021xSetting); return d->phase2SubjectMatch; } void NetworkManager::Security8021xSetting::setPhase2AltSubjectMatches(const QStringList &strings) { Q_D(Security8021xSetting); d->phase2AltSubjectMatches = strings; } QStringList NetworkManager::Security8021xSetting::phase2AltSubjectMatches() const { Q_D(const Security8021xSetting); return d->phase2AltSubjectMatches; } void NetworkManager::Security8021xSetting::setPhase2ClientCertificate(const QByteArray &certificate) { Q_D(Security8021xSetting); d->phase2ClientCert = certificate; } QByteArray NetworkManager::Security8021xSetting::phase2ClientCertificate() const { Q_D(const Security8021xSetting); return d->phase2ClientCert; } void NetworkManager::Security8021xSetting::setPassword(const QString &password) { Q_D(Security8021xSetting); d->password = password; } QString NetworkManager::Security8021xSetting::password() const { Q_D(const Security8021xSetting); return d->password; } void NetworkManager::Security8021xSetting::setPasswordFlags(NetworkManager::Setting::SecretFlags flags) { Q_D(Security8021xSetting); d->passwordFlags = flags; } NetworkManager::Setting::SecretFlags NetworkManager::Security8021xSetting::passwordFlags() const { Q_D(const Security8021xSetting); return d->passwordFlags; } void NetworkManager::Security8021xSetting::setPasswordRaw(const QByteArray &password) { Q_D(Security8021xSetting); d->passwordRaw = password; } QByteArray NetworkManager::Security8021xSetting::passwordRaw() const { Q_D(const Security8021xSetting); return d->passwordRaw; } void NetworkManager::Security8021xSetting::setPasswordRawFlags(NetworkManager::Setting::SecretFlags flags) { Q_D(Security8021xSetting); d->passwordRawFlags = flags; } NetworkManager::Setting::SecretFlags NetworkManager::Security8021xSetting::passwordRawFlags() const { Q_D(const Security8021xSetting); return d->passwordRawFlags; } void NetworkManager::Security8021xSetting::setPrivateKey(const QByteArray &key) { Q_D(Security8021xSetting); d->privateKey = key; } QByteArray NetworkManager::Security8021xSetting::privateKey() const { Q_D(const Security8021xSetting); return d->privateKey; } void NetworkManager::Security8021xSetting::setPrivateKeyPassword(const QString &password) { Q_D(Security8021xSetting); d->privateKeyPassword = password; } QString NetworkManager::Security8021xSetting::privateKeyPassword() const { Q_D(const Security8021xSetting); return d->privateKeyPassword; } void NetworkManager::Security8021xSetting::setPrivateKeyPasswordFlags(NetworkManager::Setting::SecretFlags flags) { Q_D(Security8021xSetting); d->privateKeyPasswordFlags = flags; } NetworkManager::Setting::SecretFlags NetworkManager::Security8021xSetting::privateKeyPasswordFlags() const { Q_D(const Security8021xSetting); return d->privateKeyPasswordFlags; } void NetworkManager::Security8021xSetting::setPhase2PrivateKey(const QByteArray &key) { Q_D(Security8021xSetting); d->phase2PrivateKey = key; } QByteArray NetworkManager::Security8021xSetting::phase2PrivateKey() const { Q_D(const Security8021xSetting); return d->phase2PrivateKey; } void NetworkManager::Security8021xSetting::setPhase2PrivateKeyPassword(const QString &password) { Q_D(Security8021xSetting); d->phase2PrivateKeyPassword = password; } QString NetworkManager::Security8021xSetting::phase2PrivateKeyPassword() const { Q_D(const Security8021xSetting); return d->phase2PrivateKeyPassword; } void NetworkManager::Security8021xSetting::setPhase2PrivateKeyPasswordFlags(NetworkManager::Setting::SecretFlags flags) { Q_D(Security8021xSetting); d->phase2PrivateKeyPasswordFlags = flags; } NetworkManager::Setting::SecretFlags NetworkManager::Security8021xSetting::phase2PrivateKeyPasswordFlags() const { Q_D(const Security8021xSetting); return d->phase2PrivateKeyPasswordFlags; } void NetworkManager::Security8021xSetting::setSystemCaCertificates(bool use) { Q_D(Security8021xSetting); d->systemCaCerts = use; } void NetworkManager::Security8021xSetting::setPin(const QString &pin) { Q_D(Security8021xSetting); d->pin = pin; } QString NetworkManager::Security8021xSetting::pin() const { Q_D(const Security8021xSetting); return d->pin; } void NetworkManager::Security8021xSetting::setPinFlags(NetworkManager::Setting::SecretFlags flags) { Q_D(Security8021xSetting); d->pinFlags = flags; } NetworkManager::Setting::SecretFlags NetworkManager::Security8021xSetting::pinFlags() const { Q_D(const Security8021xSetting); return d->pinFlags; } bool NetworkManager::Security8021xSetting::systemCaCertificates() const { Q_D(const Security8021xSetting); return d->systemCaCerts; } QStringList NetworkManager::Security8021xSetting::needSecrets(bool requestNew) const { QStringList secrets; if (eapMethods().contains(EapMethodTls) && (privateKeyPassword().isEmpty() || requestNew) && !privateKeyPasswordFlags().testFlag(NotRequired)) { secrets << QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD); } else if ((eapMethods().contains(EapMethodTtls) || eapMethods().contains(EapMethodPeap) || eapMethods().contains(EapMethodLeap) || eapMethods().contains(EapMethodFast) || eapMethods().contains(EapMethodPwd)) && (password().isEmpty() || requestNew) && !passwordFlags().testFlag(NotRequired)) { secrets << QLatin1String(NM_SETTING_802_1X_PASSWORD); secrets << QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW); } else if (eapMethods().contains(EapMethodSim) && (pin().isEmpty() || requestNew) && !pinFlags().testFlag(NotRequired)) { secrets << QLatin1String(NM_SETTING_802_1X_PIN); } if ((phase2AuthMethod() == AuthMethodTls || phase2AuthEapMethod() == AuthEapMethodTls) && (phase2PrivateKeyPassword().isEmpty() || requestNew) && !phase2PrivateKeyPasswordFlags().testFlag(NotRequired)) { secrets << QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD); } return secrets; } void NetworkManager::Security8021xSetting::secretsFromMap(const QVariantMap &secrets) { if (secrets.contains(QLatin1String(NM_SETTING_802_1X_PASSWORD))) { setPassword(secrets.value(QLatin1String(NM_SETTING_802_1X_PASSWORD)).toString()); } if (secrets.contains(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW))) { setPasswordRaw(secrets.value(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW)).toByteArray()); } if (secrets.contains(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD))) { setPrivateKeyPassword(secrets.value(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD)).toString()); } if (secrets.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD))) { setPhase2PrivateKeyPassword(secrets.value(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD)).toString()); } if (secrets.contains(QLatin1String(NM_SETTING_802_1X_PIN))) { setPin(secrets.value(QLatin1String(NM_SETTING_802_1X_PIN)).toString()); } } QVariantMap NetworkManager::Security8021xSetting::secretsToMap() const { QVariantMap secrets; if (!password().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_802_1X_PASSWORD), password()); } if (!passwordRaw().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW), passwordRaw()); } if (!privateKeyPassword().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD), privateKeyPassword()); } if (!phase2PrivateKeyPassword().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD), phase2PrivateKeyPassword()); } if (!pin().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_802_1X_PIN), pin()); } return secrets; } void NetworkManager::Security8021xSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_802_1X_EAP))) { const QStringList methods = setting.value(QLatin1String(NM_SETTING_802_1X_EAP)).toStringList(); QList eapMethods; Q_FOREACH (const QString & method, methods) { if (method == "leap") { eapMethods << EapMethodLeap; } else if (method == "md5") { eapMethods << EapMethodMd5; } else if (method == "tls") { eapMethods << EapMethodTls; } else if (method == "peap") { eapMethods << EapMethodPeap; } else if (method == "ttls") { eapMethods << EapMethodTtls; } else if (method == "sim") { eapMethods << EapMethodSim; } else if (method == "fast") { eapMethods << EapMethodFast; } else if (method == "pwd") { eapMethods << EapMethodPwd; } } setEapMethods(eapMethods); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_IDENTITY))) { setIdentity(setting.value(QLatin1String(NM_SETTING_802_1X_IDENTITY)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_ANONYMOUS_IDENTITY))) { setAnonymousIdentity(setting.value(QLatin1String(NM_SETTING_802_1X_ANONYMOUS_IDENTITY)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH))) { setDomainSuffixMatch(setting.value(QLatin1String(NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PAC_FILE))) { setPacFile(setting.value(QLatin1String(NM_SETTING_802_1X_PAC_FILE)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_CA_CERT))) { setCaCertificate(setting.value(QLatin1String(NM_SETTING_802_1X_CA_CERT)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_CA_PATH))) { setCaPath(setting.value(QLatin1String(NM_SETTING_802_1X_CA_PATH)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_SUBJECT_MATCH))) { setSubjectMatch(setting.value(QLatin1String(NM_SETTING_802_1X_SUBJECT_MATCH)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_ALTSUBJECT_MATCHES))) { setAltSubjectMatches(setting.value(QLatin1String(NM_SETTING_802_1X_ALTSUBJECT_MATCHES)).toStringList()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_CLIENT_CERT))) { setClientCertificate(setting.value(QLatin1String(NM_SETTING_802_1X_CLIENT_CERT)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPVER))) { const QString version = setting.value(QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPVER)).toString(); if (version == "0") { setPhase1PeapVersion(PeapVersionZero); } else if (version == "1") { setPhase1PeapVersion(PeapVersionOne); } } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPLABEL))) { const QString label = setting.value(QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPLABEL)).toString(); if (label == "1") { setPhase1PeapLabel(PeapLabelForce); } } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING))) { const QString provisioning = setting.value(QLatin1String(NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING)).toString(); if (provisioning == "0") { setPhase1FastProvisioning(FastProvisioningDisabled); } else if (provisioning == "1") { setPhase1FastProvisioning(FastProvisioningAllowUnauthenticated); } else if (provisioning == "2") { setPhase1FastProvisioning(FastProvisioningAllowAuthenticated); } else if (provisioning == "3") { setPhase1FastProvisioning(FastProvisioningAllowBoth); } } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_AUTH))) { const QString authMethod = setting.value(QLatin1String(NM_SETTING_802_1X_PHASE2_AUTH)).toString(); if (authMethod == "pap") { setPhase2AuthMethod(AuthMethodPap); } else if (authMethod == "chap") { setPhase2AuthMethod(AuthMethodChap); } else if (authMethod == "mschap") { setPhase2AuthMethod(AuthMethodMschap); } else if (authMethod == "mschapv2") { setPhase2AuthMethod(AuthMethodMschapv2); } else if (authMethod == "gtc") { setPhase2AuthMethod(AuthMethodGtc); } else if (authMethod == "otp") { setPhase2AuthMethod(AuthMethodOtp); } else if (authMethod == "md5") { setPhase2AuthMethod(AuthMethodMd5); } else if (authMethod == "tls") { setPhase2AuthMethod(AuthMethodTls); } } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_AUTHEAP))) { const QString authEapMethod = setting.value(QLatin1String(NM_SETTING_802_1X_PHASE2_AUTHEAP)).toString(); if (authEapMethod == "md5") { setPhase2AuthEapMethod(AuthEapMethodMd5); } else if (authEapMethod == "mschapv2") { setPhase2AuthEapMethod(AuthEapMethodMschapv2); } else if (authEapMethod == "otp") { setPhase2AuthEapMethod(AuthEapMethodOtp); } else if (authEapMethod == "gtc") { setPhase2AuthEapMethod(AuthEapMethodGtc); } else if (authEapMethod == "tls") { setPhase2AuthEapMethod(AuthEapMethodTls); } } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_CA_CERT))) { setPhase2CaCertificate(setting.value(QLatin1String(NM_SETTING_802_1X_PHASE2_CA_CERT)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_CA_PATH))) { setPhase2CaPath(setting.value(QLatin1String(NM_SETTING_802_1X_PHASE2_CA_PATH)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH))) { setPhase2SubjectMatch(setting.value(QLatin1String(NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES))) { setPhase2AltSubjectMatches(setting.value(QLatin1String(NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES)).toStringList()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_CLIENT_CERT))) { setPhase2ClientCertificate(setting.value(QLatin1String(NM_SETTING_802_1X_PHASE2_CLIENT_CERT)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PASSWORD))) { setPassword(setting.value(QLatin1String(NM_SETTING_802_1X_PASSWORD)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PASSWORD_FLAGS))) { setPasswordFlags((Setting::SecretFlags)setting.value(QLatin1String(NM_SETTING_802_1X_PASSWORD_FLAGS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW))) { setPasswordRaw(setting.value(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW_FLAGS))) { setPasswordRawFlags((Setting::SecretFlags)setting.value(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW_FLAGS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY))) { setPrivateKey(setting.value(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD))) { setPrivateKeyPassword(setting.value(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS))) { setPrivateKeyPasswordFlags((Setting::SecretFlags)setting.value(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY))) { setPhase2PrivateKey(setting.value(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD))) { setPhase2PrivateKeyPassword(setting.value(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS))) { setPhase2PrivateKeyPasswordFlags((Setting::SecretFlags)setting.value(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PIN))) { setPin(setting.value(QLatin1String(NM_SETTING_802_1X_PIN)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_PIN_FLAGS))) { setPinFlags((Setting::SecretFlags)setting.value(QLatin1String(NM_SETTING_802_1X_PIN_FLAGS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_802_1X_SYSTEM_CA_CERTS))) { setSystemCaCertificates(setting.value(QLatin1String(NM_SETTING_802_1X_SYSTEM_CA_CERTS)).toBool()); } } QVariantMap NetworkManager::Security8021xSetting::toMap() const { QVariantMap setting; if (!eapMethods().isEmpty()) { QStringList methods; Q_FOREACH (const EapMethod & method, eapMethods()) { if (method == EapMethodLeap) { methods << "leap"; } else if (method == EapMethodMd5) { methods << "md5"; } else if (method == EapMethodTls) { methods << "tls"; } else if (method == EapMethodPeap) { methods << "peap"; } else if (method == EapMethodTtls) { methods << "ttls"; } else if (method == EapMethodSim) { methods << "sim"; } else if (method == EapMethodFast) { methods << "fast"; } else if (method == EapMethodPwd) { methods << "pwd"; } } setting.insert(QLatin1String(NM_SETTING_802_1X_EAP), methods); } if (!identity().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_IDENTITY), identity()); } if (!anonymousIdentity().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_ANONYMOUS_IDENTITY), anonymousIdentity()); } if (!domainSuffixMatch().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH), domainSuffixMatch()); } if (!pacFile().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PAC_FILE), pacFile()); } if (!caCertificate().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_CA_CERT), caCertificate()); } if (!caPath().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_CA_PATH), caPath()); } if (!subjectMatch().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_SUBJECT_MATCH), subjectMatch()); } if (!altSubjectMatches().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_ALTSUBJECT_MATCHES), altSubjectMatches()); } if (!clientCertificate().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_CLIENT_CERT), clientCertificate()); } QString version; switch (phase1PeapVersion()) { case PeapVersionZero: version = '0'; break; case PeapVersionOne: version = '1'; break; case PeapVersionUnknown: break; } if (!version.isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPVER), version); } QString peapLabel; switch (phase1PeapLabel()) { case PeapLabelForce: peapLabel = '1'; break; case PeapLabelUnknown: break; } if (!peapLabel.isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE1_PEAPLABEL), peapLabel); } QString provisioning; switch (phase1FastProvisioning()) { case FastProvisioningDisabled: provisioning = '0'; break; case FastProvisioningAllowUnauthenticated: provisioning = '1'; break; case FastProvisioningAllowAuthenticated: provisioning = '2'; break; case FastProvisioningAllowBoth: provisioning = '3'; break; case FastProvisioningUnknown: break; } if (!provisioning.isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING), provisioning); } QString authMethod; switch (phase2AuthMethod()) { case AuthMethodPap: authMethod = "pap"; break; case AuthMethodChap: authMethod = "chap"; break; case AuthMethodMschap: authMethod = "mschap"; break; case AuthMethodMschapv2: authMethod = "mschapv2"; break; case AuthMethodGtc: authMethod = "gtc"; break; case AuthMethodOtp: authMethod = "otp"; break; case AuthMethodMd5: authMethod = "md5"; break; case AuthMethodTls: authMethod = "tls"; break; case AuthMethodUnknown: break; } if (!authMethod.isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_AUTH), authMethod); } QString authEapMethod; switch (phase2AuthEapMethod()) { case AuthEapMethodMd5: authEapMethod = "md5"; break; case AuthEapMethodMschapv2: authEapMethod = "mschapv2"; break; case AuthEapMethodOtp: authEapMethod = "otp"; break; case AuthEapMethodGtc: authEapMethod = "gtc"; break; case AuthEapMethodTls: authEapMethod = "tls"; break; case AuthEapMethodUnknown: break; } if (!authEapMethod.isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_AUTHEAP), authEapMethod); } if (!phase2CaCertificate().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_CA_CERT), phase2CaCertificate()); } if (!phase2CaPath().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_CA_PATH), phase2CaPath()); } if (!phase2SubjectMatch().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH), phase2SubjectMatch()); } if (!phase2AltSubjectMatches().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES), phase2AltSubjectMatches()); } if (!phase2ClientCertificate().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_CLIENT_CERT), phase2ClientCertificate()); } if (!password().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PASSWORD), password()); } if (passwordFlags() != None) { setting.insert(QLatin1String(NM_SETTING_802_1X_PASSWORD_FLAGS), (int)passwordFlags()); } if (!passwordRaw().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW), passwordRaw()); } if (passwordRawFlags() != None) { setting.insert(QLatin1String(NM_SETTING_802_1X_PASSWORD_RAW_FLAGS), (int)passwordRawFlags()); } if (!privateKey().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY), privateKey()); } if (!privateKeyPassword().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD), privateKeyPassword()); } if (privateKeyPasswordFlags() != None) { setting.insert(QLatin1String(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS), (int)privateKeyPasswordFlags()); } if (!phase2PrivateKey().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY), phase2PrivateKey()); } if (!phase2PrivateKeyPassword().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD), phase2PrivateKeyPassword()); } if (phase2PrivateKeyPasswordFlags() != None) { setting.insert(QLatin1String(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS), (int)phase2PrivateKeyPasswordFlags()); } if (!pin().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_802_1X_PIN), pin()); } if (pinFlags() != None) { setting.insert(QLatin1String(NM_SETTING_802_1X_PIN_FLAGS), (int)pinFlags()); } if (systemCaCertificates()) { setting.insert(QLatin1String(NM_SETTING_802_1X_SYSTEM_CA_CERTS), systemCaCertificates()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::Security8021xSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_802_1X_EAP << ": " << setting.eapMethods() << '\n'; dbg.nospace() << NM_SETTING_802_1X_IDENTITY << ": " << setting.identity() << '\n'; dbg.nospace() << NM_SETTING_802_1X_ANONYMOUS_IDENTITY << ": " << setting.anonymousIdentity() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PAC_FILE << ": " << setting.pacFile() << '\n'; dbg.nospace() << NM_SETTING_802_1X_CA_CERT << ": " << setting.caCertificate() << '\n'; dbg.nospace() << NM_SETTING_802_1X_CA_PATH << ": " << setting.caPath() << '\n'; dbg.nospace() << NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH << ": " << setting.domainSuffixMatch() << '\n'; dbg.nospace() << NM_SETTING_802_1X_SUBJECT_MATCH << ": " << setting.subjectMatch() << '\n'; dbg.nospace() << NM_SETTING_802_1X_ALTSUBJECT_MATCHES << ": " << setting.altSubjectMatches() << '\n'; dbg.nospace() << NM_SETTING_802_1X_CLIENT_CERT << ": " << setting.clientCertificate() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE1_PEAPVER << ": " << setting.phase1PeapVersion() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE1_PEAPLABEL << ": " << setting.phase1PeapLabel() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING << ": " << setting.phase1FastProvisioning() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE2_AUTH << ": " << setting.phase2AuthMethod() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE2_AUTHEAP << ": " << setting.phase2AuthEapMethod() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE2_CA_CERT << ": " << setting.phase2CaCertificate() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE2_CA_PATH << ": " << setting.phase2CaPath() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH << ": " << setting.phase2SubjectMatch() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES << ": " << setting.phase2AltSubjectMatches() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE2_CLIENT_CERT << ": " << setting.phase2ClientCertificate() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PASSWORD << ": " << setting.password() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PASSWORD_FLAGS << ": " << setting.passwordFlags() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PASSWORD_RAW << ": " << setting.passwordRaw() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PASSWORD_RAW_FLAGS << ": " << setting.passwordRawFlags() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PRIVATE_KEY << ": " << setting.privateKey() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD << ": " << setting.privateKeyPassword() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS << ": " << setting.privateKeyPasswordFlags() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE2_PRIVATE_KEY << ": " << setting.phase2PrivateKey() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD << ": " << setting.phase2PrivateKeyPassword() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS << ": " << setting.phase2PrivateKeyPasswordFlags() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PIN << ": " << setting.pin() << '\n'; dbg.nospace() << NM_SETTING_802_1X_PIN_FLAGS << ": " << setting.pinFlags() << '\n'; dbg.nospace() << NM_SETTING_802_1X_SYSTEM_CA_CERTS << ": " << setting.systemCaCertificates() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/security8021xsetting.h b/src/settings/security8021xsetting.h index 44d9d3a..6845a93 100644 --- a/src/settings/security8021xsetting.h +++ b/src/settings/security8021xsetting.h @@ -1,211 +1,197 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SECURITY8021X_SETTING_H #define NETWORKMANAGERQT_SECURITY8021X_SETTING_H #include #include "setting.h" namespace NetworkManager { class Security8021xSettingPrivate; /** * Represents 802.1x wireless security setting */ class NETWORKMANAGERQT_EXPORT Security8021xSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum EapMethod {EapMethodUnknown = 0, EapMethodLeap, EapMethodMd5, EapMethodTls, EapMethodPeap, EapMethodTtls, EapMethodSim, EapMethodFast, EapMethodPwd}; enum PeapVersion {PeapVersionUnknown = -1, PeapVersionZero, PeapVersionOne}; enum PeapLabel {PeapLabelUnknown = 0, PeapLabelForce}; enum FastProvisioning {FastProvisioningUnknown = -1, FastProvisioningDisabled, FastProvisioningAllowUnauthenticated, FastProvisioningAllowAuthenticated, FastProvisioningAllowBoth}; enum AuthMethod {AuthMethodUnknown = 0, AuthMethodPap, AuthMethodChap, AuthMethodMschap, AuthMethodMschapv2, AuthMethodGtc, AuthMethodOtp, AuthMethodMd5, AuthMethodTls }; enum AuthEapMethod {AuthEapMethodUnknown = 0, AuthEapMethodMd5, AuthEapMethodMschapv2, AuthEapMethodOtp, AuthEapMethodGtc, AuthEapMethodTls }; Security8021xSetting(); explicit Security8021xSetting(const Ptr &other); ~Security8021xSetting() override; QString name() const override; void setEapMethods(const QList &methods); QList eapMethods() const; void setIdentity(const QString &identity); QString identity() const; void setAnonymousIdentity(const QString &identity); QString anonymousIdentity() const; void setDomainSuffixMatch(const QString &domainSuffixMatch); QString domainSuffixMatch() const; /** * Set UTF-8 encoded file path containing PAC for EAP-FAST. * * \param filePath file path to be set. */ void setPacFile(const QString &filePath); QString pacFile() const; /** * Set certificate authority (ca)'s certificate for this setting. * * \param certificate certificate's file path encoded into a byte array. * * \warning certificate have to be null terminated or NetworkManager will refuse it. */ void setCaCertificate(const QByteArray &certificate); QByteArray caCertificate() const; void setCaPath(const QString &path); QString caPath() const; void setSubjectMatch(const QString &substring); QString subjectMatch() const; void setAltSubjectMatches(const QStringList &strings); QStringList altSubjectMatches() const; /** * Set client certificate for this setting. * * \param certificate certificate's file path encoded into a byte array. * * \warning certificate have to be null terminated or NetworkManager will refuse it. */ void setClientCertificate(const QByteArray &certificate); QByteArray clientCertificate() const; void setPhase1PeapVersion(PeapVersion version); PeapVersion phase1PeapVersion() const; void setPhase1PeapLabel(PeapLabel label); PeapLabel phase1PeapLabel() const; void setPhase1FastProvisioning(FastProvisioning provisioning); FastProvisioning phase1FastProvisioning() const; void setPhase2AuthMethod(AuthMethod method); AuthMethod phase2AuthMethod() const; void setPhase2AuthEapMethod(AuthEapMethod method); AuthEapMethod phase2AuthEapMethod() const; /** * Contains the CA certificate if used by the EAP method specified in the * phase2AuthMethod() or phase2AuthEapMethod() properties. * * \param certificate certificate's file path encoded into a byte array. * * \warning certificate have to be null terminated or NetworkManager will refuse it. */ void setPhase2CaCertificate(const QByteArray &certificate); QByteArray phase2CaCertificate() const; void setPhase2CaPath(const QString &path); QString phase2CaPath() const; void setPhase2SubjectMatch(const QString &substring); QString phase2SubjectMatch() const; void setPhase2AltSubjectMatches(const QStringList &strings); QStringList phase2AltSubjectMatches() const; void setPhase2ClientCertificate(const QByteArray &certificate); QByteArray phase2ClientCertificate() const; void setPassword(const QString &password); QString password() const; void setPasswordFlags(Setting::SecretFlags flags); Setting::SecretFlags passwordFlags() const; void setPasswordRaw(const QByteArray &password); QByteArray passwordRaw() const; void setPasswordRawFlags(Setting::SecretFlags flags); Setting::SecretFlags passwordRawFlags() const; /** * Set private key for this setting. * * \param key the key to be set. * * \warning key have to be null terminated or NetworkManager will refuse it. */ void setPrivateKey(const QByteArray &key); QByteArray privateKey() const; void setPrivateKeyPassword(const QString &password); QString privateKeyPassword() const; void setPrivateKeyPasswordFlags(Setting::SecretFlags flags); Setting::SecretFlags privateKeyPasswordFlags() const; void setPhase2PrivateKey(const QByteArray &key); QByteArray phase2PrivateKey() const; void setPhase2PrivateKeyPassword(const QString &password); QString phase2PrivateKeyPassword() const; void setPhase2PrivateKeyPasswordFlags(Setting::SecretFlags flags); Setting::SecretFlags phase2PrivateKeyPasswordFlags() const; void setPin(const QString &pin); QString pin() const; void setPinFlags(Setting::SecretFlags flags); Setting::SecretFlags pinFlags() const; void setSystemCaCertificates(bool use); bool systemCaCertificates() const; QStringList needSecrets(bool requestNew = false) const override; void secretsFromMap(const QVariantMap &secrets) override; QVariantMap secretsToMap() const override; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: Security8021xSettingPrivate *const d_ptr; private: Q_DECLARE_PRIVATE(Security8021xSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Security8021xSetting &setting); } #endif // NETWORKMANAGERQT_SECURITY802X_SETTING_H diff --git a/src/settings/security8021xsetting_p.h b/src/settings/security8021xsetting_p.h index e90f188..0d4306e 100644 --- a/src/settings/security8021xsetting_p.h +++ b/src/settings/security8021xsetting_p.h @@ -1,72 +1,58 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SECURITY8021X_SETTING_P_H #define NETWORKMANAGERQT_SECURITY8021X_SETTING_P_H #include namespace NetworkManager { class Security8021xSettingPrivate { public: Security8021xSettingPrivate(); QString name; QList eap; QString identity; QString anonymousIdentity; QString domainSuffixMatch; QString pacFile; QByteArray caCert; QString caPath; QString subjectMatch; QStringList altSubjectMatches; QByteArray clientCert; Security8021xSetting::PeapVersion phase1PeapVer; Security8021xSetting::PeapLabel phase1PeapLabel; Security8021xSetting::FastProvisioning phase1FastProvisioning; Security8021xSetting::AuthMethod phase2AuthMethod; Security8021xSetting::AuthEapMethod phase2AuthEapMethod; QByteArray phase2CaCert; QString phase2CaPath; QString phase2SubjectMatch; QStringList phase2AltSubjectMatches; QByteArray phase2ClientCert; QString password; Setting::SecretFlags passwordFlags; QByteArray passwordRaw; Setting::SecretFlags passwordRawFlags; QByteArray privateKey; QString privateKeyPassword; Setting::SecretFlags privateKeyPasswordFlags; QByteArray phase2PrivateKey; QString phase2PrivateKeyPassword; Setting::SecretFlags phase2PrivateKeyPasswordFlags; QString pin; Setting::SecretFlags pinFlags; bool systemCaCerts; }; } #endif // NETWORKMANAGERQT_SECURITY802X_SETTING_P_H diff --git a/src/settings/serialsetting.cpp b/src/settings/serialsetting.cpp index a148ae5..4172c94 100644 --- a/src/settings/serialsetting.cpp +++ b/src/settings/serialsetting.cpp @@ -1,207 +1,193 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "serialsetting.h" #include "serialsetting_p.h" #include NetworkManager::SerialSettingPrivate::SerialSettingPrivate() : name(NM_SETTING_SERIAL_SETTING_NAME) , baud(57600) , bits(8) , parity(SerialSetting::NoParity) , stopbits(1) , sendDelay(0) { } NetworkManager::SerialSetting::SerialSetting() : Setting(Setting::Serial) , d_ptr(new SerialSettingPrivate()) { } NetworkManager::SerialSetting::SerialSetting(const Ptr &other) : Setting(other) , d_ptr(new SerialSettingPrivate()) { setBaud(other->baud()); setBits(other->bits()); setParity(other->parity()); setStopbits(other->stopbits()); setSendDelay(other->sendDelay()); } NetworkManager::SerialSetting::~SerialSetting() { delete d_ptr; } QString NetworkManager::SerialSetting::name() const { Q_D(const SerialSetting); return d->name; } void NetworkManager::SerialSetting::setBaud(quint32 speed) { Q_D(SerialSetting); d->baud = speed; } quint32 NetworkManager::SerialSetting::baud() const { Q_D(const SerialSetting); return d->baud; } void NetworkManager::SerialSetting::setBits(quint32 byteWidgh) { Q_D(SerialSetting); d->bits = byteWidgh; } quint32 NetworkManager::SerialSetting::bits() const { Q_D(const SerialSetting); return d->bits; } void NetworkManager::SerialSetting::setParity(NetworkManager::SerialSetting::Parity paritysetting) { Q_D(SerialSetting); d->parity = paritysetting; } NetworkManager::SerialSetting::Parity NetworkManager::SerialSetting::parity() const { Q_D(const SerialSetting); return d->parity; } void NetworkManager::SerialSetting::setStopbits(quint32 number) { Q_D(SerialSetting); d->stopbits = number; } quint32 NetworkManager::SerialSetting::stopbits() const { Q_D(const SerialSetting); return d->stopbits; } void NetworkManager::SerialSetting::setSendDelay(quint64 delay) { Q_D(SerialSetting); d->sendDelay = delay; } quint64 NetworkManager::SerialSetting::sendDelay() const { Q_D(const SerialSetting); return d->sendDelay; } void NetworkManager::SerialSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_SERIAL_BAUD))) { setBaud(setting.value(QLatin1String(NM_SETTING_SERIAL_BAUD)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_SERIAL_BITS))) { setBits(setting.value(QLatin1String(NM_SETTING_SERIAL_BITS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_SERIAL_PARITY))) { QChar character = setting.value(QLatin1String(NM_SETTING_SERIAL_PARITY)).toChar(); if (character == 'n') { setParity(NoParity); } else if (character == 'E') { setParity(EvenParity); } else if (character == 'o') { setParity(OddParity); } } if (setting.contains(QLatin1String(NM_SETTING_SERIAL_STOPBITS))) { setStopbits(setting.value(QLatin1String(NM_SETTING_SERIAL_STOPBITS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_SERIAL_SEND_DELAY))) { setSendDelay((Setting::SecretFlagType)setting.value(QLatin1String(NM_SETTING_SERIAL_SEND_DELAY)).toULongLong()); } } QVariantMap NetworkManager::SerialSetting::toMap() const { QVariantMap setting; if (baud() != 57600) { setting.insert(QLatin1String(NM_SETTING_SERIAL_BAUD), baud()); } if (bits() != 8) { setting.insert(QLatin1String(NM_SETTING_SERIAL_BITS), bits()); } if (parity() != NoParity) { if (parity() == EvenParity) { setting.insert(QLatin1String(NM_SETTING_SERIAL_PARITY), 'E'); } else if (parity() == OddParity) { setting.insert(QLatin1String(NM_SETTING_SERIAL_PARITY), 'o'); } } if (stopbits() != 1) { setting.insert(QLatin1String(NM_SETTING_SERIAL_STOPBITS), stopbits()); } if (sendDelay()) { setting.insert(QLatin1String(NM_SETTING_SERIAL_SEND_DELAY), sendDelay()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::SerialSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_SERIAL_BAUD << ": " << setting.baud() << '\n'; dbg.nospace() << NM_SETTING_SERIAL_BITS << ": " << setting.bits() << '\n'; dbg.nospace() << NM_SETTING_SERIAL_PARITY << ": " << setting.parity() << '\n'; dbg.nospace() << NM_SETTING_SERIAL_STOPBITS << ": " << setting.stopbits() << '\n'; dbg.nospace() << NM_SETTING_SERIAL_SEND_DELAY << ": " << setting.sendDelay() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/serialsetting.h b/src/settings/serialsetting.h index 8acdc92..5eaae80 100644 --- a/src/settings/serialsetting.h +++ b/src/settings/serialsetting.h @@ -1,80 +1,66 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SERIAL_SETTING_H #define NETWORKMANAGERQT_SERIAL_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class SerialSettingPrivate; /** * Represents serial setting */ class NETWORKMANAGERQT_EXPORT SerialSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum Parity {NoParity, EvenParity, OddParity}; SerialSetting(); explicit SerialSetting(const Ptr &other); ~SerialSetting() override; QString name() const override; void setBaud(quint32 speed); quint32 baud() const; void setBits(quint32 byteWidth); quint32 bits() const; void setParity(Parity paritysetting); Parity parity() const; void setStopbits(quint32 number); quint32 stopbits() const; void setSendDelay(quint64 delay); quint64 sendDelay() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: SerialSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(SerialSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const SerialSetting &setting); } #endif // NETWORKMANAGERQT_SERIAL_SETTING_H diff --git a/src/settings/serialsetting_p.h b/src/settings/serialsetting_p.h index 6b828ca..539b27b 100644 --- a/src/settings/serialsetting_p.h +++ b/src/settings/serialsetting_p.h @@ -1,44 +1,30 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SERIAL_SETTING_P_H #define NETWORKMANAGERQT_SERIAL_SETTING_P_H #include namespace NetworkManager { class SerialSettingPrivate { public: SerialSettingPrivate(); QString name; quint32 baud; quint32 bits; NetworkManager::SerialSetting::Parity parity; quint32 stopbits; quint64 sendDelay; }; } #endif // NETWORKMANAGERQT_SERIAL_SETTING_P_H diff --git a/src/settings/setting.cpp b/src/settings/setting.cpp index f6db0a5..a8bbb4f 100644 --- a/src/settings/setting.cpp +++ b/src/settings/setting.cpp @@ -1,372 +1,358 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "setting.h" #undef signals #include #include #define signals Q_SIGNALS #include #if !NM_CHECK_VERSION(1, 16, 0) #define NM_SETTING_WIREGUARD_SETTING_NAME "wireguard" #endif #if !NM_CHECK_VERSION(1, 14, 0) #define NM_SETTING_MATCH_SETTING_NAME "match" #endif #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_OVS_BRIDGE_SETTING_NAME "ovs-bridge" #define NM_SETTING_OVS_INTERFACE_SETTING_NAME "ovs-interface" #define NM_SETTING_OVS_PATCH_SETTING_NAME "ovs-patch" #define NM_SETTING_OVS_PORT_SETTING_NAME "ovs-port" #define NM_SETTING_TC_CONFIG_SETTING_NAME "tc" #define NM_SETTING_TEAM_PORT_SETTING_NAME "team-port" #endif #if !NM_CHECK_VERSION(1, 8, 0) #define NM_SETTING_USER_SETTING_NAME "user" #endif #if !NM_CHECK_VERSION(1, 6, 0) #define NM_SETTING_MACSEC_SETTING_NAME "macsec" #define NM_SETTING_PROXY_SETTING_NAME "proxy" #endif namespace NetworkManager { class SettingPrivate { public: SettingPrivate(); Setting::SettingType type; bool initialized; }; QDebug operator <<(QDebug dbg, const Setting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; return dbg.maybeSpace(); } } NetworkManager::SettingPrivate::SettingPrivate(): type(Setting::Wired), initialized(false) { } QString NetworkManager::Setting::typeAsString(NetworkManager::Setting::SettingType type) { QString typeString; switch (type) { case Cdma: typeString = QLatin1String(NM_SETTING_CDMA_SETTING_NAME); break; case Gsm: typeString = QLatin1String(NM_SETTING_GSM_SETTING_NAME); break; case Bluetooth: typeString = QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME); break; case Ipv4: typeString = QLatin1String(NM_SETTING_IP4_CONFIG_SETTING_NAME); break; case Ipv6: typeString = QLatin1String(NM_SETTING_IP6_CONFIG_SETTING_NAME); break; case Ppp: typeString = QLatin1String(NM_SETTING_PPP_SETTING_NAME); break; case Pppoe: typeString = QLatin1String(NM_SETTING_PPPOE_SETTING_NAME); break; case Security8021x: typeString = QLatin1String(NM_SETTING_802_1X_SETTING_NAME); break; case Serial: typeString = QLatin1String(NM_SETTING_SERIAL_SETTING_NAME); break; case Vpn: typeString = QLatin1String(NM_SETTING_VPN_SETTING_NAME); break; case Wired: typeString = QLatin1String(NM_SETTING_WIRED_SETTING_NAME); break; case Wireless: typeString = QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME); break; case WirelessSecurity: typeString = QLatin1String(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); break; case OlpcMesh: typeString = QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME); break; case Vlan: typeString = QLatin1String(NM_SETTING_VLAN_SETTING_NAME); break; case Wimax: typeString = QLatin1String(NM_SETTING_WIMAX_SETTING_NAME); break; case Bond: typeString = QLatin1String(NM_SETTING_BOND_SETTING_NAME); break; case Bridge: typeString = QLatin1String(NM_SETTING_BRIDGE_SETTING_NAME); break; case Team: typeString = QLatin1String(NM_SETTING_TEAM_SETTING_NAME); break; case Vxlan: typeString = QLatin1String(NM_SETTING_VXLAN_SETTING_NAME); break; case IpTunnel: typeString = QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME); break; case Proxy: typeString = QLatin1String(NM_SETTING_PROXY_SETTING_NAME); break; case User: typeString = QLatin1String(NM_SETTING_USER_SETTING_NAME); break; case OvsInterface: typeString = QLatin1String(NM_SETTING_OVS_INTERFACE_SETTING_NAME); break; case OvsBridge: typeString = QLatin1String(NM_SETTING_OVS_BRIDGE_SETTING_NAME); break; case OvsPatch: typeString = QLatin1String(NM_SETTING_OVS_PATCH_SETTING_NAME); break; case OvsPort: typeString = QLatin1String(NM_SETTING_OVS_PORT_SETTING_NAME); break; case Match: typeString = QLatin1String(NM_SETTING_MATCH_SETTING_NAME); break; case Tc: typeString = QLatin1String(NM_SETTING_TC_CONFIG_SETTING_NAME); break; case TeamPort: typeString = QLatin1String(NM_SETTING_TEAM_PORT_SETTING_NAME); break; case Macsec: typeString = QLatin1String(NM_SETTING_MACSEC_SETTING_NAME); break; case Dcb: typeString = QLatin1String(NM_SETTING_DCB_SETTING_NAME); break; case NetworkManager::Setting::WireGuard: typeString = QLatin1String(NM_SETTING_WIREGUARD_SETTING_NAME); break; case NetworkManager::Setting::Generic: typeString = QLatin1String(NM_SETTING_GENERIC_SETTING_NAME); break; default: break; } return typeString; } NetworkManager::Setting::SettingType NetworkManager::Setting::typeFromString(const QString &typeString) { SettingType type = Wired; if (typeString == QLatin1String(NM_SETTING_CDMA_SETTING_NAME)) { type = Cdma; } else if (typeString == QLatin1String(NM_SETTING_GSM_SETTING_NAME)) { type = Gsm; } else if (typeString == QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME)) { type = Bluetooth; } else if (typeString == QLatin1String(NM_SETTING_IP4_CONFIG_SETTING_NAME)) { type = Ipv4; } else if (typeString == QLatin1String(NM_SETTING_IP6_CONFIG_SETTING_NAME)) { type = Ipv6; } else if (typeString == QLatin1String(NM_SETTING_PPP_SETTING_NAME)) { type = Ppp; } else if (typeString == QLatin1String(NM_SETTING_PPPOE_SETTING_NAME)) { type = Pppoe; } else if (typeString == QLatin1String(NM_SETTING_SERIAL_SETTING_NAME)) { type = Serial; } else if (typeString == QLatin1String(NM_SETTING_802_1X_SETTING_NAME)) { type = Security8021x; } else if (typeString == QLatin1String(NM_SETTING_VPN_SETTING_NAME)) { type = Vpn; } else if (typeString == QLatin1String(NM_SETTING_WIRED_SETTING_NAME)) { type = Wired; } else if (typeString == QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME)) { type = Wireless; } else if (typeString == QLatin1String(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME)) { type = WirelessSecurity; } else if (typeString == QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME)) { type = OlpcMesh; } else if (typeString == QLatin1String(NM_SETTING_VLAN_SETTING_NAME)) { type = Vlan; } else if (typeString == QLatin1String(NM_SETTING_WIMAX_SETTING_NAME)) { type = Wimax; } else if (typeString == QLatin1String(NM_SETTING_BOND_SETTING_NAME)) { type = Bond; } else if (typeString == QLatin1String(NM_SETTING_BRIDGE_SETTING_NAME)) { type = Bridge; } else if (typeString == QLatin1String(NM_SETTING_TEAM_SETTING_NAME)) { type = Team; } else if (typeString == QLatin1String(NM_SETTING_VXLAN_SETTING_NAME)) { type = Vxlan; } else if (typeString == QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME)) { type = IpTunnel; } else if (typeString == QLatin1String(NM_SETTING_GENERIC_SETTING_NAME)) { type = Generic; } else if (typeString == QLatin1String(NM_SETTING_USER_SETTING_NAME)) { type = User; } else if (typeString == QLatin1String(NM_SETTING_PROXY_SETTING_NAME)) { type = Proxy; } else if (typeString == QLatin1String(NM_SETTING_OVS_INTERFACE_SETTING_NAME)) { type = OvsInterface; } else if (typeString == QLatin1String(NM_SETTING_OVS_BRIDGE_SETTING_NAME)) { type = OvsBridge; } else if (typeString == QLatin1String(NM_SETTING_OVS_PATCH_SETTING_NAME)) { type = OvsPatch; } else if (typeString == QLatin1String(NM_SETTING_OVS_PORT_SETTING_NAME)) { type = OvsPort; } else if (typeString == QLatin1String(NM_SETTING_MATCH_SETTING_NAME)) { type = Match; } else if (typeString == QLatin1String(NM_SETTING_TC_CONFIG_SETTING_NAME)) { type = Tc; } else if (typeString == QLatin1String(NM_SETTING_TEAM_PORT_SETTING_NAME)) { type = TeamPort; } else if (typeString == QLatin1String(NM_SETTING_MACSEC_SETTING_NAME)) { type = Macsec; } else if (typeString == QLatin1String(NM_SETTING_DCB_SETTING_NAME)) { type = Dcb; } else if (typeString == QLatin1String(NM_SETTING_WIREGUARD_SETTING_NAME)) { type = WireGuard; } return type; } NetworkManager::Setting::Setting(SettingType type) : d_ptr(new SettingPrivate()) { setType(type); } NetworkManager::Setting::Setting(const NetworkManager::Setting::Ptr &setting) : d_ptr(new SettingPrivate()) { setInitialized(!setting->isNull()); setType(setting->type()); } NetworkManager::Setting::~Setting() { delete d_ptr; } void NetworkManager::Setting::fromMap(const QVariantMap &map) { Q_UNUSED(map); } QVariantMap NetworkManager::Setting::toMap() const { return QVariantMap(); } QStringList NetworkManager::Setting::needSecrets(bool requestNew) const { Q_UNUSED(requestNew); return QStringList(); } QString NetworkManager::Setting::name() const { return QString(); } void NetworkManager::Setting::secretsFromMap(const QVariantMap &map) { Q_UNUSED(map); } void NetworkManager::Setting::secretsFromStringMap(const NMStringMap &map) { QVariantMap secretsMap; NMStringMap::ConstIterator i = map.constBegin(); while (i != map.constEnd()) { secretsMap.insert(i.key(), i.value()); ++i; } secretsFromMap(secretsMap); } QVariantMap NetworkManager::Setting::secretsToMap() const { return QVariantMap(); } NMStringMap NetworkManager::Setting::secretsToStringMap() const { NMStringMap ret; QVariantMap secretsMap = secretsToMap(); QVariantMap::ConstIterator i = secretsMap.constBegin(); while (i != secretsMap.constEnd()) { ret.insert(i.key(), i.value().toString()); ++i; } return ret; } void NetworkManager::Setting::setInitialized(bool initialized) { Q_D(Setting); d->initialized = initialized; } bool NetworkManager::Setting::isNull() const { Q_D(const Setting); return !d->initialized; } void NetworkManager::Setting::setType(NetworkManager::Setting::SettingType type) { Q_D(Setting); d->type = type; } NetworkManager::Setting::SettingType NetworkManager::Setting::type() const { Q_D(const Setting); return d->type; } diff --git a/src/settings/setting.h b/src/settings/setting.h index 7bfff29..6423ea7 100644 --- a/src/settings/setting.h +++ b/src/settings/setting.h @@ -1,165 +1,151 @@ /* - Copyright 2012-2019 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2019 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SETTING_H #define NETWORKMANAGERQT_SETTING_H #include #include "generictypes.h" #undef signals #include #define signals Q_SIGNALS #include #include #include namespace NetworkManager { class SettingPrivate; /** * Base class for all kinds of setting */ class NETWORKMANAGERQT_EXPORT Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum SettingType { Adsl, Cdma, Gsm, Infiniband, Ipv4, Ipv6, Ppp, Pppoe, Security8021x, Serial, Vpn, Wired, Wireless, WirelessSecurity, Bluetooth, OlpcMesh, Vlan, Wimax, Bond, Bridge, BridgePort, Team, Generic, Tun, Vxlan, IpTunnel, Proxy, User, OvsBridge, OvsInterface, OvsPatch, OvsPort, Match, Tc, TeamPort, Macsec, Dcb, WireGuard }; enum SecretFlagType { None = 0, AgentOwned = 0x01, NotSaved = 0x02, NotRequired = 0x04 }; Q_DECLARE_FLAGS(SecretFlags, SecretFlagType) enum MacAddressRandomization { MacAddressRandomizationDefault = 0, MacAddressRandomizationNever, MacAddressRandomizationAlways }; static QString typeAsString(SettingType type); static SettingType typeFromString(const QString &type); explicit Setting(SettingType type); explicit Setting(const Ptr &setting); virtual ~Setting(); /** * @brief Must be reimplemented, default implementation does nothing */ virtual void fromMap(const QVariantMap &map); /** * @brief Must be reimplemented, default implementationd does nothing */ virtual QVariantMap toMap() const; virtual void secretsFromMap(const QVariantMap &map); /** * @brief secretsFromStringMap is a convenience function * to set the secrets from a map of strings. * @param map to extract secrets from */ virtual void secretsFromStringMap(const NMStringMap &map); virtual QVariantMap secretsToMap() const; /** * @brief secretsToStringMap is a convenience function * to get the secrets to map of strings. * @return string map with current secrets */ virtual NMStringMap secretsToStringMap() const; virtual QStringList needSecrets(bool requestNew = false) const; /** * @brief Must be reimplemented, default implementationd does nothing */ virtual QString name() const; void setInitialized(bool initialized); bool isNull() const; void setType(SettingType type); SettingType type() const; protected: SettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(Setting) }; Q_DECLARE_OPERATORS_FOR_FLAGS(Setting::SecretFlags) NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Setting &setting); } #endif // NETWORKMANAGERQT_SETTING_H diff --git a/src/settings/tcsetting.cpp b/src/settings/tcsetting.cpp index 56aa49d..a1ad84e 100644 --- a/src/settings/tcsetting.cpp +++ b/src/settings/tcsetting.cpp @@ -1,138 +1,124 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "tcsetting.h" #include "tcsetting_p.h" #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_TC_CONFIG_SETTING_NAME "tc" #define NM_SETTING_TC_CONFIG_QDISCS "qdiscs" #define NM_SETTING_TC_CONFIG_TFILTERS "tfilters" #endif NetworkManager::TcSettingPrivate::TcSettingPrivate() : name(NM_SETTING_TC_CONFIG_SETTING_NAME) { } NetworkManager::TcSetting::TcSetting() : Setting(Setting::Tc) , d_ptr(new TcSettingPrivate()) { } NetworkManager::TcSetting::TcSetting(const Ptr &other) : Setting(other) , d_ptr(new TcSettingPrivate()) { setQdiscs(other->qdiscs()); setTfilters(other->tfilters()); } NetworkManager::TcSetting::~TcSetting() { delete d_ptr; } QString NetworkManager::TcSetting::name() const { Q_D(const TcSetting); return d->name; } void NetworkManager::TcSetting::setQdiscs(const NMVariantMapList &qdiscs) { Q_D(TcSetting); d->qdiscs = qdiscs; } NMVariantMapList NetworkManager::TcSetting::qdiscs() const { Q_D(const TcSetting); return d->qdiscs; } void NetworkManager::TcSetting::setTfilters(const NMVariantMapList &tfilters) { Q_D(TcSetting); d->tfilters = tfilters; } NMVariantMapList NetworkManager::TcSetting::tfilters() const { Q_D(const TcSetting); return d->tfilters; } void NetworkManager::TcSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_TC_CONFIG_QDISCS))) { setQdiscs(qdbus_cast(setting.value(QLatin1String(NM_SETTING_TC_CONFIG_QDISCS)))); } if (setting.contains(QLatin1String(NM_SETTING_TC_CONFIG_TFILTERS))) { setTfilters(qdbus_cast(setting.value(QLatin1String(NM_SETTING_TC_CONFIG_TFILTERS)))); } } QVariantMap NetworkManager::TcSetting::toMap() const { QVariantMap setting; if (!qdiscs().empty()) { setting.insert(QLatin1String(NM_SETTING_TC_CONFIG_QDISCS), QVariant::fromValue(qdiscs())); } if (!tfilters().empty()) { setting.insert(QLatin1String(NM_SETTING_TC_CONFIG_TFILTERS), QVariant::fromValue(tfilters())); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::TcSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_TC_CONFIG_QDISCS << ": " << '\n'; Q_FOREACH (const QVariantMap & qdisc, setting.qdiscs()) { QVariantMap::const_iterator i = qdisc.constBegin(); while (i != qdisc.constEnd()) { dbg.nospace() << i.key() << ": " << i.value() << '\n'; } } dbg.nospace() << NM_SETTING_TC_CONFIG_TFILTERS << ": " << '\n'; Q_FOREACH (const QVariantMap & tfilter, setting.tfilters()) { QVariantMap::const_iterator i = tfilter.constBegin(); while (i != tfilter.constEnd()) { dbg.nospace() << i.key() << ": " << i.value() << '\n'; } } return dbg.maybeSpace(); } diff --git a/src/settings/tcsetting.h b/src/settings/tcsetting.h index 3c810ac..ca2730a 100644 --- a/src/settings/tcsetting.h +++ b/src/settings/tcsetting.h @@ -1,69 +1,55 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TC_SETTING_H #define NETWORKMANAGERQT_TC_SETTING_H #include #include "setting.h" namespace NetworkManager { class TcSettingPrivate; /** * Represents Tc setting */ class NETWORKMANAGERQT_EXPORT TcSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; TcSetting(); explicit TcSetting(const Ptr &other); ~TcSetting() override; QString name() const override; void setQdiscs(const NMVariantMapList &qdiscs); NMVariantMapList qdiscs() const; void setTfilters(const NMVariantMapList &tfilters); NMVariantMapList tfilters() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: TcSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(TcSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const TcSetting &setting); } #endif // NETWORKMANAGERQT_TC_SETTING_H diff --git a/src/settings/tcsetting_p.h b/src/settings/tcsetting_p.h index 454ffd5..8710bc7 100644 --- a/src/settings/tcsetting_p.h +++ b/src/settings/tcsetting_p.h @@ -1,47 +1,33 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TC_SETTING_P_H #define NETWORKMANAGERQT_TC_SETTING_P_H #include #include typedef QList NMVariantMapList; namespace NetworkManager { class TcSettingPrivate { public: TcSettingPrivate(); QString name; NMVariantMapList qdiscs; NMVariantMapList tfilters; }; } #endif // NETWORKMANAGERQT_TC_SETTING_P_H diff --git a/src/settings/teamportsetting.cpp b/src/settings/teamportsetting.cpp index 3a2e985..b6605da 100644 --- a/src/settings/teamportsetting.cpp +++ b/src/settings/teamportsetting.cpp @@ -1,263 +1,249 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "teamportsetting.h" #include "teamportsetting_p.h" #include #if !NM_CHECK_VERSION(1, 10, 0) #define NM_SETTING_TEAM_PORT_SETTING_NAME "team-port" #define NM_SETTING_TEAM_PORT_CONFIG "config" #define NM_SETTING_TEAM_PORT_QUEUE_ID "queue-id" #define NM_SETTING_TEAM_PORT_PRIO "prio" #define NM_SETTING_TEAM_PORT_STICKY "sticky" #define NM_SETTING_TEAM_PORT_LACP_PRIO "lacp-prio" #define NM_SETTING_TEAM_PORT_LACP_KEY "lacp-key" #define NM_SETTING_TEAM_PORT_LINK_WATCHERS "link-watchers" #endif NetworkManager::TeamPortSettingPrivate::TeamPortSettingPrivate() : name(NM_SETTING_TEAM_PORT_SETTING_NAME) , lacpKey(0) , lacpPrio(255) , prio(0) , queueId(-1) , sticky(false) { } NetworkManager::TeamPortSetting::TeamPortSetting() : Setting(Setting::TeamPort) , d_ptr(new TeamPortSettingPrivate()) { } NetworkManager::TeamPortSetting::TeamPortSetting(const Ptr &other) : Setting(other) , d_ptr(new TeamPortSettingPrivate()) { config(other->config()); lacpKey(other->lacpKey()); lacpPrio(other->lacpPrio()); prio(other->prio()); queueId(other->queueId()); sticky(other->sticky()); setLinkWatchers(other->linkWatchers()); } NetworkManager::TeamPortSetting::~TeamPortSetting() { delete d_ptr; } QString NetworkManager::TeamPortSetting::name() const { Q_D(const TeamPortSetting); return d->name; } void NetworkManager::TeamPortSetting::config(const QString &config) { Q_D(TeamPortSetting); d->config = config; } QString NetworkManager::TeamPortSetting::config() const { Q_D(const TeamPortSetting); return d->config; } void NetworkManager::TeamPortSetting::lacpKey(qint32 key) { Q_D(TeamPortSetting); d->lacpKey = key; } qint32 NetworkManager::TeamPortSetting::lacpKey() const { Q_D(const TeamPortSetting); return d->lacpKey; } void NetworkManager::TeamPortSetting::lacpPrio(qint32 priority) { Q_D(TeamPortSetting); d->lacpPrio = priority; } qint32 NetworkManager::TeamPortSetting::lacpPrio() const { Q_D(const TeamPortSetting); return d->lacpPrio; } void NetworkManager::TeamPortSetting::prio(qint32 prio) { Q_D(TeamPortSetting); d->prio = prio; } qint32 NetworkManager::TeamPortSetting::prio() const { Q_D(const TeamPortSetting); return d->prio; } void NetworkManager::TeamPortSetting::queueId(qint32 id) { Q_D(TeamPortSetting); d->queueId = id; } qint32 NetworkManager::TeamPortSetting::queueId() const { Q_D(const TeamPortSetting); return d->queueId; } void NetworkManager::TeamPortSetting::sticky(bool sticky) { Q_D(TeamPortSetting); d->sticky = sticky; } bool NetworkManager::TeamPortSetting::sticky() const { Q_D(const TeamPortSetting); return d->sticky; } void NetworkManager::TeamPortSetting::setLinkWatchers(const NMVariantMapList &linkWatchers) { Q_D(TeamPortSetting); d->linkWatchers = linkWatchers; } NMVariantMapList NetworkManager::TeamPortSetting::linkWatchers() const { Q_D(const TeamPortSetting); return d->linkWatchers; } void NetworkManager::TeamPortSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_TEAM_PORT_CONFIG))) { config(setting.value(QLatin1String(NM_SETTING_TEAM_PORT_CONFIG)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_TEAM_PORT_LACP_KEY))) { lacpKey(setting.value(QLatin1String(NM_SETTING_TEAM_PORT_LACP_KEY)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_TEAM_PORT_LACP_PRIO))) { lacpPrio(setting.value(QLatin1String(NM_SETTING_TEAM_PORT_LACP_PRIO)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_TEAM_PORT_PRIO))) { prio(setting.value(QLatin1String(NM_SETTING_TEAM_PORT_PRIO)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_TEAM_PORT_QUEUE_ID))) { queueId(setting.value(QLatin1String(NM_SETTING_TEAM_PORT_QUEUE_ID)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_TEAM_PORT_STICKY))) { sticky(setting.value(QLatin1String(NM_SETTING_TEAM_PORT_STICKY)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_TEAM_PORT_LINK_WATCHERS))) { setLinkWatchers(qdbus_cast(setting.value(QLatin1String(NM_SETTING_TEAM_PORT_LINK_WATCHERS)))); } } QVariantMap NetworkManager::TeamPortSetting::toMap() const { QVariantMap setting; if (!config().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_TEAM_PORT_CONFIG), config()); } if (lacpKey() != 0) { setting.insert(QLatin1String(NM_SETTING_TEAM_PORT_LACP_KEY), lacpKey()); } if (lacpPrio() != 255) { setting.insert(QLatin1String(NM_SETTING_TEAM_PORT_LACP_PRIO), lacpPrio()); } if (prio() != 0) { setting.insert(QLatin1String(NM_SETTING_TEAM_PORT_PRIO), prio()); } if (queueId() != -1) { setting.insert(QLatin1String(NM_SETTING_TEAM_PORT_QUEUE_ID), queueId()); } if (sticky()) { setting.insert(QLatin1String(NM_SETTING_TEAM_PORT_STICKY), sticky()); } if (!linkWatchers().empty()) { setting.insert(QLatin1String(NM_SETTING_TEAM_PORT_LINK_WATCHERS), QVariant::fromValue(linkWatchers())); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::TeamPortSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_TEAM_PORT_CONFIG << ": " << setting.config() << '\n'; dbg.nospace() << NM_SETTING_TEAM_PORT_LACP_KEY << ": " << setting.lacpKey() << '\n'; dbg.nospace() << NM_SETTING_TEAM_PORT_LACP_PRIO << ": " << setting.lacpPrio() << '\n'; dbg.nospace() << NM_SETTING_TEAM_PORT_PRIO << ": " << setting.prio() << '\n'; dbg.nospace() << NM_SETTING_TEAM_PORT_QUEUE_ID << ": " << setting.queueId() << '\n'; dbg.nospace() << NM_SETTING_TEAM_PORT_STICKY << ": " << setting.sticky() << '\n'; dbg.nospace() << NM_SETTING_TEAM_PORT_LINK_WATCHERS << ": " << '\n'; Q_FOREACH (const QVariantMap & linkWatcher, setting.linkWatchers()) { QVariantMap::const_iterator i = linkWatcher.constBegin(); while (i != linkWatcher.constEnd()) { dbg.nospace() << i.key() << ": " << i.value() << '\n'; } } return dbg.maybeSpace(); } diff --git a/src/settings/teamportsetting.h b/src/settings/teamportsetting.h index b15c6b2..76de8f1 100644 --- a/src/settings/teamportsetting.h +++ b/src/settings/teamportsetting.h @@ -1,86 +1,72 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TEAM_PORT_SETTING_H #define NETWORKMANAGERQT_TEAM_PORT_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class TeamPortSettingPrivate; /** * Represents TeamPort setting */ class NETWORKMANAGERQT_EXPORT TeamPortSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; TeamPortSetting(); explicit TeamPortSetting(const Ptr &other); ~TeamPortSetting() override; QString name() const override; void config(const QString &config); QString config() const; void lacpKey(qint32 key); qint32 lacpKey() const; void lacpPrio(qint32 priority); qint32 lacpPrio() const; void prio(qint32 prio); qint32 prio() const; void queueId(qint32 id); qint32 queueId() const; void sticky(bool sticky); bool sticky() const; void setLinkWatchers(const NMVariantMapList &linkWatchers); NMVariantMapList linkWatchers() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: TeamPortSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(TeamPortSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const TeamPortSetting &setting); } #endif // NETWORKMANAGERQT_TEAM_PORT_SETTING_H diff --git a/src/settings/teamportsetting_p.h b/src/settings/teamportsetting_p.h index d07693a..311fb1e 100644 --- a/src/settings/teamportsetting_p.h +++ b/src/settings/teamportsetting_p.h @@ -1,50 +1,36 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TEAM_PORT_SETTING_P_H #define NETWORKMANAGERQT_TEAM_PORT_SETTING_P_H #include typedef QList NMVariantMapList; namespace NetworkManager { class TeamPortSettingPrivate { public: TeamPortSettingPrivate(); QString name; QString config; qint32 lacpKey; qint32 lacpPrio; qint32 prio; qint32 queueId; bool sticky; NMVariantMapList linkWatchers; }; } #endif // NETWORKMANAGERQT_TEAM_PORT_SETTING_P_H diff --git a/src/settings/teamsetting.cpp b/src/settings/teamsetting.cpp index 0253bdf..7c6af41 100644 --- a/src/settings/teamsetting.cpp +++ b/src/settings/teamsetting.cpp @@ -1,118 +1,104 @@ /* - Copyright 2014 Lukáš Tinkl - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Lukáš Tinkl + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "teamsetting.h" #include "teamsetting_p.h" #include "manager.h" #define NM_SETTING_TEAM_INTERFACE_NAME "interface-name" #include NetworkManager::TeamSettingPrivate::TeamSettingPrivate() : name(NM_SETTING_TEAM_SETTING_NAME) { } NetworkManager::TeamSetting::TeamSetting() : Setting(Setting::Team) , d_ptr(new TeamSettingPrivate()) { } NetworkManager::TeamSetting::TeamSetting(const Ptr &other) : Setting(other) , d_ptr(new TeamSettingPrivate()) { setInterfaceName(other->interfaceName()); setConfig(other->config()); } NetworkManager::TeamSetting::~TeamSetting() { delete d_ptr; } QString NetworkManager::TeamSetting::name() const { Q_D(const TeamSetting); return d->name; } void NetworkManager::TeamSetting::setInterfaceName(const QString &name) { Q_D(TeamSetting); d->interfaceName = name; } QString NetworkManager::TeamSetting::interfaceName() const { Q_D(const TeamSetting); return d->interfaceName; } QString NetworkManager::TeamSetting::config() const { Q_D(const TeamSetting); return d->config; } void NetworkManager::TeamSetting::setConfig(const QString &config) { Q_D(TeamSetting); d->config = config; } void NetworkManager::TeamSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_TEAM_INTERFACE_NAME))) { setInterfaceName(setting.value(QLatin1String(NM_SETTING_TEAM_INTERFACE_NAME)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_TEAM_CONFIG))) { setConfig(setting.value(QLatin1String(NM_SETTING_TEAM_CONFIG)).toString()); } } QVariantMap NetworkManager::TeamSetting::toMap() const { QVariantMap setting; if (!interfaceName().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_TEAM_INTERFACE_NAME), interfaceName()); } if (!config().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_TEAM_CONFIG), config()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::TeamSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_TEAM_INTERFACE_NAME << ": " << setting.interfaceName() << '\n'; dbg.nospace() << NM_SETTING_TEAM_CONFIG << ": " << setting.config() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/teamsetting.h b/src/settings/teamsetting.h index 7b4c6cf..1582e1a 100644 --- a/src/settings/teamsetting.h +++ b/src/settings/teamsetting.h @@ -1,70 +1,56 @@ /* - Copyright 2014 Lukáš Tinkl - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Lukáš Tinkl + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TEAM_SETTING_H #define NETWORKMANAGERQT_TEAM_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class TeamSettingPrivate; /** * Represents team setting */ class NETWORKMANAGERQT_EXPORT TeamSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; TeamSetting(); explicit TeamSetting(const Ptr &other); ~TeamSetting() override; QString name() const override; /// @deprecated in favor of connection.interface-name in NM 1.0.0 void setInterfaceName(const QString &name); QString interfaceName() const; QString config() const; void setConfig(const QString &config); void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: TeamSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(TeamSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const TeamSetting &setting); } #endif // NETWORKMANAGERQT_TEAM_SETTING_H diff --git a/src/settings/teamsetting_p.h b/src/settings/teamsetting_p.h index 3024b35..29ea8d1 100644 --- a/src/settings/teamsetting_p.h +++ b/src/settings/teamsetting_p.h @@ -1,41 +1,27 @@ /* - Copyright 2014 Lukáš Tinkl - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Lukáš Tinkl + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TEAM_SETTING_P_H #define NETWORKMANAGERQT_TEAM_SETTING_P_H #include namespace NetworkManager { class TeamSettingPrivate { public: TeamSettingPrivate(); QString name; QString interfaceName; QString config; }; } #endif // NETWORKMANAGERQT_TEAM_SETTING_P_H diff --git a/src/settings/template.cpp b/src/settings/template.cpp index 8f23e1c..9875000 100644 --- a/src/settings/template.cpp +++ b/src/settings/template.cpp @@ -1,91 +1,77 @@ /* - Copyright 2012-2015 Jan Grulich + SPDX-FileCopyrightText: 2012-2015 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "template.h" #include "template_p.h" // TODO: Uncomment and replace the template with the setting that you want to implement //#include NetworkManager::TemplateSettingPrivate::TemplateSettingPrivate() // : name(NM_SETTING_TEMPLATE_SETTING_NAME) { } NetworkManager::TemplateSetting::TemplateSetting(): /* TODO: Uncomment and replace the template with the setting that you want to implement * This setting must also be added into the enum in base class */ //Setting(Setting::Template), d_ptr(new TemplateSettingPrivate()) { } NetworkManager::TemplateSetting::TemplateSetting(const Ptr &other) : Setting(other) , d_ptr(new TemplateSettingPrivate()) { /* * setFoo(setting->foo()); * */ } NetworkManager::TemplateSetting::~TemplateSetting() { delete d_ptr; } QString NetworkManager::TemplateSetting::name() const { Q_D(const TemplateSetting); return d->name; } void NetworkManager::TemplateSetting::fromMap(const QVariantMap &setting) { /* * if (setting.contains(QLatin1String(NM_SETTING_TEMPLATE_FOO))) { * setFoo(setting.value(QLatin1String(NM_SETTING_TEMPLATE_FOO))); * } * */ } QVariantMap NetworkManager::TemplateSetting::toMap() const { QVariantMap setting; /* * if (!foo.isEmpty()) { * setting.insert(QLatin1String(NM_SETTING_TEMPLATE_FOO), foo()); * } * */ return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::TemplateSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/template.h b/src/settings/template.h index 761aea0..3de618f 100644 --- a/src/settings/template.h +++ b/src/settings/template.h @@ -1,63 +1,49 @@ /* - Copyright 2012-2015 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2015 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TEMPLATE_SETTING_H #define NETWORKMANAGERQT_TEMPLATE_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class TemplateSettingPrivate; /** * Represents generic setting */ class NETWORKMANAGERQT_EXPORT TemplateSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; TemplateSetting(); explicit TemplateSetting(const Ptr &other); ~TemplateSetting() override; QString name() const override; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: TemplateSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(TemplateSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const TemplateSetting &setting); } #endif // NETWORKMANAGERQT_TEMPLATE_SETTING_H diff --git a/src/settings/template_p.h b/src/settings/template_p.h index 666c2d7..00384fb 100644 --- a/src/settings/template_p.h +++ b/src/settings/template_p.h @@ -1,39 +1,25 @@ /* - Copyright 2012-2015 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2015 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TEMPLATE_SETTING_P_H #define NETWORKMANAGERQT_TEMPLATE_SETTING_P_H #include namespace NetworkManager { class TemplateSettingPrivate { public: TemplateSettingPrivate(); QString name; }; } #endif // NETWORKMANAGERQT_TEMPLATE_SETTING_P_H diff --git a/src/settings/tunsetting.cpp b/src/settings/tunsetting.cpp index fb04868..39e3fb3 100644 --- a/src/settings/tunsetting.cpp +++ b/src/settings/tunsetting.cpp @@ -1,209 +1,195 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "tunsetting.h" #include "tunsetting_p.h" #include NetworkManager::TunSettingPrivate::TunSettingPrivate() : name(NM_SETTING_TUN_SETTING_NAME) , mode(TunSetting::Tun) , multiQueue(false) , pi(false) , vnetHdr(false) { } NetworkManager::TunSetting::TunSetting() : Setting(Setting::Tun) , d_ptr(new TunSettingPrivate()) { } NetworkManager::TunSetting::TunSetting(const Ptr &other) : Setting(other) , d_ptr(new TunSettingPrivate()) { setGroup(other->group()); setMode(other->mode()); setMultiQueue(other->multiQueue()); setOwner(other->owner()); setPi(other->pi()); setVnetHdr(other->vnetHdr()); } NetworkManager::TunSetting::~TunSetting() { delete d_ptr; } QString NetworkManager::TunSetting::name() const { Q_D(const TunSetting); return d->name; } void NetworkManager::TunSetting::setGroup(const QString& group) { Q_D(TunSetting); d->group = group; } QString NetworkManager::TunSetting::group() const { Q_D(const TunSetting); return d->group; } void NetworkManager::TunSetting::setMode(NetworkManager::TunSetting::Mode mode) { Q_D(TunSetting); d->mode = mode; } NetworkManager::TunSetting::Mode NetworkManager::TunSetting::mode() const { Q_D(const TunSetting); return d->mode; } void NetworkManager::TunSetting::setMultiQueue(bool multiQueue) { Q_D(TunSetting); d->multiQueue = multiQueue; } bool NetworkManager::TunSetting::multiQueue() const { Q_D(const TunSetting); return d->multiQueue; } void NetworkManager::TunSetting::setOwner(const QString& owner) { Q_D(TunSetting); d->owner = owner; } QString NetworkManager::TunSetting::owner() const { Q_D(const TunSetting); return d->owner; } void NetworkManager::TunSetting::setPi(bool pi) { Q_D(TunSetting); d->pi = pi; } bool NetworkManager::TunSetting::pi() const { Q_D(const TunSetting); return d->pi; } void NetworkManager::TunSetting::setVnetHdr(bool vnetHdr) { Q_D(TunSetting); d->vnetHdr = vnetHdr; } bool NetworkManager::TunSetting::vnetHdr() const { Q_D(const TunSetting); return d->vnetHdr; } void NetworkManager::TunSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_TUN_GROUP))) { setGroup(setting.value(QLatin1String(NM_SETTING_TUN_GROUP)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_TUN_MODE))) { setMode((Mode)setting.value(QLatin1String(NM_SETTING_TUN_MODE)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_TUN_MULTI_QUEUE))) { setMultiQueue(setting.value(QLatin1String(NM_SETTING_TUN_MULTI_QUEUE)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_TUN_OWNER))) { setOwner(setting.value(QLatin1String(NM_SETTING_TUN_OWNER)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_TUN_PI))) { setPi(setting.value(QLatin1String(NM_SETTING_TUN_PI)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_TUN_VNET_HDR))) { setVnetHdr(setting.value(QLatin1String(NM_SETTING_TUN_VNET_HDR)).toBool()); } } QVariantMap NetworkManager::TunSetting::toMap() const { QVariantMap setting; if (!group().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_TUN_GROUP), group()); } setting.insert(QLatin1String(NM_SETTING_TUN_MODE), (int)mode()); setting.insert(QLatin1String(NM_SETTING_TUN_MULTI_QUEUE), multiQueue()); if (!owner().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_TUN_OWNER), owner()); } setting.insert(QLatin1String(NM_SETTING_TUN_PI), pi()); setting.insert(QLatin1String(NM_SETTING_TUN_VNET_HDR), vnetHdr()); return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::TunSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_TUN_GROUP << ": " << setting.group() << '\n'; dbg.nospace() << NM_SETTING_TUN_MODE << ": " << setting.mode() << '\n'; dbg.nospace() << NM_SETTING_TUN_MULTI_QUEUE << ": " << setting.multiQueue() << '\n'; dbg.nospace() << NM_SETTING_TUN_OWNER << ": " << setting.owner() << '\n'; dbg.nospace() << NM_SETTING_TUN_PI << ": " << setting.pi() << '\n'; dbg.nospace() << NM_SETTING_TUN_VNET_HDR << ": " << setting.vnetHdr() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/tunsetting.h b/src/settings/tunsetting.h index 693ff11..c8186be 100644 --- a/src/settings/tunsetting.h +++ b/src/settings/tunsetting.h @@ -1,85 +1,71 @@ /* - Copyright 2016 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2016 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TUN_SETTING_H #define NETWORKMANAGERQT_TUN_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class TunSettingPrivate; /** * Represents generic setting */ class NETWORKMANAGERQT_EXPORT TunSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum Mode { Tun, Tap }; TunSetting(); explicit TunSetting(const Ptr &other); ~TunSetting() override; QString name() const override; void setGroup(const QString& group); QString group() const; void setMode(Mode mode); Mode mode() const; void setMultiQueue(bool multiQueue); bool multiQueue() const; void setOwner(const QString& owner); QString owner() const; void setPi(bool pi); bool pi() const; void setVnetHdr(bool vnetHdr); bool vnetHdr() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: TunSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(TunSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const TunSetting &setting); } #endif // NETWORKMANAGERQT_TUN_SETTING_H diff --git a/src/settings/tunsetting_p.h b/src/settings/tunsetting_p.h index 71c8ab2..e1887a9 100644 --- a/src/settings/tunsetting_p.h +++ b/src/settings/tunsetting_p.h @@ -1,46 +1,32 @@ /* - Copyright 2016 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2016 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TUN_SETTING_P_H #define NETWORKMANAGERQT_TUN_SETTING_P_H #include namespace NetworkManager { class TunSettingPrivate { public: TunSettingPrivate(); QString name; QString group; NetworkManager::TunSetting::Mode mode; bool multiQueue; QString owner; bool pi; bool vnetHdr; }; } #endif // NETWORKMANAGERQT_TUN_SETTING_P_H diff --git a/src/settings/usersetting.cpp b/src/settings/usersetting.cpp index 6d984c7..f0ce8a0 100644 --- a/src/settings/usersetting.cpp +++ b/src/settings/usersetting.cpp @@ -1,107 +1,93 @@ /* - Copyright Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "usersetting.h" #include "usersetting_p.h" #include #if !NM_CHECK_VERSION(1, 8, 0) #define NM_SETTING_USER_SETTING_NAME "user" #define NM_SETTING_USER_DATA "data" #endif NetworkManager::UserSettingPrivate::UserSettingPrivate() : name(NM_SETTING_USER_SETTING_NAME) { } NetworkManager::UserSetting::UserSetting() : Setting(Setting::User) , d_ptr(new UserSettingPrivate()) { } NetworkManager::UserSetting::UserSetting(const Ptr &other) : Setting(other) , d_ptr(new UserSettingPrivate()) { setData(other->data()); } NetworkManager::UserSetting::~UserSetting() { delete d_ptr; } QString NetworkManager::UserSetting::name() const { Q_D(const UserSetting); return d->name; } void NetworkManager::UserSetting::addData(const QString &data, const QString &value) { Q_D(UserSetting); d->data.insert(data, value); } void NetworkManager::UserSetting::setData(const NMStringMap &data) { Q_D(UserSetting); d->data = data; } NMStringMap NetworkManager::UserSetting::data() const { Q_D(const UserSetting); return d->data; } void NetworkManager::UserSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_USER_DATA))) { setData(qdbus_cast(setting.value(QLatin1String(NM_SETTING_USER_DATA)))); } } QVariantMap NetworkManager::UserSetting::toMap() const { QVariantMap setting; if (!data().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_USER_DATA), QVariant::fromValue(data())); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::UserSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_USER_DATA << ": " << setting.data() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/usersetting.h b/src/settings/usersetting.h index 560aadd..aa64ae9 100644 --- a/src/settings/usersetting.h +++ b/src/settings/usersetting.h @@ -1,69 +1,55 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_USER_SETTING_H #define NETWORKMANAGERQT_USER_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class UserSettingPrivate; /** * Represents user setting */ class NETWORKMANAGERQT_EXPORT UserSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; UserSetting(); explicit UserSetting(const Ptr &other); ~UserSetting() override; QString name() const override; void addData(const QString &data, const QString &value); void setData(const NMStringMap &data); NMStringMap data() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: UserSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(UserSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const UserSetting &setting); } #endif // NETWORKMANAGERQT_USER_SETTING_H diff --git a/src/settings/usersetting_p.h b/src/settings/usersetting_p.h index 232b369..d8cef7d 100644 --- a/src/settings/usersetting_p.h +++ b/src/settings/usersetting_p.h @@ -1,42 +1,28 @@ /* - Copyright 2018 Pranav Gade - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Pranav Gade + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_USER_SETTING_P_H #define NETWORKMANAGERQT_USER_SETTING_P_H #include namespace NetworkManager { class UserSettingPrivate { public: UserSettingPrivate(); QString name; NMStringMap data; }; } #endif // NETWORKMANAGERQT_USER_SETTING_P_H diff --git a/src/settings/vlansetting.cpp b/src/settings/vlansetting.cpp index 06c67bb..d575535 100644 --- a/src/settings/vlansetting.cpp +++ b/src/settings/vlansetting.cpp @@ -1,219 +1,205 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "vlansetting.h" #include "vlansetting_p.h" //define the deprecated&dropped values #define NM_SETTING_VLAN_INTERFACE_NAME "interface-name" #include NetworkManager::VlanSettingPrivate::VlanSettingPrivate() : name(NM_SETTING_VLAN_SETTING_NAME) , id(0) , flags(VlanSetting::None) { } NetworkManager::VlanSetting::VlanSetting() : Setting(Setting::Vlan) , d_ptr(new VlanSettingPrivate()) { } NetworkManager::VlanSetting::VlanSetting(const Ptr &other) : Setting(other) , d_ptr(new VlanSettingPrivate()) { setInterfaceName(other->interfaceName()); setParent(other->parent()); setId(other->id()); setFlags(other->flags()); setIngressPriorityMap(other->ingressPriorityMap()); setEgressPriorityMap(other->egressPriorityMap()); } NetworkManager::VlanSetting::~VlanSetting() { delete d_ptr; } QString NetworkManager::VlanSetting::name() const { Q_D(const VlanSetting); return d->name; } void NetworkManager::VlanSetting::setInterfaceName(const QString &name) { Q_D(VlanSetting); d->interfaceName = name; } QString NetworkManager::VlanSetting::interfaceName() const { Q_D(const VlanSetting); return d->interfaceName; } void NetworkManager::VlanSetting::setParent(const QString &parent) { Q_D(VlanSetting); d->parent = parent; } QString NetworkManager::VlanSetting::parent() const { Q_D(const VlanSetting); return d->parent; } void NetworkManager::VlanSetting::setId(quint32 id) { Q_D(VlanSetting); d->id = id; } quint32 NetworkManager::VlanSetting::id() const { Q_D(const VlanSetting); return d->id; } void NetworkManager::VlanSetting::setFlags(NetworkManager::VlanSetting::Flags flags) { Q_D(VlanSetting); d->flags = flags; } NetworkManager::VlanSetting::Flags NetworkManager::VlanSetting::flags() const { Q_D(const VlanSetting); return d->flags; } void NetworkManager::VlanSetting::setIngressPriorityMap(const QStringList &map) { Q_D(VlanSetting); d->ingressPriorityMap = map; } QStringList NetworkManager::VlanSetting::ingressPriorityMap() const { Q_D(const VlanSetting); return d->ingressPriorityMap; } void NetworkManager::VlanSetting::setEgressPriorityMap(const QStringList &map) { Q_D(VlanSetting); d->egressPriorityMap = map; } QStringList NetworkManager::VlanSetting::egressPriorityMap() const { Q_D(const VlanSetting); return d->egressPriorityMap; } void NetworkManager::VlanSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_VLAN_INTERFACE_NAME))) { setInterfaceName(setting.value(QLatin1String(NM_SETTING_VLAN_INTERFACE_NAME)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_VLAN_PARENT))) { setParent(setting.value(QLatin1String(NM_SETTING_VLAN_PARENT)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_VLAN_ID))) { setId(setting.value(QLatin1String(NM_SETTING_VLAN_ID)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_VLAN_FLAGS))) { setFlags((Flag)setting.value(QLatin1String(NM_SETTING_VLAN_FLAGS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_VLAN_INGRESS_PRIORITY_MAP))) { setIngressPriorityMap(setting.value(QLatin1String(NM_SETTING_VLAN_INGRESS_PRIORITY_MAP)).toStringList()); } if (setting.contains(QLatin1String(NM_SETTING_VLAN_EGRESS_PRIORITY_MAP))) { setEgressPriorityMap(setting.value(QLatin1String(NM_SETTING_VLAN_EGRESS_PRIORITY_MAP)).toStringList()); } } QVariantMap NetworkManager::VlanSetting::toMap() const { QVariantMap setting; if (!interfaceName().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VLAN_INTERFACE_NAME), interfaceName()); } if (!parent().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VLAN_PARENT), parent()); } if (id()) { setting.insert(QLatin1String(NM_SETTING_VLAN_ID), id()); } if (flags() != None) { setting.insert(QLatin1String(NM_SETTING_VLAN_FLAGS), (int)flags()); } if (!ingressPriorityMap().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VLAN_INGRESS_PRIORITY_MAP), ingressPriorityMap()); } if (!egressPriorityMap().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VLAN_EGRESS_PRIORITY_MAP), egressPriorityMap()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::VlanSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_VLAN_INTERFACE_NAME << ": " << setting.interfaceName() << '\n'; dbg.nospace() << NM_SETTING_VLAN_PARENT << ": " << setting.parent() << '\n'; dbg.nospace() << NM_SETTING_VLAN_ID << ": " << setting.id() << '\n'; dbg.nospace() << NM_SETTING_VLAN_FLAGS << ": " << setting.flags() << '\n'; dbg.nospace() << NM_SETTING_VLAN_INGRESS_PRIORITY_MAP << ": " << setting.ingressPriorityMap() << '\n'; dbg.nospace() << NM_SETTING_VLAN_EGRESS_PRIORITY_MAP << ": " << setting.egressPriorityMap() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/vlansetting.h b/src/settings/vlansetting.h index bc06fdc..41cf50f 100644 --- a/src/settings/vlansetting.h +++ b/src/settings/vlansetting.h @@ -1,86 +1,72 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VLAN_SETTING_H #define NETWORKMANAGERQT_VLAN_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class VlanSettingPrivate; /** * Represents vlan setting */ class NETWORKMANAGERQT_EXPORT VlanSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum Flag {None = 0, ReorderHeaders = 0x1, Gvrp = 0x2, LooseBinding = 0x4}; Q_DECLARE_FLAGS(Flags, Flag) VlanSetting(); explicit VlanSetting(const Ptr &other); ~VlanSetting() override; QString name() const override; /// @deprecated in favor of connection.interface-name in NM 1.0.0 void setInterfaceName(const QString &name); QString interfaceName() const; void setParent(const QString &parent); QString parent() const; void setId(quint32 id); quint32 id() const; void setFlags(Flags flags); Flags flags() const; void setIngressPriorityMap(const QStringList &map); QStringList ingressPriorityMap() const; void setEgressPriorityMap(const QStringList &map); QStringList egressPriorityMap() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: VlanSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(VlanSetting) }; Q_DECLARE_OPERATORS_FOR_FLAGS(VlanSetting::Flags) NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const VlanSetting &setting); } #endif // NETWORKMANAGERQT_VLAN_SETTING_H diff --git a/src/settings/vlansetting_p.h b/src/settings/vlansetting_p.h index 936468e..49f7c74 100644 --- a/src/settings/vlansetting_p.h +++ b/src/settings/vlansetting_p.h @@ -1,45 +1,31 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VLAN_SETTING_P_H #define NETWORKMANAGERQT_VLAN_SETTING_P_H #include namespace NetworkManager { class VlanSettingPrivate { public: VlanSettingPrivate(); QString name; QString interfaceName; QString parent; quint32 id; NetworkManager::VlanSetting::Flags flags; QStringList ingressPriorityMap; QStringList egressPriorityMap; }; } #endif // NETWORKMANAGERQT_VLAN_SETTING_P_H diff --git a/src/settings/vpnsetting.cpp b/src/settings/vpnsetting.cpp index 027c8a5..160cd91 100644 --- a/src/settings/vpnsetting.cpp +++ b/src/settings/vpnsetting.cpp @@ -1,259 +1,245 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "vpnsetting.h" #include "vpnsetting_p.h" #include "nmdebug.h" NetworkManager::VpnSettingPrivate::VpnSettingPrivate() : name(NM_SETTING_VPN_SETTING_NAME) , persistent(false) , timeout(0) { } NetworkManager::VpnSetting::VpnSetting() : Setting(Setting::Vpn) , d_ptr(new VpnSettingPrivate()) { } NetworkManager::VpnSetting::VpnSetting(const Ptr &other) : Setting(other) , d_ptr(new VpnSettingPrivate()) { setServiceType(other->serviceType()); setUsername(other->username()); setData(other->data()); setSecrets(other->secrets()); setPersistent(other->persistent()); setTimeout(other->timeout()); } NetworkManager::VpnSetting::~VpnSetting() { delete d_ptr; } QString NetworkManager::VpnSetting::name() const { Q_D(const VpnSetting); return d->name; } bool NetworkManager::VpnSetting::persistent() const { Q_D(const VpnSetting); return d->persistent; } void NetworkManager::VpnSetting::setPersistent(bool persistent) { Q_D(VpnSetting); d->persistent = persistent; } uint NetworkManager::VpnSetting::timeout() const { Q_D(const VpnSetting); return d->timeout; } void NetworkManager::VpnSetting::setTimeout(uint timeout) { Q_D(VpnSetting); d->timeout = timeout; } void NetworkManager::VpnSetting::setServiceType(const QString &type) { Q_D(VpnSetting); d->serviceType = type; } QString NetworkManager::VpnSetting::serviceType() const { Q_D(const VpnSetting); return d->serviceType; } void NetworkManager::VpnSetting::setUsername(const QString &username) { Q_D(VpnSetting); d->username = username; } QString NetworkManager::VpnSetting::username() const { Q_D(const VpnSetting); return d->username; } void NetworkManager::VpnSetting::setData(const NMStringMap &data) { Q_D(VpnSetting); d->data = data; } NMStringMap NetworkManager::VpnSetting::data() const { Q_D(const VpnSetting); return d->data; } void NetworkManager::VpnSetting::setSecrets(const NMStringMap &secrets) { Q_D(VpnSetting); d->secrets = secrets; } NMStringMap NetworkManager::VpnSetting::secrets() const { Q_D(const VpnSetting); return d->secrets; } void NetworkManager::VpnSetting::secretsFromMap(const QVariantMap &secrets) { if (secrets.contains(QLatin1String(NM_SETTING_VPN_SECRETS))) { setSecrets(qdbus_cast(secrets.value(QLatin1String(NM_SETTING_VPN_SECRETS)))); } } QVariantMap NetworkManager::VpnSetting::secretsToMap() const { QVariantMap secretsMap; if (!secrets().isEmpty()) { secretsMap.insert(QLatin1String(NM_SETTING_VPN_SECRETS), QVariant::fromValue(secrets())); } // qCDebug(NMQT) << secretsMap; return secretsMap; } void NetworkManager::VpnSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_VPN_SERVICE_TYPE))) { setServiceType(setting.value(QLatin1String(NM_SETTING_VPN_SERVICE_TYPE)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_VPN_USER_NAME))) { setUsername(setting.value(QLatin1String(NM_SETTING_VPN_USER_NAME)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_VPN_DATA))) { setData(qdbus_cast(setting.value(QLatin1String(NM_SETTING_VPN_DATA)))); } if (setting.contains(QLatin1String(NM_SETTING_VPN_SECRETS))) { setSecrets(qdbus_cast(setting.value(QLatin1String(NM_SETTING_VPN_SECRETS)))); } if (setting.contains(QLatin1String(NM_SETTING_VPN_PERSISTENT))) { setPersistent(setting.value(QLatin1String(NM_SETTING_VPN_PERSISTENT)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_VPN_TIMEOUT))) { setTimeout(setting.value(QLatin1String(NM_SETTING_VPN_TIMEOUT)).toUInt()); } } QVariantMap NetworkManager::VpnSetting::toMap() const { QVariantMap setting; if (!serviceType().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VPN_SERVICE_TYPE), serviceType()); } if (!username().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VPN_USER_NAME), username()); } if (!data().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VPN_DATA), QVariant::fromValue(data())); } if (!secrets().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VPN_SECRETS), QVariant::fromValue(secrets())); } setting.insert(QLatin1String(NM_SETTING_VPN_PERSISTENT), persistent()); setting.insert(QLatin1String(NM_SETTING_VPN_TIMEOUT), timeout()); return setting; } void NetworkManager::VpnSetting::secretsFromStringMap(const NMStringMap &map) { Q_D(VpnSetting); if (map.contains(QLatin1String("VpnSecrets"))) { const QStringList list = map.value(QLatin1String("VpnSecrets")).split("%SEP%"); if (list.count() % 2 == 0) { for (int i = 0; i < list.count(); i += 2) { if (d->secrets.contains(list[i])) { d->secrets.remove(list[i]); } d->secrets.insert(list[i], list[i + 1]); } } } } NMStringMap NetworkManager::VpnSetting::secretsToStringMap() const { NMStringMap ret; QStringList list; QMap::ConstIterator i = secrets().constBegin(); while (i != secrets().constEnd()) { list << i.key() << i.value(); ++i; } ret.insert(QLatin1String("VpnSecrets"), list.join("%SEP%")); return ret; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::VpnSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_VPN_SERVICE_TYPE << ": " << setting.serviceType() << '\n'; dbg.nospace() << NM_SETTING_VPN_USER_NAME << ": " << setting.username() << '\n'; dbg.nospace() << NM_SETTING_VPN_DATA << ": " << setting.data() << '\n'; dbg.nospace() << NM_SETTING_VPN_SECRETS << ": " << setting.secrets() << '\n'; dbg.nospace() << NM_SETTING_VPN_PERSISTENT << ": " << setting.persistent() << '\n'; dbg.nospace() << NM_SETTING_VPN_TIMEOUT << ": " << setting.timeout() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/vpnsetting.h b/src/settings/vpnsetting.h index 075b48b..f323d24 100644 --- a/src/settings/vpnsetting.h +++ b/src/settings/vpnsetting.h @@ -1,87 +1,73 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VPN_SETTING_H #define NETWORKMANAGERQT_VPN_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class VpnSettingPrivate; /** * Represents vpn setting */ class NETWORKMANAGERQT_EXPORT VpnSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; VpnSetting(); explicit VpnSetting(const Ptr &other); ~VpnSetting() override; QString name() const override; bool persistent() const; void setPersistent(bool persistent); void setServiceType(const QString &type); QString serviceType() const; uint timeout() const; void setTimeout(uint timeout); void setUsername(const QString &username); QString username() const; void setData(const NMStringMap &data); NMStringMap data() const; void setSecrets(const NMStringMap &secrets); NMStringMap secrets() const; void secretsFromMap(const QVariantMap &secrets) override; QVariantMap secretsToMap() const override; void secretsFromStringMap(const NMStringMap &map) override; NMStringMap secretsToStringMap() const override; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: VpnSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(VpnSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const VpnSetting &setting); } #endif // NETWORKMANAGERQT_VPN_SETTING_H diff --git a/src/settings/vpnsetting_p.h b/src/settings/vpnsetting_p.h index 01878ad..d3bf758 100644 --- a/src/settings/vpnsetting_p.h +++ b/src/settings/vpnsetting_p.h @@ -1,47 +1,33 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VPN_SETTING_P_H #define NETWORKMANAGERQT_VPN_SETTING_P_H #include "generictypes.h" #include namespace NetworkManager { class VpnSettingPrivate { public: VpnSettingPrivate(); QString name; QString serviceType; QString username; NMStringMap data; NMStringMap secrets; bool persistent; uint timeout; }; } #endif // NETWORKMANAGERQT_VPN_SETTING_P_H diff --git a/src/settings/vxlansetting.cpp b/src/settings/vxlansetting.cpp index 374f2a4..3adf504 100644 --- a/src/settings/vxlansetting.cpp +++ b/src/settings/vxlansetting.cpp @@ -1,467 +1,453 @@ /* - Copyright 2018 Billy Laws - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Billy Laws + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "vxlansetting.h" #include "vxlansetting_p.h" #include NetworkManager::VxlanSettingPrivate::VxlanSettingPrivate() : name(NM_SETTING_VXLAN_SETTING_NAME) , ageing(32) , destinationPort(8472) , id(0) , l2Miss(false) , l3Miss(false) , learning(true) , limit(0) , proxy(false) , rsc(false) , sourcePortMax(0) , sourcePortMin(0) , tos(0) , ttl(0) { } NetworkManager::VxlanSetting::VxlanSetting() : Setting(Setting::Vxlan) , d_ptr(new VxlanSettingPrivate()) { } NetworkManager::VxlanSetting::VxlanSetting(const NetworkManager::VxlanSetting::Ptr &other) : Setting(other) , d_ptr(new VxlanSettingPrivate()) { setAgeing(other->ageing()); setDestinationPort(other->destinationPort()); setId(other->id()); setL2Miss(other->l2Miss()); setL3Miss(other->l3Miss()); setLearning(other->learning()); setLimit(other->limit()); setLocal(other->local()); setParent(other->parent()); setProxy(other->proxy()); setRemote(other->remote()); setRsc(other->rsc()); setSourcePortMax(other->sourcePortMax()); setSourcePortMin(other->sourcePortMin()); setTos(other->tos()); setTtl(other->ttl()); } NetworkManager::VxlanSetting::~VxlanSetting() { delete d_ptr; } QString NetworkManager::VxlanSetting::name() const { Q_D(const VxlanSetting); return d->name; } void NetworkManager::VxlanSetting::setAgeing(quint32 ageing) { Q_D(VxlanSetting); d->ageing = ageing; } quint32 NetworkManager::VxlanSetting::ageing() const { Q_D(const VxlanSetting); return d->ageing; } void NetworkManager::VxlanSetting::setDestinationPort(quint32 port) { Q_D(VxlanSetting); d->destinationPort = port; } quint32 NetworkManager::VxlanSetting::destinationPort() const { Q_D(const VxlanSetting); return d->destinationPort; } void NetworkManager::VxlanSetting::setId(quint32 id) { Q_D(VxlanSetting); d->id = id; } quint32 NetworkManager::VxlanSetting::id() const { Q_D(const VxlanSetting); return d->id; } void NetworkManager::VxlanSetting::setL2Miss(bool enable) { Q_D(VxlanSetting); d->l2Miss = enable; } bool NetworkManager::VxlanSetting::l2Miss() const { Q_D(const VxlanSetting); return d->l2Miss; } void NetworkManager::VxlanSetting::setL3Miss(bool enable) { Q_D(VxlanSetting); d->l3Miss = enable; } bool NetworkManager::VxlanSetting::l3Miss() const { Q_D(const VxlanSetting); return d->l3Miss; } void NetworkManager::VxlanSetting::setLearning(bool enable) { Q_D(VxlanSetting); d->learning = enable; } bool NetworkManager::VxlanSetting::learning() const { Q_D(const VxlanSetting); return d->learning; } void NetworkManager::VxlanSetting::setLimit(quint32 limit) { Q_D(VxlanSetting); d->limit = limit; } quint32 NetworkManager::VxlanSetting::limit() const { Q_D(const VxlanSetting); return d->limit; } void NetworkManager::VxlanSetting::setLocal(QString local) { Q_D(VxlanSetting); d->local = local; } QString NetworkManager::VxlanSetting::local() const { Q_D(const VxlanSetting); return d->local; } void NetworkManager::VxlanSetting::setParent(QString parent) { Q_D(VxlanSetting); d->parent = parent; } QString NetworkManager::VxlanSetting::parent() const { Q_D(const VxlanSetting); return d->parent; } void NetworkManager::VxlanSetting::setProxy(bool enable) { Q_D(VxlanSetting); d->proxy = enable; } bool NetworkManager::VxlanSetting::proxy() const { Q_D(const VxlanSetting); return d->proxy; } void NetworkManager::VxlanSetting::setRemote(QString remote) { Q_D(VxlanSetting); d->remote = remote; } QString NetworkManager::VxlanSetting::remote() const { Q_D(const VxlanSetting); return d->remote; } void NetworkManager::VxlanSetting::setRsc(bool enable) { Q_D(VxlanSetting); d->rsc = enable; } bool NetworkManager::VxlanSetting::rsc() const { Q_D(const VxlanSetting); return d->rsc; } void NetworkManager::VxlanSetting::setSourcePortMax(quint32 maxPort) { Q_D(VxlanSetting); d->sourcePortMax = maxPort; } quint32 NetworkManager::VxlanSetting::sourcePortMax() const { Q_D(const VxlanSetting); return d->sourcePortMax; } void NetworkManager::VxlanSetting::setSourcePortMin(quint32 minPort) { Q_D(VxlanSetting); d->sourcePortMin = minPort; } quint32 NetworkManager::VxlanSetting::sourcePortMin() const { Q_D(const VxlanSetting); return d->sourcePortMin; } void NetworkManager::VxlanSetting::setTos(quint32 tos) { Q_D(VxlanSetting); d->tos = tos; } quint32 NetworkManager::VxlanSetting::tos() const { Q_D(const VxlanSetting); return d->tos; } void NetworkManager::VxlanSetting::setTtl(quint32 ttl) { Q_D(VxlanSetting); d->ttl = ttl; } quint32 NetworkManager::VxlanSetting::ttl() const { Q_D(const VxlanSetting); return d->ttl; } void NetworkManager::VxlanSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_VXLAN_AGEING))) { setAgeing(setting.value(QLatin1String(NM_SETTING_VXLAN_AGEING)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_DESTINATION_PORT))) { setDestinationPort(setting.value(QLatin1String(NM_SETTING_VXLAN_DESTINATION_PORT)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_ID))) { setId(setting.value(QLatin1String(NM_SETTING_VXLAN_ID)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_L2_MISS))) { setL2Miss(setting.value(QLatin1String(NM_SETTING_VXLAN_L2_MISS)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_L3_MISS))) { setL3Miss(setting.value(QLatin1String(NM_SETTING_VXLAN_L3_MISS)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_LEARNING))) { setLearning(setting.value(QLatin1String(NM_SETTING_VXLAN_LEARNING)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_LIMIT))) { setLimit(setting.value(QLatin1String(NM_SETTING_VXLAN_LIMIT)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_LOCAL))) { setLocal(setting.value(QLatin1String(NM_SETTING_VXLAN_LOCAL)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_PARENT))) { setParent(setting.value(QLatin1String(NM_SETTING_VXLAN_PARENT)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_PROXY))) { setProxy(setting.value(QLatin1String(NM_SETTING_VXLAN_PROXY)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_REMOTE))) { setRemote(setting.value(QLatin1String(NM_SETTING_VXLAN_REMOTE)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_RSC))) { setRsc(setting.value(QLatin1String(NM_SETTING_VXLAN_RSC)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MAX))) { setSourcePortMax(setting.value(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MAX)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MIN))) { setSourcePortMin(setting.value(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MIN)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_TOS))) { setTos(setting.value(QLatin1String(NM_SETTING_VXLAN_TOS)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_VXLAN_TTL))) { setTtl(setting.value(QLatin1String(NM_SETTING_VXLAN_TTL)).toUInt()); } } QVariantMap NetworkManager::VxlanSetting::toMap() const { QVariantMap setting; if (ageing() != 32) { setting.insert(QLatin1String(NM_SETTING_VXLAN_AGEING), ageing()); } if (destinationPort() != 8472) { setting.insert(QLatin1String(NM_SETTING_VXLAN_DESTINATION_PORT), destinationPort()); } if (id()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_ID), id()); } if (l2Miss()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_L2_MISS), l2Miss()); } if (l3Miss()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_L3_MISS), l3Miss()); } if (!learning()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_LEARNING), learning()); } if (limit()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_LIMIT), limit()); } if (!local().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_LOCAL), local()); } if (!parent().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_PARENT), parent()); } if (proxy()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_PROXY), proxy()); } if (!remote().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_REMOTE), remote()); } if (rsc()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_RSC), rsc()); } if (sourcePortMax()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MAX), sourcePortMax()); } if (sourcePortMin()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MIN), sourcePortMin()); } if (tos()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_TOS), tos()); } if (ttl()) { setting.insert(QLatin1String(NM_SETTING_VXLAN_TTL), ttl()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::VxlanSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_AGEING << ": " << setting.ageing() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_DESTINATION_PORT << ": " << setting.destinationPort() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_ID << ": " << setting.id() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_L2_MISS << ": " << setting.l2Miss() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_L3_MISS << ": " << setting.l3Miss() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_LEARNING << ": " << setting.learning() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_LIMIT << ": " << setting.limit() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_LOCAL << ": " << setting.local() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_PARENT << ": " << setting.parent() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_PROXY << ": " << setting.proxy() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_REMOTE << ": " << setting.remote() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_RSC << ": " << setting.rsc() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_SOURCE_PORT_MAX << ": " << setting.sourcePortMax() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_SOURCE_PORT_MIN << ": " << setting.sourcePortMin() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_TOS << ": " << setting.tos() << '\n'; dbg.nospace() << NM_SETTING_VXLAN_TTL << ": " << setting.ttl() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/vxlansetting.h b/src/settings/vxlansetting.h index 5f7c6f0..0f6c610 100644 --- a/src/settings/vxlansetting.h +++ b/src/settings/vxlansetting.h @@ -1,111 +1,97 @@ /* - Copyright 2018 Billy Laws - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Billy Laws + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VXLAN_SETTING_H #define NETWORKMANAGERQT_VXLAN_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class VxlanSettingPrivate; /** * Represents vxlan setting */ class NETWORKMANAGERQT_EXPORT VxlanSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; VxlanSetting(); explicit VxlanSetting(const Ptr &other); ~VxlanSetting() override; QString name() const override; void setAgeing(quint32 ageing); quint32 ageing() const; void setDestinationPort(quint32 port); quint32 destinationPort() const; void setId(quint32 id); quint32 id() const; void setL2Miss(bool enable); bool l2Miss() const; void setL3Miss(bool enable); bool l3Miss() const; void setLearning(bool enable); bool learning() const; void setLimit(quint32 limit); quint32 limit() const; void setLocal(QString local); QString local() const; void setParent(QString parent); QString parent() const; void setProxy(bool enable); bool proxy() const; void setRemote(QString remote); QString remote() const; void setRsc(bool enable); bool rsc() const; void setSourcePortMax(quint32 maxPort); quint32 sourcePortMax() const; void setSourcePortMin(quint32 minPort); quint32 sourcePortMin() const; void setTos(quint32 tos); quint32 tos() const; void setTtl(quint32 ttl); quint32 ttl() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: VxlanSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(VxlanSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const VxlanSetting &setting); } #endif // NETWORKMANAGERQT_VXLAN_SETTING_H diff --git a/src/settings/vxlansetting_p.h b/src/settings/vxlansetting_p.h index 3cf3fe2..b428e0b 100644 --- a/src/settings/vxlansetting_p.h +++ b/src/settings/vxlansetting_p.h @@ -1,55 +1,41 @@ /* - Copyright 2018 Billy Laws - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2018 Billy Laws + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VXLAN_SETTING_P_H #define NETWORKMANAGERQT_VXLAN_SETTING_P_H #include namespace NetworkManager { class VxlanSettingPrivate { public: VxlanSettingPrivate(); QString name; quint32 ageing; quint32 destinationPort; quint32 id; bool l2Miss; bool l3Miss; bool learning; quint32 limit; QString local; QString parent; bool proxy; QString remote; bool rsc; quint32 sourcePortMax; quint32 sourcePortMin; quint32 tos; quint32 ttl; }; } #endif // NETWORKMANAGERQT_VXLAN_SETTING_P_H diff --git a/src/settings/wimaxsetting.cpp b/src/settings/wimaxsetting.cpp index f57fdb7..1b26e3d 100644 --- a/src/settings/wimaxsetting.cpp +++ b/src/settings/wimaxsetting.cpp @@ -1,119 +1,105 @@ /* - Copyright 2012-2013 Jan Grulich - Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wimaxsetting.h" #include "wimaxsetting_p.h" #include NetworkManager::WimaxSettingPrivate::WimaxSettingPrivate() : name(NM_SETTING_WIMAX_SETTING_NAME) { } NetworkManager::WimaxSetting::WimaxSetting() : Setting(Setting::Wimax) , d_ptr(new WimaxSettingPrivate()) { } NetworkManager::WimaxSetting::WimaxSetting(const Ptr &other) : Setting(other) , d_ptr(new WimaxSettingPrivate()) { setNetworkName(other->networkName()); setMacAddress(other->macAddress()); } NetworkManager::WimaxSetting::~WimaxSetting() { delete d_ptr; } QString NetworkManager::WimaxSetting::name() const { Q_D(const WimaxSetting); return d->name; } void NetworkManager::WimaxSetting::setNetworkName(const QString &name) { Q_D(WimaxSetting); d->networkName = name; } QString NetworkManager::WimaxSetting::networkName() const { Q_D(const WimaxSetting); return d->networkName; } void NetworkManager::WimaxSetting::setMacAddress(const QByteArray &address) { Q_D(WimaxSetting); d->macAddress = address; } QByteArray NetworkManager::WimaxSetting::macAddress() const { Q_D(const WimaxSetting); return d->macAddress; } void NetworkManager::WimaxSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_WIMAX_NETWORK_NAME))) { setNetworkName(setting.value(QLatin1String(NM_SETTING_WIMAX_NETWORK_NAME)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_WIMAX_MAC_ADDRESS))) { setMacAddress(setting.value(QLatin1String(NM_SETTING_WIMAX_MAC_ADDRESS)).toByteArray()); } } QVariantMap NetworkManager::WimaxSetting::toMap() const { QVariantMap setting; if (!networkName().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIMAX_NETWORK_NAME), networkName()); } if (!macAddress().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIMAX_MAC_ADDRESS), macAddress()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::WimaxSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_WIMAX_NETWORK_NAME << ": " << setting.networkName() << '\n'; dbg.nospace() << NM_SETTING_WIMAX_MAC_ADDRESS << ": " << setting.macAddress() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/wimaxsetting.h b/src/settings/wimaxsetting.h index c5c42de..42c60f8 100644 --- a/src/settings/wimaxsetting.h +++ b/src/settings/wimaxsetting.h @@ -1,70 +1,56 @@ /* - Copyright 2012-2013 Jan Grulich - Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIMAX_SETTING_H #define NETWORKMANAGERQT_WIMAX_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class WimaxSettingPrivate; /** * Represents wimax setting */ class NETWORKMANAGERQT_EXPORT WimaxSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; WimaxSetting(); explicit WimaxSetting(const Ptr &other); ~WimaxSetting() override; QString name() const override; void setNetworkName(const QString &name); QString networkName() const; void setMacAddress(const QByteArray &address); QByteArray macAddress() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: WimaxSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(WimaxSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const WimaxSetting &setting); } #endif // NETWORKMANAGERQT_WIMAX_SETTING_H diff --git a/src/settings/wimaxsetting_p.h b/src/settings/wimaxsetting_p.h index 1bae543..548039d 100644 --- a/src/settings/wimaxsetting_p.h +++ b/src/settings/wimaxsetting_p.h @@ -1,41 +1,27 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIMAX_SETTING_P_H #define NETWORKMANAGERQT_WIMAX_SETTING_P_H #include namespace NetworkManager { class WimaxSettingPrivate { public: WimaxSettingPrivate(); QString name; QString networkName; QByteArray macAddress; }; } #endif // NETWORKMANAGERQT_WIMAX_SETTING_P_H diff --git a/src/settings/wiredsetting.cpp b/src/settings/wiredsetting.cpp index b37b806..125f13e 100644 --- a/src/settings/wiredsetting.cpp +++ b/src/settings/wiredsetting.cpp @@ -1,475 +1,461 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wiredsetting.h" #include "wiredsetting_p.h" #include "manager.h" #include NetworkManager::WiredSettingPrivate::WiredSettingPrivate() : name(NM_SETTING_WIRED_SETTING_NAME) , port(NetworkManager::WiredSetting::UnknownPort) , speed(0) , duplex(NetworkManager::WiredSetting::UnknownDuplexType) , mtu(0) , s390NetType(NetworkManager::WiredSetting::Undefined) , wakeOnLan(NetworkManager::WiredSetting::WakeOnLanDefault) { if (NetworkManager::checkVersion(1, 6, 0)) { autoNegotiate = false; } else { autoNegotiate = true; } } NetworkManager::WiredSetting::WiredSetting() : Setting(Setting::Wired) , d_ptr(new WiredSettingPrivate()) { } NetworkManager::WiredSetting::WiredSetting(const WiredSetting::Ptr &other) : Setting(other) , d_ptr(new WiredSettingPrivate()) { setPort(other->port()); setSpeed(other->speed()); setDuplexType(other->duplexType()); setAutoNegotiate(other->autoNegotiate()); setGenerateMacAddressMask(other->generateMacAddressMask()); setMacAddress(other->macAddress()); setClonedMacAddress(other->clonedMacAddress()); setMacAddressBlacklist(other->macAddressBlacklist()); setMtu(other->mtu()); setS390Subchannels(other->s390Subchannels()); setS390NetType(other->s390NetType()); setS390Options(other->s390Options()); setWakeOnLan(other->wakeOnLan()); setWakeOnLanPassword(other->wakeOnLanPassword()); } NetworkManager::WiredSetting::~WiredSetting() { delete d_ptr; } QString NetworkManager::WiredSetting::name() const { Q_D(const WiredSetting); return d->name; } void NetworkManager::WiredSetting::setPort(NetworkManager::WiredSetting::PortType port) { Q_D(WiredSetting); d->port = port; } NetworkManager::WiredSetting::PortType NetworkManager::WiredSetting::port() const { Q_D(const WiredSetting); return d->port; } void NetworkManager::WiredSetting::setSpeed(quint32 speed) { Q_D(WiredSetting); d->speed = speed; } quint32 NetworkManager::WiredSetting::speed() const { Q_D(const WiredSetting); return d->speed; } void NetworkManager::WiredSetting::setDuplexType(NetworkManager::WiredSetting::DuplexType type) { Q_D(WiredSetting); d->duplex = type; } NetworkManager::WiredSetting::DuplexType NetworkManager::WiredSetting::duplexType() const { Q_D(const WiredSetting); return d->duplex; } void NetworkManager::WiredSetting::setAutoNegotiate(bool autoNegotiate) { Q_D(WiredSetting); d->autoNegotiate = autoNegotiate; } bool NetworkManager::WiredSetting::autoNegotiate() const { Q_D(const WiredSetting); return d->autoNegotiate; } QString NetworkManager::WiredSetting::generateMacAddressMask() const { Q_D(const WiredSetting); return d->generateMacAddressMask; } void NetworkManager::WiredSetting::setGenerateMacAddressMask(const QString& mask) { Q_D(WiredSetting); d->generateMacAddressMask = mask; } void NetworkManager::WiredSetting::setMacAddress(const QByteArray &address) { Q_D(WiredSetting); d->macAddress = address; } QByteArray NetworkManager::WiredSetting::macAddress() const { Q_D(const WiredSetting); return d->macAddress; } void NetworkManager::WiredSetting::setClonedMacAddress(const QByteArray &address) { Q_D(WiredSetting); d->clonedMacAddress = address; } QByteArray NetworkManager::WiredSetting::clonedMacAddress() const { Q_D(const WiredSetting); return d->clonedMacAddress; } void NetworkManager::WiredSetting::setMacAddressBlacklist(const QStringList &list) { Q_D(WiredSetting); d->macAddressBlacklist = list; } QStringList NetworkManager::WiredSetting::macAddressBlacklist() const { Q_D(const WiredSetting); return d->macAddressBlacklist; } void NetworkManager::WiredSetting::setMtu(quint32 mtu) { Q_D(WiredSetting); d->mtu = mtu; } quint32 NetworkManager::WiredSetting::mtu() const { Q_D(const WiredSetting); return d->mtu; } void NetworkManager::WiredSetting::setS390Subchannels(const QStringList &channels) { Q_D(WiredSetting); d->s390Subchannels = channels; } QStringList NetworkManager::WiredSetting::s390Subchannels() const { Q_D(const WiredSetting); return d->s390Subchannels; } void NetworkManager::WiredSetting::setS390NetType(NetworkManager::WiredSetting::S390Nettype type) { Q_D(WiredSetting); d->s390NetType = type; } NetworkManager::WiredSetting::S390Nettype NetworkManager::WiredSetting::s390NetType() const { Q_D(const WiredSetting); return d->s390NetType; } void NetworkManager::WiredSetting::setS390Options(const QMap &options) { Q_D(WiredSetting); d->s390Options = options; } QMap NetworkManager::WiredSetting::s390Options() const { Q_D(const WiredSetting); return d->s390Options; } NetworkManager::WiredSetting::WakeOnLanFlags NetworkManager::WiredSetting::wakeOnLan() const { Q_D(const WiredSetting); return d->wakeOnLan; } void NetworkManager::WiredSetting::setWakeOnLan(NetworkManager::WiredSetting::WakeOnLanFlags wol) { Q_D(WiredSetting); d->wakeOnLan = wol; } QString NetworkManager::WiredSetting::wakeOnLanPassword() const { Q_D(const WiredSetting); return d->wakeOnLanPassword; } void NetworkManager::WiredSetting::setWakeOnLanPassword(const QString& password) { Q_D(WiredSetting); d->wakeOnLanPassword = password; } void NetworkManager::WiredSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_WIRED_PORT))) { const QString port = setting.value(QLatin1String(NM_SETTING_WIRED_PORT)).toString(); if (port == "tp") { setPort(Tp); } else if (port == "aui") { setPort(Aui); } else if (port == "bnc") { setPort(Bnc); } else if (port == "mii") { setPort(Mii); } } if (setting.contains(QLatin1String(NM_SETTING_WIRED_SPEED))) { setSpeed(setting.value(QLatin1String(NM_SETTING_WIRED_SPEED)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_WIRED_DUPLEX))) { const QString duplex = setting.value(QLatin1String(NM_SETTING_WIRED_DUPLEX)).toString(); if (duplex == "half") { setDuplexType(Half); } else if (duplex == "full") { setDuplexType(Full); } } if (setting.contains(QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE))) { setAutoNegotiate(setting.value(QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK))) { setGenerateMacAddressMask(setting.value(QLatin1String(NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS))) { setMacAddress(setting.value(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_WIRED_CLONED_MAC_ADDRESS))) { setClonedMacAddress(setting.value(QLatin1String(NM_SETTING_WIRED_CLONED_MAC_ADDRESS)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST))) { setMacAddressBlacklist(setting.value(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST)).toStringList()); } if (setting.contains(QLatin1String(NM_SETTING_WIRED_MTU))) { setMtu(setting.value(QLatin1String(NM_SETTING_WIRED_MTU)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_WIRED_S390_SUBCHANNELS))) { setS390Subchannels(setting.value(QLatin1String(NM_SETTING_WIRED_S390_SUBCHANNELS)).toStringList()); } if (setting.contains(QLatin1String(NM_SETTING_WIRED_S390_NETTYPE))) { const QString nettype = setting.value(QLatin1String(NM_SETTING_WIRED_S390_NETTYPE)).toString(); if (nettype == "qeth") { setS390NetType(Qeth); } else if (nettype == "lcs") { setS390NetType(Lcs); } else if (nettype == "ctc") { setS390NetType(Ctc); } } if (setting.contains(QLatin1String(NM_SETTING_WIRED_S390_OPTIONS))) { QMap tmp; if (setting.value(QLatin1String(NM_SETTING_WIRED_S390_OPTIONS)).canConvert()) { QDBusArgument arg = setting.value(QLatin1String(NM_SETTING_WIRED_S390_OPTIONS)).value(); tmp = qdbus_cast(arg); } else { tmp = setting.value(QLatin1String(NM_SETTING_WIRED_S390_OPTIONS)).value(); } setS390Options(tmp); } if (setting.contains(QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN))) { setWakeOnLan((NetworkManager::WiredSetting::WakeOnLanFlags)setting.value(QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD))) { setWakeOnLanPassword(setting.value(QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD)).toString()); } } QVariantMap NetworkManager::WiredSetting::toMap() const { QVariantMap setting; switch (port()) { case Tp: setting.insert(QLatin1String(NM_SETTING_WIRED_PORT), "tp"); break; case Aui: setting.insert(QLatin1String(NM_SETTING_WIRED_PORT), "aui"); break; case Bnc: setting.insert(QLatin1String(NM_SETTING_WIRED_PORT), "bnc"); break; case Mii: setting.insert(QLatin1String(NM_SETTING_WIRED_PORT), "mii"); break; case UnknownPort: // Make GCC hapy break; } // When autonegotiation is set we have to avoid setting speed and duplex, while // when autonegotiation is disabled, we have to specify both if (autoNegotiate()) { setting.insert(QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE), autoNegotiate()); } else { setting.insert(QLatin1String(NM_SETTING_WIRED_AUTO_NEGOTIATE), autoNegotiate()); setting.insert(QLatin1String(NM_SETTING_WIRED_SPEED), speed()); switch (duplexType()) { case Half: setting.insert(QLatin1String(NM_SETTING_WIRED_DUPLEX), "half"); break; case Full: setting.insert(QLatin1String(NM_SETTING_WIRED_DUPLEX), "full"); break; case UnknownDuplexType: break; } } if (!generateMacAddressMask().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK), generateMacAddressMask()); } if (!macAddress().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS), macAddress()); } if (!clonedMacAddress().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRED_CLONED_MAC_ADDRESS), clonedMacAddress()); } if (!macAddressBlacklist().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST), macAddressBlacklist()); } if (mtu()) { setting.insert(QLatin1String(NM_SETTING_WIRED_MTU), mtu()); } if (!s390Subchannels().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRED_S390_SUBCHANNELS), s390Subchannels()); } switch (s390NetType()) { case Qeth: setting.insert(QLatin1String(NM_SETTING_WIRED_S390_NETTYPE), "qeth"); break; case Lcs: setting.insert(QLatin1String(NM_SETTING_WIRED_S390_NETTYPE), "lcs"); break; case Ctc: setting.insert(QLatin1String(NM_SETTING_WIRED_S390_NETTYPE), "ctc"); break; case Undefined: break; } if (!s390Options().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRED_S390_OPTIONS), QVariant::fromValue(s390Options())); } setting.insert(QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN), (uint)wakeOnLan()); if (!wakeOnLanPassword().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD), wakeOnLanPassword()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::WiredSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_WIRED_PORT << ": " << setting.port() << '\n'; dbg.nospace() << NM_SETTING_WIRED_SPEED << ": " << setting.speed() << '\n'; dbg.nospace() << NM_SETTING_WIRED_DUPLEX << ": " << setting.duplexType() << '\n'; dbg.nospace() << NM_SETTING_WIRED_AUTO_NEGOTIATE << ": " << setting.autoNegotiate() << '\n'; dbg.nospace() << NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK << ": " << setting.generateMacAddressMask() << '\n'; dbg.nospace() << NM_SETTING_WIRED_MAC_ADDRESS << ": " << setting.macAddress() << '\n'; dbg.nospace() << NM_SETTING_WIRED_CLONED_MAC_ADDRESS << ": " << setting.clonedMacAddress() << '\n'; dbg.nospace() << NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST << ": " << setting.macAddressBlacklist() << '\n'; dbg.nospace() << NM_SETTING_WIRED_MTU << ": " << setting.mtu() << '\n'; dbg.nospace() << NM_SETTING_WIRED_S390_SUBCHANNELS << ": " << setting.s390Subchannels() << '\n'; dbg.nospace() << NM_SETTING_WIRED_S390_NETTYPE << ": " << setting.s390NetType() << '\n'; dbg.nospace() << NM_SETTING_WIRED_S390_OPTIONS << ": " << setting.s390Options() << '\n'; dbg.nospace() << NM_SETTING_WIRED_WAKE_ON_LAN << ": " << setting.wakeOnLan() << '\n'; dbg.nospace() << NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD << ": " << setting.wakeOnLanPassword() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/wiredsetting.h b/src/settings/wiredsetting.h index 918a6b3..e1a00ab 100644 --- a/src/settings/wiredsetting.h +++ b/src/settings/wiredsetting.h @@ -1,142 +1,128 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRED_SETTING_H #define NETWORKMANAGERQT_WIRED_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class WiredSettingPrivate; /** * Represents wired setting */ class NETWORKMANAGERQT_EXPORT WiredSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum PortType { UnknownPort = 0, Tp, Aui, Bnc, Mii }; enum DuplexType { UnknownDuplexType = 0, Half, Full }; enum S390Nettype { Undefined = 0, Qeth, Lcs, Ctc }; enum WakeOnLanFlag { WakeOnLanPhy = 1 << 1, WakeOnLanUnicast = 1 << 2, WakeOnLanMulticast = 1 << 3, WakeOnLanBroadcast = 1 << 4, WakeOnLanArp = 1 << 5, WakeOnLanMagic = 1 << 6, /* Special values */ WakeOnLanDefault = 1 << 0, WakeOnLanIgnore = 1 << 15 }; Q_DECLARE_FLAGS(WakeOnLanFlags, WakeOnLanFlag) Q_FLAGS(WakeOnLanFlag) WiredSetting(); explicit WiredSetting(const Ptr &other); ~WiredSetting() override; QString name() const override; void setPort(PortType port); PortType port() const; void setSpeed(quint32 speed); quint32 speed() const; void setDuplexType(DuplexType type); DuplexType duplexType() const; void setAutoNegotiate(bool autoNegotiate); bool autoNegotiate() const; QString generateMacAddressMask() const; void setGenerateMacAddressMask(const QString& mask); void setMacAddress(const QByteArray &address); QByteArray macAddress() const; void setClonedMacAddress(const QByteArray &address); QByteArray clonedMacAddress() const; void setMacAddressBlacklist(const QStringList &list); QStringList macAddressBlacklist() const; void setMtu(quint32 mtu); quint32 mtu() const; void setS390Subchannels(const QStringList &channels); QStringList s390Subchannels() const; void setS390NetType(S390Nettype type); S390Nettype s390NetType() const; void setS390Options(const QMap &options); QMap s390Options() const; WakeOnLanFlags wakeOnLan() const; void setWakeOnLan(WakeOnLanFlags wol); QString wakeOnLanPassword() const; void setWakeOnLanPassword(const QString& password); void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: WiredSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(WiredSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const WiredSetting &setting); Q_DECLARE_OPERATORS_FOR_FLAGS(WiredSetting::WakeOnLanFlags) } #endif // NETWORKMANAGERQT_WIRED_SETTING_H diff --git a/src/settings/wiredsetting_p.h b/src/settings/wiredsetting_p.h index 44772d8..8b3a888 100644 --- a/src/settings/wiredsetting_p.h +++ b/src/settings/wiredsetting_p.h @@ -1,54 +1,40 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRED_SETTING_P_H #define NETWORKMANAGERQT_WIRED_SETTING_P_H #include #include namespace NetworkManager { class WiredSettingPrivate { public: WiredSettingPrivate(); QString name; NetworkManager::WiredSetting::PortType port; quint32 speed; NetworkManager::WiredSetting::DuplexType duplex; bool autoNegotiate; QByteArray macAddress; QByteArray clonedMacAddress; QStringList macAddressBlacklist; quint32 mtu; QStringList s390Subchannels; NetworkManager::WiredSetting::S390Nettype s390NetType; QMap s390Options; QString generateMacAddressMask; NetworkManager::WiredSetting::WakeOnLanFlags wakeOnLan; QString wakeOnLanPassword; }; } #endif // NETWORKMANAGERQT_WIRED_SETTING_P_H diff --git a/src/settings/wireguardsetting.cpp b/src/settings/wireguardsetting.cpp index 299b0d7..a23fa2c 100644 --- a/src/settings/wireguardsetting.cpp +++ b/src/settings/wireguardsetting.cpp @@ -1,396 +1,382 @@ /* - Copyright 2019 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2019 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wireguardsetting.h" #include "wireguardsetting_p.h" #include #if !NM_CHECK_VERSION(1, 16, 0) #define NM_SETTING_WIREGUARD_SETTING_NAME "wireguard" #define NM_SETTING_WIREGUARD_FWMARK "fwmark" #define NM_SETTING_WIREGUARD_LISTEN_PORT "listen-port" #define NM_SETTING_WIREGUARD_PRIVATE_KEY "private-key" #define NM_SETTING_WIREGUARD_PRIVATE_KEY_FLAGS "private-key-flags" #define NM_SETTING_WIREGUARD_PEERS "peers" #define NM_SETTING_WIREGUARD_MTU "mtu" #define NM_SETTING_WIREGUARD_PEER_ROUTES "peer-routes" #define NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY "preshared-key" #define NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY_FLAGS "preshared-key-flags" #define NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY "public-key" #endif NetworkManager::WireGuardSettingPrivate::WireGuardSettingPrivate() : name(NM_SETTING_WIREGUARD_SETTING_NAME) , fwmark(0) , listenPort(0) , mtu(0) , peerRoutes(true) , privateKeyFlags(NetworkManager::Setting::None) { } NetworkManager::WireGuardSetting::WireGuardSetting() : Setting(Setting::WireGuard) , d_ptr(new WireGuardSettingPrivate()) { } NetworkManager::WireGuardSetting::WireGuardSetting(const Ptr &other) : Setting(other) , d_ptr(new WireGuardSettingPrivate()) { setFwmark(other->fwmark()); setListenPort(other->listenPort()); setMtu(other->mtu()); setPeerRoutes(other->peerRoutes()); setPeers(other->peers()); setPrivateKey(other->privateKey()); setPrivateKeyFlags(other->privateKeyFlags()); } NetworkManager::WireGuardSetting::~WireGuardSetting() { delete d_ptr; } QString NetworkManager::WireGuardSetting::name() const { Q_D(const WireGuardSetting); return d->name; } quint32 NetworkManager::WireGuardSetting::fwmark() const { Q_D(const WireGuardSetting); return d->fwmark; } void NetworkManager::WireGuardSetting::setFwmark(quint32 fwmark) { Q_D(WireGuardSetting); d->fwmark = fwmark; } quint32 NetworkManager::WireGuardSetting::listenPort() const { Q_D(const WireGuardSetting); return d->listenPort; } void NetworkManager::WireGuardSetting::setListenPort(quint32 port) { Q_D(WireGuardSetting); d->listenPort = port; } quint32 NetworkManager::WireGuardSetting::mtu() const { Q_D(const WireGuardSetting); return d->mtu; } void NetworkManager::WireGuardSetting::setMtu(quint32 mtu) { Q_D(WireGuardSetting); d->mtu = mtu; } bool NetworkManager::WireGuardSetting::peerRoutes() const { Q_D(const WireGuardSetting); return d->peerRoutes; } void NetworkManager::WireGuardSetting::setPeerRoutes(bool peerRoutes) { Q_D(WireGuardSetting); d->peerRoutes = peerRoutes; } NMVariantMapList NetworkManager::WireGuardSetting::peers() const { Q_D(const WireGuardSetting); return d->peers; } void NetworkManager::WireGuardSetting::setPeers(const NMVariantMapList &peers) { Q_D(WireGuardSetting); d->peers = peers; } QString NetworkManager::WireGuardSetting::privateKey() const { Q_D(const WireGuardSetting); return d->privateKey; } void NetworkManager::WireGuardSetting::setPrivateKey(const QString &key) { Q_D(WireGuardSetting); d->privateKey = key; } NetworkManager::Setting::SecretFlags NetworkManager::WireGuardSetting::privateKeyFlags() const { Q_D(const WireGuardSetting); return d->privateKeyFlags; } void NetworkManager::WireGuardSetting::setPrivateKeyFlags(NetworkManager::Setting::SecretFlags flags) { Q_D(WireGuardSetting); d->privateKeyFlags = flags; } void NetworkManager::WireGuardSetting::secretsFromMap(const QVariantMap &secrets) { if (secrets.contains(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY))) { setPrivateKey(secrets.value(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY)).toString()); } if (secrets.contains(QLatin1String(NM_SETTING_WIREGUARD_PEERS))) { NMVariantMapList listOfPeers = qdbus_cast(secrets.value(QLatin1String(NM_SETTING_WIREGUARD_PEERS))); NMVariantMapList origPeers = peers(); for (const QVariantMap &peer : listOfPeers) { if (peer.contains(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY))) { QString presharedKey = peer.value(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY)).toString(); QString publicKey = peer.value(QLatin1String(NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY)).toString(); for (int i = 0; i < origPeers.size(); i++) { if (origPeers[i][QLatin1String(NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY)].toString() == publicKey) { origPeers[i].insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY), presharedKey); } } } } setPeers(origPeers); } } QVariantMap NetworkManager::WireGuardSetting::secretsToMap() const { QVariantMap secrets; if (!privateKey().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY), privateKey()); } NMVariantMapList peersSecrets; for (const QVariantMap &map : peers()) { if (map.contains(QLatin1String(NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY)) && map.contains(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY))) { QVariantMap newMap; newMap.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY), map.value(QLatin1String(NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY))); newMap.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY), map.value(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY))); peersSecrets << newMap; } } if (!peersSecrets.isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_WIREGUARD_PEERS), QVariant::fromValue(peersSecrets)); } return secrets; } void NetworkManager::WireGuardSetting::secretsFromStringMap(const NMStringMap &map) { QVariantMap secretsMap; NMVariantMapList peers; auto it = map.constBegin(); while (it != map.constEnd()) { if (it.key() == QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY)) { secretsMap.insert(it.key(), it.value()); } if (it.key().startsWith(QLatin1String(NM_SETTING_WIREGUARD_PEERS)) && it.key().endsWith(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY))) { QStringList peerStrList = it.key().split(QLatin1Char('.')); QVariantMap peer; peer.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY), peerStrList.at(1)); peer.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY), it.value()); peers << peer; } ++it; } if (!peers.isEmpty()) { secretsMap.insert(QLatin1String(NM_SETTING_WIREGUARD_PEERS), QVariant::fromValue(peers)); } secretsFromMap(secretsMap); } NMStringMap NetworkManager::WireGuardSetting::secretsToStringMap() const { NMStringMap ret; QVariantMap secretsMap = secretsToMap(); auto it = secretsMap.constBegin(); while (it != secretsMap.constEnd()) { if (it.key() == QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY)) { ret.insert(it.key(), it.value().toString()); } if (it.key() == QLatin1String(NM_SETTING_WIREGUARD_PEERS)) { NMVariantMapList listOfPeers = qdbus_cast(it.value()); for (const QVariantMap &map : listOfPeers) { const QString str = QStringLiteral("%1.%2.%3").arg(QLatin1String(NM_SETTING_WIREGUARD_PEERS)) .arg(map.value(QLatin1String(NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY)).toString()) .arg(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY)); ret.insert(str, map.value(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY)).toString()); } } ++it; } return ret; } QStringList NetworkManager::WireGuardSetting::needSecrets(bool requestNew) const { QStringList secrets; if (!privateKeyFlags().testFlag(Setting::NotRequired)) { if (privateKey().isEmpty() || requestNew) { secrets << QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY); } } for (const QVariantMap &map : peers()) { const QString presharedKey = map.value(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY)).toString(); SecretFlags preSharedKeyFlags = (SecretFlags) map.value(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY_FLAGS)).toInt(); if (!presharedKey.isEmpty()) { continue; } if (preSharedKeyFlags.testFlag(Setting::NotRequired)) { continue; } const QString str = QStringLiteral("%1.%2.%3").arg(QLatin1String(NM_SETTING_WIREGUARD_PEERS)) .arg(map.value(QLatin1String(NM_WIREGUARD_PEER_ATTR_PUBLIC_KEY)).toString()) .arg(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY)); secrets << str; } return secrets; } void NetworkManager::WireGuardSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_WIREGUARD_FWMARK))) { setFwmark(setting.value(QLatin1String(NM_SETTING_WIREGUARD_FWMARK)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_WIREGUARD_LISTEN_PORT))) { setListenPort(setting.value(QLatin1String(NM_SETTING_WIREGUARD_LISTEN_PORT)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_WIREGUARD_MTU))) { setMtu(setting.value(QLatin1String(NM_SETTING_WIREGUARD_MTU)).toInt()); } if (setting.contains(QLatin1String(NM_SETTING_WIREGUARD_PEER_ROUTES))) { setPeerRoutes(setting.value(QLatin1String(NM_SETTING_WIREGUARD_PEER_ROUTES)).toBool()); } if (setting.contains(QLatin1String(NM_SETTING_WIREGUARD_PEERS))) { setPeers(qdbus_cast(setting.value(QLatin1String(NM_SETTING_WIREGUARD_PEERS)))); } if (setting.contains(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY))) { setPrivateKey(setting.value(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY_FLAGS))) { setPrivateKeyFlags((SecretFlags)setting.value(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY_FLAGS)).toInt()); } } QVariantMap NetworkManager::WireGuardSetting::toMap() const { QVariantMap setting; setting.insert(QLatin1String(NM_SETTING_WIREGUARD_FWMARK), fwmark()); setting.insert(QLatin1String(NM_SETTING_WIREGUARD_LISTEN_PORT), listenPort()); setting.insert(QLatin1String(NM_SETTING_WIREGUARD_MTU), mtu()); setting.insert(QLatin1String(NM_SETTING_WIREGUARD_PEER_ROUTES), peerRoutes()); if (!peers().isEmpty()) { // FIXME we seem to have SecretFlags as an int, but NM expects an uint, while this is not // problem for rest of *-flags properties, it's problem for "preshared-key" which NM handless // as GVariant and asks for "u" when getting it's value NMVariantMapList fixedPeers = peers(); for (QVariantMap &map : fixedPeers) { if (map.contains(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY_FLAGS))) { map.insert(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY_FLAGS), map.value(QLatin1String(NM_WIREGUARD_PEER_ATTR_PRESHARED_KEY_FLAGS)).toUInt()); } } setting.insert(QLatin1String(NM_SETTING_WIREGUARD_PEERS), QVariant::fromValue(fixedPeers)); } if (!privateKey().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY), privateKey()); } setting.insert(QLatin1String(NM_SETTING_WIREGUARD_PRIVATE_KEY_FLAGS), (int)privateKeyFlags()); return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::WireGuardSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_WIREGUARD_FWMARK << ": " << setting.fwmark() << '\n'; dbg.nospace() << NM_SETTING_WIREGUARD_LISTEN_PORT << ": " << setting.listenPort() << '\n'; dbg.nospace() << NM_SETTING_WIREGUARD_MTU << ": " << setting.mtu() << '\n'; dbg.nospace() << NM_SETTING_WIREGUARD_PEER_ROUTES << ": " << setting.peerRoutes() << '\n'; dbg.nospace() << NM_SETTING_WIREGUARD_PEERS << ": " << setting.peers() << '\n'; dbg.nospace() << NM_SETTING_WIREGUARD_PRIVATE_KEY << ": " << setting.privateKey() << '\n'; dbg.nospace() << NM_SETTING_WIREGUARD_PRIVATE_KEY_FLAGS << ": " << setting.privateKeyFlags() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/wireguardsetting.h b/src/settings/wireguardsetting.h index 376a3ef..589b485 100644 --- a/src/settings/wireguardsetting.h +++ b/src/settings/wireguardsetting.h @@ -1,99 +1,85 @@ /* - Copyright 2019 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2019 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIREGUARD_SETTING_H #define NETWORKMANAGERQT_WIREGUARD_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class WireGuardSettingPrivate; /** * Represents generic setting */ class NETWORKMANAGERQT_EXPORT WireGuardSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; WireGuardSetting(); explicit WireGuardSetting(const Ptr &other); ~WireGuardSetting() override; QString name() const override; quint32 fwmark() const; void setFwmark(quint32 fwmark); quint32 listenPort() const; void setListenPort(quint32 port); quint32 mtu() const; void setMtu(quint32 mtu); bool peerRoutes() const; void setPeerRoutes(bool peerRoutes); NMVariantMapList peers() const; void setPeers(const NMVariantMapList &peers); QString privateKey() const; void setPrivateKey(const QString &key); SecretFlags privateKeyFlags() const; void setPrivateKeyFlags(SecretFlags flags); void secretsFromMap(const QVariantMap &secrets) override; QVariantMap secretsToMap() const override; void secretsFromStringMap(const NMStringMap &map) override; NMStringMap secretsToStringMap() const override; /* * Required "preshared-key" properties from "peers" property will be returned * as strings in format "peers.public-key.preshared-key". */ QStringList needSecrets(bool requestNew = false) const override; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: WireGuardSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(WireGuardSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const WireGuardSetting &setting); } #endif // NETWORKMANAGERQT_WIREGUARD_SETTING_H diff --git a/src/settings/wireguardsetting_p.h b/src/settings/wireguardsetting_p.h index 58061aa..9448b2a 100644 --- a/src/settings/wireguardsetting_p.h +++ b/src/settings/wireguardsetting_p.h @@ -1,48 +1,34 @@ /* - Copyright 2019 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2019 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIREGUARD_SETTING_P_H #define NETWORKMANAGERQT_WIREGUARD_SETTING_P_H #include namespace NetworkManager { class WireGuardSettingPrivate { public: WireGuardSettingPrivate(); QString name; quint32 fwmark; quint32 listenPort; quint32 mtu; bool peerRoutes; NMVariantMapList peers; QString privateKey; NetworkManager::Setting::SecretFlags privateKeyFlags; }; } #endif // NETWORKMANAGERQT_WIREGUARD_SETTING_P_H diff --git a/src/settings/wirelesssecuritysetting.cpp b/src/settings/wirelesssecuritysetting.cpp index 8e23b83..0e92406 100644 --- a/src/settings/wirelesssecuritysetting.cpp +++ b/src/settings/wirelesssecuritysetting.cpp @@ -1,715 +1,701 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wirelesssecuritysetting.h" #include "wirelesssecuritysetting_p.h" #include NetworkManager::WirelessSecuritySettingPrivate::WirelessSecuritySettingPrivate() : name(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) , keyMgmt(NetworkManager::WirelessSecuritySetting::Unknown) , wepTxKeyidx(0) , authAlg(NetworkManager::WirelessSecuritySetting::None) , wepKeyFlags(NetworkManager::Setting::None) , wepKeyType(NetworkManager::WirelessSecuritySetting::NotSpecified) , pskFlags(NetworkManager::Setting::None) , leapPasswordFlags(NetworkManager::Setting::None) { } NetworkManager::WirelessSecuritySetting::WirelessSecuritySetting() : Setting(Setting::WirelessSecurity) , d_ptr(new WirelessSecuritySettingPrivate()) { } NetworkManager::WirelessSecuritySetting::WirelessSecuritySetting(const Ptr &other) : Setting(other) , d_ptr(new WirelessSecuritySettingPrivate()) { setKeyMgmt(other->keyMgmt()); setWepTxKeyindex(other->wepTxKeyindex()); setAuthAlg(other->authAlg()); setProto(other->proto()); setPairwise(other->pairwise()); setGroup(other->group()); setWepKey0(other->wepKey0()); setWepKey1(other->wepKey1()); setWepKey2(other->wepKey2()); setWepKey3(other->wepKey3()); setWepKeyFlags(other->wepKeyFlags()); setWepKeyType(other->wepKeyType()); setPsk(other->psk()); setPskFlags(other->pskFlags()); setLeapPassword(other->leapPassword()); setLeapPasswordFlags(other->leapPasswordFlags()); } NetworkManager::WirelessSecuritySetting::~WirelessSecuritySetting() { delete d_ptr; } QString NetworkManager::WirelessSecuritySetting::name() const { Q_D(const WirelessSecuritySetting); return d->name; } void NetworkManager::WirelessSecuritySetting::setKeyMgmt(NetworkManager::WirelessSecuritySetting::KeyMgmt mgmt) { Q_D(WirelessSecuritySetting); d->keyMgmt = mgmt; } NetworkManager::WirelessSecuritySetting::KeyMgmt NetworkManager::WirelessSecuritySetting::keyMgmt() const { Q_D(const WirelessSecuritySetting); return d->keyMgmt; } void NetworkManager::WirelessSecuritySetting::setWepTxKeyindex(quint32 index) { Q_D(WirelessSecuritySetting); d->wepTxKeyidx = index; } quint32 NetworkManager::WirelessSecuritySetting::wepTxKeyindex() const { Q_D(const WirelessSecuritySetting); return d->wepTxKeyidx; } void NetworkManager::WirelessSecuritySetting::setAuthAlg(NetworkManager::WirelessSecuritySetting::AuthAlg alg) { Q_D(WirelessSecuritySetting); d->authAlg = alg; } NetworkManager::WirelessSecuritySetting::AuthAlg NetworkManager::WirelessSecuritySetting::authAlg() const { Q_D(const WirelessSecuritySetting); return d->authAlg; } void NetworkManager::WirelessSecuritySetting::setProto(const QList< NetworkManager::WirelessSecuritySetting::WpaProtocolVersion > &list) { Q_D(WirelessSecuritySetting); d->proto = list; } QList< NetworkManager::WirelessSecuritySetting::WpaProtocolVersion > NetworkManager::WirelessSecuritySetting::proto() const { Q_D(const WirelessSecuritySetting); return d->proto; } void NetworkManager::WirelessSecuritySetting::setPairwise(const QList< NetworkManager::WirelessSecuritySetting::WpaEncryptionCapabilities > &list) { Q_D(WirelessSecuritySetting); d->pairwise = list; } QList< NetworkManager::WirelessSecuritySetting::WpaEncryptionCapabilities > NetworkManager::WirelessSecuritySetting::pairwise() const { Q_D(const WirelessSecuritySetting); return d->pairwise; } void NetworkManager::WirelessSecuritySetting::setGroup(const QList< NetworkManager::WirelessSecuritySetting::WpaEncryptionCapabilities > &list) { Q_D(WirelessSecuritySetting); d->group = list; } QList< NetworkManager::WirelessSecuritySetting::WpaEncryptionCapabilities > NetworkManager::WirelessSecuritySetting::group() const { Q_D(const WirelessSecuritySetting); return d->group; } void NetworkManager::WirelessSecuritySetting::setLeapUsername(const QString &username) { Q_D(WirelessSecuritySetting); d->leapUsername = username; } QString NetworkManager::WirelessSecuritySetting::leapUsername() const { Q_D(const WirelessSecuritySetting); return d->leapUsername; } void NetworkManager::WirelessSecuritySetting::setWepKey0(const QString key) { Q_D(WirelessSecuritySetting); d->wepKey0 = key; } QString NetworkManager::WirelessSecuritySetting::wepKey0() const { Q_D(const WirelessSecuritySetting); return d->wepKey0; } void NetworkManager::WirelessSecuritySetting::setWepKey1(const QString key) { Q_D(WirelessSecuritySetting); d->wepKey1 = key; } QString NetworkManager::WirelessSecuritySetting::wepKey1() const { Q_D(const WirelessSecuritySetting); return d->wepKey1; } void NetworkManager::WirelessSecuritySetting::setWepKey2(const QString key) { Q_D(WirelessSecuritySetting); d->wepKey2 = key; } QString NetworkManager::WirelessSecuritySetting::wepKey2() const { Q_D(const WirelessSecuritySetting); return d->wepKey2; } void NetworkManager::WirelessSecuritySetting::setWepKey3(const QString key) { Q_D(WirelessSecuritySetting); d->wepKey3 = key; } QString NetworkManager::WirelessSecuritySetting::wepKey3() const { Q_D(const WirelessSecuritySetting); return d->wepKey3; } void NetworkManager::WirelessSecuritySetting::setWepKeyFlags(NetworkManager::Setting::SecretFlags type) { Q_D(WirelessSecuritySetting); d->wepKeyFlags = type; } NetworkManager::Setting::SecretFlags NetworkManager::WirelessSecuritySetting::wepKeyFlags() const { Q_D(const WirelessSecuritySetting); return d->wepKeyFlags; } void NetworkManager::WirelessSecuritySetting::setWepKeyType(NetworkManager::WirelessSecuritySetting::WepKeyType type) { Q_D(WirelessSecuritySetting); d->wepKeyType = type; } NetworkManager::WirelessSecuritySetting::WepKeyType NetworkManager::WirelessSecuritySetting::wepKeyType() const { Q_D(const WirelessSecuritySetting); return d->wepKeyType; } void NetworkManager::WirelessSecuritySetting::setPsk(const QString &key) { Q_D(WirelessSecuritySetting); d->psk = key; } QString NetworkManager::WirelessSecuritySetting::psk() const { Q_D(const WirelessSecuritySetting); return d->psk; } void NetworkManager::WirelessSecuritySetting::setPskFlags(NetworkManager::Setting::SecretFlags type) { Q_D(WirelessSecuritySetting); d->pskFlags = type; } NetworkManager::Setting::SecretFlags NetworkManager::WirelessSecuritySetting::pskFlags() const { Q_D(const WirelessSecuritySetting); return d->pskFlags; } void NetworkManager::WirelessSecuritySetting::setLeapPassword(const QString &password) { Q_D(WirelessSecuritySetting); d->leapPassword = password; } QString NetworkManager::WirelessSecuritySetting::leapPassword() const { Q_D(const WirelessSecuritySetting); return d->leapPassword; } void NetworkManager::WirelessSecuritySetting::setLeapPasswordFlags(NetworkManager::Setting::SecretFlags type) { Q_D(WirelessSecuritySetting); d->leapPasswordFlags = type; } NetworkManager::Setting::SecretFlags NetworkManager::WirelessSecuritySetting::leapPasswordFlags() const { Q_D(const WirelessSecuritySetting); return d->leapPasswordFlags; } void NetworkManager::WirelessSecuritySetting::secretsFromMap(const QVariantMap &secrets) { if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0))) { setWepKey0(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)).toString()); } if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1))) { setWepKey1(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)).toString()); } if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2))) { setWepKey2(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)).toString()); } if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3))) { setWepKey3(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)).toString()); } if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK))) { setPsk(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK)).toString()); } if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD))) { setLeapPassword(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD)).toString()); } } QVariantMap NetworkManager::WirelessSecuritySetting::secretsToMap() const { QVariantMap secrets; if (!wepKey0().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), wepKey0()); } if (!wepKey1().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), wepKey1()); } if (!wepKey2().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), wepKey2()); } if (!wepKey3().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), wepKey3()); } if (!psk().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK), psk()); } if (!leapPassword().isEmpty()) { secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), leapPassword()); } return secrets; } QStringList NetworkManager::WirelessSecuritySetting::needSecrets(bool requestNew) const { QStringList secrets; if (keyMgmt() == Wep) { if (!wepKeyFlags().testFlag(Setting::NotRequired)) { switch (wepTxKeyindex()) { case 0: if (wepKey0().isEmpty() || requestNew) { secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0); return secrets; } break; case 1: if (wepKey1().isEmpty() || requestNew) { secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1); return secrets; } break; case 2: if (wepKey2().isEmpty() || requestNew) { secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2); return secrets; } break; case 3: if (wepKey3().isEmpty() || requestNew) { secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3); return secrets; } break; } } } if (keyMgmt() == WpaNone || keyMgmt() == WpaPsk || keyMgmt() == SAE) { if (!pskFlags().testFlag(Setting::NotRequired)) { if (psk().isEmpty() || requestNew) { secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK); return secrets; } } } if (authAlg() == Leap && keyMgmt() == Ieee8021x) { if (!leapPasswordFlags().testFlag(Setting::NotRequired)) { if (leapPassword().isEmpty() || requestNew) { secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD); return secrets; } } } return secrets; } void NetworkManager::WirelessSecuritySetting::fromMap(const QVariantMap &map) { if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT))) { const QString key = map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT)).toString(); if (key == "none") { setKeyMgmt(Wep); } else if (key == "ieee8021x") { setKeyMgmt(Ieee8021x); } else if (key == "wpa-none") { setKeyMgmt(WpaNone); } else if (key == "wpa-psk") { setKeyMgmt(WpaPsk); } else if (key == "wpa-eap") { setKeyMgmt(WpaEap); } else if (key == "sae") { setKeyMgmt(SAE); } } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX))) { setWepTxKeyindex(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX)).toUInt()); } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG))) { const QString alg = map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG)).toString(); if (alg == "open") { setAuthAlg(Open); } else if (alg == "shared") { setAuthAlg(Shared); } else if (alg == "leap") { setAuthAlg(Leap); } } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PROTO))) { const QStringList strList = map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PROTO)).toStringList(); QList list; Q_FOREACH (const QString & str, strList) { if (str == "wpa") { list.push_back(Wpa); } else if (str == "rsn") { list.push_back(Rsn); } } setProto(list); } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PAIRWISE))) { const QStringList strList = map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PAIRWISE)).toStringList(); QList list; Q_FOREACH (const QString & str, strList) { if (str == "wep40") { list.push_back(Wep40); } else if (str == "wep104") { list.push_back(Wep104); } else if (str == "tkip") { list.push_back(Tkip); } else if (str == "ccmp") { list.push_back(Ccmp); } } setPairwise(list); } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_GROUP))) { const QStringList strList = map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_GROUP)).toStringList(); QList list; Q_FOREACH (const QString & str, strList) { if (str == "wep40") { list.push_back(Wep40); } else if (str == "wep104") { list.push_back(Wep104); } else if (str == "tkip") { list.push_back(Tkip); } else if (str == "ccmp") { list.push_back(Ccmp); } } setGroup(list); } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME))) { setLeapUsername(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME)).toString()); } // Secrets if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0))) { setWepKey0(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)).toString()); } // Secrets if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1))) { setWepKey1(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)).toString()); } // Secrets if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2))) { setWepKey2(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)).toString()); } // Secrets if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3))) { setWepKey3(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)).toString()); } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS))) { setWepKeyFlags((SecretFlags)map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS)).toInt()); } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE))) { setWepKeyType((WepKeyType)map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE)).toUInt()); } // Secrets if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK))) { setPsk(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK)).toString()); } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS))) { setPskFlags((SecretFlags)map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS)).toInt()); } // Secrets if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD))) { setLeapPassword(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD)).toString()); } if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS))) { setLeapPasswordFlags((SecretFlags)map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS)).toInt()); } } QVariantMap NetworkManager::WirelessSecuritySetting::toMap() const { QVariantMap setting; if (keyMgmt() == Wep) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "none"); } else if (keyMgmt() == Ieee8021x) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "ieee8021x"); } else if (keyMgmt() == WpaNone) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-none"); } else if (keyMgmt() == WpaPsk) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-psk"); } else if (keyMgmt() == WpaEap) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-eap"); } else if (keyMgmt() == SAE) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "sae"); } if (wepTxKeyindex()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), wepTxKeyindex()); } if (authAlg() != None) { if (authAlg() == Open) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "open"); } else if (authAlg() == Shared) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "shared"); } else if (authAlg() == Leap) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "leap"); } } if (!proto().isEmpty()) { QStringList strList; Q_FOREACH (const WpaProtocolVersion & version, proto()) { if (version == Wpa) { strList << "wpa"; } else if (version == Rsn) { strList << "rsn"; } } setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PROTO), strList); } if (!pairwise().isEmpty()) { QStringList strList; Q_FOREACH (const WpaEncryptionCapabilities & capability, pairwise()) { if (capability == Wep40) { strList << "wep40"; } else if (capability == Wep104) { strList << "wep104"; } else if (capability == Tkip) { strList << "tkip"; } else if (capability == Ccmp) { strList << "ccmp"; } } setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PAIRWISE), strList); } if (!group().isEmpty()) { QStringList strList; Q_FOREACH (const WpaEncryptionCapabilities & capability, group()) { if (capability == Wep40) { strList << "wep40"; } else if (capability == Wep104) { strList << "wep104"; } else if (capability == Tkip) { strList << "tkip"; } else if (capability == Ccmp) { strList << "ccmp"; } } setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_GROUP), strList); } if (!leapUsername().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), leapUsername()); } // Secrets if (!wepKey0().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), wepKey0()); } // Secrets if (!wepKey1().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), wepKey1()); } // Secrets if (!wepKey2().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), wepKey2()); } // Secrets if (!wepKey3().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), wepKey3()); } if (wepKeyFlags()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS), (int)wepKeyFlags()); } if (wepKeyType()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE), wepKeyType()); } // Secrets if (!psk().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK), psk()); } if (pskFlags()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS), (int)pskFlags()); } // Secrets if (!leapPassword().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), leapPassword()); } if (leapPasswordFlags()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS), (int)leapPasswordFlags()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::WirelessSecuritySetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_KEY_MGMT << ": " << setting.keyMgmt() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX << ": " << setting.wepTxKeyindex() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_AUTH_ALG << ": " << setting.authAlg() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_PROTO << ": " << setting.proto() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_PAIRWISE << ": " << setting.pairwise() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_GROUP << ": " << setting.group() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME << ": " << setting.leapUsername() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY0 << ": " << setting.wepKey0() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY1 << ": " << setting.wepKey1() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY2 << ": " << setting.wepKey2() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY3 << ": " << setting.wepKey3() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS << ": " << setting.wepKeyFlags() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE << ": " << setting.wepKeyType() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_PSK << ": " << setting.psk() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS << ": " << setting.pskFlags() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD << ": " << setting.leapPassword() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS << ": " << setting.leapPasswordFlags() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/wirelesssecuritysetting.h b/src/settings/wirelesssecuritysetting.h index c3c1773..767956d 100644 --- a/src/settings/wirelesssecuritysetting.h +++ b/src/settings/wirelesssecuritysetting.h @@ -1,126 +1,112 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRELESSSECURITY_SETTING_H #define NETWORKMANAGERQT_WIRELESSSECURITY_SETTING_H #include #include "setting.h" #include namespace NetworkManager { class WirelessSecuritySettingPrivate; /** * Represents wireless security setting */ class NETWORKMANAGERQT_EXPORT WirelessSecuritySetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum KeyMgmt {Unknown = -1, Wep, Ieee8021x, WpaNone, WpaPsk, WpaEap, SAE}; enum AuthAlg {None, Open, Shared, Leap}; enum WpaProtocolVersion {Wpa, Rsn}; enum WpaEncryptionCapabilities {Wep40, Wep104, Tkip, Ccmp}; enum WepKeyType {NotSpecified, Hex, Passphrase}; WirelessSecuritySetting(); explicit WirelessSecuritySetting(const Ptr &other); ~WirelessSecuritySetting() override; QString name() const override; void setKeyMgmt(KeyMgmt mgmt); KeyMgmt keyMgmt() const; void setWepTxKeyindex(quint32 index); quint32 wepTxKeyindex() const; void setAuthAlg(AuthAlg alg); AuthAlg authAlg() const; void setProto(const QList &list); QList proto() const; void setPairwise(const QList &list); QList pairwise() const; void setGroup(const QList &list); QList group() const; void setLeapUsername(const QString &username); QString leapUsername() const; void setWepKey0(const QString key); QString wepKey0() const; void setWepKey1(const QString key); QString wepKey1() const; void setWepKey2(const QString key); QString wepKey2() const; void setWepKey3(const QString key); QString wepKey3() const; void setWepKeyFlags(SecretFlags type); SecretFlags wepKeyFlags() const; void setWepKeyType(WepKeyType type); WepKeyType wepKeyType() const; void setPsk(const QString &key); QString psk() const; void setPskFlags(SecretFlags type); SecretFlags pskFlags() const; void setLeapPassword(const QString &password); QString leapPassword() const; void setLeapPasswordFlags(SecretFlags type); SecretFlags leapPasswordFlags() const; void secretsFromMap(const QVariantMap &secrets) override; QVariantMap secretsToMap() const override; QStringList needSecrets(bool requestNew = false) const override; void fromMap(const QVariantMap &map) override; QVariantMap toMap() const override; protected: WirelessSecuritySettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(WirelessSecuritySetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const WirelessSecuritySetting &setting); } #endif // NETWORKMANAGERQT_WIRELESSSECURITY_SETTING_H diff --git a/src/settings/wirelesssecuritysetting_p.h b/src/settings/wirelesssecuritysetting_p.h index 5d10a08..445074c 100644 --- a/src/settings/wirelesssecuritysetting_p.h +++ b/src/settings/wirelesssecuritysetting_p.h @@ -1,58 +1,44 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRELESSSECURITY_SETTING_P_H #define NETWORKMANAGERQT_WIRELESSSECURITY_SETTING_P_H #include #include namespace NetworkManager { class WirelessSecuritySettingPrivate { public: WirelessSecuritySettingPrivate(); QString name; NetworkManager::WirelessSecuritySetting::KeyMgmt keyMgmt; quint32 wepTxKeyidx; NetworkManager::WirelessSecuritySetting::AuthAlg authAlg; QList proto; QList pairwise; QList group; QString leapUsername; QString wepKey0; QString wepKey1; QString wepKey2; QString wepKey3; NetworkManager::Setting::SecretFlags wepKeyFlags; NetworkManager::WirelessSecuritySetting::WepKeyType wepKeyType; QString psk; NetworkManager::Setting::SecretFlags pskFlags; QString leapPassword; NetworkManager::Setting::SecretFlags leapPasswordFlags; }; } #endif // NETWORKMANAGERQT_WIRELESSSECURITY_SETTING_P_H diff --git a/src/settings/wirelesssetting.cpp b/src/settings/wirelesssetting.cpp index ab1ca48..3dcadc2 100644 --- a/src/settings/wirelesssetting.cpp +++ b/src/settings/wirelesssetting.cpp @@ -1,528 +1,514 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wirelesssetting.h" #include "wirelesssetting_p.h" #include "utils.h" //define the deprecated&dropped values #define NM_SETTING_WIRELESS_SEC "security" #define NM_SETTING_WIRELESS_ASSIGNED_MAC_ADDRESS "assigned-mac-address" #include NetworkManager::WirelessSettingPrivate::WirelessSettingPrivate() : name(NM_SETTING_WIRELESS_SETTING_NAME) , mode(NetworkManager::WirelessSetting::Infrastructure) , band(NetworkManager::WirelessSetting::Automatic) , channel(0) , rate(0) , txPower(0) , mtu(0) , hidden(false) , macAddressRandomization(NetworkManager::Setting::MacAddressRandomizationDefault) , powersave(NetworkManager::WirelessSetting::PowerSaveDefault) { } NetworkManager::WirelessSetting::WirelessSetting() : Setting(Setting::Wireless) , d_ptr(new WirelessSettingPrivate()) { } NetworkManager::WirelessSetting::WirelessSetting(const Ptr &setting) : Setting(setting) , d_ptr(new WirelessSettingPrivate) { setSsid(setting->ssid()); setMode(setting->mode()); setBand(setting->band()); setChannel(setting->channel()); setBssid(setting->bssid()); setRate(setting->rate()); setTxPower(setting->txPower()); setMacAddress(setting->macAddress()); setGenerateMacAddressMask(setting->generateMacAddressMask()); setClonedMacAddress(setting->clonedMacAddress()); setMacAddressBlacklist(setting->macAddressBlacklist()); setMacAddressRandomization(setting->macAddressRandomization()); setMtu(setting->mtu()); setSeenBssids(setting->seenBssids()); setPowerSave(setting->powerSave()); setSecurity(setting->security()); setHidden(setting->hidden()); setAssignedMacAddress(setting->assignedMacAddress()); } NetworkManager::WirelessSetting::~WirelessSetting() { delete d_ptr; } QString NetworkManager::WirelessSetting::name() const { Q_D(const WirelessSetting); return d->name; } void NetworkManager::WirelessSetting::setSsid(const QByteArray &ssid) { Q_D(WirelessSetting); d->ssid = ssid; } QByteArray NetworkManager::WirelessSetting::ssid() const { Q_D(const WirelessSetting); return d->ssid; } void NetworkManager::WirelessSetting::setMode(NetworkManager::WirelessSetting::NetworkMode mode) { Q_D(WirelessSetting); d->mode = mode; } NetworkManager::WirelessSetting::NetworkMode NetworkManager::WirelessSetting::mode() const { Q_D(const WirelessSetting); return d->mode; } void NetworkManager::WirelessSetting::setBand(NetworkManager::WirelessSetting::FrequencyBand band) { Q_D(WirelessSetting); d->band = band; } NetworkManager::WirelessSetting::FrequencyBand NetworkManager::WirelessSetting::band() const { Q_D(const WirelessSetting); return d->band; } void NetworkManager::WirelessSetting::setChannel(quint32 channel) { Q_D(WirelessSetting); d->channel = channel; } quint32 NetworkManager::WirelessSetting::channel() const { Q_D(const WirelessSetting); return d->channel; } void NetworkManager::WirelessSetting::setBssid(const QByteArray &bssid) { Q_D(WirelessSetting); d->bssid = bssid; } QByteArray NetworkManager::WirelessSetting::bssid() const { Q_D(const WirelessSetting); return d->bssid; } void NetworkManager::WirelessSetting::setRate(quint32 rate) { Q_D(WirelessSetting); d->rate = rate; } quint32 NetworkManager::WirelessSetting::rate() const { Q_D(const WirelessSetting); return d->rate; } void NetworkManager::WirelessSetting::setTxPower(quint32 power) { Q_D(WirelessSetting); d->txPower = power; } quint32 NetworkManager::WirelessSetting::txPower() const { Q_D(const WirelessSetting); return d->txPower; } void NetworkManager::WirelessSetting::setAssignedMacAddress(const QString &assignedMacAddress) { Q_D(WirelessSetting); d->assignedMacAddress = assignedMacAddress; } QString NetworkManager::WirelessSetting::assignedMacAddress() const { Q_D(const WirelessSetting); return d->assignedMacAddress; } void NetworkManager::WirelessSetting::setMacAddress(const QByteArray &address) { Q_D(WirelessSetting); d->macAddress = address; } QByteArray NetworkManager::WirelessSetting::macAddress() const { Q_D(const WirelessSetting); return d->macAddress; } void NetworkManager::WirelessSetting::setClonedMacAddress(const QByteArray &address) { Q_D(WirelessSetting); d->assignedMacAddress = NetworkManager::macAddressAsString(address); } QByteArray NetworkManager::WirelessSetting::clonedMacAddress() const { Q_D(const WirelessSetting); return NetworkManager::macAddressFromString(d->assignedMacAddress.toUtf8()); } void NetworkManager::WirelessSetting::setGenerateMacAddressMask(const QString& macAddressMask) { Q_D(WirelessSetting); d->generateMacAddressMask = macAddressMask; } QString NetworkManager::WirelessSetting::generateMacAddressMask() const { Q_D(const WirelessSetting); return d->generateMacAddressMask; } void NetworkManager::WirelessSetting::setMacAddressBlacklist(const QStringList &list) { Q_D(WirelessSetting); d->macAddressBlacklist = list; } QStringList NetworkManager::WirelessSetting::macAddressBlacklist() const { Q_D(const WirelessSetting); return d->macAddressBlacklist; } void NetworkManager::WirelessSetting::setMacAddressRandomization(NetworkManager::Setting::MacAddressRandomization randomization) { Q_D(WirelessSetting); d->macAddressRandomization = randomization; } NetworkManager::Setting::MacAddressRandomization NetworkManager::WirelessSetting::macAddressRandomization() const { Q_D(const WirelessSetting); return d->macAddressRandomization; } void NetworkManager::WirelessSetting::setMtu(quint32 mtu) { Q_D(WirelessSetting); d->mtu = mtu; } quint32 NetworkManager::WirelessSetting::mtu() const { Q_D(const WirelessSetting); return d->mtu; } void NetworkManager::WirelessSetting::setSeenBssids(const QStringList &list) { Q_D(WirelessSetting); d->seenBssids = list; } QStringList NetworkManager::WirelessSetting::seenBssids() const { Q_D(const WirelessSetting); return d->seenBssids; } void NetworkManager::WirelessSetting::setPowerSave(NetworkManager::WirelessSetting::PowerSave powersave) { Q_D(WirelessSetting); d->powersave = powersave; } NetworkManager::WirelessSetting::PowerSave NetworkManager::WirelessSetting::powerSave() const { Q_D(const WirelessSetting); return d->powersave; } void NetworkManager::WirelessSetting::setSecurity(const QString &security) { Q_D(WirelessSetting); d->security = security; } QString NetworkManager::WirelessSetting::security() const { Q_D(const WirelessSetting); return d->security; } void NetworkManager::WirelessSetting::setHidden(bool hidden) { Q_D(WirelessSetting); d->hidden = hidden; } bool NetworkManager::WirelessSetting::hidden() const { Q_D(const WirelessSetting); return d->hidden; } void NetworkManager::WirelessSetting::fromMap(const QVariantMap &setting) { if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_SSID))) { setSsid(setting.value(QLatin1String(NM_SETTING_WIRELESS_SSID)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_MODE))) { const QString mode = setting.value(QLatin1String(NM_SETTING_WIRELESS_MODE)).toString(); if (mode == QLatin1String(NM_SETTING_WIRELESS_MODE_INFRA)) { setMode(Infrastructure); } else if (mode == QLatin1String(NM_SETTING_WIRELESS_MODE_ADHOC)) { setMode(Adhoc); } else if (mode == QLatin1String(NM_SETTING_WIRELESS_MODE_AP)) { setMode(Ap); } } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_BAND))) { const QString band = setting.value(QLatin1String(NM_SETTING_WIRELESS_BAND)).toString(); if (band == "a") { setBand(A); } else if (band == "bg") { setBand(Bg); } } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_CHANNEL))) { setChannel(setting.value(QLatin1String(NM_SETTING_WIRELESS_CHANNEL)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_BSSID))) { setBssid(setting.value(QLatin1String(NM_SETTING_WIRELESS_BSSID)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_RATE))) { setRate(setting.value(QLatin1String(NM_SETTING_WIRELESS_RATE)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_TX_POWER))) { setTxPower(setting.value(QLatin1String(NM_SETTING_WIRELESS_TX_POWER)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_ASSIGNED_MAC_ADDRESS))) { setAssignedMacAddress(setting.value(QLatin1String(NM_SETTING_WIRELESS_ASSIGNED_MAC_ADDRESS)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS))) { setMacAddress(setting.value(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK))) { setGenerateMacAddressMask(setting.value(QLatin1String(NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS))) { setClonedMacAddress(setting.value(QLatin1String(NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS)).toByteArray()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST))) { setMacAddressBlacklist(setting.value(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST)).toStringList()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION))) { setMacAddressRandomization(static_cast(setting.value(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION)).toUInt())); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_MTU))) { setMtu(setting.value(QLatin1String(NM_SETTING_WIRELESS_MTU)).toUInt()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_SEEN_BSSIDS))) { setSeenBssids(setting.value(QLatin1String(NM_SETTING_WIRELESS_SEEN_BSSIDS)).toStringList()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_POWERSAVE))) { setPowerSave(static_cast(setting.value(QLatin1String(NM_SETTING_WIRELESS_POWERSAVE)).toUInt())); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_SEC))) { setSecurity(setting.value(QLatin1String(NM_SETTING_WIRELESS_SEC)).toString()); } if (setting.contains(QLatin1String(NM_SETTING_WIRELESS_HIDDEN))) { setHidden(setting.value(QLatin1String(NM_SETTING_WIRELESS_HIDDEN)).toBool()); } } QVariantMap NetworkManager::WirelessSetting::toMap() const { QVariantMap setting; if (!ssid().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SSID), ssid()); } if (mode() == Infrastructure) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_MODE), QLatin1String(NM_SETTING_WIRELESS_MODE_INFRA)); } else if (mode() == Adhoc) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_MODE), QLatin1String(NM_SETTING_WIRELESS_MODE_ADHOC)); } else if (mode() == Ap) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_MODE), QLatin1String(NM_SETTING_WIRELESS_MODE_AP)); } if (band() != Automatic) { if (band() == A) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_BAND), "a"); } else if (band() == Bg) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_BAND), "bg"); } } if (channel()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_CHANNEL), channel()); } if (!bssid().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_BSSID), bssid()); } if (rate()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_RATE), rate()); } if (txPower()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_TX_POWER), txPower()); } if (!assignedMacAddress().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_ASSIGNED_MAC_ADDRESS), assignedMacAddress()); } if (!macAddress().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS), macAddress()); } if (!generateMacAddressMask().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK), generateMacAddressMask()); } if (!macAddressBlacklist().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST), macAddressBlacklist()); } setting.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION), macAddressRandomization()); if (mtu()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_MTU), mtu()); } if (!seenBssids().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SEEN_BSSIDS), seenBssids()); } setting.insert(QLatin1String(NM_SETTING_WIRELESS_POWERSAVE), powerSave()); if (!security().isEmpty()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_SEC), security()); } if (hidden()) { setting.insert(QLatin1String(NM_SETTING_WIRELESS_HIDDEN), hidden()); } return setting; } QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::WirelessSetting &setting) { dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SSID << ": " << setting.ssid() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_MODE << ": " << setting.mode() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_BAND << ": " << setting.band() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_CHANNEL << ": " << setting.channel() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_BSSID << ": " << setting.bssid() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_RATE << ": " << setting.rate() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_TX_POWER << ": " << setting.txPower() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_ASSIGNED_MAC_ADDRESS << ": " << setting.assignedMacAddress() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_MAC_ADDRESS << ": " << setting.macAddress() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK << ": " << setting.generateMacAddressMask() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST << ": " << setting.macAddressBlacklist() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION << ": " << setting.macAddressRandomization() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_MTU << ": " << setting.mtu() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SEEN_BSSIDS << ": " << setting.seenBssids() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_POWERSAVE << ": " << setting.powerSave() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_SEC << ": " << setting.security() << '\n'; dbg.nospace() << NM_SETTING_WIRELESS_HIDDEN << ": " << setting.hidden() << '\n'; return dbg.maybeSpace(); } diff --git a/src/settings/wirelesssetting.h b/src/settings/wirelesssetting.h index b906f93..9bd3256 100644 --- a/src/settings/wirelesssetting.h +++ b/src/settings/wirelesssetting.h @@ -1,141 +1,127 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRELESS_SETTING_H #define NETWORKMANAGERQT_WIRELESS_SETTING_H #include #include "setting.h" #include #include namespace NetworkManager { class WirelessSettingPrivate; /** * Represents wireless setting */ class NETWORKMANAGERQT_EXPORT WirelessSetting : public Setting { public: typedef QSharedPointer Ptr; typedef QList List; enum NetworkMode { Infrastructure, Adhoc, Ap }; enum FrequencyBand { Automatic, A, Bg }; enum PowerSave { PowerSaveDefault = 0, PowerSaveIgnore = 1, PowerSaveDisable = 2, PowerSaveEnable = 3 }; WirelessSetting(); explicit WirelessSetting(const Ptr &setting); ~WirelessSetting() override; QString name() const override; void setSsid(const QByteArray &ssid); QByteArray ssid() const; void setMode(NetworkMode mode); NetworkMode mode() const; void setBand(FrequencyBand band); FrequencyBand band() const; void setChannel(quint32 channel); quint32 channel() const; void setBssid(const QByteArray &bssid); QByteArray bssid() const; void setRate(quint32 rate); quint32 rate() const; void setTxPower(quint32 power); quint32 txPower() const; void setAssignedMacAddress(const QString &assignedMacAddress); QString assignedMacAddress() const; void setMacAddress(const QByteArray &address); QByteArray macAddress() const; /// @deprecated since NM 1.4.0, will internally use assigned-mac-address property void setClonedMacAddress(const QByteArray &address); QByteArray clonedMacAddress() const; void setGenerateMacAddressMask(const QString &macAddressMask); QString generateMacAddressMask() const; void setMacAddressBlacklist(const QStringList &list); QStringList macAddressBlacklist() const; void setMacAddressRandomization(MacAddressRandomization randomization); MacAddressRandomization macAddressRandomization() const; void setMtu(quint32 mtu); quint32 mtu() const; void setSeenBssids(const QStringList &list); QStringList seenBssids() const; void setPowerSave(PowerSave powersave); PowerSave powerSave() const; /// @deprecated since NM 1.0.0 void setSecurity(const QString &security); QString security() const; void setHidden(bool hidden); bool hidden() const; void fromMap(const QVariantMap &setting) override; QVariantMap toMap() const override; protected: WirelessSettingPrivate *d_ptr; private: Q_DECLARE_PRIVATE(WirelessSetting) }; NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const WirelessSetting &setting); } #endif // NETWORKMANAGERQT_WIRELESS_SETTING_H diff --git a/src/settings/wirelesssetting_p.h b/src/settings/wirelesssetting_p.h index 2ed47ed..cd572cd 100644 --- a/src/settings/wirelesssetting_p.h +++ b/src/settings/wirelesssetting_p.h @@ -1,58 +1,44 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRELESS_SETTING_P_H #define NETWORKMANAGERQT_WIRELESS_SETTING_P_H #include namespace NetworkManager { class WirelessSettingPrivate { public: WirelessSettingPrivate(); QString name; QByteArray ssid; NetworkManager::WirelessSetting::NetworkMode mode; NetworkManager::WirelessSetting::FrequencyBand band; quint32 channel; QByteArray bssid; quint32 rate; quint32 txPower; QByteArray macAddress; QByteArray clonedMacAddress; QStringList macAddressBlacklist; quint32 mtu; QStringList seenBssids; QString security; bool hidden; QString generateMacAddressMask; NetworkManager::Setting::MacAddressRandomization macAddressRandomization; NetworkManager::WirelessSetting::PowerSave powersave; QString assignedMacAddress; }; } #endif // NETWORKMANAGERQT_WIRELESS_SETTING_P_H diff --git a/src/settings_p.h b/src/settings_p.h index 9e313d4..3cf202c 100644 --- a/src/settings_p.h +++ b/src/settings_p.h @@ -1,70 +1,56 @@ /* - Copyright 2011 Ilia Kats - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_SETTINGS_P_H #define NETWORKMANAGERQT_SETTINGS_P_H #include #include "dbus/settingsinterface.h" #include "settings.h" class QDBusPendingCallWatcher; namespace NetworkManager { class SettingsPrivate : public NetworkManager::SettingsNotifier { Q_OBJECT friend class NetworkManagerPrivate; public: SettingsPrivate(); Connection::List listConnections(); NetworkManager::Connection::Ptr findConnectionByUuid(const QString &uuid); QString hostname() const; bool canModify() const; QDBusPendingReply addConnection(const NMVariantMapMap &); QDBusPendingReply addConnectionUnsaved(const NMVariantMapMap &); QDBusPendingReply loadConnections(const QStringList &filenames); void saveHostname(const QString &); QDBusPendingReply reloadConnections(); Connection::Ptr findRegisteredConnection(const QString &); OrgFreedesktopNetworkManagerSettingsInterface iface; QMap connections; bool m_canModify; QString m_hostname; protected Q_SLOTS: void onConnectionAdded(const QDBusObjectPath &); void onConnectionRemoved(const QDBusObjectPath &); void onConnectionRemoved(const QString &); void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); void propertiesChanged(const QVariantMap &properties); void initNotifier(); protected: void daemonUnregistered(); void init(); }; } #endif diff --git a/src/teamdevice.cpp b/src/teamdevice.cpp index 62254f5..7b63c97 100644 --- a/src/teamdevice.cpp +++ b/src/teamdevice.cpp @@ -1,113 +1,99 @@ /* - Copyright 2013 Lukáš Tinkl - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2013 Lukáš Tinkl + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "teamdevice_p.h" #include "device_p.h" #include "manager.h" #include "manager_p.h" NetworkManager::TeamDevicePrivate::TeamDevicePrivate(const QString &path, TeamDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::TeamDevicePrivate::~TeamDevicePrivate() { } NetworkManager::TeamDevice::TeamDevice(const QString &path, QObject *parent) : Device(*new TeamDevicePrivate(path, this), parent) { Q_D(TeamDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::TeamDevice::~TeamDevice() { } NetworkManager::Device::Type NetworkManager::TeamDevice::type() const { return NetworkManager::Device::Team; } bool NetworkManager::TeamDevice::carrier() const { Q_D(const TeamDevice); return d->carrier; } QString NetworkManager::TeamDevice::hwAddress() const { Q_D(const TeamDevice); return d->hwAddress; } QStringList NetworkManager::TeamDevice::slaves() const { Q_D(const TeamDevice); return d->slaves; } QString NetworkManager::TeamDevice::config() const { Q_D(const TeamDevice); return d->config; } void NetworkManager::TeamDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(TeamDevice); if (property == QLatin1String("Carrier")) { carrier = value.toBool(); Q_EMIT q->carrierChanged(carrier); } else if (property == QLatin1String("HwAddress")) { hwAddress = value.toString(); Q_EMIT q->hwAddressChanged(hwAddress); } else if (property == QLatin1String("Slaves")) { QStringList list; Q_FOREACH (const QDBusObjectPath & op, qdbus_cast< QList >(value)) { list << op.path(); } slaves = list; Q_EMIT q->slavesChanged(slaves); } else if (property == QLatin1String("Config")) { config = value.toString(); Q_EMIT q->configChanged(config); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/teamdevice.h b/src/teamdevice.h index 98f6af6..3f3397e 100644 --- a/src/teamdevice.h +++ b/src/teamdevice.h @@ -1,97 +1,83 @@ /* - Copyright 2013 Lukáš Tinkl - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2013 Lukáš Tinkl + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TEAM_DEVICE_H #define NETWORKMANAGERQT_TEAM_DEVICE_H #include "device.h" #include namespace NetworkManager { class TeamDevicePrivate; /** * A team device interface */ class NETWORKMANAGERQT_EXPORT TeamDevice : public Device { Q_OBJECT Q_PROPERTY(bool carrier READ carrier NOTIFY carrierChanged) Q_PROPERTY(QString hwAddress READ hwAddress NOTIFY hwAddressChanged) Q_PROPERTY(QStringList slaves READ slaves NOTIFY slavesChanged) Q_PROPERTY(QString config READ config NOTIFY configChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit TeamDevice(const QString &path, QObject *parent = nullptr); ~TeamDevice() override; Type type() const override; /** * Indicates whether the physical carrier is found */ bool carrier() const; /** * Hardware address of the device */ QString hwAddress() const; /** * Devices which are currently slaved to this device */ QStringList slaves() const; /** * The JSON configuration currently applied on the device. */ QString config() const; Q_SIGNALS: /** * Emitted when the carrier of this device has changed */ void carrierChanged(bool plugged); /** * Emitted when the hardware address of this device has changed */ void hwAddressChanged(const QString &address); /** * Emitted when the list of devices slaved to this device has changed */ void slavesChanged(const QStringList &slaves); /** * Emitted when the JSON confugration which is currently applied has changed */ void configChanged(const QString &config); private: Q_DECLARE_PRIVATE(TeamDevice) }; } #endif diff --git a/src/teamdevice_p.h b/src/teamdevice_p.h index b7f79a0..748e250 100644 --- a/src/teamdevice_p.h +++ b/src/teamdevice_p.h @@ -1,58 +1,44 @@ /* - Copyright 2012-2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TEAM_DEVICE_P_H #define NETWORKMANAGERQT_TEAM_DEVICE_P_H #include "teamdevice.h" #include "device_p.h" #include "manager.h" #include "manager_p.h" #include "teamdeviceinterface.h" namespace NetworkManager { class TeamDevicePrivate : public DevicePrivate { Q_OBJECT public: TeamDevicePrivate(const QString &path, TeamDevice *q); virtual ~TeamDevicePrivate(); OrgFreedesktopNetworkManagerDeviceTeamInterface iface; bool carrier; QString config; QString hwAddress; QStringList slaves; Q_DECLARE_PUBLIC(TeamDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/tundevice.cpp b/src/tundevice.cpp index bcc6d64..7e9ae0c 100644 --- a/src/tundevice.cpp +++ b/src/tundevice.cpp @@ -1,132 +1,118 @@ /* - Copyright 2013 Lukáš Tinkl - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2013 Lukáš Tinkl + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "tundevice_p.h" #include "manager_p.h" NetworkManager::TunDevicePrivate::TunDevicePrivate(const QString &path, TunDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::TunDevicePrivate::~TunDevicePrivate() { } NetworkManager::TunDevice::TunDevice(const QString &path, QObject *parent) : Device(*new TunDevicePrivate(path, this), parent) { Q_D(TunDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::TunDevice::~TunDevice() { } NetworkManager::Device::Type NetworkManager::TunDevice::type() const { return NetworkManager::Device::Tun; } qlonglong NetworkManager::TunDevice::owner() const { Q_D(const TunDevice); return d->owner; } qlonglong NetworkManager::TunDevice::group() const { Q_D(const TunDevice); return d->group; } QString NetworkManager::TunDevice::mode() const { Q_D(const TunDevice); return d->mode; } bool NetworkManager::TunDevice::multiQueue() const { Q_D(const TunDevice); return d->multiQueue; } bool NetworkManager::TunDevice::noPi() const { Q_D(const TunDevice); return d->noPi; } bool NetworkManager::TunDevice::vnetHdr() const { Q_D(const TunDevice); return d->vnetHdr; } QString NetworkManager::TunDevice::hwAddress() const { Q_D(const TunDevice); return d->hwAddress; } void NetworkManager::TunDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(TunDevice); if (property == QLatin1String("Owner")) { owner = value.toLongLong(); Q_EMIT q->ownerChanged(owner); } else if (property == QLatin1String("Group")) { group = value.toLongLong(); Q_EMIT q->groupChanged(group); } else if (property == QLatin1String("Mode")) { mode = value.toString(); Q_EMIT q->modeChanged(mode); } else if (property == QLatin1String("MultiQueue")) { multiQueue = value.toBool(); Q_EMIT q->multiQueueChanged(multiQueue); } else if (property == QLatin1String("NoPi")) { noPi = value.toBool(); Q_EMIT q->noPiChanged(noPi); } else if (property == QLatin1String("VnetHdr")) { vnetHdr = value.toBool(); Q_EMIT q->vnetHdrChanged(vnetHdr); } else if (property == QLatin1String("HwAddress")) { hwAddress = value.toString(); Q_EMIT q->hwAddressChanged(hwAddress); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/tundevice.h b/src/tundevice.h index 474bb7a..1dbde9f 100644 --- a/src/tundevice.h +++ b/src/tundevice.h @@ -1,120 +1,106 @@ /* - Copyright 2013 Lukáš Tinkl - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2013 Lukáš Tinkl + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TUN_DEVICE_H #define NETWORKMANAGERQT_TUN_DEVICE_H #include "device.h" #include namespace NetworkManager { class TunDevicePrivate; /** * A tun device interface */ class NETWORKMANAGERQT_EXPORT TunDevice : public Device { Q_OBJECT Q_PROPERTY(qlonglong owner READ owner NOTIFY ownerChanged) Q_PROPERTY(qlonglong group READ group NOTIFY groupChanged) Q_PROPERTY(QString mode READ mode NOTIFY modeChanged) Q_PROPERTY(bool multiQueue READ multiQueue NOTIFY multiQueueChanged) Q_PROPERTY(bool noPi READ noPi NOTIFY noPiChanged) Q_PROPERTY(bool vnetHdr READ vnetHdr NOTIFY vnetHdrChanged) Q_PROPERTY(QString hwAddress READ hwAddress NOTIFY hwAddressChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit TunDevice(const QString &path, QObject *parent = nullptr); ~TunDevice() override; Type type() const override; /** * The uid of the tunnel owner, or -1 if it has no owner. */ qlonglong owner() const; /** * The gid of the tunnel group, or -1 if it has no owner. */ qlonglong group() const; /** * The tunnel mode, either "tun" or "tap". */ QString mode() const; /** * The tunnel's "TUN_TAP_MQ" flag; true if callers can connect to the tap device multiple times, for multiple send/receive queues. */ bool multiQueue() const; /** * The tunnel's "TUN_NO_PI" flag; true if no protocol info is prepended to the tunnel packets. */ bool noPi() const; /** * The tunnel's "TUN_VNET_HDR" flag; true if the tunnel packets include a virtio network header. */ bool vnetHdr() const; /** * Hardware address of the device. */ QString hwAddress() const; Q_SIGNALS: /** * Emitted when the uid of the tunnel owner has changed */ void ownerChanged(qlonglong owner); /** * Emitted when the gid of the tunnel group has changed */ void groupChanged(qlonglong group); /** * Emitted when the tunnel mode has changed */ void modeChanged(const QString &mode); /** * Emitted when the tunnel's "TUN_TAP_MQ" flag has changed */ void multiQueueChanged(bool multiQueue); /** * Emitted when the tunnel's "TUN_NO_PI" flag has changed */ void noPiChanged(bool noPi); /** * Emitted when the tunnel's "TUN_VNET_HDR" flag has changed */ void vnetHdrChanged(bool vnetHdr); /** * Emitted when the hardware address of the device has changed */ void hwAddressChanged(const QString &hwAddress); private: Q_DECLARE_PRIVATE(TunDevice) }; } #endif diff --git a/src/tundevice_p.h b/src/tundevice_p.h index 0273876..70b64a8 100644 --- a/src/tundevice_p.h +++ b/src/tundevice_p.h @@ -1,58 +1,44 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_TUN_DEVICE_P_H #define NETWORKMANAGERQT_TUN_DEVICE_P_H #include "tundevice.h" #include "device_p.h" #include "tundeviceinterface.h" namespace NetworkManager { class TunDevicePrivate: public DevicePrivate { Q_OBJECT public: TunDevicePrivate(const QString &path, TunDevice *q); virtual ~TunDevicePrivate(); OrgFreedesktopNetworkManagerDeviceTunInterface iface; qlonglong owner; qlonglong group; QString mode; bool multiQueue; bool noPi; bool vnetHdr; QString hwAddress; Q_DECLARE_PUBLIC(TunDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/utils.cpp b/src/utils.cpp index e671edd..7c51ce2 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,591 +1,577 @@ /* - Copyright 2009 Will Stephenson - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2009 Will Stephenson + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include #include "utils.h" #include "time.h" QHostAddress NetworkManager::ipv6AddressAsHostAddress(const QByteArray &address) { // Q_ASSERT(address.size() == 16); Q_IPV6ADDR tmp; for (int i = 0; i < 16; ++i) { tmp[i] = address[i]; } QHostAddress hostaddress(tmp); Q_ASSERT(hostaddress.protocol() == QAbstractSocket::IPv6Protocol); return hostaddress; } QByteArray NetworkManager::ipv6AddressFromHostAddress(const QHostAddress &address) { // Q_ASSERT(address.protocol() == QAbstractSocket::IPv6Protocol); Q_IPV6ADDR tmp = address.toIPv6Address(); QByteArray assembledAddress; for (int i = 0; i < 16; ++i) { assembledAddress[i] = tmp[i]; } return assembledAddress; } QString NetworkManager::macAddressAsString(const QByteArray &ba) { QStringList mac; for (int i = 0; i < ba.size(); ++i) { mac << QString("%1").arg((quint8)ba[i], 2, 16, QLatin1Char('0')).toUpper(); } return mac.join(":"); } QByteArray NetworkManager::macAddressFromString(const QString &s) { QStringList macStringList = s.split(':'); // Q_ASSERT(macStringList.size() == 6); QByteArray ba; if (!s.isEmpty()) { ba.resize(6); int i = 0; Q_FOREACH (const QString & macPart, macStringList) { ba[i++] = macPart.toUInt(nullptr, 16); } } return ba; } bool NetworkManager::macAddressIsValid(const QString &macAddress) { QRegularExpression macAddressCheck(QStringLiteral("([a-fA-F0-9][a-fA-F0-9]:){5}[0-9a-fA-F][0-9a-fA-F]")); return macAddressCheck.match(macAddress).hasMatch(); } bool NetworkManager::macAddressIsValid(const QByteArray &macAddress) { return macAddressIsValid(macAddressAsString(macAddress)); } int NetworkManager::findChannel(int freq) { int channel; if (freq < 2500) { channel = 0; int i = 0; QList > bFreqs = getBFreqs(); while (i < bFreqs.size()) { if (bFreqs.at(i).second <= freq) { channel = bFreqs.at(i).first; } else { break; } i++; } return channel; } channel = 0; int i = 0; QList > aFreqs = getAFreqs(); while (i < aFreqs.size()) { if (aFreqs.at(i).second <= freq) { channel = aFreqs.at(i).first; } else { break; } i++; } return channel; } NetworkManager::WirelessSetting::FrequencyBand NetworkManager::findFrequencyBand(int freq) { if (freq < 2500) { return WirelessSetting::Bg; } return WirelessSetting::A; } bool NetworkManager::deviceSupportsApCiphers(NetworkManager::WirelessDevice::Capabilities interfaceCaps, NetworkManager::AccessPoint::WpaFlags apCiphers, WirelessSecurityType type) { bool havePair = false; bool haveGroup = true; if (type == NetworkManager::StaticWep) { havePair = true; } else { if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Wep40) && apCiphers.testFlag(NetworkManager::AccessPoint::PairWep40)) { havePair = true; } if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Wep104) && apCiphers.testFlag(NetworkManager::AccessPoint::PairWep104)) { havePair = true; } if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Tkip) && apCiphers.testFlag(NetworkManager::AccessPoint::PairTkip)) { havePair = true; } if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Ccmp) && apCiphers.testFlag(NetworkManager::AccessPoint::PairCcmp)) { havePair = true; } } if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Wep40) && apCiphers.testFlag(NetworkManager::AccessPoint::GroupWep40)) { haveGroup = true; } if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Wep104) && apCiphers.testFlag(NetworkManager::AccessPoint::GroupWep104)) { haveGroup = true; } if (type != StaticWep) { if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Tkip) && apCiphers.testFlag(NetworkManager::AccessPoint::GroupTkip)) { haveGroup = true; } if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Ccmp) && apCiphers.testFlag(NetworkManager::AccessPoint::GroupCcmp)) { haveGroup = true; } } return (havePair && haveGroup); } // Keep this in sync with NetworkManager/libnm-core/nm-utils.c:nm_utils_security_valid() bool NetworkManager::securityIsValid(WirelessSecurityType type, NetworkManager::WirelessDevice::Capabilities interfaceCaps, bool haveAp, bool adhoc, NetworkManager::AccessPoint::Capabilities apCaps, NetworkManager::AccessPoint::WpaFlags apWpa, NetworkManager::AccessPoint::WpaFlags apRsn) { bool good = true; //kDebug() << "type(" << type << ") interfaceCaps(" << interfaceCaps << ") haveAp(" << haveAp << ") adhoc(" << adhoc << ") apCaps(" << apCaps << ") apWpa(" << apWpa << " apRsn(" << apRsn << ")"; if (!haveAp) { if (type == NoneSecurity) { return true; } if ((type == StaticWep) || ((type == DynamicWep) && !adhoc) || ((type == Leap) && !adhoc)) { if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Wep40) || interfaceCaps.testFlag(NetworkManager::WirelessDevice::Wep104)) { return true; } else { return false; } } // apCaps.testFlag(Privacy) == true for StaticWep, Leap and DynamicWep // see libs/internals/wirelessinterfaceconnectionhelpers.cpp // TODO: this is not in nm-utils.c // if (type == Knm::WirelessSecurity::WpaPsk // || ((type == Knm::WirelessSecurity::WpaEap) && !adhoc)) { // if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Wpa) && // !apCaps.testFlag(NetworkManager::AccessPoint::Privacy)) { // return true; // } // } // if (type == Knm::WirelessSecurity::Wpa2Psk // || ((type == Knm::WirelessSecurity::Wpa2Eap) && !adhoc)) { // if (interfaceCaps.testFlag(NetworkManager::WirelessDevice::Rsn) && // !apCaps.testFlag(NetworkManager::AccessPoint::Privacy)) { // return true; // } // } } switch (type) { case NoneSecurity: Q_ASSERT(haveAp); if (apCaps.testFlag(NetworkManager::AccessPoint::Privacy)) { return false; } if (apWpa || apRsn) { return false; } break; case Leap: /* require PRIVACY bit for LEAP? */ if (adhoc) { return false; } /* Fall through */ case StaticWep: Q_ASSERT(haveAp); if (!apCaps.testFlag(NetworkManager::AccessPoint::Privacy)) { return false; } if (apWpa || apRsn) { if (!deviceSupportsApCiphers(interfaceCaps, apWpa, StaticWep)) if (!deviceSupportsApCiphers(interfaceCaps, apRsn, StaticWep)) { return false; } } break; case DynamicWep: if (adhoc) { return false; } Q_ASSERT(haveAp); if (apRsn || !(apCaps.testFlag(NetworkManager::AccessPoint::Privacy))) { return false; } /* Some APs broadcast minimal WPA-enabled beacons that must be handled */ if (apWpa) { if (!apWpa.testFlag(NetworkManager::AccessPoint::KeyMgmt8021x)) { return false; } if (!deviceSupportsApCiphers(interfaceCaps, apWpa, DynamicWep)) { return false; } } break; case WpaPsk: if (adhoc) { return false; } if (!interfaceCaps.testFlag(NetworkManager::WirelessDevice::Wpa)) { return false; } if (haveAp) { if (apWpa.testFlag(NetworkManager::AccessPoint::KeyMgmtPsk)) { if (apWpa.testFlag(NetworkManager::AccessPoint::PairTkip) && interfaceCaps.testFlag(NetworkManager::WirelessDevice::Tkip)) { return true; } if (apWpa.testFlag(NetworkManager::AccessPoint::PairCcmp) && interfaceCaps.testFlag(NetworkManager::WirelessDevice::Ccmp)) { return true; } } return false; } break; case Wpa2Psk: if (!interfaceCaps.testFlag(NetworkManager::WirelessDevice::Rsn)) { return false; } if (haveAp) { if (adhoc) { if (!interfaceCaps.testFlag(NetworkManager::WirelessDevice::IBSSRsn)) { return false; } if (apRsn.testFlag(NetworkManager::AccessPoint::PairCcmp) && interfaceCaps.testFlag(NetworkManager::WirelessDevice::Ccmp)) { return true; } } else { if (apRsn.testFlag(NetworkManager::AccessPoint::KeyMgmtPsk)) { if (apRsn.testFlag(NetworkManager::AccessPoint::PairTkip) && interfaceCaps.testFlag(NetworkManager::WirelessDevice::Tkip)) { return true; } if (apRsn.testFlag(NetworkManager::AccessPoint::PairCcmp) && interfaceCaps.testFlag(NetworkManager::WirelessDevice::Ccmp)) { return true; } } } return false; } break; case WpaEap: if (adhoc) { return false; } if (!interfaceCaps.testFlag(NetworkManager::WirelessDevice::Wpa)) { return false; } if (haveAp) { if (!apWpa.testFlag(NetworkManager::AccessPoint::KeyMgmt8021x)) { return false; } /* Ensure at least one WPA cipher is supported */ if (!deviceSupportsApCiphers(interfaceCaps, apWpa, WpaEap)) { return false; } } break; case Wpa2Eap: if (adhoc) { return false; } if (!interfaceCaps.testFlag(NetworkManager::WirelessDevice::Rsn)) { return false; } if (haveAp) { if (!apRsn.testFlag(NetworkManager::AccessPoint::KeyMgmt8021x)) { return false; } /* Ensure at least one WPA cipher is supported */ if (!deviceSupportsApCiphers(interfaceCaps, apRsn, Wpa2Eap)) { return false; } } break; case SAE: if (!interfaceCaps.testFlag(NetworkManager::WirelessDevice::Rsn)) { return false; } if (haveAp) { if (adhoc) { if (!interfaceCaps.testFlag(NetworkManager::WirelessDevice::IBSSRsn)) { return false; } if (apRsn.testFlag(NetworkManager::AccessPoint::PairCcmp) && interfaceCaps.testFlag(NetworkManager::WirelessDevice::Ccmp)) { return true; } } else { if (apRsn.testFlag(NetworkManager::AccessPoint::KeyMgmtSAE)) { if (apRsn.testFlag(NetworkManager::AccessPoint::PairTkip) && interfaceCaps.testFlag(NetworkManager::WirelessDevice::Tkip)) { return true; } if (apRsn.testFlag(NetworkManager::AccessPoint::PairCcmp) && interfaceCaps.testFlag(NetworkManager::WirelessDevice::Ccmp)) { return true; } } } return false; } break; default: good = false; break; } return good; } NetworkManager::WirelessSecurityType NetworkManager::findBestWirelessSecurity(NetworkManager::WirelessDevice::Capabilities interfaceCaps, bool haveAp, bool adHoc, NetworkManager::AccessPoint::Capabilities apCaps, NetworkManager::AccessPoint::WpaFlags apWpa, NetworkManager::AccessPoint::WpaFlags apRsn) { QList types; // The ordering of this list is a pragmatic combination of security level and popularity. // Therefore static WEP is before LEAP and Dynamic WEP because there is no way to detect // if an AP is capable of Dynamic WEP and showing Dynamic WEP first would confuse // Static WEP users. types << NetworkManager::SAE << NetworkManager::Wpa2Eap << NetworkManager::Wpa2Psk << NetworkManager::WpaEap << NetworkManager::WpaPsk << NetworkManager::StaticWep << NetworkManager::DynamicWep << NetworkManager::Leap << NetworkManager::NoneSecurity; Q_FOREACH (NetworkManager::WirelessSecurityType type, types) { if (NetworkManager::securityIsValid(type, interfaceCaps, haveAp, adHoc, apCaps, apWpa, apRsn)) { return type; } } return NetworkManager::UnknownSecurity; } bool NetworkManager::wepKeyIsValid(const QString &key, NetworkManager::WirelessSecuritySetting::WepKeyType type) { if (key.isEmpty()) { return false; } const int keylen = key.length(); if (type != WirelessSecuritySetting::NotSpecified) { if (type == WirelessSecuritySetting::Hex) { if (keylen == 10 || keylen == 26) { /* Hex key */ for (int i = 0; i < keylen; ++i) { if (!(key.at(i).isDigit() || (key.at(i) >= 'A' && key.at(i) <= 'F') || (key.at(i) >= 'a' && key.at(i) <= 'f'))) { return false; } } return true; } else if (keylen == 5 || keylen == 13) { /* ASCII KEY */ for (int i = 0; i < keylen; ++i) { if (!key.at(i).isPrint()) { return false; } } return true; } return false; } else if (type == WirelessSecuritySetting::Passphrase) { if (!keylen || keylen > 64) { return false; } return true; } } return false; } bool NetworkManager::wpaPskIsValid(const QString &psk) { if (psk.isEmpty()) { return false; } const int psklen = psk.length(); if (psklen < 8 || psklen > 64) { return false; } if (psklen == 64) { /* Hex PSK */ for (int i = 0; i < psklen; ++i) { if (!psk.at(i).isLetterOrNumber()) { return false; } } } return true; } NetworkManager::WirelessSecurityType NetworkManager::securityTypeFromConnectionSetting(const NetworkManager::ConnectionSettings::Ptr &settings) { NetworkManager::WirelessSecuritySetting::Ptr wifiSecuritySetting = settings->setting(Setting::WirelessSecurity).dynamicCast(); if (wifiSecuritySetting->keyMgmt() == WirelessSecuritySetting::Wep) { return StaticWep; } else if (wifiSecuritySetting->keyMgmt() == WirelessSecuritySetting::Ieee8021x) { if (wifiSecuritySetting->authAlg() == WirelessSecuritySetting::Leap) { return Leap; } else { return DynamicWep; } } else if (wifiSecuritySetting->keyMgmt() == WirelessSecuritySetting::WpaPsk) { if (wifiSecuritySetting->proto().contains(WirelessSecuritySetting::Wpa) && !wifiSecuritySetting->proto().contains(WirelessSecuritySetting::Rsn)) { return WpaPsk; } return Wpa2Psk; } else if (wifiSecuritySetting->keyMgmt() == WirelessSecuritySetting::WpaEap) { if (wifiSecuritySetting->proto().contains(WirelessSecuritySetting::Wpa) && !wifiSecuritySetting->proto().contains(WirelessSecuritySetting::Rsn)) { return WpaEap; } return Wpa2Eap; } else if (wifiSecuritySetting->keyMgmt() == WirelessSecuritySetting::SAE) { return SAE; } return NoneSecurity; } QList > NetworkManager::getBFreqs() { QList > freqs; freqs.append(QPair(1, 2412)); freqs.append(QPair(2, 2417)); freqs.append(QPair(3, 2422)); freqs.append(QPair(4, 2427)); freqs.append(QPair(5, 2432)); freqs.append(QPair(6, 2437)); freqs.append(QPair(7, 2442)); freqs.append(QPair(8, 2447)); freqs.append(QPair(9, 2452)); freqs.append(QPair(10, 2457)); freqs.append(QPair(11, 2462)); freqs.append(QPair(12, 2467)); freqs.append(QPair(13, 2472)); freqs.append(QPair(14, 2484)); return freqs; } QList > NetworkManager::getAFreqs() { QList > freqs; freqs.append(QPair(7, 5035)); freqs.append(QPair(8, 5040)); freqs.append(QPair(9, 5045)); freqs.append(QPair(11, 5055)); freqs.append(QPair(12, 5060)); freqs.append(QPair(16, 5080)); freqs.append(QPair(34, 5170)); freqs.append(QPair(36, 5180)); freqs.append(QPair(38, 5190)); freqs.append(QPair(40, 5200)); freqs.append(QPair(42, 5210)); freqs.append(QPair(44, 5220)); freqs.append(QPair(46, 5230)); freqs.append(QPair(48, 5240)); freqs.append(QPair(52, 5260)); freqs.append(QPair(56, 5280)); freqs.append(QPair(60, 5300)); freqs.append(QPair(64, 5320)); freqs.append(QPair(100, 5500)); freqs.append(QPair(104, 5520)); freqs.append(QPair(108, 5540)); freqs.append(QPair(112, 5560)); freqs.append(QPair(116, 5580)); freqs.append(QPair(120, 5600)); freqs.append(QPair(124, 5620)); freqs.append(QPair(128, 5640)); freqs.append(QPair(132, 5660)); freqs.append(QPair(136, 5680)); freqs.append(QPair(140, 5700)); freqs.append(QPair(149, 5745)); freqs.append(QPair(153, 5765)); freqs.append(QPair(157, 5785)); freqs.append(QPair(161, 5805)); freqs.append(QPair(165, 5825)); freqs.append(QPair(183, 4915)); freqs.append(QPair(184, 4920)); freqs.append(QPair(185, 4925)); freqs.append(QPair(187, 4935)); freqs.append(QPair(188, 4940)); freqs.append(QPair(189, 4945)); freqs.append(QPair(192, 4960)); freqs.append(QPair(196, 4980)); return freqs; } QDateTime NetworkManager::clockBootTimeToDateTime(qlonglong clockBootime) { clockid_t clk_id = CLOCK_BOOTTIME; struct timespec tp; int r; // now is used as a point of reference // with the timespec that contains the number of msec since boot QDateTime now = QDateTime::currentDateTime(); r = clock_gettime (clk_id, &tp); if (r == -1 && errno == EINVAL) { clk_id = CLOCK_MONOTONIC; r = clock_gettime (clk_id, &tp); } // convert to msecs long now_msecs = tp.tv_sec * 1000 + tp.tv_nsec / 1000000; // diff the msecs and construct a QDateTime based on the offset QDateTime res; if (clockBootime > now_msecs) { qlonglong offset = clockBootime - now_msecs; res = QDateTime::fromMSecsSinceEpoch(now.toMSecsSinceEpoch() + offset); } else { qlonglong offset = now_msecs - clockBootime; res = QDateTime::fromMSecsSinceEpoch(now.toMSecsSinceEpoch() - offset); } return res; } diff --git a/src/utils.h b/src/utils.h index d091941..a72a6b0 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,89 +1,75 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_UTILS_H #define NETWORKMANAGERQT_UTILS_H #include #include #include #include "wirelessdevice.h" #include "wirelesssecuritysetting.h" #include "wirelesssetting.h" namespace NetworkManager { enum WirelessSecurityType { UnknownSecurity = -1, NoneSecurity, StaticWep, DynamicWep, Leap, WpaPsk, WpaEap, Wpa2Psk, Wpa2Eap, SAE }; /** * @return QHostAddress representation of an ipv6 address * @param address byte array containing the binary representation of the address */ NETWORKMANAGERQT_EXPORT QHostAddress ipv6AddressAsHostAddress(const QByteArray &address); /** * @return binary representation of an ipv6 address * @param address qhostaddress containing the address */ NETWORKMANAGERQT_EXPORT QByteArray ipv6AddressFromHostAddress(const QHostAddress &address); /** * @return String representation of a mac address. * @param ba byte array containing the binary repesentation of the address */ NETWORKMANAGERQT_EXPORT QString macAddressAsString(const QByteArray &ba); /** * @return binary repesentation of a mac address. * @param s string representation of the address */ NETWORKMANAGERQT_EXPORT QByteArray macAddressFromString(const QString &s); NETWORKMANAGERQT_EXPORT bool macAddressIsValid(const QString &macAddress); NETWORKMANAGERQT_EXPORT bool macAddressIsValid(const QByteArray &macAddress); /** * @param freq frequency of a wireless network * @return The frequency channel. */ NETWORKMANAGERQT_EXPORT int findChannel(int freq); NETWORKMANAGERQT_EXPORT NetworkManager::WirelessSetting::FrequencyBand findFrequencyBand(int freq); NETWORKMANAGERQT_EXPORT bool deviceSupportsApCiphers(NetworkManager::WirelessDevice::Capabilities, NetworkManager::AccessPoint::WpaFlags ciphers, WirelessSecurityType type); NETWORKMANAGERQT_EXPORT bool securityIsValid(WirelessSecurityType type, NetworkManager::WirelessDevice::Capabilities interfaceCaps, bool haveAp, bool adHoc, NetworkManager::AccessPoint::Capabilities apCaps, NetworkManager::AccessPoint::WpaFlags apWpa, NetworkManager::AccessPoint::WpaFlags apRsn); NETWORKMANAGERQT_EXPORT WirelessSecurityType findBestWirelessSecurity(NetworkManager::WirelessDevice::Capabilities, bool haveAp, bool adHoc, NetworkManager::AccessPoint::Capabilities apCaps, NetworkManager::AccessPoint::WpaFlags apWpa, NetworkManager::AccessPoint::WpaFlags apRsn); NETWORKMANAGERQT_EXPORT bool wepKeyIsValid(const QString &key, NetworkManager::WirelessSecuritySetting::WepKeyType type); NETWORKMANAGERQT_EXPORT bool wpaPskIsValid(const QString &psk); NETWORKMANAGERQT_EXPORT WirelessSecurityType securityTypeFromConnectionSetting(const NetworkManager::ConnectionSettings::Ptr &settings); NETWORKMANAGERQT_EXPORT QList > getBFreqs(); NETWORKMANAGERQT_EXPORT QList > getAFreqs(); NETWORKMANAGERQT_EXPORT QDateTime clockBootTimeToDateTime(qlonglong clockBootime); } #endif // NETWORKMANAGERQT_UTILS_H diff --git a/src/vethdevice.cpp b/src/vethdevice.cpp index 51d9c36..1627884 100644 --- a/src/vethdevice.cpp +++ b/src/vethdevice.cpp @@ -1,80 +1,66 @@ /* - Copyright 2013 Lukáš Tinkl - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2013 Lukáš Tinkl + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "vethdevice_p.h" #include "device.h" #include "manager.h" #include "manager_p.h" NetworkManager::VethDevicePrivate::VethDevicePrivate(const QString &path, VethDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::VethDevicePrivate::~VethDevicePrivate() { } NetworkManager::VethDevice::VethDevice(const QString &path, QObject *parent) : Device(*new VethDevicePrivate(path, this), parent) { Q_D(VethDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::VethDevice::~VethDevice() { } NetworkManager::Device::Type NetworkManager::VethDevice::type() const { return NetworkManager::Device::Veth; } QString NetworkManager::VethDevice::peer() const { Q_D(const VethDevice); return d->peer; } void NetworkManager::VethDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(VethDevice); if (property == QLatin1String("Peer")) { peer = value.toString(); Q_EMIT q->peerChanged(peer); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/vethdevice.h b/src/vethdevice.h index a5f4f27..c8a4230 100644 --- a/src/vethdevice.h +++ b/src/vethdevice.h @@ -1,61 +1,47 @@ /* - Copyright 2013 Lukáš Tinkl - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2013 Lukáš Tinkl + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VETH_DEVICE_H #define NETWORKMANAGERQT_VETH_DEVICE_H #include "device.h" #include namespace NetworkManager { class VethDevicePrivate; /** * A veth device interface */ class NETWORKMANAGERQT_EXPORT VethDevice : public Device { Q_OBJECT Q_PROPERTY(QString peer READ peer NOTIFY peerChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit VethDevice(const QString &path, QObject *parent = nullptr); ~VethDevice() override; Type type() const override; QString peer() const; Q_SIGNALS: void peerChanged(const QString &peer); private: Q_DECLARE_PRIVATE(VethDevice) }; } #endif diff --git a/src/vethdevice_p.h b/src/vethdevice_p.h index e4a9474..1ac4adf 100644 --- a/src/vethdevice_p.h +++ b/src/vethdevice_p.h @@ -1,53 +1,39 @@ /* - Copyright 2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VETH_DEVICE_P_H #define NETWORKMANAGERQT_VETH_DEVICE_P_H #include "vethdevice.h" #include "device_p.h" #include "vethdeviceinterface.h" namespace NetworkManager { class VethDevicePrivate : public DevicePrivate { Q_OBJECT public: VethDevicePrivate(const QString &path, VethDevice *q); virtual ~VethDevicePrivate(); OrgFreedesktopNetworkManagerDeviceVethInterface iface; QString peer; Q_DECLARE_PUBLIC(VethDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/vlandevice.cpp b/src/vlandevice.cpp index 6ece2e0..95c76ac 100644 --- a/src/vlandevice.cpp +++ b/src/vlandevice.cpp @@ -1,114 +1,100 @@ /* - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "vlandevice_p.h" #include "device_p.h" #include "manager.h" NetworkManager::VlanDevicePrivate::VlanDevicePrivate(const QString &path, VlanDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , carrier(false) { } NetworkManager::VlanDevice::~VlanDevice() { } NetworkManager::VlanDevice::VlanDevice(const QString &path, QObject *parent) : Device(*new VlanDevicePrivate(path, this), parent) { Q_D(VlanDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::VlanDevicePrivate::~VlanDevicePrivate() { } NetworkManager::Device::Type NetworkManager::VlanDevice::type() const { return NetworkManager::Device::Vlan; } bool NetworkManager::VlanDevice::carrier() const { Q_D(const VlanDevice); return d->carrier; } QString NetworkManager::VlanDevice::hwAddress() const { Q_D(const VlanDevice); return d->hwAddress; } NetworkManager::Device::Ptr NetworkManager::VlanDevice::parent() const { if (NetworkManager::checkVersion(1, 0, 0)) { Q_D(const VlanDevice); return NetworkManager::findNetworkInterface(d->parent); } else { return NetworkManager::Device::Ptr(nullptr); } } uint NetworkManager::VlanDevice::vlanId() const { Q_D(const VlanDevice); return d->vlanId; } void NetworkManager::VlanDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(VlanDevice); if (property == QLatin1String("Carrier")) { carrier = value.toBool(); Q_EMIT q->carrierChanged(carrier); } else if (property == QLatin1String("HwAddress")) { hwAddress = value.toString(); Q_EMIT q->hwAddressChanged(hwAddress); } else if (property == QLatin1String("Parent")) { parent = value.value().path(); Q_EMIT q->parentChanged(parent); } else if (property == QLatin1String("VlanId")) { vlanId = value.toUInt(); Q_EMIT q->vlanIdChanged(vlanId); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/vlandevice.h b/src/vlandevice.h index a089fd5..13f5b41 100644 --- a/src/vlandevice.h +++ b/src/vlandevice.h @@ -1,94 +1,80 @@ /* - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VLAN_DEVICE_H #define NETWORKMANAGERQT_VLAN_DEVICE_H #include "device.h" #include namespace NetworkManager { class VlanDevicePrivate; /** * A vlan device interface */ class NETWORKMANAGERQT_EXPORT VlanDevice : public Device { Q_OBJECT Q_PROPERTY(bool carrier READ carrier NOTIFY carrierChanged) Q_PROPERTY(QString hwAddress READ hwAddress NOTIFY hwAddressChanged) Q_PROPERTY(uint vlanId READ vlanId NOTIFY vlanIdChanged) Q_PROPERTY(NetworkManager::Device::Ptr parent READ parent NOTIFY parentChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit VlanDevice(const QString &path, QObject *parent = nullptr); ~VlanDevice() override; Type type() const override; /** * Indicates whether the physical carrier is found */ bool carrier() const; /** * Hardware address of the device */ QString hwAddress() const; /** * The parent device of this VLAN device * @since 5.8.0 */ NetworkManager::Device::Ptr parent() const; /** * The VLAN ID of this VLAN interface */ uint vlanId() const; Q_SIGNALS: /** * Emitted when the carrier of this device has changed */ void carrierChanged(bool plugged); /** * Emitted when the hardware address of this device has changed */ void hwAddressChanged(const QString &address); /** * Emitted when the parent device of this device has changed */ void parentChanged(const QString &path); /** * Emitted when the VLAN ID of this device has changed */ void vlanIdChanged(uint id); private: Q_DECLARE_PRIVATE(VlanDevice) }; } #endif diff --git a/src/vlandevice_p.h b/src/vlandevice_p.h index d8d11ff..d1afc5b 100644 --- a/src/vlandevice_p.h +++ b/src/vlandevice_p.h @@ -1,56 +1,42 @@ /* - Copyright 2012-2014 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2014 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VLAN_DEVICE_P_H #define NETWORKMANAGERQT_VLAN_DEVICE_P_H #include "device_p.h" #include "vlandevice.h" #include "manager_p.h" #include "vlandeviceinterface.h" namespace NetworkManager { class VlanDevicePrivate : public DevicePrivate { Q_OBJECT public: VlanDevicePrivate(const QString &path, VlanDevice *q); virtual ~VlanDevicePrivate(); OrgFreedesktopNetworkManagerDeviceVlanInterface iface; bool carrier; QString hwAddress; QString parent; uint vlanId; Q_DECLARE_PUBLIC(VlanDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/vpnconnection.cpp b/src/vpnconnection.cpp index 7fdc51f..10cb29e 100644 --- a/src/vpnconnection.cpp +++ b/src/vpnconnection.cpp @@ -1,140 +1,126 @@ /* - Copyright 2011 Ilia Kats - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "vpnconnection_p.h" #include "connection.h" #include "device.h" #include "nmdebug.h" #include "settings.h" #include NetworkManager::VpnConnectionPrivate::VpnConnectionPrivate(const QString &path, VpnConnection *q) : ActiveConnectionPrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , q_ptr(q) { } NetworkManager::VpnConnection::State NetworkManager::VpnConnectionPrivate::convertVpnConnectionState(uint state) { return static_cast(state); } NetworkManager::VpnConnection::StateChangeReason NetworkManager::VpnConnectionPrivate::convertVpnConnectionStateReason(uint reason) { return static_cast(reason); } NetworkManager::VpnConnection::VpnConnection(const QString &path, QObject *parent) : ActiveConnection(*new VpnConnectionPrivate(path, this), parent) { Q_D(VpnConnection); // We need to get ActiveConnection's properties, because by default every ActiveConnection // is basically a VpnConnection QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(OrgFreedesktopNetworkManagerConnectionActiveInterface::staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } // Try to retrieve VPN specific properties if this is a VPN connection if (vpn()) { // Get all VpnConnection's properties at once QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->path, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); connect(&d->iface, &OrgFreedesktopNetworkManagerVPNConnectionInterface::VpnStateChanged, d, &VpnConnectionPrivate::vpnStateChanged); } NetworkManager::VpnConnection::~VpnConnection() { } QString NetworkManager::VpnConnection::banner() const { Q_D(const VpnConnection); //return d->banner; // FIXME NM doesn't Q_EMIT the Banner property change return d->iface.banner(); } NetworkManager::VpnConnection::State NetworkManager::VpnConnection::state() const { Q_D(const VpnConnection); return d->state; } void NetworkManager::VpnConnectionPrivate::dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties) { Q_UNUSED(invalidatedProperties); if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.VPN.Connection")) { propertiesChanged(properties); } else { ActiveConnectionPrivate::propertiesChanged(properties); } } void NetworkManager::VpnConnectionPrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(VpnConnection); if (property == QLatin1String("Banner")) { banner = value.toString(); Q_EMIT q->bannerChanged(banner); } else if (property == QLatin1String("VpnState")) { //Do not notify about changed VpnState twice, because there is also signal VpnStateChanged() from NetworkManager state = NetworkManager::VpnConnectionPrivate::convertVpnConnectionState(value.toUInt()); //NetworkManager::VpnConnection::StateChangeReason reason = NetworkManager::VpnConnectionPrivate::convertVpnConnectionStateReason(properties.key("Reason").toUInt()); //Q_EMIT stateChanged(d->state, reason); } else { ActiveConnectionPrivate::propertyChanged(property, value); } } void NetworkManager::VpnConnectionPrivate::vpnStateChanged(uint newState, uint reason) { Q_Q(VpnConnection); Q_UNUSED(reason); state = NetworkManager::VpnConnectionPrivate::convertVpnConnectionState(newState); NetworkManager::VpnConnection::StateChangeReason stateChangeReason = NetworkManager::VpnConnectionPrivate::convertVpnConnectionStateReason(reason); Q_EMIT q->stateChanged(state, stateChangeReason); } NetworkManager::VpnConnection::operator VpnConnection *() { Q_D(VpnConnection); if (d->vpn) { return this; } else { return nullptr; } } diff --git a/src/vpnconnection.h b/src/vpnconnection.h index e23ebe7..cde5305 100644 --- a/src/vpnconnection.h +++ b/src/vpnconnection.h @@ -1,120 +1,106 @@ /* - Copyright 2011 Ilia Kats - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VPNCONNECTION_H #define NETWORKMANAGERQT_VPNCONNECTION_H #include #include "activeconnection.h" #include #include namespace NetworkManager { class Device; class VpnConnectionPrivate; /** * An active VPN connection */ class NETWORKMANAGERQT_EXPORT VpnConnection : public ActiveConnection { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; /** * Enum describing the possible VPN connection states */ enum State { Unknown = 0, /**< The state of the VPN connection is unknown. */ Prepare, /**< The VPN connection is preparing to connect. */ NeedAuth, /**< The VPN connection needs authorization credentials. */ Connecting, /**< The VPN connection is being established. */ GettingIpConfig, /**< The VPN connection is getting an IP address. */ Activated, /**< The VPN connection is active. */ Failed, /**< The VPN connection failed. */ Disconnected /**< The VPN connection is disconnected. */ }; enum StateChangeReason { UnknownReason = 0, /**< The reason for the VPN connection state change is unknown.*/ NoneReason, /**< No reason was given for the VPN connection state change. */ UserDisconnectedReason, /**< The VPN connection changed state because the user disconnected it. */ DeviceDisconnectedReason, /**< The VPN connection changed state because the device it was using was disconnected. */ ServiceStoppedReason, /**< The service providing the VPN connection was stopped. */ IpConfigInvalidReason, /**< The IP config of the VPN connection was invalid. */ ConnectTimeoutReason, /**< The connection attempt to the VPN service timed out. */ ServiceStartTimeoutReason, /**< A timeout occurred while starting the service providing the VPN connection. */ ServiceStartFailedReason, /**< Starting the service starting the service providing the VPN connection failed. */ NoSecretsReason, /**< Necessary secrets for the VPN connection were not provided. */ LoginFailedReason, /**< Authentication to the VPN server failed. */ ConnectionRemovedReason /**< The connection was deleted from settings. */ }; /** * Creates a new VpnConnection object. * * @param path the DBus path of the device */ explicit VpnConnection(const QString &path, QObject *parent = nullptr); /** * Destroys a VpnConnection object. */ virtual ~VpnConnection(); /** * Return the current login banner */ QString banner() const; /** * returns the current state */ NetworkManager::VpnConnection::State state() const; /** * operator for casting an ActiveConnection into a VpnConnection. Returns 0 if this * object is not a VPN connection. Introduced to make it possible to create a VpnConnection * object for every active connection, without creating an ActiveConnection object, checking * if it's a VPN connection, deleting the ActiveConnection and creating a VpnConnection */ operator VpnConnection *(); Q_SIGNALS: /** * This signal is emitted when the connection @p banner has changed */ void bannerChanged(const QString &banner); /** * This signal is emitted when the VPN connection @p state has changed */ void stateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason); private: Q_DECLARE_PRIVATE(VpnConnection) }; } // namespace NetworkManager #endif //NETWORKMANAGERQT_VPNCONNECTION_H diff --git a/src/vpnconnection_p.h b/src/vpnconnection_p.h index 0bf8749..68c868a 100644 --- a/src/vpnconnection_p.h +++ b/src/vpnconnection_p.h @@ -1,64 +1,50 @@ /* - Copyright 2011 Ilia Kats - Copyright 2013-2014 Jan Grulich + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2013-2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VPNCONNECTION_P_H #define NETWORKMANAGERQT_VPNCONNECTION_P_H #include "activeconnection_p.h" #include "manager_p.h" #include "vpnconnection.h" #include "vpnconnectioninterface.h" namespace NetworkManager { class VpnConnectionPrivate : public ActiveConnectionPrivate { Q_OBJECT public: VpnConnectionPrivate(const QString &path, VpnConnection *q); static NetworkManager::VpnConnection::State convertVpnConnectionState(uint state); static NetworkManager::VpnConnection::StateChangeReason convertVpnConnectionStateReason(uint reason); QString banner; NetworkManager::VpnConnection::State state; OrgFreedesktopNetworkManagerVPNConnectionInterface iface; Q_DECLARE_PUBLIC(VpnConnection) VpnConnection *q_ptr; protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; private Q_SLOTS: void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); void vpnStateChanged(uint new_state, uint reason); }; } #endif // NETWORKMANAGERQT_VPNCONNECTION_P_H diff --git a/src/vpnplugin.cpp b/src/vpnplugin.cpp index f817f1f..c824b5b 100644 --- a/src/vpnplugin.cpp +++ b/src/vpnplugin.cpp @@ -1,137 +1,123 @@ /* - Copyright 2012-2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2012-2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "vpnplugin.h" #include "vpnconnection.h" #include "manager_p.h" #include "vpnplugininterface.h" class NetworkManager::VpnPluginPrivate { public: VpnPluginPrivate(const QString &path); VpnConnection::State state; OrgFreedesktopNetworkManagerVPNPluginInterface iface; }; NetworkManager::VpnPluginPrivate::VpnPluginPrivate(const QString &path) #ifdef NMQT_STATIC : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { } NetworkManager::VpnPlugin::VpnPlugin(const QString &path, QObject *parent) : QObject(parent), d_ptr(new VpnPluginPrivate(path)) { Q_D(VpnPlugin); d->state = (NetworkManager::VpnConnection::State)d->iface.state(); QObject::connect(&d->iface, SIGNAL(Config(QVariantMap)), this, SLOT(setConfig(QVariantMap))); QObject::connect(&d->iface, SIGNAL(Failure(uint)), this, SLOT(setFailure(QString))); QObject::connect(&d->iface, SIGNAL(Ip4Config(QVariantMap)), this, SLOT(setIp4Config(QVariantMap))); QObject::connect(&d->iface, SIGNAL(Ip6Config(QVariantMap)), this, SLOT(setIp6Config(QVariantMap))); //QObject::connect(&d->iface, SIGNAL(LoginBanner(QString)), // this, SLOT(onLoginBanner(QString))); QObject::connect(&d->iface, SIGNAL(StateChanged(uint)), this, SLOT(onStateChanged(uint))); } NetworkManager::VpnPlugin::~VpnPlugin() { delete d_ptr; } void NetworkManager::VpnPlugin::connect(const NMVariantMapMap &connection) { Q_D(VpnPlugin); QDBusPendingReply<> reply = d->iface.Connect(connection); } void NetworkManager::VpnPlugin::disconnect() { Q_D(VpnPlugin); QDBusPendingReply<> reply = d->iface.Disconnect(); } QString NetworkManager::VpnPlugin::needSecrets(const NMVariantMapMap &connection) { Q_D(VpnPlugin); QDBusPendingReply reply = d->iface.NeedSecrets(connection); return reply.value(); } void NetworkManager::VpnPlugin::setConfig(const QVariantMap &configuration) { Q_D(VpnPlugin); QDBusPendingReply reply = d->iface.SetConfig(configuration); Q_EMIT configChanged(configuration); } void NetworkManager::VpnPlugin::setFailure(const QString &reason) { Q_D(VpnPlugin); QDBusPendingReply reply = d->iface.SetFailure(reason); //TODO //Q_EMIT failureChanged(reason); } void NetworkManager::VpnPlugin::setIp4Config(const QVariantMap &config) { Q_D(VpnPlugin); QDBusPendingReply<> reply = d->iface.SetIp4Config(config); Q_EMIT ip4ConfigChanged(config); } void NetworkManager::VpnPlugin::setIp6Config(const QVariantMap &config) { Q_D(VpnPlugin); QDBusPendingReply<> reply = d->iface.SetIp6Config(config); Q_EMIT ip6ConfigChanged(config); } void NetworkManager::VpnPlugin::onStateChanged(uint state) { Q_D(VpnPlugin); d->state = (VpnConnection::State) state; Q_EMIT stateChanged(d->state); } diff --git a/src/vpnplugin.h b/src/vpnplugin.h index 5a2a3a9..685a26d 100644 --- a/src/vpnplugin.h +++ b/src/vpnplugin.h @@ -1,72 +1,58 @@ /* - Copyright 2012-2013 Jan Grulich + SPDX-FileCopyrightText: 2012-2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_VPNPLUGIN_H #define NETWORKMANAGERQT_VPNPLUGIN_H #include #include "generictypes.h" #include "vpnconnection.h" #include #include namespace NetworkManager { class VpnPluginPrivate; class NETWORKMANAGERQT_EXPORT VpnPlugin : public QObject { Q_OBJECT public: enum FailureType {LoginFailed, ConnectFailed, BadIpConfig}; explicit VpnPlugin(const QString &path, QObject *parent = nullptr); virtual ~VpnPlugin(); Q_SIGNALS: void configChanged(const QVariantMap &configuration); void failureChanged(uint reason); void ip4ConfigChanged(const QVariantMap &ip4config); void ip6ConfigChanged(const QVariantMap &ip6config); void loginBannerChanged(const QString &banner); void stateChanged(VpnConnection::State state); protected Q_SLOTS: void connect(const NMVariantMapMap &connection); void disconnect(); QString needSecrets(const NMVariantMapMap &connection); void setConfig(const QVariantMap &config); void setFailure(const QString &reason); void setIp4Config(const QVariantMap &config); void setIp6Config(const QVariantMap &config); void onStateChanged(uint state); protected: VpnPluginPrivate *const d_ptr; private: Q_DECLARE_PRIVATE(VpnPlugin) }; } // namespace NetworkManager #endif //NETWORKMANAGERQT_VPNPLUGIN_H diff --git a/src/wimaxdevice.cpp b/src/wimaxdevice.cpp index d25d00d..d83487a 100644 --- a/src/wimaxdevice.cpp +++ b/src/wimaxdevice.cpp @@ -1,183 +1,169 @@ /* - Copyright 2011 Ilia Kats - Copyright 2013 Daniel Nicoletti - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wimaxdevice.h" #include "wimaxdevice_p.h" #include "manager_p.h" #include "wimaxnsp.h" #include "nmdebug.h" NetworkManager::WimaxDevicePrivate::WimaxDevicePrivate(const QString &path, WimaxDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , wimaxIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , wimaxIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif { qDBusRegisterMetaType >(); QList nsps = wimaxIface.nsps(); Q_FOREACH (const QDBusObjectPath & op, nsps) { nspMap.insert(op.path(), NetworkManager::WimaxNsp::Ptr()); //qCDebug(NMQT) << " " << op.path(); } } NetworkManager::WimaxDevice::WimaxDevice(const QString &path, QObject *parent) : Device(*new WimaxDevicePrivate(path, this), parent) { Q_D(WimaxDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->wimaxIface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); connect(&d->wimaxIface, &OrgFreedesktopNetworkManagerDeviceWiMaxInterface::NspAdded, d, &WimaxDevicePrivate::nspAdded); connect(&d->wimaxIface, &OrgFreedesktopNetworkManagerDeviceWiMaxInterface::NspRemoved, d, &WimaxDevicePrivate::nspRemoved); } NetworkManager::WimaxDevice::~WimaxDevice() { } NetworkManager::Device::Type NetworkManager::WimaxDevice::type() const { return NetworkManager::Device::Wimax; } QStringList NetworkManager::WimaxDevice::nsps() const { Q_D(const WimaxDevice); return d->nspMap.keys(); } NetworkManager::WimaxNsp::Ptr NetworkManager::WimaxDevice::activeNsp() const { Q_D(const WimaxDevice); return findNsp(d->activeNsp); } QString NetworkManager::WimaxDevice::hardwareAddress() const { Q_D(const WimaxDevice); return d->hardwareAddress; } QString NetworkManager::WimaxDevice::bsid() const { Q_D(const WimaxDevice); return d->bsid; } uint NetworkManager::WimaxDevice::centerFrequency() const { Q_D(const WimaxDevice); return d->centerFrequency; } int NetworkManager::WimaxDevice::cinr() const { Q_D(const WimaxDevice); return d->cinr; } int NetworkManager::WimaxDevice::rssi() const { Q_D(const WimaxDevice); return d->rssi; } int NetworkManager::WimaxDevice::txPower() const { Q_D(const WimaxDevice); return d->txPower; } NetworkManager::WimaxNsp::Ptr NetworkManager::WimaxDevice::findNsp(const QString &uni) const { Q_D(const WimaxDevice); NetworkManager::WimaxNsp::Ptr nsp; QMap::ConstIterator mapIt = d->nspMap.constFind(uni); if (mapIt != d->nspMap.constEnd() && !mapIt.value().isNull()) { nsp = mapIt.value(); } else { nsp = NetworkManager::WimaxNsp::Ptr(new NetworkManager::WimaxNsp(uni), &QObject::deleteLater); d->nspMap.insert(uni, nsp); } return nsp; } void NetworkManager::WimaxDevicePrivate::nspAdded(const QDBusObjectPath &nspPath) { //qCDebug(NMQT) << nspPath.path(); Q_Q(WimaxDevice); if (!nspMap.contains(nspPath.path())) { nspMap.insert(nspPath.path(), NetworkManager::WimaxNsp::Ptr()); Q_EMIT q->nspAppeared(nspPath.path()); } } void NetworkManager::WimaxDevicePrivate::nspRemoved(const QDBusObjectPath &nspPath) { //qCDebug(NMQT) << nspPath.path(); Q_Q(WimaxDevice); if (!nspMap.contains(nspPath.path())) { qCDebug(NMQT) << "Access point list lookup failed for " << nspPath.path(); } Q_EMIT q->nspDisappeared(nspPath.path()); nspMap.remove(nspPath.path()); } void NetworkManager::WimaxDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(WimaxDevice); if (property == QLatin1String("ActiveNsp")) { activeNsp = qdbus_cast(value).path(); Q_EMIT q->activeNspChanged(activeNsp); } else if (property == QLatin1String("HwAddress")) { hardwareAddress = value.toString(); Q_EMIT q->hardwareAddressChanged(hardwareAddress); } else if (property == QLatin1String("Bsid")) { bsid = value.toString(); Q_EMIT q->bsidChanged(bsid); } else if (property == QLatin1String("CenterFrequency")) { centerFrequency = value.toUInt(); Q_EMIT q->centerFrequencyChanged(centerFrequency); } else if (property == QLatin1String("Cinr")) { cinr = value.toInt(); Q_EMIT q->cinrChanged(cinr); } else if (property == QLatin1String("Rssi")) { rssi = value.toInt(); Q_EMIT q->rssiChanged(rssi); } else if (property == QLatin1String("TxPower")) { txPower = value.toInt(); Q_EMIT q->txPowerChanged(txPower); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/wimaxdevice.h b/src/wimaxdevice.h index 6180fa6..d6ab76d 100644 --- a/src/wimaxdevice.h +++ b/src/wimaxdevice.h @@ -1,154 +1,140 @@ /* - Copyright 2011 Ilia Kats - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Daniel Nicoletti - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIMAXDEVICE_H #define NETWORKMANAGERQT_WIMAXDEVICE_H #include #include "device.h" #include "wimaxnsp.h" #include namespace NetworkManager { class WimaxDevicePrivate; /** * Wimax network interface */ class NETWORKMANAGERQT_EXPORT WimaxDevice : public Device { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; /** * Creates a new WimaxDevice object. * * @param path the DBus path of the device */ explicit WimaxDevice(const QString &path, QObject *parent = nullptr); /** * Destroys a WimaxDevice object. */ ~WimaxDevice() override; /** * Return the type */ Type type() const override; /** * List of network service providers currently visible to the hardware */ QStringList nsps() const; /** * Identifier of the NSP this interface is currently associated with */ WimaxNsp::Ptr activeNsp() const; /** * The ID of the serving base station as received from the network. */ QString bsid() const; /** * The hardware address currently used by the network interface */ QString hardwareAddress() const; /** * Center frequency (in KHz) of the radio channel the device is using to communicate with the network when connected. */ uint centerFrequency() const; /** * CINR (Carrier to Interference + Noise Ratio) of the current radio link in dB. */ int cinr() const; /** * RSSI of the current radio link in dBm. This value indicates how strong the raw received RF signal from the base station is, but does not indicate the overall quality of the radio link. */ int rssi() const; /** * Average power of the last burst transmitted by the device, in units of 0.5 dBm. i.e. a TxPower of -11 represents an actual device TX power of -5.5 dBm. */ int txPower() const; /** * Finds NSP object given its Unique Network Identifier. * * @param uni the identifier of the AP to find from this network interface * @returns a valid WimaxNsp object if a network having the given UNI for this device is known to the system, 0 otherwise */ NetworkManager::WimaxNsp::Ptr findNsp(const QString &uni) const; Q_SIGNALS: /** * This signal is emitted when the bitrate of this network has changed. * * @param bitrate the new bitrate value for this network */ void bitRateChanged(int bitrate); /** * The active NSP changed. */ void activeNspChanged(const QString &); /** * The BSID changed. */ void bsidChanged(const QString &); /** * The device changed its hardware address */ void hardwareAddressChanged(const QString &); /** * The device changed its center frequency */ void centerFrequencyChanged(uint); /** * The device changed its signal/noise ratio */ void cinrChanged(int); /** * The device changed its RSSI */ void rssiChanged(int); /** * The device changed its TxPower. */ void txPowerChanged(int); /** * A new NSP appeared */ void nspAppeared(const QString &); /** * A wireless access point disappeared */ void nspDisappeared(const QString &); private: Q_DECLARE_PRIVATE(WimaxDevice) }; } // namespace NetworkManager #endif //NETWORKMANAGERQT_WIMAXDEVICE_H diff --git a/src/wimaxdevice_p.h b/src/wimaxdevice_p.h index 44a6bb4..33dab25 100644 --- a/src/wimaxdevice_p.h +++ b/src/wimaxdevice_p.h @@ -1,61 +1,47 @@ /* - Copyright 2011 Ilia Kats - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2011 Ilia Kats + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIMAXDEVICE_P_H #define NETWORKMANAGERQT_WIMAXDEVICE_P_H #include "device_p.h" #include "wimaxdeviceinterface.h" namespace NetworkManager { class WimaxDevicePrivate : public DevicePrivate { Q_OBJECT public: explicit WimaxDevicePrivate(const QString &path, WimaxDevice *q); OrgFreedesktopNetworkManagerDeviceWiMaxInterface wimaxIface; QString hardwareAddress; mutable QMap nspMap; QString activeNsp; uint centerFrequency; int cinr; QString bsid; int rssi; int txPower; Q_DECLARE_PUBLIC(WimaxDevice) protected Q_SLOTS: void nspAdded(const QDBusObjectPath &); void nspRemoved(const QDBusObjectPath &); protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/wimaxnsp.cpp b/src/wimaxnsp.cpp index 8617e8c..ecef5e8 100644 --- a/src/wimaxnsp.cpp +++ b/src/wimaxnsp.cpp @@ -1,124 +1,110 @@ /* - Copyright 2011 Ilia Kats - Copyright 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2013 Daniel Nicoletti - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wimaxnsp_p.h" #include "manager_p.h" #include "wimaxdevice.h" #include "nmdebug.h" namespace NetworkManager { NetworkManager::WimaxNsp::NetworkType convertNetworkType(uint type) { switch (type) { case 0: return NetworkManager::WimaxNsp::Unknown; case 1: return NetworkManager::WimaxNsp::Home; case 2: return NetworkManager::WimaxNsp::Partner; case 3: return NetworkManager::WimaxNsp::RoamingPartner; } return NetworkManager::WimaxNsp::Unknown; } } NetworkManager::WimaxNspPrivate::WimaxNspPrivate(const QString &path, WimaxNsp *q) #ifdef NMQT_STATIC : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else : iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , networkType(WimaxNsp::Unknown) , signalQuality(0) , q_ptr(q) { } NetworkManager::WimaxNsp::WimaxNsp(const QString &path, QObject *parent) : QObject(parent) , d_ptr(new WimaxNspPrivate(path, this)) { Q_D(WimaxNsp); d->uni = path; if (d->iface.isValid()) { d->networkType = convertNetworkType(d->iface.networkType()); d->name = d->iface.name(); d->signalQuality = d->iface.signalQuality(); connect(&d->iface, &OrgFreedesktopNetworkManagerWiMaxNspInterface::PropertiesChanged, d, &WimaxNspPrivate::propertiesChanged); } } NetworkManager::WimaxNsp::~WimaxNsp() { Q_D(WimaxNsp); delete d; } QString NetworkManager::WimaxNsp::uni() const { Q_D(const WimaxNsp); return d->uni; } NetworkManager::WimaxNsp::NetworkType NetworkManager::WimaxNsp::networkType() const { Q_D(const WimaxNsp); return d->networkType; } QString NetworkManager::WimaxNsp::name() const { Q_D(const WimaxNsp); return d->name; } uint NetworkManager::WimaxNsp::signalQuality() const { Q_D(const WimaxNsp); return d->signalQuality; } void NetworkManager::WimaxNspPrivate::propertiesChanged(const QVariantMap &properties) { Q_Q(WimaxNsp); QVariantMap::const_iterator it = properties.constBegin(); while (it != properties.constEnd()) { const QString property = it.key(); if (property == QLatin1String("Name")) { name = it->toString(); Q_EMIT q->nameChanged(name); } else if (property == QLatin1String("NetworkType")) { networkType = convertNetworkType(it->toUInt()); Q_EMIT q->networkTypeChanged(networkType); } else if (property == QLatin1String("SignalQuality")) { signalQuality = it->toUInt(); Q_EMIT q->signalQualityChanged(signalQuality); } else { qCWarning(NMQT) << Q_FUNC_INFO << "Unhandled property" << property; } ++it; } } diff --git a/src/wimaxnsp.h b/src/wimaxnsp.h index 7112b4f..2c6355d 100644 --- a/src/wimaxnsp.h +++ b/src/wimaxnsp.h @@ -1,94 +1,80 @@ /* - Copyright 2011 Ilia Kats - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2011 Ilia Kats + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Daniel Nicoletti - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIMAXNSP_H #define NETWORKMANAGERQT_WIMAXNSP_H #include #include namespace NetworkManager { class WimaxNspPrivate; /** * Wimax network service provider (access point) */ class NETWORKMANAGERQT_EXPORT WimaxNsp : public QObject { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; /** * network types a NSP can have */ enum NetworkType { Unknown = 0x1, Home = 0x2, Partner = 0x3, RoamingPartner = 0x4 }; explicit WimaxNsp(const QString &path, QObject *parent = nullptr); virtual ~WimaxNsp(); QString uni() const; /** * The network type of the NSP */ NetworkType networkType() const; /** * The name of the NSP */ QString name() const; /** * The current signal quality of the NSP, in percent */ uint signalQuality() const; Q_SIGNALS: /** * This signal is emitted when the network type of this NSP has changed. * * @param type the new type */ void networkTypeChanged(NetworkType type); /** * This signal is emitted when the name of this NSP has changed * * @param name the new name for this NSP */ void nameChanged(const QString &name); /** * This signal is emitted when the signal quality of this NSP has changed. * * @param quality the new quality */ void signalQualityChanged(uint quality); private: Q_DECLARE_PRIVATE(WimaxNsp) WimaxNspPrivate *const d_ptr; }; } #endif diff --git a/src/wimaxnsp_p.h b/src/wimaxnsp_p.h index c1289c4..bf73ab1 100644 --- a/src/wimaxnsp_p.h +++ b/src/wimaxnsp_p.h @@ -1,48 +1,34 @@ /* - Copyright 2014 Jan Grulich + SPDX-FileCopyrightText: 2014 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIMAXNSP_P_H #define NETWORKMANAGERQT_WIMAXNSP_P_H #include "wimaxnsp.h" #include "dbus/wimaxnspinterface.h" namespace NetworkManager { class WimaxNspPrivate : public QObject { Q_OBJECT public: WimaxNspPrivate(const QString &path, WimaxNsp *q); OrgFreedesktopNetworkManagerWiMaxNspInterface iface; QString uni; WimaxNsp::NetworkType networkType; QString name; uint signalQuality; Q_DECLARE_PUBLIC(WimaxNsp) WimaxNsp *q_ptr; private Q_SLOTS: void propertiesChanged(const QVariantMap &properties); }; } #endif // NETWORKMANAGERQT_WIMAXNSP_P_H diff --git a/src/wireddevice.cpp b/src/wireddevice.cpp index 66bd82b..43e5df1 100644 --- a/src/wireddevice.cpp +++ b/src/wireddevice.cpp @@ -1,127 +1,113 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wireddevice.h" #include "wireddevice_p.h" #include "manager.h" #include "manager_p.h" #include "nmdebug.h" NetworkManager::WiredDevicePrivate::WiredDevicePrivate(const QString &path, WiredDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , wiredIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , wiredIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , bitrate(0) , carrier(false) { } NetworkManager::WiredDevicePrivate::~WiredDevicePrivate() { } NetworkManager::WiredDevice::WiredDevice(const QString &path, QObject *parent) : Device(*new NetworkManager::WiredDevicePrivate(path, this), parent) { Q_D(WiredDevice); // Get all WiredDevices's properties at once QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->wiredIface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } #ifndef NMQT_STATIC QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); #endif #ifdef NMQT_STATIC connect(&d->wiredIface, &OrgFreedesktopNetworkManagerDeviceWiredInterface::PropertiesChanged, d, &WiredDevicePrivate::propertiesChanged); #endif } NetworkManager::WiredDevice::~WiredDevice() { } NetworkManager::Device::Type NetworkManager::WiredDevice::type() const { return NetworkManager::Device::Ethernet; } QString NetworkManager::WiredDevice::hardwareAddress() const { Q_D(const NetworkManager::WiredDevice); return d->hardwareAddress; } QString NetworkManager::WiredDevice::permanentHardwareAddress() const { Q_D(const NetworkManager::WiredDevice); return d->permanentHardwareAddress; } int NetworkManager::WiredDevice::bitRate() const { Q_D(const NetworkManager::WiredDevice); return d->bitrate; } bool NetworkManager::WiredDevice::carrier() const { Q_D(const NetworkManager::WiredDevice); return d->carrier; } QStringList NetworkManager::WiredDevice::s390SubChannels() const { Q_D(const NetworkManager::WiredDevice); return d->s390SubChannels; } void NetworkManager::WiredDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(NetworkManager::WiredDevice); if (property == QLatin1String("Carrier")) { carrier = value.toBool(); Q_EMIT q->carrierChanged(carrier); } else if (property == QLatin1String("HwAddress")) { hardwareAddress = value.toString(); Q_EMIT q->hardwareAddressChanged(hardwareAddress); } else if (property == QLatin1String("PermHwAddress")) { permanentHardwareAddress = value.toString(); Q_EMIT q->permanentHardwareAddressChanged(permanentHardwareAddress); } else if (property == QLatin1String("Speed")) { bitrate = value.toUInt() * 1000; Q_EMIT q->bitRateChanged(bitrate); } else if (property == QLatin1String("S390Subchannels")) { s390SubChannels = value.toStringList(); Q_EMIT q->s390SubChannelsChanged(s390SubChannels); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/wireddevice.h b/src/wireddevice.h index c21bb13..e8a59a7 100644 --- a/src/wireddevice.h +++ b/src/wireddevice.h @@ -1,106 +1,92 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIREDDEVICE_H #define NETWORKMANAGERQT_WIREDDEVICE_H #include #include "device.h" namespace NetworkManager { class WiredDevicePrivate; /** * A wired device interface */ class NETWORKMANAGERQT_EXPORT WiredDevice : public Device { Q_OBJECT Q_PROPERTY(QString hardwareAddress READ hardwareAddress) Q_PROPERTY(QString permanentHardwareAddress READ permanentHardwareAddress) Q_PROPERTY(bool carrier READ carrier NOTIFY carrierChanged) Q_PROPERTY(int bitRate READ bitRate NOTIFY bitRateChanged) Q_PROPERTY(QStringList s390SubChannels READ s390SubChannels NOTIFY s390SubChannelsChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit WiredDevice(const QString &path, QObject *parent = nullptr); ~WiredDevice() override; /** * Return the type */ Type type() const override; /** * Active hardware address of the device */ QString hardwareAddress() const; /** * Permanent hardware address of the device */ QString permanentHardwareAddress() const; /** * Design speed of the device, in megabits/second (Mb/s) */ int bitRate() const; /** * Indicates whether the physical carrier is found (e.g. whether a cable is plugged in or not) */ bool carrier() const; /** * Array of S/390 subchannels for S/390 or z/Architecture devices */ QStringList s390SubChannels() const; Q_SIGNALS: /** * Emitted when the design speed of the device has changed */ void bitRateChanged(int bitRate); /** * Emitted when the carrier of this device has changed */ void carrierChanged(bool plugged); /** * Emitted when the hardware address of this device has changed */ void hardwareAddressChanged(const QString &hwAddress); /** * Emitted when the permanent hardware address of this device has changed */ void permanentHardwareAddressChanged(const QString &permHwAddress); /* * Emitted when the array of s390SubChannels has changed */ void s390SubChannelsChanged(const QStringList &channels); private: Q_DECLARE_PRIVATE(WiredDevice) }; } #endif // NETWORKMANAGERQT_WIREDDEVICE_H diff --git a/src/wireddevice_p.h b/src/wireddevice_p.h index d50c374..068fc47 100644 --- a/src/wireddevice_p.h +++ b/src/wireddevice_p.h @@ -1,54 +1,40 @@ /* - Copyright 2008,2011 Will Stephenson - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIREDDEVICE_P_H #define NETWORKMANAGERQT_WIREDDEVICE_P_H #include "device_p.h" #include "dbus/wireddeviceinterface.h" namespace NetworkManager { class WiredDevicePrivate : public DevicePrivate { Q_OBJECT public: explicit WiredDevicePrivate(const QString &path, WiredDevice *q); virtual ~WiredDevicePrivate(); OrgFreedesktopNetworkManagerDeviceWiredInterface wiredIface; QString hardwareAddress; QString permanentHardwareAddress; QStringList s390SubChannels; int bitrate; bool carrier; Q_DECLARE_PUBLIC(WiredDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } // namespace NetworkManager #endif diff --git a/src/wireguarddevice.cpp b/src/wireguarddevice.cpp index c80dbe3..29908a3 100644 --- a/src/wireguarddevice.cpp +++ b/src/wireguarddevice.cpp @@ -1,101 +1,87 @@ /* - Copyright 2019 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2019 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wireguarddevice.h" #include "wireguarddevice_p.h" #include "manager_p.h" NetworkManager::WireGuardDevicePrivate::WireGuardDevicePrivate(const QString &path, WireGuardDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , listenPort(0) , fwMark(0) { } NetworkManager::WireGuardDevicePrivate::~WireGuardDevicePrivate() { } NetworkManager::WireGuardDevice::WireGuardDevice(const QString &path, QObject *parent): Device(*new WireGuardDevicePrivate(path, this), parent) { Q_D(WireGuardDevice); QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->iface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); } NetworkManager::WireGuardDevice::~WireGuardDevice() { } NetworkManager::Device::Type NetworkManager::WireGuardDevice::type() const { return NetworkManager::Device::WireGuard; } QByteArray NetworkManager::WireGuardDevice::publicKey() const { Q_D(const WireGuardDevice); return d->publicKey; } uint NetworkManager::WireGuardDevice::listenPort() const { Q_D(const WireGuardDevice); return d->listenPort; } uint NetworkManager::WireGuardDevice::fwMark() const { Q_D(const WireGuardDevice); return d->fwMark; } void NetworkManager::WireGuardDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(WireGuardDevice); if (property == QLatin1String("PublicKey")) { publicKey = value.toByteArray(); Q_EMIT q->publicKeyChanged(publicKey); } else if (property == QLatin1String("ListenPort")) { listenPort = value.toUInt(); Q_EMIT q->listenPortChanged(listenPort); } else if (property == QLatin1String("FwMark")) { fwMark = value.toUInt(); Q_EMIT q->fwMarkChanged(fwMark); } else { DevicePrivate::propertyChanged(property, value); } } diff --git a/src/wireguarddevice.h b/src/wireguarddevice.h index 6317473..917a364 100644 --- a/src/wireguarddevice.h +++ b/src/wireguarddevice.h @@ -1,84 +1,70 @@ /* - Copyright 2019 Jan Grulich + SPDX-FileCopyrightText: 2019 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIREGUARD_DEVICE_H #define NETWORKMANAGERQT_WIREGUARD_DEVICE_H #include "device.h" #include namespace NetworkManager { class WireGuardDevicePrivate; /** * A WireGuard device interface */ class NETWORKMANAGERQT_EXPORT WireGuardDevice : public Device { Q_OBJECT Q_PROPERTY(QByteArray publicKey READ publicKey NOTIFY publicKeyChanged) Q_PROPERTY(uint listenPort READ listenPort NOTIFY listenPortChanged) Q_PROPERTY(uint fwMark READ fwMark NOTIFY fwMarkChanged) public: typedef QSharedPointer Ptr; typedef QList List; explicit WireGuardDevice(const QString &path, QObject *parent = nullptr); ~WireGuardDevice() override; Type type() const override; /** * 32-byte public WireGuard key. */ QByteArray publicKey() const; /** * Local UDP listening port. */ uint listenPort() const; /** * Optional 32-bit mark used to set routing policy for outgoing encrypted packets. See: ip-rule(8) */ uint fwMark() const; Q_SIGNALS: /** * Emitted when the public key of this device has changed */ void publicKeyChanged(const QByteArray &publicKey); /** * Emitted when the listen port of this device has changed */ void listenPortChanged(uint listenPort); /** * Emitted when the fwmark of this device have changed */ void fwMarkChanged(uint fwMark); private: Q_DECLARE_PRIVATE(WireGuardDevice) }; } #endif diff --git a/src/wireguarddevice_p.h b/src/wireguarddevice_p.h index 4fbeb39..7d3ede0 100644 --- a/src/wireguarddevice_p.h +++ b/src/wireguarddevice_p.h @@ -1,54 +1,40 @@ /* - Copyright 2019 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2019 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIREGUARD_DEVICE_P_H #define NETWORKMANAGERQT_WIREGUARD_DEVICE_P_H #include "wireguarddevice.h" #include "device_p.h" #include "manager.h" #include "wireguarddeviceinterface.h" namespace NetworkManager { class WireGuardDevicePrivate : public DevicePrivate { public: WireGuardDevicePrivate(const QString &path, WireGuardDevice *q); virtual ~WireGuardDevicePrivate(); OrgFreedesktopNetworkManagerDeviceWireGuardInterface iface; QByteArray publicKey; uint listenPort; uint fwMark; Q_DECLARE_PUBLIC(WireGuardDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; }; } #endif diff --git a/src/wirelessdevice.cpp b/src/wirelessdevice.cpp index 11bdc89..a9741a5 100644 --- a/src/wirelessdevice.cpp +++ b/src/wirelessdevice.cpp @@ -1,285 +1,271 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2013 Daniel Nicoletti - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wirelessdevice.h" #include "wirelessdevice_p.h" #undef signals #include #define signals Q_SIGNALS #include "accesspoint.h" #include "manager_p.h" #include "nmdebug.h" #include "utils.h" NetworkManager::WirelessDevicePrivate::WirelessDevicePrivate(const QString &path, WirelessDevice *q) : DevicePrivate(path, q) #ifdef NMQT_STATIC , wirelessIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus()) #else , wirelessIface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus()) #endif , bitRate(0) { } NetworkManager::WirelessDevice::WirelessDevice(const QString &path, QObject *parent) : Device(*new WirelessDevicePrivate(path, this), parent) { Q_D(WirelessDevice); qDBusRegisterMetaType >(); QList aps = d->wirelessIface.accessPoints(); // qCDebug(NMQT) << "AccessPoint list"; Q_FOREACH (const QDBusObjectPath & op, aps) { // qCDebug(NMQT) << " " << op.path(); d->accessPointAdded(op); } // Get all WirelessDevices's properties at once QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(d->wirelessIface.staticInterfaceName(), path); if (!initialProperties.isEmpty()) { d->propertiesChanged(initialProperties); } #ifndef NMQT_STATIC QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE, d->uni, NetworkManagerPrivate::FDO_DBUS_PROPERTIES, QLatin1String("PropertiesChanged"), d, SLOT(dbusPropertiesChanged(QString,QVariantMap,QStringList))); #endif #ifdef NMQT_STATIC connect(&d->wirelessIface, &OrgFreedesktopNetworkManagerDeviceWirelessInterface::PropertiesChanged, d, &WirelessDevicePrivate::propertiesChanged); #endif connect(&d->wirelessIface, &OrgFreedesktopNetworkManagerDeviceWirelessInterface::AccessPointAdded, d, &WirelessDevicePrivate::accessPointAdded); connect(&d->wirelessIface, &OrgFreedesktopNetworkManagerDeviceWirelessInterface::AccessPointRemoved, d, &WirelessDevicePrivate::accessPointRemoved); } NetworkManager::WirelessDevice::~WirelessDevice() { } NetworkManager::Device::Type NetworkManager::WirelessDevice::type() const { return NetworkManager::Device::Wifi; } QStringList NetworkManager::WirelessDevice::accessPoints() const { Q_D(const WirelessDevice); return d->apMap.keys(); } QDBusPendingReply<> NetworkManager::WirelessDevice::requestScan(const QVariantMap &options) { Q_D(WirelessDevice); d->lastRequestScan = QDateTime::currentDateTime(); return d->wirelessIface.RequestScan(options); } NetworkManager::AccessPoint::Ptr NetworkManager::WirelessDevice::activeAccessPoint() const { Q_D(const WirelessDevice); return d->activeAccessPoint; } QString NetworkManager::WirelessDevice::hardwareAddress() const { Q_D(const WirelessDevice); return d->hardwareAddress; } QString NetworkManager::WirelessDevice::permanentHardwareAddress() const { Q_D(const WirelessDevice); return d->permanentHardwareAddress; } NetworkManager::WirelessDevice::OperationMode NetworkManager::WirelessDevice::mode() const { Q_D(const WirelessDevice); return d->mode; } int NetworkManager::WirelessDevice::bitRate() const { Q_D(const WirelessDevice); return d->bitRate; } QDateTime NetworkManager::WirelessDevice::lastScan() const { Q_D(const WirelessDevice); return d->lastScan; } QDateTime NetworkManager::WirelessDevice::lastRequestScan() const { Q_D(const WirelessDevice); return d->lastRequestScan; } NetworkManager::WirelessDevice::Capabilities NetworkManager::WirelessDevice::wirelessCapabilities() const { Q_D(const WirelessDevice); return d->wirelessCapabilities; } NetworkManager::AccessPoint::Ptr NetworkManager::WirelessDevice::findAccessPoint(const QString &uni) { Q_D(WirelessDevice); NetworkManager::AccessPoint::Ptr accessPoint; QMap::ConstIterator mapIt = d->apMap.constFind(uni); if (mapIt != d->apMap.constEnd()) { accessPoint = mapIt.value(); } else if (!uni.isEmpty() && uni != QLatin1String("/")) { d->accessPointAdded(QDBusObjectPath(uni)); mapIt = d->apMap.constFind(uni); if (mapIt != d->apMap.constEnd()) { accessPoint = mapIt.value(); } } return accessPoint; } NetworkManager::WirelessNetwork::List NetworkManager::WirelessDevice::networks() const { Q_D(const WirelessDevice); return d->networks.values(); } NetworkManager::WirelessNetwork::Ptr NetworkManager::WirelessDevice::findNetwork(const QString &ssid) const { Q_D(const WirelessDevice); NetworkManager::WirelessNetwork::Ptr ret; if (d->networks.contains(ssid)) { ret = d->networks.value(ssid); } return ret; } void NetworkManager::WirelessDevicePrivate::accessPointAdded(const QDBusObjectPath &accessPoint) { //kDebug(1441) << apPath.path(); Q_Q(WirelessDevice); if (!apMap.contains(accessPoint.path())) { NetworkManager::AccessPoint::Ptr accessPointPtr(new NetworkManager::AccessPoint(accessPoint.path()), &QObject::deleteLater); apMap.insert(accessPoint.path(), accessPointPtr); Q_EMIT q->accessPointAppeared(accessPoint.path()); const QString ssid = accessPointPtr->ssid(); if (!ssid.isEmpty() && !networks.contains(ssid)) { NetworkManager::WirelessNetwork::Ptr wifiNetwork(new NetworkManager::WirelessNetwork(accessPointPtr, q), &QObject::deleteLater); networks.insert(ssid, wifiNetwork); connect(wifiNetwork.data(), &WirelessNetwork::disappeared, this, &WirelessDevicePrivate::removeNetwork); Q_EMIT q->networkAppeared(ssid); } } } void NetworkManager::WirelessDevicePrivate::accessPointRemoved(const QDBusObjectPath &accessPoint) { //kDebug(1441) << apPath.path(); Q_Q(WirelessDevice); if (!apMap.contains(accessPoint.path())) { qCDebug(NMQT) << "Access point list lookup failed for " << accessPoint.path(); } Q_EMIT q->accessPointDisappeared(accessPoint.path()); apMap.remove(accessPoint.path()); } void NetworkManager::WirelessDevicePrivate::removeNetwork(const QString &network) { Q_Q(WirelessDevice); if (networks.contains(network)) { networks.remove(network); Q_EMIT q->networkDisappeared(network); } } void NetworkManager::WirelessDevicePrivate::propertyChanged(const QString &property, const QVariant &value) { Q_Q(WirelessDevice); if (property == QLatin1String("ActiveAccessPoint")) { QDBusObjectPath activeAccessPointTmp = qdbus_cast(value); activeAccessPoint = q->findAccessPoint(activeAccessPointTmp.path()); Q_EMIT q->activeAccessPointChanged(activeAccessPointTmp.path()); } else if (property == QLatin1String("HwAddress")) { hardwareAddress = value.toString(); Q_EMIT q->hardwareAddressChanged(hardwareAddress); } else if (property == QLatin1String("PermHwAddress")) { permanentHardwareAddress = value.toString(); Q_EMIT q->permanentHardwareAddressChanged(permanentHardwareAddress); } else if (property == QLatin1String("Bitrate")) { bitRate = value.toUInt(); Q_EMIT q->bitRateChanged(bitRate); } else if (property == QLatin1String("Mode")) { mode = q->convertOperationMode(value.toUInt()); Q_EMIT q->modeChanged(mode); } else if (property == QLatin1String("WirelessCapabilities")) { wirelessCapabilities = q->convertCapabilities(value.toUInt()); Q_EMIT q->wirelessCapabilitiesChanged(wirelessCapabilities); } else if (property == QLatin1String("LastScan")) { lastScan = NetworkManager::clockBootTimeToDateTime(value.toLongLong()); Q_EMIT q->lastScanChanged(lastScan); } else if (property == QLatin1String("AccessPoints")) { // TODO use this instead AccessPointAdded/Removed signals? } else { DevicePrivate::propertyChanged(property, value); } } NetworkManager::WirelessDevice::OperationMode NetworkManager::WirelessDevice::convertOperationMode(uint theirMode) { NetworkManager::WirelessDevice::OperationMode ourMode = NetworkManager::WirelessDevice::Unknown; switch (theirMode) { case NM_802_11_MODE_UNKNOWN: ourMode = NetworkManager::WirelessDevice::Unknown; break; case NM_802_11_MODE_ADHOC: ourMode = NetworkManager::WirelessDevice::Adhoc; break; case NM_802_11_MODE_INFRA: ourMode = NetworkManager::WirelessDevice::Infra; break; case NM_802_11_MODE_AP: ourMode = NetworkManager::WirelessDevice::ApMode; break; default: qCDebug(NMQT) << Q_FUNC_INFO << "Unhandled mode" << theirMode; } return ourMode; } NetworkManager::WirelessDevice::Capabilities NetworkManager::WirelessDevice::convertCapabilities(uint caps) { return (NetworkManager::WirelessDevice::Capabilities)caps; } diff --git a/src/wirelessdevice.h b/src/wirelessdevice.h index 764f630..28f32ee 100644 --- a/src/wirelessdevice.h +++ b/src/wirelessdevice.h @@ -1,241 +1,227 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Daniel Nicoletti - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Daniel Nicoletti + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRELESSDEVICE_H #define NETWORKMANAGERQT_WIRELESSDEVICE_H #include #include "device.h" #include "accesspoint.h" #include "wirelessnetwork.h" #include #include namespace NetworkManager { class WirelessDevicePrivate; /** * A wireless network interface */ class NETWORKMANAGERQT_EXPORT WirelessDevice : public Device { Q_OBJECT public: typedef QSharedPointer Ptr; typedef QList List; /** * The device's current operating mode */ enum OperationMode { Unknown = 0, /**< not associated with a network */ Adhoc, /**< part of an adhoc network */ Infra, /**< a station in an infrastructure wireless network */ ApMode /**< access point in an infrastructure network */ }; Q_ENUM(OperationMode) /** * Capabilities (currently all encryption/authentication related) of the device * @note FreqValid, Freq2Ghz, Freq5Ghz are available in runtime NM >= 1.0.2 */ enum Capability { NoCapability = 0x0, /**< Null capability */ Wep40 = 0x1, /**< 40 bit WEP cipher */ Wep104 = 0x2, /**< 104 bit WEP cipher */ Tkip = 0x4, /**< TKIP encryption cipher */ Ccmp = 0x8, /**< CCMP encryption cipher */ Wpa = 0x10, /**< WPA authentication protocol */ Rsn = 0x20, /**< RSN authethication protocol */ ApCap = 0x40, /**< The device supports Access Point mode. */ AdhocCap = 0x80, /**< The device supports Ad-Hoc mode. */ FreqValid = 0x100, /**< The device properly reports information about supported frequencies */ Freq2Ghz = 0x200, /**< The device supports 2.4Ghz frequencies */ Freq5Ghz = 0x400, /**< The device supports 5Ghz frequencies */ Mesh = 0x1000, /**< The device supports acting as a mesh point */ IBSSRsn = 0x2000 /**< device supports WPA2/RSN in an IBSS network */ }; Q_DECLARE_FLAGS(Capabilities, Capability) /** * Creates a new WirelessDevice object. * * @param path the DBus path of the devise */ explicit WirelessDevice(const QString &path, QObject *parent = nullptr); /** * Destroys a WirelessDevice object. */ ~WirelessDevice() override; /** * Return the type */ Type type() const override; /** * List of wireless networks currently visible to the hardware */ QStringList accessPoints() const; /** * Asks the device for a new scan of available wireless networks * @param options Options of scan * No documentation for options yet, see http://projects.gnome.org/NetworkManager/developers/api/09/spec.html#org.freedesktop.NetworkManager.Device.Wireless */ QDBusPendingReply<> requestScan(const QVariantMap &options = QVariantMap()); /** * AccessPoint pointer this interface is currently associated with */ AccessPoint::Ptr activeAccessPoint() const; /** * The permanent hardware address of the network interface */ QString permanentHardwareAddress() const; /** * The hardware address currently used by the network interface */ QString hardwareAddress() const; /** * Retrieves the operation mode of this network. * * @return the current mode * @see OperationMode */ WirelessDevice::OperationMode mode() const; /** * Retrieves the effective bit rate currently attainable by this device. * * @return the bitrate in Kbit/s */ int bitRate() const; /** * The LastScan property value, converted to QDateTime * @since 5.62.0 * @note will always return invalid QDateTime when runtime NM < 1.12 * @return */ QDateTime lastScan() const; /** * The time the last RequestScan function was called * @since 5.62.0 * @return */ QDateTime lastRequestScan() const; /** * Retrieves the capabilities of this wifi network. * * @return the flag set describing the capabilities * @see Capabilities */ WirelessDevice::Capabilities wirelessCapabilities() const; /** * Helper method to convert wire representation of operation mode to enum */ static WirelessDevice::OperationMode convertOperationMode(uint); /** * Helper method to convert wire representation of capabilities to enum */ static WirelessDevice::Capabilities convertCapabilities(uint); /** * Finds access point object given its Unique Network Identifier. * * @param uni the identifier of the AP to find from this network interface * @returns a valid AccessPoint object if a network having the given UNI for this device is known to the system, 0 otherwise */ AccessPoint::Ptr findAccessPoint(const QString &uni); /** * Return the current list of networks */ WirelessNetwork::List networks() const; /** * Find a network with the given @p ssid, a Null object is * returned if it can not be found */ WirelessNetwork::Ptr findNetwork(const QString &ssid) const; Q_SIGNALS: /** * This signal is emitted when the bitrate of this network has changed. * * @param bitrate the new bitrate value for this network */ void bitRateChanged(int bitrate); /** * The active network changed. */ void activeAccessPointChanged(const QString &); /** * The device switched operating mode. */ void modeChanged(WirelessDevice::OperationMode); /** * The device changed its capabilities */ void wirelessCapabilitiesChanged(Capabilities); /** * The device changed its hardware address */ void hardwareAddressChanged(const QString &); /** * The device changed its permanent hardware address */ void permanentHardwareAddressChanged(const QString &); /** * The device changed its properties */ void wirelessPropertiesChanged(uint); // TODO this is bogus, remove /** * A new wireless access point appeared */ void accessPointAppeared(const QString &uni); /** * A wireless access point disappeared */ void accessPointDisappeared(const QString &uni); /** * A wireless network appeared */ void networkAppeared(const QString &ssid); /** * A wireless network disappeared */ void networkDisappeared(const QString &ssid); /** * The LastScan property has changed, meaning a scan has just finished * @since 5.62.0 * @note will never be emitted when runtime NM < 1.12 * @see lastScanTime */ void lastScanChanged(const QDateTime &dateTime); private: Q_DECLARE_PRIVATE(WirelessDevice) }; } // namespace NetworkManager #endif //NETWORKMANAGERQT_WIRELESSDEVICE_H diff --git a/src/wirelessdevice_p.h b/src/wirelessdevice_p.h index ce73f61..d8d0698 100644 --- a/src/wirelessdevice_p.h +++ b/src/wirelessdevice_p.h @@ -1,66 +1,52 @@ /* - Copyright 2008,2011 Will Stephenson - Copyright 2013 Jan Grulich + SPDX-FileCopyrightText: 2008, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Jan Grulich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRELESSDEVICE_P_H #define NETWORKMANAGERQT_WIRELESSDEVICE_P_H #include "device_p.h" #include "dbus/wirelessdeviceinterface.h" namespace NetworkManager { class WirelessDevicePrivate : public DevicePrivate { Q_OBJECT public: explicit WirelessDevicePrivate(const QString &path, WirelessDevice *q); OrgFreedesktopNetworkManagerDeviceWirelessInterface wirelessIface; QString permanentHardwareAddress; QString hardwareAddress; QHash networks; QMap apMap; // index of the active AP or -1 if none AccessPoint::Ptr activeAccessPoint; WirelessDevice::OperationMode mode; uint bitRate; WirelessDevice::Capabilities wirelessCapabilities; QDateTime lastScan; QDateTime lastRequestScan; Q_DECLARE_PUBLIC(WirelessDevice) protected: /** * When subclassing make sure to call the parent class method * if the property was not useful to your new class */ void propertyChanged(const QString &property, const QVariant &value) override; protected Q_SLOTS: void accessPointAdded(const QDBusObjectPath &); void accessPointRemoved(const QDBusObjectPath &); void removeNetwork(const QString &network); }; } #endif diff --git a/src/wirelessnetwork.cpp b/src/wirelessnetwork.cpp index 1ba7053..0efaad3 100644 --- a/src/wirelessnetwork.cpp +++ b/src/wirelessnetwork.cpp @@ -1,148 +1,134 @@ /* - Copyright 2009,2011 Will Stephenson - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2009, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "wirelessnetwork.h" #include "wirelessnetwork_p.h" #include "wirelessdevice.h" #include "manager.h" NetworkManager::WirelessNetworkPrivate::WirelessNetworkPrivate(WirelessNetwork *q, WirelessDevice *device) : q_ptr(q) , wirelessNetworkInterface(device) { QObject::connect(device, SIGNAL(accessPointAppeared(QString)), q, SLOT(accessPointAppeared(QString))); QObject::connect(device, SIGNAL(accessPointDisappeared(QString)), q, SLOT(accessPointDisappeared(QString))); } NetworkManager::WirelessNetworkPrivate::~WirelessNetworkPrivate() { } void NetworkManager::WirelessNetworkPrivate::addAccessPointInternal(const NetworkManager::AccessPoint::Ptr &accessPoint) { Q_Q(WirelessNetwork); QObject::connect(accessPoint.data(), SIGNAL(signalStrengthChanged(int)), q, SLOT(updateStrength())); aps.insert(accessPoint->uni(), accessPoint); updateStrength(); } void NetworkManager::WirelessNetworkPrivate::accessPointAppeared(const QString &uni) { if (!aps.contains(uni) && wirelessNetworkInterface) { NetworkManager::AccessPoint::Ptr accessPoint = wirelessNetworkInterface->findAccessPoint(uni); if (accessPoint && accessPoint->ssid() == ssid) { addAccessPointInternal(accessPoint); } } } void NetworkManager::WirelessNetworkPrivate::accessPointDisappeared(const QString &uni) { Q_Q(WirelessNetwork); aps.remove(uni); if (aps.isEmpty()) { Q_EMIT q->disappeared(ssid); } else { updateStrength(); } } void NetworkManager::WirelessNetworkPrivate::updateStrength() { Q_Q(WirelessNetwork); int maximumStrength = -1; NetworkManager::AccessPoint::Ptr strongestAp; Q_FOREACH (const NetworkManager::AccessPoint::Ptr & iface, aps) { if (maximumStrength <= iface->signalStrength()) { maximumStrength = iface->signalStrength(); strongestAp = iface; } } if (maximumStrength != strength) { strength = maximumStrength; Q_EMIT q->signalStrengthChanged(strength); } if (strongestAp && referenceAp != strongestAp) { referenceAp = strongestAp; Q_EMIT q->referenceAccessPointChanged(referenceAp->uni()); } //TODO: update the networks delayed //kDebug() << "update strength" << ssid << strength; } NetworkManager::WirelessNetwork::WirelessNetwork(const AccessPoint::Ptr &accessPoint, WirelessDevice *device) : d_ptr(new WirelessNetworkPrivate(this, device)) { Q_D(WirelessNetwork); d->strength = -1; d->ssid = accessPoint->ssid(); d->addAccessPointInternal(accessPoint); } NetworkManager::WirelessNetwork::~WirelessNetwork() { delete d_ptr; } QString NetworkManager::WirelessNetwork::ssid() const { Q_D(const WirelessNetwork); return d->ssid; } int NetworkManager::WirelessNetwork::signalStrength() const { Q_D(const WirelessNetwork); return d->strength; } NetworkManager::AccessPoint::Ptr NetworkManager::WirelessNetwork::referenceAccessPoint() const { Q_D(const WirelessNetwork); return d->referenceAp; } NetworkManager::AccessPoint::List NetworkManager::WirelessNetwork::accessPoints() const { Q_D(const WirelessNetwork); return d->aps.values(); } QString NetworkManager::WirelessNetwork::device() const { Q_D(const WirelessNetwork); if (d->wirelessNetworkInterface) { return d->wirelessNetworkInterface->uni(); } else { return QString(); } } #include "moc_wirelessnetwork.cpp" diff --git a/src/wirelessnetwork.h b/src/wirelessnetwork.h index 8b3467e..c7458d8 100644 --- a/src/wirelessnetwork.h +++ b/src/wirelessnetwork.h @@ -1,111 +1,97 @@ /* - Copyright 2009,2011 Will Stephenson - Copyright 2011-2013 Lamarque V. Souza - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2009, 2011 Will Stephenson + SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRELESSNETWORK_H #define NETWORKMANAGERQT_WIRELESSNETWORK_H #include #include "accesspoint.h" #include #include namespace NetworkManager { class WirelessDevice; class WirelessNetworkPrivate; /** * This class represents a wireless network, which aggregates all * access points with the same SSID */ class NETWORKMANAGERQT_EXPORT WirelessNetwork : public QObject { Q_OBJECT friend class WirelessDevice; friend class WirelessDevicePrivate; public: typedef QSharedPointer Ptr; typedef QList List; ~WirelessNetwork(); /** * ESSID of the network */ QString ssid() const; /** * Signal strength of the network. Syntactic sugar around tracking the reference access * point and watching its signal strength */ int signalStrength() const; /** * The uni of the current 'best' (strongest) Access Point. Note that this may change or disappear over time. * Get the Access Point object using @ref WirelessDevice::findAccessPoint() on the NetworkInterface this network was obtained from. * Use @ref WirelessDevice::accessPointDisappeared() or * WirelessNetwork::referenceAccessPointChanged() to detect this. */ AccessPoint::Ptr referenceAccessPoint() const; /** * List of access points * @warning Subject to change, do not store! */ AccessPoint::List accessPoints() const; /** * The uni of device associated with this network. */ QString device() const; Q_SIGNALS: /** * Indicate that the signal strength changed * @param strength strength as a percentage. */ void signalStrengthChanged(int strength); /** * Indicate that the reference access point changed * @param apUni new access point or empty string if none */ void referenceAccessPointChanged(const QString &apUni); /** * Indicate that this network has no more access points * (meaning the network has disappeared from view of the network interface) * @param ssid the SSID of this network */ void disappeared(const QString &ssid); private: Q_DECLARE_PRIVATE(WirelessNetwork) Q_PRIVATE_SLOT(d_func(), void accessPointAppeared(const QString &)) Q_PRIVATE_SLOT(d_func(), void accessPointDisappeared(const QString &)) Q_PRIVATE_SLOT(d_func(), void updateStrength()) WirelessNetworkPrivate *const d_ptr; explicit WirelessNetwork(const AccessPoint::Ptr &accessPoint, WirelessDevice *device); }; } #endif // NETWORKMANAGERQT_WIRELESSNETWORK_H diff --git a/src/wirelessnetwork_p.h b/src/wirelessnetwork_p.h index 0f512c3..dda3aff 100644 --- a/src/wirelessnetwork_p.h +++ b/src/wirelessnetwork_p.h @@ -1,57 +1,43 @@ /* - Copyright 2009,2011 Will Stephenson - Copyright 2013 Jan Grulich - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-FileCopyrightText: 2009, 2011 Will Stephenson + SPDX-FileCopyrightText: 2013 Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef NETWORKMANAGERQT_WIRELESSNETWORK_P_H #define NETWORKMANAGERQT_WIRELESSNETWORK_P_H #include "wirelessdevice.h" #include namespace NetworkManager { class WirelessNetworkPrivate { public: Q_DECLARE_PUBLIC(WirelessNetwork) WirelessNetwork *q_ptr; WirelessNetworkPrivate(WirelessNetwork *q, WirelessDevice *); ~WirelessNetworkPrivate(); void addAccessPointInternal(const AccessPoint::Ptr &accessPoint); QString ssid; int strength; QPointer wirelessNetworkInterface; QHash aps; AccessPoint::Ptr referenceAp; private Q_SLOTS: void accessPointAppeared(const QString &uni); void accessPointDisappeared(const QString &uni); void updateStrength(); }; } #endif