+++ /dev/null
-project(plasma-networkmanagement)
-
-find_package(NetworkManager "0.9.8.4" REQUIRED)
-
-include(FindPkgConfig)
-
-set(PLASMA_NM_VERSION 0.9.3.6)
-set(PLASMA_NM_STRING_VERSION "${PLASMA_NM_VERSION}")
-
-pkg_check_modules(NETWORKMANAGERQT REQUIRED NetworkManagerQt)
-if (NOT NETWORKMANAGERQT_FOUND)
- message(FATAL_ERROR "ERROR: NetworkManagerQt not found. http://projects.kde.org/libnm-qt")
-elseif(${NETWORKMANAGERQT_VERSION} VERSION_LESS 0.9.8.2)
- message(FATAL_ERROR "ERROR: NetworkManagerQt required version is 0.9.8.2. http://projects.kde.org/libnm-qt")
-endif()
-
-if (DISABLE_MODEMMANAGER_SUPPORT)
- message(STATUS "Disabling ModemManager support")
- set(WITH_MODEMMANAGER_SUPPORT 0)
-else()
- pkg_check_modules(MODEMMANAGERQT ModemManagerQt)
- if (MODEMMANAGERQT_FOUND)
- message(STATUS "Enabling ModemManager support")
- set(WITH_MODEMMANAGER_SUPPORT 1)
- else()
- message(STATUS "ModemManagerQt not found")
- set(WITH_MODEMMANAGER_SUPPORT 0)
- endif()
-endif()
-
-configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} ${CMAKE_MODULE_PATH})
-
-if (MODEMMANAGERQT_FOUND)
- macro_optional_find_package(MobileBroadbandProviderInfo)
- macro_log_feature(MOBILEBROADBANDPROVIDERINFO_FOUND "mobile-broadband-provider-info" "Database of mobile broadband service providers" "http://live.gnome.org/NetworkManager/MobileBroadband/ServiceProviders" FALSE "" "Needed for Mobile Connection Wizard support in Broadband Modem Management")
-endif()
-
-add_definitions(
- -DWITH_MODEMMANAGER_SUPPORT=${WITH_MODEMMANAGER_SUPPORT}
- ${NETWORKMANAGERQT_CFLAGS_OTHER})
-
-include_directories(${CMAKE_CURRENT_BINARY_DIR} # for config.h
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/libs
- ${CMAKE_CURRENT_SOURCE_DIR}/libs/editor/
- ${NETWORKMANAGER_INCLUDE_DIRS}
- ${NM-GLIB_INCLUDE_DIRS}
- ${NETWORKMANAGERQT_INCLUDE_DIRS}
- ${KDE4_INCLUDES})
-
-if (MODEMMANAGERQT_FOUND)
- include_directories(${MODEMMANAGERQT_INCLUDE_DIRS})
-endif()
-
-add_subdirectory(applet)
-add_subdirectory(editor)
-add_subdirectory(kded)
-add_subdirectory(libs)
-add_subdirectory(vpn)
-add_subdirectory(settings)
-
-include(MacroOptionalAddSubdirectory)
+++ /dev/null
- 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.
-
- GNU GENERAL PUBLIC LICENSE
- 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.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 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.
-
- <signature of Ty Coon>, 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.
+++ /dev/null
- 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.
-\f
- 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.
-\f
- GNU LESSER GENERAL PUBLIC LICENSE
- 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.
-\f
- 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.
-\f
- 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.
-\f
- 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.
-\f
- 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.
-\f
- 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.
-\f
- 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
-\f
- 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 a brief 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!
+++ /dev/null
-# - Try to find mobile-broadband-provider-info
-# Once done this will define
-#
-# MOBILEBROADBANDPROVIDERINFO_FOUND - system has mobile-broadband-provider-info
-# MOBILEBROADBANDPROVIDERINFO_CFLAGS - the mobile-broadband-provider-info directory
-
-# Copyright (c) 2011, Lamarque Souza <lamarque@kde.org>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-
-IF (MOBILEBROADBANDPROVIDERINFO_CFLAGS)
- # in cache already
- SET(MobileBroadbandProviderInfo_FIND_QUIETLY TRUE)
-ENDIF (MOBILEBROADBANDPROVIDERINFO_CFLAGS)
-
-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( MOBILEBROADBANDPROVIDERINFO mobile-broadband-provider-info )
-ENDIF (NOT WIN32)
-
-IF (MOBILEBROADBANDPROVIDERINFO_FOUND)
- IF (NOT MobileBroadbandProviderInfo_FIND_QUIETLY)
- MESSAGE(STATUS "Found mobile-broadband-provider-info ${MOBILEBROADBANDPROVIDERINFO_VERSION}: ${MOBILEBROADBANDPROVIDERINFO_CFLAGS}")
- ENDIF (NOT MobileBroadbandProviderInfo_FIND_QUIETLY)
-ELSE (MOBILEBROADBANDPROVIDERINFO_FOUND)
- IF (MobileBroadbandProviderInfo_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could NOT find mobile-broadband-provider-info, check FindPkgConfig output above!")
- ENDIF (MobileBroadbandProviderInfo_FIND_REQUIRED)
-ENDIF (MOBILEBROADBANDPROVIDERINFO_FOUND)
-
-MARK_AS_ADVANCED(MOBILEBROADBANDPROVIDERINFO_CFLAGS)
-
+++ /dev/null
-#!/usr/bin/env bash
-
-$EXTRACTRC `find settings/details -name '*.ui' -o -name '*.rc'` `find applet -name '*.ui'` >> rc.cpp
-$XGETTEXT rc.cpp `find applet -name '*.cpp'` `find libs -name '*.cpp' | grep -v 'libs/editor'` `find settings/details -name '*.cpp'` -o $podir/plasma_applet_org.kde.networkmanagement.pot
-$XGETTEXT `find applet -name '*.qml'` -j -L Java -o $podir/plasma_applet_org.kde.networkmanagement.pot
-rm -f rc.cpp
+++ /dev/null
-Plasma-nm
-========================
-
-Plasma applet written in QML for managing network connections
-
-Dependencies:
--------------
- * libnm-qt - 0.9.8.2 (git NM/0.9.8 branch) or newer version
- - requires NetworkManager 0.9.8.4+, but NetworkManager 0.9.8.10 is recommended
- - requires libmm-qt 1.0.x (MM/1.0 branch) if you want ModemManager support or newer version
-
-Optional dependencies:
----------------------
- * libmm-qt
- - requires ModemManager 1.0+
- - Plasma-nm is compiled with ModemManager support by default when libmm-qt is found,
- when you want to explicitly disable ModemManager support, use -DDISABLE_MODEMMANAGER_SUPPORT=true cmake parameter.
-
- * openconnect
- - if you want to build the OpenConnect VPN plugin
-
- * NetworkManager-openvpn|openconnect|openswan|l2tp|strongswan|pptp|vpnc
- - these are runtime dependencies for VPN plugins
-
-Compiling:
-----------
- mkdir build
- cd build
- cmake ../ -DCMAKE_INSTALL_PREFIX=/usr [-DDISABLE_MODEMMANAGER_SUPPORT=true]
- make
- # As root:
- make install
-
-
-BUGS:
------
-Submit bugs and feature requests to KDE bugzilla, product plasma-nm:
-
-https://bugs.kde.org/describecomponents.cgi?product=plasma-nm
-
-
-NetworkManager specification:
-------------------------------
-http://projects.gnome.org/NetworkManager/developers/api/09/spec.html
-http://projects.gnome.org/NetworkManager/developers/api/09/ref-settings.html
-https://developer.gnome.org/ModemManager/unstable/
+++ /dev/null
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/declarative/metadata.desktop.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/declarative/metadata.desktop
- @ONLY)
-
-install(DIRECTORY declarative/contents DESTINATION ${DATA_INSTALL_DIR}/plasma/plasmoids/org.kde.networkmanagement)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/declarative/metadata.desktop DESTINATION ${DATA_INSTALL_DIR}/plasma/plasmoids/org.kde.networkmanagement)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/declarative/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME plasma-applet-networkmanagement.desktop)
-
-add_subdirectory(icons)
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
- http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
- <kcfgfile name=""/>
-
- <group name="General">
- <entry name="detailKeys" type="StringList">
- <default>ipv4:address,interface:hardwareaddress,wireless:ssid,wireless:signal,wireless:security,mobile:operator,mobile:quality,mobile:technology,bluetooth:name,vpn:plugin,vpn:banner</default>
- </entry>
- <entry name="showSections" type="Bool">
- <default>true</default>
- </entry>
- <entry name="networkSpeedUnit" type="Enum">
- <choices name="NetworkSpeedUnitChoices">
- <choice name="KBytes"/>
- <choice name="KBits"/>
- </choices>
- </entry>
- </group>
-</kcfg>
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
-import org.kde.networkmanagement 0.1 as PlasmaNM
-
-Item {
- id: panelIconWidget;
-
- PlasmaNM.NetworkStatus {
- id: networkStatus;
- }
-
- PlasmaNM.ConnectionIcon {
- id: connectionIconProvider;
- }
-
- PlasmaCore.Svg {
- id: svgIcons;
-
- multipleImages: true;
- imagePath: "icons/plasma-networkmanagement2";
- }
-
- PlasmaCore.SvgItem {
- id: connectionIcon;
-
- anchors.centerIn: parent
- width: Math.min(parent.width, parent.height)
- height: width
- svg: svgIcons;
- elementId: connectionIconProvider.connectionIcon
-
- PlasmaComponents.BusyIndicator {
- id: connectingIndicator;
-
- anchors.fill: parent;
- running: connectionIconProvider.connecting;
- visible: running;
- }
-
- MouseArea {
- id: mouseAreaPopup;
-
- anchors.fill: parent;
- hoverEnabled: true;
- onClicked: plasmoid.togglePopup();
-
- PlasmaCore.ToolTip {
- id: tooltip;
- target: mouseAreaPopup;
- image: connectionIconProvider.connectionTooltipIcon;
- subText: networkStatus.activeConnections;
- }
- }
- }
-}
+++ /dev/null
-/*
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import QtQuick 1.1
-import org.kde.plasma.components 0.1 as PlasmaComponents
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.locale 0.1 as KLocale
-import org.kde.networkmanagement 0.1 as PlasmaNM
-
-ListItem {
- id: connectionItem;
-
- property int baseHeight: connectionItemBase.height + Math.round(units.gridUnit / 3);
- property bool expanded: visibleDetails || visiblePasswordDialog;
- property bool predictableWirelessPassword: !Uuid && Type == PlasmaNM.Enums.Wireless &&
- (SecurityType == PlasmaNM.Enums.StaticWep || SecurityType == PlasmaNM.Enums.WpaPsk ||
- SecurityType == PlasmaNM.Enums.Wpa2Psk);
- property bool showSpeed: ConnectionState == PlasmaNM.Enums.Activated &&
- (Type == PlasmaNM.Enums.Wimax ||
- Type == PlasmaNM.Enums.Wired ||
- Type == PlasmaNM.Enums.Wireless ||
- Type == PlasmaNM.Enums.Gsm ||
- Type == PlasmaNM.Enums.Cdma);
- property bool visibleDetails: false;
- property bool visiblePasswordDialog: false;
-
- height: expanded ? baseHeight + expandableComponentLoader.height : baseHeight;
- enabled: true;
-
- KLocale.Locale { id: locale }
-
- PlasmaCore.Svg {
- id: svgNetworkIcons;
-
- multipleImages: true;
- imagePath: "icons/plasma-networkmanagement2";
- }
-
- PlasmaCore.DataSource {
- id: dataSource;
-
- property string downloadSource: "network/interfaces/" + DeviceName + "/receiver/data";
- property string uploadSource: "network/interfaces/" + DeviceName + "/transmitter/data";
-
- engine: "systemmonitor";
- connectedSources: showSpeed && mainWindow.isExpanded ? [downloadSource, uploadSource] : [];
- interval: 2000;
- }
-
- Item {
- id: connectionItemBase;
-
- anchors {
- left: parent.left;
- right: parent.right;
- top: parent.top;
- // Reset top margin from PlasmaComponents.ListItem
- topMargin: -Math.round(units.gridUnit / 2);
- }
-
- height: Math.max(theme.iconSizes.toolbar, connectionNameLabel.height + connectionStatusLabel.height) + Math.round(units.gridUnit / 2);
-
- PlasmaCore.SvgItem {
- id: connectionSvgIcon;
-
- anchors {
- left: parent.left
- verticalCenter: parent.verticalCenter
- }
-
- height: theme.iconSizes.toolbar;
- width: height;
- svg: svgNetworkIcons;
- elementId: ConnectionIcon;
- }
-
- PlasmaComponents.Label {
- id: connectionNameLabel;
-
- anchors {
- left: connectionSvgIcon.right;
- leftMargin: Math.round(units.gridUnit / 2);
- right: stateChangeButton.visible ? stateChangeButton.left : parent.right;
- bottom: connectionSvgIcon.verticalCenter
- }
-
- height: paintedHeight;
- elide: Text.ElideRight;
- font.weight: ConnectionState == PlasmaNM.Enums.Activated ? Font.DemiBold : Font.Normal;
- font.italic: ConnectionState == PlasmaNM.Enums.Activating ? true : false;
- text: ItemUniqueName;
- }
-
- PlasmaComponents.Label {
- id: connectionStatusLabel;
-
- anchors {
- left: connectionSvgIcon.right;
- leftMargin: Math.round(units.gridUnit / 2);
- right: stateChangeButton.visible ? stateChangeButton.left : parent.right;
- top: connectionNameLabel.bottom;
- }
-
- height: paintedHeight;
- elide: Text.ElideRight;
- font.pointSize: theme.smallestFont.pointSize;
- opacity: 0.6;
- text: itemText();
- }
-
- PlasmaComponents.BusyIndicator {
- id: connectingIndicator;
-
- anchors {
- right: stateChangeButton.visible ? stateChangeButton.left : parent.right;
- rightMargin: Math.round(units.gridUnit / 2);
- verticalCenter: connectionSvgIcon.verticalCenter;
- }
-
- height: theme.iconSizes.toolbar;
- width: height;
- running: ConnectionState == PlasmaNM.Enums.Activating;
- visible: running && !stateChangeButton.visible;
- }
-
- PlasmaComponents.Button {
- id: stateChangeButton;
-
- anchors {
- right: parent.right;
- rightMargin: Math.round(units.gridUnit / 2);
- verticalCenter: connectionSvgIcon.verticalCenter;
- }
-
- opacity: connectionItem.containsMouse ? 1 : 0
- visible: opacity != 0
- text: (ConnectionState == PlasmaNM.Enums.Deactivated) ? i18n("Connect") : i18n("Disconnect");
-
- Behavior on opacity { NumberAnimation { duration: 50 } }
-
- onClicked: changeState();
- }
- }
-
- Loader {
- id: expandableComponentLoader;
-
- anchors {
- left: parent.left;
- right: parent.right;
- top: connectionItemBase.bottom;
- }
- }
-
- Component {
- id: detailsComponent;
-
- Item {
- height: childrenRect.height;
-
- PlasmaCore.SvgItem {
- id: detailsSeparator;
-
- height: lineSvg.elementSize("horizontal-line").height;
- width: parent.width;
- anchors {
- left: parent.left;
- right: parent.right;
- top: parent.top;
- }
- elementId: "horizontal-line";
-
- svg: PlasmaCore.Svg {
- id: lineSvg;
- imagePath: "widgets/line";
- }
- }
-
- PlasmaComponents.TabBar {
- id: detailsTabBar;
-
- anchors {
- left: parent.left;
- right: parent.right;
- top: detailsSeparator.bottom;
- topMargin: Math.round(units.gridUnit / 3);
- }
- visible: DevicePath && ConnectionState == PlasmaNM.Enums.Activated && Type != PlasmaNM.Enums.Vpn;
-
- PlasmaComponents.TabButton {
- id: speedTabButton;
- text: i18n("Speed");
- visible: DevicePath && ConnectionState == PlasmaNM.Enums.Activated && Type != PlasmaNM.Enums.Vpn;
- }
-
- PlasmaComponents.TabButton {
- id: detailsTabButton;
- text: i18n("Details");
- }
-
- Component.onCompleted: {
- if (!speedTabButton.visible) {
- currentTab = detailsTabButton;
- }
- }
- }
-
- Item {
- id: detailsContent;
-
- height: if (detailsTabBar.currentTab == speedTabButton) trafficMonitorTab.height;
- else detailsTextTab.height;
-
- anchors {
- left: parent.left;
- right: parent.right;
- top: detailsTabBar.visible ? detailsTabBar.bottom : detailsSeparator.bottom;
- topMargin: Math.round(units.gridUnit / 3);
- }
-
- TrafficMonitor {
- id: trafficMonitorTab;
- anchors {
- left: parent.left;
- right: parent.right;
- top: parent.top;
- }
- device: DevicePath;
- visible: detailsTabBar.currentTab == speedTabButton &&
- DevicePath && ConnectionState == PlasmaNM.Enums.Activated && Type != PlasmaNM.Enums.Vpn
- }
-
- TextEdit {
- id: detailsTextTab;
-
- height: implicitHeight;
- anchors {
- left: parent.left;
- right: parent.right;
- top: parent.top;
- }
-
- color: theme.textColor;
- opacity: 0.6;
- readOnly: true;
- selectByMouse: true;
- textFormat: Text.RichText;
- text: ConnectionDetails;
- visible: detailsTabBar.currentTab == detailsTabButton;
- wrapMode: TextEdit.WordWrap;
- }
- }
- }
- }
-
- Component {
- id: passwordDialogComponent;
-
- Item {
- height: childrenRect.height;
-
- property alias password: passwordInput.text;
- property alias passwordFocus: passwordInput
-
- PlasmaCore.SvgItem {
- id: passwordSeparator;
-
- height: lineSvg.elementSize("horizontal-line").height;
- width: parent.width;
- anchors {
- left: parent.left;
- right: parent.right;
- top: parent.top;
- }
- elementId: "horizontal-line";
-
- svg: PlasmaCore.Svg {
- id: lineSvg;
- imagePath: "widgets/line";
- }
- }
-
- PlasmaComponents.TextField {
- id: passwordInput;
-
- width: 200;
- height: implicitHeight;
- anchors {
- horizontalCenter: parent.horizontalCenter;
- top: passwordSeparator.bottom;
- topMargin: Math.round(units.gridUnit / 3);
- }
- echoMode: showPasswordCheckbox.checked ? TextInput.Normal : TextInput.Password
- placeholderText: i18n("Password...");
- validator: RegExpValidator {
- regExp: if (SecurityType == PlasmaNM.Enums.StaticWep) {
- /^(?:[\x20-\x7F]{5}|[0-9a-fA-F]{10}|[\x20-\x7F]{13}|[0-9a-fA-F]{26}){1}$/
- } else {
- /^(?:[\x20-\x7F]{8,64}){1}$/
- }
- }
-
- onAccepted: {
- stateChangeButton.clicked();
- }
-
- onAcceptableInputChanged: {
- stateChangeButton.enabled = acceptableInput;
- }
- }
-
- PlasmaComponents.CheckBox {
- id: showPasswordCheckbox;
-
- anchors {
- left: passwordInput.left;
- right: parent.right;
- top: passwordInput.bottom;
- }
- checked: false;
- text: i18n("Show password");
- }
-
- Component.onCompleted: {
- stateChangeButton.enabled = false;
- }
-
- Component.onDestruction: {
- stateChangeButton.enabled = true;
- }
- }
- }
-
- states: [
- State {
- name: "collapsed";
- when: !(visibleDetails || visiblePasswordDialog);
- StateChangeScript { script: if (expandableComponentLoader.status == Loader.Ready) {expandableComponentLoader.sourceComponent = undefined} }
- },
-
- State {
- name: "expandedDetails";
- when: visibleDetails;
- StateChangeScript { script: createContent(); }
- },
-
- State {
- name: "expandedPasswordDialog";
- when: visiblePasswordDialog;
- StateChangeScript { script: createContent(); }
- PropertyChanges { target: stateChangeButton; opacity: 1; }
- }
- ]
-
- function createContent() {
- if (visibleDetails) {
- expandableComponentLoader.sourceComponent = detailsComponent;
- } else if (visiblePasswordDialog) {
- expandableComponentLoader.sourceComponent = passwordDialogComponent;
- expandableComponentLoader.item.passwordFocus.forceActiveFocus();
- }
- }
-
- function changeState() {
- visibleDetails = false;
- if (Uuid || !predictableWirelessPassword || visiblePasswordDialog) {
- if (ConnectionState == PlasmaNM.Enums.Deactivated) {
- if (!predictableWirelessPassword && !Uuid) {
- handler.addAndActivateConnection(DevicePath, SpecificPath);
- } else if (visiblePasswordDialog) {
- if (expandableComponentLoader.item.password != "") {
- handler.addAndActivateConnection(DevicePath, SpecificPath, expandableComponentLoader.item.password);
- }
- visiblePasswordDialog = false;
- } else {
- handler.activateConnection(ConnectionPath, DevicePath, SpecificPath);
- }
- } else {
- handler.deactivateConnection(ConnectionPath, DevicePath);
- }
- } else if (predictableWirelessPassword) {
- visiblePasswordDialog = true;
- }
- }
-
- function itemText() {
- if (ConnectionState == PlasmaNM.Enums.Activating) {
- if (Type == PlasmaNM.Enums.Vpn)
- return VpnState;
- else
- return DeviceState;
- } else if (ConnectionState == PlasmaNM.Enums.Deactivating) {
- if (Type == PlasmaNM.Enums.Vpn)
- return VpnState;
- else
- return DeviceState;
- } else if (ConnectionState == PlasmaNM.Enums.Deactivated) {
- var result = LastUsed;
- if (SecurityType > PlasmaNM.Enums.None)
- result += ", " + SecurityTypeString;
- return result;
- } else if (ConnectionState == PlasmaNM.Enums.Activated) {
- if (showSpeed && dataSource.data && dataSource.data[dataSource.downloadSource] && dataSource.data[dataSource.uploadSource]) {
- return i18n("Connected, ⬇ %1/s, ⬆ %2/s",
- locale.formatByteSize(dataSource.data[dataSource.downloadSource].value * 1024 || 0),
- locale.formatByteSize(dataSource.data[dataSource.uploadSource].value * 1024 || 0))
- } else {
- return i18n("Connected");
- }
- }
- }
-
- onStateChanged: {
- if (state == "expandedPasswordDialog" || state == "expandedDetails") {
- ListView.view.currentIndex = index;
- }
- }
-
- onClicked: {
- if (visiblePasswordDialog) {
- visiblePasswordDialog = false;
- } else {
- visibleDetails = !visibleDetails;
- }
-
- if (!visibleDetails) {
- ListView.view.currentIndex = -1;
- }
- }
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import QtQuick 1.1
-import org.kde.plasma.components 0.1 as PlasmaComponents
-
-PlasmaComponents.ListItem {
- id: header;
-
- property alias text: headerLabel.text;
-
- height: headerLabel.height + units.gridUnit;
- sectionDelegate: true;
-
- anchors {
- left: parent.left;
- right: parent.right;
- }
-
- PlasmaComponents.Label {
- id: headerLabel
-
- anchors {
- horizontalCenter: parent.horizontalCenter;
- verticalCenter: parent.verticalCenter;
- }
-
- font.weight: Font.DemiBold;
- }
-
- PlasmaComponents.ToolButton {
- id: refreshButton;
-
- anchors {
- right: parent.right;
- rightMargin: padding.margins.right;
- verticalCenter: parent.verticalCenter;
- }
-
- iconSource: "view-refresh";
- visible: header.text == i18n("Available connections");
-
- onClicked: {
- handler.requestScan();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2010 Marco Martin <notmart@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details
- *
- * You should have received a copy of the GNU Library 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.
- */
-
-import QtQuick 1.0
-import org.kde.plasma.core 0.1 as PlasmaCore
-
-/**
- * An item delegate for the primitive ListView component.
- *
- * It's intended to make all listviews look coherent.
- */
-Item {
- id: listItem
- default property alias content: paddingItem.data
-
- /**
- * type:bool Holds if the item emits signals related to mouse interaction.
- *
- * The default value is false.
- */
- property alias enabled: itemMouse.enabled
- //item has been clicked or pressed+hold
-
- /**
- * This signal is emitted when there is a click.
- *
- * This is disabled by default, set enabled to true to use it.
- * @see enabled
- */
- signal clicked
-
-
- /**
- * The user pressed the item with the mouse and didn't release it for a
- * certain amount of time.
- *
- * This is disabled by default, set enabled to true to use it.
- * @see enabled
- */
- signal pressAndHold
-
- /**
- * If true makes the list item look as checked or pressed. It has to be set
- * from the code, it won't change by itself.
- */
- //plasma extension
- //always look pressed?
- property bool checked: false
-
- /**
- * If true the item will be a delegate for a section, so will look like a
- * "title" for the otems under it.
- */
- //is this to be used as section delegate?
- property bool sectionDelegate: false
-
- property alias containsMouse: itemMouse.containsMouse
-
- width: parent ? parent.width : childrenRect.width
- height: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom
-
- property int implicitHeight: paddingItem.childrenRect.height + background.margins.top + background.margins.bottom
-
- Connections {
- target: listItem
- onCheckedChanged: background.prefix = (listItem.checked ? "pressed" : "normal")
- onSectionDelegateChanged: background.prefix = (listItem.sectionDelegate ? "section" : "normal")
- }
-
- PlasmaCore.FrameSvgItem {
- id : background
- imagePath: "widgets/listitem"
- prefix: "normal"
-
- anchors.fill: parent
- visible: listItem.ListView.view ? listItem.ListView.view.highlight === null : true
- opacity: itemMouse.containsMouse && !itemMouse.pressed ? 0.5 : 1
- Component.onCompleted: {
- prefix = (listItem.sectionDelegate ? "section" : (listItem.checked ? "pressed" : "normal"))
- }
- Behavior on opacity { NumberAnimation { duration: 200 } }
- }
-
- PlasmaCore.SvgItem {
- svg: PlasmaCore.Svg {imagePath: "widgets/listitem"}
- elementId: "separator"
- anchors {
- left: parent.left
- right: parent.right
- top: parent.top
- }
- height: naturalSize.height
- visible: listItem.sectionDelegate || (typeof(index) != "undefined" && index > 0 && !listItem.checked && !itemMouse.pressed)
- }
-
- MouseArea {
- id: itemMouse
- property bool changeBackgroundOnPress: !listItem.checked && !listItem.sectionDelegate
- anchors.fill: background
- enabled: false
- hoverEnabled: true
-
- onClicked: listItem.clicked()
- onPressAndHold: listItem.pressAndHold()
- onPressed: if (changeBackgroundOnPress) background.prefix = "pressed"
- onReleased: if (changeBackgroundOnPress) background.prefix = "normal"
- onCanceled: if (changeBackgroundOnPress) background.prefix = "normal"
-
- Item {
- id: paddingItem
- anchors {
- fill: parent
- leftMargin: background.margins.left
- topMargin: background.margins.top
- rightMargin: background.margins.right
- bottomMargin: background.margins.bottom
- }
- }
- }
-}
+++ /dev/null
-/*
- Copyright 2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import QtQuick 1.1
-import org.kde.plasma.components 0.1 as PlasmaComponents
-import org.kde.plasma.core 0.1 as PlasmaCore
-
-Item {
- id: switchButton;
-
- property alias icon: switchButtonIcon.elementId;
- property alias checked: switchButtonCheckbox.checked;
- property alias enabled: switchButtonCheckbox.enabled;
- property alias tooltipText: switchButtonTooltip.mainText;
-
- signal clicked();
-
- height: switchButtonIcon.height + Math.round(units.gridUnit / 2);
- width: switchButtonCheckbox.width + switchButtonIcon.width + units.gridUnit;
-
- PlasmaComponents.CheckBox {
- id: switchButtonCheckbox;
-
- anchors {
- left: parent.left;
- leftMargin: padding.margins.right;
- verticalCenter: parent.verticalCenter;
- }
- }
-
- PlasmaCore.SvgItem {
- id: switchButtonIcon;
-
- width: sizes.iconSize;
- height: width;
- anchors {
- left: switchButtonCheckbox.right;
- leftMargin: padding.margins.left;
- verticalCenter: parent.verticalCenter;
- }
- svg: svgNetworkIcons;
- }
-
- MouseArea {
- id: switchButtonMouseArea;
-
- anchors.fill: parent;
-
- PlasmaCore.ToolTip {
- id: switchButtonTooltip;
- target: switchButtonMouseArea;
- }
-
- onClicked: {
- if (switchButton.enabled) {
- switchButton.clicked();
- }
- }
- }
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import QtQuick 1.1
-import org.kde.plasma.components 0.1 as PlasmaComponents
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.networkmanagement 0.1 as PlasmaNM
-
-Item {
- id: toolbar;
-
- height: wifiSwitchButton.height;
-
- PlasmaNM.EnabledConnections {
- id: enabledConnections;
- }
-
- PlasmaNM.AvailableDevices {
- id: availableDevices;
- }
-
- PlasmaCore.Svg {
- id: lineSvg;
- imagePath: "widgets/line";
- }
-
- Row {
- anchors {
- bottom: parent.bottom;
- left: parent.left;
- top: parent.top;
- }
- spacing: 3;
-
- SwitchButton {
- id: wifiSwitchButton;
-
- checked: enabled && enabledConnections.wirelessEnabled;
- enabled: enabledConnections.wirelessHwEnabled && availableDevices.wirelessDeviceAvailable && !globalConfig.airplaneModeEnabled;
- icon: checked ? "network-wireless-on" : "network-wireless-off";
- tooltipText: checked ? i18n("Wireless enabled") : i18n("Wireless disabled");
- visible: availableDevices.wirelessDeviceAvailable;
-
- onClicked: {
- handler.enableWireless(!checked);
- }
- }
-
- SwitchButton {
- id: wwanSwitchButton;
-
- checked: enabled && enabledConnections.wwanEnabled;
- enabled: enabledConnections.wwanHwEnabled && availableDevices.modemDeviceAvailable && !globalConfig.airplaneModeEnabled;
- icon: checked ? "network-mobile-on" : "network-mobile-off";
- tooltipText: checked ? i18n("Mobile broadband enabled") : i18n("Mobile broadband disabled");
- visible: availableDevices.modemDeviceAvailable;
-
- onClicked: {
- handler.enableWwan(!checked);
- }
- }
-
- SwitchButton {
- id: planeModeSwitchButton;
-
- checked: globalConfig.airplaneModeEnabled;
- icon: checked ? "flightmode-on" : "flightmode-off";
- tooltipText: checked ? i18n("Airplane mode enabled") : i18n("Airplane mode disabled");
-
- onClicked: {
- handler.enableAirplaneMode(!checked);
- globalConfig.setAirplaneModeEnabled(!checked);
- }
- }
- }
-
- PlasmaComponents.ToolButton {
- id: openEditorButton;
-
- anchors {
- right: parent.right;
- rightMargin: Math.round(units.gridUnit / 2);
- verticalCenter: parent.verticalCenter;
- }
- iconSource: "configure";
-
- onClicked: {
- handler.openEditor();
- }
- }
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import QtQuick 1.1
-import org.kde.networkmanagement 0.1 as PlasmaNM
-
-Item {
- id: trafficMonitor;
-
- property alias device: trafficMonitorWidget.device;
-
- height: visible ? trafficMonitorWidget.height : 0;
-
- PlasmaNM.TrafficMonitor {
- id: trafficMonitorWidget;
- anchors.fill: parent;
- device: itemDevicePath;
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Form</class>
- <widget class="QWidget" name="Form">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>638</width>
- <height>440</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="1">
- <widget class="QCheckBox" name="kcfg_showSections">
- <property name="text">
- <string>Show sections</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="tristate">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Show &network speed in:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>kcfg_networkSpeedUnit</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KComboBox" name="kcfg_networkSpeedUnit">
- <item>
- <property name="text">
- <string>KBytes/s</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>KBits/s</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0">
- <widget class="Line" name="line">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Connection Details</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="DetailKeysEditor" name="kcfg_detailKeys"/>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>DetailKeysEditor</class>
- <extends>QWidget</extends>
- <header>detailkeyseditor.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.networkmanagement 0.1 as PlasmaNM
-
-Item {
- id: mainWindow;
-
- property int minimumWidth: 300;
- property int minimumHeight: 300;
- property bool isExpanded: false;
- property bool showSections: true;
- property Component compactRepresentation: CompactRepresentation {
- Component.onCompleted: {
- plasmoid.addEventListener('configChanged', mainWindow.configChanged)
- }
- }
-
- signal sectionChanged();
-
- PlasmaNM.GlobalConfig {
- id: globalConfig;
-
- onDetailKeysChanged: {
- connectionModel.updateItems();
- }
-
- onNetworkSpeedUnitChanged: {
- connectionModel.updateItems();
- }
- }
-
- PlasmaNM.Handler {
- id: handler;
- }
-
- PlasmaNM.NetworkModel {
- id: connectionModel;
- }
- PlasmaNM.AppletProxyModel {
- id: appletProxyModel;
-
- sourceModel: connectionModel;
- }
-
- PlasmaCore.Svg {
- id: svgNetworkIcons;
-
- multipleImages: true;
- imagePath: "icons/plasma-networkmanagement2";
- }
-
- PlasmaCore.FrameSvgItem {
- id: padding
- imagePath: "widgets/viewitem"
- prefix: "hover"
- opacity: 0
- anchors.fill: parent
- }
-
- Item {
- id: sizes;
-
- property int iconSize: theme.iconSizes.toolbar;
- property int itemSize: iconSize + padding.margins.top + padding.margins.bottom;
- }
-
- Toolbar {
- id: toolbar;
-
- anchors {
- left: parent.left;
- right: parent.right;
- top: parent.top;
- }
- }
-
- ListView {
- id: connectionView;
-
- anchors {
- bottom: parent.bottom;
- left: parent.left;
- right: parent.right;
- top: toolbar.bottom;
- }
- clip: true
- model: appletProxyModel;
- currentIndex: -1;
- interactive: true;
- boundsBehavior: Flickable.StopAtBounds;
- section.property: showSections ? "Section" : "";
- section.delegate: Header { text: section }
- delegate: ConnectionItem {
- onStateChanged: {
- if (state == "expanded") {
- connectionView.currentIndex = index;
- }
- }
- }
- }
-
- Component.onCompleted: {
- configChanged();
- plasmoid.addEventListener('configChanged', mainWindow.configChanged)
- plasmoid.popupEvent.connect(popupEventSlot)
- }
-
- function configChanged() {
- var keys;
- keys = plasmoid.readConfig("detailKeys");
- globalConfig.setDetailKeys(keys);
- var speedUnit;
- speedUnit = plasmoid.readConfig("networkSpeedUnit");
- globalConfig.setNetworkSpeedUnit(speedUnit);
- showSections = plasmoid.readConfig("showSections");
- }
-
- function popupEventSlot(popped) {
- isExpanded = popped;
- }
-}
+++ /dev/null
-[Desktop Entry]
-Name=Network Management
-Name[bg]=Управление на мрежа
-Name[bs]=Upravljanje mrežom
-Name[ca]=Gestió de la xarxa
-Name[ca@valencia]=Gestió de la xarxa
-Name[cs]=Správa sítě
-Name[da]=Netværkshåndtering
-Name[de]=Netzwerkverwaltung
-Name[el]=Διαχείριση δικτύων
-Name[en_GB]=Network Management
-Name[es]=Gestión de red
-Name[et]=Võrguhaldus
-Name[fi]=Verkonhallinta
-Name[fr]=Gestion du réseau
-Name[hu]=Hálózatkezelés
-Name[it]=Gestione di rete
-Name[ko]=네트워크 관리
-Name[lt]=Tinklo valdymas
-Name[nb]=Nettverksstyring
-Name[nds]=Nettwarkpleeg
-Name[nl]=Netwerkbeheer
-Name[pl]=Zarządzanie siecią
-Name[pt]=Gestão de Rede
-Name[pt_BR]=Gerenciamento de rede
-Name[ro]=Gestiunea rețelei
-Name[ru]=Управление сетью
-Name[sk]=Správa siete
-Name[sl]=Omrežno upravljanje
-Name[sv]=Nätverkshantering
-Name[tr]=Ağ Yönetimi
-Name[ug]=تور باشقۇرۇش
-Name[uk]=Керування мережею
-Name[x-test]=xxNetwork Managementxx
-Name[zh_CN]=网络管理
-
-Comment=Network status and control
-Comment[bg]=Състояние и контрол на мрежата
-Comment[bs]=Kontrola i status mreže
-Comment[ca]=Control i estat de la xarxa
-Comment[ca@valencia]=Control i estat de la xarxa
-Comment[cs]=Stav a ovládání sítě
-Comment[da]=Status og kontrol over netværk
-Comment[de]=Netzwerkstatus und -steuerung
-Comment[el]=Κατάσταση δικτύου και έλεγχος
-Comment[en_GB]=Network status and control
-Comment[es]=Estado y control de la red
-Comment[et]=Võrgu olek ja juhtimine
-Comment[fi]=Verkon tila ja hallinta
-Comment[fr]=État et contrôle du réseau
-Comment[hu]=Hálózatállapot és vezérlés
-Comment[it]=Stato e controllo della rete
-Comment[ko]=네트워크 상태 및 제어
-Comment[lt]=Tinklo būsena ir kontrolė
-Comment[nb]=Nettverksstatus og styring
-Comment[nds]=Nettwarkstatus un -stüern
-Comment[nl]=Netwerkstatus en besturing
-Comment[pl]=Wyświetla stan i zapewnia sterowanie siecią
-Comment[pt]=Estado e controlo da rede
-Comment[pt_BR]=Estado e controle da rede
-Comment[ro]=Starea și controlul rețelei
-Comment[ru]=Состояние и управление сетью
-Comment[sk]=Správa a ovládanie siete
-Comment[sl]=Stanje omrežja in nadzor
-Comment[sv]=Nätverksstatus och kontroll
-Comment[tr]=Ağ denetim ve durum izleme
-Comment[uk]=Стеження за станом і керування мережею
-Comment[x-test]=xxNetwork status and controlxx
-Comment[zh_CN]=网络状态和控制
-
-Type=Service
-ServiceTypes=Plasma/Applet,Plasma/PopupApplet
-Icon=network-defaultroute
-
-X-Plasma-API=declarativeappletscript
-X-Plasma-MainScript=ui/main.qml
-X-Plasma-DefaultSize=350,450
-X-Plasma-NotificationArea=true
-X-Plasma-ConfigPlugins=networkmanagement_notifications
-
-X-KDE-PluginInfo-Name=org.kde.networkmanagement
-X-KDE-PluginInfo-Category=System Information
-X-KDE-PluginInfo-Author=Jan Grulich,Lukáš Tinkl
-X-KDE-PluginInfo-Email=jgrulich@redhat.com,ltinkl@redhat.com
-X-KDE-PluginInfo-Version=@PLASMA_NM_VERSION@
-X-KDE-PluginInfo-Website=https://projects.kde.org/plasma-nm
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=true
-X-KDE-ServiceTypes=Plasma/Applet,Plasma/PopupApplet
+++ /dev/null
-install(FILES plasma-networkmanagement.svgz DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/icons/ RENAME plasma-networkmanagement2.svgz)
-
-kde4_install_icons(${ICON_INSTALL_DIR})
-
-
-
-
+++ /dev/null
-#define PLASMA_NM_VERSION_STRING "${PLASMA_NM_VERSION}"
+++ /dev/null
-include_directories(${PROJECT_SOURCE_DIR}/libs/editor
- ${PROJECT_SOURCE_DIR}/libs/editor/widgets
- ${PROJECT_SOURCE_DIR}/libs/models)
-
-set(connectioneditor_SRCS
- main.cpp
- connectioneditor.cpp
- connectioneditor.ui
-)
-
-add_executable(kde-nm-connection-editor ${connectioneditor_SRCS})
-
-target_link_libraries(kde-nm-connection-editor
- plasmanetworkmanagement-internal
- plasmanetworkmanagement-editor
- ${NETWORKMANAGERQT_LDFLAGS}
- ${MODEMMANAGERQT_LDFLAGS}
- ${QT_QTCORE_LIBRARY}
- ${QT_QTDBUS_LIBRARY}
- ${KDE4_KDEUI_LIBS}
- ${KDE4_KIO_LIBS}
-)
-
-install(TARGETS kde-nm-connection-editor DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS})
-install(PROGRAMS kde-nm-connection-editor.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
-install(FILES kde-nm-connection-editorui.rc DESTINATION ${DATA_INSTALL_DIR}/kde-nm-connection-editor)
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
-$XGETTEXT `find . -name "*.cpp"` -o $podir/kde-nm-connection-editor.pot
-rm -f rc.cpp
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "connectioneditor.h"
-#include "ui_connectioneditor.h"
-#include "connectiondetaileditor.h"
-#include "editoridentitymodel.h"
-#include "editorproxymodel.h"
-#include "networkmodel.h"
-#include "mobileconnectionwizard.h"
-#include "uiutils.h"
-#include "vpnuiplugin.h"
-#include <networkmodelitem.h>
-
-#include <KActionCollection>
-#include <KLocale>
-#include <KMessageBox>
-#include <KService>
-#include <KServiceTypeTrader>
-#include <KStandardAction>
-#include <KAction>
-#include <KXMLGUIFactory>
-#include <KMenu>
-#include <KAcceleratorManager>
-#include <KConfig>
-#include <KConfigGroup>
-#include <KWallet/Wallet>
-#include <KStandardDirs>
-#include <KFileDialog>
-#include <KShell>
-#include <KFilterProxySearchLine>
-#include <QTimer>
-
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/Connection>
-#include <NetworkManagerQt/ActiveConnection>
-#include <NetworkManagerQt/VpnSetting>
-
-using namespace NetworkManager;
-
-ConnectionEditor::ConnectionEditor(QWidget* parent, Qt::WindowFlags flags)
- : KXmlGuiWindow(parent, flags)
- , m_editor(new Ui::ConnectionEditor)
- , m_handler(new Handler(this))
-{
- QWidget * tmp = new QWidget(this);
- m_editor->setupUi(tmp);
- setCentralWidget(tmp);
-
- m_editor->connectionsWidget->setSortingEnabled(false);
- m_editor->connectionsWidget->sortByColumn(0, Qt::AscendingOrder);
- m_editor->connectionsWidget->setSortingEnabled(true);
- m_editor->connectionsWidget->setContextMenuPolicy(Qt::CustomContextMenu);
-
- m_editor->messageWidget->hide();
- m_editor->messageWidget->setCloseButtonVisible(false);
- m_editor->messageWidget->setWordWrap(true);
-
- m_editor->ktreewidgetsearchline->lineEdit()->setClickMessage(i18n("Type here to search connections..."));
-
- initializeConnections();
- initializeMenu();
-
- connect(m_editor->connectionsWidget, SIGNAL(pressed(QModelIndex)),
- SLOT(slotItemClicked(QModelIndex)));
- connect(m_editor->connectionsWidget, SIGNAL(doubleClicked(QModelIndex)),
- SLOT(slotItemDoubleClicked(QModelIndex)));
- connect(m_editor->connectionsWidget, SIGNAL(customContextMenuRequested(QPoint)),
- SLOT(slotContextMenuRequested(QPoint)));
- connect(m_menu->menu(), SIGNAL(triggered(QAction*)),
- SLOT(addConnection(QAction*)));
- connect(NetworkManager::settingsNotifier(), SIGNAL(connectionAdded(QString)),
- SLOT(connectionAdded(QString)));
-
- KConfig config("kde-nm-connection-editor");
- KConfigGroup generalGroup = config.group("General");
-
- if (generalGroup.isValid()) {
- if (generalGroup.readEntry("FirstStart", true)) {
- importSecretsFromPlainTextFiles();
- }
-
- generalGroup.writeEntry("FirstStart", false);
- }
-}
-
-ConnectionEditor::~ConnectionEditor()
-{
- delete m_editor;
-}
-
-void ConnectionEditor::initializeMenu()
-{
- m_menu = new KActionMenu(KIcon("list-add"), i18n("Add"), this);
- m_menu->menu()->setSeparatorsCollapsible(false);
- m_menu->setDelayed(false);
-
- QAction * action = m_menu->addSeparator();
- action->setText(i18n("Hardware"));
-
- // TODO Adsl
- action = new QAction(i18n("DSL"), this);
- action->setData(NetworkManager::ConnectionSettings::Pppoe);
- m_menu->addAction(action);
- action = new QAction(i18n("InfiniBand"), this);
- action->setData(NetworkManager::ConnectionSettings::Infiniband);
- m_menu->addAction(action);
-#if WITH_MODEMMANAGER_SUPPORT
- action = new QAction(i18n("Mobile Broadband..."), this);
- action->setData(NetworkManager::ConnectionSettings::Gsm);
- m_menu->addAction(action);
-#endif
- action = new QAction(i18n("Wired"), this);
- action->setData(NetworkManager::ConnectionSettings::Wired);
- action->setProperty("shared", false);
- m_menu->addAction(action);
- action = new QAction(i18n("Wired (shared)"), this);
- action->setData(NetworkManager::ConnectionSettings::Wired);
- action->setProperty("shared", true);
- m_menu->addAction(action);
- action = new QAction(i18n("Wireless"), this);
- action->setData(NetworkManager::ConnectionSettings::Wireless);
- action->setProperty("shared", false);
- m_menu->addAction(action);
- action = new QAction(i18n("Wireless (shared)"), this);
- action->setData(NetworkManager::ConnectionSettings::Wireless);
- action->setProperty("shared", true);
- m_menu->addAction(action);
- action = new QAction(i18n("WiMAX"), this);
- action->setData(NetworkManager::ConnectionSettings::Wimax);
- m_menu->addAction(action);
-
- action = m_menu->addSeparator();
- action->setText(i18nc("Virtual hardware devices, eg Bridge, Bond", "Virtual"));
-
- action = new QAction(i18n("Bond"), this);
- action->setData(NetworkManager::ConnectionSettings::Bond);
- m_menu->addAction(action);
- action = new QAction(i18n("Bridge"), this);
- action->setData(NetworkManager::ConnectionSettings::Bridge);
- m_menu->addAction(action);
- action = new QAction(i18n("VLAN"), this);
- action->setData(NetworkManager::ConnectionSettings::Vlan);
- m_menu->addAction(action);
-
- action = m_menu->addSeparator();
- action->setText(i18n("VPN"));
-
- const KService::List services = KServiceTypeTrader::self()->query("PlasmaNetworkManagement/VpnUiPlugin");
- foreach (const KService::Ptr & service, services) {
- qDebug() << "Found VPN plugin" << service->name() << ", type:" << service->property("X-NetworkManager-Services", QVariant::String).toString();
-
- action = new QAction(service->name(), this);
- action->setData(NetworkManager::ConnectionSettings::Vpn);
- action->setProperty("type", service->property("X-NetworkManager-Services", QVariant::String));
- m_menu->addAction(action);
- }
-
- actionCollection()->addAction("add_connection", m_menu);
-
- KAction * kAction = new KAction(KIcon("network-connect"), i18n("Connect"), this);
- kAction->setEnabled(false);
- connect(kAction, SIGNAL(triggered()), this, SLOT(connectConnection()));
- actionCollection()->addAction("connect_connection", kAction);
-
- kAction = new KAction(KIcon("network-disconnect"), i18n("Disconnect"), this);
- kAction->setEnabled(false);
- connect(kAction, SIGNAL(triggered()), this, SLOT(disconnectConnection()));
- actionCollection()->addAction("disconnect_connection", kAction);
-
- kAction = new KAction(KIcon("configure"), i18n("Edit..."), this);
- kAction->setEnabled(false);
- connect(kAction, SIGNAL(triggered()), SLOT(editConnection()));
- actionCollection()->addAction("edit_connection", kAction);
-
- kAction = new KAction(KIcon("edit-delete"), i18n("Delete"), this);
- kAction->setEnabled(false);
- kAction->setShortcut(Qt::Key_Delete);
- connect(kAction, SIGNAL(triggered()), SLOT(removeConnection()));
- actionCollection()->addAction("delete_connection", kAction);
-
- kAction = new KAction(KIcon("document-import"), i18n("Import VPN..."), this);
- actionCollection()->addAction("import_vpn", kAction);
- connect(kAction, SIGNAL(triggered()), SLOT(importVpn()));
-
- kAction = new KAction(KIcon("document-export"), i18n("Export VPN..."), this);
- actionCollection()->addAction("export_vpn", kAction);
- kAction->setEnabled(false);
- connect(kAction, SIGNAL(triggered()), SLOT(exportVpn()));
-
- KStandardAction::keyBindings(guiFactory(), SLOT(configureShortcuts()), actionCollection());
- KStandardAction::quit(this, SLOT(close()), actionCollection());
-
- setupGUI(QSize(480, 480));
-
- setAutoSaveSettings();
-
- KAcceleratorManager::manage(this);
-}
-
-void ConnectionEditor::addConnection(QAction* action)
-{
- qDebug() << "ADDING new connection" << action->data().toUInt();
- const QString vpnType = action->property("type").toString();
- qDebug() << "VPN type:" << vpnType;
-
- ConnectionSettings::ConnectionType type = static_cast<ConnectionSettings::ConnectionType>(action->data().toUInt());
-
- if (type == NetworkManager::ConnectionSettings::Gsm) { // launch the mobile broadband wizard, both gsm/cdma
-#if WITH_MODEMMANAGER_SUPPORT
- QWeakPointer<MobileConnectionWizard> wizard = new MobileConnectionWizard(NetworkManager::ConnectionSettings::Unknown, this);
- if (wizard.data()->exec() == QDialog::Accepted && wizard.data()->getError() == MobileProviders::Success) {
- qDebug() << "Mobile broadband wizard finished:" << wizard.data()->type() << wizard.data()->args();
- QPointer<ConnectionDetailEditor> editor = new ConnectionDetailEditor(wizard.data()->type(), wizard.data()->args(), this);
- editor->exec();
-
- if (editor) {
- editor->deleteLater();
- }
- }
- if (wizard) {
- wizard.data()->deleteLater();
- }
-#endif
- } else {
- bool shared = false;
- if (type == ConnectionSettings::Wired || type == ConnectionSettings::Wireless) {
- shared = action->property("shared").toBool();
- }
-
- QPointer<ConnectionDetailEditor> editor = new ConnectionDetailEditor(type, this, vpnType, shared);
- editor->exec();
-
- if (editor) {
- editor->deleteLater();
- }
- }
-}
-
-void ConnectionEditor::connectionAdded(const QString& connection)
-{
- NetworkManager::Connection::Ptr con = NetworkManager::findConnection(connection);
-
- if (!con) {
- return;
- }
-
- if (con->settings()->isSlave())
- return;
-
- m_editor->messageWidget->animatedShow();
- m_editor->messageWidget->setMessageType(KMessageWidget::Positive);
- m_editor->messageWidget->setText(i18n("Connection %1 has been added", con->name()));
- QTimer::singleShot(5000, m_editor->messageWidget, SLOT(animatedHide()));
-}
-
-void ConnectionEditor::connectConnection()
-{
- const QModelIndex currentIndex = m_editor->connectionsWidget->currentIndex();
-
- if (!currentIndex.isValid() || currentIndex.parent().isValid()) {
- return;
- }
-
- const QString connectionPath = currentIndex.data(NetworkModel::ConnectionPathRole).toString();
- const QString devicePath = currentIndex.data(NetworkModel::DevicePathRole).toString();
- const QString specificPath = currentIndex.data(NetworkModel::SpecificPathRole).toString();
-
- m_handler->activateConnection(connectionPath, devicePath, specificPath);
-}
-
-void ConnectionEditor::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
-{
- QModelIndex currentIndex = m_editor->connectionsWidget->currentIndex();
- if (currentIndex.isValid()) {
- for (int i = topLeft.row(); i <= bottomRight.row(); i++) {
- QModelIndex index = m_editor->connectionsWidget->model()->index(i, 0);
- if (index.isValid() && index == currentIndex) {
- // Re-check enabled/disabled actions
- slotItemClicked(currentIndex);
- break;
- }
- }
- }
-}
-
-void ConnectionEditor::disconnectConnection()
-{
- const QModelIndex currentIndex = m_editor->connectionsWidget->currentIndex();
-
- if (!currentIndex.isValid() || currentIndex.parent().isValid()) {
- return;
- }
-
- const QString connectionPath = currentIndex.data(NetworkModel::ConnectionPathRole).toString();
- const QString devicePath = currentIndex.data(NetworkModel::DevicePathRole).toString();
- m_handler->deactivateConnection(connectionPath, devicePath);
-}
-
-void ConnectionEditor::editConnection()
-{
- const QModelIndex currentIndex = m_editor->connectionsWidget->currentIndex();
-
- if (!currentIndex.isValid() || currentIndex.parent().isValid()) {
- return;
- }
-
- slotItemDoubleClicked(currentIndex);
-}
-
-void ConnectionEditor::initializeConnections()
-{
- EditorIdentityModel * model = new EditorIdentityModel(this);
- EditorProxyModel * filterModel = new EditorProxyModel(this);
- filterModel->setSourceModel(model);
- connect(filterModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),SLOT(dataChanged(QModelIndex,QModelIndex)));
-
- m_editor->connectionsWidget->setModel(filterModel);
- m_editor->ktreewidgetsearchline->setProxy(filterModel);
- m_editor->connectionsWidget->header()->setResizeMode(0, QHeaderView::Stretch);
-}
-
-void ConnectionEditor::removeConnection()
-{
- const QModelIndex currentIndex = m_editor->connectionsWidget->currentIndex();
-
- if (!currentIndex.isValid() || currentIndex.parent().isValid()) {
- return;
- }
-
- Connection::Ptr connection = NetworkManager::findConnectionByUuid(currentIndex.data(NetworkModel::UuidRole).toString());
-
- if (!connection) {
- return;
- }
-
- if (KMessageBox::questionYesNo(this, i18n("Do you want to remove the connection '%1'?", connection->name()), i18n("Remove Connection"), KStandardGuiItem::remove(),
- KStandardGuiItem::no(), QString(), KMessageBox::Dangerous)
- == KMessageBox::Yes) {
- foreach (const NetworkManager::Connection::Ptr &con, NetworkManager::listConnections()) {
- NetworkManager::ConnectionSettings::Ptr settings = con->settings();
- if (settings->master() == connection->uuid()) {
- con->remove();
- }
- }
- connection->remove();
- }
-}
-
-void ConnectionEditor::slotContextMenuRequested(const QPoint&)
-{
- QMenu * menu = new QMenu(this);
-
- QModelIndex index = m_editor->connectionsWidget->currentIndex();
- const bool isActive = (NetworkManager::ActiveConnection::State)index.data(NetworkModel::ConnectionStateRole).toUInt() == NetworkManager::ActiveConnection::Activated;
- const bool isAvailable = (NetworkModelItem::ItemType)index.data(NetworkModel::ItemTypeRole).toUInt() == NetworkModelItem::AvailableConnection;
-
- if (isAvailable && !isActive) {
- menu->addAction(actionCollection()->action("connect_connection"));
- } else if (isAvailable && isActive) {
- menu->addAction(actionCollection()->action("disconnect_connection"));
- }
- menu->addAction(actionCollection()->action("edit_connection"));
- menu->addAction(actionCollection()->action("delete_connection"));
- menu->exec(QCursor::pos());
-}
-
-void ConnectionEditor::slotItemClicked(const QModelIndex &index)
-{
- if (!index.isValid()) {
- return;
- }
-
- qDebug() << "Clicked item" << index.data(NetworkModel::UuidRole).toString();
-
- if (index.parent().isValid()) { // category
- actionCollection()->action("connect_connection")->setEnabled(false);
- actionCollection()->action("disconnect_connection")->setEnabled(false);
- actionCollection()->action("edit_connection")->setEnabled(false);
- actionCollection()->action("delete_connection")->setEnabled(false);
- actionCollection()->action("export_vpn")->setEnabled(false);
- actionCollection()->action("export_vpn")->setEnabled(false);
- } else { //connection
- const bool isActive = (NetworkManager::ActiveConnection::State)index.data(NetworkModel::ConnectionStateRole).toUInt() == NetworkManager::ActiveConnection::Activated;
- const bool isActivating = (NetworkManager::ActiveConnection::State)index.data(NetworkModel::ConnectionStateRole).toUInt() == NetworkManager::ActiveConnection::Activating;
- const bool isAvailable = (NetworkModelItem::ItemType)index.data(NetworkModel::ItemTypeRole).toUInt() == NetworkModelItem::AvailableConnection;
-
- actionCollection()->action("connect_connection")->setEnabled(isAvailable && !isActive && !isActivating);
- actionCollection()->action("disconnect_connection")->setEnabled(isAvailable && (isActive || isActivating));
- actionCollection()->action("edit_connection")->setEnabled(true);
- actionCollection()->action("delete_connection")->setEnabled(true);
- const bool isVpn = static_cast<NetworkManager::ConnectionSettings::ConnectionType>(index.data(NetworkModel::TypeRole).toUInt()) ==
- NetworkManager::ConnectionSettings::Vpn;
- actionCollection()->action("export_vpn")->setEnabled(isVpn);
- }
-}
-
-void ConnectionEditor::slotItemDoubleClicked(const QModelIndex &index)
-{
- if (!index.isValid()) {
- return;
- }
-
- qDebug() << "Double clicked item" << index.data(NetworkModel::UuidRole).toString();
-
- if (index.parent().isValid()) { // category
- qDebug() << "double clicked on the root item which is not editable";
- return;
- }
-
- const QString uuid = index.data(NetworkModel::UuidRole).toString();
- m_handler->editConnection(uuid);
-}
-
-void ConnectionEditor::importSecretsFromPlainTextFiles()
-{
- const QString secretsDirectory = KStandardDirs::locateLocal("data", "networkmanagement/secrets/");
- QDir dir(secretsDirectory);
- if (dir.exists() && !dir.entryList(QDir::Files).isEmpty()) {
- QMap<QString, QMap<QString, QString > > resultingMap;
- foreach (const QString & file, dir.entryList(QDir::Files)) {
- KConfig config(secretsDirectory % file, KConfig::SimpleConfig);
- foreach (const QString & groupName, config.groupList()) {
- KConfigGroup group = config.group(groupName);
- QMap<QString, QString> map = group.entryMap();
- if (!map.isEmpty()) {
- const QString entry = file % ';' % groupName;
- resultingMap.insert(entry, map);
- }
- }
- }
-
- storeSecrets(resultingMap);
- }
-}
-
-void ConnectionEditor::storeSecrets(const QMap< QString, QMap< QString, QString > >& map)
-{
- if (KWallet::Wallet::isEnabled()) {
- KWallet::Wallet * wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0, KWallet::Wallet::Synchronous);
-
- if (!wallet || !wallet->isOpen()) {
- return;
- }
-
- if (!wallet->hasFolder("Network Management")) {
- wallet->createFolder("Network Management");
- }
-
- if (wallet->hasFolder("Network Management") && wallet->setFolder("Network Management")) {
- int count = 0;
- foreach (const QString & entry, map.keys()) {
- QString connectionUuid = entry.split(';').first();
- connectionUuid.replace('{',"").replace('}',"");
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(connectionUuid);
-
- if (connection) {
- wallet->writeMap(entry, map.value(entry));
- ++count;
- }
- }
- }
- }
-}
-
-void ConnectionEditor::importVpn()
-{
- // get the list of supported extensions
- const KService::List services = KServiceTypeTrader::self()->query("PlasmaNetworkManagement/VpnUiPlugin");
- QString extensions;
- foreach (const KService::Ptr &service, services) {
- VpnUiPlugin * vpnPlugin = service->createInstance<VpnUiPlugin>(this);
- if (vpnPlugin) {
- extensions += vpnPlugin->supportedFileExtensions() % QLatin1Literal(" ");
- delete vpnPlugin;
- }
- }
-
- const QString filename = KFileDialog::getOpenFileName(KUrl(), extensions.simplified(), this, i18n("Import VPN Connection"));
- if (!filename.isEmpty()) {
- QFileInfo fi(filename);
- const QString ext = QLatin1Literal("*.") % fi.suffix();
- qDebug() << "Importing VPN connection" << filename << "extension:" << ext;
-
- foreach (const KService::Ptr &service, services) {
- VpnUiPlugin * vpnPlugin = service->createInstance<VpnUiPlugin>(this);
- if (vpnPlugin && vpnPlugin->supportedFileExtensions().contains(ext)) {
- qDebug() << "Found VPN plugin" << service->name() << ", type:" << service->property("X-NetworkManager-Services", QVariant::String).toString();
-
- NMVariantMapMap connection = vpnPlugin->importConnectionSettings(filename);
-
- //qDebug() << "Raw connection:" << connection;
-
- NetworkManager::ConnectionSettings connectionSettings;
- connectionSettings.fromMap(connection);
- connectionSettings.setUuid(NetworkManager::ConnectionSettings::createNewUuid());
-
- //qDebug() << "Converted connection:" << connectionSettings;
-
- const QString conId = NetworkManager::addConnection(connectionSettings.toMap());
- qDebug() << "Adding imported connection under id:" << conId;
-
- if (connection.isEmpty()) { // the "positive" part will arrive with connectionAdded
- m_editor->messageWidget->animatedShow();
- m_editor->messageWidget->setMessageType(KMessageWidget::Error);
- m_editor->messageWidget->setText(i18n("Importing VPN connection %1 failed\n%2", fi.fileName(), vpnPlugin->lastErrorMessage()));
- QTimer::singleShot(5000, m_editor->messageWidget, SLOT(animatedHide()));
- } else {
- delete vpnPlugin;
- break; // stop iterating over the plugins if the import produced at least some output
- }
-
- delete vpnPlugin;
- }
- }
- }
-}
-
-void ConnectionEditor::exportVpn()
-{
- const QModelIndex currentIndex = m_editor->connectionsWidget->currentIndex();
-
- if (!currentIndex.isValid() || currentIndex.parent().isValid()) {
- return;
- }
-
- Connection::Ptr connection = NetworkManager::findConnectionByUuid(currentIndex.data(NetworkModel::UuidRole).toString());
- if (!connection) {
- return;
- }
-
- NetworkManager::ConnectionSettings::Ptr connSettings = connection->settings();
-
- if (connSettings->connectionType() != NetworkManager::ConnectionSettings::Vpn)
- return;
-
- NetworkManager::VpnSetting::Ptr vpnSetting = connSettings->setting(NetworkManager::Setting::Vpn).dynamicCast<NetworkManager::VpnSetting>();
-
- qDebug() << "Exporting VPN connection" << connection->name() << "type:" << vpnSetting->serviceType();
-
- QString error;
- VpnUiPlugin * vpnPlugin = KServiceTypeTrader::createInstanceFromQuery<VpnUiPlugin>(QString::fromLatin1("PlasmaNetworkManagement/VpnUiPlugin"),
- QString::fromLatin1("[X-NetworkManager-Services]=='%1'").arg(vpnSetting->serviceType()),
- this, QVariantList(), &error);
-
- if (vpnPlugin) {
- if (vpnPlugin->suggestedFileName(connSettings).isEmpty()) { // this VPN doesn't support export
- m_editor->messageWidget->animatedShow();
- m_editor->messageWidget->setMessageType(KMessageWidget::Error);
- m_editor->messageWidget->setText(i18n("Export is not supported by this VPN type"));
- QTimer::singleShot(5000, m_editor->messageWidget, SLOT(animatedHide()));
- return;
- }
-
- const KUrl url = KUrl::fromLocalFile(KGlobalSettings::documentPath() + QDir::separator() + vpnPlugin->suggestedFileName(connSettings));
- const QString filename = KFileDialog::getSaveFileName(url, vpnPlugin->supportedFileExtensions(), this, i18n("Export VPN Connection"));
- if (!filename.isEmpty()) {
- if (!vpnPlugin->exportConnectionSettings(connSettings, filename)) {
- m_editor->messageWidget->animatedShow();
- m_editor->messageWidget->setMessageType(KMessageWidget::Error);
- m_editor->messageWidget->setText(i18n("Exporting VPN connection %1 failed\n%2", connection->name(), vpnPlugin->lastErrorMessage()));
- QTimer::singleShot(5000, m_editor->messageWidget, SLOT(animatedHide()));
- } else {
- m_editor->messageWidget->animatedShow();
- m_editor->messageWidget->setMessageType(KMessageWidget::Positive);
- m_editor->messageWidget->setText(i18n("VPN connection %1 exported successfully", connection->name()));
- QTimer::singleShot(5000, m_editor->messageWidget, SLOT(animatedHide()));
- }
- }
- delete vpnPlugin;
- } else {
- qWarning() << "Error getting VpnUiPlugin for export:" << error;
- }
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_CONNECTION_EDITOR_H
-#define PLASMA_NM_CONNECTION_EDITOR_H
-
-#include "handler.h"
-
-#include <QMenu>
-#include <QModelIndex>
-
-#include <KXmlGuiWindow>
-#include <KActionMenu>
-
-#include <NetworkManagerQt/Connection>
-
-namespace Ui
-{
-class ConnectionEditor;
-}
-
-class QTreeWidgetItem;
-
-class ConnectionEditor : public KXmlGuiWindow
-{
-Q_OBJECT
-
-public:
- explicit ConnectionEditor(QWidget* parent = 0, Qt::WindowFlags flags = 0);
- virtual ~ConnectionEditor();
-
-private Q_SLOTS:
- void addConnection(QAction * action);
- void connectionAdded(const QString & connection);
- void connectConnection();
- void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
- void disconnectConnection();
- void editConnection();
- void exportVpn();
- void importVpn();
- void initializeConnections();
- void removeConnection();
- void slotContextMenuRequested(const QPoint& point);
- void slotItemClicked(const QModelIndex& index);
- void slotItemDoubleClicked(const QModelIndex& index);
-
-private:
- Ui::ConnectionEditor * m_editor;
- Handler * m_handler;
- KActionMenu * m_menu;
-
- void initializeMenu();
- void importSecretsFromPlainTextFiles();
- void storeSecrets(const QMap<QString, QMap<QString, QString> > & map);
-};
-
-#endif // PLASMA_NM_CONNECTION_EDITOR_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ConnectionEditor</class>
- <widget class="QWidget" name="ConnectionEditor">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>552</width>
- <height>561</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle">
- <string>Connection Editor</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="KMessageWidget" name="messageWidget" native="true"/>
- </item>
- <item>
- <widget class="KFilterProxySearchLine" name="ktreewidgetsearchline">
- <property name="urlDropsEnabled" stdset="0">
- <bool>false</bool>
- </property>
- <property name="clickMessage" stdset="0">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTreeView" name="connectionsWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="styleSheet">
- <string notr="true">QTreeView::item {
- margin-top: 5px;
- margin-bottom: 5px;
-}</string>
- </property>
- <property name="editTriggers">
- <set>QAbstractItemView::NoEditTriggers</set>
- </property>
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="rootIsDecorated">
- <bool>false</bool>
- </property>
- <property name="sortingEnabled">
- <bool>true</bool>
- </property>
- <property name="allColumnsShowFocus">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KFilterProxySearchLine</class>
- <extends>KLineEdit</extends>
- <header>kfilterproxysearchline.h</header>
- </customwidget>
- <customwidget>
- <class>KMessageWidget</class>
- <extends>QWidget</extends>
- <header>kmessagewidget.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>ktreewidgetsearchline</tabstop>
- <tabstop>connectionsWidget</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-[Desktop Entry]
-Name=kde-nm-connection-editor
-Name[bg]=kde-nm-connection-editor
-Name[bs]=kde-nm-connection-editor
-Name[ca]=kde-nm-connection-editor
-Name[ca@valencia]=kde-nm-connection-editor
-Name[cs]=kde-nm-connection-editor
-Name[da]=kde-nm-connection-editor
-Name[de]=KDE-NM-Verbindungseditor
-Name[el]=kde-nm-connection-editor
-Name[en_GB]=kde-nm-connection-editor
-Name[es]=kde-nm-connection-editor
-Name[et]=kde-nm-connection-editor
-Name[fi]=kde-nm-connection-editor
-Name[fr]=kde-nm-connection-editor
-Name[hu]=kde-nm-connection-editor
-Name[it]=kde-nm-connection-editor
-Name[ko]=kde-nm-connection-editor
-Name[lt]=kde-nm-connection-editor
-Name[mr]=केडीई-एनएम-जुळवणी-संपादक
-Name[nb]=kde-nm-connection-editor
-Name[nds]=NM-Verbinnenpleger för KDE
-Name[nl]=Bewerker van verbindingen voor kde-nm
-Name[pl]=kde-nm-connection-editor
-Name[pt]=kde-nm-connection-editor
-Name[pt_BR]=kde-nm-connection-editor
-Name[ro]=kde-nm-connection-editor
-Name[ru]=kde-nm-connection-editor
-Name[sk]=kde-nm-connection-editor
-Name[sl]=kde-nm-connection-editor
-Name[sv]=kde-nm-connection-editor
-Name[tr]=kde-nm-connection-editor
-Name[uk]=Редактор з’єднань kde-nm
-Name[x-test]=xxkde-nm-connection-editorxx
-Name[zh_CN]=kde-nm-connection-editor
-GenericName=Connection editor
-GenericName[bg]=Редактор на мрежи
-GenericName[bs]=Uređivač konekcije
-GenericName[ca]=Editor de la connexió
-GenericName[ca@valencia]=Editor de la connexió
-GenericName[cs]=Editor spojení
-GenericName[da]=Forbindelseseditor
-GenericName[de]=Verbindungs-Editor
-GenericName[el]=Επεξεργαστής συνδέσεων
-GenericName[en_GB]=Connection editor
-GenericName[es]=Editor de conexión
-GenericName[et]=Ühenduse redaktor
-GenericName[fi]=Yhteysmuokkain
-GenericName[fr]=Éditeur de connexion
-GenericName[hu]=Kapcsolatszerkesztő
-GenericName[it]=Editor delle connessioni
-GenericName[ko]=연결 편집기
-GenericName[lt]=Ryšio tvarkyklė
-GenericName[nb]=Tilkoblingsredigering
-GenericName[nds]=Verbinneneditor
-GenericName[nl]=Bewerker van verbindingen
-GenericName[pl]=Edytor połączenia
-GenericName[pt]=Editor de ligações
-GenericName[pt_BR]=Editor de conexão
-GenericName[ro]=Redactor de conexiuni
-GenericName[ru]=Редактор соединений
-GenericName[sk]=Editor pripojení
-GenericName[sl]=Urejevalnik povezav
-GenericName[sv]=Anslutningseditor
-GenericName[tr]=Bağlantı düzenleyici
-GenericName[uk]=Редактор з’єднань
-GenericName[x-test]=xxConnection editorxx
-GenericName[zh_CN]=连接编辑器
-Comment=Edit your network connections
-Comment[bg]=Управление на мрежовите връзки
-Comment[bs]=Uredi mrežne konekcije
-Comment[ca]=Edita les vostres connexions de xarxa
-Comment[ca@valencia]=Edita les vostres connexions de xarxa
-Comment[cs]=Upravit vaše síťová spojení
-Comment[da]=Redigér dine netværksforbindelser
-Comment[de]=Bearbeiten Sie Ihre Netzwerkverbindungen
-Comment[el]=Επεξεργασία των συνδέσεων δικτύου
-Comment[en_GB]=Edit your network connections
-Comment[es]=Edita tus conexiones de red
-Comment[et]=Võrguühenduste muutmine
-Comment[fi]=Verkkoyhteyksiesi muokkaus
-Comment[fr]=Modifier vos connexions réseau
-Comment[hu]=A hálózati kapcsolatok szerkesztése
-Comment[it]=Modifica le tue connessioni di rete
-Comment[ko]=네트워크 연결 편집
-Comment[lt]=Tvarkykite savo tinklo ryšius
-Comment[mr]=तुमच्या संजाळ जुळवण्या संपादित करा
-Comment[nb]=Rediger dine nettverkstilkoblinger
-Comment[nds]=Dien Nettwarkverbinnen bewerken
-Comment[nl]=Bewerk uw netwerkverbindingen
-Comment[pl]=Edytuj swoje połączenia sieciowe
-Comment[pt]=Edite as suas ligações de rede
-Comment[pt_BR]=Edite as suas conexões de rede
-Comment[ro]=Redactați-vă conexiunile de rețea
-Comment[ru]=Изменить сетевые соединения
-Comment[sk]=Upraviť vaše sieťové pripojenia
-Comment[sl]=Uredite vaše omrežne povezave
-Comment[sv]=Redigera nätverksanslutningar
-Comment[tr]=Ağ bağlantılarınızı düzenleyin
-Comment[uk]=Редагування ваших записів з’єднань з мережею
-Comment[x-test]=xxEdit your network connectionsxx
-Comment[zh_CN]=编辑您的网络连接
-Exec=kde-nm-connection-editor --icon '%i' --caption '%c'
-Icon=network-defaultroute
-Type=Application
-Terminal=false
-Categories=Qt;KDE;Network;
-NoDisplay=true
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<gui name="kde-nm-connection-editor"
- version="3"
- xmlns="http://www.kde.org/standards/kxmlgui/1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0
- http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd" >
-
- <MenuBar>
- <Menu name="file" >
- <Action name="import_vpn" />
- <Action name="export_vpn" />
- </Menu>
-
- <Menu name="connection">
- <text>Connection</text>
- <Action name="connect_connection" />
- <Action name="disconnect_connection" />
- <Action name="add_connection" />
- <Action name="edit_connection" />
- <Action name="delete_connection" />
- </Menu>
- </MenuBar>
-
- <ToolBar name="mainToolBar" >
- <text>Main Toolbar</text>
- <Action name="add_connection" />
- <Separator/>
- <Action name="connect_connection" />
- <Action name="disconnect_connection" />
- <Action name="edit_connection" />
- <Action name="delete_connection" />
- </ToolBar>
-</gui>
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "connectioneditor.h"
-#include "connectiondetaileditor.h"
-#include <config.h>
-
-#include <KApplication>
-#include <KAboutData>
-#include <KCmdLineArgs>
-#include <KMainWindow>
-#include <KUrl>
-#include <KIcon>
-
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/Connection>
-#include <NetworkManagerQt/ConnectionSettings>
-
-int main(int argc, char *argv[])
-{
- KAboutData about("kde-nm-connection-editor", 0, ki18n("Connection editor"),
- PLASMA_NM_VERSION_STRING, ki18n("Manage your network connections"),
- KAboutData::License_GPL, ki18n("(C) 2013-2014 Jan Grulich and Lukáš Tinkl"),
- ki18n("This application allows you to create, edit and delete network connections.\n\nUsing NM version: %1")
- .subs(NetworkManager::version()));
- about.addAuthor(ki18n("Jan Grulich"), ki18n("Developer"), "jgrulich@redhat.com");
- about.addAuthor(ki18n("Lukáš Tinkl"), ki18n("Developer"), "ltinkl@redhat.com");
- about.addCredit(ki18n("Lamarque Souza"), ki18n("libnm-qt author"), "lamarque@kde.org");
- about.addCredit(ki18n("Daniel Nicoletti"), ki18n("various bugfixes"), "dantti12@gmail.com");
- about.addCredit(ki18n("Will Stephenson"), ki18n("VPN plugins"), "wstephenson@kde.org");
- about.addCredit(ki18n("Ilia Kats"), ki18n("VPN plugins"), "ilia-kats@gmx.net");
-
- KCmdLineArgs::init(argc, argv, &about);
-
- KCmdLineOptions options;
- options.add("+[uuid]", ki18n("Edit connection"));
- KCmdLineArgs::addCmdLineOptions(options);
-
- KApplication app;
-
- KGlobal::insertCatalog("libplasmanetworkmanagement-editor"); // setting widgets
- KGlobal::insertCatalog("plasma_applet_org.kde.networkmanagement"); // mobile wizard, UiUtils, ...
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- if(args->count()) {
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(args->arg(0));
-
- if (connection) {
- NetworkManager::ConnectionSettings::Ptr connectionSetting = connection->settings();
-
- ConnectionDetailEditor * editor = new ConnectionDetailEditor(connectionSetting);
- editor->setWindowIcon(KIcon("network-defaultroute"));
- editor->show();
- } else {
- return 1;
- }
- } else {
- if (app.isSessionRestored()) {
- kRestoreMainWindows<ConnectionEditor>();
- } else {
- ConnectionEditor * editor = new ConnectionEditor();
- editor->setWindowIcon(KIcon("network-defaultroute"));
- editor->show();
- }
- }
-
- return app.exec();
-}
+++ /dev/null
-include_directories(${PROJECT_SOURCE_DIR}/libs/editor/widgets)
-
-if (WITH_MODEMMANAGER_SUPPORT)
- set(kded_networkmanagement_SRCS
- notification.cpp
- passworddialog.cpp
- secretagent.cpp
- service.cpp
- bluetoothmonitor.cpp
- modemmonitor.cpp
- pindialog.cpp
- pinwidget.ui
- passworddialog.ui
-
- )
-else()
- set(kded_networkmanagement_SRCS
- notification.cpp
- passworddialog.cpp
- secretagent.cpp
- service.cpp
- bluetoothmonitor.cpp
- passworddialog.ui
- )
-endif()
-
-kde4_add_plugin(kded_networkmanagement ${kded_networkmanagement_SRCS})
-
-target_link_libraries(kded_networkmanagement
- plasmanetworkmanagement-internal
- plasmanetworkmanagement-editor
- ${NETWORKMANAGERQT_LDFLAGS}
- ${MODEMMANAGERQT_LDFLAGS}
- ${KDE4_KDECORE_LIBS}
- ${KDE4_KDEUI_LIBS}
- ${KDE4_SOLID_LIBS}
-)
-
-install(TARGETS kded_networkmanagement DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install(FILES networkmanagement.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded)
-install(FILES networkmanagement.notifyrc DESTINATION ${DATA_INSTALL_DIR}/networkmanagement)
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
-$XGETTEXT `find . -name "*.cpp"` -o $podir/plasmanetworkmanagement-kded.pot
-rm -f rc.cpp
+++ /dev/null
-/*
- Copyright 2011 Lamarque Souza <lamarque@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "bluetoothmonitor.h"
-#include "connectiondetaileditor.h"
-#include <config.h>
-
-#include <QDBusInterface>
-#include <QDBusReply>
-#include <QUuid>
-
-#include <KDebug>
-#include <KStandardDirs>
-#include <KLocale>
-#include <KMessageBox>
-
-#include <NetworkManagerQt/ConnectionSettings>
-#include <NetworkManagerQt/BluetoothSetting>
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/Utils>
-
-#if WITH_MODEMMANAGER_SUPPORT
-#include <ModemManagerQt/modem.h>
-#include <ModemManagerQt/modemdevice.h>
-#endif
-
-BluetoothMonitor::BluetoothMonitor(QObject * parent)
- : QObject(parent)
-{
- QDBusConnection::sessionBus().registerService("org.kde.plasmanetworkmanagement");
- QDBusConnection::sessionBus().registerObject("/org/kde/plasmanetworkmanagement", this, QDBusConnection::ExportScriptableContents);
-}
-
-BluetoothMonitor::~BluetoothMonitor()
-{
-}
-
-void BluetoothMonitor::addBluetoothConnection(const QString& bdAddr, const QString& service)
-{
- qDebug() << "Adding BT connection:" << bdAddr << service;
-
- if (bdAddr.isEmpty() || service.isEmpty()) {
- return;
- }
-
- mBdaddr = bdAddr;
- mService = service.toLower();
- if (mService == "dun") {
-#if WITH_MODEMMANAGER_SUPPORT
- connect(ModemManager::notifier(), SIGNAL(modemAdded(QString)),
- SLOT(modemAdded(QString)));
-#endif
- }
- init();
-}
-
-void BluetoothMonitor::init()
-{
- QRegExp rx("dun|rfcomm?|nap");
-
- if (rx.indexIn(mService) < 0) {
- KMessageBox::sorry(0, i18n("Only 'dun' and 'nap' services are supported."));
- return;
- }
- qDebug() << "Bdaddr == " << mBdaddr;
-
- /*
- * Find default bluetooth adapter registered in BlueZ.
- */
-
- QDBusInterface bluez(QLatin1String("org.bluez"), QLatin1String("/"),
- QLatin1String("org.bluez.Manager"), QDBusConnection::systemBus());
-
- if (!bluez.isValid()) {
- KMessageBox::error(0, i18n("Could not contact Bluetooth manager (BlueZ)."));
- return;
- }
-
- qDebug() << "Querying default adapter";
- QDBusReply<QDBusObjectPath> adapterPath = bluez.call(QLatin1String("DefaultAdapter"));
-
- if (!adapterPath.isValid()) {
- KMessageBox::error(0, i18n("Default Bluetooth adapter not found: %1", adapterPath.error().message()));
- return;
- }
-
- qDebug() << "Default adapter path is " << adapterPath.value().path();
-
- /*
- * Find device path registered in BlueZ.
- */
-
- QDBusInterface adapter(QLatin1String("org.bluez"), adapterPath.value().path(),
- QLatin1String("org.bluez.Adapter"), QDBusConnection::systemBus());
-
- QDBusReply<QDBusObjectPath> devicePath = adapter.call(QLatin1String("FindDevice"), mBdaddr);
-
- if (!devicePath.isValid()) {
- kWarning(KDE_DEFAULT_DEBUG_AREA) << mBdaddr << " is not registered in default bluetooth adapter, it may be in another adapter.";
- kWarning(KDE_DEFAULT_DEBUG_AREA) << mBdaddr << " waiting for it to be registered in ModemManager";
- return;
- }
-
- mDevicePath = devicePath.value().path();
- qDebug() << "Device path for " << mBdaddr << " is " << mDevicePath;
-
- /*
- * Find name registered in BlueZ.
- */
-
- // get device properties
- QDBusInterface device(QLatin1String("org.bluez"), mDevicePath,
- QLatin1String("org.bluez.Device"), QDBusConnection::systemBus());
-
- QDBusReply<QMap<QString, QVariant> > deviceProperties = device.call(QLatin1String("GetProperties"));
-
- if (!deviceProperties.isValid()) {
- return;
- }
-
- QMap<QString, QVariant> properties = deviceProperties.value();
- qDebug() << "Device properties == " << properties;
-
- if (properties.contains("Name")) {
- qDebug() << "Name for" << mBdaddr << "is" << properties["Name"].toString();
- mDeviceName = properties["Name"].toString();
- }
-
- /*
- * Check if phone supports the requested service.
- */
- bool dun = false, nap = false;
- if (properties.contains("UUIDs")) {
- foreach (const QString &u, properties["UUIDs"].toStringList()) {
- QUuid uuid(u);
- if (uuid.data1 == 0x1103) {
- dun = true;
- } else if (uuid.data1 == 0x1116) {
- nap = true;
- }
- }
- }
-
- if (mService != QLatin1String("nap") && !dun) {
- KMessageBox::error(0, i18n("%1 (%2) does not support Dialup Networking (DUN).", mDeviceName, mBdaddr));
- return;
- }
-
- if (mService == QLatin1String("nap") && !nap) {
- KMessageBox::error(0, i18n("%1 (%2) does not support Network Access Point (NAP).", mDeviceName, mBdaddr));
- return;
- }
-
- if (mService == QLatin1String("nap")) {
- bool exists = false;
-
- foreach (const NetworkManager::Connection::Ptr &con, NetworkManager::listConnections()) {
- if (con && con->settings() && con->settings()->connectionType() == NetworkManager::ConnectionSettings::Bluetooth) {
- NetworkManager::BluetoothSetting::Ptr btSetting = con->settings()->setting(NetworkManager::Setting::Bluetooth).staticCast<NetworkManager::BluetoothSetting>();
- if (NetworkManager::Utils::macAddressFromString(btSetting->bluetoothAddress()) == mBdaddr) {
- exists = true;
- break;
- }
- }
- }
-
- if (!exists) {
- NetworkManager::ConnectionSettings connectionSettings(NetworkManager::ConnectionSettings::Bluetooth, NM_BT_CAPABILITY_NAP);
- connectionSettings.setUuid(NetworkManager::ConnectionSettings::createNewUuid());
- connectionSettings.setId(mDeviceName);
- NetworkManager::BluetoothSetting::Ptr btSetting = connectionSettings.setting(NetworkManager::Setting::Bluetooth).staticCast<NetworkManager::BluetoothSetting>();
- btSetting->setBluetoothAddress(NetworkManager::Utils::macAddressFromString(mBdaddr));
- btSetting->setProfileType(NetworkManager::BluetoothSetting::Panu);
- btSetting->setInitialized(true);
- qDebug() << "Adding PAN connection" << connectionSettings;
-
- NetworkManager::addConnection(connectionSettings.toMap());
- }
- return;
- } else if (mService != QLatin1String("dun")) {
- mDunDevice = mService;
- kWarning(KDE_DEFAULT_DEBUG_AREA) << "device(" << mDunDevice << ") for" << mBdaddr << " passed as argument";
- kWarning(KDE_DEFAULT_DEBUG_AREA) << "waiting for it to be registered in ModemManager";
- return;
- }
-
- qDebug() << "Connecting to modem's" << mDevicePath << "serial DUN port with" << mService;
-
- /*
- * Contact BlueZ to connect phone's service.
- */
- QDBusInterface serial(QLatin1String("org.bluez"), mDevicePath,
- QLatin1String("org.bluez.Serial"), QDBusConnection::systemBus());
-
- QDBusReply<QString> reply = serial.call(QLatin1String("Connect"), mService);
- if (!reply.isValid()) {
- KMessageBox::error(0, i18n("Error activating devices's serial port: %1", reply.error().message()));
- return;
- }
-
- mDunDevice = reply.value();
-}
-
-#if WITH_MODEMMANAGER_SUPPORT
-void BluetoothMonitor::modemAdded(const QString &udi)
-{
- qDebug() << "Modem added" << udi;
-
- ModemManager::ModemDevice::Ptr modemDevice = ModemManager::findModemDevice(udi);
- ModemManager::Modem::Ptr modem = modemDevice->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
-
- qDebug() << "Found suitable modem:" << modemDevice->uni();
- qDebug() << "DUN device:" << mDunDevice;
-
- QStringList temp = mDunDevice.split('/');
- if (temp.count() == 3) {
- mDunDevice = temp[2];
- }
-
- if (!modem || modem->device() != mDunDevice) {
-
- if (modem) {
- KMessageBox::error(0, i18n("Device %1 is not the wanted one (%2)", modem->device(), mDunDevice));
- } else {
- KMessageBox::error(0, i18n("Device for serial port %1 (%2) not found.", mDunDevice, udi));
- }
- return;
- }
-
- NetworkManager::ConnectionSettings::ConnectionType type;
- if (modemDevice->isGsmModem())
- type = NetworkManager::ConnectionSettings::Gsm;
- else if (modemDevice->isCdmaModem())
- type = NetworkManager::ConnectionSettings::Cdma;
- else
- type = NetworkManager::ConnectionSettings::Unknown;
-
- if (type == NetworkManager::ConnectionSettings::Unknown) {
- return;
- }
-
- bool exists = false;
-
- foreach (const NetworkManager::Connection::Ptr &con, NetworkManager::listConnections()) {
- if (con && con->settings() && con->settings()->connectionType() == NetworkManager::ConnectionSettings::Bluetooth) {
- NetworkManager::BluetoothSetting::Ptr btSetting = con->settings()->setting(NetworkManager::Setting::Bluetooth).staticCast<NetworkManager::BluetoothSetting>();
- if (btSetting->bluetoothAddress() == NetworkManager::Utils::macAddressFromString(mBdaddr)) {
- exists = true;
- break;
- }
- }
- }
-
- if (!exists) {
- mobileConnectionWizard = new MobileConnectionWizard(NetworkManager::ConnectionSettings::Bluetooth);
- if (mobileConnectionWizard.data()->exec() == QDialog::Accepted && mobileConnectionWizard.data()->getError() == MobileProviders::Success) {
- qDebug() << "Mobile broadband wizard finished:" << mobileConnectionWizard.data()->type() << mobileConnectionWizard.data()->args();
- if (mobileConnectionWizard.data()->args().count() == 2) { //GSM or CDMA
- qDebug() << "Creating new PAN connection for BT device:" << mBdaddr;
-
- QVariantMap tmp = qdbus_cast<QVariantMap>(mobileConnectionWizard.data()->args().value(1));
- NetworkManager::ConnectionSettings connectionSettings(NetworkManager::ConnectionSettings::Bluetooth, NM_BT_CAPABILITY_DUN);
- connectionSettings.setUuid(NetworkManager::ConnectionSettings::createNewUuid());
- connectionSettings.setId(mDeviceName);
- NetworkManager::BluetoothSetting::Ptr btSetting = connectionSettings.setting(NetworkManager::Setting::Bluetooth).staticCast<NetworkManager::BluetoothSetting>();
- btSetting->setBluetoothAddress(NetworkManager::Utils::macAddressFromString(mBdaddr));
- btSetting->setProfileType(NetworkManager::BluetoothSetting::Dun);
- btSetting->setInitialized(true);
-
- if (mobileConnectionWizard.data()->type() == NetworkManager::ConnectionSettings::Gsm) {
- connectionSettings.setting(NetworkManager::Setting::Gsm)->fromMap(tmp);
- connectionSettings.setting(NetworkManager::Setting::Gsm)->setInitialized(true);
- } else if (mobileConnectionWizard.data()->type() == NetworkManager::ConnectionSettings::Cdma) {
- connectionSettings.setting(NetworkManager::Setting::Cdma)->fromMap(tmp);
- connectionSettings.setting(NetworkManager::Setting::Cdma)->setInitialized(true);
- }
-
- qDebug() << "Adding DUN connection" << connectionSettings;
-
- NetworkManager::addConnection(connectionSettings.toMap());
- }
- }
-
- if (mobileConnectionWizard) {
- mobileConnectionWizard.clear();
- }
- }
-}
-#endif
+++ /dev/null
-/*
- Copyright 2011 Lamarque Souza <lamarque@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_BLUETOOTH_MONITOR_H
-#define PLASMA_NM_BLUETOOTH_MONITOR_H
-#if WITH_MODEMMANAGER_SUPPORT
-#include "mobileconnectionwizard.h"
-#include <ModemManagerQt/manager.h>
-#endif
-#include <QDBusObjectPath>
-
-class BluetoothMonitor: public QObject
-{
-Q_OBJECT
-Q_CLASSINFO("D-Bus Interface", "org.kde.plasmanetworkmanagement")
-public:
- explicit BluetoothMonitor(QObject * parent);
- ~BluetoothMonitor();
-
-public Q_SLOTS:
- Q_SCRIPTABLE void addBluetoothConnection(const QString & bdAddr, const QString & service);
-private Q_SLOTS:
- void init();
-#if WITH_MODEMMANAGER_SUPPORT
- void modemAdded(const QString &udi);
-#endif
-private:
- QString mBdaddr;
- QString mService;
- QString mDunDevice;
- QString mDevicePath;
- QString mDeviceName;
-#if WITH_MODEMMANAGER_SUPPORT
- QWeakPointer<MobileConnectionWizard> mobileConnectionWizard;
-#endif
-};
-#endif
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "modemmonitor.h"
-
-#include <QDBusPendingReply>
-
-#include <KLocale>
-#include <KMessageBox>
-#include <kdeversion.h>
-#include <KDebug>
-
-#include <ModemManager/ModemManager.h>
-#include <ModemManagerQt/manager.h>
-#include <ModemManagerQt/modemdevice.h>
-#include <ModemManagerQt/modem.h>
-#include <ModemManagerQt/sim.h>
-
-#include "pindialog.h"
-
-class ModemMonitorPrivate
-{
-public:
- QWeakPointer<PinDialog> dialog;
-};
-
-ModemMonitor::ModemMonitor(QObject * parent)
- :QObject(parent), d_ptr(new ModemMonitorPrivate)
-{
- Q_D(ModemMonitor);
- d->dialog.clear();
-
- QObject::connect(ModemManager::notifier(), SIGNAL(modemAdded(QString)), SLOT(modemAdded(QString)));
- foreach (const ModemManager::ModemDevice::Ptr &iface, ModemManager::modemDevices()) {
- modemAdded(iface->uni());
- }
-}
-
-ModemMonitor::~ModemMonitor()
-{
- delete d_ptr;
-}
-
-void ModemMonitor::modemAdded(const QString & udi)
-{
- Q_D(ModemMonitor);
-
- ModemManager::ModemDevice::Ptr modemDevice = ModemManager::findModemDevice(udi);
- ModemManager::Modem::Ptr modem;
- if (modemDevice) {
- modem = modemDevice->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
- } else {
- return;
- }
-
- connect(modem.data(), SIGNAL(unlockRequiredChanged(MMModemLock)), SLOT(requestPin(MMModemLock)));
-
- if (d->dialog || (modem && modem->unlockRequired() == MM_MODEM_LOCK_NONE) || (modem && modem->unlockRequired() == MM_MODEM_LOCK_UNKNOWN)) {
- return;
- }
-
- if (modem) {
- // Using queued invocation to prevent kded stalling here until user enters the pin.
- QMetaObject::invokeMethod(modem.data(), "unlockRequiredChanged", Qt::QueuedConnection,
- Q_ARG(MMModemLock, modem->unlockRequired()));
- }
-}
-
-void ModemMonitor::requestPin(MMModemLock lock)
-{
- Q_D(ModemMonitor);
- kDebug() << "unlockRequired == " << lock;
- // Handle just SIM-PIN and SIM-PUK, because some other types may cause problems and they are not also handled by nm-applet
- if (lock == MM_MODEM_LOCK_NONE || lock == MM_MODEM_LOCK_UNKNOWN || (lock != MM_MODEM_LOCK_SIM_PIN && lock != MM_MODEM_LOCK_SIM_PUK)) {
- return;
- }
-
- ModemManager::Modem *modem = qobject_cast<ModemManager::Modem *>(sender());
- if (!modem) {
- return;
- }
-
- if (d->dialog) {
- kDebug() << "PinDialog already running";
- return;
- }
-
- if (lock == MM_MODEM_LOCK_SIM_PIN) {
- d->dialog = new PinDialog(modem, PinDialog::SimPin);
- } else if (lock == MM_MODEM_LOCK_SIM_PIN2) {
- d->dialog = new PinDialog(modem, PinDialog::SimPin2);
- } else if (lock == MM_MODEM_LOCK_SIM_PUK) {
- d->dialog = new PinDialog(modem, PinDialog::SimPuk);
- } else if (lock == MM_MODEM_LOCK_SIM_PUK2 ) {
- d->dialog = new PinDialog(modem, PinDialog::SimPuk);
- } else if (lock == MM_MODEM_LOCK_PH_SP_PIN) {
- d->dialog = new PinDialog(modem, PinDialog::ModemServiceProviderPin);
- } else if (lock == MM_MODEM_LOCK_PH_SP_PUK) {
- d->dialog = new PinDialog(modem, PinDialog::ModemServiceProviderPuk);
- } else if (lock == MM_MODEM_LOCK_PH_NET_PIN) {
- d->dialog = new PinDialog(modem, PinDialog::ModemNetworkPin);
- } else if (lock == MM_MODEM_LOCK_PH_NET_PUK) {
- d->dialog = new PinDialog(modem, PinDialog::ModemNetworkPuk);
- } else if (lock == MM_MODEM_LOCK_PH_SIM_PIN) {
- d->dialog = new PinDialog(modem, PinDialog::ModemPin);
- } else if (lock == MM_MODEM_LOCK_PH_CORP_PIN) {
- d->dialog = new PinDialog(modem, PinDialog::ModemCorporatePin);
- } else if (lock == MM_MODEM_LOCK_PH_CORP_PUK) {
- d->dialog = new PinDialog(modem, PinDialog::ModemCorporatePuk);
- } else if (lock == MM_MODEM_LOCK_PH_FSIM_PIN) {
- d->dialog = new PinDialog(modem, PinDialog::ModemPhFsimPin);
- } else if (lock == MM_MODEM_LOCK_PH_FSIM_PUK) {
- d->dialog = new PinDialog(modem, PinDialog::ModemPhFsimPuk);
- } else if (lock == MM_MODEM_LOCK_PH_NETSUB_PIN) {
- d->dialog = new PinDialog(modem, PinDialog::ModemNetworkSubsetPin);
- } else if (lock == MM_MODEM_LOCK_PH_NETSUB_PUK) {
- d->dialog = new PinDialog(modem, PinDialog::ModemNetworkSubsetPuk);
- }
-
- if (d->dialog.data()->exec() != QDialog::Accepted) {
- goto OUT;
- }
-
- kDebug() << "Sending unlock code";
-
- {
- ModemManager::Sim::Ptr sim;
- ModemManager::ModemDevice::Ptr modemDevice = ModemManager::findModemDevice(modem->uni());
- if (modemDevice && modemDevice->sim()) {
- sim = modemDevice->sim();
- }
-
- if (!sim) {
- return;
- }
-
- QDBusPendingCallWatcher *watcher = 0;
-
- PinDialog::Type type = d->dialog.data()->type();
-
- if (type == PinDialog::SimPin || type == PinDialog::SimPin2 ||
- type == PinDialog::ModemServiceProviderPin || type == PinDialog::ModemNetworkPin ||
- type == PinDialog::ModemPin || type == PinDialog::ModemCorporatePin ||
- type == PinDialog::ModemPhFsimPin || type == PinDialog::ModemNetworkSubsetPin) {
- QDBusPendingCall reply = sim->sendPin(d->dialog.data()->pin());
- watcher = new QDBusPendingCallWatcher(reply, sim.data());
- } else if (type == PinDialog::SimPuk ||
- type == PinDialog::SimPuk2 || type == PinDialog::ModemServiceProviderPuk ||
- type == PinDialog::ModemNetworkPuk || type == PinDialog::ModemCorporatePuk ||
- type == PinDialog::ModemPhFsimPuk || type == PinDialog::ModemNetworkSubsetPuk) {
- QDBusPendingCall reply = sim->sendPuk(d->dialog.data()->puk(), d->dialog.data()->pin());
- watcher = new QDBusPendingCallWatcher(reply, sim.data());
- }
-
- connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onSendPinArrived(QDBusPendingCallWatcher*)));
- }
-
-OUT:
- if(d->dialog) {
- d->dialog.data()->deleteLater();
- }
- d->dialog.clear();
-}
-
-void ModemMonitor::onSendPinArrived(QDBusPendingCallWatcher * watcher)
-{
- QDBusPendingReply<> reply = *watcher;
-
- if (reply.isValid()) {
- // Automatically enabling this for cell phones with expensive data plans is not a good idea.
- //NetworkManager::setWwanEnabled(true);
- } else {
- KMessageBox::error(0, i18nc("Text in GSM PIN/PUK unlock error dialog", "Error unlocking modem: %1", reply.error().message()),
- i18nc("Title for GSM PIN/PUK unlock error dialog", "PIN/PUK unlock error"));
- }
-
- watcher->deleteLater();
-}
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_MODEM_MONITOR_H
-#define PLASMA_NM_MODEM_MONITOR_H
-
-#include <QObject>
-#include <QDBusPendingCallWatcher>
-
-#include <config.h>
-
-#include <ModemManager/ModemManager.h>
-#include <ModemManagerQt/modem.h>
-
-#include "plasmanm_export.h"
-
-class ModemMonitorPrivate;
-
-/**
- * Monitors modem hardware and provides a PIN unlock dialog
- */
-class PLASMA_NM_EXPORT ModemMonitor : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(ModemMonitor)
-public:
- explicit ModemMonitor(QObject * parent);
- virtual ~ModemMonitor();
-private slots:
- void modemAdded(const QString&);
- void requestPin(MMModemLock lock);
- void onSendPinArrived(QDBusPendingCallWatcher *);
-private:
- ModemMonitorPrivate * d_ptr;
-};
-
-#endif // PLASMA_NM_MODEM_MONITOR_H
+++ /dev/null
-[Desktop Entry]
-Name=Plasma Networkmanagement module
-Name[bg]=Модул за настройка на мрежата
-Name[bs]=Plasma Networkmanagement režim
-Name[ca]=Mòdul de Plasma per a la Gestió de la xarxa
-Name[ca@valencia]=Mòdul de Plasma per a la Gestió de la xarxa
-Name[cs]=Modul Plasma Networkmanagement
-Name[da]=Plasma netværkshåndteringsmodul
-Name[de]=Plasma-Netzwerkverwaltungsmodul
-Name[el]=Άρθρωμα Plasma για τη διαχείριση δικτύων
-Name[en_GB]=Plasma Networkmanagement module
-Name[es]=Módulo Networkmanagement de Plasma
-Name[et]=Plasma võrguhalduse moodul
-Name[fi]=Plasman verkonhallintamoduuli
-Name[fr]=Module « Networkmanagement » pour Plasma
-Name[hu]=Plasma hálózatkezelés modul
-Name[it]=Modulo della gestione di rete di Plasma
-Name[ko]=Plasma 네트워크 관리 모듈
-Name[lt]=Plasma tinklo valdymo modulis
-Name[nb]=Plasma-modul for nettverksstyring
-Name[nds]=Plasma-Nettwarkpleegmoduul
-Name[nl]=Plasma module voor netwerkbeheer
-Name[pl]=Moduł zarządzania siecią Plazmy
-Name[pt]=Módulo de Gestão de Rede do Plasma
-Name[pt_BR]=Módulo do Networkmanagement para o Plasma
-Name[ro]=Modul Plasma pentru gestiunea rețelei
-Name[ru]=Модуль для управления сетью
-Name[sk]=Modul Plasma správa siete
-Name[sl]=Modul upravljanja omrežij za Plasmo
-Name[sv]=Plasma nätverkshanteringsmodul
-Name[tr]=Plasma Ağ yönetimi modülü
-Name[uk]=Модуль керування мережею Плазми
-Name[x-test]=xxPlasma Networkmanagement modulexx
-Name[zh_CN]=Plasma 网络管理模块
-Comment=Provides secrets to the NetworkManager daemon
-Comment[bs]=Pruža tajne Upravljaču mreže daemon
-Comment[ca]=Proporciona secrets al dimoni NetworkManager
-Comment[ca@valencia]=Proporciona secrets al dimoni NetworkManager
-Comment[cs]=Poskytuje přihlašovací informace pro službu NetworkManageru
-Comment[da]=Giver hemmeligheder til NetworkManager-dæmonen
-Comment[de]=Stellt dem NetworkManager-Dienst vertrauliche Daten zur Verfügung
-Comment[el]=Παρέχει κωδικούς ασφαλείας στον δαίμονας NetworkManager
-Comment[en_GB]=Provides secrets to the NetworkManager daemon
-Comment[es]=Proporciona secretos para el demonio NetworkManager
-Comment[et]=Saladuste edastamine NetworkManageri deemonile
-Comment[fi]=Välittää salaisuuksia NetworkManager-palvelulle
-Comment[fr]=Fournit des mots de passe pour le démon NetworkManager
-Comment[hu]=Titkokat biztosít a NetworkManager démonhoz
-Comment[it]=Fornisce i segreti al demone NetworkManager
-Comment[ko]=NetworkManager 데몬에 비밀 정보 제공
-Comment[lt]=Teikia slapukus NetworkManager tarnybai
-Comment[nb]=Forsyner NetworkManager-daemonen med hemmeligheter
-Comment[nds]=Stellt Anmellinformatschonen för den NetworkManager-Dämoon praat
-Comment[nl]=Levert secrets aan de NetworkManager-daemon
-Comment[pl]=Dostarcza danych poufnych do demona Menadżera Sieci Sieci
-Comment[pt]=Fornece as senhas do serviço NetworkManager
-Comment[pt_BR]=Fornece as senhas do serviço NetworkManager
-Comment[ro]=Furnizează secrete către demonul NetworkManager
-Comment[ru]=Предоставляет пароли и ключи демону NetworkManager
-Comment[sk]=Poskytuje tajnosti k démonu NetworkManager
-Comment[sl]=Ponuja skrivnosti za ozadnji program NetworkManager
-Comment[sv]=Tillhandahåller hemligheter till nätverkshanteringsdemonen
-Comment[tr]=AğYönetici yardımcısına şifreleri sağlar
-Comment[uk]=Надає реєстраційні дані фоновій службі NetworkManager
-Comment[x-test]=xxProvides secrets to the NetworkManager daemonxx
-Comment[zh_CN]=为 NetworkManager 守护程序提供密码
-Type=Service
-X-KDE-ServiceTypes=KDEDModule
-X-KDE-ModuleType=Library
-X-KDE-Library=networkmanagement
-X-KDE-DBus-ModuleName=networkmanagement
-X-KDE-Kded-autoload=true
-X-KDE-Kded-load-on-demand=true
-X-KDE-Kded-phase=1
-OnlyShowIn=KDE;
+++ /dev/null
-[Global]
-IconName=applications-internet
-Name=networkmanagement
-Name[bg]=networkmanagement
-Name[bs]=Upravljanje mrežom
-Name[ca]=Gestió de la xarxa
-Name[ca@valencia]=Gestió de la xarxa
-Name[cs]=networkmanagement
-Name[da]=netværkshåndtering
-Name[de]=Netzwerkverwaltung
-Name[el]=networkmanagement
-Name[en_GB]=networkmanagement
-Name[es]=networkmanagement
-Name[et]=networkmanagement
-Name[fi]=networkmanagement
-Name[fr]=networkmanagement
-Name[hu]=hálózatkezelés
-Name[it]=gestione di rete
-Name[ko]=networkmanagement
-Name[lt]=tinklo valdymas
-Name[nb]=nettverksstyring
-Name[nds]=Nettwarkpleegmoduul
-Name[nl]=netwerkbeheer
-Name[pl]=zarządzanie siecią
-Name[pt]=Gestão de Rede
-Name[pt_BR]=networkmanagement
-Name[ro]=networkmanagement
-Name[ru]=networkmanagement
-Name[sk]=správa siete
-Name[sl]=networkmanagement
-Name[sv]=nätverkshantering
-Name[tr]=ağyönetimi
-Name[uk]=Керування мережею
-Name[x-test]=xxnetworkmanagementxx
-Name[zh_CN]=网络管理
-Comment=Notifies about network errors
-Comment[bg]=Уведомява за мрежови грешки
-Comment[bs]=Prijavljuje mrežne greške
-Comment[ca]=Notifica quant als errors de la xarxa
-Comment[ca@valencia]=Notifica quant als errors de la xarxa
-Comment[cs]=Oznamuje chyby sítě
-Comment[da]=Bekendtgør om netværksfejl
-Comment[de]=Benachrichtigungen über Netzwerkfehler
-Comment[el]=Ειδοποιεί για σφάλματα σύνδεσης
-Comment[en_GB]=Notifies about network errors
-Comment[es]=Notifica errores de red
-Comment[et]=Märguanded võrgutõrgete kohta
-Comment[fi]=Ilmoittaa verkkovirheistä
-Comment[fr]=Notifie les erreurs de réseau
-Comment[hu]=Értesít a hálózati hibákról
-Comment[it]=Notifica gli errori di rete
-Comment[ko]=네트워크 오류 알림
-Comment[lt]=Praneša apie tinklo klaidas
-Comment[nb]=Varsler om nettverksfeil
-Comment[nds]=Gifft över Nettwarkfehlers Bescheed
-Comment[nl]=Geeft meldingen over netwerkfouten
-Comment[pl]=Powiadamia o błędach sieci
-Comment[pt]=Notificações de erros na rede
-Comment[pt_BR]=Notificações de erros na rede
-Comment[ro]=Notifică despre erorile de rețea
-Comment[sk]=Upozorní na sieťové chyby
-Comment[sl]=Obvešča o napakah omrežja
-Comment[sv]=Underrättar om nätverksfel
-Comment[tr]=Ağ hatalarını bildirir
-Comment[uk]=Сповіщає про помилки у роботі мережі
-Comment[x-test]=xxNotifies about network errorsxx
-Comment[zh_CN]=提示网络错误
-
-[Event/ConnectionActivated]
-Name=Connection activated
-Name[bs]=Konekcija aktivirana
-Name[ca]=Connexió activada
-Name[cs]=Spojení aktivováno
-Name[da]=Forbindelse aktiveret
-Name[de]=Verbindung aktiviert
-Name[en_GB]=Connection activated
-Name[es]=Conexión activada
-Name[et]=Ühendus on aktiivne
-Name[fi]=Yhteys muodostettu
-Name[hu]=Kapcsolat aktiválva
-Name[it]=Connessione attivata
-Name[ko]=연결 활성화됨
-Name[nb]=Tilkobling aktivert
-Name[nds]=Verbinnen anmaakt
-Name[nl]=Verbinding geactiveerd
-Name[pl]=Nawiązano połączenie
-Name[pt]=Ligação activada
-Name[pt_BR]=Conexão ativada
-Name[ru]=Соединение установлено
-Name[sk]=Pripojenie aktivované
-Name[sl]=Povezava omogočena
-Name[sv]=Anslutning aktiverad
-Name[tr]=Bağlantı etkinleştirildi
-Name[uk]=З’єднання задіяно
-Name[x-test]=xxConnection activatedxx
-IconName=applications-internet
-Action=Popup
-
-[Event/ConnectionDeactivated]
-Name=Connection deactivated
-Name[bs]=Konekcija deaktivirana
-Name[ca]=Connexió desactivada
-Name[cs]=Spojení deaktivováno
-Name[da]=Forbindelse deaktiveret
-Name[de]=Verbindung deaktiviert
-Name[en_GB]=Connection deactivated
-Name[es]=Conexión desactivada
-Name[et]=Ühendus
-Name[fi]=Yhteys katkaistu
-Name[hu]=Kapcsolat deaktiválva
-Name[it]=Connessione disattivata
-Name[ko]=연결 비활성화됨
-Name[nb]=Tilkobling deaktivert
-Name[nds]=Verbinnen utmaakt
-Name[nl]=Verbinding gedeactiveerd
-Name[pl]=Zerwano połączenie
-Name[pt]=Ligação desactivada
-Name[pt_BR]=Conexão desativada
-Name[ru]=Соединение отключено
-Name[sk]=Pripojenie deaktivované
-Name[sl]=Povezava onemogočena
-Name[sv]=Anslutning nerkopplad
-Name[tr]=Bağlantı devre dışı bırakıldı
-Name[uk]=З’єднання вимкнено
-Name[x-test]=xxConnection deactivatedxx
-IconName=applications-internet
-Action=Popup
-
-[Event/DeviceFailed]
-Name=Device failed
-Name[bs]=Uređaj pao
-Name[ca]=El dispositiu ha fallat
-Name[cs]=Zařízení selhalo
-Name[da]=Enheden fejlede
-Name[de]=Das Gerät ist nicht bereit
-Name[en_GB]=Device failed
-Name[es]=El dispositivo ha fallado
-Name[et]=Ühendus ei ole aktiivne
-Name[fi]=Laite lakkasi toimimasta
-Name[hu]=Az eszköz meghiúsult
-Name[it]=Dispositivo non funzionante
-Name[ko]=장치 오류
-Name[nb]=Enhet sviktet
-Name[nds]=Reedschap-Fehler
-Name[nl]=Apparaat is mislukt
-Name[pl]=Niepowodzenie urządzenia
-Name[pt]=Não foi possível activar o dispositivo
-Name[pt_BR]=Falha no dispositivo
-Name[ru]=Сбой устройства
-Name[sk]=Zariadenie zlyhalo
-Name[sl]=Naprava je spodletela
-Name[sv]=Enhet misslyckades
-Name[tr]=Aygıt etkinleştirilemedi
-Name[uk]=Помилка пристрою
-Name[x-test]=xxDevice failedxx
-IconName=applications-internet
-Action=Popup
-
-[Event/FailedToActivateConnection]
-Name=Failed to activate connection
-Name[bs]=Neuspjela aktivacija konekcije
-Name[ca]=Ha fallat en activar la connexió
-Name[cs]=Spojení nelze aktivovat
-Name[da]=Kunne ikke aktivere forbindelsen
-Name[de]=Die Verbindung kann nicht aktiviert werden
-Name[en_GB]=Failed to activate connection
-Name[es]=La activación de la conexión ha fallado
-Name[et]=Ühenduse aktiveerimine nurjus
-Name[fi]=Yhteyden muodostaminen epäonnistui
-Name[hu]=Nem sikerült aktiválni a kapcsolatot
-Name[it]=Attivazione del dispositivo non riuscita
-Name[ko]=연결을 활성화할 수 없음
-Name[nb]=Klarte ikke å aktivere tilkobling
-Name[nds]=Verbinnen lett sik nich anmaken
-Name[nl]=Activeren van verbinding is mislukt
-Name[pl]=Nieudane nawiązywanie połączenia
-Name[pt]=Não foi possível activar a ligação
-Name[pt_BR]=Ocorreu um erro ao ativar a conexão
-Name[ru]=Не удалось задействовать соединение
-Name[sk]=Zlyhalo aktivovanie pripojenia
-Name[sl]=Povezave ni bilo mogoče omogočiti
-Name[sv]=Aktivering av anslutning misslyckades
-Name[tr]=Bağlantı etkinleştirme başarısız
-Name[uk]=Не вдалося задіяти з’єднання
-Name[x-test]=xxFailed to activate connectionxx
-IconName=applications-internet
-Action=Popup
-
-[Event/FailedToAddConnection]
-Name=Failed to add connection
-Name[bs]=Neuspjelo dodavanje konekcije
-Name[ca]=Ha fallat en afegir la connexió
-Name[cs]=Přidání spojení selhalo
-Name[da]=Kunne ikke tilføje forbindelse
-Name[de]=Die Verbindung kann nicht hinzugefügt werden
-Name[en_GB]=Failed to add connection
-Name[es]=Ha ocurrido un fallo al añadir la conexión
-Name[et]=Ühenduse lisamine nurjus
-Name[fi]=Yhteyden lisääminen epäonnistui
-Name[hu]=Nem sikerült hozzáadni a kapcsolatot
-Name[it]=Aggiunta della connessione non riuscita
-Name[ko]=연결을 추가할 수 없음
-Name[nb]=Klarte ikke å legge til tilkobling
-Name[nds]=Verbinnen lett sik nich tofögen
-Name[nl]=Toevoegen van verbinding is mislukt
-Name[pl]=Nieudane dodawanie połączenia
-Name[pt]=Não foi possível adicionar a ligação
-Name[pt_BR]=Ocorreu um erro ao adicionar a conexão
-Name[ru]=Не удалось добавить соединение
-Name[sk]=Zlyhalo pridanie pripojenia
-Name[sl]=Povezave ni bilo mogoče dodati
-Name[sv]=Tillägg av anslutning misslyckades
-Name[tr]=Bağlantı eklenemedi
-Name[uk]=Не вдалося додати з’єднання
-Name[x-test]=xxFailed to add connectionxx
-IconName=applications-internet
-Action=Popup
-
-[Event/FailedToRequestScan]
-Name=Failed to request scan
-Name[bs]=Neuspjelo traženje skeniranja
-Name[ca]=Ha fallat en demanar escanejar
-Name[cs]=Vyžádání skenu selhalo
-Name[da]=Kunne ikke anmode om scanning
-Name[de]=Anforderung zum Durchsuchen fehlgeschlagen
-Name[en_GB]=Failed to request scan
-Name[es]=La petición de la exploración ha fallado
-Name[et]=Uurimise nõudmine nurjus
-Name[fi]=Verkkojen hakemispyyntö epäonnistui
-Name[hu]=Nem sikerült a pásztázás kérése
-Name[it]=Richiesta di scansione non riuscita
-Name[ko]=검색을 요청할 수 없음
-Name[nb]=Klarte ikke be om skanning
-Name[nds]=Dörkieken lett sik nich anfragen
-Name[nl]=Scan uitvoeren is mislukt
-Name[pl]=Nieudane żądanie przeszukiwania
-Name[pt]=Não foi possível pedir a sondagem
-Name[pt_BR]=Ocorreu um erro ao solicitar a verificação
-Name[ru]=Не удалось запросить сканирование
-Name[sk]=Zlyhalo vyžiadanie prehľadania
-Name[sl]=Zahteva po preiskovanju ni uspela
-Name[sv]=Begäran om sökning misslyckades
-Name[tr]=Tarama isteği başarısız
-Name[uk]=Не вдалося виконати запит щодо сканування
-Name[x-test]=xxFailed to request scanxx
-IconName=applications-internet
-Action=None
-
-[Event/MissingVpnPlugin]
-Name=Missing VPN plugin
-Name[bg]=Лшпсваща приставка за VPN
-Name[bs]=Nedostaje VPN dodatak
-Name[ca]=Manca el connector VPN
-Name[ca@valencia]=Manca el connector VPN
-Name[cs]=Chybějící modul VPN
-Name[da]=Mangler VPN-plugin
-Name[de]=Fehlendes VPN-Modul
-Name[el]=Λείπει το πρόσθετο VPN
-Name[en_GB]=Missing VPN plugin
-Name[es]=Falta complemento VPN
-Name[et]=VPN-i plugin puudub
-Name[fi]=Puuttuva VPN-liitännäinen
-Name[fr]=Module VPN manquant
-Name[hu]=Hiányzó VPN bővítmény
-Name[it]=Estensione VPN mancante
-Name[ko]=VPN 플러그인 없음
-Name[lt]=Trūksta VPN įskiepio
-Name[nb]=Mangler VPN-programtillegg
-Name[nds]=VPN-Moduul fehlt
-Name[nl]=VPN-plug-in ontbreekt
-Name[pl]=Brak wtyczki VPN
-Name[pt]='Plugin' de VPN em falta
-Name[pt_BR]=Plugin de VPN ausente
-Name[ru]=Отсутствует модуль VPN
-Name[sk]=Chýba VPN plugin
-Name[sl]=Manjka vstavek VPN
-Name[sv]=Saknar VPN-insticksprogram
-Name[tr]=VPN eklentisi eksik
-Name[uk]=Не вистачає додатка VPN
-Name[x-test]=xxMissing VPN pluginxx
-Name[zh_CN]=缺少 OpenVPN 插件
-IconName=applications-internet
-Action=Popup
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 by Daniel Nicoletti <dantti12@gmail.com>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "notification.h"
-
-#include <uiutils.h>
-
-#include <NetworkManagerQt/Manager>
-
-#include <KLocalizedString>
-#include <KNotification>
-#include <KIcon>
-#include <KDebug>
-
-Notification::Notification(QObject *parent) :
- QObject(parent)
-{
- // devices
- foreach (const NetworkManager::Device::Ptr &device, NetworkManager::networkInterfaces()) {
- addDevice(device);
- }
-
- connect(NetworkManager::notifier(), SIGNAL(deviceAdded(QString)), this, SLOT(deviceAdded(QString)));
-
- // connections
- foreach (const NetworkManager::ActiveConnection::Ptr &ac, NetworkManager::activeConnections()) {
- addActiveConnection(ac);
- }
-
- connect(NetworkManager::notifier(), SIGNAL(activeConnectionAdded(QString)), this, SLOT(addActiveConnection(QString)));
-}
-
-void Notification::deviceAdded(const QString &uni)
-{
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(uni);
- addDevice(device);
-}
-
-void Notification::addDevice(const NetworkManager::Device::Ptr &device)
-{
- connect(device.data(), SIGNAL(stateChanged(NetworkManager::Device::State,NetworkManager::Device::State,NetworkManager::Device::StateChangeReason)),
- this, SLOT(stateChanged(NetworkManager::Device::State,NetworkManager::Device::State,NetworkManager::Device::StateChangeReason)));
-}
-
-void Notification::stateChanged(NetworkManager::Device::State newstate, NetworkManager::Device::State oldstate, NetworkManager::Device::StateChangeReason reason)
-{
- Q_UNUSED(oldstate)
- kDebug() << newstate << reason;
- NetworkManager::Device *device = qobject_cast<NetworkManager::Device*>(sender());
- if (newstate == NetworkManager::Device::Activated && m_notifications.contains(device->uni())) {
- KNotification *notify = m_notifications.value(device->uni());
- notify->deleteLater();
- m_notifications.remove(device->uni());
- return;
- } else if (newstate != NetworkManager::Device::Failed) {
- return;
- }
-
- const QString identifier = UiUtils::prettyInterfaceName(device->type(), device->interfaceName());
- QString text;
- switch (reason) {
- case NetworkManager::Device::NoReason:
- case NetworkManager::Device::UnknownReason:
- case NetworkManager::Device::NowManagedReason:
- case NetworkManager::Device::NowUnmanagedReason:
- return;
- case NetworkManager::Device::ConfigFailedReason:
- text = i18nc("@info:status Notification when the device failed due to ConfigFailedReason",
- "The device could not be configured");
- break;
- case NetworkManager::Device::ConfigUnavailableReason:
- text = i18nc("@info:status Notification when the device failed due to ConfigUnavailableReason",
- "IP configuration was unavailable");
- break;
- case NetworkManager::Device::ConfigExpiredReason:
- text = i18nc("@info:status Notification when the device failed due to ConfigExpiredReason",
- "IP configuration expired");
- break;
- case NetworkManager::Device::NoSecretsReason:
- text = i18nc("@info:status Notification when the device failed due to NoSecretsReason",
- "No secrets were provided");
- break;
- case NetworkManager::Device::AuthSupplicantDisconnectReason:
- text = i18nc("@info:status Notification when the device failed due to AuthSupplicantDisconnectReason",
- "Authorization supplicant disconnected");
- break;
- case NetworkManager::Device::AuthSupplicantConfigFailedReason:
- text = i18nc("@info:status Notification when the device failed due to AuthSupplicantConfigFailedReason",
- "Authorization supplicant's configuration failed");
- break;
- case NetworkManager::Device::AuthSupplicantFailedReason:
- text = i18nc("@info:status Notification when the device failed due to AuthSupplicantFailedReason",
- "Authorization supplicant failed");
- break;
- case NetworkManager::Device::AuthSupplicantTimeoutReason:
- text = i18nc("@info:status Notification when the device failed due to AuthSupplicantTimeoutReason",
- "Authorization supplicant timed out");
- break;
- case NetworkManager::Device::PppStartFailedReason:
- text = i18nc("@info:status Notification when the device failed due to PppStartFailedReason",
- "PPP failed to start");
- break;
- case NetworkManager::Device::PppDisconnectReason:
- text = i18nc("@info:status Notification when the device failed due to PppDisconnectReason",
- "PPP disconnected");
- break;
- case NetworkManager::Device::PppFailedReason:
- text = i18nc("@info:status Notification when the device failed due to PppFailedReason",
- "PPP failed");
- break;
- case NetworkManager::Device::DhcpStartFailedReason:
- text = i18nc("@info:status Notification when the device failed due to DhcpStartFailedReason",
- "DHCP failed to start");
- break;
- case NetworkManager::Device::DhcpErrorReason:
- text = i18nc("@info:status Notification when the device failed due to DhcpErrorReason",
- "A DHCP error occurred");
- break;
- case NetworkManager::Device::DhcpFailedReason:
- text = i18nc("@info:status Notification when the device failed due to DhcpFailedReason",
- "DHCP failed ");
- break;
- case NetworkManager::Device::SharedStartFailedReason:
- text = i18nc("@info:status Notification when the device failed due to SharedStartFailedReason",
- "The shared service failed to start");
- break;
- case NetworkManager::Device::SharedFailedReason:
- text = i18nc("@info:status Notification when the device failed due to SharedFailedReason",
- "The shared service failed");
- break;
- case NetworkManager::Device::AutoIpStartFailedReason:
- text = i18nc("@info:status Notification when the device failed due to AutoIpStartFailedReason",
- "The auto IP service failed to start");
- break;
- case NetworkManager::Device::AutoIpErrorReason:
- text = i18nc("@info:status Notification when the device failed due to AutoIpErrorReason",
- "The auto IP service reported an error");
- break;
- case NetworkManager::Device::AutoIpFailedReason:
- text = i18nc("@info:status Notification when the device failed due to AutoIpFailedReason",
- "The auto IP service failed");
- break;
- case NetworkManager::Device::ModemBusyReason:
- text = i18nc("@info:status Notification when the device failed due to ModemBusyReason",
- "The modem is busy");
- break;
- case NetworkManager::Device::ModemNoDialToneReason:
- text = i18nc("@info:status Notification when the device failed due to ModemNoDialToneReason",
- "The modem has no dial tone");
- break;
- case NetworkManager::Device::ModemNoCarrierReason:
- text = i18nc("@info:status Notification when the device failed due to ModemNoCarrierReason",
- "The modem shows no carrier");
- break;
- case NetworkManager::Device::ModemDialTimeoutReason:
- text = i18nc("@info:status Notification when the device failed due to ModemDialTimeoutReason",
- "The modem dial timed out");
- break;
- case NetworkManager::Device::ModemDialFailedReason:
- text = i18nc("@info:status Notification when the device failed due to ModemDialFailedReason",
- "The modem dial failed");
- break;
- case NetworkManager::Device::ModemInitFailedReason:
- text = i18nc("@info:status Notification when the device failed due to ModemInitFailedReason",
- "The modem could not be initialized");
- break;
- case NetworkManager::Device::GsmApnSelectFailedReason:
- text = i18nc("@info:status Notification when the device failed due to GsmApnSelectFailedReason",
- "The GSM APN could not be selected");
- break;
- case NetworkManager::Device::GsmNotSearchingReason:
- text = i18nc("@info:status Notification when the device failed due to GsmNotSearchingReason",
- "The GSM modem is not searching");
- break;
- case NetworkManager::Device::GsmRegistrationDeniedReason:
- text = i18nc("@info:status Notification when the device failed due to GsmRegistrationDeniedReason",
- "GSM network registration was denied");
- break;
- case NetworkManager::Device::GsmRegistrationTimeoutReason:
- text = i18nc("@info:status Notification when the device failed due to GsmRegistrationTimeoutReason",
- "GSM network registration timed out");
- break;
- case NetworkManager::Device::GsmRegistrationFailedReason:
- text = i18nc("@info:status Notification when the device failed due to GsmRegistrationFailedReason",
- "GSM registration failed");
- break;
- case NetworkManager::Device::GsmPinCheckFailedReason:
- text = i18nc("@info:status Notification when the device failed due to GsmPinCheckFailedReason",
- "The GSM PIN check failed");
- break;
- case NetworkManager::Device::FirmwareMissingReason:
- text = i18nc("@info:status Notification when the device failed due to FirmwareMissingReason",
- "Device firmware is missing");
- break;
- case NetworkManager::Device::DeviceRemovedReason:
- text = i18nc("@info:status Notification when the device failed due to DeviceRemovedReason",
- "The device was removed");
- break;
- case NetworkManager::Device::SleepingReason:
- text = i18nc("@info:status Notification when the device failed due to SleepingReason",
- "The networking system is now sleeping");
- break;
- case NetworkManager::Device::ConnectionRemovedReason:
- text = i18nc("@info:status Notification when the device failed due to ConnectionRemovedReason",
- "The connection was removed");
- break;
- case NetworkManager::Device::UserRequestedReason:
- return;
- case NetworkManager::Device::CarrierReason:
- text = i18nc("@info:status Notification when the device failed due to CarrierReason",
- "The cable was disconnected");
- break;
- case NetworkManager::Device::ConnectionAssumedReason:
- case NetworkManager::Device::SupplicantAvailableReason:
- return;
- case NetworkManager::Device::ModemNotFoundReason:
- text = i18nc("@info:status Notification when the device failed due to ModemNotFoundReason",
- "The modem could not be found");
- break;
- case NetworkManager::Device::BluetoothFailedReason:
- text = i18nc("@info:status Notification when the device failed due to BluetoothFailedReason",
- "The bluetooth connection failed or timed out");
- break;
- case NetworkManager::Device::GsmSimNotInserted:
- text = i18nc("@info:status Notification when the device failed due to GsmSimNotInserted",
- "GSM Modem's SIM Card not inserted");
- break;
- case NetworkManager::Device::GsmSimPinRequired:
- text = i18nc("@info:status Notification when the device failed due to GsmSimPinRequired",
- "GSM Modem's SIM Pin required");
- break;
- case NetworkManager::Device::GsmSimPukRequired:
- text = i18nc("@info:status Notification when the device failed due to GsmSimPukRequired",
- "GSM Modem's SIM Puk required");
- break;
- case NetworkManager::Device::GsmSimWrong:
- text = i18nc("@info:status Notification when the device failed due to GsmSimWrong",
- "GSM Modem's SIM wrong");
- break;
- case NetworkManager::Device::InfiniBandMode:
- text = i18nc("@info:status Notification when the device failed due to InfiniBandMode",
- "InfiniBand device does not support connected mode");
- break;
- case NetworkManager::Device::DependencyFailed:
- text = i18nc("@info:status Notification when the device failed due to DependencyFailed",
- "A dependency of the connection failed");
- break;
- case NetworkManager::Device::Br2684Failed:
- text = i18nc("@info:status Notification when the device failed due to Br2684Failed",
- "Problem with the RFC 2684 Ethernet over ADSL bridge");
- break;
- case NetworkManager::Device::ModemManagerUnavailable:
- text = i18nc("@info:status Notification when the device failed due to ModemManagerUnavailable",
- "ModemManager not running");
- break;
- case NetworkManager::Device::SsidNotFound:
- text = i18nc("@info:status Notification when the device failed due to SsidNotFound",
- "The WiFi network could not be found");
- break;
- case NetworkManager::Device::SecondaryConnectionFailed:
- text = i18nc("@info:status Notification when the device failed due to SecondaryConnectionFailed",
- "A secondary connection of the base connection failed");
- break;
- case NetworkManager::Device::Reserved:
- return;
- }
- kDebug() << text;
-
- if (m_notifications.contains(device->uni())) {
- KNotification *notify = m_notifications.value(device->uni());
- notify->setText(text);
- notify->update();
- } else {
- KNotification *notify = new KNotification("DeviceFailed", KNotification::CloseOnTimeout, this);
- connect(notify, SIGNAL(closed()), this, SLOT(notificationClosed()));
- notify->setProperty("uni", device->uni());
- notify->setComponentData(KComponentData("networkmanagement"));
- notify->setPixmap(KIcon("dialog-warning").pixmap(64, 64));
- notify->setTitle(identifier);
- notify->setText(text);
- notify->sendEvent();
- m_notifications[device->uni()] = notify;
- }
-}
-
-void Notification::addActiveConnection(const QString &path)
-{
- NetworkManager::ActiveConnection::Ptr ac = NetworkManager::findActiveConnection(path);
- if (ac && ac->isValid()) {
- addActiveConnection(ac);
- }
-}
-
-void Notification::addActiveConnection(const NetworkManager::ActiveConnection::Ptr &ac)
-{
- if (ac->vpn()) {
- NetworkManager::VpnConnection::Ptr vpnConnection = ac.objectCast<NetworkManager::VpnConnection>();
- connect(vpnConnection.data(), SIGNAL(stateChanged(NetworkManager::VpnConnection::State,NetworkManager::VpnConnection::StateChangeReason)),
- this, SLOT(onVpnConnectionStateChanged(NetworkManager::VpnConnection::State,NetworkManager::VpnConnection::StateChangeReason)));
- } else {
- connect(ac.data(), SIGNAL(stateChanged(NetworkManager::ActiveConnection::State)),
- this, SLOT(onActiveConnectionStateChanged(NetworkManager::ActiveConnection::State)));
- }
-}
-
-void Notification::onActiveConnectionStateChanged(NetworkManager::ActiveConnection::State state)
-{
- NetworkManager::ActiveConnection *ac = qobject_cast<NetworkManager::ActiveConnection*>(sender());
-
- QString eventId, text;
- const QString acName = ac->connection()->name();
- const QString connectionId = ac->path();
-
- if (state == NetworkManager::ActiveConnection::Activated) {
- eventId = "ConnectionActivated";
- text = i18n("Connection '%1' activated.", acName);
- } else if (state == NetworkManager::ActiveConnection::Deactivated) {
- eventId = "ConnectionDeactivated";
- text = i18n("Connection '%1' deactivated.", acName);
- } else {
- kDebug() << "Unhandled active connection state change: " << state;
- return;
- }
-
- KNotification *notify = new KNotification(eventId, KNotification::CloseOnTimeout, this);
- connect(notify, SIGNAL(closed()), this, SLOT(notificationClosed()));
- notify->setProperty("uni", connectionId);
- notify->setComponentData(KComponentData("networkmanagement"));
- if (state == NetworkManager::ActiveConnection::Activated) {
- notify->setPixmap(KIcon("dialog-information").pixmap(64, 64));
- } else {
- notify->setPixmap(KIcon("dialog-warning").pixmap(64, 64));
- }
- notify->setTitle(acName);
- notify->setText(text);
- notify->sendEvent();
- m_notifications[connectionId] = notify;
-}
-
-void Notification::onVpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason)
-{
- NetworkManager::VpnConnection *vpn = qobject_cast<NetworkManager::VpnConnection*>(sender());
-
- QString eventId, text;
- const QString vpnName = vpn->connection()->name();
- const QString connectionId = vpn->path();
-
- if (state == NetworkManager::VpnConnection::Activated) {
- eventId = "ConnectionActivated";
- text = i18n("VPN connection '%1' activated.", vpnName);
- } else if (state == NetworkManager::VpnConnection::Failed) {
- eventId = "FailedToActivateConnection";
- text = i18n("VPN connection '%1' failed.", vpnName);
- } else if (state == NetworkManager::VpnConnection::Disconnected) {
- eventId = "ConnectionDeactivated";
- text = i18n("VPN connection '%1' disconnected.", vpnName);
- } else {
- kDebug() << "Unhandled VPN connection state change: " << state;
- return;
- }
-
- switch (reason) {
- case NetworkManager::VpnConnection::UserDisconnectedReason:
- text = i18n("The VPN connection changed state because the user disconnected it.");
- break;
- case NetworkManager::VpnConnection::DeviceDisconnectedReason:
- text = i18n("The VPN connection changed state because the device it was using was disconnected.");
- break;
- case NetworkManager::VpnConnection::ServiceStoppedReason:
- text = i18n("The service providing the VPN connection was stopped.");
- break;
- case NetworkManager::VpnConnection::IpConfigInvalidReason:
- text = i18n("The IP config of the VPN connection was invalid.");
- break;
- case NetworkManager::VpnConnection::ConnectTimeoutReason:
- text = i18n("The connection attempt to the VPN service timed out.");
- break;
- case NetworkManager::VpnConnection::ServiceStartTimeoutReason:
- text = i18n("A timeout occurred while starting the service providing the VPN connection.");
- break;
- case NetworkManager::VpnConnection::ServiceStartFailedReason:
- text = i18n("Starting the service providing the VPN connection failed.");
- break;
- case NetworkManager::VpnConnection::NoSecretsReason:
- text = i18n("Necessary secrets for the VPN connection were not provided.");
- break;
- case NetworkManager::VpnConnection::LoginFailedReason:
- text = i18n("Authentication to the VPN server failed.");
- break;
- case NetworkManager::VpnConnection::ConnectionRemovedReason:
- text = i18n("The connection was deleted from settings.");
- break;
- default:
- case NetworkManager::VpnConnection::UnknownReason:
- case NetworkManager::VpnConnection::NoneReason:
- break;
- }
-
- KNotification *notify = new KNotification(eventId, KNotification::CloseOnTimeout, this);
- connect(notify, SIGNAL(closed()), this, SLOT(notificationClosed()));
- notify->setProperty("uni", connectionId);
- notify->setComponentData(KComponentData("networkmanagement"));
- if (state == NetworkManager::VpnConnection::Activated) {
- notify->setPixmap(KIcon("dialog-information").pixmap(64, 64));
- } else {
- notify->setPixmap(KIcon("dialog-warning").pixmap(64, 64));
- }
- notify->setTitle(vpnName);
- notify->setText(text);
- notify->sendEvent();
- m_notifications[connectionId] = notify;
-}
-
-void Notification::notificationClosed()
-{
- KNotification *notify = qobject_cast<KNotification*>(sender());
- m_notifications.remove(notify->property("uni").toString());
- notify->deleteLater();
-}
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 by Daniel Nicoletti <dantti12@gmail.com>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_NOTIFICATION_H
-#define PLASMA_NM_NOTIFICATION_H
-
-#include <QObject>
-
-#include <NetworkManagerQt/Device>
-#include <NetworkManagerQt/VpnConnection>
-
-class KNotification;
-class Notification : public QObject
-{
- Q_OBJECT
-public:
- explicit Notification(QObject *parent = 0);
-
-private slots:
- void deviceAdded(const QString &uni);
- void addDevice(const NetworkManager::Device::Ptr &device);
- void stateChanged(NetworkManager::Device::State newstate, NetworkManager::Device::State oldstate, NetworkManager::Device::StateChangeReason reason);
-
- void addActiveConnection(const QString & path);
- void addActiveConnection(const NetworkManager::ActiveConnection::Ptr & ac);
- void onActiveConnectionStateChanged(NetworkManager::ActiveConnection::State state);
- void onVpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason);
-
- void notificationClosed();
-
-private:
- QHash<QString, KNotification*> m_notifications;
-};
-
-#endif // PLASMA_NM_NOTIFICATION_H
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 by Daniel Nicoletti <dantti12@gmail.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "passworddialog.h"
-#include "ui_passworddialog.h"
-
-#include <vpnuiplugin.h>
-
-#include <NetworkManagerQt/WirelessSetting>
-#include <NetworkManagerQt/VpnSetting>
-
-#include <KServiceTypeTrader>
-#include <KIcon>
-#include <KDebug>
-
-using namespace NetworkManager;
-
-PasswordDialog::PasswordDialog(const NMVariantMapMap &connection, SecretAgent::GetSecretsFlags flags, const QString &setting_name, QWidget *parent) :
- KDialog(parent),
- ui(0),
- vpnWidget(0),
- m_connection(connection),
- m_flags(flags),
- m_settingName(setting_name),
- m_hasError(false),
- m_error(SecretAgent::NoSecrets)
-{
- setWindowIcon(KIcon("dialog-password"));
-}
-
-PasswordDialog::~PasswordDialog()
-{
- delete ui;
-}
-
-void PasswordDialog::setupGenericUi(const ConnectionSettings &connectionSettings)
-{
- NetworkManager::Setting::Ptr setting = connectionSettings.setting(m_settingName);
-
- ui = new Ui::PasswordDialog;
- ui->setupUi(mainWidget());
- // TODO fix this for high DPI
- ui->labelIcon->setPixmap(KIcon("dialog-password").pixmap(32));
-
- m_neededSecrets = setting->needSecrets(m_flags & SecretAgent::RequestNew);
- if (m_neededSecrets.isEmpty()) {
- kWarning() << "list of secrets is empty!!!";
- m_hasError = true;
- m_error = SecretAgent::InternalError;
- m_errorMessage = QLatin1String("No secrets were requested");
- return;
- }
-
- NetworkManager::WirelessSetting::Ptr wifi;
- wifi = connectionSettings.setting(Setting::Wireless).dynamicCast<WirelessSetting>();
-
- Setting::SettingType connectionType = setting->type();
- if (wifi && (connectionType == Setting::WirelessSecurity || connectionType == Setting::Security8021x)) {
- const QString ssid = QString::fromUtf8(wifi->ssid());
- ui->labelText->setText(i18n("For accessing the wireless network '%1' you need to provide a password below", ssid));
- } else {
- ui->labelText->setText(i18n("Please provide the password for activating connection '%1'", connectionSettings.id()));
- }
-
- ui->password->setPasswordMode(true);
- ui->password->setFocus();
- connect(ui->showPassword, SIGNAL(toggled(bool)), this, SLOT(showPassword(bool)));
-}
-
-void PasswordDialog::setupVpnUi(const ConnectionSettings &connectionSettings)
-{
- NetworkManager::VpnSetting::Ptr vpnSetting;
- vpnSetting = connectionSettings.setting(NetworkManager::Setting::Vpn).dynamicCast<NetworkManager::VpnSetting>();
- if (!vpnSetting) {
- kDebug() << "Missing VPN setting!";
- m_hasError = true;
- m_error = SecretAgent::InternalError;
- m_errorMessage = QLatin1String("VPN settings are missing");
- } else {
- VpnUiPlugin *vpnUiPlugin;
- QString error;
- const QString serviceType = vpnSetting->serviceType();
- //qDebug() << "Agent loading VPN plugin" << serviceType << "from DBUS" << calledFromDBus();
- //vpnSetting->printSetting();
- vpnUiPlugin = KServiceTypeTrader::createInstanceFromQuery<VpnUiPlugin>(QLatin1String("PlasmaNetworkManagement/VpnUiPlugin"),
- QString::fromLatin1("[X-NetworkManager-Services]=='%1'").arg(serviceType),
- this, QVariantList(), &error);
- if (vpnUiPlugin && error.isEmpty()) {
- const QString shortName = serviceType.section('.', -1);
- setCaption(i18n("VPN secrets (%1)", shortName));
- vpnWidget = vpnUiPlugin->askUser(vpnSetting, this);
- setMainWidget(vpnWidget);
- } else {
- kDebug() << error << ", serviceType == " << serviceType;
- m_hasError = true;
- m_error = SecretAgent::InternalError;
- m_errorMessage = error;
- }
- }
-}
-
-bool PasswordDialog::hasError() const
-{
- return m_hasError;
-}
-
-SecretAgent::Error PasswordDialog::error() const
-{
- return m_error;
-}
-
-QString PasswordDialog::errorMessage() const
-{
- return m_errorMessage;
-}
-
-NMVariantMapMap PasswordDialog::secrets() const
-{
- NMVariantMapMap ret = m_connection;
- QVariantMap result;
- if (vpnWidget) {
- result = vpnWidget->setting();
- } else if (!ui->password->text().isEmpty() && !m_neededSecrets.isEmpty()) {
- result.insert(m_neededSecrets.first(), ui->password->text());
- }
-
- ret.insert(m_settingName, result);
-
- return ret;
-}
-
-void PasswordDialog::showPassword(bool show)
-{
- ui->password->setPasswordMode(!show);
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 by Daniel Nicoletti <dantti12@gmail.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_PASSWORD_DIALOG_H
-#define PLASMA_NM_PASSWORD_DIALOG_H
-
-#include <NetworkManagerQt/ConnectionSettings>
-#include <NetworkManagerQt/SecretAgent>
-
-#include <KDialog>
-
-#include "plasmanm_export.h"
-
-namespace Ui {
-class PasswordDialog;
-}
-class SettingWidget;
-class PLASMA_NM_EXPORT PasswordDialog : public KDialog
-{
- Q_OBJECT
-public:
- explicit PasswordDialog(const NMVariantMapMap &connection,
- NetworkManager::SecretAgent::GetSecretsFlags flags,
- const QString &setting_name,
- QWidget *parent = 0);
- ~PasswordDialog();
- void setupGenericUi(const NetworkManager::ConnectionSettings &connectionSettings);
- void setupVpnUi(const NetworkManager::ConnectionSettings &connectionSettings);
-
- bool hasError() const;
- NetworkManager::SecretAgent::Error error() const;
- QString errorMessage() const;
-
- NMVariantMapMap secrets() const;
-
-private slots:
- void showPassword(bool show);
-
-private:
- Ui::PasswordDialog *ui;
- SettingWidget *vpnWidget;
- NMVariantMapMap m_connection;
- NetworkManager::SecretAgent::GetSecretsFlags m_flags;
- QString m_settingName;
- QStringList m_neededSecrets;
- bool m_hasError;
- NetworkManager::SecretAgent::Error m_error;
- QString m_errorMessage;
-};
-
-#endif // PLASMA_NM_PASSWORD_DIALOG_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PasswordDialog</class>
- <widget class="QWidget" name="PasswordDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>415</width>
- <height>83</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Password dialog</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="labelIcon">
- <property name="text">
- <string>TextLabel</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <layout class="QFormLayout" name="formLayout">
- <item row="1" column="0">
- <widget class="QLabel" name="labelPass">
- <property name="text">
- <string>Password:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="password" native="true">
- <property name="maxLength" stdset="0">
- <number>64</number>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QCheckBox" name="showPassword">
- <property name="text">
- <string>&Show password</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="2">
- <widget class="QLabel" name="labelText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QWidget</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2011 Lamarque Souza <lamarque@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "pindialog.h"
-
-#include <QIntValidator>
-
-#include <KDebug>
-#include <kwindowsystem.h>
-
-#include <ModemManagerQt/manager.h>
-
-PinDialog::PinDialog(ModemManager::Modem *modem, const Type type, QWidget *parent)
- : KDialog(parent), m_type(type)
-{
- if (modem) {
- m_udi = modem->uni();
- m_name = modem->device();
- foreach (const Solid::Device &d, Solid::Device::allDevices()) {
- if (d.udi().contains(m_name, Qt::CaseInsensitive)) {
- m_name = d.product();
- if (!m_name.startsWith(d.vendor())) {
- m_name = d.vendor() + ' ' + m_name;
- }
- break;
- }
- }
- }
-
- QWidget *w = new QWidget();
- ui = new Ui::PinWidget();
- ui->setupUi(w);
- ui->pin->setPasswordMode(true);
-
- QIntValidator * validator = new QIntValidator(this);
- validator->setRange(1000, 99999999);
- ui->pin->setValidator(validator);
- ui->pin2->setValidator(validator);
-
- QIntValidator * validator2 = new QIntValidator(this);
- validator2->setRange(10000000, 99999999);
- ui->puk->setValidator(validator2);
-
- ui->errorMessage->setHidden(true);
- QRect desktop = KGlobalSettings::desktopGeometry(topLevelWidget());
- setMinimumWidth(qMin(1000, qMax(sizeHint().width(), desktop.width() / 4)));
-
- pixmapLabel = new QLabel(mainWidget());
- pixmapLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
- ui->gridLayout->addWidget(pixmapLabel, 0, 0);
- pixmapLabel->setPixmap(KIcon("dialog-password").pixmap(KIconLoader::SizeHuge));
-
- setButtons(KDialog::Ok | KDialog::Cancel);
- setDefaultButton(KDialog::Ok);
- button(KDialog::Ok)->setText(i18nc("As in 'Unlock cell phone with this pin code'", "Unlock"));
- setMainWidget(w);
-
- if (isPukDialog()) {
- QString pukType;
- if (m_type == PinDialog::SimPuk) {
- pukType = i18n("SIM PUK");
- } else if (m_type == PinDialog::SimPuk2) {
- pukType = i18n("SIM PUK2");
- } else if (m_type == PinDialog::ModemServiceProviderPuk) {
- pukType = i18n("Service provider PUK");
- } else if (m_type == PinDialog::ModemNetworkPuk) {
- pukType = i18n("Network PUK");
- } else if (m_type == PinDialog::ModemCorporatePuk) {
- pukType = i18n("Corporate PUK");
- } else if (m_type == PinDialog::ModemPhFsimPuk) {
- pukType = i18n("PH-FSIM PUK");
- } else {
- pukType = i18n("Network Subset PUK");
- }
-
- setWindowTitle(i18n("%1 unlock required", pukType));
- ui->title->setText(i18n("%1 Unlock Required", pukType));
- ui->prompt->setText(i18n("The mobile broadband device '%1' requires a %2 code before it can be used.", m_name, pukType));
- ui->pukLabel->setText(i18n("%1 code:",pukType));
- ui->pinLabel->setText(i18n("New PIN code:"));
- ui->pin2Label->setText(i18n("Re-enter new PIN code:"));
- ui->chkShowPass->setText(i18n("Show PIN/PUK code"));
-
- ui->puk->setFocus();
- ui->pukLabel->show();
- ui->puk->show();
- ui->pin2Label->show();
- ui->pin2->show();
- } else if (isPinDialog()) {
- QString pinType;
- if (m_type == PinDialog::SimPin) {
- pinType = i18n("SIM PIN");
- } else if (m_type == PinDialog::SimPin2) {
- pinType = i18n("SIM PIN2");
- } else if (m_type == PinDialog::ModemServiceProviderPin) {
- pinType = i18n("Service provider PIN");
- } else if (m_type == PinDialog::ModemNetworkPin) {
- pinType = i18n("Network PIN");
- } else if (m_type == PinDialog::ModemPin) {
- pinType = i18n("PIN");
- } else if (m_type == PinDialog::ModemCorporatePin) {
- pinType = i18n("Corporate PIN");
- } else if (m_type == PinDialog::ModemPhFsimPin) {
- pinType = i18n("PH-FSIM PIN");
- } else {
- pinType = i18n("Network Subset PIN");
- }
- setWindowTitle(i18n("%1 unlock required", pinType));
- ui->title->setText(i18n("%1 Unlock Required", pinType));
- ui->prompt->setText(i18n("The mobile broadband device '%1' requires a %2 code before it can be used.", m_name, pinType));
- ui->pinLabel->setText(i18n("%1 code:", pinType));
- ui->chkShowPass->setText(i18n("Show PIN code"));
-
- ui->pin->setFocus();
- ui->pukLabel->hide();
- ui->puk->hide();
- ui->pin2Label->hide();
- ui->pin2->hide();
- }
-
- ui->puk->clear();
- ui->pin->clear();
- ui->pin2->clear();
- ui->puk->setCursorPosition(0);
- ui->pin->setCursorPosition(0);
- ui->pin2->setCursorPosition(0);
-
- KWindowSystem::setState(winId(), NET::KeepAbove);
- KWindowSystem::activateWindow(winId());
-
- move((desktop.width() - width()) / 2, (desktop.height() - height()) / 2);
- connect(ui->chkShowPass, SIGNAL(toggled(bool)), this, SLOT(chkShowPassToggled(bool)));
- connect(ModemManager::notifier(), SIGNAL(modemRemoved(QString)), SLOT(modemRemoved(QString)));
-}
-
-PinDialog::~PinDialog()
-{
- delete ui;
-}
-
-void PinDialog::chkShowPassToggled(bool on)
-{
- ui->pin->setPasswordMode(!on);
- ui->pin2->setPasswordMode(!on);
- ui->puk->setPasswordMode(!on);
-
- ui->puk->setCursorPosition(0);
- ui->pin->setCursorPosition(0);
- ui->pin2->setCursorPosition(0);
-
- if (isPukDialog()) {
- ui->puk->setFocus();
- } else {
- ui->pin->setFocus();
- }
-}
-
-void PinDialog::modemRemoved(const QString &udi)
-{
- if (udi == m_udi) {
- reject();
- }
-}
-
-PinDialog::Type PinDialog::type() const
-{
- return m_type;
-}
-
-QString PinDialog::pin() const
-{
- return ui->pin->text();
-}
-
-QString PinDialog::pin2() const
-{
- return ui->pin2->text();
-}
-
-QString PinDialog::puk() const
-{
- return ui->puk->text();
-}
-
-void PinDialog::showErrorMessage(const PinDialog::ErrorCode error)
-{
- QString msg;
- QFont bold = font();
- ui->pinLabel->setFont(bold);
- ui->pin2Label->setFont(bold);
- ui->pukLabel->setFont(bold);
- bold.setBold(true);
- switch(error) {
- case PinCodeTooShort:
- msg = i18n("PIN code too short. It should be at least 4 digits.");
- ui->pin->setFocus();
- ui->pinLabel->setFont(bold);
- break;
- case PinCodesDoNotMatch:
- msg = i18n("The two PIN codes do not match");
- ui->pin2->setFocus();
- ui->pin2Label->setFont(bold);
- break;
- case PukCodeTooShort:
- msg = i18n("PUK code too short. It should be 8 digits.");
- ui->puk->setFocus();
- ui->pukLabel->setFont(bold);
- break;
- default:
- msg = i18n("Unknown Error");
- }
- ui->errorMessage->setText(msg, KTitleWidget::ErrorMessage);
- adjustSize();
-}
-
-
-void PinDialog::accept()
-{
- if (isPukDialog()) {
- if (pin() != pin2()) {
- showErrorMessage(PinCodesDoNotMatch);
- return;
- } else if (puk().length() < 8) {
- showErrorMessage(PukCodeTooShort);
- return;
- }
- }
-
- if (pin().length() < 4) {
- showErrorMessage(PinCodeTooShort);
- return;
- }
-
- QDialog::accept();
-}
-
-bool PinDialog::isPinDialog() const
-{
- return (m_type == PinDialog::SimPin ||
- m_type == PinDialog::SimPin2 ||
- m_type == PinDialog::ModemServiceProviderPin ||
- m_type == PinDialog::ModemNetworkPin ||
- m_type == PinDialog::ModemPin ||
- m_type == PinDialog::ModemCorporatePin ||
- m_type == PinDialog::ModemPhFsimPin ||
- m_type == PinDialog::ModemNetworkSubsetPin);
-}
-
-bool PinDialog::isPukDialog() const
-{
- return !isPinDialog();
-}
+++ /dev/null
-/*
-Copyright 2011 Lamarque Souza <lamarque@kde.org>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_PIN_DIALOG_H
-#define PLASMA_NM_PIN_DIALOG_H
-
-#include <QWidget>
-
-#include <KDialog>
-#include <KLocale>
-#include <KPushButton>
-#include <Solid/Device>
-
-#include <config.h>
-
-#include <ModemManagerQt/modem.h>
-#include "ui_pinwidget.h"
-
-class PinWidget;
-
-class PinDialog : public KDialog
-{
- Q_OBJECT
-public:
- enum Type {
- SimPin,
- SimPin2,
- SimPuk,
- SimPuk2,
- ModemServiceProviderPin,
- ModemServiceProviderPuk,
- ModemNetworkPin,
- ModemNetworkPuk,
- ModemPin,
- ModemCorporatePin,
- ModemCorporatePuk,
- ModemPhFsimPin,
- ModemPhFsimPuk,
- ModemNetworkSubsetPin,
- ModemNetworkSubsetPuk
- };
- enum ErrorCode {PinCodeTooShort, PinCodesDoNotMatch, PukCodeTooShort};
-
- explicit PinDialog(ModemManager::Modem *modem, const Type type = SimPin, QWidget *parent=0);
- ~PinDialog();
-
- Type type() const;
- QString pin() const;
- QString pin2() const;
- QString puk() const;
-
-public Q_SLOTS:
- void accept();
-
-private Q_SLOTS:
- void chkShowPassToggled(bool on);
- void modemRemoved(const QString &udi);
-
-private:
- void showErrorMessage(const PinDialog::ErrorCode);
- bool isPukDialog() const;
- bool isPinDialog() const;
- Ui::PinWidget * ui;
- QLabel* pixmapLabel;
- QString m_name;
- Type m_type;
- QString m_udi;
-};
-
-#endif // PLASMA_NM_PIN_DIALOG_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PinWidget</class>
- <widget class="QWidget" name="PinWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>218</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>SIM PIN unlock required</string>
- </property>
- <layout class="QVBoxLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <layout class="QGridLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <item row="0" column="1">
- <widget class="QLabel" name="title">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>10</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="font">
- <font>
- <pointsize>9</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>SIM PIN unlock required</string>
- </property>
- <property name="textFormat">
- <enum>Qt::RichText</enum>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="prompt">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>10</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="font">
- <font>
- <pointsize>9</pointsize>
- <weight>50</weight>
- <bold>false</bold>
- </font>
- </property>
- <property name="text">
- <string>The mobile broadband device '%1' requires a SIM PIN code before it can be used.</string>
- </property>
- <property name="textFormat">
- <enum>Qt::RichText</enum>
- </property>
- <property name="alignment">
- <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>400</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="KTitleWidget" name="errorMessage"/>
- </item>
- <item>
- <layout class="QFormLayout" name="formLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="pukLabel">
- <property name="text">
- <string>PUK code:</string>
- </property>
- <property name="buddy">
- <cstring>puk</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="puk">
- <property name="showClearButton" stdset="0">
- <bool>true</bool>
- </property>
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="pinLabel">
- <property name="text">
- <string>New PIN code:</string>
- </property>
- <property name="buddy">
- <cstring>pin</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="pin">
- <property name="showClearButton" stdset="0">
- <bool>true</bool>
- </property>
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="pin2Label">
- <property name="text">
- <string>Re-enter PIN code:</string>
- </property>
- <property name="buddy">
- <cstring>pin2</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KLineEdit" name="pin2">
- <property name="showClearButton" stdset="0">
- <bool>true</bool>
- </property>
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QCheckBox" name="chkShowPass">
- <property name="text">
- <string>Show PIN/PUK code</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KTitleWidget</class>
- <extends>QWidget</extends>
- <header>ktitlewidget.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>puk</tabstop>
- <tabstop>pin</tabstop>
- <tabstop>pin2</tabstop>
- <tabstop>chkShowPass</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 by Daniel Nicoletti <dantti12@gmail.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "secretagent.h"
-#include "passworddialog.h"
-
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/ConnectionSettings>
-#include <NetworkManagerQt/GenericTypes>
-#include <NetworkManagerQt/GsmSetting>
-#include <NetworkManagerQt/Security8021xSetting>
-#include <NetworkManagerQt/VpnSetting>
-#include <NetworkManagerQt/WirelessSecuritySetting>
-#include <NetworkManagerQt/WirelessSetting>
-
-#include <QStringBuilder>
-
-#include <KPluginFactory>
-#include <KWindowSystem>
-#include <KDialog>
-#include <KDebug>
-#include <KConfig>
-#include <KConfigGroup>
-#include <KWallet/Wallet>
-#include <QDebug>
-
-SecretAgent::SecretAgent(QObject* parent)
- : NetworkManager::SecretAgent("org.kde.networkmanagement", parent)
- , m_openWalletFailed(false)
- , m_wallet(0)
- , m_dialog(0)
-{
- connect(NetworkManager::notifier(), SIGNAL(serviceDisappeared()),
- this, SLOT(killDialogs()));
-
- // We have to import secrets previously stored in plaintext files
- importSecretsFromPlainTextFiles();
-}
-
-SecretAgent::~SecretAgent()
-{
-}
-
-NMVariantMapMap SecretAgent::GetSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path, const QString &setting_name,
- const QStringList &hints, uint flags)
-{
- qDebug() << Q_FUNC_INFO;
- qDebug() << "Path:" << connection_path.path();
- qDebug() << "Setting name:" << setting_name;
- qDebug() << "Hints:" << hints;
- qDebug() << "Flags:" << flags;
-
- QString callId = connection_path.path() % setting_name;
- foreach (const SecretsRequest & request, m_calls) {
- if (request == callId) {
- kWarning() << "GetSecrets was called again! This should not happen, cancelling first call" << connection_path.path() << setting_name;
- CancelGetSecrets(connection_path, setting_name);
- break;
- }
- }
-
- setDelayedReply(true);
- SecretsRequest request(SecretsRequest::GetSecrets);
- request.callId = callId;
- request.connection = connection;
- request.connection_path = connection_path;
- request.flags = static_cast<NetworkManager::SecretAgent::GetSecretsFlags>(flags);
- request.hints = hints;
- request.setting_name = setting_name;
- request.message = message();
- m_calls << request;
-
- processNext();
-
- return NMVariantMapMap();
-}
-
-void SecretAgent::SaveSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path)
-{
- kDebug() << connection_path.path();
-
- setDelayedReply(true);
- SecretsRequest::Type type;
- if (hasSecrets(connection)) {
- type = SecretsRequest::SaveSecrets;
- } else {
- type = SecretsRequest::DeleteSecrets;
- }
- SecretsRequest request(type);
- request.connection = connection;
- request.connection_path = connection_path;
- request.message = message();
- m_calls << request;
-
- processNext();
-}
-
-void SecretAgent::DeleteSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path)
-{
- kDebug() << connection_path.path();
-
- setDelayedReply(true);
- SecretsRequest request(SecretsRequest::DeleteSecrets);
- request.connection = connection;
- request.connection_path = connection_path;
- request.message = message();
- m_calls << request;
-
- processNext();
-}
-
-void SecretAgent::CancelGetSecrets(const QDBusObjectPath &connection_path, const QString &setting_name)
-{
- kDebug() << connection_path.path() << setting_name;
- QString callId = connection_path.path() % setting_name;
- for (int i = 0; i < m_calls.size(); ++i) {
- SecretsRequest request = m_calls.at(i);
- if (request.type == SecretsRequest::GetSecrets && callId == request.callId) {
- if (m_dialog == request.dialog) {
- m_dialog = 0;
- }
- delete request.dialog;
- sendError(SecretAgent::AgentCanceled,
- QLatin1String("Agent canceled the password dialog"),
- request.message);
- m_calls.removeAt(i);
- break;
- }
- }
-
- processNext();
-}
-
-void SecretAgent::dialogAccepted()
-{
- for (int i = 0; i < m_calls.size(); ++i) {
- SecretsRequest request = m_calls[i];
- if (request.type == SecretsRequest::GetSecrets && request.dialog == m_dialog) {
- NMStringMap tmpOpenconnectSecrets;
- NMVariantMapMap connection = request.dialog->secrets();
- if (connection.contains(QLatin1String("vpn"))) {
- if (connection.value(QLatin1String("vpn")).contains(QLatin1String("tmp-secrets"))) {
- QVariantMap vpnSetting = connection.value(QLatin1String("vpn"));
- tmpOpenconnectSecrets = qdbus_cast<NMStringMap>(vpnSetting.take(QLatin1String("tmp-secrets")));
- connection.insert(QLatin1String("vpn"), vpnSetting);
- }
- }
-
- sendSecrets(connection, request.message);
- NetworkManager::ConnectionSettings::Ptr connectionSettings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(connection));
- NetworkManager::ConnectionSettings::Ptr completeConnectionSettings;
- NetworkManager::Connection::Ptr con = NetworkManager::findConnectionByUuid(connectionSettings->uuid());
- if (con) {
- completeConnectionSettings = con->settings();
- } else {
- completeConnectionSettings = connectionSettings;
- }
- if (request.saveSecretsWithoutReply && completeConnectionSettings->connectionType() != NetworkManager::ConnectionSettings::Vpn) {
- bool requestOffline = true;
- if (completeConnectionSettings->connectionType() == NetworkManager::ConnectionSettings::Gsm) {
- NetworkManager::GsmSetting::Ptr gsmSetting = completeConnectionSettings->setting(NetworkManager::Setting::Gsm).staticCast<NetworkManager::GsmSetting>();
- if (gsmSetting) {
- if (gsmSetting->passwordFlags().testFlag(NetworkManager::Setting::NotSaved) ||
- gsmSetting->passwordFlags().testFlag(NetworkManager::Setting::NotRequired)) {
- requestOffline = false;
- } else if (gsmSetting->pinFlags().testFlag(NetworkManager::Setting::NotSaved) ||
- gsmSetting->pinFlags().testFlag(NetworkManager::Setting::NotRequired)) {
- requestOffline = false;
- }
- }
- } else if (completeConnectionSettings->connectionType() == NetworkManager::ConnectionSettings::Wireless) {
- NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting = completeConnectionSettings->setting(NetworkManager::Setting::WirelessSecurity).staticCast<NetworkManager::WirelessSecuritySetting>();
- if (wirelessSecuritySetting && wirelessSecuritySetting->keyMgmt() == NetworkManager::WirelessSecuritySetting::WpaEap) {
- NetworkManager::Security8021xSetting::Ptr security8021xSetting = completeConnectionSettings->setting(NetworkManager::Setting::Security8021x).staticCast<NetworkManager::Security8021xSetting>();
- if (security8021xSetting) {
- if (security8021xSetting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethodFast) ||
- security8021xSetting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethodTtls) ||
- security8021xSetting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethodPeap)) {
- if (security8021xSetting->passwordFlags().testFlag(NetworkManager::Setting::NotSaved) ||
- security8021xSetting->passwordFlags().testFlag(NetworkManager::Setting::NotRequired)) {
- requestOffline = false;
- }
- }
- }
- }
- }
-
- if (requestOffline) {
- SecretsRequest requestOffline(SecretsRequest::SaveSecrets);
- requestOffline.connection = connection;
- requestOffline.connection_path = request.connection_path;
- requestOffline.saveSecretsWithoutReply = true;
- m_calls << requestOffline;
- }
- } else if (request.saveSecretsWithoutReply && completeConnectionSettings->connectionType() == NetworkManager::ConnectionSettings::Vpn && !tmpOpenconnectSecrets.isEmpty()) {
- NetworkManager::VpnSetting::Ptr vpnSetting = completeConnectionSettings->setting(NetworkManager::Setting::Vpn).staticCast<NetworkManager::VpnSetting>();
- if (vpnSetting) {
- NMStringMap data = vpnSetting->data();
- NMStringMap secrets = vpnSetting->secrets();
-
- // Load secrets from auth dialog which are returned back to NM
- if (connection.value(QLatin1String("vpn")).contains(QLatin1String("secrets"))) {
- secrets.unite(qdbus_cast<NMStringMap>(connection.value(QLatin1String("vpn")).value(QLatin1String("secrets"))));
- }
-
- // Load temporary secrets from auth dialog which are not returned to NM
- foreach (const QString &key, tmpOpenconnectSecrets.keys()) {
- if (secrets.contains(QLatin1String("save_passwords")) && secrets.value(QLatin1String("save_passwords")) == QLatin1String("yes")) {
- data.insert(key + QLatin1String("-flags"), QString::number(NetworkManager::Setting::AgentOwned));
- } else {
- data.insert(key + QLatin1String("-flags"), QString::number(NetworkManager::Setting::NotSaved));
- }
-
- secrets.insert(key, tmpOpenconnectSecrets.value(key));
- }
-
- vpnSetting->setData(data);
- vpnSetting->setSecrets(secrets);
- if (!con) {
- con = NetworkManager::findConnection(request.connection_path.path());
- }
-
- if (con) {
- con->update(completeConnectionSettings->toMap());
- }
- }
- }
-
- m_calls.removeAt(i);
- break;
- }
- }
-
- m_dialog->deleteLater();
- m_dialog = 0;
-
- processNext();
-}
-
-void SecretAgent::dialogRejected()
-{
- for (int i = 0; i < m_calls.size(); ++i) {
- SecretsRequest request = m_calls[i];
- if (request.type == SecretsRequest::GetSecrets && request.dialog == m_dialog) {
- sendError(SecretAgent::UserCanceled,
- QLatin1String("User canceled the password dialog"),
- request.message);
- m_calls.removeAt(i);
- break;
- }
- }
-
- m_dialog->deleteLater();
- m_dialog = 0;
-
- processNext();
-}
-
-void SecretAgent::killDialogs()
-{
- int i = 0;
- while (i < m_calls.size()) {
- SecretsRequest request = m_calls[i];
- if (request.type == SecretsRequest::GetSecrets) {
- delete request.dialog;
- m_calls.removeAt(i);
- }
-
- ++i;
- }
-}
-
-void SecretAgent::walletOpened(bool success)
-{
- if (!success) {
- m_openWalletFailed = true;
- m_wallet->deleteLater();
- m_wallet = 0;
- } else {
- m_openWalletFailed = false;
- }
-
- processNext();
-}
-
-void SecretAgent::walletClosed()
-{
- if (m_wallet) {
- m_wallet->deleteLater();
- }
- m_wallet = 0;
-}
-
-void SecretAgent::processNext()
-{
- int i = 0;
- while (i < m_calls.size()) {
- SecretsRequest &request = m_calls[i];
- switch (request.type) {
- case SecretsRequest::GetSecrets:
- if (processGetSecrets(request)) {
- m_calls.removeAt(i);
- continue;
- }
- break;
- case SecretsRequest::SaveSecrets:
- if (processSaveSecrets(request)) {
- m_calls.removeAt(i);
- continue;
- }
- break;
- case SecretsRequest::DeleteSecrets:
- if (processDeleteSecrets(request)) {
- m_calls.removeAt(i);
- continue;
- }
- break;
- }
- ++i;
- }
-}
-
-bool SecretAgent::processGetSecrets(SecretsRequest &request) const
-{
- if (m_dialog) {
- return false;
- }
-
- NetworkManager::ConnectionSettings connectionSettings(request.connection);
-
- NetworkManager::Setting::Ptr setting = connectionSettings.setting(request.setting_name);
-
- const bool requestNew = request.flags & RequestNew;
- const bool userRequested = request.flags & UserRequested;
- const bool allowInteraction = request.flags & AllowInteraction;
- const bool isVpn = (setting->type() == NetworkManager::Setting::Vpn);
-
- NMStringMap secretsMap;
- if (!requestNew && useWallet()) {
- if (m_wallet->isOpen()) {
- if (m_wallet->hasFolder("Network Management") && m_wallet->setFolder("Network Management")) {
- QString key = QLatin1Char('{') % connectionSettings.uuid() % QLatin1Char('}') % QLatin1Char(';') % request.setting_name;
- m_wallet->readMap(key, secretsMap);
- }
- } else {
- kDebug() << "Waiting for the wallet to open";
- return false;
- }
- }
-
- if (!secretsMap.isEmpty()) {
- setting->secretsFromStringMap(secretsMap);
- if (!isVpn && setting->needSecrets(requestNew).isEmpty()) {
- // Enough secrets were retrieved from storage
- request.connection[request.setting_name] = setting->secretsToMap();
- sendSecrets(request.connection, request.message);
- return true;
- }
- }
-
- if (requestNew || (allowInteraction && !setting->needSecrets(requestNew).isEmpty()) || (allowInteraction && userRequested) || (isVpn && allowInteraction)) {
- m_dialog = new PasswordDialog(request.connection, request.flags, request.setting_name);
- connect(m_dialog, SIGNAL(accepted()), this, SLOT(dialogAccepted()));
- connect(m_dialog, SIGNAL(rejected()), this, SLOT(dialogRejected()));
- if (isVpn) {
- m_dialog->setupVpnUi(connectionSettings);
- } else {
- m_dialog->setupGenericUi(connectionSettings);
- }
-
- if (m_dialog->hasError()) {
- sendError(m_dialog->error(),
- m_dialog->errorMessage(),
- request.message);
- delete m_dialog;
- m_dialog = 0;
- return true;
- } else {
- request.dialog = m_dialog;
- request.saveSecretsWithoutReply = !connectionSettings.permissions().isEmpty();
- m_dialog->show();
- KWindowSystem::setState(m_dialog->winId(), NET::KeepAbove);
- KWindowSystem::forceActiveWindow(m_dialog->winId());
- return false;
- }
- } else if (isVpn && userRequested) { // just return what we have
- NMVariantMapMap result;
- NetworkManager::VpnSetting::Ptr vpnSetting;
- vpnSetting = connectionSettings.setting(NetworkManager::Setting::Vpn).dynamicCast<NetworkManager::VpnSetting>();
- //FIXME workaround when NM is asking for secrets which should be system-stored, if we send an empty map it
- // won't ask for additional secrets with AllowInteraction flag which would display the authentication dialog
- if (vpnSetting->secretsToMap().isEmpty()) {
- // Insert an empty secrets map as it was before I fixed it in NetworkManagerQt to make sure NM will ask again
- // with flags we need
- QVariantMap secretsMap;
- secretsMap.insert(QLatin1String("secrets"), QVariant::fromValue<NMStringMap>(NMStringMap()));
- result.insert("vpn", secretsMap);
- } else {
- result.insert("vpn", vpnSetting->secretsToMap());
- }
- sendSecrets(result, request.message);
- return true;
- } else if (setting->needSecrets().isEmpty()) {
- NMVariantMapMap result;
- result.insert(setting->name(), setting->secretsToMap());
- sendSecrets(result, request.message);
- return true;
- } else {
- sendError(SecretAgent::InternalError,
- QLatin1String("Plasma-nm did not know how to handle the request"),
- request.message);
- return true;
- }
-}
-
-bool SecretAgent::processSaveSecrets(SecretsRequest &request) const
-{
- if (useWallet()) {
- if (m_wallet->isOpen()) {
- NetworkManager::ConnectionSettings connectionSettings(request.connection);
-
- if (!m_wallet->hasFolder("Network Management")) {
- m_wallet->createFolder("Network Management");
- }
-
- if (m_wallet->setFolder("Network Management")) {
- foreach (const NetworkManager::Setting::Ptr &setting, connectionSettings.settings()) {
- NMStringMap secretsMap = setting->secretsToStringMap();
-
- if (!secretsMap.isEmpty()) {
- QString entryName = QLatin1Char('{') % connectionSettings.uuid() % QLatin1Char('}') % QLatin1Char(';') % setting->name();
- m_wallet->writeMap(entryName, secretsMap);
- }
- }
- } else if (!request.saveSecretsWithoutReply) {
- sendError(SecretAgent::InternalError,
- QLatin1String("Could not store secrets in the wallet."),
- request.message);
- return true;
- }
- } else {
- kDebug() << "Waiting for the wallet to open";
- return false;
- }
- }
-
- if (!request.saveSecretsWithoutReply) {
- QDBusMessage reply = request.message.createReply();
- if (!QDBusConnection::systemBus().send(reply)) {
- kWarning() << "Failed put save secrets reply into the queue";
- }
- }
-
- return true;
-}
-
-bool SecretAgent::processDeleteSecrets(SecretsRequest &request) const
-{
- if (useWallet()) {
- if (m_wallet->isOpen()) {
- if (m_wallet->hasFolder("Network Management") && m_wallet->setFolder("Network Management")) {
- NetworkManager::ConnectionSettings connectionSettings(request.connection);
- foreach (const NetworkManager::Setting::Ptr &setting, connectionSettings.settings()) {
- QString entryName = QLatin1Char('{') % connectionSettings.uuid() % QLatin1Char('}') % QLatin1Char(';') % setting->name();
- foreach (const QString &entry, m_wallet->entryList()) {
- if (entry.startsWith(entryName)) {
- m_wallet->removeEntry(entryName);
- }
- }
- }
- }
- } else {
- kDebug() << "Waiting for the wallet to open";
- return false;
- }
- }
-
- QDBusMessage reply = request.message.createReply();
- if (!QDBusConnection::systemBus().send(reply)) {
- kWarning() << "Failed put delete secrets reply into the queue";
- }
-
- return true;
-}
-
-bool SecretAgent::useWallet() const
-{
- if (m_wallet) {
- return true;
- }
-
- /* If opening of KWallet failed before, we should not try to open it again and
- * we should return false instead */
- if (m_openWalletFailed) {
- m_openWalletFailed = false;
- return false;
- }
-
- if (KWallet::Wallet::isEnabled()) {
- m_wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0, KWallet::Wallet::Asynchronous);
- if (m_wallet) {
- connect(m_wallet, SIGNAL(walletOpened(bool)), this, SLOT(walletOpened(bool)));
- connect(m_wallet, SIGNAL(walletClosed()), this, SLOT(walletClosed()));
- return true;
- } else {
- kWarning() << "Error opening kwallet.";
- }
- } else if (m_wallet) {
- m_wallet->deleteLater();
- m_wallet = 0;
- }
-
- return false;
-}
-
-bool SecretAgent::hasSecrets(const NMVariantMapMap &connection) const
-{
- NetworkManager::ConnectionSettings connectionSettings(connection);
- foreach (const NetworkManager::Setting::Ptr &setting, connectionSettings.settings()) {
- if (!setting->secretsToMap().isEmpty()) {
- return true;
- }
- }
-
- return false;
-}
-
-void SecretAgent::sendSecrets(const NMVariantMapMap &secrets, const QDBusMessage &message) const
-{
- QDBusMessage reply;
- reply = message.createReply(QVariant::fromValue(secrets));
- if (!QDBusConnection::systemBus().send(reply)) {
- kWarning() << "Failed put the secret into the queue";
- }
-}
-
-void SecretAgent::importSecretsFromPlainTextFiles()
-{
- KConfig config(QLatin1String("plasma-networkmanagement"), KConfig::SimpleConfig);
-
- // No action is required when the list of secrets is empty
- if (!config.groupList().isEmpty()) {
- foreach (const QString &groupName, config.groupList()) {
- QString loadedUuid = groupName.split(';').first().remove('{').remove('}');
- QString loadedSettingType = groupName.split(';').last();
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(loadedUuid);
- if (connection) {
- NetworkManager::Setting::SecretFlags secretFlags = KWallet::Wallet::isEnabled() ? NetworkManager::Setting::AgentOwned : NetworkManager::Setting::None;
- QMap<QString, QString> secrets = config.entryMap(groupName);
- NMVariantMapMap settings = connection->settings()->toMap();
-
- foreach (const QString &setting, settings.keys()) {
- if (setting == QLatin1String("vpn")) {
- NetworkManager::VpnSetting::Ptr vpnSetting = connection->settings()->setting(NetworkManager::Setting::Vpn).staticCast<NetworkManager::VpnSetting>();
- if (vpnSetting) {
- // Add loaded secrets from the config file
- vpnSetting->secretsFromStringMap(secrets);
-
- NMStringMap vpnData = vpnSetting->data();
- // Reset flags, we can't save secrets to our secret agent when KWallet is not enabled, because
- // we dropped support for plaintext files, therefore they need to be stored to NetworkManager
- foreach (const QString &key, vpnData.keys()) {
- if (key.endsWith(QLatin1String("-flags"))) {
- vpnData.insert(key, QString::number((int)secretFlags));
- }
- }
-
- vpnSetting->setData(vpnData);
- settings.insert(setting, vpnSetting->toMap());
- connection->update(settings);
- }
- } else {
- if (setting == loadedSettingType) {
- QVariantMap tmpSetting = settings.value(setting);
- // Reset flags, we can't save secrets to our secret agent when KWallet is not enabled, because
- // we dropped support for plaintext files, therefore they need to be stored to NetworkManager
- foreach (const QString &key, tmpSetting.keys()) {
- if (key.endsWith(QLatin1String("-flags"))) {
- tmpSetting.insert(key, (int)secretFlags);
- }
- }
-
- // Add loaded secrets from the config file
- QMap<QString, QString>::const_iterator it = secrets.constBegin();
- QMap<QString, QString>::const_iterator end = secrets.constEnd();
- for (; it != end; ++it) {
- tmpSetting.insert(it.key(), it.value());
- }
-
- // Replace the old setting with the new one
- settings.insert(setting, tmpSetting);
- // Update the connection which re-saves secrets
- connection->update(settings);
- }
- }
- }
- }
-
- // Remove the group
- KConfigGroup group(&config, groupName);
- group.deleteGroup();
- }
- }
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 by Daniel Nicoletti <dantti12@gmail.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_SECRET_AGENT_H
-#define PLASMA_NM_SECRET_AGENT_H
-
-#include <NetworkManagerQt/SecretAgent>
-
-#include "plasmanm_export.h"
-
-namespace KWallet {
-class Wallet;
-}
-
-class PasswordDialog;
-class SecretsRequest {
-public:
- enum Type {
- GetSecrets,
- SaveSecrets,
- DeleteSecrets
- };
- explicit SecretsRequest(Type _type) :
- type(_type),
- flags(NetworkManager::SecretAgent::None),
- saveSecretsWithoutReply(false),
- dialog(0)
- {}
- inline bool operator==(const QString &other) const {
- return callId == other;
- }
- Type type;
- QString callId;
- NMVariantMapMap connection;
- QDBusObjectPath connection_path;
- QString setting_name;
- QStringList hints;
- NetworkManager::SecretAgent::GetSecretsFlags flags;
- /**
- * When a user connection is called on GetSecrets,
- * the secret agent is supposed to save the secrets
- * typed by user, when true proccessSaveSecrets
- * should skip the DBus reply.
- */
- bool saveSecretsWithoutReply;
- QDBusMessage message;
- PasswordDialog *dialog;
-};
-
-class PLASMA_NM_EXPORT SecretAgent : public NetworkManager::SecretAgent
-{
- Q_OBJECT
-public:
- explicit SecretAgent(QObject* parent = 0);
- virtual ~SecretAgent();
-
-public Q_SLOTS:
- virtual NMVariantMapMap GetSecrets(const NMVariantMapMap&, const QDBusObjectPath&, const QString&, const QStringList&, uint);
- virtual void SaveSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path);
- virtual void DeleteSecrets(const NMVariantMapMap &, const QDBusObjectPath &);
- virtual void CancelGetSecrets(const QDBusObjectPath &, const QString &);
-
-private Q_SLOTS:
- void dialogAccepted();
- void dialogRejected();
- void killDialogs();
- void walletOpened(bool success);
- void walletClosed();
-
-private:
- void processNext();
- /**
- * @brief processGetSecrets requests
- * @param request the request we are processing
- * @param ignoreWallet true if the code should avoid Wallet
- * nomally if it failed to open
- * @return true if the item was processed
- */
- bool processGetSecrets(SecretsRequest &request) const;
- bool processSaveSecrets(SecretsRequest &request) const;
- bool processDeleteSecrets(SecretsRequest &request) const;
- /**
- * @brief useWallet checks if the KWallet system is enabled
- * and tries to open it async.
- * @return return true if the method should use the wallet,
- * the caller MUST always check if the wallet is opened.
- */
- bool useWallet() const;
-
- /**
- * @brief hasSecrets verifies if the desired connection has secrets to store
- * @param connection map with or without secrets
- * @return true if the connection has secrets, false otherwise
- */
- bool hasSecrets(const NMVariantMapMap &connection) const;
- void sendSecrets(const NMVariantMapMap &secrets, const QDBusMessage &message) const;
-
- mutable bool m_openWalletFailed;
- mutable KWallet::Wallet *m_wallet;
- mutable PasswordDialog *m_dialog;
- QList<SecretsRequest> m_calls;
-
- void importSecretsFromPlainTextFiles();
-
-};
-
-#endif // PLASMA_NM_SECRET_AGENT_H
+++ /dev/null
-/*
- Copyright 2009 Dario Freddi <drf54321@gmail.com>
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2011-2012 Lamarque V. Souza <lamarque@kde.org>
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "service.h"
-
-#include <KPluginFactory>
-
-#include "secretagent.h"
-#include "notification.h"
-#if WITH_MODEMMANAGER_SUPPORT
-#include "modemmonitor.h"
-#endif
-#include "bluetoothmonitor.h"
-
-#include <QDBusMetaType>
-#include <QDBusServiceWatcher>
-#include <QDBusConnection>
-#include <QDBusConnectionInterface>
-#include <QDBusReply>
-
-K_PLUGIN_FACTORY(NetworkManagementServiceFactory, registerPlugin<NetworkManagementService>();)
-K_EXPORT_PLUGIN(NetworkManagementServiceFactory("networkmanagement", "plasmanetworkmanagement-kded"))
-
-class NetworkManagementServicePrivate
-{
-public:
- SecretAgent * agent;
- BluetoothMonitor * bluetoothMonitor;
-#if WITH_MODEMMANAGER_SUPPORT
- ModemMonitor * modemMonitor;
-#endif
- Notification * notification;
-};
-
-NetworkManagementService::NetworkManagementService(QObject * parent, const QVariantList&)
- : KDEDModule(parent), d_ptr(new NetworkManagementServicePrivate)
-{
- Q_D(NetworkManagementService);
-
- d->agent = 0;
- d->notification = 0;
-
-#if WITH_MODEMMANAGER_SUPPORT
- d->modemMonitor = 0;
-#endif
- d->bluetoothMonitor = 0;
-
- connect(this, SIGNAL(moduleRegistered(QDBusObjectPath)), this, SLOT(slotRegistered(QDBusObjectPath)));
-}
-
-NetworkManagementService::~NetworkManagementService()
-{
- delete d_ptr;
-}
-
-void NetworkManagementService::init()
-{
- Q_D(NetworkManagementService);
-
- if (!d->agent) {
- d->agent = new SecretAgent(this);
- }
-
- if (!d->notification) {
- d->notification = new Notification(this);
- }
-
-#if WITH_MODEMMANAGER_SUPPORT
- if (!d->modemMonitor) {
- d->modemMonitor = new ModemMonitor(this);
- }
-#endif
-
- if (!d->bluetoothMonitor) {
- d->bluetoothMonitor = new BluetoothMonitor(this);
- }
-}
-void NetworkManagementService::slotRegistered(const QDBusObjectPath &path)
-{
- if (path.path() == QLatin1String("/modules/networkmanagement")) {
- Q_EMIT registered();
- }
-}
-
-#include "moc_service.cpp"
+++ /dev/null
-/*
- Copyright 2009 Dario Freddi <drf54321@gmail.com>
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMANM_KDED_SERVICE_H
-#define PLASMANM_KDED_SERVICE_H
-
-#include <KDEDModule>
-
-#include "plasmanm_export.h"
-
-#include <QVariant>
-
-class NetworkManagementServicePrivate;
-
-class PLASMA_NM_EXPORT NetworkManagementService : public KDEDModule
-{
- Q_CLASSINFO("D-Bus Interface", "org.kde.plasmanetworkmanagement")
- Q_OBJECT
- Q_DECLARE_PRIVATE(NetworkManagementService)
-public:
- NetworkManagementService(QObject * parent, const QVariantList&);
- virtual ~NetworkManagementService();
-
-public Q_SLOTS:
- Q_SCRIPTABLE void init();
-
-Q_SIGNALS:
- Q_SCRIPTABLE void registered();
-
-private Q_SLOTS:
- void slotRegistered(const QDBusObjectPath &path);
-
-private:
- NetworkManagementServicePrivate * const d_ptr;
-};
-
-#endif // PLASMANM_KDED_SERVICE_H
+++ /dev/null
-set(plasmanetworkmanagement-internal_SRCS
- models/appletproxymodel.cpp
- models/editoridentitymodel.cpp
- models/editorproxymodel.cpp
- models/networkitemslist.cpp
- models/networkmodel.cpp
- models/networkmodelitem.cpp
-
- debug.cpp
- globalconfig.cpp
- handler.cpp
- uiutils.cpp
-)
-
-add_library(plasmanetworkmanagement-internal SHARED ${plasmanetworkmanagement-internal_SRCS})
-
-target_link_libraries(plasmanetworkmanagement-internal
- plasmanetworkmanagement-editor
- ${NETWORKMANAGERQT_LDFLAGS}
- ${MODEMMANAGERQT_LDFLAGS}
- ${KDE4_PLASMA_LIBS}
- ${KDE4_KDECORE_LIBS}
- ${KDE4_KDEUI_LIBS}
- ${QT_QTNETWORK_LIBRARY}
-)
-
-install(TARGETS plasmanetworkmanagement-internal ${INSTALL_TARGETS_DEFAULT_ARGS})
-
-add_subdirectory(declarative)
-add_subdirectory(editor)
+++ /dev/null
-/*
- Copyright 2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "debug.h"
-
-int debugArea()
-{
- static int area = KDebug::registerArea("Plasma-nm", false);
- return area;
-}
-
-int rawDataDebugArea()
-{
- static int rd_area = KDebug::registerArea("Plasma-nm (raw data)", false);
- return rd_area;
-}
+++ /dev/null
-/*
- Copyright 2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_DEBUG_H
-#define PLASMA_NM_DEBUG_H
-
-#include <KDebug>
-
-int debugArea();
-int rawDataDebugArea();
-
-#define nmDebug() kDebug(debugArea())
-#define nmWarning() kWarning(debugArea())
-#define nmRawDebug() kDebug(rawDataDebugArea())
-
-#endif // PLASMA_NM_DEBUG_H
+++ /dev/null
-include_directories(${PROJECT_SOURCE_DIR}/libs
- ${PROJECT_SOURCE_DIR}/libs/models)
-
-set(plasma_networkmanagement_qml_plugins_SRCS
- availabledevices.cpp
- connectionicon.cpp
- enabledconnections.cpp
- enums.cpp
- networkstatus.cpp
- trafficmonitor.cpp
- qmlplugins.cpp
-)
-
-add_library(plasmanetworkmanagementplugins SHARED ${plasma_networkmanagement_qml_plugins_SRCS})
-
-target_link_libraries(plasmanetworkmanagementplugins
- plasmanetworkmanagement-internal
- plasmanetworkmanagement-editor
- ${NETWORKMANAGERQT_LDFLAGS}
- ${MODEMMANAGERQT_LDFLAGS}
- ${KDE4_PLASMA_LIBS}
- ${KDE4_KDECORE_LIBS}
- ${KDE4_KDEUI_LIBS}
- ${QT_QTNETWORK_LIBRARY}
- ${QT_QTDECLARATIVE_LIBRARY})
-
-install(TARGETS plasmanetworkmanagementplugins DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/networkmanagement)
-install(FILES qmldir DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/networkmanagement)
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "availabledevices.h"
-
-#include <NetworkManagerQt/Manager>
-
-AvailableDevices::AvailableDevices(QObject* parent)
- : QObject(parent)
- , m_wiredDeviceAvailable(false)
- , m_wirelessDeviceAvailable(false)
- , m_wimaxDeviceAvailable(false)
- , m_modemDeviceAvailable(false)
- , m_bluetoothDeviceAvailable(false)
-{
- foreach (const NetworkManager::Device::Ptr& device, NetworkManager::networkInterfaces()) {
- if (device->type() == NetworkManager::Device::Modem) {
- m_modemDeviceAvailable = true;
- } else if (device->type() == NetworkManager::Device::Wifi) {
- m_wirelessDeviceAvailable = true;
- } else if (device->type() == NetworkManager::Device::Wimax) {
- m_wimaxDeviceAvailable = true;
- } else if (device->type() == NetworkManager::Device::Ethernet) {
- m_wiredDeviceAvailable = true;
- } else if (device->type() == NetworkManager::Device::Bluetooth) {
- m_bluetoothDeviceAvailable = true;
- }
- }
-
- connect(NetworkManager::notifier(), SIGNAL(deviceAdded(QString)),
- SLOT(deviceAdded(QString)));
- connect(NetworkManager::notifier(), SIGNAL(deviceRemoved(QString)),
- SLOT(deviceRemoved()));
-}
-
-AvailableDevices::~AvailableDevices()
-{
-}
-
-bool AvailableDevices::isWiredDeviceAvailable() const
-{
- return m_wiredDeviceAvailable;
-}
-
-bool AvailableDevices::isWirelessDeviceAvailable() const
-{
- return m_wirelessDeviceAvailable;
-}
-
-bool AvailableDevices::isWimaxDeviceAvailable() const
-{
- return m_wimaxDeviceAvailable;
-}
-
-bool AvailableDevices::isModemDeviceAvailable() const
-{
- return m_modemDeviceAvailable;
-}
-
-bool AvailableDevices::isBluetoothDeviceAvailable() const
-{
- return m_bluetoothDeviceAvailable;
-}
-
-void AvailableDevices::deviceAdded(const QString& dev)
-{
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(dev);
-
- if (device) {
- if (device->type() == NetworkManager::Device::Modem && !m_modemDeviceAvailable) {
- m_modemDeviceAvailable = true;
- Q_EMIT modemDeviceAvailableChanged(true);
- } else if (device->type() == NetworkManager::Device::Wifi && !m_wirelessDeviceAvailable) {
- m_wirelessDeviceAvailable = true;
- Q_EMIT wirelessDeviceAvailableChanged(true);
- } else if (device->type() == NetworkManager::Device::Wimax && !m_wimaxDeviceAvailable) {
- m_wimaxDeviceAvailable = true;
- Q_EMIT wimaxDeviceAvailableChanged(true);
- } else if (device->type() == NetworkManager::Device::Ethernet && !m_wiredDeviceAvailable) {
- m_wiredDeviceAvailable = true;
- Q_EMIT wiredDeviceAvailableChanged(true);
- } else if (device->type() == NetworkManager::Device::Bluetooth && !m_bluetoothDeviceAvailable) {
- m_bluetoothDeviceAvailable = true;
- Q_EMIT bluetoothDeviceAvailableChanged(true);
- }
- }
-}
-
-void AvailableDevices::deviceRemoved()
-{
- bool wired = false;
- bool wireless = false;
- bool wimax = false;
- bool modem = false;
- bool bluetooth = false;
-
- foreach (const NetworkManager::Device::Ptr& device, NetworkManager::networkInterfaces()) {
- if (device->type() == NetworkManager::Device::Modem) {
- modem = true;
- } else if (device->type() == NetworkManager::Device::Wifi) {
- wireless = true;
- } else if (device->type() == NetworkManager::Device::Wimax) {
- wimax = true;
- } else if (device->type() == NetworkManager::Device::Ethernet) {
- wired = true;
- } else if (device->type() == NetworkManager::Device::Bluetooth) {
- bluetooth = true;
- }
- }
-
- if (!wired && m_wiredDeviceAvailable) {
- m_wiredDeviceAvailable = false;
- Q_EMIT wiredDeviceAvailableChanged(false);
- }
-
- if (!wireless && m_wirelessDeviceAvailable) {
- m_wirelessDeviceAvailable = false;
- Q_EMIT wirelessDeviceAvailableChanged(false);
- }
-
- if (!wimax && m_wimaxDeviceAvailable) {
- m_wimaxDeviceAvailable = false;
- Q_EMIT wimaxDeviceAvailableChanged(false);
- }
-
- if (!modem && m_modemDeviceAvailable) {
- m_modemDeviceAvailable = false;
- Q_EMIT modemDeviceAvailableChanged(false);
- }
-
- if (!bluetooth && m_bluetoothDeviceAvailable) {
- m_bluetoothDeviceAvailable = false;
- Q_EMIT bluetoothDeviceAvailableChanged(false);
- }
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_AVAILABLE_DEVICES_H
-#define PLASMA_NM_AVAILABLE_DEVICES_H
-
-#include <QObject>
-
-#include <NetworkManagerQt/Device>
-
-class AvailableDevices : public QObject
-{
-/**
- * Return true when there is present wired device
- */
-Q_PROPERTY(bool wiredDeviceAvailable READ isWiredDeviceAvailable NOTIFY wiredDeviceAvailableChanged)
-/**
- * Return true when there is present wireless device
- */
-Q_PROPERTY(bool wirelessDeviceAvailable READ isWirelessDeviceAvailable NOTIFY wirelessDeviceAvailableChanged)
-/**
- * Return true when there is present wimax device
- */
-Q_PROPERTY(bool wimaxDeviceAvailable READ isWimaxDeviceAvailable NOTIFY wimaxDeviceAvailableChanged)
-/**
- * Return true when there is present modem device
- */
-Q_PROPERTY(bool modemDeviceAvailable READ isModemDeviceAvailable NOTIFY modemDeviceAvailableChanged)
-/**
- * Return true when there is present bluetooth device
- * Bluetooth device is visible for NetworkManager only when there is some Bluetooth connection
- */
-Q_PROPERTY(bool bluetoothDeviceAvailable READ isBluetoothDeviceAvailable NOTIFY bluetoothDeviceAvailableChanged)
-Q_OBJECT
-public:
- explicit AvailableDevices(QObject* parent = 0);
- virtual ~AvailableDevices();
-
-public Q_SLOTS:
- bool isWiredDeviceAvailable() const;
- bool isWirelessDeviceAvailable() const;
- bool isWimaxDeviceAvailable() const;
- bool isModemDeviceAvailable() const;
- bool isBluetoothDeviceAvailable() const;
-
-private Q_SLOTS:
- void deviceAdded(const QString& dev);
- void deviceRemoved();
-
-Q_SIGNALS:
- void wiredDeviceAvailableChanged(bool available);
- void wirelessDeviceAvailableChanged(bool available);
- void wimaxDeviceAvailableChanged(bool available);
- void modemDeviceAvailableChanged(bool available);
- void bluetoothDeviceAvailableChanged(bool available);
-
-private:
- bool m_wiredDeviceAvailable;
- bool m_wirelessDeviceAvailable;
- bool m_wimaxDeviceAvailable;
- bool m_modemDeviceAvailable;
- bool m_bluetoothDeviceAvailable;
-};
-
-#endif // PLASMA_NM_AVAILABLE_DEVICES_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "connectionicon.h"
-
-#include <NetworkManagerQt/BluetoothDevice>
-#include <NetworkManagerQt/Connection>
-#include <NetworkManagerQt/ConnectionSettings>
-#include <NetworkManagerQt/Device>
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/ModemDevice>
-#include <NetworkManagerQt/WiredDevice>
-#include <NetworkManagerQt/WirelessDevice>
-#include <NetworkManagerQt/WirelessSetting>
-
-ConnectionIcon::ConnectionIcon(QObject* parent)
- : QObject(parent)
- , m_signal(0)
- , m_wirelessNetwork(0)
- , m_connecting(false)
- , m_limited(false)
- , m_vpn(false)
-#if WITH_MODEMMANAGER_SUPPORT
- , m_modemNetwork(0)
-#endif
-{
- connect(NetworkManager::notifier(), SIGNAL(primaryConnectionChanged(QString)),
- SLOT(primaryConnectionChanged(QString)));
- connect(NetworkManager::notifier(), SIGNAL(activatingConnectionChanged(QString)),
- SLOT(activatingConnectionChanged(QString)));
- connect(NetworkManager::notifier(), SIGNAL(activeConnectionAdded(QString)),
- SLOT(activeConnectionAdded(QString)));
- connect(NetworkManager::notifier(), SIGNAL(connectivityChanged(NetworkManager::Connectivity)),
- SLOT(connectivityChanged()));
- connect(NetworkManager::notifier(), SIGNAL(deviceAdded(QString)),
- SLOT(deviceAdded(QString)));
- connect(NetworkManager::notifier(), SIGNAL(deviceRemoved(QString)),
- SLOT(deviceRemoved(QString)));
- connect(NetworkManager::notifier(), SIGNAL(networkingEnabledChanged(bool)),
- SLOT(networkingEnabledChanged(bool)));
- connect(NetworkManager::notifier(), SIGNAL(statusChanged(NetworkManager::Status)),
- SLOT(statusChanged(NetworkManager::Status)));
- connect(NetworkManager::notifier(), SIGNAL(wirelessEnabledChanged(bool)),
- SLOT(wirelessEnabledChanged(bool)));
- connect(NetworkManager::notifier(), SIGNAL(wirelessHardwareEnabledChanged(bool)),
- SLOT(wirelessEnabledChanged(bool)));
- connect(NetworkManager::notifier(), SIGNAL(wwanEnabledChanged(bool)),
- SLOT(wwanEnabledChanged(bool)));
- connect(NetworkManager::notifier(), SIGNAL(wwanHardwareEnabledChanged(bool)),
- SLOT(wwanEnabledChanged(bool)));
-
- foreach (NetworkManager::Device::Ptr device, NetworkManager::networkInterfaces()) {
- if (device->type() == NetworkManager::Device::Ethernet) {
- NetworkManager::WiredDevice::Ptr wiredDevice = device.staticCast<NetworkManager::WiredDevice>();
- if (wiredDevice) {
- connect(wiredDevice.data(), SIGNAL(carrierChanged(bool)),
- SLOT(carrierChanged(bool)));
- }
- } else if (device->type() == NetworkManager::Device::Wifi) {
- NetworkManager::WirelessDevice::Ptr wifiDevice = device.staticCast<NetworkManager::WirelessDevice>();
- if (wifiDevice) {
- connect(wifiDevice.data(), SIGNAL(availableConnectionAppeared(QString)),
- SLOT(wirelessNetworkAppeared(QString)));
- connect(wifiDevice.data(), SIGNAL(networkAppeared(QString)),
- SLOT(wirelessNetworkAppeared(QString)));
- }
- }
- }
-
- foreach (NetworkManager::ActiveConnection::Ptr activeConnection, NetworkManager::activeConnections()) {
- activeConnectionAdded(activeConnection->path());
- if (activeConnection->vpn()) {
- NetworkManager::VpnConnection::Ptr vpnConnection;
- vpnConnection = activeConnection.objectCast<NetworkManager::VpnConnection>();
- if (vpnConnection && vpnConnection->state() == NetworkManager::VpnConnection::Activated) {
- m_vpn = true;
- }
- }
- }
-
- connectivityChanged();
-}
-
-ConnectionIcon::~ConnectionIcon()
-{
-}
-
-bool ConnectionIcon::connecting() const
-{
- return m_connecting;
-}
-
-QString ConnectionIcon::connectionIcon() const
-{
- if (m_vpn && !m_connectionIcon.contains("available")) {
- return m_connectionIcon + "-locked";
- }
-
- if (m_limited && !m_connectionIcon.contains("available")) {
- return m_connectionIcon + "-limited";
- }
-
- return m_connectionIcon;
-}
-
-QString ConnectionIcon::connectionTooltipIcon() const
-{
- return m_connectionTooltipIcon;
-}
-
-void ConnectionIcon::activatingConnectionChanged(const QString& connection)
-{
- Q_UNUSED(connection);
- setIcons();
-}
-
-void ConnectionIcon::activeConnectionAdded(const QString &activeConnection)
-{
- NetworkManager::ActiveConnection::Ptr active = NetworkManager::findActiveConnection(activeConnection);
-
- if (active) {
- NetworkManager::VpnConnection::Ptr vpnConnection;
- if (active->vpn()) {
- vpnConnection = active.objectCast<NetworkManager::VpnConnection>();
- }
- if ((active->state() == NetworkManager::ActiveConnection::Activating) ||
- (vpnConnection && (vpnConnection->state() == NetworkManager::VpnConnection::Prepare ||
- vpnConnection->state() == NetworkManager::VpnConnection::NeedAuth ||
- vpnConnection->state() == NetworkManager::VpnConnection::Connecting ||
- vpnConnection->state() == NetworkManager::VpnConnection::GettingIpConfig))) {
- connect(active.data(), SIGNAL(destroyed(QObject*)),
- SLOT(activeConnectionDestroyed()));
- if (vpnConnection) {
- connect(vpnConnection.data(), SIGNAL(stateChanged(NetworkManager::VpnConnection::State,NetworkManager::VpnConnection::StateChangeReason)),
- SLOT(vpnConnectionStateChanged(NetworkManager::VpnConnection::State,NetworkManager::VpnConnection::StateChangeReason)), Qt::UniqueConnection);
- } else {
- connect(active.data(), SIGNAL(stateChanged(NetworkManager::ActiveConnection::State)),
- SLOT(activeConnectionStateChanged(NetworkManager::ActiveConnection::State)), Qt::UniqueConnection);
- }
- m_connecting = true;
- Q_EMIT connectingChanged(true);
- }
- }
-}
-
-void ConnectionIcon::activeConnectionStateChanged(NetworkManager::ActiveConnection::State state)
-{
- if (state == NetworkManager::ActiveConnection::Deactivated ||
- state == NetworkManager::ActiveConnection::Deactivating ||
- state == NetworkManager::ActiveConnection::Activated ||
- state == NetworkManager::ActiveConnection::Unknown) {
- m_connecting = false;
- Q_EMIT connectingChanged(false);
- }
-}
-
-void ConnectionIcon::activeConnectionDestroyed()
-{
- m_connecting = false;
- Q_EMIT connectingChanged(false);
-}
-
-void ConnectionIcon::carrierChanged(bool carrier)
-{
- Q_UNUSED(carrier);
- if (NetworkManager::status() == NetworkManager::Disconnected) {
- setDisconnectedIcon();
- }
-}
-
-void ConnectionIcon::connectivityChanged()
-{
- NetworkManager::Connectivity conn = NetworkManager::connectivity();
- m_limited = (conn == NetworkManager::Portal || conn == NetworkManager::Limited);
- setIcons();
-}
-
-void ConnectionIcon::deviceAdded(const QString& device)
-{
- NetworkManager::Device::Ptr dev = NetworkManager::findNetworkInterface(device);
-
- if (!dev) {
- return;
- }
-
- if (dev->type() == NetworkManager::Device::Ethernet) {
- NetworkManager::WiredDevice::Ptr wiredDev = dev.objectCast<NetworkManager::WiredDevice>();
- connect(wiredDev.data(), SIGNAL(carrierChanged(bool)),
- SLOT(carrierChanged(bool)));
- }
-}
-
-void ConnectionIcon::deviceRemoved(const QString& device)
-{
- Q_UNUSED(device);
-
- if (NetworkManager::status() == NetworkManager::Disconnected) {
- setDisconnectedIcon();
- }
-}
-
-#if WITH_MODEMMANAGER_SUPPORT
-void ConnectionIcon::modemNetworkRemoved()
-{
- m_modemNetwork.clear();
-}
-
-void ConnectionIcon::modemSignalChanged(uint signal)
-{
- int diff = m_signal - signal;
-
- if (diff >= 10 ||
- diff <= -10) {
- m_signal = signal;
-
- setIconForModem();
- }
-}
-#endif
-
-void ConnectionIcon::networkingEnabledChanged(bool enabled)
-{
- if (!enabled) {
- m_connectionIcon = "network-unavailable";
- Q_EMIT connectionIconChanged("network-unavailable");
- }
-}
-
-void ConnectionIcon::primaryConnectionChanged(const QString& connection)
-{
- if (!connection.isEmpty()) {
- setIcons();
- }
-}
-
-void ConnectionIcon::statusChanged(NetworkManager::Status status)
-{
- if (status == NetworkManager::Disconnected) {
- setDisconnectedIcon();
- }
-}
-
-void ConnectionIcon::vpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason)
-{
- Q_UNUSED(reason);
- if (state == NetworkManager::VpnConnection::Activated ||
- state == NetworkManager::VpnConnection::Failed ||
- state == NetworkManager::VpnConnection::Disconnected) {
- m_connecting = false;
- Q_EMIT connectingChanged(false);
- }
-
- if (state == NetworkManager::VpnConnection::Activated) {
- m_vpn = true;
- setIcons();
- } else if (state == NetworkManager::VpnConnection::Failed ||
- state == NetworkManager::VpnConnection::Disconnected) {
- m_vpn = false;
-
- foreach (const NetworkManager::ActiveConnection::Ptr activeConnection, NetworkManager::activeConnections()) {
- if (activeConnection->vpn()) {
- NetworkManager::VpnConnection::Ptr vpnConnection = activeConnection.objectCast<NetworkManager::VpnConnection>();
- if (vpnConnection && vpnConnection->state() == NetworkManager::VpnConnection::Activated) {
- m_vpn = true;
- }
- }
- }
-
- setIcons();
- }
-}
-
-void ConnectionIcon::wirelessEnabledChanged(bool enabled)
-{
- Q_UNUSED(enabled);
- if (NetworkManager::status() == NetworkManager::Disconnected) {
- setDisconnectedIcon();
- }
-}
-
-void ConnectionIcon::wirelessNetworkAppeared(const QString& network)
-{
- Q_UNUSED(network);
- if (NetworkManager::status() == NetworkManager::Disconnected) {
- setDisconnectedIcon();
- }
-}
-
-void ConnectionIcon::wwanEnabledChanged(bool enabled)
-{
- Q_UNUSED(enabled);
- if (NetworkManager::status() == NetworkManager::Disconnected) {
- setDisconnectedIcon();
- }
-}
-
-void ConnectionIcon::setIcons()
-{
- m_signal = 0;
-#if WITH_MODEMMANAGER_SUPPORT
- if (m_modemNetwork) {
- disconnect(m_modemNetwork.data(), 0, this, 0);
- m_modemNetwork.clear();
- }
-#endif
- if (m_wirelessNetwork) {
- disconnect(m_wirelessNetwork.data(), 0, this, 0);
- m_wirelessNetwork.clear();
- }
-
- NetworkManager::ActiveConnection::Ptr connection = NetworkManager::activatingConnection();
- if (!connection) {
- connection = NetworkManager::primaryConnection();
- }
-
- // Workaround, because PrimaryConnection is kinda broken in NM 0.9.8.x and
- // doesn't work correctly with some VPN connections. This shouldn't be necessary
- // for NM 0.9.9.0 or the upcoming bugfix release NM 0.9.8.10
-#if !NM_CHECK_VERSION(0, 9, 10)
- if (!connection) {
- bool defaultRoute = false;
- NetworkManager::ActiveConnection::Ptr mainActiveConnection;
- Q_FOREACH (const NetworkManager::ActiveConnection::Ptr & activeConnection, NetworkManager::activeConnections()) {
- if ((activeConnection->default4() || activeConnection->default6()) && activeConnection->vpn()) {
- defaultRoute = true;
- mainActiveConnection = activeConnection;
- break;
- }
- }
-
- if (!defaultRoute) {
- Q_FOREACH (const NetworkManager::ActiveConnection::Ptr & activeConnection, NetworkManager::activeConnections()) {
- if (activeConnection->vpn()) {
- mainActiveConnection = activeConnection;
- break;
- }
- }
- }
-
- if (mainActiveConnection) {
- NetworkManager::ActiveConnection::Ptr baseActiveConnection;
- baseActiveConnection = NetworkManager::findActiveConnection(mainActiveConnection->specificObject());
- if (baseActiveConnection) {
- connection = baseActiveConnection;
- }
- }
- }
-#endif
-
- if (connection && !connection->devices().isEmpty()) {
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(connection->devices().first());
-
- if (device) {
- NetworkManager::Device::Type type = device->type();
- if (type == NetworkManager::Device::Wifi) {
- NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
- if (wifiDevice->mode() == NetworkManager::WirelessDevice::Adhoc) {
- setWirelessIconForSignalStrength(100);
- } else {
- NetworkManager::AccessPoint::Ptr ap = wifiDevice->activeAccessPoint();
- if (ap) {
- setWirelessIcon(device, ap->ssid());
- }
- }
- } else if (type == NetworkManager::Device::Ethernet) {
- m_connectionIcon = "network-wired-activated";
- m_connectionTooltipIcon = "network-wired-activated";
- Q_EMIT connectionIconChanged("network-wired-activated");
- Q_EMIT connectionTooltipIconChanged("network-wired-activated");
- } else if (type == NetworkManager::Device::Modem) {
-#if WITH_MODEMMANAGER_SUPPORT
- setModemIcon(device);
-#else
- m_connectionIcon = "network-mobile-0";
- m_connectionTooltipIcon = "phone";
- Q_EMIT connectionIconChanged("network-mobile-0");
- Q_EMIT connectionTooltipIconChanged("phone");
-#endif
- } else if (type == NetworkManager::Device::Bluetooth) {
- NetworkManager::BluetoothDevice::Ptr btDevice = device.objectCast<NetworkManager::BluetoothDevice>();
- if (btDevice) {
- if (btDevice->bluetoothCapabilities().testFlag(NetworkManager::BluetoothDevice::Dun)) {
-#if WITH_MODEMMANAGER_SUPPORT
- setModemIcon(device);
-#else
- m_connectionIcon = "network-mobile-0";
- m_connectionTooltipIcon = "phone";
- Q_EMIT connectionIconChanged("network-mobile-0");
- Q_EMIT connectionTooltipIconChanged("phone");
-#endif
- } else {
- m_connectionIcon = "network-bluetooth-activated";
- m_connectionTooltipIcon = "preferences-system-bluetooth";
- Q_EMIT connectionIconChanged("network-bluetooth-activated");
- Q_EMIT connectionTooltipIconChanged("preferences-system-bluetooth");
- }
- }
- } else {
- m_connectionIcon = "network-wired-activated";
- m_connectionTooltipIcon = "network-wired-activated";
- Q_EMIT connectionIconChanged("network-wired-activated");
- Q_EMIT connectionTooltipIconChanged("network-wired-activated");
- }
- }
- } else {
- setDisconnectedIcon();
- }
-}
-
-void ConnectionIcon::setDisconnectedIcon()
-{
- if (NetworkManager::status() == NetworkManager::Unknown ||
- NetworkManager::status() == NetworkManager::Asleep) {
- m_connectionIcon = "network-unavailable";
- Q_EMIT connectionIconChanged("network-unavailable");
- return;
- }
-
- bool wired = false;
- bool wireless = false;
- bool modem = false;
-
- m_limited = false;
- m_vpn = false;
-
- foreach (const NetworkManager::Device::Ptr &device, NetworkManager::networkInterfaces()) {
- if (device->type() == NetworkManager::Device::Ethernet) {
- NetworkManager::WiredDevice::Ptr wiredDev = device.objectCast<NetworkManager::WiredDevice>();
- if (wiredDev->carrier()) {
- wired = true;
- }
- } else if (device->type() == NetworkManager::Device::Wifi &&
- NetworkManager::isWirelessEnabled() &&
- NetworkManager::isWirelessHardwareEnabled()) {
- NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
- if (!wifiDevice->accessPoints().isEmpty() || !wifiDevice->availableConnections().isEmpty()) {
- wireless = true;
- }
- } else if (device->type() == NetworkManager::Device::Modem &&
- NetworkManager::isWwanEnabled() &&
- NetworkManager::isWwanHardwareEnabled()) {
- modem = true;
- }
- }
-
- if (wired) {
- m_connectionIcon = "network-wired-available";
- m_connectionTooltipIcon = "network-wired";
- Q_EMIT connectionIconChanged("network-wired-available");
- Q_EMIT connectionTooltipIconChanged("network-wired");
- return;
- } else if (wireless) {
- m_connectionIcon = "network-wireless-available";
- m_connectionTooltipIcon = "network-wireless-connected-00";
- Q_EMIT connectionIconChanged("network-wireless-available");
- Q_EMIT connectionTooltipIconChanged("network-wireless-connected-00");
- return;
- } else if (modem) {
- m_connectionIcon = "network-mobile-available";
- m_connectionTooltipIcon = "phone";
- Q_EMIT connectionIconChanged("network-mobile-available");
- Q_EMIT connectionTooltipIconChanged("phone");
- return;
- } else {
- m_connectionIcon = "network-unavailable";
- m_connectionTooltipIcon = "network-wired";
- Q_EMIT connectionIconChanged("network-unavailable");
- Q_EMIT connectionTooltipIconChanged("network-wired");
- }
-}
-
-#if WITH_MODEMMANAGER_SUPPORT
-void ConnectionIcon::setModemIcon(const NetworkManager::Device::Ptr & device)
-{
- NetworkManager::ModemDevice::Ptr modemDevice = device.objectCast<NetworkManager::ModemDevice>();
-
- if (!modemDevice) {
- m_connectionIcon = "network-mobile-100";
- Q_EMIT connectionIconChanged("network-mobile-100");
-
- return;
- }
-
- m_modemNetwork = modemDevice->getModemNetworkIface();
-
- if (m_modemNetwork) {
- connect(m_modemNetwork.data(), SIGNAL(signalQualityChanged(uint)),
- SLOT(modemSignalChanged(uint)), Qt::UniqueConnection);
- connect(m_modemNetwork.data(), SIGNAL(accessTechnologyChanged(ModemManager::Modem::AccessTechnologies)),
- SLOT(setIconForModem()), Qt::UniqueConnection);
- connect(m_modemNetwork.data(), SIGNAL(destroyed(QObject*)),
- SLOT(modemNetworkRemoved()));
-
- m_signal = m_modemNetwork->signalQuality().signal;
- setIconForModem();
- } else {
- m_connectionIcon = "network-mobile-0";
- Q_EMIT connectionIconChanged("network-mobile-0");
- m_connectionTooltipIcon = "phone";
- Q_EMIT connectionTooltipIconChanged("phone");
- return;
- }
-}
-
-void ConnectionIcon::setIconForModem()
-{
- if (!m_signal) {
- m_signal = m_modemNetwork->signalQuality().signal;
- }
- QString strength = "00";
-
- if (m_signal == 0) {
- strength = '0';
- } else if (m_signal < 20) {
- strength = "20";
- } else if (m_signal < 40) {
- strength = "40";
- } else if (m_signal < 60) {
- strength = "60";
- } else if (m_signal < 80) {
- strength = "80";
- } else {
- strength = "100";
- }
-
- QString result;
-
- switch(m_modemNetwork->accessTechnologies()) {
- case MM_MODEM_ACCESS_TECHNOLOGY_GSM:
- case MM_MODEM_ACCESS_TECHNOLOGY_GSM_COMPACT:
- result = "network-mobile-%1";
- break;
- case MM_MODEM_ACCESS_TECHNOLOGY_GPRS:
- result = "network-mobile-%1-gprs";
- break;
- case MM_MODEM_ACCESS_TECHNOLOGY_EDGE:
- result = "network-mobile-%1-edge";
- break;
- case MM_MODEM_ACCESS_TECHNOLOGY_UMTS:
- result = "network-mobile-%1-umts";
- break;
- case MM_MODEM_ACCESS_TECHNOLOGY_HSDPA:
- result = "network-mobile-%1-hsdpa";
- break;
- case MM_MODEM_ACCESS_TECHNOLOGY_HSUPA:
- result = "network-mobile-%1-hsupa";
- break;
- case MM_MODEM_ACCESS_TECHNOLOGY_HSPA:
- case MM_MODEM_ACCESS_TECHNOLOGY_HSPA_PLUS:
- result = "network-mobile-%1-hspa";
- break;
- case MM_MODEM_ACCESS_TECHNOLOGY_LTE:
- result = "network-mobile-%1-lte";
- break;
- default:
- result = "network-mobile-%1";
- break;
- }
-
- m_connectionIcon = QString(result).arg(strength);
- m_connectionTooltipIcon = "phone";
- Q_EMIT connectionIconChanged(QString(result).arg(strength));
- Q_EMIT connectionTooltipIconChanged("phone");
-}
-#endif
-
-void ConnectionIcon::setWirelessIcon(const NetworkManager::Device::Ptr &device, const QString& ssid)
-{
- NetworkManager::WirelessDevice::Ptr wirelessDevice = device.objectCast<NetworkManager::WirelessDevice>();
- if (device) {
- m_wirelessNetwork = wirelessDevice->findNetwork(ssid);
- } else {
- m_wirelessNetwork.clear();
- }
-
- if (m_wirelessNetwork) {
- connect(m_wirelessNetwork.data(), SIGNAL(signalStrengthChanged(int)),
- SLOT(setWirelessIconForSignalStrength(int)), Qt::UniqueConnection);
-
- setWirelessIconForSignalStrength(m_wirelessNetwork->signalStrength());
- } else {
- setDisconnectedIcon();
- }
-}
-
-void ConnectionIcon::setWirelessIconForSignalStrength(int strength)
-{
- int iconStrength = 100;
- if (strength == 0) {
- iconStrength = 0;
- m_connectionTooltipIcon = "network-wireless-connected-00";
- Q_EMIT connectionTooltipIconChanged("network-wireless-connected-00");
- } else if (strength < 20) {
- iconStrength = 20;
- m_connectionTooltipIcon = "network-wireless-connected-20";
- Q_EMIT connectionTooltipIconChanged("network-wireless-connected-20");
- } else if (strength < 40) {
- iconStrength = 40;
- m_connectionTooltipIcon = "network-wireless-connected-40";
- Q_EMIT connectionTooltipIconChanged("network-wireless-connected-40");
- } else if (strength < 60) {
- iconStrength = 60;
- m_connectionTooltipIcon = "network-wireless-connected-60";
- Q_EMIT connectionTooltipIconChanged("network-wireless-connected-60");
- } else if (strength < 80) {
- iconStrength = 80;
- m_connectionTooltipIcon = "network-wireless-connected-80";
- Q_EMIT connectionTooltipIconChanged("network-wireless-connected-80");
- } else if (strength < 100) {
- m_connectionTooltipIcon = "network-wireless-connected-100";
- Q_EMIT connectionTooltipIconChanged("network-wireless-connected-100");
- }
-
- QString icon = QString("network-wireless-%1").arg(iconStrength);
-
- m_connectionIcon = icon;
- Q_EMIT connectionIconChanged(icon);
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_CONNECTION_ICON_H
-#define PLASMA_NM_CONNECTION_ICON_H
-
-#include <config.h>
-
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/ActiveConnection>
-#include <NetworkManagerQt/VpnConnection>
-#include <NetworkManagerQt/WirelessNetwork>
-#if WITH_MODEMMANAGER_SUPPORT
-#include <ModemManagerQt/modem.h>
-#endif
-
-class ConnectionIcon : public QObject
-{
-Q_PROPERTY(bool connecting READ connecting NOTIFY connectingChanged)
-Q_PROPERTY(QString connectionIcon READ connectionIcon NOTIFY connectionIconChanged)
-Q_PROPERTY(QString connectionTooltipIcon READ connectionTooltipIcon NOTIFY connectionTooltipIconChanged)
-Q_OBJECT
-public:
- explicit ConnectionIcon(QObject* parent = 0);
- virtual ~ConnectionIcon();
-
- bool connecting() const;
- QString connectionIcon() const;
- QString connectionTooltipIcon() const;
-
-private Q_SLOTS:
- void activatingConnectionChanged(const QString & connection);
- void activeConnectionAdded(const QString & activeConnection);
- void activeConnectionDestroyed();
- void activeConnectionStateChanged(NetworkManager::ActiveConnection::State state);
- void carrierChanged(bool carrier);
- void connectivityChanged();
- void deviceAdded(const QString & device);
- void deviceRemoved(const QString & device);
- void networkingEnabledChanged(bool enabled);
- void primaryConnectionChanged(const QString & connection);
-#if WITH_MODEMMANAGER_SUPPORT
- void modemNetworkRemoved();
- void modemSignalChanged(uint signal);
- void setIconForModem();
-#endif
- void statusChanged(NetworkManager::Status status);
- void setWirelessIconForSignalStrength(int strength);
- void vpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason);
- void wirelessEnabledChanged(bool enabled);
- void wirelessNetworkAppeared(const QString &network);
- void wwanEnabledChanged(bool enabled);
-Q_SIGNALS:
- void connectingChanged(bool connecting);
- void connectionIconChanged(const QString & icon);
- void connectionTooltipIconChanged(const QString & icon);
-
-private:
- uint m_signal;
- NetworkManager::WirelessNetwork::Ptr m_wirelessNetwork;
-
- bool m_connecting;
- bool m_limited;
- bool m_vpn;
- QString m_connectionIcon;
- QString m_connectionTooltipIcon;
-
- void setDisconnectedIcon();
- void setIcons();
- void setWirelessIcon(const NetworkManager::Device::Ptr & device, const QString & ssid);
-#if WITH_MODEMMANAGER_SUPPORT
- ModemManager::Modem::Ptr m_modemNetwork;
- void setModemIcon(const NetworkManager::Device::Ptr & device);
-#endif
-};
-
-#endif // PLASMA_NM_CONNECTION_ICON_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#include "enabledconnections.h"
-
-#include <NetworkManagerQt/Manager>
-
-EnabledConnections::EnabledConnections(QObject* parent)
- : QObject(parent)
- , m_networkingEnabled(NetworkManager::isNetworkingEnabled())
- , m_wirelessEnabled(NetworkManager::isWirelessEnabled())
- , m_wirelessHwEnabled(NetworkManager::isWirelessHardwareEnabled())
- , m_wimaxEnabled(NetworkManager::isWimaxEnabled())
- , m_wimaxHwEnabled(NetworkManager::isWimaxHardwareEnabled())
- , m_wwanEnabled(NetworkManager::isWwanEnabled())
- , m_wwanHwEnabled(NetworkManager::isWwanHardwareEnabled())
-{
- connect(NetworkManager::notifier(), SIGNAL(networkingEnabledChanged(bool)),
- SLOT(onNetworkingEnabled(bool)));
- connect(NetworkManager::notifier(), SIGNAL(wirelessEnabledChanged(bool)),
- SLOT(onWirelessEnabled(bool)));
- connect(NetworkManager::notifier(), SIGNAL(wirelessHardwareEnabledChanged(bool)),
- SLOT(onWirelessHwEnabled(bool)));
- connect(NetworkManager::notifier(), SIGNAL(wimaxEnabledChanged(bool)),
- SLOT(onWimaxEnabled(bool)));
- connect(NetworkManager::notifier(), SIGNAL(wimaxHardwareEnabledChanged(bool)),
- SLOT(onWimaxHwEnabled(bool)));
- connect(NetworkManager::notifier(), SIGNAL(wwanEnabledChanged(bool)),
- SLOT(onWwanEnabled(bool)));
- connect(NetworkManager::notifier(), SIGNAL(wwanHardwareEnabledChanged(bool)),
- SLOT(onWwanHwEnabled(bool)));
-}
-
-EnabledConnections::~EnabledConnections()
-{
-}
-
-bool EnabledConnections::isNetworkingEnabled() const
-{
- return m_networkingEnabled;
-}
-
-bool EnabledConnections::isWirelessEnabled() const
-{
- return m_wirelessEnabled;
-}
-
-bool EnabledConnections::isWirelessHwEnabled() const
-{
- return m_wirelessHwEnabled;
-}
-
-bool EnabledConnections::isWimaxEnabled() const
-{
- return m_wimaxEnabled;
-}
-
-bool EnabledConnections::isWimaxHwEnabled() const
-{
- return m_wimaxHwEnabled;
-}
-
-bool EnabledConnections::isWwanEnabled() const
-{
- return m_wwanEnabled;
-}
-
-bool EnabledConnections::isWwanHwEnabled() const
-{
- return m_wwanHwEnabled;
-}
-
-void EnabledConnections::onNetworkingEnabled(bool enabled)
-{
- m_networkingEnabled = enabled;
- Q_EMIT networkingEnabled(enabled);
-}
-
-void EnabledConnections::onWirelessEnabled(bool enabled)
-{
- m_wirelessEnabled = enabled;
- Q_EMIT wirelessEnabled(enabled);
-}
-
-void EnabledConnections::onWirelessHwEnabled(bool enabled)
-{
- m_wirelessHwEnabled = enabled;
- Q_EMIT wirelessHwEnabled(enabled);
-}
-
-void EnabledConnections::onWimaxEnabled(bool enabled)
-{
- m_wimaxEnabled = enabled;
- Q_EMIT wimaxEnabled(enabled);
-}
-
-void EnabledConnections::onWimaxHwEnabled(bool enabled)
-{
- m_wimaxHwEnabled = enabled;
- Q_EMIT wimaxHwEnabled(enabled);
-}
-
-void EnabledConnections::onWwanEnabled(bool enabled)
-{
- m_wwanEnabled = enabled;
- Q_EMIT wwanEnabled(enabled);
-}
-
-void EnabledConnections::onWwanHwEnabled(bool enabled)
-{
- m_wwanHwEnabled = enabled;
- Q_EMIT wwanHwEnabled(enabled);
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_ENABLED_CONNECTIONS_H
-#define PLASMA_NM_ENABLED_CONNECTIONS_H
-
-#include <QObject>
-
-class EnabledConnections : public QObject
-{
-/**
- * Indicates if overall networking is currently enabled or not
- */
-Q_PROPERTY(bool networkingEnabled READ isNetworkingEnabled NOTIFY networkingEnabled)
-/**
- * Indicates if wireless is currently enabled or not
- */
-Q_PROPERTY(bool wirelessEnabled READ isWirelessEnabled NOTIFY wirelessEnabled)
-/**
- * Indicates if the wireless hardware is currently enabled, i.e. the state of the RF kill switch
- */
-Q_PROPERTY(bool wirelessHwEnabled READ isWirelessHwEnabled NOTIFY wirelessHwEnabled)
-/**
- * Indicates if WiMAX devices are currently enabled or not
- */
-Q_PROPERTY(bool wimaxEnabled READ isWimaxEnabled NOTIFY wimaxEnabled)
-/**
- * Indicates if the WiMAX hardware is currently enabled, i.e. the state of the RF kill switch.
- */
-Q_PROPERTY(bool wimaxHwEnabled READ isWimaxHwEnabled NOTIFY wimaxHwEnabled)
-/**
- * Indicates if mobile broadband devices are currently enabled or not.
- */
-Q_PROPERTY(bool wwanEnabled READ isWwanEnabled NOTIFY wwanEnabled)
-/**
- * Indicates if the mobile broadband hardware is currently enabled, i.e. the state of the RF kill switch.
- */
-Q_PROPERTY(bool wwanHwEnabled READ isWwanHwEnabled NOTIFY wwanHwEnabled)
-Q_OBJECT
-public:
- explicit EnabledConnections(QObject* parent = 0);
- virtual ~EnabledConnections();
-
- bool isNetworkingEnabled() const;
- bool isWirelessEnabled() const;
- bool isWirelessHwEnabled() const;
- bool isWimaxEnabled() const;
- bool isWimaxHwEnabled() const;
- bool isWwanEnabled() const;
- bool isWwanHwEnabled() const;
-
-public Q_SLOTS:
- void onNetworkingEnabled(bool enabled);
- void onWirelessEnabled(bool enabled);
- void onWirelessHwEnabled(bool enabled);
- void onWimaxEnabled(bool enabled);
- void onWimaxHwEnabled(bool enabled);
- void onWwanEnabled(bool enabled);
- void onWwanHwEnabled(bool enabled);
-
-Q_SIGNALS:
- void networkingEnabled(bool enabled);
- void wirelessEnabled(bool enabled);
- void wirelessHwEnabled(bool enabled);
- void wimaxEnabled(bool enabled);
- void wimaxHwEnabled(bool enabled);
- void wwanEnabled(bool enabled);
- void wwanHwEnabled(bool enabled);
-
-private:
- bool m_networkingEnabled;
- bool m_wirelessEnabled;
- bool m_wirelessHwEnabled;
- bool m_wimaxEnabled;
- bool m_wimaxHwEnabled;
- bool m_wwanEnabled;
- bool m_wwanHwEnabled;
-};
-
-#endif // PLASMA_NM_ENABLED_CONNECTIONS_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "enums.h"
-
-Enums::Enums(QObject* parent)
- : QObject(parent)
-{
-}
-
-Enums::~Enums()
-{
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_ENUMS_H
-#define PLASMA_NM_ENUMS_H
-
-#include <QObject>
-
-class Enums : public QObject
-{
-Q_OBJECT
-Q_ENUMS(ConnectionStatus)
-Q_ENUMS(ConnectionType)
-Q_ENUMS(FilterType)
-Q_ENUMS(SecurityType)
-
-public:
- explicit Enums(QObject* parent = 0);
- virtual ~Enums();
-
- enum ConnectionStatus {
- UnknownState = 0,
- Activating,
- Activated,
- Deactivating,
- Deactivated
- };
-
- enum ConnectionType {
- UnknownConnectionType = 0,
- Adsl,
- Bluetooth,
- Bond,
- Bridge,
- Cdma,
- Gsm,
- Infiniband,
- OLPCMesh,
- Pppoe,
- Vlan,
- Vpn,
- Wimax,
- Wired,
- Wireless
- };
-
- enum SecurityType {
- UnknownSecurity = -1,
- None = 0,
- StaticWep,
- DynamicWep,
- Leap,
- WpaPsk,
- WpaEap,
- Wpa2Psk,
- Wpa2Eap
- };
-};
-
-#endif // PLASMA_NM_ENUMS_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "networkstatus.h"
-#include "uiutils.h"
-
-#include <QDBusConnection>
-
-#include <NetworkManagerQt/ActiveConnection>
-#include <NetworkManagerQt/Connection>
-
-#include <KLocalizedString>
-
-NetworkStatus::NetworkStatus(QObject* parent)
- : QObject(parent)
-{
- connect(NetworkManager::notifier(), SIGNAL(statusChanged(NetworkManager::Status)),
- SLOT(statusChanged(NetworkManager::Status)));
- connect(NetworkManager::notifier(), SIGNAL(activeConnectionsChanged()),
- SLOT(activeConnectionsChanged()));
-
- activeConnectionsChanged();
- statusChanged(NetworkManager::status());
-}
-
-NetworkStatus::~NetworkStatus()
-{
-}
-
-QString NetworkStatus::activeConnections() const
-{
- return m_activeConnections;
-}
-
-QString NetworkStatus::networkStatus() const
-{
- return m_networkStatus;
-}
-
-void NetworkStatus::activeConnectionsChanged()
-{
- foreach (const NetworkManager::ActiveConnection::Ptr & active, NetworkManager::activeConnections()) {
- connect(active.data(), SIGNAL(default4Changed(bool)),
- SLOT(defaultChanged()), Qt::UniqueConnection);
- connect(active.data(), SIGNAL(default6Changed(bool)),
- SLOT(defaultChanged()), Qt::UniqueConnection);
- connect(active.data(), SIGNAL(stateChanged(NetworkManager::ActiveConnection::State)),
- SLOT(changeActiveConnections()));
- }
-
- changeActiveConnections();
-}
-
-void NetworkStatus::defaultChanged()
-{
- statusChanged(NetworkManager::status());
-}
-
-void NetworkStatus::statusChanged(NetworkManager::Status status)
-{
- switch (status) {
- case NetworkManager::ConnectedLinkLocal:
- m_networkStatus = i18nc("A network device is connected, but there is only link-local connectivity", "Connected");
- break;
- case NetworkManager::ConnectedSiteOnly:
- m_networkStatus = i18nc("A network device is connected, but there is only site-local connectivity", "Connected");
- break;
- case NetworkManager::Connected:
- m_networkStatus = i18nc("A network device is connected, with global network connectivity", "Connected");
- break;
- case NetworkManager::Asleep:
- m_networkStatus = i18nc("Networking is inactive and all devices are disabled", "Inactive");
- break;
- case NetworkManager::Disconnected:
- m_networkStatus = i18nc("There is no active network connection", "Disconnected");
- break;
- case NetworkManager::Disconnecting:
- m_networkStatus = i18nc("Network connections are being cleaned up", "Disconnecting");
- break;
- case NetworkManager::Connecting:
- m_networkStatus = i18nc("A network device is connecting to a network and there is no other available network connection", "Connecting");
- break;
- default:
- m_networkStatus = checkUnknownReason();
- break;
- }
-
- if (status == NetworkManager::ConnectedLinkLocal ||
- status == NetworkManager::ConnectedSiteOnly ||
- status == NetworkManager::Connected) {
- changeActiveConnections();
- } else {
- m_activeConnections = m_networkStatus;
- Q_EMIT activeConnectionsChanged(m_activeConnections);
- }
-
- Q_EMIT networkStatusChanged(m_networkStatus);
-}
-
-void NetworkStatus::changeActiveConnections()
-{
- if (NetworkManager::status() != NetworkManager::Connected &&
- NetworkManager::status() != NetworkManager::ConnectedLinkLocal &&
- NetworkManager::status() != NetworkManager::ConnectedSiteOnly) {
- return;
- }
-
- QString activeConnections = "<qt>";
- const QString format = "<b>%1 - %2</b><br>%3<br><br>";
- const QString formatDefault = "<b>%1 - %2</b><br><b>%3</b><br><br>";
-
- foreach (const NetworkManager::ActiveConnection::Ptr & active, NetworkManager::activeConnections()) {
- if (!active->devices().isEmpty()) {
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(active->devices().first());
-
-#if NM_CHECK_VERSION(0, 9, 10)
- if (device && ((device->type() >= NetworkManager::Device::Ethernet && device->type() <= NetworkManager::Device::Wifi) ||
- ((device->type() >= NetworkManager::Device::Bluetooth && device->type() <= NetworkManager::Device::Bridge)))) {
-#else
- if (device) {
-#endif
- QString devName;
- QString conType;
- QString status;
- if (device->ipInterfaceName().isEmpty()) {
- devName = device->interfaceName();
- } else {
- devName = device->ipInterfaceName();
- }
- if (active->vpn()) {
- conType = i18n("VPN Connection");
- } else {
- conType = UiUtils::interfaceTypeLabel(device->type(), device);
- }
- if (active->state() == NetworkManager::ActiveConnection::Activated) {
- status = i18n("Connected to %1", active->connection()->name());
- } else if (active->state() == NetworkManager::ActiveConnection::Activating) {
- status = i18n("Connecting to %1", active->connection()->name());
- }
- if (active->default4() || active->default6()) {
- activeConnections += QString(formatDefault).arg(devName, conType, status);
- } else {
- activeConnections += QString(format).arg(devName, conType, status);
- }
- }
- }
- }
-
- activeConnections += "</qt>";
- // Remove the last two new lines
- activeConnections.replace("<br><br></qt>", "</qt>");
-
- m_activeConnections = activeConnections;
- Q_EMIT activeConnectionsChanged(activeConnections);
-}
-
-QString NetworkStatus::checkUnknownReason() const
-{
- // Check if NetworkManager is running.
- if (!QDBusConnection::systemBus().interface()->isServiceRegistered(NM_DBUS_INTERFACE)) {
- return i18n("NetworkManager not running");
- }
-
- // Check for compatible NetworkManager version.
- if (NetworkManager::compareVersion(0, 9, 8) < 0) {
- return i18n("NetworkManager 0.9.8 required, found %1.", NetworkManager::version());
- }
-
- return i18nc("global connection state", "Unknown");
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_NETWORK_STATUS_H
-#define PLASMA_NM_NETWORK_STATUS_H
-
-#include <QObject>
-#include <QIcon>
-
-#include <NetworkManagerQt/Manager>
-
-class NetworkStatus : public QObject
-{
-/**
- * Returns a formated list of active connections or NM status when there is no active connection
- */
-Q_PROPERTY(QString activeConnections READ activeConnections NOTIFY activeConnectionsChanged)
-/**
- * Returns the current status of NetworkManager
- */
-Q_PROPERTY(QString networkStatus READ networkStatus NOTIFY networkStatusChanged)
-Q_OBJECT
-public:
- explicit NetworkStatus(QObject* parent = 0);
- virtual ~NetworkStatus();
-
- QString activeConnections() const;
- QString networkStatus() const;
-
-private Q_SLOTS:
- void activeConnectionsChanged();
- void defaultChanged();
- void statusChanged(NetworkManager::Status status);
- void changeActiveConnections();
-
-Q_SIGNALS:
- void activeConnectionsChanged(const QString & activeConnections);
- void networkStatusChanged(const QString & status);
-
-private:
- QString m_activeConnections;
- QString m_networkStatus;
-
- QString checkUnknownReason() const;
-};
-
-#endif // PLAMA_NM_NETWORK_STATUS_H
+++ /dev/null
-plugin plasmanetworkmanagementplugins
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "qmlplugins.h"
-
-#include <QtDeclarative>
-
-#include "availabledevices.h"
-#include "connectionicon.h"
-#include "enabledconnections.h"
-#include "globalconfig.h"
-#include "networkstatus.h"
-#include "trafficmonitor.h"
-
-#include "appletproxymodel.h"
-#include "networkmodel.h"
-
-#include "handler.h"
-#include "enums.h"
-
-void QmlPlugins::registerTypes(const char* uri)
-{
- // @uri org.kde.networkmanagement.AvailableDevices
- qmlRegisterType<AvailableDevices>(uri, 0, 1, "AvailableDevices");
- // @uri org.kde.networkmanagement.ConnectionIcon
- qmlRegisterType<ConnectionIcon>(uri, 0, 1, "ConnectionIcon");
- // @uri org.kde.networkmanagement.EnabledConnections
- qmlRegisterType<EnabledConnections>(uri, 0, 1, "EnabledConnections");
- // @uri org.kde.networkmanagement.Enums
- qmlRegisterUncreatableType<Enums>(uri, 0, 1, "Enums", "You cannot create Enums on yourself");
- // @uri org.kde.networkmanagement.GlobalConfig
- qmlRegisterType<GlobalConfig>(uri, 0, 1, "GlobalConfig");
- // @uri org.kde.networkmanagement.NetworkStatus
- qmlRegisterType<NetworkStatus>(uri, 0, 1, "NetworkStatus");
- // @uri org.kde.networkmanagement.Handler
- qmlRegisterType<Handler>(uri, 0, 1, "Handler");
- // @uri org.kde.networkmanagement.NetworkModel
- qmlRegisterType<NetworkModel>(uri, 0, 1, "NetworkModel");
- // @uri org.kde.networkmanagement.AppletProxyModel
- qmlRegisterType<AppletProxyModel>(uri, 0, 1, "AppletProxyModel");
- // @uri org.kde.networkmanagement.TrafficMonitor
- qmlRegisterType<TrafficMonitor>(uri, 0, 1, "TrafficMonitor");
-}
-
-Q_EXPORT_PLUGIN2(plasmanetworkmanagement, QmlPlugins)
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_QML_PLUGINS_H
-#define PLASMA_NM_QML_PLUGINS_H
-
-#include <QtDeclarative/QDeclarativeExtensionPlugin>
-
-class QmlPlugins : public QDeclarativeExtensionPlugin
-{
- public:
- virtual void registerTypes(const char * uri);
-};
-
-#endif // PLASMA_NM_QML_PLUGINS_H
+++ /dev/null
-/*
- Copyright 2010 Sebastian Kügler <sebas@kde.org>
- Copyright 2010-2013 Lamarque V. Souza <lamarque@kde.org>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "trafficmonitor.h"
-
-#include <Plasma/DataEngineManager>
-
-#include <QLabel>
-#include <QGraphicsLinearLayout>
-
-#include <KGlobalSettings>
-
-#include <NetworkManagerQt/Manager>
-
-#include "globalconfig.h"
-
-TrafficMonitor::TrafficMonitor(QGraphicsItem* parent)
- : QGraphicsWidget(parent, 0)
- , m_device(0)
- , m_updateEnabled(false)
-{
- QGraphicsLinearLayout * layout = new QGraphicsLinearLayout(this);
- layout->setOrientation(Qt::Vertical);
-
- m_txColor.setAlphaF(0.6);
- m_txColor = QColor("#0099FF");
- m_rxColor = QColor("#91FF00");
-
- m_trafficPlotter = new Plasma::SignalPlotter(this);
- m_trafficPlotter->setFont(KGlobalSettings::smallestReadableFont());
- m_trafficPlotter->addPlot(m_rxColor);
- m_trafficPlotter->addPlot(m_txColor);
- m_trafficPlotter->setThinFrame(true);
- m_trafficPlotter->setShowLabels(true);
- m_trafficPlotter->setShowTopBar(true);
- m_trafficPlotter->setShowVerticalLines(false);
- m_trafficPlotter->setShowHorizontalLines(true);
- m_trafficPlotter->setHorizontalLinesCount(2);
- m_trafficPlotter->setUseAutoRange(true);
- m_trafficPlotter->setSizePolicy(QSizePolicy::QSizePolicy::Expanding, QSizePolicy::QSizePolicy::Expanding);
- m_trafficPlotter->setMinimumHeight(100);
-
- layout->addItem(m_trafficPlotter);
-
- m_traffic = new Plasma::Label(this);
- m_traffic->setFont(KGlobalSettings::smallestReadableFont());
- m_traffic->nativeWidget()->setWordWrap(false);
- m_traffic->nativeWidget()->setTextInteractionFlags(Qt::TextSelectableByMouse);
-
- layout->addItem(m_traffic);
-
- setLayout(layout);
-
- Plasma::DataEngineManager::self()->loadEngine("systemmonitor");
-
- connect(m_traffic, SIGNAL(heightChanged()), this, SIGNAL(heightChanged()));
-}
-
-TrafficMonitor::~TrafficMonitor()
-{
-}
-
-void TrafficMonitor::setDevice(const QString& device)
-{
- if (m_device && m_device->uni() == device) {
- return;
- }
-
- if (device.isEmpty()) {
- resetMonitor();
- setUpdateEnabled(false);
- return;
- }
-
- m_device = NetworkManager::findNetworkInterface(device);
-
- if (!m_device) {
- resetMonitor();
- setUpdateEnabled(false);
- return;
- }
-
- QString interfaceName = m_device->ipInterfaceName();
- if (interfaceName.isEmpty()) {
- interfaceName = m_device->interfaceName();
- }
-
- m_rxSource = QString("network/interfaces/%1/receiver/data").arg(interfaceName);
- m_txSource = QString("network/interfaces/%1/transmitter/data").arg(interfaceName);
- m_rxTotalSource = QString("network/interfaces/%1/receiver/dataTotal").arg(interfaceName);
- m_txTotalSource = QString("network/interfaces/%1/transmitter/dataTotal").arg(interfaceName);
- m_rxTotal = m_txTotal = 0;
-
- Plasma::DataEngine * engine = Plasma::DataEngineManager::self()->engine("systemmonitor");
- if (engine->isValid() && engine->query(m_rxSource).empty()) {
- Plasma::DataEngineManager::self()->unloadEngine("systemmonitor");
- Plasma::DataEngineManager::self()->loadEngine("systemmonitor");
- }
-
- setUpdateEnabled(true);
-}
-
-QString TrafficMonitor::device() const
-{
- if (m_device)
- return m_device->uni();
-
- return QString();
-}
-
-qreal TrafficMonitor::height() const
-{
- return m_trafficPlotter->geometry().height() + m_traffic->geometry().height() + 5;
-}
-
-void TrafficMonitor::resetMonitor()
-{
- const QString format = "<b>%1:</b> %2";
- QString temp;
-
- temp = QString("<qt><table align=\"left\" border=\"0\"><tr><td align=\"right\" width=\"50%\">");
- temp += QString(format).arg(i18nc("traffic received empty", "Received")).arg("-");
- temp += QString("</td></tr><tr><td width=\"50%\"> ");
- temp += QString(format).arg(i18nc("traffic transmitted empty", "Transmitted")).arg("-");
- temp += QString("</td></tr></table></qt>");
- m_traffic->setText(temp);
-
- m_trafficPlotter->removePlot(0);
- m_trafficPlotter->removePlot(1);
- m_trafficPlotter->addPlot(m_rxColor);
- m_trafficPlotter->addPlot(m_txColor);
-}
-
-void TrafficMonitor::dataUpdated(const QString& sourceName, const Plasma::DataEngine::Data& data)
-{
- if (sourceName == m_txSource) {
- m_tx = data["value"].toString();
- m_txUnit = data["units"].toString();
- } else if (sourceName == m_rxSource) {
- m_rx = data["value"].toString();
- m_rxUnit = data["units"].toString();
- } else if (sourceName == m_rxTotalSource) {
- m_rxTotal = data["value"].toString().toLong();
- } else if (sourceName == m_txTotalSource) {
- m_txTotal = data["value"].toString().toLong();
- }
- updateTraffic();
-}
-
-void TrafficMonitor::setUpdateEnabled(bool enable)
-{
- Plasma::DataEngine * engine = Plasma::DataEngineManager::self()->engine("systemmonitor");
- if (engine->isValid()) {
- int interval = 2000;
- if (enable) {
- if (m_device) {
- engine->connectSource(m_rxSource, this, interval);
- engine->connectSource(m_txSource, this, interval);
- engine->connectSource(m_rxTotalSource, this, interval);
- engine->connectSource(m_txTotalSource, this, interval);
- }
- } else {
- engine->disconnectSource(m_rxSource, this);
- engine->disconnectSource(m_txSource, this);
- engine->disconnectSource(m_rxTotalSource, this);
- engine->disconnectSource(m_txTotalSource, this);
- }
- }
- m_updateEnabled = enable;
-}
-
-void TrafficMonitor::updateTraffic()
-{
- double _r;
- double _t;
- QString r, t;
- int precision = 0;
-
- if (GlobalConfig().networkSpeedUnit() == GlobalConfig::KBits) {
- _r = m_rx.toInt() << 3;
- _t = m_tx.toInt() << 3;
-
- if (_r < 1000) {
- m_rxUnit = i18n("KBit/s");
- } else if (_r < 1000000) {
- m_rxUnit = i18n("MBit/s");
- _r /= 1000;
- _t /= 1000;
- precision = 2;
- } else {
- m_rxUnit = i18n("GBit/s");
- _r /= 1000000;
- _t /= 1000000;
- precision = 2;
- }
-
- m_txUnit = m_rxUnit;
- r = QString("%1 %2").arg(QString::number(_r, 'f', precision), m_rxUnit);
- t = QString("%1 %2").arg(QString::number(_t, 'f', precision), m_txUnit);
- } else {
- _r = m_rx.toDouble();
- _t = m_tx.toDouble();
-
- r = KGlobal::locale()->formatByteSize(_r*1024);
- r.append("/s");
- t = KGlobal::locale()->formatByteSize(_t*1024);
- t.append("/s");
- }
-
- QList<double> v;
- v << _r << _t;
- m_trafficPlotter->addSample(v);
- m_trafficPlotter->setUnit(m_rxUnit);
-
- const QString s = i18nc("traffic, e.g. n KB/s\n m KB/s", "%1 %2", r, t);
- m_trafficPlotter->setTitle(s);
-
- const QString format = "<b>%1:</b> %2";
- QString temp;
-
- temp = QString("<qt><table align=\"left\" border=\"0\"><tr>");
- temp += QString("<td width=\"20pt\" bgcolor=\"%1\"> ").arg(m_rxColor.name());
- temp += QString("</td><td width=\"50%\">");
- temp += QString(format).arg(i18n("Received"), KGlobal::locale()->formatByteSize(m_rxTotal*1000, 2));
- temp += QString(" </td></tr><tr><td width=\"20pt\" bgcolor=\"%1\"> ").arg(m_txColor.name());
- temp += QString("</td><td width=\"50%\">");
- temp += QString(format).arg(i18n("Transmitted"), KGlobal::locale()->formatByteSize(m_txTotal*1000, 2));
- temp += QString("</td></tr></table></qt>");
- m_traffic->setText(temp);
-}
+++ /dev/null
-/*
- Copyright 2010 Sebastian Kügler <sebas@kde.org>
- Copyright 2010-2013 Lamarque V. Souza <lamarque@kde.org>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_TRAFFIC_MONITOR_H
-#define PLASMA_NM_TRAFFIC_MONITOR_H
-
-#include <QGraphicsWidget>
-
-#include <NetworkManagerQt/Device>
-#include <NetworkManagerQt/ModemDevice>
-
-#include <Plasma/DataEngine>
-#include <Plasma/SignalPlotter>
-#include <Plasma/Label>
-
-class TrafficMonitor : public QGraphicsWidget
-{
-Q_PROPERTY(QString device READ device WRITE setDevice)
-Q_PROPERTY(qreal height READ height NOTIFY heightChanged)
-Q_OBJECT
-public:
- explicit TrafficMonitor(QGraphicsItem * parent = 0);
- virtual ~TrafficMonitor();
-
- void setDevice(const QString & device);
- QString device() const;
-
- qreal height() const;
-
-public Q_SLOTS:
- void dataUpdated(const QString & sourceName, const Plasma::DataEngine::Data & data);
-
-private:
- void resetMonitor();
- void updateTraffic();
- void setUpdateEnabled(bool enable);
-
- NetworkManager::Device::Ptr m_device;
-
- Plasma::DataEngine * m_engine;
- Plasma::SignalPlotter *m_trafficPlotter;
- Plasma::Label * m_traffic;
-
- QString m_tx;
- QString m_txSource;
- QString m_txTotalSource;
- QString m_txUnit;
- QString m_rx;
- QString m_rxSource;
- QString m_rxTotalSource;
- QString m_rxUnit;
- QColor m_txColor;
- QColor m_rxColor;
- qlonglong m_txTotal;
- qlonglong m_rxTotal;
-
- bool m_updateEnabled;
- int m_speedUnit;
-
-Q_SIGNALS:
- void heightChanged();
-};
-
-#endif // PLASMA_NM_TRAFFIC_MONITOR_H
+++ /dev/null
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/widgets)
-
-set(plasmanetworkmanagement_libeditor_SRCS
- settings/bondwidget.cpp
- settings/bridgewidget.cpp
- settings/btwidget.cpp
- settings/cdmawidget.cpp
- settings/connectionwidget.cpp
- settings/gsmwidget.cpp
- settings/infinibandwidget.cpp
- settings/ipv4widget.cpp
- settings/ipv6widget.cpp
- settings/pppoewidget.cpp
- settings/pppwidget.cpp
- settings/security802-1x.cpp
- settings/vlanwidget.cpp
- settings/wificonnectionwidget.cpp
- settings/wifisecurity.cpp
- settings/wimaxwidget.cpp
- settings/wiredconnectionwidget.cpp
- settings/wiredsecurity.cpp
-
- widgets/advancedpermissionswidget.cpp
- widgets/bssidcombobox.cpp
- widgets/delegate.cpp
- widgets/hwaddrcombobox.cpp
- widgets/intdelegate.cpp
- widgets/ipv4delegate.cpp
- widgets/ipv4routeswidget.cpp
- widgets/ipv6delegate.cpp
- widgets/ipv6routeswidget.cpp
- widgets/settingwidget.cpp
- widgets/ssidcombobox.cpp
-
- connectiondetaileditor.cpp
- simpleipv4addressvalidator.cpp
- simpleipv6addressvalidator.cpp
- vpnuiplugin.cpp
-
- ../uiutils.cpp
-
- settings/802-1x.ui
- settings/bond.ui
- settings/bridge.ui
- settings/bt.ui
- settings/cdma.ui
- settings/connectionwidget.ui
- settings/gsm.ui
- settings/infiniband.ui
- settings/ipv4.ui
- settings/ipv6.ui
- settings/ppp.ui
- settings/pppoe.ui
- settings/vlan.ui
- settings/wificonnectionwidget.ui
- settings/wifisecurity.ui
- settings/wimax.ui
- settings/wiredconnectionwidget.ui
- settings/wiredsecurity.ui
-
- widgets/advancedpermissionswidget.ui
- widgets/ipv4routes.ui
- widgets/ipv6routes.ui
-
- connectiondetaileditor.ui
-)
-
-if (WITH_MODEMMANAGER_SUPPORT)
- set(plasmanetworkmanagement_libeditor_SRCS
- ${plasmanetworkmanagement_libeditor_SRCS}
- widgets/mobileconnectionwizard.cpp
- mobileproviders.cpp)
-endif()
-
-
-add_library(plasmanetworkmanagement-editor SHARED ${plasmanetworkmanagement_libeditor_SRCS})
-target_link_libraries(plasmanetworkmanagement-editor
- ${KDE4_KDEUI_LIBS}
- ${KDE4_KIO_LIBS}
- ${KDE4_SOLID_LIBS}
- ${QT_QTXML_LIBRARY}
- ${QT_QTNETWORK_LIBRARY}
- ${NETWORKMANAGERQT_LDFLAGS}
- ${MODEMMANAGERQT_LDFLAGS}
-)
-
-install(TARGETS plasmanetworkmanagement-editor ${INSTALL_TARGETS_DEFAULT_ARGS})
-install(FILES plasma-networkmanagement-vpnuiplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
-$XGETTEXT `find . -name "*.cpp"` -o $podir/libplasmanetworkmanagement-editor.pot
-rm -f rc.cpp
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
- Copyright 2013, 2014 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "connectiondetaileditor.h"
-#include "ui_connectiondetaileditor.h"
-
-#include "settings/bondwidget.h"
-#include "settings/bridgewidget.h"
-#include "settings/btwidget.h"
-#include "settings/cdmawidget.h"
-#include "settings/connectionwidget.h"
-#include "settings/gsmwidget.h"
-#include "settings/infinibandwidget.h"
-#include "settings/ipv4widget.h"
-#include "settings/ipv6widget.h"
-#include "settings/pppwidget.h"
-#include "settings/pppoewidget.h"
-#include "settings/vlanwidget.h"
-#include "settings/wimaxwidget.h"
-#include "settings/wiredsecurity.h"
-#include "settings/wiredconnectionwidget.h"
-#include "settings/wifisecurity.h"
-#include "settings/wificonnectionwidget.h"
-#include "vpn/openvpn/nm-openvpn-service.h"
-#include "vpnuiplugin.h"
-
-#include <NetworkManagerQt/ActiveConnection>
-#include <NetworkManagerQt/AdslSetting>
-#include <NetworkManagerQt/CdmaSetting>
-#include <NetworkManagerQt/Connection>
-#include <NetworkManagerQt/GenericTypes>
-#include <NetworkManagerQt/GsmSetting>
-#include <NetworkManagerQt/PppoeSetting>
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/Utils>
-#include <NetworkManagerQt/VpnSetting>
-#include <NetworkManagerQt/WirelessSetting>
-#include <NetworkManagerQt/WirelessDevice>
-
-#include <QDebug>
-
-#include <KUser>
-#include <KPluginFactory>
-#include <KServiceTypeTrader>
-#include <QPushButton>
-#include <KWallet/Wallet>
-
-using namespace NetworkManager;
-
-ConnectionDetailEditor::ConnectionDetailEditor(NetworkManager::ConnectionSettings::ConnectionType type, QWidget* parent,
- const QString &masterUuid, const QString &slaveType, Qt::WindowFlags f):
- QDialog(parent, f),
- m_ui(new Ui::ConnectionDetailEditor),
- m_connection(new NetworkManager::ConnectionSettings(type)),
- m_new(true),
- m_masterUuid(masterUuid),
- m_slaveType(slaveType)
-{
- setAttribute(Qt::WA_DeleteOnClose);
- m_ui->setupUi(this);
-
- initEditor();
-}
-
-ConnectionDetailEditor::ConnectionDetailEditor(NetworkManager::ConnectionSettings::ConnectionType type, QWidget* parent,
- const QString &vpnType, bool shared, Qt::WindowFlags f):
- QDialog(parent, f),
- m_ui(new Ui::ConnectionDetailEditor),
- m_connection(new NetworkManager::ConnectionSettings(type)),
- m_new(true),
- m_vpnType(vpnType)
-{
- setAttribute(Qt::WA_DeleteOnClose);
- m_ui->setupUi(this);
-
- if (shared) {
- if (type == ConnectionSettings::Wireless) {
- NetworkManager::WirelessSetting::Ptr wifiSetting = m_connection->setting(Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
- wifiSetting->setMode(WirelessSetting::Adhoc);
- wifiSetting->setSsid(i18n("my_shared_connection").toUtf8());
-
- foreach (const NetworkManager::Device::Ptr & device, NetworkManager::networkInterfaces()) {
- if (device->type() == Device::Wifi) {
- NetworkManager::WirelessDevice::Ptr wifiDev = device.objectCast<NetworkManager::WirelessDevice>();
- if (wifiDev) {
- if (wifiDev->wirelessCapabilities().testFlag(WirelessDevice::ApCap)) {
- wifiSetting->setMode(WirelessSetting::Ap);
- wifiSetting->setMacAddress(Utils::macAddressFromString(wifiDev->hardwareAddress()));
- }
- }
- }
- }
- }
- NetworkManager::Ipv4Setting::Ptr ipv4Setting = m_connection->setting(Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
- ipv4Setting->setMethod(Ipv4Setting::Shared);
- m_connection->setAutoconnect(false);
- }
-
- initEditor();
-}
-
-ConnectionDetailEditor::ConnectionDetailEditor(ConnectionSettings::ConnectionType type, const QVariantList &args, QWidget *parent, Qt::WindowFlags f):
- QDialog(parent, f),
- m_ui(new Ui::ConnectionDetailEditor),
- m_connection(new NetworkManager::ConnectionSettings(type)),
- m_new(true)
-{
- setAttribute(Qt::WA_DeleteOnClose);
- m_ui->setupUi(this);
-
- // parse args given from the wizard
- qDebug() << "Editing new mobile connection, number of args:" << args.count();
- foreach(const QVariant & arg, args) {
- qDebug() << "Argument:" << arg;
- }
-
- if (args.count() == 2) { //GSM or CDMA
- QVariantMap tmp = qdbus_cast<QVariantMap>(args.value(1));
-
-#if 0 // network IDs are not used yet and seem to break the setting
- if (args.count() == 3) { // gsm specific
- QStringList networkIds = args.value(1).toStringList();
- if (!networkIds.isEmpty())
- tmp.insert("network-id", networkIds.first());
- }
-#endif
-
- m_connection->setConnectionType(type);
- m_connection->setId(args.value(0).toString());
- qDebug() << "New " << m_connection->typeAsString(m_connection->connectionType()) << "connection initializing with:" << tmp;
- if (type == ConnectionSettings::Gsm)
- m_connection->setting(Setting::Gsm)->fromMap(tmp);
- else if (type == ConnectionSettings::Cdma)
- m_connection->setting(Setting::Cdma)->fromMap(tmp);
- else
- qWarning() << Q_FUNC_INFO << "Unhandled setting type";
-
- qDebug() << "New connection initialized:";
- qDebug() << *m_connection;
- } else {
- qWarning() << Q_FUNC_INFO << "Unexpected number of args to parse";
- }
-
- initEditor();
-}
-
-
-ConnectionDetailEditor::ConnectionDetailEditor(const NetworkManager::ConnectionSettings::Ptr &connection, QWidget* parent, Qt::WindowFlags f, bool newConnection):
- QDialog(parent, f),
- m_ui(new Ui::ConnectionDetailEditor),
- m_connection(connection),
- m_new(newConnection),
- m_masterUuid(connection->master()),
- m_slaveType(connection->slaveType())
-{
- setAttribute(Qt::WA_DeleteOnClose);
- m_ui->setupUi(this);
-
- initEditor();
-}
-
-ConnectionDetailEditor::~ConnectionDetailEditor()
-{
- m_connection.clear();
- delete m_ui;
-}
-
-void ConnectionDetailEditor::initEditor()
-{
- enableOKButton(false);
-
- if (!m_new) {
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(m_connection->uuid());
- if (connection) {
- bool hasSecrets = false;
- connect(connection.data(), SIGNAL(gotSecrets(QString,bool,NMVariantMapMap,QString)),
- SLOT(gotSecrets(QString,bool,NMVariantMapMap,QString)), Qt::UniqueConnection);
-
- if (m_connection->connectionType() == NetworkManager::ConnectionSettings::Adsl) {
- NetworkManager::AdslSetting::Ptr adslSetting = connection->settings()->setting(NetworkManager::Setting::Adsl).staticCast<NetworkManager::AdslSetting>();
- if (adslSetting && !adslSetting->needSecrets().isEmpty()) {
- hasSecrets = true;
- connection->secrets("adsl");
- }
- } else if (m_connection->connectionType() == NetworkManager::ConnectionSettings::Bluetooth) {
- NetworkManager::GsmSetting::Ptr gsmSetting = connection->settings()->setting(NetworkManager::Setting::Gsm).staticCast<NetworkManager::GsmSetting>();
- if (gsmSetting && !gsmSetting->needSecrets().isEmpty()) {
- hasSecrets = true;
- connection->secrets("gsm");
- }
- } else if (m_connection->connectionType() == NetworkManager::ConnectionSettings::Cdma) {
- NetworkManager::CdmaSetting::Ptr cdmaSetting = connection->settings()->setting(NetworkManager::Setting::Cdma).staticCast<NetworkManager::CdmaSetting>();
- if (cdmaSetting && !cdmaSetting->needSecrets().isEmpty()) {
- hasSecrets = true;
- connection->secrets("cdma");
- }
- } else if (m_connection->connectionType() == NetworkManager::ConnectionSettings::Gsm) {
- NetworkManager::GsmSetting::Ptr gsmSetting = connection->settings()->setting(NetworkManager::Setting::Gsm).staticCast<NetworkManager::GsmSetting>();
- if (gsmSetting && !gsmSetting->needSecrets().isEmpty()) {
- hasSecrets = true;
- connection->secrets("gsm");
- }
- } else if (m_connection->connectionType() == NetworkManager::ConnectionSettings::Pppoe) {
- NetworkManager::PppoeSetting::Ptr pppoeSetting = connection->settings()->setting(NetworkManager::Setting::Pppoe).staticCast<NetworkManager::PppoeSetting>();
- if (pppoeSetting && !pppoeSetting->needSecrets().isEmpty()) {
- hasSecrets = true;
- connection->secrets("pppoe");
- }
- } else if (m_connection->connectionType() == NetworkManager::ConnectionSettings::Wired) {
- NetworkManager::Security8021xSetting::Ptr securitySetting = connection->settings()->setting(NetworkManager::Setting::Security8021x).staticCast<NetworkManager::Security8021xSetting>();
- if (securitySetting && !securitySetting->needSecrets().isEmpty()) {
- hasSecrets = true;
- connection->secrets("802-1x");
- }
- } else if (m_connection->connectionType() == NetworkManager::ConnectionSettings::Wireless) {
- NetworkManager::WirelessSecuritySetting::Ptr wifiSecuritySetting = connection->settings()->setting(NetworkManager::Setting::WirelessSecurity).staticCast<NetworkManager::WirelessSecuritySetting>();
- if (wifiSecuritySetting &&
- (wifiSecuritySetting->keyMgmt() == NetworkManager::WirelessSecuritySetting::WpaEap ||
- (wifiSecuritySetting->keyMgmt() == NetworkManager::WirelessSecuritySetting::WirelessSecuritySetting::Ieee8021x &&
- wifiSecuritySetting->authAlg() != WirelessSecuritySetting::Leap))) {
- NetworkManager::Security8021xSetting::Ptr securitySetting = connection->settings()->setting(NetworkManager::Setting::Security8021x).staticCast<NetworkManager::Security8021xSetting>();
- if (securitySetting && !securitySetting->needSecrets().isEmpty()) {
- hasSecrets = true;
- connection->secrets("802-1x");
- }
- } else {
- if (!wifiSecuritySetting->needSecrets().isEmpty()) {
- hasSecrets = true;
- connection->secrets("802-11-wireless-security");
- }
- }
- } else if (m_connection->connectionType() == NetworkManager::ConnectionSettings::Vpn) {
- hasSecrets = true;
- connection->secrets("vpn");
- }
-
- if (!hasSecrets) {
- initTabs();
- }
- }
- } else {
- initTabs();
- }
-
- if (m_connection->id().isEmpty()) {
- setWindowTitle(i18n("New Connection (%1)", m_connection->typeAsString(m_connection->connectionType())));
- m_ui->connectionName->setText(i18n("New %1 connection", m_connection->typeAsString(m_connection->connectionType())));
- } else {
- setWindowTitle(i18n("Edit Connection '%1'", m_connection->id()));
- m_ui->connectionName->setText(m_connection->id());
- }
-
- connect(this, SIGNAL(accepted()), SLOT(saveSetting()));
- connect(this, SIGNAL(accepted()), SLOT(disconnectSignals()));
- connect(this, SIGNAL(rejected()), SLOT(disconnectSignals()));
-}
-
-void ConnectionDetailEditor::initTabs()
-{
- if (m_new) {
- m_connection->addToPermissions(KUser().loginName(), QString());
- }
-
- // create/set UUID, need this beforehand for slave connections
- QString uuid = m_connection->uuid();
- if (QUuid(uuid).isNull()) {
- uuid = NetworkManager::ConnectionSettings::createNewUuid();
- m_connection->setUuid(uuid);
- }
-
- ConnectionWidget * connectionWidget = new ConnectionWidget(m_connection);
- m_ui->tabWidget->addTab(connectionWidget, i18nc("General", "General configuration"));
-
- qDebug() << "Initting tabs, UUID:" << uuid;
-
- const NetworkManager::ConnectionSettings::ConnectionType type = m_connection->connectionType();
-
- // setup the widget tabs
- QString serviceType;
- if (type == NetworkManager::ConnectionSettings::Wired) {
- WiredConnectionWidget * wiredWidget = new WiredConnectionWidget(m_connection->setting(NetworkManager::Setting::Wired), this);
- m_ui->tabWidget->addTab(wiredWidget, i18n("Wired"));
- WiredSecurity * wiredSecurity = new WiredSecurity(m_connection->setting(NetworkManager::Setting::Security8021x).staticCast<NetworkManager::Security8021xSetting>(), this);
- m_ui->tabWidget->addTab(wiredSecurity, i18n("802.1x Security"));
- } else if (type == NetworkManager::ConnectionSettings::Wireless) {
- WifiConnectionWidget * wifiWidget = new WifiConnectionWidget(m_connection->setting(NetworkManager::Setting::Wireless), this);
- m_ui->tabWidget->addTab(wifiWidget, i18n("Wireless"));
- WifiSecurity * wifiSecurity = new WifiSecurity(m_connection->setting(NetworkManager::Setting::WirelessSecurity),
- m_connection->setting(NetworkManager::Setting::Security8021x).staticCast<NetworkManager::Security8021xSetting>(),
- this);
- m_ui->tabWidget->addTab(wifiSecurity, i18n("Wireless Security"));
- } else if (type == NetworkManager::ConnectionSettings::Pppoe) { // DSL
- PppoeWidget * pppoeWidget = new PppoeWidget(m_connection->setting(NetworkManager::Setting::Pppoe), this);
- m_ui->tabWidget->addTab(pppoeWidget, i18n("DSL"));
- WiredConnectionWidget * wiredWidget = new WiredConnectionWidget(m_connection->setting(NetworkManager::Setting::Wired), this);
- m_ui->tabWidget->addTab(wiredWidget, i18n("Wired"));
- } else if (type == NetworkManager::ConnectionSettings::Gsm) { // GSM
- GsmWidget * gsmWidget = new GsmWidget(m_connection->setting(NetworkManager::Setting::Gsm), this);
- m_ui->tabWidget->addTab(gsmWidget, i18n("Mobile Broadband (%1)", m_connection->typeAsString(m_connection->connectionType())));
- } else if (type == NetworkManager::ConnectionSettings::Cdma) { // CDMA
- CdmaWidget * cdmaWidget = new CdmaWidget(m_connection->setting(NetworkManager::Setting::Cdma), this);
- m_ui->tabWidget->addTab(cdmaWidget, i18n("Mobile Broadband (%1)", m_connection->typeAsString(m_connection->connectionType())));
- } else if (type == NetworkManager::ConnectionSettings::Bluetooth) { // Bluetooth
- BtWidget * btWidget = new BtWidget(m_connection->setting(NetworkManager::Setting::Bluetooth), this);
- m_ui->tabWidget->addTab(btWidget, i18n("Bluetooth"));
- NetworkManager::BluetoothSetting::Ptr btSetting = m_connection->setting(NetworkManager::Setting::Bluetooth).staticCast<NetworkManager::BluetoothSetting>();
- if (btSetting->profileType() == NetworkManager::BluetoothSetting::Dun) {
- GsmWidget * gsmWidget = new GsmWidget(m_connection->setting(NetworkManager::Setting::Gsm), this);
- m_ui->tabWidget->addTab(gsmWidget, i18n("GSM"));
- PPPWidget * pppWidget = new PPPWidget(m_connection->setting(NetworkManager::Setting::Ppp), this);
- m_ui->tabWidget->addTab(pppWidget, i18n("PPP"));
- }
- } else if (type == NetworkManager::ConnectionSettings::Infiniband) { // Infiniband
- InfinibandWidget * infinibandWidget = new InfinibandWidget(m_connection->setting(NetworkManager::Setting::Infiniband), this);
- m_ui->tabWidget->addTab(infinibandWidget, i18n("Infiniband"));
- } else if (type == NetworkManager::ConnectionSettings::Bond) { // Bond
- BondWidget * bondWidget = new BondWidget(uuid, m_connection->setting(NetworkManager::Setting::Bond), this);
- m_ui->tabWidget->addTab(bondWidget, i18n("Bond"));
- } else if (type == NetworkManager::ConnectionSettings::Bridge) { // Bridge
- BridgeWidget * bridgeWidget = new BridgeWidget(uuid, m_connection->setting(NetworkManager::Setting::Bridge), this);
- m_ui->tabWidget->addTab(bridgeWidget, i18n("Bridge"));
- } else if (type == NetworkManager::ConnectionSettings::Vlan) { // Vlan
- VlanWidget * vlanWidget = new VlanWidget(m_connection->setting(NetworkManager::Setting::Vlan), this);
- m_ui->tabWidget->addTab(vlanWidget, i18n("Vlan"));
- } else if (type == NetworkManager::ConnectionSettings::Wimax) { // Wimax
- WimaxWidget * wimaxWidget = new WimaxWidget(m_connection->setting(NetworkManager::Setting::Wimax), this);
- m_ui->tabWidget->addTab(wimaxWidget, i18n("WiMAX"));
- } else if (type == NetworkManager::ConnectionSettings::Vpn) { // VPN
- QString error;
- VpnUiPlugin * vpnPlugin = 0;
- NetworkManager::VpnSetting::Ptr vpnSetting =
- m_connection->setting(NetworkManager::Setting::Vpn).staticCast<NetworkManager::VpnSetting>();
- if (!vpnSetting) {
- qDebug() << "Missing VPN setting!";
- } else {
- if (m_new && !m_vpnType.isEmpty()) {
- serviceType = m_vpnType;
- vpnSetting->setServiceType(serviceType);
- }
- else
- serviceType = vpnSetting->serviceType();
- //qDebug() << "Editor loading VPN plugin" << serviceType;
- //vpnSetting->printSetting();
- vpnPlugin = KServiceTypeTrader::createInstanceFromQuery<VpnUiPlugin>(QString::fromLatin1("PlasmaNetworkManagement/VpnUiPlugin"),
- QString::fromLatin1("[X-NetworkManager-Services]=='%1'").arg(serviceType),
- this, QVariantList(), &error);
- if (vpnPlugin && error.isEmpty()) {
- const QString shortName = serviceType.section('.', -1);
- SettingWidget * vpnWidget = vpnPlugin->widget(vpnSetting, this);
- m_ui->tabWidget->addTab(vpnWidget, i18n("VPN (%1)", shortName));
- } else {
- qDebug() << error << ", serviceType == " << serviceType;
- }
- }
- }
-
- // PPP widget
- if (type == ConnectionSettings::Pppoe || type == ConnectionSettings::Cdma || type == ConnectionSettings::Gsm) {
- PPPWidget * pppWidget = new PPPWidget(m_connection->setting(NetworkManager::Setting::Ppp), this);
- m_ui->tabWidget->addTab(pppWidget, i18n("PPP"));
- }
-
- // IPv4 widget
- if (!isSlave()) {
- IPv4Widget * ipv4Widget = new IPv4Widget(m_connection->setting(NetworkManager::Setting::Ipv4), this);
- m_ui->tabWidget->addTab(ipv4Widget, i18n("IPv4"));
- }
-
- // IPv6 widget
- if ((type == ConnectionSettings::Wired
- || type == ConnectionSettings::Wireless
- || type == ConnectionSettings::Infiniband
- || type == ConnectionSettings::Wimax
- || type == ConnectionSettings::Bond
- || type == ConnectionSettings::Bridge
- || type == ConnectionSettings::Vlan
- || (type == ConnectionSettings::Vpn && serviceType == QLatin1String(NM_DBUS_SERVICE_OPENVPN))) && !isSlave()) {
- IPv6Widget * ipv6Widget = new IPv6Widget(m_connection->setting(NetworkManager::Setting::Ipv6), this);
- m_ui->tabWidget->addTab(ipv6Widget, i18n("IPv6"));
- }
-
- // validation
- bool valid = true;
- for (int i = 0; i < m_ui->tabWidget->count(); ++i) {
- SettingWidget * widget = dynamic_cast<SettingWidget *>(m_ui->tabWidget->widget(i));
- if (widget) {
- valid = valid && widget->isValid();
- connect(widget, SIGNAL(validChanged(bool)), SLOT(validChanged(bool)));
- }
- }
- enableOKButton(valid);
- m_ui->tabWidget->setCurrentIndex(1);
-
- KAcceleratorManager::manage(this);
-}
-
-void ConnectionDetailEditor::saveSetting()
-{
- ConnectionWidget * connectionWidget = static_cast<ConnectionWidget*>(m_ui->tabWidget->widget(0));
-
- NMVariantMapMap settings = connectionWidget->setting();
-
- bool agentOwned = false;
- // We can store secrets into KWallet if KWallet is enabled and permissions list is not empty
- if (!settings.value("connection").value("permissions").toStringList().isEmpty() && KWallet::Wallet::isEnabled()) {
- agentOwned = true;
- }
-
- for (int i = 1; i < m_ui->tabWidget->count(); ++i) {
- SettingWidget * widget = static_cast<SettingWidget*>(m_ui->tabWidget->widget(i));
- const QString type = widget->type();
- if (type != NetworkManager::Setting::typeAsString(NetworkManager::Setting::Security8021x) &&
- type != NetworkManager::Setting::typeAsString(NetworkManager::Setting::WirelessSecurity)) {
- settings.insert(type, widget->setting(agentOwned));
- }
-
- // add 802.1x security if needed
- QVariantMap security8021x;
- if (type == NetworkManager::Setting::typeAsString(NetworkManager::Setting::WirelessSecurity)) {
- WifiSecurity * wifiSecurity = static_cast<WifiSecurity*>(widget);
- if (wifiSecurity->enabled()) {
- settings.insert(type, wifiSecurity->setting(agentOwned));
- }
- if (wifiSecurity->enabled8021x()) {
- security8021x = static_cast<WifiSecurity *>(widget)->setting8021x(agentOwned);
- settings.insert(NetworkManager::Setting::typeAsString(NetworkManager::Setting::Security8021x), security8021x);
- }
- } else if (type == NetworkManager::Setting::typeAsString(NetworkManager::Setting::Security8021x)) {
- WiredSecurity * wiredSecurity = static_cast<WiredSecurity*>(widget);
- if (wiredSecurity->enabled8021x()) {
- security8021x = static_cast<WiredSecurity *>(widget)->setting(agentOwned);
- settings.insert(NetworkManager::Setting::typeAsString(NetworkManager::Setting::Security8021x), security8021x);
- }
- }
- }
-
- NetworkManager::ConnectionSettings * connectionSettings = new NetworkManager::ConnectionSettings(m_connection->connectionType());
-
- connectionSettings->fromMap(settings);
- connectionSettings->setId(m_ui->connectionName->text());
-
- if (connectionSettings->connectionType() == ConnectionSettings::Wireless) {
- NetworkManager::WirelessSecuritySetting::Ptr securitySetting = connectionSettings->setting(Setting::WirelessSecurity).staticCast<NetworkManager::WirelessSecuritySetting>();
- NetworkManager::WirelessSetting::Ptr wirelessSetting = connectionSettings->setting(Setting::Wireless).staticCast<NetworkManager::WirelessSetting>();
-
- if (securitySetting && wirelessSetting) {
- if (securitySetting->keyMgmt() != NetworkManager::WirelessSecuritySetting::WirelessSecuritySetting::Unknown) {
- wirelessSetting->setSecurity("802-11-wireless-security");
- }
- }
- }
-
- // set UUID
- connectionSettings->setUuid(m_connection->uuid());
-
- // set master & slave type
- if (isSlave()) {
- connectionSettings->setMaster(m_masterUuid);
- connectionSettings->setSlaveType(m_slaveType);
- }
-
- qDebug() << *connectionSettings; // debug
-
- if (m_new) { // create new connection
- connect(NetworkManager::settingsNotifier(), SIGNAL(connectionAddComplete(QString,bool,QString)),
- SLOT(connectionAddComplete(QString,bool,QString)));
- NetworkManager::addConnection(connectionSettings->toMap());
- } else { // update existing connection
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(connectionSettings->uuid());
-
- if (connection) {
- connection->update(connectionSettings->toMap());
- }
- }
-}
-
-void ConnectionDetailEditor::connectionAddComplete(const QString& id, bool success, const QString& msg)
-{
- qDebug() << id << " - " << success << " - " << msg;
-}
-
-void ConnectionDetailEditor::gotSecrets(const QString& id, bool success, const NMVariantMapMap& secrets, const QString& msg)
-{
- if (id == m_connection->uuid() && success) {
- foreach (const QString & key, secrets.keys()) {
- NetworkManager::Setting::Ptr setting = m_connection->setting(NetworkManager::Setting::typeFromString(key));
- if (setting) {
- setting->secretsFromMap(secrets.value(key));
- }
- }
- }
-
- initTabs();
-}
-
-void ConnectionDetailEditor::disconnectSignals()
-{
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(m_connection->uuid());
-
- if (connection) {
- disconnect(connection.data(), SIGNAL(gotSecrets(QString,bool,NMVariantMapMap,QString)),
- this, SLOT(gotSecrets(QString,bool,NMVariantMapMap,QString)));
- }
-}
-
-void ConnectionDetailEditor::validChanged(bool valid)
-{
- if (!valid) {
- enableOKButton(false);
- return;
- } else {
- for (int i = 1; i < m_ui->tabWidget->count(); ++i) {
- SettingWidget * widget = static_cast<SettingWidget*>(m_ui->tabWidget->widget(i));
- if (!widget->isValid()) {
- enableOKButton(false);
- return;
- }
- }
- }
-
- enableOKButton(true);
-}
-
-void ConnectionDetailEditor::enableOKButton(bool enabled)
-{
- m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enabled);
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_CONNECTION_DETAIL_EDITOR_H
-#define PLASMA_NM_CONNECTION_DETAIL_EDITOR_H
-
-#include <QtGui/QDialog>
-
-#include <NetworkManagerQt/ConnectionSettings>
-
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class ConnectionDetailEditor;
-}
-
-class PLASMA_NM_EXPORT ConnectionDetailEditor : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit ConnectionDetailEditor(NetworkManager::ConnectionSettings::ConnectionType type,
- QWidget* parent = 0,
- const QString &masterUuid = QString(),
- const QString &slaveType = QString(),
- Qt::WindowFlags f = 0);
- explicit ConnectionDetailEditor(NetworkManager::ConnectionSettings::ConnectionType type,
- QWidget* parent = 0,
- const QString &vpnType = QString(),
- bool shared = false,
- Qt::WindowFlags f = 0);
- explicit ConnectionDetailEditor(const NetworkManager::ConnectionSettings::Ptr &connection,
- QWidget* parent = 0, Qt::WindowFlags f = 0, bool newConnection = false);
- explicit ConnectionDetailEditor(NetworkManager::ConnectionSettings::ConnectionType type,
- const QVariantList &args,
- QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~ConnectionDetailEditor();
-
- bool isSlave() const { return !m_masterUuid.isEmpty() && !m_slaveType.isEmpty(); }
-
-private Q_SLOTS:
- void connectionAddComplete(const QString & id, bool success, const QString & msg);
- void disconnectSignals();
- void gotSecrets(const QString & id, bool success, const NMVariantMapMap & secrets, const QString & msg);
- void validChanged(bool valid);
- void saveSetting();
-
-private:
- void enableOKButton(bool enabled);
-
- Ui::ConnectionDetailEditor * m_ui;
- NetworkManager::ConnectionSettings::Ptr m_connection;
- bool m_new;
- QString m_vpnType;
- QString m_masterUuid;
- QString m_slaveType;
-
- void initEditor();
- void initTabs();
-};
-
-#endif // PLASMA_NM_CONNECTION_DETAIL_EDITOR_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ConnectionDetailEditor</class>
- <widget class="QDialog" name="ConnectionDetailEditor">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>480</width>
- <height>427</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Dialog</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Connection name:</string>
- </property>
- <property name="buddy">
- <cstring>connectionName</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="2">
- <widget class="KLineEdit" name="connectionName"/>
- </item>
- <item row="1" column="0" colspan="3">
- <widget class="KTabWidget" name="tabWidget">
- <property name="currentIndex">
- <number>-1</number>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>228</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="2">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KTabWidget</class>
- <extends>QTabWidget</extends>
- <header>ktabwidget.h</header>
- <container>1</container>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>connectionName</tabstop>
- <tabstop>tabWidget</tabstop>
- <tabstop>buttonBox</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>ConnectionDetailEditor</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>248</x>
- <y>254</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>ConnectionDetailEditor</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>316</x>
- <y>260</y>
- </hint>
- <hint type="destinationlabel">
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-/*
- Copyright 2010-2012 Lamarque Souza <lamarque@kde.org>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "mobileproviders.h"
-
-#include <QFile>
-#include <QTextStream>
-
-#include <KDebug>
-#include <KLocale>
-#include <KGlobal>
-
-const QString MobileProviders::ProvidersFile = "/usr/share/mobile-broadband-provider-info/serviceproviders.xml";
-
-bool localeAwareCompare(const QString & one, const QString & two) {
- return one.localeAwareCompare(two) < 0;
-}
-
-MobileProviders::MobileProviders()
-{
- const QStringList allCountries = KGlobal::locale()->allCountriesList();
- foreach (const QString & cc, allCountries) {
- //kDebug() << "Inserting" << cc.toUpper() << KGlobal::locale()->countryCodeToName(cc);
- mCountries.insert(cc.toUpper(), KGlobal::locale()->countryCodeToName(cc));
- }
- mError = Success;
-
- QFile file2(ProvidersFile);
-
- if (file2.open(QIODevice::ReadOnly)) {
- if (mDocProviders.setContent(&file2)) {
- docElement = mDocProviders.documentElement();
-
- if (docElement.isNull()) {
- kDebug() << ProvidersFile << ": document is null";
- mError = ProvidersIsNull;
- } else {
- if (docElement.isNull() || docElement.tagName() != "serviceproviders") {
- kDebug() << ProvidersFile << ": wrong format";
- mError = ProvidersWrongFormat;
- } else {
- if (docElement.attribute("format") != "2.0") {
- kDebug() << ProvidersFile << ": mobile broadband provider database format '" << docElement.attribute("format") << "' not supported.";
- mError = ProvidersFormatNotSupported;
- } else {
- //kDebug() << "Everything is alright so far";
- }
- }
- }
- }
-
- file2.close();
- } else {
- kDebug() << "Error opening providers file" << ProvidersFile;
- mError = ProvidersMissing;
- }
-}
-
-MobileProviders::~MobileProviders()
-{
-}
-
-QStringList MobileProviders::getCountryList() const
-{
- QStringList temp = mCountries.values();
- qSort(temp.begin(), temp.end(), localeAwareCompare);
- return temp;
-}
-
-QString MobileProviders::countryFromLocale() const
-{
- return KGlobal::locale()->country().toUpper();
-}
-
-QStringList MobileProviders::getProvidersList(QString country, NetworkManager::ConnectionSettings::ConnectionType type)
-{
- mProvidersGsm.clear();
- mProvidersCdma.clear();
- QDomNode n = docElement.firstChild();
-
- // country is a country name and we parse country codes.
- if (!mCountries.key(country).isNull()) {
- country = mCountries.key(country);
- }
- QMap<QString, QString> sortedGsm;
- QMap<QString, QString> sortedCdma;
- while (!n.isNull()) {
- QDomElement e = n.toElement(); // <country ...>
-
- if (!e.isNull() && e.attribute("code").toUpper() == country) {
- QDomNode n2 = e.firstChild();
- while (!n2.isNull()) {
- QDomElement e2 = n2.toElement(); // <provider ...>
-
- if (!e2.isNull() && e2.tagName().toLower() == "provider") {
- QDomNode n3 = e2.firstChild();
- bool hasGsm = false;
- bool hasCdma = false;
- QMap<QString, QString> localizedProviderNames;
-
- while (!n3.isNull()) {
- QDomElement e3 = n3.toElement(); // <name | gsm | cdma>
-
- if (!e3.isNull()) {
- if (e3.tagName().toLower() == "gsm") {
- hasGsm = true;
- } else if (e3.tagName().toLower() == "cdma") {
- hasCdma = true;
- } else if (e3.tagName().toLower() == "name") {
- QString lang = e3.attribute("xml:lang");
- if (lang.isEmpty()) {
- lang = "en"; // English is default
- } else {
- lang = lang.toLower();
- lang.remove(QRegExp("\\-.*$")); // Remove everything after '-' in xml:lang attribute.
- }
- localizedProviderNames.insert(lang, e3.text());
- }
- }
- n3 = n3.nextSibling();
- }
- const QString name = getNameByLocale(localizedProviderNames);
- if (hasGsm) {
- mProvidersGsm.insert(name, e2.firstChild());
- sortedGsm.insert(name.toLower(), name);
- }
- if (hasCdma) {
- mProvidersCdma.insert(name, e2.firstChild());
- sortedCdma.insert(name.toLower(), name);
- }
- }
- n2 = n2.nextSibling();
- }
- break;
- }
- n = n.nextSibling();
- }
-
- if (type == NetworkManager::ConnectionSettings::Gsm) {
- return sortedGsm.values();
- }
- return sortedCdma.values();
-}
-
-QStringList MobileProviders::getApns(const QString & provider)
-{
- mApns.clear();
- mNetworkIds.clear();
- if (!mProvidersGsm.contains(provider)) {
- return QStringList();
- }
-
- QDomNode n = mProvidersGsm[provider];
-
- while (!n.isNull()) {
- QDomElement e = n.toElement(); // <gsm | cdma>
-
- if (!e.isNull() && e.tagName().toLower() == "gsm") {
- QDomNode n2 = e.firstChild();
- while (!n2.isNull()) {
- QDomElement e2 = n2.toElement(); // <apn | network-id>
-
- if (!e2.isNull() && e2.tagName().toLower() == "apn") {
- bool isInternet = true;
- QDomNode n3 = e2.firstChild();
- while (!n3.isNull()) {
- QDomElement e3 = n3.toElement(); // <usage>
- if (!e3.isNull() &&
- e3.tagName().toLower() == "usage" &&
- !e3.attribute("type").isNull() &&
- e3.attribute("type").toLower() != "internet") {
- //kDebug() << "apn" << e2.attribute("value") << "ignored because of usage" << e3.attribute("type");
- isInternet = false;
- break;
- }
- n3 = n3.nextSibling();
- }
- if (isInternet) {
- mApns.insert(e2.attribute("value"), e2.firstChild());
- }
- } else if (!e2.isNull() && e2.tagName().toLower() == "network-id") {
- mNetworkIds.append(e2.attribute("mcc") + '-' + e2.attribute("mnc"));
- }
-
- n2 = n2.nextSibling();
- }
- }
- n = n.nextSibling();
- }
-
- QStringList temp = mApns.keys();
- temp.sort();
- return temp;
-}
-
-
-QStringList MobileProviders::getNetworkIds(const QString & provider)
-{
- if (mNetworkIds.isEmpty()) {
- getApns(provider);
- }
- return mNetworkIds;
-}
-
-QVariantMap MobileProviders::getApnInfo(const QString & apn)
-{
- QVariantMap temp;
- QDomNode n = mApns[apn];
- QStringList dnsList;
- QMap<QString, QString> localizedPlanNames;
-
- while (!n.isNull()) {
- QDomElement e = n.toElement(); // <name|username|password|dns(*)>
-
- if (!e.isNull()) {
- if (e.tagName().toLower() == "name") {
- QString lang = e.attribute("xml:lang");
- if (lang.isEmpty()) {
- lang = "en"; // English is default
- } else {
- lang = lang.toLower();
- lang.remove(QRegExp("\\-.*$")); // Remove everything after '-' in xml:lang attribute.
- }
- localizedPlanNames.insert(lang, e.text());
- } else if (e.tagName().toLower() == "username") {
- temp.insert("username", e.text());
- } else if (e.tagName().toLower() == "password") {
- temp.insert("password", e.text());
- } else if (e.tagName().toLower() == "dns") {
- dnsList.append(e.text());
- }
- }
-
- n = n.nextSibling();
- }
-
- QString name = getNameByLocale(localizedPlanNames);
- if (!name.isEmpty()) {
- temp.insert("name", QVariant::fromValue(name));
- }
- temp.insert("number", getGsmNumber());
- temp.insert("apn", apn);
- temp.insert("dnsList", dnsList);
-
- return temp;
-}
-
-QVariantMap MobileProviders::getCdmaInfo(const QString & provider)
-{
- if (!mProvidersCdma.contains(provider)) {
- return QVariantMap();
- }
-
- QVariantMap temp;
- QDomNode n = mProvidersCdma[provider];
- QStringList sidList;
-
- while (!n.isNull()) {
- QDomElement e = n.toElement(); // <gsm or cdma ...>
-
- if (!e.isNull() && e.tagName().toLower() == "cdma") {
- QDomNode n2 = e.firstChild();
- while (!n2.isNull()) {
- QDomElement e2 = n2.toElement(); // <name | username | password | sid>
-
- if (!e2.isNull()) {
- if (e2.tagName().toLower() == "username") {
- temp.insert("username", e2.text());
- } else if (e2.tagName().toLower() == "password") {
- temp.insert("password", e2.text());
- } else if (e2.tagName().toLower() == "sid") {
- sidList.append(e2.text());
- }
- }
-
- n2 = n2.nextSibling();
- }
- }
- n = n.nextSibling();
- }
-
- temp.insert("number", getCdmaNumber());
- temp.insert("sidList", sidList);
- return temp;
-}
-
-QString MobileProviders::getNameByLocale(const QMap<QString, QString> & localizedNames) const
-{
- QString name;
- const QStringList locales = KGlobal::locale()->languageList();
- foreach(const QString & locale, locales) {
- QString language, country, modifier, charset;
- KLocale::splitLocale(locale, language, country, modifier, charset);
-
- if (localizedNames.contains(language)) {
- return localizedNames[language];
- }
- }
-
- name = localizedNames["en"];
-
- // Use any language if no proper localized name were found.
- if (name.isEmpty() && !localizedNames.isEmpty()) {
- name = localizedNames.constBegin().value();
- }
- return name;
-}
+++ /dev/null
-/*
- Copyright 2010-2012 Lamarque Souza <lamarque@kde.org>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_MOBILE_PROVIDERS_H
-#define PLASMA_NM_MOBILE_PROVIDERS_H
-
-#include <QStringList>
-#include <QHash>
-#include <QDomDocument>
-#include <QVariantMap>
-
-#include <NetworkManagerQt/ConnectionSettings>
-
-class MobileProviders
-{
-public:
- static const QString ProvidersFile;
-
- enum ErrorCodes { Success, CountryCodesMissing, ProvidersMissing, ProvidersIsNull, ProvidersWrongFormat, ProvidersFormatNotSupported };
-
- MobileProviders();
- ~MobileProviders();
-
- QStringList getCountryList() const;
- QString countryFromLocale() const;
- QString getCountryName(const QString & key) const { return mCountries.value(key); }
- QStringList getProvidersList(QString country, NetworkManager::ConnectionSettings::ConnectionType type);
- QStringList getApns(const QString & provider);
- QStringList getNetworkIds(const QString & provider);
- QVariantMap getApnInfo(const QString & apn);
- QVariantMap getCdmaInfo(const QString & provider);
- QString getGsmNumber() const { return QString("*99#"); }
- QString getCdmaNumber() const { return QString("#777"); }
- inline ErrorCodes getError() { return mError; }
-
-private:
- QHash<QString, QString> mCountries;
- QMap<QString, QDomNode> mProvidersGsm;
- QMap<QString, QDomNode> mProvidersCdma;
- QMap<QString, QDomNode> mApns;
- QStringList mNetworkIds;
- QDomDocument mDocProviders;
- QDomElement docElement;
- ErrorCodes mError;
- QString getNameByLocale(const QMap<QString, QString> & names) const;
-};
-
-#endif // PLASMA_NM_MOBILE_PROVIDERS_H
+++ /dev/null
-[Desktop Entry]
-Type=ServiceType
-X-KDE-ServiceType=PlasmaNetworkManagement/VpnUiPlugin
-Name=Network Management VPN UI Plugin
-Name[bs]=Dodatak za upravljanje mrežom VPN UI
-Name[ca]=Connector de la IU per a la VPN del Gestor de la xarxa
-Name[ca@valencia]=Connector de la IU per a VPN del Gestor de la xarxa
-Name[cs]=VPN UI modul pro správu sítě
-Name[da]=VPN UI-plugin til netværkshåndtering
-Name[de]=Netzwerkverwaltung VPN-Modul
-Name[el]=Πρόσθετο VPN UI της διαχείρισης δικτύων
-Name[en_GB]=Network Management VPN UI Plugin
-Name[es]=Complemento de interfaz gráfica VPN de gestión de red
-Name[et]=Võrguhalduri VPN-i UI plugin
-Name[fi]=Verkonhallinnan VPN-käyttöliittymäliitännäinen
-Name[fr]=Module externe d'interface utilisateur VPN de gestion de réseau
-Name[hu]=Hálózatkezelő VPN UI bővítmény
-Name[it]=Estensione interfaccia di gestione di rete di KDE
-Name[ko]=네트워크 관리 VPN UI 플러그인
-Name[lt]=Tinklo valdymo VPN UI priedas
-Name[nb]=Programtillegg til nettverkstyring med VPN brukerflate
-Name[nds]=Nettwarkpleger-VPN-Böversietmoduul
-Name[nl]=Netwerkbeheer VPN UI-plugin
-Name[pl]=Wtyczka VPN interfejsu użytkownika dla zarządzania siecią
-Name[pt]='Plugin' de Interface VPN da Gestão de Rede
-Name[pt_BR]=Plugin de interface VPN do gerenciamento de redes
-Name[ro]=Modul de interfață VPN pentru gestiunea rețelei
-Name[ru]=Графический модуль управления сетевыми VPN-соединениями
-Name[sk]=Modul pre správu siete VPN
-Name[sl]=Vstavek vmesnika za upravljanje omrežij VPN
-Name[sv]=Insticksprogram till nätverkshantering med VPN-användargränssnitt
-Name[tr]=Ağ Yönetimi VPN UI Eklentisi
-Name[ug]=تور باشقۇرۇش VPN UI قىستۇرمىسى
-Name[uk]=Додаток графічного інтерфейсу керування мережею VPN
-Name[x-test]=xxNetwork Management VPN UI Pluginxx
-Name[zh_CN]=网络管理 VPN 用户界面插件
-Comment=Defines KDE Network Management UI Plugins
-Comment[bs]=Definiše KDE dodatke za upravljanje mrežom
-Comment[ca]=Defineix els connectors de la IU del Gestor de la xarxa del KDE
-Comment[ca@valencia]=Defineix els connectors de la IU del Gestor de la xarxa del KDE
-Comment[cs]=Definuje grafické moduly správy sítě KDE
-Comment[da]=Definerer UI-plugins til KDE netværkshåndtering
-Comment[de]=Legt die Module der KDE-Netzwerkverwaltung fest
-Comment[el]=Καθορίζει τα πρόσθετα UI της διαχείρισης δικτύων
-Comment[en_GB]=Defines KDE Network Management UI Plugins
-Comment[es]=Defina los complementos de interfaz gráfica de la gestión de red de KDE
-Comment[et]=KDE võrguhalduri UI pluginate määratlus
-Comment[fi]=Määrittää KDE:n verkonhallinnan käyttöliittymäliitännäiset
-Comment[fr]=Définit les modules externes d'interface utilisateur de gestion de réseau pour KDE
-Comment[hu]=Meghatározza a KDE hálózatkezelő UI bővítményeket
-Comment[it]=Definisce le estensioni dell'interfaccia di gestione rete di KDE
-Comment[ko]=KDE 네트워크 관리 UI 플러그인 정의
-Comment[lt]=Apibrėžia KDE Tinklo valdymo UI priedus
-Comment[nb]=Definerer brukerflate-tillegg til KDE nettverkstyring
-Comment[nds]=Leggt Böversietmodulen för de KDE-Nettwarkpleeg fast
-Comment[nl]=Definieert KDE netwerkbeheer UI-plugins
-Comment[pl]=Określa wtyczki interfejsu użytkownika dla zarządzania siecią
-Comment[pt]=Define os 'plugins' de interface da Gestão de Rede
-Comment[pt_BR]=Define os plugins de interface do gerenciamento de redes
-Comment[ro]=Definește modulele de interfață pentru gestiunea rețelei
-Comment[ru]=Графический модуль управления сетевыми соединениями для KDE
-Comment[sk]=Definuje moduly pre správu siete KDE
-Comment[sl]=Določa vstavke za KDE-jev vmesnik za upravljanje omrežij
-Comment[sv]=Definierar insticksprogram för KDE:s nätverkshantering
-Comment[tr]=KDE Ağ Yönetimi UI Eklentilerini tanımlar
-Comment[uk]=Визначає додатки інтерфейсу засобу керування мережею KDE
-Comment[x-test]=xxDefines KDE Network Management UI Pluginsxx
-Comment[zh_CN]=定义 KDE 网络管理用户界面插件
-
-[PropertyDef::X-NetworkManager-Services]
-Type=QString
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <ltinkl@redhat.com></author>
- <class>Security8021x</class>
- <widget class="QWidget" name="Security8021x">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>563</width>
- <height>471</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Authentication:</string>
- </property>
- <property name="buddy">
- <cstring>auth</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="auth">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>MD5</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>TLS</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>LEAP</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>FAST</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Tunneled TLS (TTLS)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Protected EAP (PEAP)</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QStackedWidget" name="stackedWidget">
- <widget class="QWidget" name="md5Page">
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>md5UserName</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="md5UserName"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>md5Password</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="md5Password">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QCheckBox" name="cbAskMd5Password">
- <property name="text">
- <string>Ask for this password every time</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QCheckBox" name="cbShowMd5Password">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="tlsPage">
- <layout class="QFormLayout" name="formLayout_2">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Identity:</string>
- </property>
- <property name="buddy">
- <cstring>tlsIdentity</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="tlsIdentity"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>User certificate:</string>
- </property>
- <property name="buddy">
- <cstring>tlsUserCert</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>CA certificate:</string>
- </property>
- <property name="buddy">
- <cstring>tlsCACert</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KUrlRequester" name="tlsCACert">
- <property name="filter">
- <string notr="true">*.der *.pem *.crt *.cer</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>Private key:</string>
- </property>
- <property name="buddy">
- <cstring>tlsPrivateKey</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="KUrlRequester" name="tlsPrivateKey">
- <property name="filter">
- <string notr="true">*.der *.pem *.p12</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>Private key password:</string>
- </property>
- <property name="buddy">
- <cstring>tlsPrivateKeyPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KLineEdit" name="tlsPrivateKeyPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QCheckBox" name="cbShowTlsPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KUrlRequester" name="tlsUserCert">
- <property name="filter">
- <string notr="true">*.der *.pem *.crt *.cer</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="leapPage">
- <layout class="QFormLayout" name="formLayout_3">
- <item row="0" column="0">
- <widget class="QLabel" name="label_9">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>leapUsername</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="leapUsername"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_10">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>leapPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="leapPassword"/>
- </item>
- <item row="2" column="1">
- <widget class="QCheckBox" name="cbShowLeapPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="fastPage">
- <layout class="QFormLayout" name="formLayout_4">
- <item row="0" column="0">
- <widget class="QLabel" name="label_11">
- <property name="text">
- <string>Anonymous identity:</string>
- </property>
- <property name="buddy">
- <cstring>fastAnonIdentity</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="fastAnonIdentity"/>
- </item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="fastAllowPacProvisioning">
- <property name="text">
- <string>Automatic PAC provisioning</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KComboBox" name="pacMethod">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>Anonymous</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Authenticated</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Both</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_12">
- <property name="text">
- <string>PAC &file:</string>
- </property>
- <property name="buddy">
- <cstring>pacFile</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KUrlRequester" name="pacFile">
- <property name="filter">
- <string notr="true">*.pac</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_13">
- <property name="text">
- <string>Inner authentication:</string>
- </property>
- <property name="buddy">
- <cstring>fastInnerAuth</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="KComboBox" name="fastInnerAuth">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>GTC</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>MSCHAPv2</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_14">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>fastUsername</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KLineEdit" name="fastUsername"/>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="label_15">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>fastPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="KLineEdit" name="fastPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="QCheckBox" name="cbAskFastPassword">
- <property name="text">
- <string>Ask for this password every time</string>
- </property>
- </widget>
- </item>
- <item row="7" column="1">
- <widget class="QCheckBox" name="cbShowFastPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="ttlsPage">
- <layout class="QFormLayout" name="formLayout_5">
- <item row="0" column="0">
- <widget class="QLabel" name="label_19">
- <property name="text">
- <string>Anonymous identity:</string>
- </property>
- <property name="buddy">
- <cstring>fastAnonIdentity</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="ttlsAnonIdentity"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_20">
- <property name="text">
- <string>CA certificate:</string>
- </property>
- <property name="buddy">
- <cstring>tlsCACert</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KUrlRequester" name="ttlsCACert">
- <property name="filter">
- <string notr="true">*.der *.pem *.crt *.cer</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_16">
- <property name="text">
- <string>Inner authentication:</string>
- </property>
- <property name="buddy">
- <cstring>fastInnerAuth</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KComboBox" name="ttlsInnerAuth">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>PAP</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>MSCHAP</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>MSCHAPv2</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>CHAP</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_17">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>fastUsername</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="KLineEdit" name="ttlsUsername"/>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_18">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>fastPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KLineEdit" name="ttlsPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QCheckBox" name="cbAskTtlsPassword">
- <property name="text">
- <string>Ask for this password every time</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="QCheckBox" name="cbShowTtlsPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="peapPage">
- <layout class="QFormLayout" name="formLayout_6">
- <item row="0" column="0">
- <widget class="QLabel" name="label_24">
- <property name="text">
- <string>Anonymous identity:</string>
- </property>
- <property name="buddy">
- <cstring>fastAnonIdentity</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="peapAnonIdentity"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_23">
- <property name="text">
- <string>CA certificate:</string>
- </property>
- <property name="buddy">
- <cstring>tlsCACert</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KUrlRequester" name="peapCACert">
- <property name="filter">
- <string notr="true">*.der *.pem *.crt *.cer</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_22">
- <property name="text">
- <string>Inner authentication:</string>
- </property>
- <property name="buddy">
- <cstring>fastInnerAuth</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="KComboBox" name="peapInnerAuth">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>MSCHAPv2</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>MD5</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>GTC</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_25">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>fastUsername</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KLineEdit" name="peapUsername"/>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="label_21">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>fastPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="KLineEdit" name="peapPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="QCheckBox" name="cbAskPeapPassword">
- <property name="text">
- <string>Ask for this password every time</string>
- </property>
- </widget>
- </item>
- <item row="7" column="1">
- <widget class="QCheckBox" name="cbShowPeapPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_26">
- <property name="text">
- <string>PEAP version:</string>
- </property>
- <property name="buddy">
- <cstring>peapVersion</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KComboBox" name="peapVersion">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>Automatic</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Version 0</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Version 1</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KUrlRequester</class>
- <extends>QFrame</extends>
- <header>kurlrequester.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections>
- <connection>
- <sender>auth</sender>
- <signal>currentIndexChanged(int)</signal>
- <receiver>stackedWidget</receiver>
- <slot>setCurrentIndex(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>156</x>
- <y>16</y>
- </hint>
- <hint type="destinationlabel">
- <x>149</x>
- <y>72</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>stackedWidget</sender>
- <signal>currentChanged(int)</signal>
- <receiver>auth</receiver>
- <slot>setCurrentIndex(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>376</x>
- <y>114</y>
- </hint>
- <hint type="destinationlabel">
- <x>355</x>
- <y>14</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cbAskMd5Password</sender>
- <signal>toggled(bool)</signal>
- <receiver>md5Password</receiver>
- <slot>setDisabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>123</x>
- <y>98</y>
- </hint>
- <hint type="destinationlabel">
- <x>117</x>
- <y>80</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>fastAllowPacProvisioning</sender>
- <signal>toggled(bool)</signal>
- <receiver>pacMethod</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>95</x>
- <y>73</y>
- </hint>
- <hint type="destinationlabel">
- <x>285</x>
- <y>77</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cbAskFastPassword</sender>
- <signal>toggled(bool)</signal>
- <receiver>fastPassword</receiver>
- <slot>setDisabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>311</x>
- <y>211</y>
- </hint>
- <hint type="destinationlabel">
- <x>311</x>
- <y>189</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cbAskTtlsPassword</sender>
- <signal>toggled(bool)</signal>
- <receiver>ttlsPassword</receiver>
- <slot>setDisabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>253</x>
- <y>180</y>
- </hint>
- <hint type="destinationlabel">
- <x>245</x>
- <y>156</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cbAskPeapPassword</sender>
- <signal>toggled(bool)</signal>
- <receiver>peapPassword</receiver>
- <slot>setDisabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>216</x>
- <y>214</y>
- </hint>
- <hint type="destinationlabel">
- <x>215</x>
- <y>191</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <ltinkl@redhat.com></author>
- <class>BondWidget</class>
- <widget class="QWidget" name="BondWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>473</width>
- <height>384</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Interface name:</string>
- </property>
- <property name="buddy">
- <cstring>ifaceName</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="ifaceName"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Bonded connections:</string>
- </property>
- <property name="buddy">
- <cstring>bonds</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" rowspan="4">
- <widget class="KListWidget" name="bonds">
- <property name="editTriggers">
- <set>QAbstractItemView::NoEditTriggers</set>
- </property>
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="uniformItemSizes">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KPushButton" name="btnAdd">
- <property name="text">
- <string>Add...</string>
- </property>
- <property name="icon">
- <iconset theme="list-add">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KPushButton" name="btnEdit">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Edit...</string>
- </property>
- <property name="icon">
- <iconset theme="configure">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KPushButton" name="btnDelete">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Delete</string>
- </property>
- <property name="icon">
- <iconset theme="edit-delete">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Mode:</string>
- </property>
- <property name="buddy">
- <cstring>mode</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="KComboBox" name="mode">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Link monitoring:</string>
- </property>
- <property name="buddy">
- <cstring>linkMonitoring</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KComboBox" name="linkMonitoring">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Monitoring frequency:</string>
- </property>
- <property name="buddy">
- <cstring>monitorFreq</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QSpinBox" name="monitorFreq">
- <property name="suffix">
- <string> ms</string>
- </property>
- <property name="minimum">
- <number>1</number>
- </property>
- <property name="maximum">
- <number>999999999</number>
- </property>
- <property name="value">
- <number>100</number>
- </property>
- </widget>
- </item>
- <item row="6" column="0" colspan="2">
- <widget class="QStackedWidget" name="monitorStack">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="miiPage">
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Link up delay:</string>
- </property>
- <property name="buddy">
- <cstring>upDelay</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QSpinBox" name="upDelay">
- <property name="suffix">
- <string> ms</string>
- </property>
- <property name="maximum">
- <number>999999999</number>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>Link down delay:</string>
- </property>
- <property name="buddy">
- <cstring>downDelay</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QSpinBox" name="downDelay">
- <property name="suffix">
- <string> ms</string>
- </property>
- <property name="maximum">
- <number>999999999</number>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="arpPage">
- <layout class="QFormLayout" name="formLayout_3">
- <item row="0" column="0">
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>ARP targets:</string>
- </property>
- <property name="buddy">
- <cstring>arpTargets</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="arpTargets">
- <property name="toolTip">
- <string>An IP address or comma-separated list of addresses.</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- <customwidget>
- <class>KListWidget</class>
- <extends>QListWidget</extends>
- <header>klistwidget.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>ifaceName</tabstop>
- <tabstop>bonds</tabstop>
- <tabstop>btnAdd</tabstop>
- <tabstop>btnEdit</tabstop>
- <tabstop>btnDelete</tabstop>
- <tabstop>mode</tabstop>
- <tabstop>linkMonitoring</tabstop>
- <tabstop>monitorFreq</tabstop>
- <tabstop>upDelay</tabstop>
- <tabstop>downDelay</tabstop>
- <tabstop>arpTargets</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>linkMonitoring</sender>
- <signal>currentIndexChanged(int)</signal>
- <receiver>monitorStack</receiver>
- <slot>setCurrentIndex(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>310</x>
- <y>273</y>
- </hint>
- <hint type="destinationlabel">
- <x>360</x>
- <y>334</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "bondwidget.h"
-#include "ui_bond.h"
-#include "connectiondetaileditor.h"
-
-#include <QDebug>
-
-#include <NetworkManagerQt/GenericTypes>
-#include <NetworkManagerQt/Connection>
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/ConnectionSettings>
-
-#include <KLocalizedString>
-#include <KMessageBox>
-
-#define NM_SETTING_BOND_OPTION_MII_MONITOR "mii"
-#define NM_SETTING_BOND_OPTION_ARP_MONITOR "arp"
-
-BondWidget::BondWidget(const QString & masterUuid, const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_uuid(masterUuid),
- m_ui(new Ui::BondWidget)
-{
- m_ui->setupUi(this);
-
- // Action buttons and menu
- m_menu = new QMenu(this);
- QAction * action = new QAction(i18n("Ethernet"), this);
- action->setData(NetworkManager::ConnectionSettings::Wired);
- m_menu->addAction(action);
- action = new QAction(i18n("InfiniBand"), this);
- action->setData(NetworkManager::ConnectionSettings::Infiniband);
- m_menu->addAction(action);
- m_ui->btnAdd->setMenu(m_menu);
- connect(m_menu, SIGNAL(triggered(QAction*)), SLOT(addBond(QAction*)));
- connect(m_ui->btnEdit, SIGNAL(clicked()), SLOT(editBond()));
- connect(m_ui->btnDelete, SIGNAL(clicked()), SLOT(deleteBond()));
-
- // mode
- m_ui->mode->addItem(i18nc("bond mode", "Round-robin"), QLatin1String("balance-rr"));
- m_ui->mode->addItem(i18nc("bond mode", "Active backup"), QLatin1String("active-backup"));
- m_ui->mode->addItem(i18nc("bond mode", "Broadcast"), QLatin1String("broadcast"));
- m_ui->mode->addItem(i18nc("bond mode", "802.3ad"), QLatin1String("802.3ad"));
- m_ui->mode->addItem(i18nc("bond mode", "Adaptive transmit load balancing"), QLatin1String("balance-tlb"));
- m_ui->mode->addItem(i18nc("bond mode", "Adaptive load balancing"), QLatin1String("balance-alb"));
-
- // link monitor
- m_ui->linkMonitoring->addItem(i18nc("bond link monitoring", "MII (recommended)"), NM_SETTING_BOND_OPTION_MII_MONITOR);
- m_ui->linkMonitoring->addItem(i18nc("bond link monitoring", "ARP"), NM_SETTING_BOND_OPTION_ARP_MONITOR);
-
- // bonds
- populateBonds();
- connect(m_ui->bonds, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SLOT(currentBondChanged(QListWidgetItem*,QListWidgetItem*)));
- connect(m_ui->bonds, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(editBond()));
-
- connect(m_ui->ifaceName, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->arpTargets, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->linkMonitoring, SIGNAL(currentIndexChanged(int)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
- KAcceleratorManager::manage(m_menu);
-
- if (setting)
- loadConfig(setting);
-}
-
-BondWidget::~BondWidget()
-{
- delete m_ui;
-}
-
-void BondWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::BondSetting::Ptr bondSetting = setting.staticCast<NetworkManager::BondSetting>();
-
- m_ui->ifaceName->setText(bondSetting->interfaceName());
-
- const NMStringMap options = bondSetting->options();
-
- // mode
- int modeIndex = m_ui->mode->findData(options.value(NM_SETTING_BOND_OPTION_MODE));
- if (modeIndex == -1)
- modeIndex = 0;
- m_ui->mode->setCurrentIndex(modeIndex);
-
- const QString arpTargets = options.value(NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
- if (!arpTargets.isEmpty()) { // ARP
- m_ui->linkMonitoring->setCurrentIndex(m_ui->linkMonitoring->findData(NM_SETTING_BOND_OPTION_ARP_MONITOR));
-
- bool ok = false;
- const int arpMonFreq = options.value(NM_SETTING_BOND_OPTION_ARP_INTERVAL).toInt(&ok);
- if (ok && arpMonFreq > 0)
- m_ui->monitorFreq->setValue(arpMonFreq);
-
- m_ui->arpTargets->setText(arpTargets);
- } else { // MII
- m_ui->linkMonitoring->setCurrentIndex(m_ui->linkMonitoring->findData(NM_SETTING_BOND_OPTION_MII_MONITOR));
-
- bool ok = false;
- const int miiMonFreq = options.value(NM_SETTING_BOND_OPTION_MIIMON).toInt(&ok);
- if (ok && miiMonFreq > 0)
- m_ui->monitorFreq->setValue(miiMonFreq);
-
- ok = false;
- const int upDelay = options.value(NM_SETTING_BOND_OPTION_UPDELAY).toInt(&ok);
- if (ok && upDelay > 0)
- m_ui->upDelay->setValue(upDelay);
-
- ok = false;
- const int downDelay = options.value(NM_SETTING_BOND_OPTION_DOWNDELAY).toInt(&ok);
- if (ok && downDelay > 0)
- m_ui->upDelay->setValue(downDelay);
- }
-}
-
-QVariantMap BondWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned)
-
- NetworkManager::BondSetting setting;
- setting.setInterfaceName(m_ui->ifaceName->text());
-
- NMStringMap options;
- options.insert(NM_SETTING_BOND_OPTION_MODE, m_ui->mode->itemData(m_ui->mode->currentIndex()).toString());
-
- if (m_ui->linkMonitoring->itemData(m_ui->linkMonitoring->currentIndex()).toString() == NM_SETTING_BOND_OPTION_MII_MONITOR) { // MII
- options.insert(NM_SETTING_BOND_OPTION_MIIMON, QString::number(m_ui->monitorFreq->value()));
- const int upDelay = m_ui->upDelay->value();
- if (upDelay)
- options.insert(NM_SETTING_BOND_OPTION_UPDELAY, QString::number(upDelay));
- const int downDelay = m_ui->downDelay->value();
- if (downDelay)
- options.insert(NM_SETTING_BOND_OPTION_DOWNDELAY, QString::number(downDelay));
- } else { // ARP
- options.insert(NM_SETTING_BOND_OPTION_ARP_INTERVAL, QString::number(m_ui->monitorFreq->value()));
- const QString arpTargets = m_ui->arpTargets->text();
- if (!arpTargets.isEmpty())
- options.insert(NM_SETTING_BOND_OPTION_ARP_IP_TARGET, arpTargets);
- }
-
- setting.setOptions(options);
- return setting.toMap();
-}
-
-void BondWidget::addBond(QAction *action)
-{
- qDebug() << "Adding bonded connection:" << action->data();
- qDebug() << "Master UUID:" << m_uuid;
- qDebug() << "Slave type:" << type();
-
- QPointer<ConnectionDetailEditor> bondEditor = new ConnectionDetailEditor(NetworkManager::ConnectionSettings::ConnectionType(action->data().toInt()),
- this, m_uuid, type());
- if (bondEditor->exec() == QDialog::Accepted) {
- qDebug() << "Saving slave connection";
- connect(NetworkManager::settingsNotifier(), SIGNAL(connectionAddComplete(QString,bool,QString)),
- this, SLOT(bondAddComplete(QString,bool,QString)));
- }
-
- if (bondEditor) {
- bondEditor->deleteLater();
- }
-}
-
-void BondWidget::currentBondChanged(QListWidgetItem *current, QListWidgetItem *previous)
-{
- Q_UNUSED(previous)
-
- m_ui->btnEdit->setEnabled(current);
- m_ui->btnDelete->setEnabled(current);
-}
-
-void BondWidget::bondAddComplete(const QString &uuid, bool success, const QString &msg)
-{
- qDebug() << Q_FUNC_INFO << uuid << success << msg;
-
- // find the slave connection with matching UUID
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(uuid);
- if (connection && connection->settings()->master() == m_uuid && success) {
- const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType()));
- QListWidgetItem * slaveItem = new QListWidgetItem(label, m_ui->bonds);
- slaveItem->setData(Qt::UserRole, uuid);
- slotWidgetChanged();
- } else {
- qWarning() << "Bonded connection not added:" << msg;
- }
-
- disconnect(NetworkManager::settingsNotifier(), SIGNAL(connectionAddComplete(QString,bool,QString)),
- this, SLOT(bondAddComplete(QString,bool,QString)));
-}
-
-void BondWidget::editBond()
-{
- QListWidgetItem * currentItem = m_ui->bonds->currentItem();
- if (!currentItem)
- return;
-
- const QString uuid = currentItem->data(Qt::UserRole).toString();
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(uuid);
-
- if (connection) {
- qDebug() << "Editing bonded connection" << currentItem->text() << uuid;
- QPointer<ConnectionDetailEditor> bondEditor = new ConnectionDetailEditor(connection->settings(), this);
- if (bondEditor->exec() == QDialog::Accepted) {
- connect(connection.data(), SIGNAL(updated()), this, SLOT(populateBonds()));
- }
-
- if (bondEditor) {
- bondEditor->deleteLater();
- }
- }
-}
-
-void BondWidget::deleteBond()
-{
- QListWidgetItem * currentItem = m_ui->bonds->currentItem();
- if (!currentItem)
- return;
-
- const QString uuid = currentItem->data(Qt::UserRole).toString();
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(uuid);
-
- if (connection) {
- qDebug() << "About to delete bonded connection" << currentItem->text() << uuid;
- if (KMessageBox::questionYesNo(this, i18n("Do you want to remove the connection '%1'?", connection->name()), i18n("Remove Connection"),
- KStandardGuiItem::remove(), KStandardGuiItem::no(), QString(), KMessageBox::Dangerous)
- == KMessageBox::Yes) {
- connection->remove();
- delete currentItem;
- slotWidgetChanged();
- }
- }
-}
-
-void BondWidget::populateBonds()
-{
- m_ui->bonds->clear();
-
- foreach (const NetworkManager::Connection::Ptr &connection, NetworkManager::listConnections()) {
- NetworkManager::ConnectionSettings::Ptr settings = connection->settings();
- if (settings->master() == m_uuid && settings->slaveType() == type()) {
- const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType()));
- QListWidgetItem * slaveItem = new QListWidgetItem(label, m_ui->bonds);
- slaveItem->setData(Qt::UserRole, connection->uuid());
- }
- }
-}
-
-bool BondWidget::isValid() const
-{
- if (m_ui->linkMonitoring->itemData(m_ui->linkMonitoring->currentIndex()).toString() == NM_SETTING_BOND_OPTION_ARP_MONITOR) {
- const QStringList ipAddresses = m_ui->arpTargets->text().split(',');
- if (ipAddresses.isEmpty()) {
- return false;
- }
-
- foreach (const QString & ip, ipAddresses) {
- QHostAddress ipAddress(ip);
- if (ipAddress.isNull()) {
- return false;
- }
- }
- }
-
- return !m_ui->ifaceName->text().isEmpty() && m_ui->bonds->count() > 0;
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_BOND_WIDGET_H
-#define PLASMA_NM_BOND_WIDGET_H
-
-#include <QWidget>
-#include <QMenu>
-#include <QListWidgetItem>
-
-#include <NetworkManagerQt/BondSetting>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class BondWidget;
-}
-
-class PLASMA_NM_EXPORT BondWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit BondWidget(const QString & masterUuid, const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(),
- QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~BondWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void addBond(QAction * action);
- void currentBondChanged(QListWidgetItem * current, QListWidgetItem * previous);
- void bondAddComplete(const QString &uuid, bool success, const QString & msg);
-
- void editBond();
- void deleteBond();
-
- void populateBonds();
-
-private:
- QString m_uuid;
- Ui::BondWidget * m_ui;
- QMenu * m_menu;
-};
-
-#endif // PLASMA_NM_BOND_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <ltinkl@redhat.com></author>
- <class>BridgeWidget</class>
- <widget class="QWidget" name="BridgeWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>436</width>
- <height>449</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Interface name:</string>
- </property>
- <property name="buddy">
- <cstring>ifaceName</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="2">
- <widget class="KLineEdit" name="ifaceName"/>
- </item>
- <item row="1" column="0" colspan="3">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>Bridged connections:</string>
- </property>
- <property name="buddy">
- <cstring>bridges</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="3">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" rowspan="4">
- <widget class="KListWidget" name="bridges">
- <property name="editTriggers">
- <set>QAbstractItemView::NoEditTriggers</set>
- </property>
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="uniformItemSizes">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KPushButton" name="btnAdd">
- <property name="text">
- <string>Add...</string>
- </property>
- <property name="icon">
- <iconset theme="list-add">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KPushButton" name="btnEdit">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Edit...</string>
- </property>
- <property name="icon">
- <iconset theme="configure">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KPushButton" name="btnDelete">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Delete</string>
- </property>
- <property name="icon">
- <iconset theme="edit-delete">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Aging time:</string>
- </property>
- <property name="buddy">
- <cstring>agingTime</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="2">
- <widget class="QSpinBox" name="agingTime">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="suffix">
- <string comment="seconds"> s</string>
- </property>
- <property name="maximum">
- <number>999999999</number>
- </property>
- <property name="value">
- <number>300</number>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="3">
- <widget class="QGroupBox" name="stpGroup">
- <property name="title">
- <string>Enable STP (Spanning Tree Protocol)</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Priority:</string>
- </property>
- <property name="buddy">
- <cstring>priority</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QSpinBox" name="priority">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximum">
- <number>999999999</number>
- </property>
- <property name="value">
- <number>128</number>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Forward delay:</string>
- </property>
- <property name="buddy">
- <cstring>forwardDelay</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QSpinBox" name="forwardDelay">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="suffix">
- <string comment="seconds"> s</string>
- </property>
- <property name="maximum">
- <number>999999999</number>
- </property>
- <property name="value">
- <number>15</number>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Hello time:</string>
- </property>
- <property name="buddy">
- <cstring>helloTime</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QSpinBox" name="helloTime">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="suffix">
- <string comment="seconds"> s</string>
- </property>
- <property name="maximum">
- <number>999999999</number>
- </property>
- <property name="value">
- <number>2</number>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Max age:</string>
- </property>
- <property name="buddy">
- <cstring>maxAge</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QSpinBox" name="maxAge">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="suffix">
- <string comment="seconds"> s</string>
- </property>
- <property name="maximum">
- <number>999999999</number>
- </property>
- <property name="value">
- <number>20</number>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- <customwidget>
- <class>KListWidget</class>
- <extends>QListWidget</extends>
- <header>klistwidget.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>ifaceName</tabstop>
- <tabstop>bridges</tabstop>
- <tabstop>btnAdd</tabstop>
- <tabstop>btnEdit</tabstop>
- <tabstop>btnDelete</tabstop>
- <tabstop>agingTime</tabstop>
- <tabstop>stpGroup</tabstop>
- <tabstop>priority</tabstop>
- <tabstop>forwardDelay</tabstop>
- <tabstop>helloTime</tabstop>
- <tabstop>maxAge</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "bridgewidget.h"
-#include "ui_bridge.h"
-#include "connectiondetaileditor.h"
-
-#include <QDebug>
-
-#include <NetworkManagerQt/GenericTypes>
-#include <NetworkManagerQt/Connection>
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/ConnectionSettings>
-
-#include <KLocalizedString>
-#include <KMessageBox>
-
-BridgeWidget::BridgeWidget(const QString & masterUuid, const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_uuid(masterUuid),
- m_ui(new Ui::BridgeWidget)
-{
- m_ui->setupUi(this);
-
- // Action buttons and menu
- m_menu = new QMenu(this);
- QAction * action = new QAction(i18n("Ethernet"), this);
- action->setData(NetworkManager::ConnectionSettings::Wired);
- m_menu->addAction(action);
- action = new QAction(i18n("VLAN"), this);
- action->setData(NetworkManager::ConnectionSettings::Vlan);
- m_menu->addAction(action);
- action = new QAction(i18n("Wireless"), this);
- action->setData(NetworkManager::ConnectionSettings::Wireless);
- m_menu->addAction(action);
- m_ui->btnAdd->setMenu(m_menu);
- connect(m_menu, SIGNAL(triggered(QAction*)), SLOT(addBridge(QAction*)));
- connect(m_ui->btnEdit, SIGNAL(clicked()), SLOT(editBridge()));
- connect(m_ui->btnDelete, SIGNAL(clicked()), SLOT(deleteBridge()));
-
- // bridges
- populateBridges();
- connect(m_ui->bridges, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SLOT(currentBridgeChanged(QListWidgetItem*,QListWidgetItem*)));
- connect(m_ui->bridges, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(editBridge()));
-
- connect(m_ui->ifaceName, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
- KAcceleratorManager::manage(m_menu);
-
- if (setting)
- loadConfig(setting);
-}
-
-BridgeWidget::~BridgeWidget()
-{
- delete m_ui;
-}
-
-void BridgeWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::BridgeSetting::Ptr bridgeSetting = setting.staticCast<NetworkManager::BridgeSetting>();
-
- m_ui->ifaceName->setText(bridgeSetting->interfaceName());
- m_ui->agingTime->setValue(bridgeSetting->agingTime());
-
- const bool stp = bridgeSetting->stp();
- m_ui->stpGroup->setChecked(stp);
- if (stp) {
- m_ui->priority->setValue(bridgeSetting->priority());
- m_ui->forwardDelay->setValue(bridgeSetting->forwardDelay());
- m_ui->helloTime->setValue(bridgeSetting->helloTime());
- m_ui->maxAge->setValue(bridgeSetting->maxAge());
- }
-}
-
-QVariantMap BridgeWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned)
-
- NetworkManager::BridgeSetting setting;
- setting.setInterfaceName(m_ui->ifaceName->text());
- setting.setAgingTime(m_ui->agingTime->value());
-
- const bool stp = m_ui->stpGroup->isChecked();
- setting.setStp(stp);
- if (stp) {
- setting.setPriority(m_ui->priority->value());
- setting.setForwardDelay(m_ui->forwardDelay->value());
- setting.setHelloTime(m_ui->helloTime->value());
- setting.setMaxAge(m_ui->maxAge->value());
- }
-
- return setting.toMap();
-}
-
-void BridgeWidget::addBridge(QAction *action)
-{
- qDebug() << "Adding bridged connection:" << action->data();
- qDebug() << "Master UUID:" << m_uuid;
- qDebug() << "Slave type:" << type();
-
- QPointer<ConnectionDetailEditor> bridgeEditor = new ConnectionDetailEditor(NetworkManager::ConnectionSettings::ConnectionType(action->data().toInt()),
- this, m_uuid, type());
- if (bridgeEditor->exec() == QDialog::Accepted) {
- qDebug() << "Saving slave connection";
- connect(NetworkManager::settingsNotifier(), SIGNAL(connectionAddComplete(QString,bool,QString)),
- this, SLOT(bridgeAddComplete(QString,bool,QString)));
- }
-
- if (bridgeEditor) {
- bridgeEditor->deleteLater();
- }
-}
-
-void BridgeWidget::currentBridgeChanged(QListWidgetItem *current, QListWidgetItem *previous)
-{
- Q_UNUSED(previous)
-
- m_ui->btnEdit->setEnabled(current);
- m_ui->btnDelete->setEnabled(current);
-}
-
-void BridgeWidget::bridgeAddComplete(const QString &uuid, bool success, const QString &msg)
-{
- qDebug() << Q_FUNC_INFO << uuid << success << msg;
-
- // find the slave connection with matching UUID
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(uuid);
- if (connection && connection->settings()->master() == m_uuid && success) {
- const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType()));
- QListWidgetItem * slaveItem = new QListWidgetItem(label, m_ui->bridges);
- slaveItem->setData(Qt::UserRole, uuid);
- slotWidgetChanged();
- } else {
- qWarning() << "Bridged connection not added:" << msg;
- }
-
- disconnect(NetworkManager::settingsNotifier(), SIGNAL(connectionAddComplete(QString,bool,QString)),
- this, SLOT(bridgeAddComplete(QString,bool,QString)));
-}
-
-void BridgeWidget::editBridge()
-{
- QListWidgetItem * currentItem = m_ui->bridges->currentItem();
- if (!currentItem)
- return;
-
- const QString uuid = currentItem->data(Qt::UserRole).toString();
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(uuid);
-
- if (connection) {
- qDebug() << "Editing bridged connection" << currentItem->text() << uuid;
- QPointer<ConnectionDetailEditor> bridgeEditor = new ConnectionDetailEditor(connection->settings(), this);
- if (bridgeEditor->exec() == QDialog::Accepted) {
- connect(connection.data(), SIGNAL(updated()), this, SLOT(populateBridges()));
- }
-
- if (bridgeEditor) {
- bridgeEditor->deleteLater();
- }
- }
-}
-
-void BridgeWidget::deleteBridge()
-{
- QListWidgetItem * currentItem = m_ui->bridges->currentItem();
- if (!currentItem)
- return;
-
- const QString uuid = currentItem->data(Qt::UserRole).toString();
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(uuid);
-
- if (connection) {
- qDebug() << "About to delete bridged connection" << currentItem->text() << uuid;
- if (KMessageBox::questionYesNo(this, i18n("Do you want to remove the connection '%1'?", connection->name()), i18n("Remove Connection"), KStandardGuiItem::remove(),
- KStandardGuiItem::no(), QString(), KMessageBox::Dangerous)
- == KMessageBox::Yes) {
- connection->remove();
- delete currentItem;
- slotWidgetChanged();
- }
- }
-}
-
-void BridgeWidget::populateBridges()
-{
- m_ui->bridges->clear();
-
- foreach (const NetworkManager::Connection::Ptr &connection, NetworkManager::listConnections()) {
- NetworkManager::ConnectionSettings::Ptr settings = connection->settings();
- if (settings->master() == m_uuid && settings->slaveType() == type()) {
- const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType()));
- QListWidgetItem * slaveItem = new QListWidgetItem(label, m_ui->bridges);
- slaveItem->setData(Qt::UserRole, connection->uuid());
- }
- }
-}
-
-bool BridgeWidget::isValid() const
-{
- return !m_ui->ifaceName->text().isEmpty() && m_ui->bridges->count() > 0;
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_BRIDGE_WIDGET_H
-#define PLASMA_NM_BRIDGE_WIDGET_H
-
-#include <QWidget>
-#include <QMenu>
-#include <QListWidgetItem>
-
-#include <NetworkManagerQt/BridgeSetting>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class BridgeWidget;
-}
-
-class PLASMA_NM_EXPORT BridgeWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit BridgeWidget(const QString & masterUuid, const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(),
- QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~BridgeWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void addBridge(QAction * action);
- void currentBridgeChanged(QListWidgetItem * current, QListWidgetItem * previous);
- void bridgeAddComplete(const QString &uuid, bool success, const QString & msg);
-
- void editBridge();
- void deleteBridge();
-
- void populateBridges();
-
-private:
- QString m_uuid;
- Ui::BridgeWidget * m_ui;
- QMenu * m_menu;
-};
-
-#endif // PLASMA_NM_BRIDGE_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <ltinkl@redhat.com></author>
- <class>BtWidget</class>
- <widget class="QWidget" name="BtWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Address of the device:</string>
- </property>
- <property name="buddy">
- <cstring>bdaddr</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="HwAddrComboBox" name="bdaddr">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Connection type:</string>
- </property>
- <property name="buddy">
- <cstring>type</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KComboBox" name="type">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>HwAddrComboBox</class>
- <extends>QComboBox</extends>
- <header>hwaddrcombobox.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "btwidget.h"
-#include "ui_bt.h"
-#include "uiutils.h"
-
-#include <KLocalizedString>
-
-#include <NetworkManagerQt/Utils>
-
-BtWidget::BtWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::BtWidget)
-{
- m_ui->setupUi(this);
-
- m_ui->type->addItem(i18n("DUN (dial up networking)"), NetworkManager::BluetoothSetting::Dun);
- m_ui->type->addItem(i18n("PAN (personal area network)"), NetworkManager::BluetoothSetting::Panu);
-
- m_ui->type->setEnabled(false);
-
- connect(m_ui->bdaddr, SIGNAL(hwAddressChanged()), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (setting)
- loadConfig(setting);
-}
-
-BtWidget::~BtWidget()
-{
- delete m_ui;
-}
-
-void BtWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::BluetoothSetting::Ptr btSetting = setting.staticCast<NetworkManager::BluetoothSetting>();
-
- m_ui->bdaddr->init(NetworkManager::Device::Bluetooth, NetworkManager::Utils::macAddressAsString(btSetting->bluetoothAddress()));
- m_ui->type->setCurrentIndex(m_ui->type->findData(btSetting->profileType()));
-}
-
-QVariantMap BtWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned);
-
- NetworkManager::BluetoothSetting btSetting;
-
- btSetting.setBluetoothAddress(NetworkManager::Utils::macAddressFromString(m_ui->bdaddr->hwAddress()));
- btSetting.setProfileType(static_cast<NetworkManager::BluetoothSetting::ProfileType>(m_ui->type->itemData(m_ui->type->currentIndex()).toInt()));
-
- return btSetting.toMap();
-}
-
-bool BtWidget::isValid() const
-{
- return m_ui->bdaddr->isValid();
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_BT_WIDGET_H
-#define PLASMA_NM_BT_WIDGET_H
-
-#include <QtGui/QWidget>
-
-#include <NetworkManagerQt/BluetoothSetting>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class BtWidget;
-}
-
-class PLASMA_NM_EXPORT BtWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit BtWidget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~BtWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private:
- Ui::BtWidget * m_ui;
-};
-
-#endif // PLASMA_NM_BT_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>CdmaWidget</class>
- <widget class="QWidget" name="CdmaWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Number:</string>
- </property>
- <property name="buddy">
- <cstring>number</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="number">
- <property name="text">
- <string notr="true">#777</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>username</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="username"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>password</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KLineEdit" name="password">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QCheckBox" name="cbShowPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>number</tabstop>
- <tabstop>username</tabstop>
- <tabstop>password</tabstop>
- <tabstop>cbShowPassword</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "cdmawidget.h"
-#include "ui_cdma.h"
-
-#include <NetworkManagerQt/CdmaSetting>
-
-CdmaWidget::CdmaWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::CdmaWidget)
-{
- m_ui->setupUi(this);
-
- connect(m_ui->cbShowPassword, SIGNAL(toggled(bool)), SLOT(showPassword(bool)));
-
- KAcceleratorManager::manage(this);
-
- if (setting)
- loadConfig(setting);
-}
-
-CdmaWidget::~CdmaWidget()
-{
- delete m_ui;
-}
-
-void CdmaWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::CdmaSetting::Ptr cdmaSetting = setting.staticCast<NetworkManager::CdmaSetting>();
- const QString number = cdmaSetting->number();
- if (!number.isEmpty())
- m_ui->number->setText(number);
- m_ui->username->setText(cdmaSetting->username());
- m_ui->password->setText(cdmaSetting->password());
-}
-
-QVariantMap CdmaWidget::setting(bool agentOwned) const
-{
- NetworkManager::CdmaSetting cdmaSetting;
- if (!m_ui->number->text().isEmpty())
- cdmaSetting.setNumber(m_ui->number->text());
- if (!m_ui->username->text().isEmpty())
- cdmaSetting.setUsername(m_ui->username->text());
- if (!m_ui->password->text().isEmpty())
- cdmaSetting.setPassword(m_ui->password->text());
-
- if (agentOwned) {
- cdmaSetting.setPasswordFlags(NetworkManager::Setting::AgentOwned);
- }
-
- return cdmaSetting.toMap();
-}
-
-void CdmaWidget::showPassword(bool show)
-{
- m_ui->password->setPasswordMode(!show);
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_CDMA_WIDGET_H
-#define PLASMA_NM_CDMA_WIDGET_H
-
-#include <QtGui/QWidget>
-
-#include <NetworkManagerQt/Setting>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class CdmaWidget;
-}
-
-class PLASMA_NM_EXPORT CdmaWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit CdmaWidget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~CdmaWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
-private slots:
- void showPassword(bool show);
-
-private:
- Ui::CdmaWidget * m_ui;
-};
-
-#endif // PLASMA_NM_CDMA_WIDGET_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "connectionwidget.h"
-#include "ui_connectionwidget.h"
-#include "advancedpermissionswidget.h"
-
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/Connection>
-#include <NetworkManagerQt/ConnectionSettings>
-
-#include <KUser>
-#include <KAcceleratorManager>
-#include <KDialog>
-#include <KLocale>
-
-ConnectionWidget::ConnectionWidget(const NetworkManager::ConnectionSettings::Ptr &settings, QWidget* parent, Qt::WindowFlags f):
- QWidget(parent, f),
- m_widget(new Ui::ConnectionWidget),
- m_type(settings->connectionType()),
- m_masterUuid(settings->master()),
- m_slaveType(settings->slaveType())
-{
- m_widget->setupUi(this);
-
- m_widget->firewallZone->addItems(firewallZones());
-
- // VPN combo
- populateVpnConnections();
- if (settings->connectionType() == NetworkManager::ConnectionSettings::Vpn) {
- m_widget->autoconnectVpn->setEnabled(false);
- m_widget->vpnCombobox->setEnabled(false);
- m_widget->autoconnect->setEnabled(false);
- } else {
- m_widget->autoconnectVpn->setEnabled(true);
- m_widget->autoconnect->setEnabled(true);
- }
-
- connect(m_widget->autoconnectVpn, SIGNAL(toggled(bool)), SLOT(autoVpnToggled(bool)));
-
- if (settings)
- loadConfig(settings);
-
- m_tmpSetting.setPermissions(settings->permissions());
-
- KAcceleratorManager::manage(this);
-
- connect(m_widget->pushButtonPermissions, SIGNAL(clicked(bool)),
- SLOT(openAdvancedPermissions()));
-}
-
-ConnectionWidget::~ConnectionWidget()
-{
- delete m_widget;
-}
-
-void ConnectionWidget::loadConfig(const NetworkManager::ConnectionSettings::Ptr &settings)
-{
- if (settings->permissions().isEmpty()) {
- m_widget->allUsers->setChecked(true);
- } else {
- m_widget->allUsers->setChecked(false);
- }
-
- const QString zone = settings->zone();
- m_widget->firewallZone->setCurrentIndex(m_widget->firewallZone->findText(zone));
-
- const QStringList secondaries = settings->secondaries();
- const QStringList vpnKeys = vpnConnections().keys();
- if (!secondaries.isEmpty() && !vpnKeys.isEmpty()) {
- foreach (const QString & vpnKey, vpnKeys) {
- if (secondaries.contains(vpnKey)) {
- m_widget->vpnCombobox->setCurrentIndex(m_widget->vpnCombobox->findData(vpnKey));
- m_widget->autoconnectVpn->setChecked(true);
- break;
- }
- }
- } else {
- m_widget->autoconnectVpn->setChecked(false);
- }
-
- m_widget->autoconnect->setChecked(settings->autoconnect());
-}
-
-NMVariantMapMap ConnectionWidget::setting() const
-{
- NetworkManager::ConnectionSettings settings;
-
- settings.setConnectionType(m_type);
- settings.setAutoconnect(m_widget->autoconnect->isChecked());
- settings.setMaster(m_masterUuid);
- settings.setSlaveType(m_slaveType);
-
- if (m_widget->allUsers->isChecked()) {
- settings.setPermissions(QHash<QString, QString>());
- } else {
- if (m_tmpSetting.permissions().isEmpty()) {
- settings.addToPermissions(KUser().loginName(), QString());
- } else {
- settings.setPermissions(m_tmpSetting.permissions());
- }
- }
-
- if (m_widget->autoconnectVpn->isChecked() && m_widget->vpnCombobox->count() > 0) {
- settings.setSecondaries(QStringList() << m_widget->vpnCombobox->itemData(m_widget->vpnCombobox->currentIndex()).toString());
- }
-
- const QString zone = m_widget->firewallZone->currentText();
- if (!zone.isEmpty()) {
- settings.setZone(zone);
- }
-
- return settings.toMap();
-}
-
-void ConnectionWidget::autoVpnToggled(bool on)
-{
- m_widget->vpnCombobox->setEnabled(on);
-}
-
-void ConnectionWidget::openAdvancedPermissions()
-{
- QPointer<KDialog> dialog = new KDialog(this);
- dialog->setCaption(i18nc("@title:window advanced permissions editor",
- "Advanced Permissions Editor"));
- dialog->setButtons(KDialog::Ok | KDialog::Cancel);
- AdvancedPermissionsWidget permissions(m_tmpSetting.permissions());
- dialog->setMainWidget(&permissions);
- if (dialog->exec() == QDialog::Accepted) {
- m_tmpSetting.setPermissions(permissions.currentUsers());
- }
-
- if (dialog) {
- dialog->deleteLater();
- }
-}
-
-NMStringMap ConnectionWidget::vpnConnections() const
-{
- NetworkManager::Connection::List list = NetworkManager::listConnections();
- NMStringMap result;
-
- foreach (const NetworkManager::Connection::Ptr & conn, list) {
- NetworkManager::ConnectionSettings::Ptr conSet = conn->settings();
- if (conSet->connectionType() == NetworkManager::ConnectionSettings::Vpn) {
- //qDebug() << "Found VPN" << conSet->id() << conSet->uuid();
- result.insert(conSet->uuid(), conSet->id());
- }
- }
-
- return result;
-}
-
-QStringList ConnectionWidget::firewallZones() const
-{
- QDBusMessage msg = QDBusMessage::createMethodCall("org.fedoraproject.FirewallD1", "/org/fedoraproject/FirewallD1", "org.fedoraproject.FirewallD1.zone",
- "getZones");
- QDBusPendingReply<QStringList> reply = QDBusConnection::systemBus().asyncCall(msg);
- reply.waitForFinished();
- if (reply.isValid())
- return reply.value();
-
- return QStringList();
-}
-
-void ConnectionWidget::populateVpnConnections()
-{
- QMapIterator<QString,QString> it(vpnConnections());
- while (it.hasNext()) {
- it.next();
- m_widget->vpnCombobox->addItem(it.value(), it.key());
- }
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_CONNECTION_WIDGET_H
-#define PLASMA_NM_CONNECTION_WIDGET_H
-
-#include <QtGui/QWidget>
-
-#include <NetworkManagerQt/ConnectionSettings>
-
-namespace Ui
-{
-class ConnectionWidget;
-}
-
-class ConnectionWidget : public QWidget
-{
-Q_OBJECT
-
-public:
- explicit ConnectionWidget(const NetworkManager::ConnectionSettings::Ptr &settings = NetworkManager::ConnectionSettings::Ptr(),
- QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~ConnectionWidget();
-
- void loadConfig(const NetworkManager::ConnectionSettings::Ptr &settings);
-
- NMVariantMapMap setting() const;
-
-private slots:
- void autoVpnToggled(bool on);
- void openAdvancedPermissions();
-
-private:
- // list of VPN: UUID, name
- NMStringMap vpnConnections() const;
- // list of firewalld zones
- QStringList firewallZones() const;
-
- void populateVpnConnections();
- Ui::ConnectionWidget * m_widget;
- NetworkManager::ConnectionSettings m_tmpSetting;
- NetworkManager::ConnectionSettings::ConnectionType m_type;
- QString m_masterUuid;
- QString m_slaveType;
-};
-
-#endif // PLASMA_NM_CONNECTION_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ConnectionWidget</class>
- <widget class="QWidget" name="ConnectionWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>586</width>
- <height>441</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="8" column="1">
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>118</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="0" colspan="3">
- <widget class="QCheckBox" name="autoconnect">
- <property name="text">
- <string>Automatically connect to this network when it is available</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="5" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QCheckBox" name="allUsers">
- <property name="text">
- <string>All users may connect to this network</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="KPushButton" name="pushButtonPermissions">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Edit advanced permissions for this connection</string>
- </property>
- <property name="whatsThis">
- <string>Fine-grained permissions editor for this connection. It lets you choose which users can activate/modify/delete this connection.</string>
- </property>
- <property name="text">
- <string>Advanced...</string>
- </property>
- <property name="icon">
- <iconset theme="preferences-desktop-user">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Firewall zone:</string>
- </property>
- <property name="buddy">
- <cstring>firewallZone</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="3">
- <widget class="QCheckBox" name="autoconnectVpn">
- <property name="text">
- <string>Automatically connect to VPN when using this connection</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="3">
- <widget class="KComboBox" name="vpnCombobox">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="7" column="0" colspan="3">
- <widget class="KComboBox" name="firewallZone">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- <property name="insertPolicy">
- <enum>QComboBox::InsertAlphabetically</enum>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>autoconnect</tabstop>
- <tabstop>allUsers</tabstop>
- <tabstop>pushButtonPermissions</tabstop>
- <tabstop>autoconnectVpn</tabstop>
- <tabstop>vpnCombobox</tabstop>
- <tabstop>firewallZone</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>allUsers</sender>
- <signal>toggled(bool)</signal>
- <receiver>pushButtonPermissions</receiver>
- <slot>setDisabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>199</x>
- <y>39</y>
- </hint>
- <hint type="destinationlabel">
- <x>382</x>
- <y>51</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <lukas@redhat.com></author>
- <class>GsmWidget</class>
- <widget class="QWidget" name="GsmWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>554</width>
- <height>461</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QGroupBox" name="basicGroup">
- <property name="title">
- <string>Basic</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Number:</string>
- </property>
- <property name="buddy">
- <cstring>number</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="KLineEdit" name="number">
- <property name="text">
- <string notr="true">*99#</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>username</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="KLineEdit" name="username"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>password</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="KLineEdit" name="password">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="passwordStorage">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="advGroup">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="title">
- <string>Advanced</string>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="3" column="1" colspan="2">
- <widget class="QCheckBox" name="roaming">
- <property name="text">
- <string>Allow roaming if home network is not available</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>APN:</string>
- </property>
- <property name="buddy">
- <cstring>apn</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="labelNetworkId">
- <property name="text">
- <string>Network ID:</string>
- </property>
- <property name="buddy">
- <cstring>networkId</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="apn">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Type:</string>
- </property>
- <property name="buddy">
- <cstring>type</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>PIN:</string>
- </property>
- <property name="buddy">
- <cstring>pin</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="networkId"/>
- </item>
- <item row="2" column="1">
- <widget class="KComboBox" name="type">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="KLineEdit" name="pin">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="pinStorage">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>130</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QCheckBox" name="cbShowPasswords">
- <property name="text">
- <string>Show passwords</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>number</tabstop>
- <tabstop>username</tabstop>
- <tabstop>password</tabstop>
- <tabstop>passwordStorage</tabstop>
- <tabstop>apn</tabstop>
- <tabstop>networkId</tabstop>
- <tabstop>type</tabstop>
- <tabstop>roaming</tabstop>
- <tabstop>pin</tabstop>
- <tabstop>pinStorage</tabstop>
- <tabstop>cbShowPasswords</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013, 2014 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "gsmwidget.h"
-#include "ui_gsm.h"
-
-#include <KLocalizedString>
-
-#include <NetworkManagerQt/GsmSetting>
-
-GsmWidget::GsmWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::GsmWidget)
-{
- m_ui->setupUi(this);
-
- // Network ID not supported yet in NM
- m_ui->labelNetworkId->setHidden(true);
- m_ui->networkId->setHidden(true);
-
- m_ui->type->addItem(i18nc("GSM network type", "Any"), NetworkManager::GsmSetting::Any);
- m_ui->type->addItem(i18n("3G Only (UMTS/HSPA)"), NetworkManager::GsmSetting::Only3G);
- m_ui->type->addItem(i18n("2G Only (GPRS/EDGE)"), NetworkManager::GsmSetting::GprsEdgeOnly);
- m_ui->type->addItem(i18n("Prefer 3G (UMTS/HSPA)"), NetworkManager::GsmSetting::Prefer3G);
- m_ui->type->addItem(i18n("Prefer 2G (GPRS/EDGE)"), NetworkManager::GsmSetting::Prefer2G);
- m_ui->type->addItem(i18n("Prefer 4G (LTE)"), NetworkManager::GsmSetting::Prefer4GLte);
- m_ui->type->addItem(i18n("4G Only (LTE)"), NetworkManager::GsmSetting::Only4GLte);
-
- connect(m_ui->cbShowPasswords, SIGNAL(toggled(bool)), SLOT(showPasswords(bool)));
- connect(m_ui->pinStorage, SIGNAL(currentIndexChanged(int)), SLOT(pinStorageChanged(int)));
- connect(m_ui->passwordStorage, SIGNAL(currentIndexChanged(int)), SLOT(passwordStorageChanged(int)));
-
- connect(m_ui->apn, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (setting)
- loadConfig(setting);
-}
-
-GsmWidget::~GsmWidget()
-{
- delete m_ui;
-}
-
-void GsmWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::GsmSetting::Ptr gsmSetting = setting.staticCast<NetworkManager::GsmSetting>();
-
- const QString number = gsmSetting->number();
- if (!number.isEmpty())
- m_ui->number->setText(number);
- m_ui->username->setText(gsmSetting->username());
- m_ui->password->setText(gsmSetting->password());
- if (gsmSetting->passwordFlags().testFlag(NetworkManager::Setting::None) ||
- gsmSetting->passwordFlags().testFlag(NetworkManager::Setting::AgentOwned)) {
- m_ui->passwordStorage->setCurrentIndex(SettingWidget::EnumPasswordStorageType::Store);
- } else if (gsmSetting->passwordFlags().testFlag(NetworkManager::Setting::NotSaved)) {
- m_ui->passwordStorage->setCurrentIndex(SettingWidget::EnumPasswordStorageType::AlwaysAsk);
- } else {
- m_ui->passwordStorage->setCurrentIndex(SettingWidget::EnumPasswordStorageType::NotRequired);
- }
- m_ui->apn->setText(gsmSetting->apn());
- m_ui->networkId->setText(gsmSetting->networkId());
- if (gsmSetting->networkType() != NetworkManager::GsmSetting::Any)
- m_ui->type->setCurrentIndex(m_ui->type->findData(static_cast<int>(gsmSetting->networkType())));
- m_ui->roaming->setChecked(!gsmSetting->homeOnly());
- m_ui->pin->setText(gsmSetting->pin());
- if (gsmSetting->pinFlags() == NetworkManager::Setting::None ||
- gsmSetting->pinFlags() == NetworkManager::Setting::AgentOwned) {
- m_ui->pinStorage->setCurrentIndex(SettingWidget::EnumPasswordStorageType::Store);
- } else if (gsmSetting->pinFlags() == NetworkManager::Setting::NotSaved) {
- m_ui->pinStorage->setCurrentIndex(SettingWidget::EnumPasswordStorageType::AlwaysAsk);
- } else {
- m_ui->pinStorage->setCurrentIndex(SettingWidget::EnumPasswordStorageType::NotRequired);
- }
-}
-
-QVariantMap GsmWidget::setting(bool agentOwned) const
-{
- NetworkManager::GsmSetting gsmSetting;
- if (!m_ui->number->text().isEmpty())
- gsmSetting.setNumber(m_ui->number->text());
- if (!m_ui->username->text().isEmpty())
- gsmSetting.setUsername(m_ui->username->text());
- if (!m_ui->password->text().isEmpty())
- gsmSetting.setPassword(m_ui->password->text());
- if (m_ui->passwordStorage->currentIndex() == SettingWidget::EnumPasswordStorageType::Store) {
- if (agentOwned) {
- gsmSetting.setPasswordFlags(NetworkManager::Setting::AgentOwned);
- }
- } else if (m_ui->passwordStorage->currentIndex() == SettingWidget::EnumPasswordStorageType::AlwaysAsk) {
- gsmSetting.setPasswordFlags(NetworkManager::Setting::NotSaved);
- } else {
- gsmSetting.setPasswordFlags(NetworkManager::Setting::NotRequired);
- }
-
- if (!m_ui->apn->text().isEmpty())
- gsmSetting.setApn(m_ui->apn->text());
- if (!m_ui->networkId->text().isEmpty())
- gsmSetting.setNetworkId(m_ui->networkId->text());
- gsmSetting.setNetworkType(static_cast<NetworkManager::GsmSetting::NetworkType>(m_ui->type->itemData(m_ui->type->currentIndex()).toInt()));
- gsmSetting.setHomeOnly(!m_ui->roaming->isChecked());
- if (!m_ui->pin->text().isEmpty())
- gsmSetting.setPin(m_ui->pin->text());
- if (m_ui->pinStorage->currentIndex() == SettingWidget::EnumPasswordStorageType::Store) {
- if (agentOwned) {
- gsmSetting.setPinFlags(NetworkManager::Setting::AgentOwned);
- }
- } else if (m_ui->pinStorage->currentIndex() == SettingWidget::EnumPasswordStorageType::AlwaysAsk) {
- gsmSetting.setPinFlags(NetworkManager::Setting::NotSaved);
- } else {
- gsmSetting.setPinFlags(NetworkManager::Setting::NotRequired);
- }
-
- return gsmSetting.toMap();
-}
-
-void GsmWidget::showPasswords(bool show)
-{
- m_ui->password->setPasswordMode(!show);
- m_ui->pin->setPasswordMode(!show);
-}
-
-void GsmWidget::pinStorageChanged(int index)
-{
- m_ui->pin->setEnabled(index == SettingWidget::EnumPasswordStorageType::Store);
-}
-
-void GsmWidget::passwordStorageChanged(int index)
-{
- m_ui->password->setEnabled(index == SettingWidget::EnumPasswordStorageType::Store);
-}
-
-bool GsmWidget::isValid() const
-{
- return !m_ui->apn->text().isEmpty();
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_GSM_WIDGET_H
-#define PLASMA_NM_GSM_WIDGET_H
-
-#include <QtGui/QWidget>
-
-#include <NetworkManagerQt/Setting>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class GsmWidget;
-}
-
-class PLASMA_NM_EXPORT GsmWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit GsmWidget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~GsmWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void showPasswords(bool show);
- void pinStorageChanged(int index);
- void passwordStorageChanged(int index);
-
-private:
- Ui::GsmWidget * m_ui;
-};
-
-#endif // PLASMA_NM_GSM_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <ltinkl@redhat.com></author>
- <class>InfinibandWidget</class>
- <widget class="QWidget" name="InfinibandWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>414</width>
- <height>362</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Transport mode:</string>
- </property>
- <property name="buddy">
- <cstring>transport</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="transport">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Restrict to device:</string>
- </property>
- <property name="buddy">
- <cstring>macAddress</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="HwAddrComboBox" name="macAddress">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>MTU:</string>
- </property>
- <property name="buddy">
- <cstring>mtu</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KIntSpinBox" name="mtu">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="specialValueText">
- <string>Automatic</string>
- </property>
- <property name="suffix">
- <string> bytes</string>
- </property>
- <property name="maximum">
- <number>9999</number>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KIntSpinBox</class>
- <extends>QSpinBox</extends>
- <header>knuminput.h</header>
- </customwidget>
- <customwidget>
- <class>HwAddrComboBox</class>
- <extends>QComboBox</extends>
- <header>hwaddrcombobox.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>transport</tabstop>
- <tabstop>macAddress</tabstop>
- <tabstop>mtu</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "infinibandwidget.h"
-#include "ui_infiniband.h"
-#include "uiutils.h"
-
-#include <KLocalizedString>
-
-#include <NetworkManagerQt/Utils>
-#include <NetworkManagerQt/InfinibandSetting>
-
-InfinibandWidget::InfinibandWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::InfinibandWidget)
-{
- m_ui->setupUi(this);
-
- m_ui->transport->addItem(i18nc("infiniband transport mode", "Datagram"), NetworkManager::InfinibandSetting::Datagram);
- m_ui->transport->addItem(i18nc("infiniband transport mode", "Connected"), NetworkManager::InfinibandSetting::Connected);
- m_ui->transport->setCurrentIndex(0);
-
- connect(m_ui->macAddress, SIGNAL(hwAddressChanged()), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (setting)
- loadConfig(setting);
-}
-
-InfinibandWidget::~InfinibandWidget()
-{
- delete m_ui;
-}
-
-void InfinibandWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::InfinibandSetting::Ptr infinibandSetting = setting.staticCast<NetworkManager::InfinibandSetting>();
-
- if (infinibandSetting->transportMode() != NetworkManager::InfinibandSetting::Unknown) {
- if (infinibandSetting->transportMode() == NetworkManager::InfinibandSetting::Datagram) {
- m_ui->transport->setCurrentIndex(0);
- } else if (infinibandSetting->transportMode() == NetworkManager::InfinibandSetting::Connected) {
- m_ui->transport->setCurrentIndex(1);
- }
- }
- m_ui->macAddress->init(NetworkManager::Device::InfiniBand, NetworkManager::Utils::macAddressAsString(infinibandSetting->macAddress()));
- if (infinibandSetting->mtu()) {
- m_ui->mtu->setValue(infinibandSetting->mtu());
- }
-}
-
-QVariantMap InfinibandWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned)
-
- NetworkManager::InfinibandSetting setting;
- if (m_ui->transport->currentIndex() == 0) {
- setting.setTransportMode(NetworkManager::InfinibandSetting::Datagram);
- } else {
- setting.setTransportMode(NetworkManager::InfinibandSetting::Connected);
- }
- setting.setMacAddress(NetworkManager::Utils::macAddressFromString(m_ui->macAddress->hwAddress()));
- if (m_ui->mtu->value()) {
- setting.setMtu(m_ui->mtu->value());
- }
-
- return setting.toMap();
-}
-
-bool InfinibandWidget::isValid() const
-{
- return m_ui->macAddress->isValid();
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_INFINIBAND_WIDGET_H
-#define PLASMA_NM_INFINIBAND_WIDGET_H
-
-#include <QtGui/QWidget>
-
-#include <NetworkManagerQt/Setting>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class InfinibandWidget;
-}
-
-class PLASMA_NM_EXPORT InfinibandWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit InfinibandWidget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~InfinibandWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private:
- Ui::InfinibandWidget * m_ui;
-};
-
-#endif // PLASMA_NM_INFI_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>IPv4Widget</class>
- <widget class="QWidget" name="IPv4Widget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>424</width>
- <height>434</height>
- </rect>
- </property>
- <property name="toolTip">
- <string extracomment="Advanced IP settings"/>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Method:</string>
- </property>
- <property name="buddy">
- <cstring>method</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="2">
- <widget class="KComboBox" name="method">
- <item>
- <property name="text">
- <string>Automatic</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Automatic (Only addresses)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Link-Local</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="like in use Manual configuration">Manual</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Shared to other computers</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="like in this setting is Disabled">Disabled</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="dnsLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string comment="@info">DNS Servers:</string>
- </property>
- <property name="textFormat">
- <enum>Qt::AutoText</enum>
- </property>
- <property name="buddy">
- <cstring>dns</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1" colspan="2">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="KLineEdit" name="dns">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>250</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Use this field to specify the IP address(es) of one or more DNS servers. Use ',' to separate entries.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KPushButton" name="dnsMorePushButton">
- <property name="toolTip">
- <string>Edit DNS the list of servers</string>
- </property>
- <property name="icon">
- <iconset theme="document-properties">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="dnsSearchLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string comment="@info">Search Domains:</string>
- </property>
- <property name="buddy">
- <cstring>dnsSearch</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1" colspan="2">
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="KLineEdit" name="dnsSearch">
- <property name="minimumSize">
- <size>
- <width>250</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Use this field to specify one or more DNS domains to search. Use ',' to separate entries.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KPushButton" name="dnsSearchMorePushButton">
- <property name="toolTip">
- <string>Edit the list of DNS domains being searched</string>
- </property>
- <property name="icon">
- <iconset theme="document-properties">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="4" column="1">
- <spacer name="verticalSpacer_5">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>17</width>
- <height>15</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="labelDhcpClientId">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>DHCP Client ID:</string>
- </property>
- <property name="buddy">
- <cstring>dhcpClientId</cstring>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>17</width>
- <height>15</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="7" column="0" colspan="3">
- <layout class="QGridLayout" name="gridLayout">
- <item row="1" column="1">
- <widget class="QPushButton" name="btnRemove">
- <property name="text">
- <string>Remove</string>
- </property>
- <property name="icon">
- <iconset theme="list-remove">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QPushButton" name="btnAdd">
- <property name="text">
- <string>Add</string>
- </property>
- <property name="icon">
- <iconset theme="list-add">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="0" column="0" rowspan="3">
- <widget class="QTableView" name="tableViewAddresses">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Addresses</string>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::SingleSelection</enum>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectRows</enum>
- </property>
- <attribute name="horizontalHeaderStretchLastSection">
- <bool>true</bool>
- </attribute>
- <attribute name="verticalHeaderVisible">
- <bool>false</bool>
- </attribute>
- </widget>
- </item>
- <item row="2" column="1">
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::MinimumExpanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="8" column="0" colspan="2">
- <widget class="QCheckBox" name="ipv4RequiredCB">
- <property name="text">
- <string>IPv4 is required for this connection</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="9" column="2">
- <widget class="QPushButton" name="btnRoutes">
- <property name="text">
- <string>Routes...</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1" colspan="2">
- <widget class="KLineEdit" name="dhcpClientId">
- <property name="toolTip">
- <string>Use this field to specify the DHCP client ID which is a string sent to the DHCP server to identify the local machine that the DHCP server may use to customize the DHCP lease and options.</string>
- </property>
- </widget>
- </item>
- <item row="9" column="0" colspan="2">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>method</tabstop>
- <tabstop>dns</tabstop>
- <tabstop>dnsMorePushButton</tabstop>
- <tabstop>dnsSearch</tabstop>
- <tabstop>dnsSearchMorePushButton</tabstop>
- <tabstop>dhcpClientId</tabstop>
- <tabstop>tableViewAddresses</tabstop>
- <tabstop>btnAdd</tabstop>
- <tabstop>btnRemove</tabstop>
- <tabstop>ipv4RequiredCB</tabstop>
- <tabstop>btnRoutes</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "ipv4widget.h"
-#include "ui_ipv4.h"
-#include "ipv4delegate.h"
-
-#include <QDialog>
-#include <QStandardItemModel>
-#include <QItemSelection>
-#include <QNetworkAddressEntry>
-
-#include <KEditListWidget>
-#include <KDialog>
-#include <KLocale>
-
-quint32 suggestNetmask(quint32 ip)
-{
- /*
- A 0 0.0.0.0 <-->127.255.255.255 255.0.0.0 <--->/8
- B 10 128.0.0.0 <>191.255.255.255 255.255.0.0 <->/16
- C 110 192.0.0.0 <>223.255.255.255 255.255.255.0 >/24
- D 1110 224.0.0.0 <>239.255.255.255 not defined <->not defined
- E 1111 240.0.0.0 <>255.255.255.254 not defined <->not defined
- */
- quint32 netmask = 0;
-
- if (!(ip & 0x80000000)) {
- // test 0 leading bit
- netmask = 0xFF000000;
- }
- else if (!(ip & 0x40000000)) {
- // test 10 leading bits
- netmask = 0xFFFF0000;
- }
- else if (!(ip & 0x20000000)) {
- // test 110 leading bits
- netmask = 0xFFFFFF00;
- }
-
- return netmask;
-}
-
-class IPv4Widget::Private
-{
-public:
- Private() : model(0,3)
- {
- QStandardItem * headerItem = new QStandardItem(i18nc("Header text for IPv4 address", "Address"));
- model.setHorizontalHeaderItem(0, headerItem);
- headerItem = new QStandardItem(i18nc("Header text for IPv4 netmask", "Netmask"));
- model.setHorizontalHeaderItem(1, headerItem);
- headerItem = new QStandardItem(i18nc("Header text for IPv4 gateway", "Gateway"));
- model.setHorizontalHeaderItem(2, headerItem);
- }
- QStandardItemModel model;
-};
-
-
-IPv4Widget::IPv4Widget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::IPv4Widget),
- d(new IPv4Widget::Private())
-{
- m_ui->setupUi(this);
-
- m_ui->tableViewAddresses->setModel(&d->model);
- m_ui->tableViewAddresses->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
- m_ui->tableViewAddresses->horizontalHeader()->setStretchLastSection(true);
-
- IpV4Delegate *ipDelegate = new IpV4Delegate(this);
- m_ui->tableViewAddresses->setItemDelegateForColumn(0, ipDelegate);
- m_ui->tableViewAddresses->setItemDelegateForColumn(1, ipDelegate);
- m_ui->tableViewAddresses->setItemDelegateForColumn(2, ipDelegate);
-
- connect(m_ui->btnAdd, SIGNAL(clicked()), this, SLOT(slotAddIPAddress()));
- connect(m_ui->btnRemove, SIGNAL(clicked()), this, SLOT(slotRemoveIPAddress()));
-
- connect(m_ui->dnsMorePushButton, SIGNAL(clicked()), SLOT(slotDnsServers()));
- connect(m_ui->dnsSearchMorePushButton, SIGNAL(clicked()), SLOT(slotDnsDomains()));
-
- connect(m_ui->tableViewAddresses->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
- this, SLOT(selectionChanged(QItemSelection)));
-
- connect(&d->model, SIGNAL(itemChanged(QStandardItem*)),
- this, SLOT(tableViewItemChanged(QStandardItem*)));
-
- if (setting) {
- loadConfig(setting);
- }
-
- connect(m_ui->method, SIGNAL(currentIndexChanged(int)),
- SLOT(slotModeComboChanged(int)));
- slotModeComboChanged(m_ui->method->currentIndex());
-
- connect(m_ui->btnRoutes, SIGNAL(clicked()),
- SLOT(slotRoutesDialog()));
-
- // Validation
- connect(m_ui->dns, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->method, SIGNAL(currentIndexChanged(int)), SLOT(slotWidgetChanged()));
- connect(&d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(slotWidgetChanged()));
- connect(&d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-}
-
-IPv4Widget::~IPv4Widget()
-{
- delete d;
- delete m_ui;
-}
-
-void IPv4Widget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::Ipv4Setting::Ptr ipv4Setting = setting.staticCast<NetworkManager::Ipv4Setting>();
-
- m_tmpIpv4Setting.setRoutes(ipv4Setting->routes());
- m_tmpIpv4Setting.setNeverDefault(ipv4Setting->neverDefault());
- m_tmpIpv4Setting.setIgnoreAutoRoutes(ipv4Setting->ignoreAutoRoutes());
-
- // method
- switch (ipv4Setting->method()) {
- case NetworkManager::Ipv4Setting::Automatic:
- if (ipv4Setting->ignoreAutoDns()) {
- m_ui->method->setCurrentIndex(AutomaticOnlyIP);
- } else {
- m_ui->method->setCurrentIndex(Automatic);
- }
- break;
- case NetworkManager::Ipv4Setting::Manual:
- m_ui->method->setCurrentIndex(Manual);
- break;
- case NetworkManager::Ipv4Setting::LinkLocal:
- m_ui->method->setCurrentIndex(LinkLocal);
- break;
- case NetworkManager::Ipv4Setting::Shared:
- m_ui->method->setCurrentIndex(Shared);
- break;
- case NetworkManager::Ipv4Setting::Disabled:
- m_ui->method->setCurrentIndex(Disabled);
- break;
- }
-
- // dns
- QStringList tmp;
- foreach (const QHostAddress & addr, ipv4Setting->dns()) {
- tmp.append(addr.toString());
- }
- m_ui->dns->setText(tmp.join(","));
- m_ui->dnsSearch->setText(ipv4Setting->dnsSearch().join(","));
-
- m_ui->dhcpClientId->setText(ipv4Setting->dhcpClientId());
-
- // addresses
- foreach (const NetworkManager::IpAddress &addr, ipv4Setting->addresses()) {
- QList<QStandardItem *> item;
- item << new QStandardItem(addr.ip().toString())
- << new QStandardItem(addr.netmask().toString())
- << new QStandardItem(addr.gateway().toString());
-
- d->model.appendRow(item);
- }
-
- // may-fail
- m_ui->ipv4RequiredCB->setChecked(!ipv4Setting->mayFail());
-}
-
-QVariantMap IPv4Widget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned);
-
- NetworkManager::Ipv4Setting ipv4Setting;
-
- ipv4Setting.setRoutes(m_tmpIpv4Setting.routes());
- ipv4Setting.setNeverDefault(m_tmpIpv4Setting.neverDefault());
- ipv4Setting.setIgnoreAutoRoutes(m_tmpIpv4Setting.ignoreAutoRoutes());
-
- // method
- switch ((MethodIndex)m_ui->method->currentIndex()) {
- case Automatic:
- ipv4Setting.setMethod(NetworkManager::Ipv4Setting::Automatic);
- break;
- case IPv4Widget::AutomaticOnlyIP:
- ipv4Setting.setMethod(NetworkManager::Ipv4Setting::Automatic);
- ipv4Setting.setIgnoreAutoDns(true);
- break;
- case Manual:
- ipv4Setting.setMethod(NetworkManager::Ipv4Setting::Manual);
- break;
- case LinkLocal:
- ipv4Setting.setMethod(NetworkManager::Ipv4Setting::LinkLocal);
- break;
- case Shared:
- ipv4Setting.setMethod(NetworkManager::Ipv4Setting::Shared);
- break;
- case Disabled:
- ipv4Setting.setMethod(NetworkManager::Ipv4Setting::Disabled);
- break;
- }
-
- // dns
- if (m_ui->dns->isEnabled() && !m_ui->dns->text().isEmpty()) {
- QStringList tmp = m_ui->dns->text().split(',');
- QList<QHostAddress> tmpAddrList;
- foreach (const QString & str, tmp) {
- QHostAddress addr(str);
- if (!addr.isNull())
- tmpAddrList.append(addr);
- }
- ipv4Setting.setDns(tmpAddrList);
- }
- if (m_ui->dnsSearch->isEnabled() && !m_ui->dnsSearch->text().isEmpty()) {
- ipv4Setting.setDnsSearch(m_ui->dnsSearch->text().split(','));
- }
-
- // dhcp id
- if (m_ui->dhcpClientId->isEnabled() && !m_ui->dhcpClientId->text().isEmpty()) {
- ipv4Setting.setDhcpClientId(m_ui->dhcpClientId->text());
- }
-
- // addresses
- if (m_ui->tableViewAddresses->isEnabled()) {
- QList<NetworkManager::IpAddress> list;
- for (int i = 0, rowCount = d->model.rowCount(); i < rowCount; i++) {
- NetworkManager::IpAddress address;
- address.setIp(QHostAddress(d->model.item(i, 0)->text()));
- address.setNetmask(QHostAddress(d->model.item(i, 1)->text()));
- address.setGateway(QHostAddress(d->model.item(i, 2)->text()));
- list << address;
- }
- if (!list.isEmpty()) {
- ipv4Setting.setAddresses(list);
- }
- }
-
- // may-fail
- if (m_ui->ipv4RequiredCB->isEnabled()) {
- ipv4Setting.setMayFail(!m_ui->ipv4RequiredCB->isChecked());
- }
-
- return ipv4Setting.toMap();
-}
-
-void IPv4Widget::slotModeComboChanged(int index)
-{
- if (index == Automatic) { // Automatic
- m_ui->dnsLabel->setText(i18n("Other DNS Servers:"));
- m_ui->dns->setEnabled(true);
- m_ui->dnsMorePushButton->setEnabled(true);
- m_ui->dnsSearch->setEnabled(true);
- m_ui->dnsSearchMorePushButton->setEnabled(true);
- m_ui->dhcpClientId->setEnabled(true);
- m_ui->ipv4RequiredCB->setEnabled(true);
- m_ui->btnRoutes->setEnabled(true);
- m_ui->tableViewAddresses->setEnabled(false);
- m_ui->tableViewAddresses->setVisible(false);
- m_ui->btnAdd->setVisible(false);
- m_ui->btnRemove->setVisible(false);
- } else if (index == AutomaticOnlyIP) {
- m_ui->dnsLabel->setText(i18n("DNS Servers:"));
- m_ui->dns->setEnabled(true);
- m_ui->dnsMorePushButton->setEnabled(true);
- m_ui->dnsSearch->setEnabled(true);
- m_ui->dnsSearchMorePushButton->setEnabled(true);
- m_ui->dhcpClientId->setEnabled(true);
- m_ui->ipv4RequiredCB->setEnabled(true);
- m_ui->btnRoutes->setEnabled(true);
- m_ui->tableViewAddresses->setEnabled(false);
- m_ui->tableViewAddresses->setVisible(false);
- m_ui->btnAdd->setVisible(false);
- m_ui->btnRemove->setVisible(false);
- } else if (index == Manual) { // Manual
- m_ui->dnsLabel->setText(i18n("DNS Servers:"));
- m_ui->dns->setEnabled(true);
- m_ui->dnsMorePushButton->setEnabled(true);
- m_ui->dnsSearch->setEnabled(true);
- m_ui->dnsSearchMorePushButton->setEnabled(true);
- m_ui->dhcpClientId->setEnabled(false);
- m_ui->ipv4RequiredCB->setEnabled(true);
- m_ui->btnRoutes->setEnabled(true);
- m_ui->tableViewAddresses->setEnabled(true);
- m_ui->tableViewAddresses->setVisible(true);
- m_ui->btnAdd->setVisible(true);
- m_ui->btnRemove->setVisible(true);
- } else if (index == LinkLocal || index == Shared) { // Link-local or Shared
- m_ui->dnsLabel->setText(i18n("DNS Servers:"));
- m_ui->dns->setEnabled(false);
- m_ui->dnsMorePushButton->setEnabled(false);
- m_ui->dnsSearch->setEnabled(false);
- m_ui->dnsSearchMorePushButton->setEnabled(false);
- m_ui->dhcpClientId->setEnabled(false);
- m_ui->ipv4RequiredCB->setEnabled(true);
- m_ui->btnRoutes->setEnabled(false);
- m_ui->tableViewAddresses->setEnabled(false);
- m_ui->tableViewAddresses->setVisible(false);
- m_ui->btnAdd->setVisible(false);
- m_ui->btnRemove->setVisible(false);
- } else if (index == Disabled) { // Disabled
- m_ui->dnsLabel->setText(i18n("DNS Servers:"));
- m_ui->dns->setEnabled(false);
- m_ui->dnsMorePushButton->setEnabled(false);
- m_ui->dnsSearch->setEnabled(false);
- m_ui->dnsSearchMorePushButton->setEnabled(false);
- m_ui->dhcpClientId->setEnabled(false);
- m_ui->ipv4RequiredCB->setEnabled(false);
- m_ui->btnRoutes->setEnabled(false);
- m_ui->tableViewAddresses->setEnabled(false);
- m_ui->tableViewAddresses->setVisible(false);
- m_ui->btnAdd->setVisible(false);
- m_ui->btnRemove->setVisible(false);
- }
-}
-
-void IPv4Widget::slotAddIPAddress()
-{
- QList<QStandardItem *> item;
- item << new QStandardItem << new QStandardItem << new QStandardItem;
- d->model.appendRow(item);
-
- const int rowCount = d->model.rowCount();
- if (rowCount > 0) {
- m_ui->tableViewAddresses->selectRow(rowCount - 1);
-
- QItemSelectionModel * selectionModel = m_ui->tableViewAddresses->selectionModel();
- QModelIndexList list = selectionModel->selectedIndexes();
- if (!list.isEmpty()) {
- // QTableView is configured to select only rows.
- // So, list[0] - IP address.
- m_ui->tableViewAddresses->edit(list[0]);
- }
- }
-}
-
-void IPv4Widget::slotRemoveIPAddress()
-{
- QItemSelectionModel * selectionModel = m_ui->tableViewAddresses->selectionModel();
- if (selectionModel->hasSelection()) {
- QModelIndexList indexes = selectionModel->selectedIndexes();
- d->model.takeRow(indexes[0].row());
- }
- m_ui->btnRemove->setEnabled(m_ui->tableViewAddresses->selectionModel()->hasSelection());
-}
-
-void IPv4Widget::selectionChanged(const QItemSelection & selected)
-{
- m_ui->btnRemove->setEnabled(!selected.isEmpty());
-}
-
-void IPv4Widget::tableViewItemChanged(QStandardItem *item)
-{
- if (item->text().isEmpty()) {
- return;
- }
-
- const int column = item->column();
- if (column == 0) { // ip
- int row = item->row();
-
- QStandardItem *netmaskItem = d->model.item(row, column + 1); // netmask
- if (netmaskItem && netmaskItem->text().isEmpty()) {
- QHostAddress addr(item->text());
- const quint32 netmask = suggestNetmask(addr.toIPv4Address());
- if (netmask) {
- QHostAddress v(netmask);
- netmaskItem->setText(v.toString());
- }
- }
- }
-}
-
-void IPv4Widget::slotRoutesDialog()
-{
- QPointer<IpV4RoutesWidget> dlg = new IpV4RoutesWidget(this);
-
- dlg->setRoutes(m_tmpIpv4Setting.routes());
- dlg->setNeverDefault(m_tmpIpv4Setting.neverDefault());
- if (m_ui->method->currentIndex() == 2) { // manual
- dlg->setIgnoreAutoRoutesCheckboxEnabled(false);
- } else {
- dlg->setIgnoreAutoRoutes(m_tmpIpv4Setting.ignoreAutoRoutes());
- }
-
- if (dlg->exec() == QDialog::Accepted) {
- m_tmpIpv4Setting.setRoutes(dlg->routes());
- m_tmpIpv4Setting.setNeverDefault(dlg->neverDefault());
- m_tmpIpv4Setting.setIgnoreAutoRoutes(dlg->ignoreautoroutes());
- }
-
- if (dlg) {
- dlg->deleteLater();
- }
-}
-
-void IPv4Widget::slotDnsServers()
-{
- QPointer<KDialog> dlg = new KDialog(this);
- dlg->setCaption(i18n("Edit DNS servers"));
- dlg->setButtons(KDialog::Ok | KDialog::Cancel);
- KEditListWidget * listWidget = new KEditListWidget(dlg);
- dlg->setMainWidget(listWidget);
- listWidget->setItems(m_ui->dns->text().split(',').replaceInStrings(" ", ""));
-
- if (dlg->exec() == KDialog::Accepted) {
- QString text = listWidget->items().join(",");
- if (text.endsWith(',')) {
- text.chop(1);
- }
- m_ui->dns->setText(text);
- }
-
- if (dlg) {
- dlg->deleteLater();
- }
-}
-
-void IPv4Widget::slotDnsDomains()
-{
- QPointer<KDialog> dlg = new KDialog(this);
- dlg->setCaption(i18n("Edit DNS search domains"));
- dlg->setButtons(KDialog::Ok | KDialog::Cancel);
- KEditListWidget * listWidget = new KEditListWidget(dlg);
- dlg->setMainWidget(listWidget);
- listWidget->setItems(m_ui->dnsSearch->text().split(',').replaceInStrings(" ", ""));
-
- if (dlg->exec() == KDialog::Accepted) {
- QString text = listWidget->items().join(",");
- if (text.endsWith(',')) {
- text.chop(1);
- }
- m_ui->dnsSearch->setText(text);
- }
-
- if (dlg) {
- dlg->deleteLater();
- }
-}
-
-bool IPv4Widget::isValid() const
-{
- if (m_ui->method->currentIndex() == Manual) {
- if (!d->model.rowCount()) {
- return false;
- }
-
- for (int i = 0, rowCount = d->model.rowCount(); i < rowCount; i++) {
- QHostAddress ip = QHostAddress(d->model.item(i, 0)->text());
- QHostAddress netmask = QHostAddress(d->model.item(i, 1)->text());
- QHostAddress gateway = QHostAddress(d->model.item(i, 2)->text());
-
- if (ip.isNull() || netmask.isNull() || (gateway.isNull() && !d->model.item(i, 2)->text().isEmpty())) {
- return false;
- }
- }
- }
-
- if (!m_ui->dns->text().isEmpty() && (m_ui->method->currentIndex() == Automatic || m_ui->method->currentIndex() == Manual || m_ui->method->currentIndex() == AutomaticOnlyIP)) {
- const QStringList tmp = m_ui->dns->text().split(',');
- foreach (const QString & str, tmp) {
- QHostAddress addr(str);
- if (addr.isNull()) {
- return false;
- }
- }
- }
-
- return true;
-}
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_IPV4_WIDGET_H
-#define PLASMA_NM_IPV4_WIDGET_H
-
-#include <QtGui/QWidget>
-#include <NetworkManagerQt/Ipv4Setting>
-
-#include "settingwidget.h"
-#include "ipv4routeswidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class IPv4Widget;
-}
-
-class PLASMA_NM_EXPORT IPv4Widget : public SettingWidget
-{
-Q_OBJECT
-public:
- enum MethodIndex { Automatic = 0, AutomaticOnlyIP, LinkLocal, Manual, Shared, Disabled };
-
- explicit IPv4Widget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~IPv4Widget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void slotModeComboChanged(int index);
- void slotRoutesDialog();
-
- void slotDnsServers();
- void slotDnsDomains();
-
- void slotAddIPAddress();
- void slotRemoveIPAddress();
-
- void selectionChanged(const QItemSelection & selected);
- void tableViewItemChanged(QStandardItem * item);
-
-private:
- Ui::IPv4Widget * m_ui;
- NetworkManager::Ipv4Setting m_tmpIpv4Setting;
-
- class Private;
- Private *d;
-};
-
-#endif // PLASMA_NM_IPV4_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>IPv6Widget</class>
- <widget class="QWidget" name="IPv6Widget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>424</width>
- <height>435</height>
- </rect>
- </property>
- <property name="toolTip">
- <string extracomment="Advanced IP settings"/>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="4" column="1">
- <spacer name="verticalSpacer_5">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>17</width>
- <height>15</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="labelPrivacy">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Privacy:</string>
- </property>
- <property name="buddy">
- <cstring>privacyCombo</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Method:</string>
- </property>
- <property name="buddy">
- <cstring>method</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="2">
- <widget class="KComboBox" name="method">
- <item>
- <property name="text">
- <string>Automatic</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Automatic (Only addresses)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Automatic (Only DHCP)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Link-Local</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="like in use Manual configuration">Manual</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="like in this setting is Disabled">Ignored</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="dnsLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string comment="@info">DNS Servers:</string>
- </property>
- <property name="textFormat">
- <enum>Qt::AutoText</enum>
- </property>
- <property name="buddy">
- <cstring>dns</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1" colspan="2">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="KLineEdit" name="dns">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>250</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Use this field to specify the IP address(es) of one or more DNS servers. Use ',' to separate entries.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KPushButton" name="dnsMorePushButton">
- <property name="toolTip">
- <string>Edit DNS the list of servers</string>
- </property>
- <property name="icon">
- <iconset theme="document-properties">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="dnsSearchLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string comment="@info">Search Domains:</string>
- </property>
- <property name="buddy">
- <cstring>dnsSearch</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1" colspan="2">
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="KLineEdit" name="dnsSearch">
- <property name="minimumSize">
- <size>
- <width>250</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Use this field to specify one or more DNS domains to search. Use ',' to separate entries.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KPushButton" name="dnsSearchMorePushButton">
- <property name="toolTip">
- <string>Edit the list of DNS domains being searched</string>
- </property>
- <property name="icon">
- <iconset theme="document-properties">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="6" column="1">
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>17</width>
- <height>15</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="7" column="0" colspan="3">
- <layout class="QGridLayout" name="gridLayout">
- <item row="1" column="1">
- <widget class="QPushButton" name="btnRemove">
- <property name="text">
- <string>Remove</string>
- </property>
- <property name="icon">
- <iconset theme="list-remove">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QPushButton" name="btnAdd">
- <property name="text">
- <string>Add</string>
- </property>
- <property name="icon">
- <iconset theme="list-add">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="0" column="0" rowspan="3">
- <widget class="QTableView" name="tableViewAddresses">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Addresses</string>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::SingleSelection</enum>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectRows</enum>
- </property>
- <attribute name="horizontalHeaderStretchLastSection">
- <bool>true</bool>
- </attribute>
- <attribute name="verticalHeaderVisible">
- <bool>false</bool>
- </attribute>
- </widget>
- </item>
- <item row="2" column="1">
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::MinimumExpanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="8" column="0" colspan="2">
- <widget class="QCheckBox" name="ipv6RequiredCB">
- <property name="text">
- <string>IPv6 is required for this connection</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="9" column="2">
- <widget class="QPushButton" name="btnRoutes">
- <property name="text">
- <string>Routes...</string>
- </property>
- </widget>
- </item>
- <item row="9" column="0" colspan="2">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="5" column="1" colspan="2">
- <widget class="KComboBox" name="privacyCombo">
- <item>
- <property name="text">
- <string>Default</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="privacy disabled">Disabled</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Enabled (prefer public address)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Enabled (prefer temporary addresses)</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>method</tabstop>
- <tabstop>dns</tabstop>
- <tabstop>dnsMorePushButton</tabstop>
- <tabstop>dnsSearch</tabstop>
- <tabstop>dnsSearchMorePushButton</tabstop>
- <tabstop>privacyCombo</tabstop>
- <tabstop>tableViewAddresses</tabstop>
- <tabstop>btnAdd</tabstop>
- <tabstop>btnRemove</tabstop>
- <tabstop>ipv6RequiredCB</tabstop>
- <tabstop>btnRoutes</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "ipv6widget.h"
-#include "ui_ipv6.h"
-#include "ipv6delegate.h"
-#include "intdelegate.h"
-
-#include <QDialog>
-#include <QStandardItemModel>
-#include <QItemSelection>
-#include <QNetworkAddressEntry>
-
-#include <KEditListWidget>
-#include <KDialog>
-#include <KLocale>
-
-quint32 suggestNetmask(Q_IPV6ADDR ip)
-{
- Q_UNUSED(ip);
-
- /*
- TODO: find out common IPv6-netmasks and make a complete function
-
- */
- quint32 netmask = 64;
-
- return netmask;
-}
-
-class IPv6Widget::Private
-{
-public:
- Private() : model(0,3)
- {
- QStandardItem * headerItem = new QStandardItem(i18nc("Header text for IPv6 address", "Address"));
- model.setHorizontalHeaderItem(0, headerItem);
- headerItem = new QStandardItem(i18nc("Header text for IPv6 prefix", "Prefix"));
- model.setHorizontalHeaderItem(1, headerItem);
- headerItem = new QStandardItem(i18nc("Header text for IPv6 gateway", "Gateway"));
- model.setHorizontalHeaderItem(2, headerItem);
- }
- QStandardItemModel model;
-};
-
-
-IPv6Widget::IPv6Widget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::IPv6Widget),
- d(new IPv6Widget::Private())
-{
- m_ui->setupUi(this);
-
- m_ui->tableViewAddresses->setModel(&d->model);
- m_ui->tableViewAddresses->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
- m_ui->tableViewAddresses->horizontalHeader()->setStretchLastSection(true);
-
- IpV6Delegate *ipDelegate = new IpV6Delegate(this);
- IntDelegate *prefixDelegate = new IntDelegate (0, 128, this);
- m_ui->tableViewAddresses->setItemDelegateForColumn(0, ipDelegate);
- m_ui->tableViewAddresses->setItemDelegateForColumn(1, prefixDelegate);
- m_ui->tableViewAddresses->setItemDelegateForColumn(2, ipDelegate);
-
- connect(m_ui->btnAdd, SIGNAL(clicked()), this, SLOT(slotAddIPAddress()));
- connect(m_ui->btnRemove, SIGNAL(clicked()), this, SLOT(slotRemoveIPAddress()));
-
- connect(m_ui->dnsMorePushButton, SIGNAL(clicked()), SLOT(slotDnsServers()));
- connect(m_ui->dnsSearchMorePushButton, SIGNAL(clicked()), SLOT(slotDnsDomains()));
-
- connect(m_ui->tableViewAddresses->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
- this, SLOT(selectionChanged(QItemSelection)));
-
- connect(&d->model, SIGNAL(itemChanged(QStandardItem*)),
- this, SLOT(tableViewItemChanged(QStandardItem*)));
-
- if (setting) {
- loadConfig(setting);
- }
-
- connect(m_ui->method, SIGNAL(currentIndexChanged(int)),
- SLOT(slotModeComboChanged(int)));
- slotModeComboChanged(m_ui->method->currentIndex());
-
- connect(m_ui->btnRoutes, SIGNAL(clicked()),
- SLOT(slotRoutesDialog()));
-
- // Validation
- connect(m_ui->dns, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->method, SIGNAL(currentIndexChanged(int)), SLOT(slotWidgetChanged()));
- connect(&d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(slotWidgetChanged()));
- connect(&d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-}
-
-IPv6Widget::~IPv6Widget()
-{
- delete d;
- delete m_ui;
-}
-
-void IPv6Widget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::Ipv6Setting::Ptr ipv6Setting = setting.staticCast<NetworkManager::Ipv6Setting>();
-
- m_tmpIpv6Setting.setRoutes(ipv6Setting->routes());
- m_tmpIpv6Setting.setNeverDefault(ipv6Setting->neverDefault());
- m_tmpIpv6Setting.setIgnoreAutoRoutes(ipv6Setting->ignoreAutoRoutes());
-
- // method
- switch (ipv6Setting->method()) {
- case NetworkManager::Ipv6Setting::Automatic:
- if (ipv6Setting->ignoreAutoDns()) {
- m_ui->method->setCurrentIndex(AutomaticOnlyIP);
- } else {
- m_ui->method->setCurrentIndex(Automatic);
- }
- break;
- case NetworkManager::Ipv6Setting::Dhcp:
- m_ui->method->setCurrentIndex(AutomaticOnlyDHCP);
- break;
- case NetworkManager::Ipv6Setting::Manual:
- m_ui->method->setCurrentIndex(Manual);
- break;
- case NetworkManager::Ipv6Setting::LinkLocal:
- m_ui->method->setCurrentIndex(LinkLocal);
- break;
- case NetworkManager::Ipv6Setting::Ignored:
- m_ui->method->setCurrentIndex(Disabled);
- break;
- }
-
- // dns
- QStringList tmp;
- foreach (const QHostAddress & addr, ipv6Setting->dns()) {
- tmp.append(addr.toString());
- }
- m_ui->dns->setText(tmp.join(","));
- m_ui->dnsSearch->setText(ipv6Setting->dnsSearch().join(","));
-
- // addresses
- foreach (const NetworkManager::IpAddress &address, ipv6Setting->addresses()) {
- QList<QStandardItem *> item;
-
- item << new QStandardItem(address.ip().toString())
- << new QStandardItem(QString::number(address.prefixLength(),10))
- << new QStandardItem(address.gateway().toString());
-
- d->model.appendRow(item);
- }
-
- // may-fail
- m_ui->ipv6RequiredCB->setChecked(!ipv6Setting->mayFail());
-
- // privacy
- if (ipv6Setting->privacy() != NetworkManager::Ipv6Setting::Unknown) {
- m_ui->privacyCombo->setCurrentIndex(static_cast<int>(ipv6Setting->privacy()) + 1);
- }
-}
-
-QVariantMap IPv6Widget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned);
-
- NetworkManager::Ipv6Setting ipv6Setting;
-
- ipv6Setting.setRoutes(m_tmpIpv6Setting.routes());
- ipv6Setting.setNeverDefault(m_tmpIpv6Setting.neverDefault());
- ipv6Setting.setIgnoreAutoRoutes(m_tmpIpv6Setting.ignoreAutoRoutes());
-
- // method
- switch ((MethodIndex)m_ui->method->currentIndex()) {
- case Automatic:
- ipv6Setting.setMethod(NetworkManager::Ipv6Setting::Automatic);
- break;
- case AutomaticOnlyIP:
- ipv6Setting.setMethod(NetworkManager::Ipv6Setting::Automatic);
- ipv6Setting.setIgnoreAutoDns(true);
- break;
- case IPv6Widget::AutomaticOnlyDHCP:
- ipv6Setting.setMethod(NetworkManager::Ipv6Setting::Dhcp);
- break;
- case Manual:
- ipv6Setting.setMethod(NetworkManager::Ipv6Setting::Manual);
- break;
- case LinkLocal:
- ipv6Setting.setMethod(NetworkManager::Ipv6Setting::LinkLocal);
- break;
- case Disabled:
- ipv6Setting.setMethod(NetworkManager::Ipv6Setting::Ignored);
- break;
- }
-
- // dns
- if (m_ui->dns->isEnabled() && !m_ui->dns->text().isEmpty()) {
- QStringList tmp = m_ui->dns->text().split(',');
- QList<QHostAddress> tmpAddrList;
- foreach (const QString & str, tmp) {
- QHostAddress addr(str);
- if (!addr.isNull())
- tmpAddrList.append(addr);
- }
- ipv6Setting.setDns(tmpAddrList);
- }
- if (m_ui->dnsSearch->isEnabled() && !m_ui->dnsSearch->text().isEmpty()) {
- ipv6Setting.setDnsSearch(m_ui->dnsSearch->text().split(','));
- }
-
- // addresses
- if (m_ui->tableViewAddresses->isEnabled()) {
- QList<NetworkManager::IpAddress> list;
- for (int i = 0, rowCount = d->model.rowCount(); i < rowCount; i++) {
- NetworkManager::IpAddress address;
- address.setIp(QHostAddress(d->model.item(i, 0)->text()));
- address.setPrefixLength(d->model.item(i, 1)->text().toInt());
- address.setGateway(QHostAddress(d->model.item(i, 2)->text()));
-
- list << address;
- }
- ipv6Setting.setAddresses(list);
- }
-
- // may-fail
- if (m_ui->ipv6RequiredCB->isEnabled()) {
- ipv6Setting.setMayFail(!m_ui->ipv6RequiredCB->isChecked());
- }
-
- // privacy
- if (m_ui->privacyCombo->isEnabled() && m_ui->privacyCombo->currentIndex()) {
- ipv6Setting.setPrivacy(static_cast<NetworkManager::Ipv6Setting::IPv6Privacy>(m_ui->privacyCombo->currentIndex() - 1));
- }
-
- return ipv6Setting.toMap();
-}
-
-void IPv6Widget::slotModeComboChanged(int index)
-{
- if (index == Automatic) { // Automatic
- m_ui->dnsLabel->setText(i18n("Other DNS Servers:"));
- m_ui->dns->setEnabled(true);
- m_ui->dnsMorePushButton->setEnabled(true);
- m_ui->dnsSearch->setEnabled(true);
- m_ui->dnsSearchMorePushButton->setEnabled(true);
- m_ui->ipv6RequiredCB->setEnabled(true);
- m_ui->privacyCombo->setEnabled(true);
- m_ui->btnRoutes->setEnabled(true);
- m_ui->tableViewAddresses->setEnabled(false);
- m_ui->tableViewAddresses->setVisible(false);
- m_ui->btnAdd->setVisible(false);
- m_ui->btnRemove->setVisible(false);
- } else if (index == AutomaticOnlyIP) {
- m_ui->dnsLabel->setText(i18n("DNS Servers:"));
- m_ui->dns->setEnabled(true);
- m_ui->dnsMorePushButton->setEnabled(true);
- m_ui->dnsSearch->setEnabled(true);
- m_ui->dnsSearchMorePushButton->setEnabled(true);
- m_ui->ipv6RequiredCB->setEnabled(true);
- m_ui->privacyCombo->setEnabled(true);
- m_ui->btnRoutes->setEnabled(true);
- m_ui->tableViewAddresses->setEnabled(false);
- m_ui->tableViewAddresses->setVisible(false);
- m_ui->btnAdd->setVisible(false);
- m_ui->btnRemove->setVisible(false);
- } else if (index == Manual) { // Manual
- m_ui->dnsLabel->setText(i18n("DNS Servers:"));
- m_ui->dns->setEnabled(true);
- m_ui->dnsMorePushButton->setEnabled(true);
- m_ui->dnsSearch->setEnabled(true);
- m_ui->dnsSearchMorePushButton->setEnabled(true);
- m_ui->ipv6RequiredCB->setEnabled(true);
- m_ui->privacyCombo->setEnabled(true);
- m_ui->btnRoutes->setEnabled(true);
- m_ui->tableViewAddresses->setEnabled(true);
- m_ui->tableViewAddresses->setVisible(true);
- m_ui->btnAdd->setVisible(true);
- m_ui->btnRemove->setVisible(true);
- } else if (index == AutomaticOnlyDHCP || index == LinkLocal) { // Link-local or DHCP
- m_ui->dnsLabel->setText(i18n("DNS Servers:"));
- m_ui->dns->setEnabled(false);
- m_ui->dnsMorePushButton->setEnabled(false);
- m_ui->dnsSearch->setEnabled(false);
- m_ui->dnsSearchMorePushButton->setEnabled(false);
- m_ui->ipv6RequiredCB->setEnabled(true);
- m_ui->privacyCombo->setEnabled(true);
- m_ui->btnRoutes->setEnabled(false);
- m_ui->tableViewAddresses->setEnabled(false);
- m_ui->tableViewAddresses->setVisible(false);
- m_ui->btnAdd->setVisible(false);
- m_ui->btnRemove->setVisible(false);
- } else if (index == Disabled) { // Ignored
- m_ui->dnsLabel->setText(i18n("DNS Servers:"));
- m_ui->dns->setEnabled(false);
- m_ui->dnsMorePushButton->setEnabled(false);
- m_ui->dnsSearch->setEnabled(false);
- m_ui->dnsSearchMorePushButton->setEnabled(false);
- m_ui->ipv6RequiredCB->setEnabled(false);
- m_ui->privacyCombo->setEnabled(false);
- m_ui->btnRoutes->setEnabled(false);
- m_ui->tableViewAddresses->setEnabled(false);
- m_ui->tableViewAddresses->setVisible(false);
- m_ui->btnAdd->setVisible(false);
- m_ui->btnRemove->setVisible(false);
- }
-}
-
-void IPv6Widget::slotAddIPAddress()
-{
- QList<QStandardItem *> item;
- item << new QStandardItem << new QStandardItem << new QStandardItem;
- d->model.appendRow(item);
-
- const int rowCount = d->model.rowCount();
- if (rowCount > 0) {
- m_ui->tableViewAddresses->selectRow(rowCount - 1);
-
- QItemSelectionModel * selectionModel = m_ui->tableViewAddresses->selectionModel();
- QModelIndexList list = selectionModel->selectedIndexes();
- if (list.size()) {
- // QTableView is configured to select only rows.
- // So, list[0] - IP address.
- m_ui->tableViewAddresses->edit(list[0]);
- }
- }
-}
-
-void IPv6Widget::slotRemoveIPAddress()
-{
- QItemSelectionModel * selectionModel = m_ui->tableViewAddresses->selectionModel();
- if (selectionModel->hasSelection()) {
- QModelIndexList indexes = selectionModel->selectedIndexes();
- d->model.takeRow(indexes[0].row());
- }
- m_ui->btnRemove->setEnabled(m_ui->tableViewAddresses->selectionModel()->hasSelection());
-}
-
-void IPv6Widget::selectionChanged(const QItemSelection & selected)
-{
- m_ui->btnRemove->setEnabled(!selected.isEmpty());
-}
-
-void IPv6Widget::tableViewItemChanged(QStandardItem *item)
-{
- if (item->text().isEmpty()) {
- return;
- }
-
- const int column = item->column();
- if (column == 0) { // ip
- int row = item->row();
-
- QStandardItem *netmaskItem = d->model.item(row, column + 1); // netmask
- if (netmaskItem && netmaskItem->text().isEmpty()) {
- QHostAddress addr(item->text());
- const quint32 netmask = suggestNetmask(addr.toIPv6Address());
- if (netmask) {
- netmaskItem->setText(QString::number(netmask,10));
- }
- }
- }
-}
-
-void IPv6Widget::slotRoutesDialog()
-{
- QPointer<IpV6RoutesWidget> dlg = new IpV6RoutesWidget(this);
-
- dlg->setRoutes(m_tmpIpv6Setting.routes());
- dlg->setNeverDefault(m_tmpIpv6Setting.neverDefault());
- if (m_ui->method->currentIndex() == 3) { // manual
- dlg->setIgnoreAutoRoutesCheckboxEnabled(false);
- } else {
- dlg->setIgnoreAutoRoutes(m_tmpIpv6Setting.ignoreAutoRoutes());
- }
-
- if (dlg->exec() == QDialog::Accepted) {
- m_tmpIpv6Setting.setRoutes(dlg->routes());
- m_tmpIpv6Setting.setNeverDefault(dlg->neverDefault());
- m_tmpIpv6Setting.setIgnoreAutoRoutes(dlg->ignoreautoroutes());
- }
-
- if (dlg) {
- dlg->deleteLater();
- }
-}
-
-void IPv6Widget::slotDnsServers()
-{
- QPointer<KDialog> dlg = new KDialog(this);
- dlg->setCaption(i18n("Edit DNS servers"));
- dlg->setButtons(KDialog::Ok | KDialog::Cancel);
- KEditListWidget * listWidget = new KEditListWidget(dlg);
- dlg->setMainWidget(listWidget);
- listWidget->setItems(m_ui->dns->text().split(',').replaceInStrings(" ", ""));
-
- if (dlg->exec() == KDialog::Accepted) {
- QString text = listWidget->items().join(",");
- if (text.endsWith(',')) {
- text.chop(1);
- }
- m_ui->dns->setText(text);
- }
-
- if (dlg) {
- dlg->deleteLater();
- }
-}
-
-void IPv6Widget::slotDnsDomains()
-{
- QPointer<KDialog> dlg = new KDialog(this);
- dlg->setCaption(i18n("Edit DNS search domains"));
- dlg->setButtons(KDialog::Ok | KDialog::Cancel);
- KEditListWidget * listWidget = new KEditListWidget(dlg);
- dlg->setMainWidget(listWidget);
- listWidget->setItems(m_ui->dnsSearch->text().split(',').replaceInStrings(" ", ""));
-
- if (dlg->exec() == KDialog::Accepted) {
- QString text = listWidget->items().join(",");
- if (text.endsWith(',')) {
- text.chop(1);
- }
- m_ui->dnsSearch->setText(text);
- }
-
- if (dlg) {
- dlg->deleteLater();
- }
-}
-
-bool IPv6Widget::isValid() const
-{
- if (m_ui->method->currentIndex() == Manual) {
- if (!d->model.rowCount()) {
- return false;
- }
-
- for (int i = 0, rowCount = d->model.rowCount(); i < rowCount; i++) {
- QHostAddress ip = QHostAddress(d->model.item(i, 0)->text());
- const int prefix = d->model.item(i,1)->text().toInt();
- QHostAddress gateway = QHostAddress(d->model.item(i, 2)->text());
-
- if (ip.isNull() || !(prefix >= 1 && prefix <= 128) || (gateway.isNull() && !d->model.item(i, 2)->text().isEmpty())) {
- return false;
- }
- }
- }
-
- if (!m_ui->dns->text().isEmpty() && (m_ui->method->currentIndex() == Automatic || m_ui->method->currentIndex() == Manual || m_ui->method->currentIndex() == AutomaticOnlyIP)) {
- const QStringList tmp = m_ui->dns->text().split(',');
- foreach (const QString & str, tmp) {
- QHostAddress addr(str);
- if (addr.isNull()) {
- return false;
- }
- }
- }
-
- return true;
-}
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_IPV6_WIDGET_H
-#define PLASMA_NM_IPV6_WIDGET_H
-
-#include <QtGui/QWidget>
-#include <NetworkManagerQt/Ipv6Setting>
-
-#include "settingwidget.h"
-#include "ipv6routeswidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class IPv6Widget;
-}
-
-class PLASMA_NM_EXPORT IPv6Widget : public SettingWidget
-{
-Q_OBJECT
-public:
- enum MethodIndex { Automatic = 0, AutomaticOnlyIP, AutomaticOnlyDHCP, LinkLocal, Manual, Disabled };
-
- explicit IPv6Widget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~IPv6Widget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void slotModeComboChanged(int index);
- void slotRoutesDialog();
-
- void slotDnsServers();
- void slotDnsDomains();
-
- void slotAddIPAddress();
- void slotRemoveIPAddress();
-
- void selectionChanged(const QItemSelection & selected);
- void tableViewItemChanged(QStandardItem * item);
-
-private:
- Ui::IPv6Widget * m_ui;
- NetworkManager::Ipv6Setting m_tmpIpv6Setting;
-
- class Private;
- Private *d;
-};
-
-#endif // PLASMA_NM_IPV4_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PPPWidget</class>
- <widget class="QWidget" name="PPPWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>440</width>
- <height>423</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QGroupBox" name="authGroup">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="title">
- <string>Authentication</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
- </property>
- <property name="labelAlignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <item row="0" column="0">
- <widget class="QCheckBox" name="eap">
- <property name="text">
- <string>EAP</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="mschap">
- <property name="text">
- <string>MSCHAP</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="pap">
- <property name="text">
- <string>PAP</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="mschapv2">
- <property name="text">
- <string>MSCHAPv2</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QCheckBox" name="chap">
- <property name="text">
- <string>CHAP</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="compressionGroup">
- <property name="title">
- <string>Compression</string>
- </property>
- <property name="flat">
- <bool>false</bool>
- </property>
- <property name="checkable">
- <bool>false</bool>
- </property>
- <layout class="QFormLayout" name="formLayout_2">
- <property name="labelAlignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <item row="0" column="0">
- <widget class="QCheckBox" name="mppe">
- <property name="text">
- <string>Use point-to-point encryption (MPPE)</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QCheckBox" name="bsdComp">
- <property name="text">
- <string>Use BSD data compression</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QCheckBox" name="deflateComp">
- <property name="text">
- <string>Use Deflate data compression</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QCheckBox" name="tcpComp">
- <property name="text">
- <string>Use TCP header compression</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="mppe128">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="styleSheet">
- <string notr="true">padding-left: 20px</string>
- </property>
- <property name="text">
- <string>Require 128-bit encryption</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="mppeStateful">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="styleSheet">
- <string notr="true">padding-left: 20px</string>
- </property>
- <property name="text">
- <string>Use stateful MPPE</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="echoGroup">
- <property name="title">
- <string>Echo</string>
- </property>
- <property name="flat">
- <bool>false</bool>
- </property>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <widget class="QCheckBox" name="senddEcho">
- <property name="text">
- <string>Send PPP echo packets</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>113</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <tabstops>
- <tabstop>eap</tabstop>
- <tabstop>mschap</tabstop>
- <tabstop>pap</tabstop>
- <tabstop>mschapv2</tabstop>
- <tabstop>chap</tabstop>
- <tabstop>mppe</tabstop>
- <tabstop>bsdComp</tabstop>
- <tabstop>deflateComp</tabstop>
- <tabstop>tcpComp</tabstop>
- <tabstop>senddEcho</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>mppe</sender>
- <signal>toggled(bool)</signal>
- <receiver>mppe128</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>137</x>
- <y>204</y>
- </hint>
- <hint type="destinationlabel">
- <x>133</x>
- <y>232</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>mppe</sender>
- <signal>toggled(bool)</signal>
- <receiver>mppeStateful</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>199</x>
- <y>205</y>
- </hint>
- <hint type="destinationlabel">
- <x>177</x>
- <y>256</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PppoeWidget</class>
- <widget class="QWidget" name="PppoeWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Service:</string>
- </property>
- <property name="buddy">
- <cstring>service</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="service"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>username</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="username"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>password</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KLineEdit" name="password">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QCheckBox" name="cbShowPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "pppoewidget.h"
-#include "ui_pppoe.h"
-
-#include <NetworkManagerQt/PppoeSetting>
-
-PppoeWidget::PppoeWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::PppoeWidget)
-{
- m_ui->setupUi(this);
-
- connect(m_ui->cbShowPassword, SIGNAL(toggled(bool)), SLOT(showPassword(bool)));
- connect(m_ui->username, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (setting)
- loadConfig(setting);
-}
-
-PppoeWidget::~PppoeWidget()
-{
- delete m_ui;
-}
-
-void PppoeWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::PppoeSetting::Ptr pppoeSetting = setting.staticCast<NetworkManager::PppoeSetting>();
-
- m_ui->service->setText(pppoeSetting->service());
- m_ui->username->setText(pppoeSetting->username());
- m_ui->password->setText(pppoeSetting->password());
-}
-
-QVariantMap PppoeWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned);
-
- NetworkManager::PppoeSetting pppoeSetting;
- if (!m_ui->service->text().isEmpty())
- pppoeSetting.setService(m_ui->service->text());
- if (!m_ui->username->text().isEmpty())
- pppoeSetting.setUsername(m_ui->username->text());
- if (!m_ui->password->text().isEmpty())
- pppoeSetting.setPassword(m_ui->password->text());
-
- if (agentOwned) {
- pppoeSetting.setPasswordFlags(NetworkManager::Setting::AgentOwned);
- }
-
- return pppoeSetting.toMap();
-}
-
-void PppoeWidget::showPassword(bool show)
-{
- m_ui->password->setPasswordMode(!show);
-}
-
-bool PppoeWidget::isValid() const
-{
- return !m_ui->username->text().isEmpty();
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_PPPOE_WIDGET_H
-#define PLASMA_NM_PPPOE_WIDGET_H
-
-#include <QtGui/QWidget>
-
-#include <NetworkManagerQt/Setting>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class PppoeWidget;
-}
-
-class PLASMA_NM_EXPORT PppoeWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit PppoeWidget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~PppoeWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void showPassword(bool show);
-
-private:
- Ui::PppoeWidget * m_ui;
-};
-
-#endif // PLASMA_NM_PPPOE_WIDGET_H
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "pppwidget.h"
-#include "ui_ppp.h"
-
-#include <NetworkManagerQt/PppSetting>
-
-PPPWidget::PPPWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::PPPWidget)
-{
- m_ui->setupUi(this);
-
- KAcceleratorManager::manage(this);
-
- if (setting)
- loadConfig(setting);
-}
-
-PPPWidget::~PPPWidget()
-{
- delete m_ui;
-}
-
-void PPPWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::PppSetting::Ptr pppSetting = setting.staticCast<NetworkManager::PppSetting>();
-
- m_ui->eap->setChecked(!pppSetting->refuseEap());
- m_ui->pap->setChecked(!pppSetting->refusePap());
- m_ui->chap->setChecked(!pppSetting->refuseChap());
- m_ui->mschap->setChecked(!pppSetting->refuseMschap());
- m_ui->mschapv2->setChecked(!pppSetting->refuseMschapv2());
-
- m_ui->mppe->setChecked(pppSetting->requireMppe());
- m_ui->mppe128->setChecked(pppSetting->requireMppe128());
- m_ui->mppeStateful->setChecked(pppSetting->mppeStateful());
-
- m_ui->bsdComp->setChecked(!pppSetting->noBsdComp());
- m_ui->deflateComp->setChecked(!pppSetting->noDeflate());
- m_ui->tcpComp->setChecked(!pppSetting->noVjComp());
-
- if (pppSetting->lcpEchoInterval() > 0) {
- m_ui->senddEcho->setChecked(true);
- } else {
- m_ui->senddEcho->setChecked(false);
- }
-}
-
-QVariantMap PPPWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned);
-
- NetworkManager::PppSetting pppSetting;
-
- pppSetting.setRefuseEap(!m_ui->eap->isChecked());
- pppSetting.setRefusePap(!m_ui->pap->isChecked());
- pppSetting.setRefuseChap(!m_ui->chap->isChecked());
- pppSetting.setRefuseMschap(!m_ui->mschap->isChecked());
- pppSetting.setRefuseMschapv2(!m_ui->mschapv2->isChecked());
-
- pppSetting.setRequireMppe(m_ui->mppe->isChecked());
- pppSetting.setRequireMppe128(m_ui->mppe128->isChecked());
- pppSetting.setMppeStateful(m_ui->mppeStateful->isChecked());
-
- pppSetting.setNoBsdComp(!m_ui->bsdComp->isChecked());
- pppSetting.setNoDeflate(!m_ui->deflateComp->isChecked());
- pppSetting.setNoVjComp(!m_ui->tcpComp->isChecked());
-
- if (m_ui->senddEcho->isChecked()) {
- pppSetting.setLcpEchoFailure(5);
- pppSetting.setLcpEchoInterval(30);
- }
-
- return pppSetting.toMap();
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_PPP_WIDGET_H
-#define PLASMA_NM_PPP_WIDGET_H
-
-#include <QtGui/QWidget>
-
-#include <NetworkManagerQt/Setting>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class PPPWidget;
-}
-
-class PLASMA_NM_EXPORT PPPWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit PPPWidget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~PPPWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
-private:
- Ui::PPPWidget * m_ui;
-};
-
-#endif // PLASMA_NM_PPP_WIDGET_H
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "security802-1x.h"
-#include "ui_802-1x.h"
-
-#include <QDebug>
-#include <KAcceleratorManager>
-
-Security8021x::Security8021x(const NetworkManager::Security8021xSetting::Ptr &setting, bool wifiMode, QWidget *parent) :
- QWidget(parent),
- m_setting(setting),
- m_ui(new Ui::Security8021x)
-{
- m_ui->setupUi(this);
-
- m_ui->auth->setItemData(0, NetworkManager::Security8021xSetting::EapMethodMd5);
- m_ui->auth->setItemData(1, NetworkManager::Security8021xSetting::EapMethodTls);
- m_ui->auth->setItemData(2, NetworkManager::Security8021xSetting::EapMethodLeap);
- m_ui->auth->setItemData(3, NetworkManager::Security8021xSetting::EapMethodFast);
- m_ui->auth->setItemData(4, NetworkManager::Security8021xSetting::EapMethodTtls);
- m_ui->auth->setItemData(5, NetworkManager::Security8021xSetting::EapMethodPeap);
-
- connect(m_ui->cbShowMd5Password, SIGNAL(toggled(bool)), SLOT(setShowMD5Password(bool)));
- connect(m_ui->cbShowTlsPassword, SIGNAL(toggled(bool)), SLOT(setShowTlsPrivateKeyPassword(bool)));
- connect(m_ui->cbShowLeapPassword, SIGNAL(toggled(bool)), SLOT(setShowLeapPassword(bool)));
- connect(m_ui->cbShowFastPassword, SIGNAL(toggled(bool)), SLOT(setShowFastPassword(bool)));
- connect(m_ui->cbShowTtlsPassword, SIGNAL(toggled(bool)), SLOT(setShowTtlsPassword(bool)));
- connect(m_ui->cbShowPeapPassword, SIGNAL(toggled(bool)), SLOT(setShowPeapPassword(bool)));
-
- connect(m_ui->cbAskMd5Password, SIGNAL(toggled(bool)), m_ui->cbShowMd5Password, SLOT(setDisabled(bool)));
- connect(m_ui->cbAskFastPassword, SIGNAL(toggled(bool)), m_ui->cbShowFastPassword, SLOT(setDisabled(bool)));
- connect(m_ui->cbAskPeapPassword, SIGNAL(toggled(bool)), m_ui->cbShowPeapPassword, SLOT(setDisabled(bool)));
- connect(m_ui->cbAskTtlsPassword, SIGNAL(toggled(bool)), m_ui->cbShowTtlsPassword, SLOT(setDisabled(bool)));
-
- if (wifiMode) {
- m_ui->auth->removeItem(m_ui->auth->findData(NetworkManager::Security8021xSetting::EapMethodMd5)); // MD 5
- m_ui->stackedWidget->removeWidget(m_ui->md5Page);
- } else {
- m_ui->auth->removeItem(m_ui->auth->findData(NetworkManager::Security8021xSetting::EapMethodLeap)); // LEAP
- m_ui->stackedWidget->removeWidget(m_ui->leapPage);
- }
-
- KAcceleratorManager::manage(this);
- connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(currentAuthChanged(int)));
-
- if (m_setting)
- loadConfig();
-}
-
-Security8021x::~Security8021x()
-{
- delete m_ui;
-}
-
-void Security8021x::loadConfig()
-{
- const QList<NetworkManager::Security8021xSetting::EapMethod> eapMethods = m_setting->eapMethods();
- const NetworkManager::Security8021xSetting::AuthMethod phase2AuthMethod = m_setting->phase2AuthMethod();
- const bool notSavedPassword = m_setting->passwordFlags() & NetworkManager::Setting::NotSaved;
-
- if (eapMethods.contains(NetworkManager::Security8021xSetting::EapMethodMd5)) {
- m_ui->auth->setCurrentIndex(m_ui->auth->findData(NetworkManager::Security8021xSetting::EapMethodMd5));
- m_ui->md5UserName->setText(m_setting->identity());
- m_ui->md5Password->setText(m_setting->password());
- m_ui->cbAskMd5Password->setChecked(notSavedPassword);
- } else if (eapMethods.contains(NetworkManager::Security8021xSetting::EapMethodTls)) {
- m_ui->auth->setCurrentIndex(m_ui->auth->findData(NetworkManager::Security8021xSetting::EapMethodTls));
- m_ui->tlsIdentity->setText(m_setting->identity());
- m_ui->tlsUserCert->setText(m_setting->clientCertificate()); // FIXME check the blob vs. path case
- m_ui->tlsCACert->setText(m_setting->caCertificate()); // FIXME check the blob vs. path case
- m_ui->tlsPrivateKey->setText(m_setting->privateKey()); // FIXME check the blob vs. path case
- m_ui->tlsPrivateKeyPassword->setText(m_setting->privateKeyPassword());
- } else if (eapMethods.contains(NetworkManager::Security8021xSetting::EapMethodLeap)) {
- m_ui->auth->setCurrentIndex(m_ui->auth->findData(NetworkManager::Security8021xSetting::EapMethodLeap));
- m_ui->leapUsername->setText(m_setting->identity());
- m_ui->leapPassword->setText(m_setting->password());
- } else if (eapMethods.contains(NetworkManager::Security8021xSetting::EapMethodFast)) {
- m_ui->auth->setCurrentIndex(m_ui->auth->findData(NetworkManager::Security8021xSetting::EapMethodFast));
- m_ui->fastAnonIdentity->setText(m_setting->anonymousIdentity());
- m_ui->fastAllowPacProvisioning->setChecked((int)m_setting->phase1FastProvisioning() > 0);
- m_ui->pacMethod->setCurrentIndex(m_setting->phase1FastProvisioning() - 1);
- m_ui->pacFile->setText(m_setting->pacFile()); // TODO check the file scheme used
- if (phase2AuthMethod == NetworkManager::Security8021xSetting::AuthMethodGtc)
- m_ui->fastInnerAuth->setCurrentIndex(0);
- else
- m_ui->fastInnerAuth->setCurrentIndex(1);
- m_ui->fastUsername->setText(m_setting->identity());
- m_ui->fastPassword->setText(m_setting->password());
- m_ui->cbAskFastPassword->setChecked(notSavedPassword);
- } else if (eapMethods.contains(NetworkManager::Security8021xSetting::EapMethodTtls)) {
- m_ui->auth->setCurrentIndex(m_ui->auth->findData(NetworkManager::Security8021xSetting::EapMethodTtls));
- m_ui->ttlsAnonIdentity->setText(m_setting->anonymousIdentity());
- m_ui->ttlsCACert->setText(m_setting->caCertificate()); // FIXME check the blob vs. path case
- if (phase2AuthMethod == NetworkManager::Security8021xSetting::AuthMethodPap)
- m_ui->ttlsInnerAuth->setCurrentIndex(0);
- else if (phase2AuthMethod == NetworkManager::Security8021xSetting::AuthMethodMschap)
- m_ui->ttlsInnerAuth->setCurrentIndex(1);
- else if (phase2AuthMethod == NetworkManager::Security8021xSetting::AuthMethodMschapv2)
- m_ui->ttlsInnerAuth->setCurrentIndex(2);
- else if (phase2AuthMethod == NetworkManager::Security8021xSetting::AuthMethodChap)
- m_ui->ttlsInnerAuth->setCurrentIndex(3);
- m_ui->ttlsUsername->setText(m_setting->identity());
- m_ui->ttlsPassword->setText(m_setting->password());
- m_ui->cbAskTtlsPassword->setChecked(notSavedPassword);
- } else if (eapMethods.contains(NetworkManager::Security8021xSetting::EapMethodPeap)) {
- m_ui->auth->setCurrentIndex(m_ui->auth->findData(NetworkManager::Security8021xSetting::EapMethodPeap));
- m_ui->peapAnonIdentity->setText(m_setting->anonymousIdentity());
- m_ui->peapCACert->setText(m_setting->caCertificate()); // FIXME check the blob vs. path case
- m_ui->peapVersion->setCurrentIndex(m_setting->phase1PeapVersion() + 1);
- if (phase2AuthMethod == NetworkManager::Security8021xSetting::AuthMethodMschapv2)
- m_ui->peapInnerAuth->setCurrentIndex(0);
- else if (phase2AuthMethod == NetworkManager::Security8021xSetting::AuthMethodMd5)
- m_ui->peapInnerAuth->setCurrentIndex(1);
- else if (phase2AuthMethod == NetworkManager::Security8021xSetting::AuthMethodGtc)
- m_ui->peapInnerAuth->setCurrentIndex(2);
- m_ui->peapUsername->setText(m_setting->identity());
- m_ui->peapPassword->setText(m_setting->password());
- m_ui->cbAskPeapPassword->setChecked(notSavedPassword);
- }
-}
-
-QVariantMap Security8021x::setting(bool agentOwned) const
-{
- NetworkManager::Security8021xSetting setting;
-
- NetworkManager::Security8021xSetting::EapMethod method =
- static_cast<NetworkManager::Security8021xSetting::EapMethod>(m_ui->auth->itemData(m_ui->auth->currentIndex()).toInt());
-
- setting.setEapMethods(QList<NetworkManager::Security8021xSetting::EapMethod>() << method);
-
- if (method == NetworkManager::Security8021xSetting::EapMethodMd5) {
- if (!m_ui->md5UserName->text().isEmpty())
- setting.setIdentity(m_ui->md5UserName->text());
- if (m_ui->cbAskMd5Password->isChecked())
- setting.setPasswordFlags(NetworkManager::Setting::NotSaved);
- else if (!m_ui->md5Password->text().isEmpty())
- setting.setPassword(m_ui->md5Password->text());
-
- if (agentOwned && !m_ui->cbAskMd5Password->isChecked()) {
- setting.setPasswordFlags(NetworkManager::Setting::AgentOwned);
- }
- } else if (method == NetworkManager::Security8021xSetting::EapMethodTls) {
- if (!m_ui->tlsIdentity->text().isEmpty())
- setting.setIdentity(m_ui->tlsIdentity->text());
- if (!m_ui->tlsUserCert->url().isEmpty())
- setting.setClientCertificate(QFile::encodeName(m_ui->tlsUserCert->url().url()).append('\0'));
- if (!m_ui->tlsCACert->url().isEmpty())
- setting.setCaCertificate(QFile::encodeName(m_ui->tlsCACert->url().url()).append('\0'));
- if (!m_ui->tlsPrivateKey->url().isEmpty())
- setting.setPrivateKey(QFile::encodeName(m_ui->tlsPrivateKey->url().url()).append('\0'));
- if (!m_ui->tlsPrivateKeyPassword->text().isEmpty())
- setting.setPrivateKeyPassword(m_ui->tlsPrivateKeyPassword->text());
-
- if (agentOwned) {
- setting.setPrivateKeyPasswordFlags(NetworkManager::Setting::AgentOwned);
- }
- } else if (method == NetworkManager::Security8021xSetting::EapMethodLeap) {
- if (!m_ui->leapUsername->text().isEmpty())
- setting.setIdentity(m_ui->leapUsername->text());
- if (!m_ui->leapPassword->text().isEmpty())
- setting.setPassword(m_ui->leapPassword->text());
-
- if (agentOwned) {
- setting.setPasswordFlags(NetworkManager::Setting::AgentOwned);
- }
- } else if (method == NetworkManager::Security8021xSetting::EapMethodFast) {
- if (!m_ui->fastAnonIdentity->text().isEmpty())
- setting.setAnonymousIdentity(m_ui->fastAnonIdentity->text());
- if (!m_ui->fastAllowPacProvisioning->isChecked()) {
- setting.setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioningDisabled);
- } else {
- setting.setPhase1FastProvisioning(static_cast<NetworkManager::Security8021xSetting::FastProvisioning>(m_ui->pacMethod->currentIndex() + 1));
- }
- if (!m_ui->pacFile->text().isEmpty())
- setting.setPacFile(QFile::encodeName(m_ui->pacFile->url().url()).append('\0'));
- if (m_ui->fastInnerAuth->currentIndex() == 0)
- setting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodGtc);
- else
- setting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodMschapv2);
- if (!m_ui->fastUsername->text().isEmpty())
- setting.setIdentity(m_ui->fastUsername->text());
- if (m_ui->cbAskFastPassword->isChecked())
- setting.setPasswordFlags(NetworkManager::Setting::NotSaved);
- else if (!m_ui->fastPassword->text().isEmpty())
- setting.setPassword(m_ui->fastPassword->text());
-
- if (agentOwned && !m_ui->cbAskFastPassword->isChecked()) {
- setting.setPasswordFlags(NetworkManager::Setting::AgentOwned);
- }
- } else if (method == NetworkManager::Security8021xSetting::EapMethodTtls) {
- if (!m_ui->ttlsAnonIdentity->text().isEmpty())
- setting.setAnonymousIdentity(m_ui->ttlsAnonIdentity->text());
- if (!m_ui->ttlsCACert->text().isEmpty())
- setting.setCaCertificate(QFile::encodeName(m_ui->ttlsCACert->url().url()).append('\0'));
- const int innerAuth = m_ui->ttlsInnerAuth->currentIndex();
- if (innerAuth == 0)
- setting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodPap);
- else if (innerAuth == 1)
- setting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodMschap);
- else if (innerAuth == 2)
- setting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodMschapv2);
- else if (innerAuth == 3)
- setting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodChap);
- if (!m_ui->ttlsUsername->text().isEmpty())
- setting.setIdentity(m_ui->ttlsUsername->text());
- if (m_ui->cbAskTtlsPassword->isChecked())
- setting.setPasswordFlags(NetworkManager::Setting::NotSaved);
- else if (!m_ui->ttlsPassword->text().isEmpty())
- setting.setPassword(m_ui->ttlsPassword->text());
-
- if (agentOwned && !m_ui->cbAskTtlsPassword->isChecked()) {
- setting.setPasswordFlags(NetworkManager::Setting::AgentOwned);
- }
- } else if (method == NetworkManager::Security8021xSetting::EapMethodPeap) {
- if (!m_ui->peapAnonIdentity->text().isEmpty())
- setting.setAnonymousIdentity(m_ui->peapAnonIdentity->text());
- if (!m_ui->peapCACert->text().isEmpty())
- setting.setCaCertificate(QFile::encodeName(m_ui->peapCACert->url().url()).append('\0'));
- setting.setPhase1PeapVersion(static_cast<NetworkManager::Security8021xSetting::PeapVersion>(m_ui->peapVersion->currentIndex() - 1));
- const int innerAuth = m_ui->peapInnerAuth->currentIndex();
- if (innerAuth == 0)
- setting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodMschapv2);
- else if (innerAuth == 1)
- setting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodMd5);
- else if (innerAuth == 2)
- setting.setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethodGtc);
- if (m_ui->cbAskPeapPassword->isChecked())
- setting.setPasswordFlags(NetworkManager::Setting::NotSaved);
- else if (!m_ui->peapPassword->text().isEmpty())
- setting.setPassword(m_ui->peapPassword->text());
- if (!m_ui->peapUsername->text().isEmpty())
- setting.setIdentity(m_ui->peapUsername->text());
-
- if (agentOwned && !m_ui->cbAskPeapPassword->isChecked()) {
- setting.setPasswordFlags(NetworkManager::Setting::AgentOwned);
- }
- }
-
- return setting.toMap();
-}
-
-void Security8021x::setShowMD5Password(bool on)
-{
- m_ui->md5Password->setPasswordMode(!on);
-}
-
-void Security8021x::setShowTlsPrivateKeyPassword(bool on)
-{
- m_ui->tlsPrivateKeyPassword->setPasswordMode(!on);
-}
-
-void Security8021x::setShowLeapPassword(bool on)
-{
- m_ui->leapPassword->setPasswordMode(!on);
-}
-
-void Security8021x::setShowFastPassword(bool on)
-{
- m_ui->fastPassword->setPasswordMode(!on);
-}
-
-void Security8021x::setShowTtlsPassword(bool on)
-{
- m_ui->ttlsPassword->setPasswordMode(!on);
-}
-
-void Security8021x::setShowPeapPassword(bool on)
-{
- m_ui->peapPassword->setPasswordMode(!on);
-}
-
-void Security8021x::currentAuthChanged(int index)
-{
- Q_UNUSED(index);
- KAcceleratorManager::manage(m_ui->stackedWidget->currentWidget());
-}
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_SECURITY8021X_H
-#define PLASMA_NM_SECURITY8021X_H
-
-#include <QWidget>
-
-#include <NetworkManagerQt/Security8021xSetting>
-
-namespace Ui
-{
-class Security8021x;
-}
-
-class Security8021x: public QWidget
-{
- Q_OBJECT
-public:
- Security8021x(const NetworkManager::Security8021xSetting::Ptr &setting, bool wifiMode, QWidget *parent = 0);
- virtual ~Security8021x();
- QVariantMap setting(bool agentOwned = false) const;
-
-private slots:
- void setShowMD5Password(bool on);
- void setShowTlsPrivateKeyPassword(bool on);
- void setShowLeapPassword(bool on);
- void setShowFastPassword(bool on);
- void setShowTtlsPassword(bool on);
- void setShowPeapPassword(bool on);
- void currentAuthChanged(int index);
-
-private:
- void loadConfig();
- NetworkManager::Security8021xSetting::Ptr m_setting;
- Ui::Security8021x * m_ui;
-};
-
-#endif // SECURITY8021X_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <ltinkl@redhat.com></author>
- <class>VlanWidget</class>
- <widget class="QWidget" name="VlanWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>394</width>
- <height>193</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Parent interface:</string>
- </property>
- <property name="buddy">
- <cstring>parent</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KComboBox" name="parent">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>VLAN id:</string>
- </property>
- <property name="buddy">
- <cstring>id</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QSpinBox" name="id">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximum">
- <number>999999999</number>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>VLAN interface name:</string>
- </property>
- <property name="buddy">
- <cstring>ifaceName</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="KLineEdit" name="ifaceName"/>
- </item>
- <item row="10" column="1">
- <widget class="QCheckBox" name="reorderHeaders">
- <property name="text">
- <string>Output packet headers reordering</string>
- </property>
- </widget>
- </item>
- <item row="12" column="1">
- <widget class="QCheckBox" name="gvrp">
- <property name="toolTip">
- <string>GARP VLAN Registration Protocol</string>
- </property>
- <property name="text">
- <string>GVRP</string>
- </property>
- </widget>
- </item>
- <item row="13" column="1">
- <widget class="QCheckBox" name="looseBinding">
- <property name="text">
- <string>Loose binding</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>parent</tabstop>
- <tabstop>id</tabstop>
- <tabstop>ifaceName</tabstop>
- <tabstop>reorderHeaders</tabstop>
- <tabstop>gvrp</tabstop>
- <tabstop>looseBinding</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "vlanwidget.h"
-#include "ui_vlan.h"
-#include "uiutils.h"
-
-#include <NetworkManagerQt/VlanSetting>
-#include <NetworkManagerQt/Settings>
-
-VlanWidget::VlanWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::VlanWidget)
-{
- m_ui->setupUi(this);
-
- fillConnections();
-
- connect(m_ui->ifaceName, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->parent, SIGNAL(currentIndexChanged(int)), SLOT(slotWidgetChanged()));
- connect(m_ui->parent->lineEdit(), SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (setting)
- loadConfig(setting);
-}
-
-VlanWidget::~VlanWidget()
-{
- delete m_ui;
-}
-
-void VlanWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::VlanSetting::Ptr vlanSetting = setting.staticCast<NetworkManager::VlanSetting>();
-
- m_ui->parent->setCurrentIndex(m_ui->parent->findData(vlanSetting->parent()));
-
- m_ui->id->setValue(vlanSetting->id());
- m_ui->ifaceName->setText(vlanSetting->interfaceName());
-
- m_ui->reorderHeaders->setChecked(vlanSetting->flags().testFlag(NetworkManager::VlanSetting::ReorderHeaders));
- m_ui->gvrp->setChecked(vlanSetting->flags().testFlag(NetworkManager::VlanSetting::Gvrp));
- m_ui->looseBinding->setChecked(vlanSetting->flags().testFlag(NetworkManager::VlanSetting::LooseBinding));
-}
-
-QVariantMap VlanWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned);
-
- NetworkManager::VlanSetting setting;
-
- setting.setParent(m_ui->parent->itemData(m_ui->parent->currentIndex()).toString());
- setting.setId(m_ui->id->value());
-
- const QString ifaceName = m_ui->ifaceName->text();
- if (!ifaceName.isEmpty())
- setting.setInterfaceName(ifaceName);
-
- NetworkManager::VlanSetting::Flags flags;
- if (m_ui->reorderHeaders->isChecked())
- flags |= NetworkManager::VlanSetting::ReorderHeaders;
- if (m_ui->gvrp->isChecked())
- flags |= NetworkManager::VlanSetting::Gvrp;
- if (m_ui->looseBinding->isChecked())
- flags |= NetworkManager::VlanSetting::LooseBinding;
- if (flags)
- setting.setFlags(flags);
-
- return setting.toMap();
-}
-
-void VlanWidget::fillConnections()
-{
- m_ui->parent->clear();
-
- foreach (const NetworkManager::Connection::Ptr &con, NetworkManager::listConnections()) {
- if (!con->settings()->isSlave() && con->settings()->connectionType() == NetworkManager::ConnectionSettings::Wired)
- m_ui->parent->addItem(con->name(), con->uuid());
- }
-}
-
-bool VlanWidget::isValid() const
-{
- return !m_ui->parent->currentText().isEmpty() || !m_ui->ifaceName->text().isEmpty();
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_VLAN_WIDGET_H
-#define PLASMA_NM_VLAN_WIDGET_H
-
-#include <QWidget>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class VlanWidget;
-}
-
-class PLASMA_NM_EXPORT VlanWidget : public SettingWidget
-{
-Q_OBJECT
-
-public:
- explicit VlanWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~VlanWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private:
- void fillConnections();
- Ui::VlanWidget * m_ui;
-};
-
-#endif // PLASMA_NM_VLAN_WIDGET_H
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "wificonnectionwidget.h"
-#include "ui_wificonnectionwidget.h"
-
-#include <NetworkManagerQt/Utils>
-
-#include <KDebug>
-#include <KLocale>
-
-#include "uiutils.h"
-
-WifiConnectionWidget::WifiConnectionWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::WifiConnectionWidget)
-{
- qsrand(QTime::currentTime().msec());
-
- m_ui->setupUi(this);
-
- connect(m_ui->btnRandomMacAddr, SIGNAL(clicked()), SLOT(generateRandomClonedMac()));
- connect(m_ui->SSIDCombo, SIGNAL(ssidChanged()), SLOT(ssidChanged()));
- connect(m_ui->modeComboBox, SIGNAL(currentIndexChanged(int)), SLOT(modeChanged(int)));
- connect(m_ui->band, SIGNAL(currentIndexChanged(int)), SLOT(bandChanged(int)));
-
- // Validation
- connect(m_ui->macAddress, SIGNAL(hwAddressChanged()), SLOT(slotWidgetChanged()));
- connect(m_ui->BSSIDCombo, SIGNAL(bssidChanged()), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (setting)
- loadConfig(setting);
-}
-
-WifiConnectionWidget::~WifiConnectionWidget()
-{
- delete m_ui;
-}
-
-void WifiConnectionWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::WirelessSetting::Ptr wifiSetting = setting.staticCast<NetworkManager::WirelessSetting>();
-
- m_ui->SSIDCombo->init(QString::fromUtf8(wifiSetting->ssid()));
-
- if (wifiSetting->mode() != NetworkManager::WirelessSetting::Infrastructure) {
- m_ui->modeComboBox->setCurrentIndex(wifiSetting->mode());
- }
- modeChanged(wifiSetting->mode());
-
- m_ui->BSSIDCombo->init(NetworkManager::Utils::macAddressAsString(wifiSetting->bssid()), QString::fromUtf8(wifiSetting->ssid()));
-
- m_ui->band->setCurrentIndex(wifiSetting->band());
- if (wifiSetting->band() != NetworkManager::WirelessSetting::Automatic) {
- m_ui->channel->setCurrentIndex(m_ui->channel->findData(wifiSetting->channel()));
- }
-
- m_ui->macAddress->init(NetworkManager::Device::Wifi, NetworkManager::Utils::macAddressAsString(wifiSetting->macAddress()));
-
- if (!wifiSetting->clonedMacAddress().isEmpty()) {
- m_ui->clonedMacAddress->setText(NetworkManager::Utils::macAddressAsString(wifiSetting->clonedMacAddress()));
- }
-
- if (wifiSetting->mtu()) {
- m_ui->mtu->setValue(wifiSetting->mtu());
- }
-
- if (wifiSetting->hidden()) {
- m_ui->hiddenNetwork->setChecked(true);
- }
-}
-
-QVariantMap WifiConnectionWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned);
-
- NetworkManager::WirelessSetting wifiSetting;
-
- wifiSetting.setSsid(m_ui->SSIDCombo->ssid().toUtf8());
-
- wifiSetting.setMode(static_cast<NetworkManager::WirelessSetting::NetworkMode>(m_ui->modeComboBox->currentIndex()));
-
- wifiSetting.setBssid(NetworkManager::Utils::macAddressFromString(m_ui->BSSIDCombo->bssid()));
-
- if (wifiSetting.mode() != NetworkManager::WirelessSetting::Infrastructure && m_ui->band->currentIndex() != 0) {
- wifiSetting.setBand((NetworkManager::WirelessSetting::FrequencyBand)m_ui->band->currentIndex());
- wifiSetting.setChannel(m_ui->channel->itemData(m_ui->channel->currentIndex()).toUInt());
- }
-
- wifiSetting.setMacAddress(NetworkManager::Utils::macAddressFromString(m_ui->macAddress->hwAddress()));
-
- if (!m_ui->clonedMacAddress->text().isEmpty() && m_ui->clonedMacAddress->text() != ":::::") {
- wifiSetting.setClonedMacAddress(NetworkManager::Utils::macAddressFromString(m_ui->clonedMacAddress->text()));
- }
-
- if (m_ui->mtu->value()) {
- wifiSetting.setMtu(m_ui->mtu->value());
- }
-
- wifiSetting.setHidden(m_ui->hiddenNetwork->isChecked());
-
- return wifiSetting.toMap();
-}
-
-void WifiConnectionWidget::generateRandomClonedMac()
-{
- QByteArray mac;
- mac.resize(6);
- for (int i = 0; i < 6; i++) {
- int random = qrand() % 255;
- mac[i] = random;
- }
- m_ui->clonedMacAddress->setText(NetworkManager::Utils::macAddressAsString(mac));
-}
-
-void WifiConnectionWidget::ssidChanged()
-{
- m_ui->BSSIDCombo->init(m_ui->BSSIDCombo->bssid(), m_ui->SSIDCombo->ssid());
- slotWidgetChanged();
-}
-
-void WifiConnectionWidget::modeChanged(int mode)
-{
- if (mode == NetworkManager::WirelessSetting::Infrastructure) {
- m_ui->BSSIDLabel->setVisible(true);
- m_ui->BSSIDCombo->setVisible(true);
- m_ui->bandLabel->setVisible(false);
- m_ui->band->setVisible(false);
- m_ui->channelLabel->setVisible(false);
- m_ui->channel->setVisible(false);
- } else {
- m_ui->BSSIDLabel->setVisible(false);
- m_ui->BSSIDCombo->setVisible(false);
- m_ui->bandLabel->setVisible(true);
- m_ui->band->setVisible(true);
- m_ui->channelLabel->setVisible(true);
- m_ui->channel->setVisible(true);
- }
-}
-
-void WifiConnectionWidget::bandChanged(int band)
-{
- m_ui->channel->clear();
-
- if (band == NetworkManager::WirelessSetting::Automatic) {
- m_ui->channel->setEnabled(false);
- } else {
- fillChannels((NetworkManager::WirelessSetting::FrequencyBand)band);
- m_ui->channel->setEnabled(true);
- }
-}
-
-void WifiConnectionWidget::fillChannels(NetworkManager::WirelessSetting::FrequencyBand band)
-{
- QList<QPair<int, int> > channels;
-
- if (band == NetworkManager::WirelessSetting::A) {
- channels = NetworkManager::Utils::getAFreqs();
- } else if (band == NetworkManager::WirelessSetting::Bg) {
- channels = NetworkManager::Utils::getBFreqs();
- } else {
- kWarning() << "Unhandled band number" << band;
- return;
- }
-
- QListIterator<QPair<int,int> > i(channels);
- while (i.hasNext()) {
- QPair<int,int> channel = i.next();
- m_ui->channel->addItem(i18n("%1 (%2 MHz)", channel.first, channel.second), channel.first);
- }
-}
-
-bool WifiConnectionWidget::isValid() const
-{
- return !m_ui->SSIDCombo->currentText().isEmpty() && m_ui->macAddress->isValid() && m_ui->BSSIDCombo->isValid();
-}
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_WIFI_CONNECTION_WIDGET_H
-#define PLASMA_NM_WIFI_CONNECTION_WIDGET_H
-
-#include <QWidget>
-
-#include <NetworkManagerQt/WirelessSetting>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class WifiConnectionWidget;
-}
-
-class PLASMA_NM_EXPORT WifiConnectionWidget : public SettingWidget
-{
-Q_OBJECT
-
-public:
- explicit WifiConnectionWidget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~WifiConnectionWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void generateRandomClonedMac();
- void ssidChanged();
- void modeChanged(int mode);
- void bandChanged(int band);
-
-private:
- Ui::WifiConnectionWidget * m_ui;
- void fillChannels(NetworkManager::WirelessSetting::FrequencyBand band);
-};
-
-#endif // PLASMA_NM_WIFI_CONNECTION_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>WifiConnectionWidget</class>
- <widget class="QWidget" name="WifiConnectionWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>391</width>
- <height>279</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="SSIDLabel">
- <property name="text">
- <string>SSID:</string>
- </property>
- <property name="buddy">
- <cstring>SSIDCombo</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="SsidComboBox" name="SSIDCombo">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="modeLabel">
- <property name="text">
- <string>Mode:</string>
- </property>
- <property name="buddy">
- <cstring>modeComboBox</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KComboBox" name="modeComboBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>Infrastructure</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Ad-hoc</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Access Point</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="BSSIDLabel">
- <property name="text">
- <string>BSSID:</string>
- </property>
- <property name="buddy">
- <cstring>BSSIDCombo</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="BssidComboBox" name="BSSIDCombo">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="7" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Restrict to device:</string>
- </property>
- <property name="buddy">
- <cstring>macAddress</cstring>
- </property>
- </widget>
- </item>
- <item row="7" column="1">
- <widget class="HwAddrComboBox" name="macAddress">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="8" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Cloned MAC address:</string>
- </property>
- <property name="buddy">
- <cstring>clonedMacAddress</cstring>
- </property>
- </widget>
- </item>
- <item row="8" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="KLineEdit" name="clonedMacAddress">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="inputMask">
- <string notr="true">HH:HH:HH:HH:HH:HH;_</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnRandomMacAddr">
- <property name="text">
- <string>Random...</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="10" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>MTU:</string>
- </property>
- <property name="buddy">
- <cstring>mtu</cstring>
- </property>
- </widget>
- </item>
- <item row="10" column="1">
- <widget class="QSpinBox" name="mtu">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="specialValueText">
- <string>Automatic</string>
- </property>
- <property name="suffix">
- <string> bytes</string>
- </property>
- <property name="prefix">
- <string/>
- </property>
- <property name="maximum">
- <number>9999</number>
- </property>
- </widget>
- </item>
- <item row="11" column="1">
- <widget class="QCheckBox" name="hiddenNetwork">
- <property name="toolTip">
- <string>Mark this if you want to create a connection for a hidden network</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="11" column="0">
- <widget class="QLabel" name="label_4">
- <property name="toolTip">
- <string>Mark this if you want to create a connection for a hidden network</string>
- </property>
- <property name="text">
- <string>Hidden network:</string>
- </property>
- <property name="buddy">
- <cstring>hiddenNetwork</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="bandLabel">
- <property name="text">
- <string>Band:</string>
- </property>
- <property name="buddy">
- <cstring>band</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="KComboBox" name="band">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string extracomment="automatic band">Automatic</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>A (5 GHz)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>B/G (2.4 GHz)</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="channelLabel">
- <property name="text">
- <string>Channel:</string>
- </property>
- <property name="buddy">
- <cstring>channel</cstring>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="KComboBox" name="channel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>HwAddrComboBox</class>
- <extends>QComboBox</extends>
- <header>hwaddrcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>SsidComboBox</class>
- <extends>QComboBox</extends>
- <header>ssidcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>BssidComboBox</class>
- <extends>QComboBox</extends>
- <header>bssidcombobox.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>SSIDCombo</tabstop>
- <tabstop>modeComboBox</tabstop>
- <tabstop>BSSIDCombo</tabstop>
- <tabstop>band</tabstop>
- <tabstop>macAddress</tabstop>
- <tabstop>clonedMacAddress</tabstop>
- <tabstop>btnRandomMacAddr</tabstop>
- <tabstop>mtu</tabstop>
- <tabstop>hiddenNetwork</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "wifisecurity.h"
-#include "ui_wifisecurity.h"
-
-#include <NetworkManagerQt/Utils>
-
-#include <QDebug>
-
-WifiSecurity::WifiSecurity(const NetworkManager::Setting::Ptr &setting, const NetworkManager::Security8021xSetting::Ptr &setting8021x,
- QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::WifiSecurity)
-{
- m_wifiSecurity = setting.staticCast<NetworkManager::WirelessSecuritySetting>();
-
- m_ui->setupUi(this);
-
- m_8021xWidget = new Security8021x(setting8021x, true, this); // Dynamic WEP
- m_WPA2Widget = new Security8021x(setting8021x, true, this); // WPA(2) Enterprise
- m_ui->stackedWidget->insertWidget(3, m_8021xWidget);
- m_ui->stackedWidget->insertWidget(5, m_WPA2Widget);
-
- connect(m_ui->securityCombo, SIGNAL(currentIndexChanged(int)), SLOT(securityChanged(int)));
-
- connect(m_ui->cbShowWepKey, SIGNAL(toggled(bool)), SLOT(slotShowWepKeyPasswordChecked(bool)));
- connect(m_ui->cbShowLeapPassword, SIGNAL(toggled(bool)), SLOT(slotShowLeapPasswordChecked(bool)));
- connect(m_ui->cbShowPsk, SIGNAL(toggled(bool)), SLOT(slotShowPskPasswordChecked(bool)));
-
- connect(m_ui->wepIndex, SIGNAL(currentIndexChanged(int)), SLOT(setWepKey(int)));
-
- connect(m_ui->wepKey, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->leapUsername, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->leapPassword, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->psk, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->wepIndex, SIGNAL(currentIndexChanged(int)), SLOT(slotWidgetChanged()));
- connect(m_ui->securityCombo, SIGNAL(currentIndexChanged(int)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (setting)
- loadConfig(setting);
-}
-
-WifiSecurity::~WifiSecurity()
-{
- delete m_ui;
-}
-
-bool WifiSecurity::enabled() const
-{
- return m_ui->securityCombo->currentIndex() > 0;
-}
-
-bool WifiSecurity::enabled8021x() const
-{
- if (m_ui->securityCombo->currentIndex() == 4 || m_ui->securityCombo->currentIndex() == 6) {
- return true;
- }
-
- return false;
-}
-
-bool WifiSecurity::isValid() const
-{
- const int securityIndex = m_ui->securityCombo->currentIndex();
-
- if (securityIndex == WepHex) { // WEP Hex
- return NetworkManager::Utils::wepKeyIsValid(m_ui->wepKey->text(), NetworkManager::WirelessSecuritySetting::Hex);
- } else if (securityIndex == WepPassphrase) { // WEP Passphrase
- return NetworkManager::Utils::wepKeyIsValid(m_ui->wepKey->text(), NetworkManager::WirelessSecuritySetting::Passphrase);
- }else if (securityIndex == Leap) { // LEAP
- return !m_ui->leapUsername->text().isEmpty() && !m_ui->leapPassword->text().isEmpty();
- } else if (securityIndex == WpaPsk) { // WPA
- return NetworkManager::Utils::wpaPskIsValid(m_ui->psk->text());
- }
-
- return true;
-}
-
-void WifiSecurity::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::WirelessSecuritySetting::Ptr wifiSecurity = setting.staticCast<NetworkManager::WirelessSecuritySetting>();
-
- const NetworkManager::WirelessSecuritySetting::KeyMgmt keyMgmt = wifiSecurity->keyMgmt();
- const NetworkManager::WirelessSecuritySetting::AuthAlg authAlg = wifiSecurity->authAlg();
-
- if (keyMgmt == NetworkManager::WirelessSecuritySetting::Unknown) {
- m_ui->securityCombo->setCurrentIndex(None); // None
-
- } else if (keyMgmt == NetworkManager::WirelessSecuritySetting::Wep) {
- if (wifiSecurity->wepKeyType() == NetworkManager::WirelessSecuritySetting::Hex ||
- wifiSecurity->wepKeyType() == NetworkManager::WirelessSecuritySetting::NotSpecified) {
- m_ui->securityCombo->setCurrentIndex(WepHex); // WEP Hex
- } else {
- m_ui->securityCombo->setCurrentIndex(WepPassphrase);
- }
- const int keyIndex = static_cast<int>(wifiSecurity->wepTxKeyindex());
- setWepKey(keyIndex);
- m_ui->wepIndex->setCurrentIndex(keyIndex);
-
- if (wifiSecurity->authAlg() == NetworkManager::WirelessSecuritySetting::Open) {
- m_ui->wepAuth->setCurrentIndex(0);
- }
- else {
- m_ui->wepAuth->setCurrentIndex(1);
- }
-
- } else if (keyMgmt == NetworkManager::WirelessSecuritySetting::Ieee8021x
- && authAlg == NetworkManager::WirelessSecuritySetting::Leap) {
- m_ui->securityCombo->setCurrentIndex(Leap); // LEAP
- m_ui->leapUsername->setText(wifiSecurity->leapUsername());
- m_ui->leapPassword->setText(wifiSecurity->leapPassword());
-
- } else if (keyMgmt == NetworkManager::WirelessSecuritySetting::Ieee8021x) {
- m_ui->securityCombo->setCurrentIndex(DynamicWep); // Dynamic WEP
- // done in the widget
-
- } else if (keyMgmt == NetworkManager::WirelessSecuritySetting::WpaPsk) {
- m_ui->securityCombo->setCurrentIndex(WpaPsk); // WPA
- m_ui->psk->setText(wifiSecurity->psk());
-
- } else if (keyMgmt == NetworkManager::WirelessSecuritySetting::WpaEap) {
- m_ui->securityCombo->setCurrentIndex(WpaEap); // WPA2 Enterprise
- // done in the widget
- }
-}
-
-QVariantMap WifiSecurity::setting(bool agentOwned) const
-{
- NetworkManager::WirelessSecuritySetting wifiSecurity;
-
- const int securityIndex = m_ui->securityCombo->currentIndex();
- if (securityIndex == None) {
- wifiSecurity.setKeyMgmt(NetworkManager::WirelessSecuritySetting::Unknown);
- } else if (securityIndex == WepHex || securityIndex == WepPassphrase) { // WEP
- wifiSecurity.setKeyMgmt(NetworkManager::WirelessSecuritySetting::Wep);
- if (securityIndex == WepHex) {
- wifiSecurity.setWepKeyType(NetworkManager::WirelessSecuritySetting::Hex);
- } else {
- wifiSecurity.setWepKeyType(NetworkManager::WirelessSecuritySetting::Passphrase);
- }
- const int keyIndex = m_ui->wepIndex->currentIndex();
- const QString wepKey = m_ui->wepKey->text();
- wifiSecurity.setWepTxKeyindex(keyIndex);
- if (keyIndex == 0)
- wifiSecurity.setWepKey0(wepKey);
- else if (keyIndex == 1)
- wifiSecurity.setWepKey1(wepKey);
- else if (keyIndex == 2)
- wifiSecurity.setWepKey2(wepKey);
- else if (keyIndex == 3)
- wifiSecurity.setWepKey3(wepKey);
-
- if (agentOwned) {
- wifiSecurity.setWepKeyFlags(NetworkManager::Setting::AgentOwned);
- }
- if (m_ui->wepAuth->currentIndex() == 0)
- wifiSecurity.setAuthAlg(NetworkManager::WirelessSecuritySetting::Open);
- else
- wifiSecurity.setAuthAlg(NetworkManager::WirelessSecuritySetting::Shared);
- } else if (securityIndex == Leap) { // LEAP
- wifiSecurity.setKeyMgmt(NetworkManager::WirelessSecuritySetting::Ieee8021x);
- wifiSecurity.setAuthAlg(NetworkManager::WirelessSecuritySetting::Leap);
- wifiSecurity.setLeapUsername(m_ui->leapUsername->text());
- wifiSecurity.setLeapPassword(m_ui->leapPassword->text());
- if (agentOwned) {
- wifiSecurity.setLeapPasswordFlags(NetworkManager::Setting::AgentOwned);
- }
- } else if (securityIndex == DynamicWep) { // Dynamic WEP
- wifiSecurity.setKeyMgmt(NetworkManager::WirelessSecuritySetting::Ieee8021x);
- } else if (securityIndex == WpaPsk) { // WPA
- wifiSecurity.setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
- wifiSecurity.setPsk(m_ui->psk->text());
- if (agentOwned) {
- wifiSecurity.setPskFlags(NetworkManager::Setting::AgentOwned);
- }
- } else if (securityIndex == WpaEap) { // WPA2 Enterprise
- wifiSecurity.setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
- }
-
- return wifiSecurity.toMap();
-}
-
-QVariantMap WifiSecurity::setting8021x(bool agentOwned) const
-{
- if (m_ui->securityCombo->currentIndex() == DynamicWep) // Dynamic WEP
- return m_8021xWidget->setting(agentOwned);
- else if (m_ui->securityCombo->currentIndex() == WpaEap) // WPA2 Enterprise
- return m_WPA2Widget->setting(agentOwned);
-
- return QVariantMap();
-}
-
-void WifiSecurity::setWepKey(int keyIndex)
-{
- if (keyIndex == 0)
- m_ui->wepKey->setText(m_wifiSecurity->wepKey0());
- else if (keyIndex == 1)
- m_ui->wepKey->setText(m_wifiSecurity->wepKey1());
- else if (keyIndex == 2)
- m_ui->wepKey->setText(m_wifiSecurity->wepKey2());
- else if (keyIndex == 3)
- m_ui->wepKey->setText(m_wifiSecurity->wepKey3());
-}
-
-void WifiSecurity::securityChanged(int index)
-{
- if (index == 0) {
- m_ui->stackedWidget->setCurrentIndex(0);
- } else if (index == 1 || index == 2) {
- m_ui->stackedWidget->setCurrentIndex(1);
- } else {
- m_ui->stackedWidget->setCurrentIndex(index-1);
- }
-
- KAcceleratorManager::manage(m_ui->stackedWidget->currentWidget());
-}
-
-void WifiSecurity::slotShowWepKeyPasswordChecked(bool checked)
-{
- m_ui->wepKey->setPasswordMode(!checked);
-}
-
-void WifiSecurity::slotShowLeapPasswordChecked(bool checked)
-{
- m_ui->leapPassword->setPasswordMode(!checked);
-}
-
-void WifiSecurity::slotShowPskPasswordChecked(bool checked)
-{
- m_ui->psk->setPasswordMode(!checked);
-}
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_WIFI_SECURITY_H
-#define PLASMA_NM_WIFI_SECURITY_H
-
-#include <QtGui/QWidget>
-
-#include <NetworkManagerQt/WirelessSecuritySetting>
-#include <NetworkManagerQt/Security8021xSetting>
-
-#include "settingwidget.h"
-#include "security802-1x.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class WifiSecurity;
-}
-
-class PLASMA_NM_EXPORT WifiSecurity : public SettingWidget
-{
- Q_OBJECT
-public:
- // Keep this in sync with NetworkManager::Utils::WirelessSecurityType from
- // NetworkManagerQt.
- enum SecurityTypeIndex { None = 0, WepHex, WepPassphrase, Leap, DynamicWep, WpaPsk, WpaEap };
-
- explicit WifiSecurity(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(),
- const NetworkManager::Security8021xSetting::Ptr &setting8021x = NetworkManager::Security8021xSetting::Ptr(),
- QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~WifiSecurity();
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
- QVariantMap setting(bool agentOwned = false) const;
- QVariantMap setting8021x(bool agentOwned = false) const;
-
- bool enabled() const;
- bool enabled8021x() const;
-
- virtual bool isValid() const;
-
-private slots:
- void securityChanged(int index);
- void slotShowWepKeyPasswordChecked(bool checked);
- void slotShowLeapPasswordChecked(bool checked);
- void slotShowPskPasswordChecked(bool checked);
- void setWepKey(int keyIndex);
-
-private:
- Ui::WifiSecurity * m_ui;
- Security8021x * m_8021xWidget;
- Security8021x * m_WPA2Widget;
- NetworkManager::WirelessSecuritySetting::Ptr m_wifiSecurity;
-};
-
-#endif // PLASMA_NM_WIFI_SECURITY_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <ltinkl@redhat.com></author>
- <class>WifiSecurity</class>
- <widget class="QWidget" name="WifiSecurity">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>489</width>
- <height>374</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Wifi Security</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="1">
- <widget class="KComboBox" name="securityCombo">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string comment="no security">None</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>WEP key 40/128 bits (Hex or ASCII)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>WEP key 128 bits</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>LEAP</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Dynamic WEP (802.1x)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>WPA & WPA2 Personal</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>WPA & WPA2 Enterprise</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Security:</string>
- </property>
- <property name="buddy">
- <cstring>securityCombo</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QStackedWidget" name="stackedWidget">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="securityNone"/>
- <widget class="QWidget" name="securityWep">
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Key:</string>
- </property>
- <property name="buddy">
- <cstring>wepKey</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="wepKey">
- <property name="maxLength">
- <number>26</number>
- </property>
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QCheckBox" name="cbShowWepKey">
- <property name="text">
- <string>Show key</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>WEP index:</string>
- </property>
- <property name="buddy">
- <cstring>wepIndex</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KComboBox" name="wepIndex">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>1 (default)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>2</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>3</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>4</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Authentication:</string>
- </property>
- <property name="buddy">
- <cstring>wepAuth</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="KComboBox" name="wepAuth">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>Open System</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Shared Key</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="securityLeap">
- <layout class="QFormLayout" name="formLayout_3">
- <item row="0" column="0">
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>leapUsername</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="leapUsername"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_9">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>leapPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="leapPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QCheckBox" name="cbShowLeapPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="securityWpaPersonal">
- <layout class="QFormLayout" name="formLayout_4">
- <item row="0" column="0">
- <widget class="QLabel" name="label_10">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>psk</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="psk">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QCheckBox" name="cbShowPsk">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <ltinkl@redhat.com></author>
- <class>WimaxWidget</class>
- <widget class="QWidget" name="WimaxWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>369</width>
- <height>70</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Network name:</string>
- </property>
- <property name="buddy">
- <cstring>networkName</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="networkName"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Restrict to device:</string>
- </property>
- <property name="buddy">
- <cstring>macAddress</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="HwAddrComboBox" name="macAddress">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>HwAddrComboBox</class>
- <extends>QComboBox</extends>
- <header>hwaddrcombobox.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>networkName</tabstop>
- <tabstop>macAddress</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "wimaxwidget.h"
-#include "ui_wimax.h"
-#include "uiutils.h"
-
-#include <NetworkManagerQt/Utils>
-#include <NetworkManagerQt/WimaxSetting>
-
-#include <KLocalizedString>
-
-WimaxWidget::WimaxWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::WimaxWidget)
-{
- m_ui->setupUi(this);
-
- connect(m_ui->networkName, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->macAddress, SIGNAL(hwAddressChanged()), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (setting)
- loadConfig(setting);
-}
-
-WimaxWidget::~WimaxWidget()
-{
- delete m_ui;
-}
-
-void WimaxWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::WimaxSetting::Ptr wimaxSetting = setting.staticCast<NetworkManager::WimaxSetting>();
-
- m_ui->networkName->setText(wimaxSetting->networkName());
- m_ui->macAddress->init(NetworkManager::Device::Wimax, NetworkManager::Utils::macAddressAsString(wimaxSetting->macAddress()));
-}
-
-QVariantMap WimaxWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned);
-
- NetworkManager::WimaxSetting wimaxSetting;
-
- wimaxSetting.setNetworkName(m_ui->networkName->text());
- wimaxSetting.setMacAddress(NetworkManager::Utils::macAddressFromString(m_ui->macAddress->hwAddress()));
-
- return wimaxSetting.toMap();
-}
-
-bool WimaxWidget::isValid() const
-{
- return !m_ui->networkName->text().isEmpty() && m_ui->macAddress->isValid();
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_WIMAX_WIDGET_H
-#define PLASMA_NM_WIMAX_WIDGET_H
-
-#include <QtGui/QWidget>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class WimaxWidget;
-}
-
-class PLASMA_NM_EXPORT WimaxWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit WimaxWidget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~WimaxWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private:
- Ui::WimaxWidget * m_ui;
-};
-
-#endif // PLASMA_NM_WIMAX_WIDGET_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "wiredconnectionwidget.h"
-#include "ui_wiredconnectionwidget.h"
-#include "uiutils.h"
-
-#include <NetworkManagerQt/Utils>
-#include <NetworkManagerQt/WiredSetting>
-
-WiredConnectionWidget::WiredConnectionWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_widget(new Ui::WiredConnectionWidget)
-{
- qsrand(QTime::currentTime().msec());
-
- m_widget->setupUi(this);
- m_widget->speedLabel->setHidden(true);
- m_widget->speed->setHidden(true);
- m_widget->duplexLabel->setHidden(true);
- m_widget->duplex->setHidden(true);
-
- connect(m_widget->btnRandomMacAddr, SIGNAL(clicked()), SLOT(generateRandomClonedMac()));
-
- if (setting)
- loadConfig(setting);
-
- KAcceleratorManager::manage(this);
-
- // Validation
- connect(m_widget->macAddress, SIGNAL(hwAddressChanged()), SLOT(slotWidgetChanged()));
- connect(m_widget->clonedMacAddress, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-}
-
-WiredConnectionWidget::~WiredConnectionWidget()
-{
- delete m_widget;
-}
-
-void WiredConnectionWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- NetworkManager::WiredSetting::Ptr wiredSetting = setting.staticCast<NetworkManager::WiredSetting>();
-
- m_widget->macAddress->init(NetworkManager::Device::Ethernet, NetworkManager::Utils::macAddressAsString(wiredSetting->macAddress()));
-
- if (!wiredSetting->clonedMacAddress().isEmpty()) {
- m_widget->clonedMacAddress->setText(NetworkManager::Utils::macAddressAsString(wiredSetting->clonedMacAddress()));
- }
-
- if (wiredSetting->mtu()) {
- m_widget->mtu->setValue(wiredSetting->mtu());
- }
-
- if (!wiredSetting->autoNegotiate()) {
- m_widget->autonegotiate->setChecked(false);
-
- if (wiredSetting->speed()) {
- m_widget->speed->setValue(wiredSetting->speed());
- }
-
- if (wiredSetting->duplexType() == NetworkManager::WiredSetting::Full) {
- m_widget->duplex->setCurrentIndex(0);
- } else {
- m_widget->duplex->setCurrentIndex(1);
- }
- }
-}
-
-QVariantMap WiredConnectionWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned);
-
- NetworkManager::WiredSetting wiredSetting;
-
- wiredSetting.setMacAddress(NetworkManager::Utils::macAddressFromString(m_widget->macAddress->hwAddress()));
-
- if (!m_widget->clonedMacAddress->text().isEmpty() && m_widget->clonedMacAddress->text() != ":::::") {
- wiredSetting.setClonedMacAddress(NetworkManager::Utils::macAddressFromString(m_widget->clonedMacAddress->text()));
- }
-
- if (m_widget->mtu->value()) {
- wiredSetting.setMtu(m_widget->mtu->value());
- }
-
- if (m_widget->autonegotiate->isChecked()) {
- wiredSetting.setAutoNegotiate(true);
- } else {
- wiredSetting.setAutoNegotiate(false);
-
- if (m_widget->speed->value()) {
- wiredSetting.setSpeed(m_widget->speed->value());
- }
-
- if (m_widget->duplex->currentIndex() == 0) {
- wiredSetting.setDuplexType(NetworkManager::WiredSetting::Full);
- } else {
- wiredSetting.setDuplexType(NetworkManager::WiredSetting::Half);
- }
- }
-
- return wiredSetting.toMap();
-}
-
-void WiredConnectionWidget::generateRandomClonedMac()
-{
- QByteArray mac;
- mac.resize(6);
- for (int i = 0; i < 6; i++) {
- int random = qrand() % 255;
- mac[i] = random;
- }
- m_widget->clonedMacAddress->setText(NetworkManager::Utils::macAddressAsString(mac));
-}
-
-bool WiredConnectionWidget::isValid() const
-{
- if (!m_widget->macAddress->isValid()) {
- return false;
- }
-
- if (m_widget->clonedMacAddress->text() != ":::::") {
- if (!NetworkManager::Utils::macAddressIsValid(m_widget->clonedMacAddress->text())) {
- return false;
- }
- }
-
- return true;
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_WIRED_CONNECTION_WIDGET_H
-#define PLASMA_NM_WIRED_CONNECTION_WIDGET_H
-
-#include <QtGui/QWidget>
-
-#include "settingwidget.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class WiredConnectionWidget;
-}
-
-class PLASMA_NM_EXPORT WiredConnectionWidget : public SettingWidget
-{
-Q_OBJECT
-
-public:
- explicit WiredConnectionWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~WiredConnectionWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- bool isValid() const;
-
-private slots:
- void generateRandomClonedMac();
-
-private:
- Ui::WiredConnectionWidget * m_widget;
-};
-
-#endif // PLASMA_NM_WIRED_CONNECTION_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>WiredConnectionWidget</class>
- <widget class="QWidget" name="WiredConnectionWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>374</width>
- <height>216</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Restrict to device:</string>
- </property>
- <property name="buddy">
- <cstring>macAddress</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="HwAddrComboBox" name="macAddress">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Cloned MAC address:</string>
- </property>
- <property name="buddy">
- <cstring>clonedMacAddress</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="KLineEdit" name="clonedMacAddress">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="inputMask">
- <string notr="true">HH:HH:HH:HH:HH:HH;_</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnRandomMacAddr">
- <property name="text">
- <string>Random...</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>MTU:</string>
- </property>
- <property name="buddy">
- <cstring>mtu</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KIntSpinBox" name="mtu">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="specialValueText">
- <string>Automatic</string>
- </property>
- <property name="suffix">
- <string> bytes</string>
- </property>
- <property name="maximum">
- <number>9999</number>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="speedLabel">
- <property name="text">
- <string>Speed:</string>
- </property>
- <property name="buddy">
- <cstring>speed</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="KIntSpinBox" name="speed">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="specialValueText">
- <string>Automatic</string>
- </property>
- <property name="suffix">
- <string> Mbit/s</string>
- </property>
- <property name="maximum">
- <number>9999</number>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="duplexLabel">
- <property name="text">
- <string>Duplex:</string>
- </property>
- <property name="buddy">
- <cstring>duplex</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KComboBox" name="duplex">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>Full</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Half</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QCheckBox" name="autonegotiate">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Autonegotiate</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="tristate">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KIntSpinBox</class>
- <extends>QSpinBox</extends>
- <header>knuminput.h</header>
- </customwidget>
- <customwidget>
- <class>HwAddrComboBox</class>
- <extends>QComboBox</extends>
- <header>hwaddrcombobox.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>macAddress</tabstop>
- <tabstop>clonedMacAddress</tabstop>
- <tabstop>btnRandomMacAddr</tabstop>
- <tabstop>mtu</tabstop>
- <tabstop>speed</tabstop>
- <tabstop>duplex</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>autonegotiate</sender>
- <signal>toggled(bool)</signal>
- <receiver>speedLabel</receiver>
- <slot>setHidden(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>80</x>
- <y>290</y>
- </hint>
- <hint type="destinationlabel">
- <x>81</x>
- <y>117</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>autonegotiate</sender>
- <signal>toggled(bool)</signal>
- <receiver>speed</receiver>
- <slot>setHidden(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>80</x>
- <y>290</y>
- </hint>
- <hint type="destinationlabel">
- <x>245</x>
- <y>118</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>autonegotiate</sender>
- <signal>toggled(bool)</signal>
- <receiver>duplexLabel</receiver>
- <slot>setHidden(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>80</x>
- <y>290</y>
- </hint>
- <hint type="destinationlabel">
- <x>81</x>
- <y>147</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>autonegotiate</sender>
- <signal>toggled(bool)</signal>
- <receiver>duplex</receiver>
- <slot>setHidden(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>80</x>
- <y>290</y>
- </hint>
- <hint type="destinationlabel">
- <x>298</x>
- <y>143</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "wiredsecurity.h"
-#include "ui_wiredsecurity.h"
-
-#include <QDebug>
-
-WiredSecurity::WiredSecurity(const NetworkManager::Security8021xSetting::Ptr &setting8021x, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting8021x, parent, f),
- m_ui(new Ui::WiredSecurity),
- m_8021xSetting(setting8021x)
-{
- m_ui->setupUi(this);
-
- m_8021xWidget = new Security8021x(m_8021xSetting, false, this);
- m_8021xWidget->setDisabled(true);
-
- m_ui->verticalLayout->addWidget(m_8021xWidget);
-
- connect(m_ui->use8021X, SIGNAL(toggled(bool)), m_8021xWidget, SLOT(setEnabled(bool)));
-
- KAcceleratorManager::manage(this);
-
- loadConfig(setting8021x);
-}
-
-WiredSecurity::~WiredSecurity()
-{
- delete m_ui;
-}
-
-bool WiredSecurity::enabled8021x() const
-{
- if (m_ui->use8021X->checkState() == Qt::Checked) {
- return true;
- }
-
- return false;
-}
-
-void WiredSecurity::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- if (!setting->isNull()) {
- m_8021xWidget->setEnabled(true);
- m_ui->use8021X->setChecked(true);
- }
-}
-
-QVariantMap WiredSecurity::setting(bool agentOwned) const
-{
- if (m_ui->use8021X->isChecked())
- return m_8021xWidget->setting(agentOwned);
-
- return QVariantMap();
-}
+++ /dev/null
-/*
- Copyright (c) 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_WIRED_SECURITY_H
-#define PLASMA_NM_WIRED_SECURITY_H
-
-#include <QtGui/QWidget>
-
-#include <NetworkManagerQt/Security8021xSetting>
-
-#include "settingwidget.h"
-#include "security802-1x.h"
-#include "plasmanm_export.h"
-
-namespace Ui
-{
-class WiredSecurity;
-}
-
-class PLASMA_NM_EXPORT WiredSecurity : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit WiredSecurity(const NetworkManager::Security8021xSetting::Ptr &setting8021x = NetworkManager::Security8021xSetting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~WiredSecurity();
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
- QVariantMap setting(bool agentOwned = false) const;
-
- bool enabled8021x() const;
-
-private:
- Ui::WiredSecurity * m_ui;
- Security8021x * m_8021xWidget;
- NetworkManager::Security8021xSetting::Ptr m_8021xSetting;
-};
-
-#endif // PLASMA_NM_WIRED_SECURITY_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>WiredSecurity</class>
- <widget class="QWidget" name="WiredSecurity">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>487</width>
- <height>379</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QCheckBox" name="use8021X">
- <property name="text">
- <string>Use 802.1x security for this connection</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
-Copyright 2009 Paul Marchouk <pmarchouk@gmail.com>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of
-the License or (at your option) version 3 or any later version
-accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "simpleipv4addressvalidator.h"
-
-#include <KDebug>
-#include <QStringList>
-
-SimpleIpV4AddressValidator::SimpleIpV4AddressValidator(QObject *parent)
- : QValidator(parent)
-{
-}
-
-SimpleIpV4AddressValidator::~SimpleIpV4AddressValidator()
-{
-}
-
-QValidator::State SimpleIpV4AddressValidator::validate(QString &address, int &pos) const
-{
- if (QValidator::Invalid == checkWithInputMask(address, pos)) {
- return QValidator::Invalid;
- }
-
- // this list will be filled with tetrad values. It can be used to make
- // some additional correctness checks on the last validation step.
- QList<int> tetrads;
-
- return checkTetradsRanges(address, tetrads);
-}
-
-QValidator::State SimpleIpV4AddressValidator::checkWithInputMask(QString &value, int &pos) const
-{
- QRegExpValidator v(QRegExp("[0-9, ]{1,3}\\.[0-9, ]{1,3}\\.[0-9, ]{1,3}\\.[0-9, ]{1,3}"), 0);
-
- return v.validate(value, pos);
-}
-
-QValidator::State SimpleIpV4AddressValidator::checkTetradsRanges(QString &value, QList<int> &tetrads) const
-{
- QStringList temp;
- const QStringList addrParts = value.split(QLatin1Char('.'));
- int i = 0;
- // fill in the list with invalid values
- tetrads << -1 << -1 << -1 << -1;
-
- // lets check address parts
- foreach(const QString &part, addrParts) {
- if (part.isEmpty()) {
- if (i != (addrParts.size() - 1)) {
- //kDebug() << "part.isEmpty()";
- return QValidator::Invalid;
- }
- // the last tetrad can be empty, continue...
- return QValidator::Intermediate;
- }
-
- tetrads[i] = part.toInt();
-
- if (tetrads[i] > 255) {
- //kDebug() << "tetrads[i] > 255";
- return QValidator::Invalid;
- }
-
- // correct tetrad value: for example, 001 -> 1
- temp.append(QString::number(tetrads[i]));
-
- i++;
- }
-
- // replace input string with the corrected version
- value = temp.join(QLatin1String("."));
-
- if (i < 4) {
- // not all tetrads are filled... continue
- //kDebug() << "QValidator::Intermediate";
- return QValidator::Intermediate;
- } else {
- //kDebug() << "QValidator::Acceptable";
- return QValidator::Acceptable;
- }
-}
+++ /dev/null
-/*
-Copyright 2009 Paul Marchouk <pmarchouk@gmail.com>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of
-the License or (at your option) version 3 or any later version
-accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef SIMPLEIPV4ADDRESSVALIDATOR_H
-#define SIMPLEIPV4ADDRESSVALIDATOR_H
-
-#include <QValidator>
-
-class SimpleIpV4AddressValidator : public QValidator
-{
-public:
- explicit SimpleIpV4AddressValidator(QObject *parent);
- virtual ~SimpleIpV4AddressValidator();
-
- virtual State validate(QString &, int &) const;
-
- /** Check input value with a regular expression describing simple input mask.
- */
- QValidator::State checkWithInputMask(QString &, int &) const;
- /** Function split intput string into tetrads and check them for valid values.
- * In the tetrads are placed into QList. Input string may be changed.
- */
- QValidator::State checkTetradsRanges(QString &, QList<int>&) const;
-};
-
-#endif // SIMPLEIPV4ADDRESSVALIDATOR_H
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>, based on work by Paul Marchouk <pmarchouk@gmail.com>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of
-the License or (at your option) version 3 or any later version
-accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "simpleipv6addressvalidator.h"
-
-#include <KDebug>
-#include <QStringList>
-
-SimpleIpV6AddressValidator::SimpleIpV6AddressValidator(QObject *parent)
- : QValidator(parent)
-{
-}
-
-SimpleIpV6AddressValidator::~SimpleIpV6AddressValidator()
-{
-}
-
-QValidator::State SimpleIpV6AddressValidator::validate(QString &address, int &pos) const
-{
- if (QValidator::Invalid == checkWithInputMask(address, pos)) {
- return QValidator::Invalid;
- }
-
- return checkTetradsRanges(address);
-}
-
-QValidator::State SimpleIpV6AddressValidator::checkWithInputMask(QString &value, int &pos) const
-{
- QRegExpValidator v(QRegExp("([0-9a-fA-F]{1,4}|:)+"), 0);
-
- return v.validate(value, pos);
-}
-
-QValidator::State SimpleIpV6AddressValidator::checkTetradsRanges(QString &value) const
-{
- const QStringList addrParts = value.split(QLatin1Char(':'));
- int number = addrParts.size();
- if (number > 8) {
- return QValidator::Invalid;
- }
-
- // lets check address parts
- bool emptypresent = false;
- int i = 1;
- foreach(QString part, addrParts) { // krazy:exclude=foreach
- if (part.isEmpty() && i < number) {
- if (emptypresent) {
- //kDebug() << "part.isEmpty()";
- return QValidator::Invalid;
- }
- else if (!emptypresent)
- {
- part.setNum(0,16);
- emptypresent = true;
- }
- }
- i++;
-
- bool ok;
- if (part.toInt(&ok, 16) > 65535) {
- return QValidator::Invalid;
- }
- }
-
- if (number < 8 && !emptypresent)
- return QValidator::Intermediate;
-
- return QValidator::Acceptable;
-
-}
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>, based on work by Paul Marchouk <pmarchouk@gmail.com>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of
-the License or (at your option) version 3 or any later version
-accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef SIMPLEIPV6ADDRESSVALIDATOR_H
-#define SIMPLEIPV6ADDRESSVALIDATOR_H
-
-#include <QValidator>
-
-class SimpleIpV6AddressValidator : public QValidator
-{
-public:
- explicit SimpleIpV6AddressValidator(QObject *parent);
- virtual ~SimpleIpV6AddressValidator();
-
- virtual State validate(QString &, int &) const;
-
- /** Check input value with a regular expression describing simple input mask.
- */
- QValidator::State checkWithInputMask(QString &, int &) const;
- /** Function split intput string into tetrads and check them for valid values.
- * In the tetrads are placed into QList. Input string may be changed.
- */
- QValidator::State checkTetradsRanges(QString &) const;
-};
-
-#endif // SIMPLEIPV6ADDRESSVALIDATOR_H
+++ /dev/null
-/*
- Copyright 2008 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "vpnuiplugin.h"
-
-#include <KLocalizedString>
-
-VpnUiPlugin::VpnUiPlugin(QObject * parent, const QVariantList & /*args*/):
- QObject(parent)
-{
- mError = NoError;
-}
-
-VpnUiPlugin::~VpnUiPlugin()
-{
-}
-
-QMessageBox::StandardButtons VpnUiPlugin::suggestedAuthDialogButtons() const
-{
- return QMessageBox::Ok | QMessageBox::Cancel;
-}
-
-VpnUiPlugin::ErrorType VpnUiPlugin::lastError() const
-{
- return mError;
-}
-
-QString VpnUiPlugin::lastErrorMessage()
-{
- switch (mError) {
- case NoError:
- mErrorMessage = "";
- break;
- case NotImplemented:
- return i18nc("Error message in VPN import/export dialog", "Operation not supported for this VPN type.");
- break;
- case Error:
- break;
- }
- return mErrorMessage;
-}
+++ /dev/null
-/*
- Copyright 2008 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_VPN_UI_PLUGIN_H
-#define PLASMA_NM_VPN_UI_PLUGIN_H
-
-#include <QObject>
-#include <QVariant>
-#include <QMessageBox>
-
-#include <NetworkManagerQt/VpnSetting>
-#include <NetworkManagerQt/ConnectionSettings>
-#include <NetworkManagerQt/generic-types.h>
-
-#include <kdemacros.h>
-
-#include "settingwidget.h"
-
-/**
- * Plugin for UI elements for VPN configuration
- */
-class KDE_EXPORT VpnUiPlugin : public QObject
-{
- Q_OBJECT
-public:
- enum ErrorType {NoError, NotImplemented, Error};
-
- explicit VpnUiPlugin(QObject * parent = 0, const QVariantList& = QVariantList());
- virtual ~VpnUiPlugin();
-
- virtual SettingWidget * widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0) = 0;
- virtual SettingWidget * askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0) = 0;
-
- /**
- * Suggested file name to save the exported connection configuration.
- * Try not to use space, parenthesis, or any other Unix unfriendly file name character.
- */
- virtual QString suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const = 0;
- /**
- * File extension to be used in KFileDialog when selecting the file to import.
- * The format is: *.<extension> [*.<extension> ...]. For instance: '*.pcf'
- */
- virtual QString supportedFileExtensions() const = 0;
-
- /**
- * If the plugin does not support fileName's extension it must just return an empty QVariantList.
- * If it supports the extension and import has failed it must set mError with VpnUiPlugin::Error
- * and mErrorMessage with a custom error message before returning an empty QVariantList.
- */
- virtual NMVariantMapMap importConnectionSettings(const QString &fileName) = 0;
- virtual bool exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName) = 0;
-
- virtual QMessageBox::StandardButtons suggestedAuthDialogButtons() const;
- ErrorType lastError() const;
- QString lastErrorMessage();
-protected:
- ErrorType mError;
- QString mErrorMessage;
-};
-
-#endif // PLASMA_NM_VPN_UI_PLUGIN_H
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "advancedpermissionswidget.h"
-#include "ui_advancedpermissionswidget.h"
-
-#include <KUser>
-#include <KLocalizedString>
-#include <KDebug>
-#include <QList>
-#include <KAcceleratorManager>
-
-#define UserTagRole Qt::UserRole + 1
-
-class AdvancedPermissionsWidgetPrivate
-{
-public:
- Ui_AdvancedPermissions ui;
-};
-
-AdvancedPermissionsWidget::AdvancedPermissionsWidget(QWidget *parent):
- QWidget(parent),
- d_ptr(new AdvancedPermissionsWidgetPrivate)
-{
- Q_D(AdvancedPermissionsWidget);
- d->ui.setupUi(this);
-
- foreach (const KUser &user, KUser::allUsers()) {
- if (user.uid() >= 1000 && user.loginName() != QLatin1String("nobody"))
- d->ui.availUsers->addTopLevelItem(constructItem(user));
- }
- setupCommon();
-}
-
-AdvancedPermissionsWidget::AdvancedPermissionsWidget(const QHash<QString,QString> &users, QWidget *parent):
- QWidget(parent),
- d_ptr(new AdvancedPermissionsWidgetPrivate)
-{
- Q_D(AdvancedPermissionsWidget);
- d->ui.setupUi(this);
-
- foreach (const KUser &user, KUser::allUsers()) {
- const QString name = user.loginName();
- if (!users.contains(name) && user.uid() >= 1000 && user.loginName() != QLatin1String("nobody"))
- d->ui.availUsers->addTopLevelItem(constructItem(user));
- else if (users.contains(name))
- d->ui.currentUsers->addTopLevelItem(constructItem(user, users.value(name)));
- }
- setupCommon();
-}
-
-AdvancedPermissionsWidget::~AdvancedPermissionsWidget()
-{
- Q_D(AdvancedPermissionsWidget);
- while (QTreeWidgetItem *item = d->ui.currentUsers->takeTopLevelItem(0)) {
- delete item;
- }
- while (QTreeWidgetItem *item = d->ui.availUsers->takeTopLevelItem(0)) {
- delete item;
- }
- delete d_ptr;
-}
-
-void AdvancedPermissionsWidget::setupCommon()
-{
- Q_D(AdvancedPermissionsWidget);
- connect(d->ui.arrowLeft, SIGNAL(clicked()), this, SLOT(leftArrowClicked()));
- connect(d->ui.arrowRight, SIGNAL(clicked()), this, SLOT(rightArrowClicked()));
- d->ui.availUsers->sortByColumn(FullName, Qt::AscendingOrder);
- d->ui.currentUsers->sortByColumn(FullName, Qt::AscendingOrder);
- d->ui.availUsers->setSortingEnabled(true);
- d->ui.currentUsers->setSortingEnabled(true);
-
- KAcceleratorManager::manage(this);
-}
-
-QTreeWidgetItem * AdvancedPermissionsWidget::constructItem(const KUser &user, const QString &itemData)
-{
- QStringList data;
- QString name = user.property(KUser::FullName).toString();
- QString nametooltip;
- if (name.isEmpty()) {
- name = i18nc("@item:intable shortcut for Not Available", "N/A");
- nametooltip = i18nc("@info:tooltip real user name is not available", "Not Available");
- } else {
- nametooltip = name;
- }
- data << name << user.loginName();
- QTreeWidgetItem *item = new QTreeWidgetItem(data);
- item->setData(LoginName, UserTagRole, itemData);
- item->setToolTip(FullName, nametooltip);
- item->setToolTip(LoginName, user.loginName());
- return item;
-}
-
-QHash<QString, QString> AdvancedPermissionsWidget::currentUsers()
-{
- Q_D(AdvancedPermissionsWidget);
- QHash<QString, QString> permissions;
- const int itemNumber = d->ui.currentUsers->topLevelItemCount();
- for (int i = 0; i < itemNumber; i++) {
- QTreeWidgetItem *item = d->ui.currentUsers->topLevelItem(i);
- QString username = item->data(LoginName, Qt::DisplayRole).toString();
- QString tags = item->data(LoginName, UserTagRole).toString();
- permissions.insert(username, tags);
- }
- return permissions;
-}
-
-void AdvancedPermissionsWidget::rightArrowClicked()
-{
- Q_D(AdvancedPermissionsWidget);
- foreach (QTreeWidgetItem *item, d->ui.availUsers->selectedItems()) {
- const int index = d->ui.availUsers->indexOfTopLevelItem(item);
- d->ui.availUsers->takeTopLevelItem(index);
- d->ui.currentUsers->addTopLevelItem(item);
- }
-}
-
-void AdvancedPermissionsWidget::leftArrowClicked()
-{
- Q_D(AdvancedPermissionsWidget);
- foreach (QTreeWidgetItem *item, d->ui.currentUsers->selectedItems()) {
- if (item->data(LoginName, Qt::DisplayRole) != KUser().loginName()) {
- const int index = d->ui.currentUsers->indexOfTopLevelItem(item);
- d->ui.currentUsers->takeTopLevelItem(index);
- d->ui.availUsers->addTopLevelItem(item);
- }
- }
-}
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_ADVANCED_PERMISSIONS_WIDGET_H
-#define PLASMA_NM_ADVANCED_PERMISSIONS_WIDGET_H
-
-#include <QWidget>
-#include <QHash>
-
-class QTreeWidgetItem;
-class AdvancedPermissionsWidgetPrivate;
-class KUser;
-
-class AdvancedPermissionsWidget : public QWidget
-{
-Q_OBJECT
-Q_DECLARE_PRIVATE(AdvancedPermissionsWidget)
-public:
- explicit AdvancedPermissionsWidget(QWidget *parent=0);
- AdvancedPermissionsWidget(const QHash<QString,QString>&, QWidget *parent=0);
- ~AdvancedPermissionsWidget();
-
- QHash<QString,QString> currentUsers();
-
-protected:
- AdvancedPermissionsWidgetPrivate *d_ptr;
-
-private:
- enum Columns {FullName = 0, LoginName = 1};
- void setupCommon();
- QTreeWidgetItem * constructItem(const KUser &user, const QString &itemData = QString());
-
-private Q_SLOTS:
- void leftArrowClicked();
- void rightArrowClicked();
-};
-
-#endif // PLASMA_NM_ADVANCED_PERMISSIONS_WIDGET_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>AdvancedPermissions</class>
- <widget class="QWidget" name="AdvancedPermissions">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>620</width>
- <height>243</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Available Users</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTreeWidget" name="availUsers">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>80</height>
- </size>
- </property>
- <property name="editTriggers">
- <set>QAbstractItemView::NoEditTriggers</set>
- </property>
- <property name="showDropIndicator" stdset="0">
- <bool>false</bool>
- </property>
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::ExtendedSelection</enum>
- </property>
- <property name="rootIsDecorated">
- <bool>false</bool>
- </property>
- <property name="uniformRowHeights">
- <bool>true</bool>
- </property>
- <property name="itemsExpandable">
- <bool>false</bool>
- </property>
- <property name="allColumnsShowFocus">
- <bool>true</bool>
- </property>
- <property name="columnCount">
- <number>2</number>
- </property>
- <attribute name="headerDefaultSectionSize">
- <number>100</number>
- </attribute>
- <column>
- <property name="text">
- <string>Real Name</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string comment="like in Username for athentication">Username</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="KPushButton" name="arrowRight">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="icon">
- <iconset theme="arrow-right"/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KPushButton" name="arrowLeft">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="icon">
- <iconset theme="arrow-left"/>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Users allowed to activate the connection</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTreeWidget" name="currentUsers">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>80</height>
- </size>
- </property>
- <property name="editTriggers">
- <set>QAbstractItemView::NoEditTriggers</set>
- </property>
- <property name="showDropIndicator" stdset="0">
- <bool>false</bool>
- </property>
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::ExtendedSelection</enum>
- </property>
- <property name="rootIsDecorated">
- <bool>false</bool>
- </property>
- <property name="uniformRowHeights">
- <bool>true</bool>
- </property>
- <property name="itemsExpandable">
- <bool>false</bool>
- </property>
- <property name="allColumnsShowFocus">
- <bool>true</bool>
- </property>
- <property name="columnCount">
- <number>2</number>
- </property>
- <attribute name="headerDefaultSectionSize">
- <number>100</number>
- </attribute>
- <column>
- <property name="text">
- <string>Real Name</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string comment="like in Username for athentication">Username</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "bssidcombobox.h"
-
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/Utils>
-#include <NetworkManagerQt/WirelessDevice>
-
-#include <KLocalizedString>
-
-#include <QtAlgorithms>
-
-bool signalCompare(const NetworkManager::AccessPoint::Ptr & one, const NetworkManager::AccessPoint::Ptr & two) {
- return one->signalStrength() > two->signalStrength();
-}
-
-BssidComboBox::BssidComboBox(QWidget *parent) :
- KComboBox(parent), m_dirty(false)
-{
- setEditable(true);
- setInsertPolicy(QComboBox::NoInsert);
-
- connect(this, SIGNAL(editTextChanged(QString)), SLOT(editTextChanged(QString)));
- connect(this, SIGNAL(activated(int)), SLOT(currentIndexChanged(int)));
-}
-
-QString BssidComboBox::bssid() const
-{
- QString result;
- if (!m_dirty)
- result = itemData(currentIndex()).toString();
- else
- result = currentText();
-
- //qDebug() << "Result:" << currentIndex() << result;
-
- return result;
-}
-
-bool BssidComboBox::isValid() const
-{
- if (bssid().isEmpty()) {
- return true;
- }
-
- return NetworkManager::Utils::macAddressIsValid(bssid());
-}
-
-void BssidComboBox::editTextChanged(const QString &)
-{
- m_dirty = true;
- emit bssidChanged();
-}
-
-void BssidComboBox::currentIndexChanged(int)
-{
- m_dirty = false;
- setEditText(bssid());
- emit bssidChanged();
-}
-
-void BssidComboBox::init(const QString & bssid, const QString &ssid)
-{
- m_initialBssid = bssid;
-
- //qDebug() << "Initial ssid:" << m_initialBssid;
-
- QList<NetworkManager::AccessPoint::Ptr> aps;
-
- foreach(const NetworkManager::Device::Ptr & device, NetworkManager::networkInterfaces()) {
- if (device->type() == NetworkManager::Device::Wifi) {
- NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
- NetworkManager::WirelessNetwork::Ptr wifiNetwork = wifiDevice->findNetwork(ssid);
-
- if (!wifiNetwork) {
- continue;
- }
-
- foreach (const NetworkManager::AccessPoint::Ptr & newAp, wifiNetwork->accessPoints()) {
- bool found = false;;
- foreach (const NetworkManager::AccessPoint::Ptr & existingAp, aps) {
- if (newAp->hardwareAddress() == existingAp->hardwareAddress()) {
- if (newAp->signalStrength() > existingAp->signalStrength()) {
- aps.removeOne(existingAp);
- break;
- } else {
- found = true;
- break;
- }
- }
- }
-
- if (!found) {
- aps << newAp;
- }
- }
- }
- }
-
- qSort(aps.begin(), aps.end(), signalCompare);
- addBssidsToCombo(aps);
-
- const int index = findData(m_initialBssid);
- if (index == -1) {
- insertItem(0, m_initialBssid, m_initialBssid);
- setCurrentIndex(0);
- } else {
- setCurrentIndex(index);
- }
- setEditText(m_initialBssid);
-}
-
-void BssidComboBox::addBssidsToCombo(const QList<NetworkManager::AccessPoint::Ptr> & aps)
-{
- clear();
-
- if (aps.isEmpty()) {
- addItem(i18n("First select the SSID"));
- return;
- }
-
- foreach (const NetworkManager::AccessPoint::Ptr & ap, aps) {
- if (!ap) {
- continue;
- }
-
- const QString text = i18n("%1 (%2%)\nFrequency: %3 Mhz\nChannel: %4", ap->hardwareAddress(), ap->signalStrength(), ap->frequency(), QString::number(NetworkManager::Utils::findChannel(ap->frequency())));
- addItem(text, QVariant::fromValue(ap->hardwareAddress()));
- }
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_BSSIDCOMBOBOX_H
-#define PLASMA_NM_BSSIDCOMBOBOX_H
-
-#include <KComboBox>
-
-#include "plasmanm_export.h"
-
-#include <NetworkManagerQt/Device>
-#include <NetworkManagerQt/AccessPoint>
-
-class PLASMA_NM_EXPORT BssidComboBox : public KComboBox
-{
- Q_OBJECT
-public:
- explicit BssidComboBox(QWidget *parent = 0);
-
- QString bssid() const;
- bool isValid() const;
-
-Q_SIGNALS:
- void bssidChanged();
-
-public slots:
- void init(const QString & bssid, const QString &ssid);
-
-private slots:
- void editTextChanged(const QString &);
- void currentIndexChanged(int);
-
-private:
- void addBssidsToCombo(const QList<NetworkManager::AccessPoint::Ptr> & aps);
-
- QString m_initialBssid;
- bool m_dirty;
-};
-
-#endif // PLASMA_NM_BSSIDCOMBOBOX_H
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "delegate.h"
-
-#include <KLineEdit>
-#include <QStandardItem>
-#include <QStandardItemModel>
-
-
-Delegate::Delegate(QObject * parent) : QStyledItemDelegate(parent) {}
-Delegate::~Delegate() {}
-
-QWidget * Delegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
-{
- KLineEdit *editor = new KLineEdit(parent);
-
- return editor;
-}
-
-void Delegate::setEditorData(QWidget *editor, const QModelIndex &index) const
-{
- QString value = index.model()->data(index, Qt::EditRole).toString();
-
- KLineEdit *le = static_cast<KLineEdit*>(editor);
- le->setText(value);
-}
-
-void Delegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
-{
- KLineEdit *le = static_cast<KLineEdit*>(editor);
-
- model->setData(index, le->text(), Qt::EditRole);
-}
-
-void Delegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const
-{
- editor->setGeometry(option.rect);
-}
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef DELEGATE_H
-#define DELEGATE_H
-
-#include <QWidget>
-#include <QStyledItemDelegate>
-
-class Delegate : public QStyledItemDelegate
-{
- Q_OBJECT
-public:
- explicit Delegate(QObject * parent = 0);
- virtual ~Delegate();
-
- virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
- virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
-
- virtual void setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const;
-
- virtual void updateEditorGeometry(QWidget *editor,
- const QStyleOptionViewItem &option, const QModelIndex &index) const;
-};
-
-#endif
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "hwaddrcombobox.h"
-
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/WiredDevice>
-#include <NetworkManagerQt/WirelessDevice>
-#include <NetworkManagerQt/BluetoothDevice>
-#include <NetworkManagerQt/OlpcMeshDevice>
-#include <NetworkManagerQt/WimaxDevice>
-#include <NetworkManagerQt/InfinibandDevice>
-#include <NetworkManagerQt/BondDevice>
-#include <NetworkManagerQt/BridgeDevice>
-#include <NetworkManagerQt/VlanDevice>
-#include <NetworkManagerQt/Utils>
-
-HwAddrComboBox::HwAddrComboBox(QWidget *parent) :
- KComboBox(parent), m_dirty(false)
-{
- setEditable(true);
- setInsertPolicy(QComboBox::NoInsert);
-
- connect(this, SIGNAL(editTextChanged(QString)), SLOT(editTextChanged(QString)));
- connect(this, SIGNAL(currentIndexChanged(int)), SLOT(currentIndexChanged(int)));
-}
-
-bool HwAddrComboBox::isValid() const
-{
- if (hwAddress().isEmpty()) {
- return true;
- }
-
- return NetworkManager::Utils::macAddressIsValid(hwAddress());
-}
-
-QString HwAddrComboBox::hwAddress() const
-{
- QString result;
- if (!m_dirty)
- result = itemData(currentIndex()).toString();
- else
- result = currentText();
-
- //qDebug() << "Result:" << currentIndex() << result;
-
- return result;
-}
-
-void HwAddrComboBox::editTextChanged(const QString &)
-{
- m_dirty = true;
- emit hwAddressChanged();
-}
-
-void HwAddrComboBox::currentIndexChanged(int)
-{
- m_dirty = false;
- emit hwAddressChanged();
-}
-
-void HwAddrComboBox::init(const NetworkManager::Device::Type &deviceType, const QString &address)
-{
- m_initialAddress = address;
-
- //qDebug() << "Initial address:" << m_initialAddress;
-
- QString deviceName;
- foreach(const NetworkManager::Device::Ptr & device, NetworkManager::networkInterfaces()) {
- const NetworkManager::Device::Type type = device->type();
- if (type == deviceType) {
- if (address == hwAddressFromDevice(device).toString()) {
- if (device->state() == NetworkManager::Device::Activated) {
- deviceName = device->ipInterfaceName();
- } else {
- deviceName = device->interfaceName();
- }
- }
- addAddressToCombo(device);
- }
- }
-
- const int index = findData(m_initialAddress);
- if (index == -1) {
- if (!m_initialAddress.isEmpty()) {
- QString text = QString("%1 (%2)").arg(deviceName).arg(m_initialAddress);
- insertItem(0, text, m_initialAddress);
- } else {
- insertItem(0, m_initialAddress, m_initialAddress);
- }
- setCurrentIndex(0);
- } else {
- setCurrentIndex(index);
- }
-}
-
-void HwAddrComboBox::addAddressToCombo(const NetworkManager::Device::Ptr &device)
-{
- QVariant data = hwAddressFromDevice(device);
- //qDebug() << "Data:" << data;
-
- QString name;
- if (device->state() == NetworkManager::Device::Activated)
- name = device->ipInterfaceName();
- else
- name = device->interfaceName();
-
- //qDebug() << "Name:" << name;
-
- if (!data.isNull()) {
- if (name == data.toString()) {
- addItem(data.toString(), data);
- }
- else {
- addItem(QString("%1 (%2)").arg(name).arg(data.toString()), data);
- }
- }
-}
-
-
-QVariant HwAddrComboBox::hwAddressFromDevice(const NetworkManager::Device::Ptr& device)
-{
- const NetworkManager::Device::Type type = device->type();
-
- QVariant data;
- if (type == NetworkManager::Device::Ethernet) {
- data = device->as<NetworkManager::WiredDevice>()->hardwareAddress();
- } else if (type == NetworkManager::Device::Wifi) {
- data = device->as<NetworkManager::WirelessDevice>()->hardwareAddress();
- } else if (type == NetworkManager::Device::Bluetooth) {
- data = device->as<NetworkManager::BluetoothDevice>()->hardwareAddress();
- } else if (type == NetworkManager::Device::OlpcMesh) {
- data = device->as<NetworkManager::OlpcMeshDevice>()->hardwareAddress();
- } else if (type == NetworkManager::Device::Wimax) {
- data = device->as<NetworkManager::WimaxDevice>()->hardwareAddress();
- } else if (type == NetworkManager::Device::InfiniBand) {
- data = device->as<NetworkManager::InfinibandDevice>()->hwAddress();
- } else if (type == NetworkManager::Device::Bond) {
- data = device->as<NetworkManager::BondDevice>()->hwAddress();
- } else if (type == NetworkManager::Device::Bridge) {
- data = device->as<NetworkManager::BridgeDevice>()->hwAddress();
- } else if (type == NetworkManager::Device::Vlan) {
- data = device->as<NetworkManager::VlanDevice>()->hwAddress();
- }
-
- return data;
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_HWADDRCOMBOBOX_H
-#define PLASMA_NM_HWADDRCOMBOBOX_H
-
-#include <KComboBox>
-
-#include "plasmanm_export.h"
-
-#include <NetworkManagerQt/Device>
-
-class PLASMA_NM_EXPORT HwAddrComboBox : public KComboBox
-{
- Q_OBJECT
-public:
- explicit HwAddrComboBox(QWidget *parent = 0);
-
- void init(const NetworkManager::Device::Type &deviceType, const QString &address);
-
- bool isValid() const;
- QString hwAddress() const;
-
-signals:
- void hwAddressChanged();
-
-private slots:
- void editTextChanged(const QString &);
- void currentIndexChanged(int);
-
-private:
- void addAddressToCombo(const NetworkManager::Device::Ptr &device);
- QVariant hwAddressFromDevice(const NetworkManager::Device::Ptr &device);
- QString m_initialAddress;
- bool m_dirty;
-};
-
-#endif // PLASMA_NM_HWADDRCOMBOBOX_H
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "intdelegate.h"
-#include <QIntValidator>
-
-#include <KLineEdit>
-
-IntDelegate::IntDelegate(QObject * parent) : Delegate(parent), m_boundary(false) {}
-IntDelegate::IntDelegate(int min, int max, QObject * parent) : Delegate(parent), m_min(min), m_max(max), m_boundary(true) {}
-IntDelegate::~IntDelegate() {}
-
-QWidget * IntDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
-{
- KLineEdit *editor = new KLineEdit(parent);
- if (m_boundary)
- editor->setValidator(new QIntValidator(m_min, m_max, editor));
- else
- editor->setValidator(new QIntValidator(editor));
-
- return editor;
-}
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef INTDELEGATE_H
-#define INTDELEGATE_H
-
-#include <KLineEdit>
-#include <QStandardItem>
-#include <QStandardItemModel>
-
-#include "delegate.h"
-
-class IntDelegate : public Delegate
-{
- Q_OBJECT
-public:
- explicit IntDelegate(QObject * parent = 0);
- IntDelegate(int min, int max, QObject * parent = 0);
- virtual ~IntDelegate();
-
- QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
-
-private:
- int m_min;
- int m_max;
- bool m_boundary;
-};
-
-#endif
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "ipv4delegate.h"
-
-#include <KLineEdit>
-#include <QStandardItem>
-#include <QStandardItemModel>
-
-#include "simpleipv4addressvalidator.h"
-
-IpV4Delegate::IpV4Delegate(QObject * parent) : Delegate(parent) {}
-IpV4Delegate::~IpV4Delegate() {}
-
-QWidget * IpV4Delegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
-{
- KLineEdit *editor = new KLineEdit(parent);
- editor->setValidator(new SimpleIpV4AddressValidator(editor));
-
- return editor;
-}
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef IPV4DELEGATE_H
-#define IPV4DELEGATE_H
-
-#include <QWidget>
-#include "delegate.h"
-
-class IpV4Delegate : public Delegate
-{
- Q_OBJECT
-public:
- explicit IpV4Delegate(QObject * parent = 0);
- virtual ~IpV4Delegate();
-
- QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
-};
-
-#endif
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>RoutesIp4Config</class>
- <widget class="QWidget" name="RoutesIp4Config">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>477</width>
- <height>324</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle">
- <string>Edit IPv4 Routes</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="2" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>12</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="4" column="0">
- <widget class="QCheckBox" name="cbNeverDefault">
- <property name="text">
- <string>Use only for resources on this connection</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>119</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="2">
- <widget class="QPushButton" name="pushButtonRemove">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string comment="Remove a selected row">R&emove</string>
- </property>
- <property name="icon">
- <iconset theme="list-remove">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="3">
- <widget class="QTableView" name="tableViewAddresses">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>150</width>
- <height>50</height>
- </size>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::SingleSelection</enum>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectRows</enum>
- </property>
- <property name="showGrid">
- <bool>true</bool>
- </property>
- <property name="gridStyle">
- <enum>Qt::SolidLine</enum>
- </property>
- <attribute name="horizontalHeaderStretchLastSection">
- <bool>true</bool>
- </attribute>
- <attribute name="verticalHeaderVisible">
- <bool>false</bool>
- </attribute>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QPushButton" name="pushButtonAdd">
- <property name="text">
- <string comment="Insert a row">Add</string>
- </property>
- <property name="icon">
- <iconset theme="list-add">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="cbIgnoreAutoRoutes">
- <property name="text">
- <string>Ignore automatically obtained routes</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1" colspan="2">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "ipv4routeswidget.h"
-
-#include <KLineEdit>
-#include <QStandardItem>
-#include <QStandardItemModel>
-#include <QNetworkAddressEntry>
-
-#include <KDebug>
-#include <KAcceleratorManager>
-#include <KLocale>
-
-#include "ui_ipv4routes.h"
-
-#include "ipv4delegate.h"
-#include "intdelegate.h"
-
-class IpV4RoutesWidget::Private
-{
-public:
- Private() : model(0,4)
- {
- QStandardItem * headerItem = new QStandardItem(i18nc("Header text for IPv4 address", "Address"));
- model.setHorizontalHeaderItem(0, headerItem);
- headerItem = new QStandardItem(i18nc("Header text for IPv4 netmask", "Netmask"));
- model.setHorizontalHeaderItem(1, headerItem);
- headerItem = new QStandardItem(i18nc("Header text for IPv4 gateway", "Gateway"));
- model.setHorizontalHeaderItem(2, headerItem);
- headerItem = new QStandardItem(i18nc("Header text for IPv4 route metric", "Metric"));
- model.setHorizontalHeaderItem(3, headerItem);
- }
- Ui_RoutesIp4Config ui;
- QStandardItemModel model;
-};
-
-IpV4RoutesWidget::IpV4RoutesWidget(QWidget * parent)
- : QDialog(parent), d(new IpV4RoutesWidget::Private())
-{
- d->ui.setupUi(this);
- d->ui.tableViewAddresses->setModel(&d->model);
- d->ui.tableViewAddresses->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
-
- IpV4Delegate *ipDelegate = new IpV4Delegate(this);
- IntDelegate *metricDelegate = new IntDelegate(this);
- d->ui.tableViewAddresses->setItemDelegateForColumn(0, ipDelegate);
- d->ui.tableViewAddresses->setItemDelegateForColumn(1, ipDelegate);
- d->ui.tableViewAddresses->setItemDelegateForColumn(2, ipDelegate);
- d->ui.tableViewAddresses->setItemDelegateForColumn(3, metricDelegate);
-
- connect(d->ui.pushButtonAdd, SIGNAL(clicked()), this, SLOT(addRoute()));
- connect(d->ui.pushButtonRemove, SIGNAL(clicked()), this, SLOT(removeRoute()));
-
- connect(d->ui.tableViewAddresses->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,
- SLOT(selectionChanged(QItemSelection)));
-
- connect(&d->model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(tableViewItemChanged(QStandardItem*)));
-
- connect(d->ui.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(d->ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
-
- KAcceleratorManager::manage(this);
-}
-
-IpV4RoutesWidget::~IpV4RoutesWidget()
-{
- delete d;
-}
-
-void IpV4RoutesWidget::setNeverDefault(bool checked)
-{
- d->ui.cbNeverDefault->setChecked(checked);
-}
-
-bool IpV4RoutesWidget::neverDefault() const
-{
- return d->ui.cbNeverDefault->isChecked();
-}
-
-void IpV4RoutesWidget::setIgnoreAutoRoutes(bool checked)
-{
- d->ui.cbIgnoreAutoRoutes->setChecked(checked);
-}
-
-void IpV4RoutesWidget::setIgnoreAutoRoutesCheckboxEnabled(bool enabled)
-{
- d->ui.cbIgnoreAutoRoutes->setEnabled(enabled);
-}
-
-bool IpV4RoutesWidget::ignoreautoroutes() const
-{
- return d->ui.cbIgnoreAutoRoutes->isChecked();
-}
-
-void IpV4RoutesWidget::setRoutes(const QList<NetworkManager::IpRoute> &list)
-{
- d->model.removeRows(0, d->model.rowCount());
- foreach (const NetworkManager::IpRoute &route, list) {
- QList<QStandardItem *> item;
-
- kDebug() << route.ip();
- item << new QStandardItem(route.ip().toString())
- << new QStandardItem(route.netmask().toString())
- << new QStandardItem(route.nextHop().toString())
- << new QStandardItem(QString::number(route.metric(), 10));
-
- d->model.appendRow(item);
- }
-}
-
-QList<NetworkManager::IpRoute> IpV4RoutesWidget::routes()
-{
- QList<NetworkManager::IpRoute> list;
-
- for (int i = 0, rowCount = d->model.rowCount(); i < rowCount; i++) {
- NetworkManager::IpRoute route;
- QStandardItem *item = d->model.item(i,0);
- if (item) {
- route.setIp(QHostAddress(item->text()));
- }
- item = d->model.item(i, 1);
- if (item) {
- route.setNetmask(QHostAddress(item->text()));
- }
- item = d->model.item(i, 2);
- if (item) {
- route.setNextHop(QHostAddress(item->text()));
- }
- item = d->model.item(i, 3);
- if (item) {
- route.setMetric(item->text().toUInt());
- }
-
- list << route;
- }
- return list;
-}
-
-void IpV4RoutesWidget::addRoute()
-{
- QList<QStandardItem *> item;
- item << new QStandardItem << new QStandardItem << new QStandardItem;
- d->model.appendRow(item);
-
- const int rowCount = d->model.rowCount();
- if (rowCount > 0) {
- d->ui.tableViewAddresses->selectRow(rowCount - 1);
-
- QItemSelectionModel * selectionModel = d->ui.tableViewAddresses->selectionModel();
- QModelIndexList list = selectionModel->selectedIndexes();
- if (list.size()) {
- // QTableView is configured to select only rows.
- // So, list[0] - IP address.
- d->ui.tableViewAddresses->edit(list[0]);
- }
- }
-}
-
-void IpV4RoutesWidget::removeRoute()
-{
- QItemSelectionModel * selectionModel = d->ui.tableViewAddresses->selectionModel();
- if (selectionModel->hasSelection()) {
- QModelIndexList indexes = selectionModel->selectedIndexes();
- d->model.takeRow(indexes[0].row());
- }
- d->ui.pushButtonRemove->setEnabled(d->ui.tableViewAddresses->selectionModel()->hasSelection());
-}
-
-void IpV4RoutesWidget::selectionChanged(const QItemSelection & selected)
-{
- kDebug() << "selectionChanged";
- d->ui.pushButtonRemove->setEnabled(!selected.isEmpty());
-}
-
-extern quint32 suggestNetmask(quint32 ip);
-
-void IpV4RoutesWidget::tableViewItemChanged(QStandardItem *item)
-{
- if (item->text().isEmpty()) {
- return;
- }
-
- const int column = item->column();
- if (column == 0) { // ip
- int row = item->row();
-
- QStandardItem *netmaskItem = d->model.item(row, column + 1); // netmask
- if (netmaskItem && netmaskItem->text().isEmpty()) {
- QHostAddress addr(item->text());
- quint32 netmask = suggestNetmask(addr.toIPv4Address());
- if (netmask) {
- QHostAddress v(netmask);
- netmaskItem->setText(v.toString());
- }
- }
- }
-}
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef IPV4ROUTESWIDGET_H
-#define IPV4ROUTESWIDGET_H
-
-#include <QDialog>
-#include <QStyledItemDelegate>
-
-#include <NetworkManagerQt/IpConfig>
-
-class QStandardItem;
-class QItemSelection;
-
-class IpV4RoutesWidget : public QDialog
-{
- Q_OBJECT
-public:
- explicit IpV4RoutesWidget(QWidget * parent = 0);
- virtual ~IpV4RoutesWidget();
-
- void setRoutes(const QList<NetworkManager::IpRoute> &list);
- QList<NetworkManager::IpRoute> routes();
- void setNeverDefault(bool checked);
- bool neverDefault() const;
- void setIgnoreAutoRoutes(bool checked);
- void setIgnoreAutoRoutesCheckboxEnabled(bool enabled);
- bool ignoreautoroutes() const;
-
-private slots:
- void addRoute();
- void removeRoute();
- /**
- * Update remove IP button depending on if there is a selection
- */
- void selectionChanged(const QItemSelection &);
- void tableViewItemChanged(QStandardItem *);
-
-private:
- class Private;
- Private *d;
-};
-
-#endif // IPV4ROUTESWIDGET_H
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "ipv6delegate.h"
-
-#include <KLineEdit>
-#include <QStandardItem>
-#include <QStandardItemModel>
-
-#include "simpleipv6addressvalidator.h"
-
-IpV6Delegate::IpV6Delegate(QObject * parent) : Delegate(parent) {}
-IpV6Delegate::~IpV6Delegate() {}
-
-QWidget * IpV6Delegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
-{
- KLineEdit *editor = new KLineEdit(parent);
- editor->setValidator(new SimpleIpV6AddressValidator(editor));
-
- return editor;
-}
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef IPV6DELEGATE_H
-#define IPV6DELEGATE_H
-
-#include <QWidget>
-#include <QStyledItemDelegate>
-
-#include "delegate.h"
-
-class IpV6Delegate : public Delegate
-{
- Q_OBJECT
-public:
- explicit IpV6Delegate(QObject * parent = 0);
- virtual ~IpV6Delegate();
-
- QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
-};
-
-#endif
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>RoutesIp6Config</class>
- <widget class="QWidget" name="RoutesIp6Config">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>449</width>
- <height>324</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle">
- <string>Edit IPv6 Routes</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="3">
- <widget class="QTableView" name="tableViewAddresses">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>150</width>
- <height>50</height>
- </size>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::SingleSelection</enum>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectRows</enum>
- </property>
- <property name="showGrid">
- <bool>true</bool>
- </property>
- <property name="gridStyle">
- <enum>Qt::SolidLine</enum>
- </property>
- <attribute name="horizontalHeaderStretchLastSection">
- <bool>true</bool>
- </attribute>
- <attribute name="verticalHeaderVisible">
- <bool>false</bool>
- </attribute>
- </widget>
- </item>
- <item row="1" column="0">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>119</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="1">
- <widget class="QPushButton" name="pushButtonAdd">
- <property name="text">
- <string comment="Insert a row">Add</string>
- </property>
- <property name="icon">
- <iconset theme="list-add">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QPushButton" name="pushButtonRemove">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string comment="Remove a selected row">R&emove</string>
- </property>
- <property name="icon">
- <iconset theme="list-remove">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>12</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="cbIgnoreAutoRoutes">
- <property name="text">
- <string>Ignore automatically obtained routes</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="2">
- <widget class="QCheckBox" name="cbNeverDefault">
- <property name="text">
- <string>Use only for resources on this connection</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1" colspan="2">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "ipv6routeswidget.h"
-
-#include <KLineEdit>
-#include <QStandardItem>
-#include <QStandardItemModel>
-#include <QNetworkAddressEntry>
-
-#include <KDebug>
-#include <KAcceleratorManager>
-#include <KLocale>
-
-#include "ui_ipv6routes.h"
-
-#include "ipv6delegate.h"
-#include "intdelegate.h"
-
-class IpV6RoutesWidget::Private
-{
-public:
- Private() : model(0,4)
- {
- QStandardItem * headerItem = new QStandardItem(i18nc("Header text for IPv6 address", "Address"));
- model.setHorizontalHeaderItem(0, headerItem);
- headerItem = new QStandardItem(i18nc("Header text for IPv6 netmask", "Netmask"));
- model.setHorizontalHeaderItem(1, headerItem);
- headerItem = new QStandardItem(i18nc("Header text for IPv6 gateway", "Gateway"));
- model.setHorizontalHeaderItem(2, headerItem);
- headerItem = new QStandardItem(i18nc("Header text for IPv6 route metric", "Metric"));
- model.setHorizontalHeaderItem(3, headerItem);
- }
- Ui_RoutesIp6Config ui;
- QStandardItemModel model;
-};
-
-IpV6RoutesWidget::IpV6RoutesWidget(QWidget * parent)
- : QDialog(parent), d(new IpV6RoutesWidget::Private())
-{
- d->ui.setupUi(this);
- d->ui.tableViewAddresses->setModel(&d->model);
- d->ui.tableViewAddresses->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
-
- IpV6Delegate *ipDelegate = new IpV6Delegate(this);
- IntDelegate *netmaskDelegate = new IntDelegate(0,128,this);
- IntDelegate *metricDelegate = new IntDelegate(this);
- d->ui.tableViewAddresses->setItemDelegateForColumn(0, ipDelegate);
- d->ui.tableViewAddresses->setItemDelegateForColumn(1, netmaskDelegate);
- d->ui.tableViewAddresses->setItemDelegateForColumn(2, ipDelegate);
- d->ui.tableViewAddresses->setItemDelegateForColumn(3, metricDelegate);
-
- connect(d->ui.pushButtonAdd, SIGNAL(clicked()), this, SLOT(addRoute()));
- connect(d->ui.pushButtonRemove, SIGNAL(clicked()), this, SLOT(removeRoute()));
-
- connect(d->ui.tableViewAddresses->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,
- SLOT(selectionChanged(QItemSelection)));
-
- connect(&d->model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(tableViewItemChanged(QStandardItem*)));
-
- connect(d->ui.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(d->ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
-
- KAcceleratorManager::manage(this);
-}
-
-IpV6RoutesWidget::~IpV6RoutesWidget()
-{
- delete d;
-}
-
-void IpV6RoutesWidget::setNeverDefault(bool checked)
-{
- d->ui.cbNeverDefault->setChecked(checked);
-}
-
-bool IpV6RoutesWidget::neverDefault() const
-{
- return d->ui.cbNeverDefault->isChecked();
-}
-
-void IpV6RoutesWidget::setIgnoreAutoRoutes(bool checked)
-{
- d->ui.cbIgnoreAutoRoutes->setChecked(checked);
-}
-
-void IpV6RoutesWidget::setIgnoreAutoRoutesCheckboxEnabled(bool enabled)
-{
- d->ui.cbIgnoreAutoRoutes->setEnabled(enabled);
-}
-
-bool IpV6RoutesWidget::ignoreautoroutes() const
-{
- return d->ui.cbIgnoreAutoRoutes->isChecked();
-}
-
-void IpV6RoutesWidget::setRoutes(const QList<NetworkManager::IpRoute> &list)
-{
- d->model.removeRows(0, d->model.rowCount());
- foreach (const NetworkManager::IpRoute &route, list) {
- QList<QStandardItem *> item;
- kDebug() << route.ip();
- item << new QStandardItem(route.ip().toString())
- << new QStandardItem(QString::number(route.prefixLength(), 10))
- << new QStandardItem(route.nextHop().toString())
- << new QStandardItem(QString::number(route.metric(), 10));
-
- d->model.appendRow(item);
- }
-}
-
-QList<NetworkManager::IpRoute> IpV6RoutesWidget::routes()
-{
- QList<NetworkManager::IpRoute> list;
-
- for (int i = 0, rowCount = d->model.rowCount(); i < rowCount; i++) {
- NetworkManager::IpRoute route;
- QStandardItem *item = d->model.item(i,0);
- if (item) {
- route.setIp(QHostAddress(item->text()));
- }
- item = d->model.item(i, 2);
- if (item) {
- route.setNextHop(QHostAddress(item->text()));
- }
- item = d->model.item(i, 1);
- if (item) {
- route.setPrefixLength(item->text().toInt());
- }
- item = d->model.item(i, 3);
- if (item) {
- route.setMetric(item->text().toUInt());
- }
-
- list << route;
- }
- return list;
-}
-
-void IpV6RoutesWidget::addRoute()
-{
- QList<QStandardItem *> item;
- item << new QStandardItem << new QStandardItem << new QStandardItem;
- d->model.appendRow(item);
-
- const int rowCount = d->model.rowCount();
- if (rowCount > 0) {
- d->ui.tableViewAddresses->selectRow(rowCount - 1);
-
- QItemSelectionModel * selectionModel = d->ui.tableViewAddresses->selectionModel();
- QModelIndexList list = selectionModel->selectedIndexes();
- if (list.size()) {
- // QTableView is configured to select only rows.
- // So, list[0] - IP address.
- d->ui.tableViewAddresses->edit(list[0]);
- }
- }
-}
-
-void IpV6RoutesWidget::removeRoute()
-{
- QItemSelectionModel * selectionModel = d->ui.tableViewAddresses->selectionModel();
- if (selectionModel->hasSelection()) {
- QModelIndexList indexes = selectionModel->selectedIndexes();
- d->model.takeRow(indexes[0].row());
- }
- d->ui.pushButtonRemove->setEnabled(false);
-}
-
-void IpV6RoutesWidget::selectionChanged(const QItemSelection & selected)
-{
- kDebug() << "selectionChanged";
- d->ui.pushButtonRemove->setEnabled(!selected.isEmpty());
-}
-
-extern quint32 suggestNetmask(Q_IPV6ADDR ip);
-
-void IpV6RoutesWidget::tableViewItemChanged(QStandardItem *item)
-{
- if (item->text().isEmpty()) {
- return;
- }
-
- const int column = item->column();
- if (column == 0) { // ip
- int row = item->row();
-
- QStandardItem *netmaskItem = d->model.item(row, column + 1); // netmask
- if (netmaskItem && netmaskItem->text().isEmpty()) {
- QHostAddress addr(item->text());
- quint32 netmask = suggestNetmask(addr.toIPv6Address());
- if (netmask) {
- netmaskItem->setText(QString::number(netmask,10));
- }
- }
- }
-}
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef IPV6ROUTESWIDGET_H
-#define IPV6ROUTESWIDGET_H
-
-#include <QDialog>
-#include <QStyledItemDelegate>
-
-#include <NetworkManagerQt/IpConfig>
-
-class QStandardItem;
-class QItemSelection;
-
-class IpV6RoutesWidget : public QDialog
-{
- Q_OBJECT
-public:
- explicit IpV6RoutesWidget(QWidget * parent = 0);
- virtual ~IpV6RoutesWidget();
-
- void setRoutes(const QList<NetworkManager::IpRoute> &list);
- QList<NetworkManager::IpRoute> routes();
- void setNeverDefault(bool checked);
- bool neverDefault() const;
- void setIgnoreAutoRoutes(bool checked);
- void setIgnoreAutoRoutesCheckboxEnabled(bool enabled);
- bool ignoreautoroutes() const;
-
-private slots:
- void addRoute();
- void removeRoute();
- /**
- * Update remove IP button depending on if there is a selection
- */
- void selectionChanged(const QItemSelection &);
- void tableViewItemChanged(QStandardItem *);
-
-private:
- class Private;
- Private *d;
-};
-
-#endif // IPV6ROUTESWIDGET_H
+++ /dev/null
-/*
- Copyright 2010-2012 Lamarque Souza <lamarque@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "mobileconnectionwizard.h"
-#include "uiutils.h"
-
-#include <QVBoxLayout>
-
-#include <KLocale>
-#include <KDebug>
-#include <KGlobal>
-#include <KIconLoader>
-#include <Solid/Device>
-
-#include <NetworkManagerQt/ModemDevice>
-
-#include <ModemManagerQt/manager.h>
-#include <ModemManagerQt/modem.h>
-
-#define NUMBER_OF_STATIC_ENTRIES 3
-
-MobileConnectionWizard::MobileConnectionWizard(NetworkManager::ConnectionSettings::ConnectionType connectionType, QWidget * parent)
- : QWizard(parent)
-{
- if (connectionType == NetworkManager::ConnectionSettings::Unknown) {
- mInitialMethodType = false;
- } else {
- mInitialMethodType = true;
-
- if (connectionType == NetworkManager::ConnectionSettings::Bluetooth) {
- mType = NetworkManager::ConnectionSettings::Gsm;
- } else {
- mType = connectionType;
- }
- }
-
- mProviders = new MobileProviders();
- setWindowTitle(i18nc("Mobile Connection Wizard", "New Mobile Broadband Connection"));
- addPage(createIntroPage());
- addPage(createCountryPage());
- addPage(createProvidersPage());
- addPage(createPlansPage());
- addPage(createConfirmPage());
- setOptions(QWizard::NoBackButtonOnStartPage);
-}
-
-MobileConnectionWizard::~MobileConnectionWizard()
-{
- delete mProviders;
-}
-
-MobileProviders::ErrorCodes MobileConnectionWizard::getError()
-{
- if (mProviders) {
- return mProviders->getError();
- }
- return MobileProviders::Success;
-}
-
-void MobileConnectionWizard::initializePage(int id)
-{
- switch (id) {
- case 1: { // Country Page
- if (country.isEmpty()) {
- country = mProviders->countryFromLocale();
- }
-
- if (country.isEmpty())
- mCountryList->setCurrentRow(0);
- else {
- QList<QListWidgetItem *> items = mCountryList->findItems(mProviders->getCountryName(country), Qt::MatchExactly);
- if (!items.empty()) {
- mCountryList->setCurrentItem(items.first());
- }
- }
-
- if (!mInitialMethodType) {
- NetworkManager::Device::Ptr iface = NetworkManager::findNetworkInterface(mDeviceComboBox->itemData(mDeviceComboBox->currentIndex()).toString());
- if (iface) {
- NetworkManager::ModemDevice::Ptr nmModemIface = iface.objectCast<NetworkManager::ModemDevice>();
- if (nmModemIface && UiUtils::modemSubType(nmModemIface->currentCapabilities()) == NetworkManager::ModemDevice::CdmaEvdo) {
- mType = NetworkManager::ConnectionSettings::Cdma;
- } else {
- mType = NetworkManager::ConnectionSettings::Gsm;
- }
- } else {
- mType = static_cast<NetworkManager::ConnectionSettings::ConnectionType>(mDeviceComboBox->itemData(mDeviceComboBox->currentIndex()).toUInt());
- }
- }
-
- if (mProviders->getError() != MobileProviders::Success) {
- accept();
- }
- break;
- }
-
- case 2: // Providers Page
- country = mCountryList->currentItem()->text();
- mProvidersList->clear();
- lineEditProvider->clear();
- radioAutoProvider->setChecked(true);
-
- switch (type()) {
- case NetworkManager::ConnectionSettings::Gsm:
- mProvidersList->insertItems(0, mProviders->getProvidersList(country, NetworkManager::ConnectionSettings::Gsm));
- break;
- case NetworkManager::ConnectionSettings::Cdma:
- mProvidersList->insertItems(0, mProviders->getProvidersList(country, NetworkManager::ConnectionSettings::Cdma));
- break;
- default:
- break;
- }
- mProvidersList->setCurrentRow(0);
- if (mProvidersList->count() > 0) {
- mProvidersList->setEnabled(true);
- radioAutoProvider->setEnabled(true);
- mProvidersList->setFocus();
- } else {
- mProvidersList->setEnabled(false);
- radioAutoProvider->setEnabled(false);
- radioManualProvider->setChecked(true);
- // TODO: this does not work, try reimplementing QWizardPage::isComplete()
- //button(QWizard::NextButton)->setEnabled(false);
- }
- break;
-
- case 3: // Plans Page
- disconnect(mPlanComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotEnablePlanEditBox(QString)));
- mPlanComboBox->clear();
- if (type() != NetworkManager::ConnectionSettings::Gsm) {
- goto OUT_3;
- }
- if (radioManualProvider->isChecked()) {
- mPlanComboBox->insertSeparator(1);
- mPlanComboBox->addItem(i18nc("Mobile Connection Wizard", "My plan is not listed..."));
- mPlanComboBox->setCurrentIndex(1);
- userApn->clear();
-
- if (lineEditProvider->text().isEmpty()) {
- lineEditProvider->setText(i18nc("Mobile Connection Wizard", "Unknown Provider"));
- }
- } else {
- if (mProvidersList->currentItem() != 0) {
- const QStringList mApns = mProviders->getApns(mProvidersList->currentItem()->text());
- if (!mApns.isEmpty()) {
- userApn->setText(mApns.first());
- mPlanComboBox->insertItems(0, mApns);
- mPlanComboBox->setItemText(0, i18nc("Mobile Connection Wizard", "Default"));
- }
- }
-
- mPlanComboBox->insertSeparator(1);
- mPlanComboBox->addItem(i18nc("Mobile Connection Wizard", "My plan is not listed..."));
- }
-OUT_3:
- connect(mPlanComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotEnablePlanEditBox(QString)));
- break;
-
- case 4: // Confirm Page
- if (radioManualProvider->isChecked()) {
- labelProvider->setText(" " + lineEditProvider->text() + ", " + country);
- provider = lineEditProvider->text();
- } else {
- labelProvider->setText(" " + mProvidersList->currentItem()->text() + ", " + country);
- provider = mProvidersList->currentItem()->text();
- }
-
- if (type() == NetworkManager::ConnectionSettings::Cdma) {
- labelPlanLabel->hide();
- labelPlan->hide();
- labelApn->hide();
- userApn->clear();
- apn.clear();
- } else {
- labelPlanLabel->show();
- labelPlan->show();
- labelApn->show();
-
- if (mPlanComboBox->currentText() == i18nc("Mobile Connection Wizard", "My plan is not listed...")) {
- labelPlan->setText(" " + userApn->text());
- labelApn->setText(" " + i18nc("Mobile Connection Wizard", "APN: %1", userApn->text()));
- apn = userApn->text();
- } else {
- int i = mPlanComboBox->currentIndex();
- i = i > 1 ? (i-1) : 0; // ignores separator's index (i == 1).
-
- QStringList mApns = mProviders->getApns(mProvidersList->currentItem()->text());
- labelPlan->setText(" " + mPlanComboBox->currentText());
- labelApn->setText(" " + i18nc("Mobile Connection Wizard", "APN: %1", mApns.at(i)));
- apn = mApns.at(i);
- }
- }
- break;
- }
-}
-
-int MobileConnectionWizard::nextId() const
-{
- // Providers page
- if (currentId() == 2 && type() != NetworkManager::ConnectionSettings::Gsm) {
- // Jumps to Confirm page instead of Plans page if type != Gsm.
- return 4;
- } else {
- return QWizard::nextId();
- }
-}
-
-QVariantList MobileConnectionWizard::args()
-{
- QVariantList temp;
-
- switch (type()) {
- case NetworkManager::ConnectionSettings::Cdma:
- temp << provider << mProviders->getCdmaInfo(provider);
- break;
-
- case NetworkManager::ConnectionSettings::Gsm:
- temp << provider /*<< mProviders->getNetworkIds(provider)*/ << mProviders->getApnInfo(apn);
- break;
-
- default:
- break;
- }
- return temp;
-}
-
-/**********************************************************/
-/* Intro page */
-/**********************************************************/
-
-QWizardPage * MobileConnectionWizard::createIntroPage()
-{
- QWizardPage *page = new QWizardPage();
- page->setTitle(i18nc("Mobile Connection Wizard", "Set up a Mobile Broadband Connection"));
- QVBoxLayout *layout = new QVBoxLayout;
-
- QLabel *label = new QLabel(i18nc("Mobile Connection Wizard", "This assistant helps you easily set up a mobile broadband connection to a cellular (3G) network."));
- label->setWordWrap(true);
- layout->addWidget(label);
-
- label = new QLabel('\n' + i18nc("Mobile Connection Wizard", "You will need the following information:"));
- layout->addWidget(label);
-
- label = new QLabel(QString(" . %1\n . %2\n . %3").
- arg(i18nc("Mobile Connection Wizard", "Your broadband provider's name")).
- arg(i18nc("Mobile Connection Wizard", "Your broadband billing plan name")).
- arg(i18nc("Mobile Connection Wizard", "(in some cases) Your broadband billing plan APN (Access Point Name)")));
- layout->addWidget(label);
-
- if (!mInitialMethodType) {
- label = new QLabel('\n' + i18nc("Mobile Connection Wizard", "Create a connection for &this mobile broadband device:"));
- layout->addWidget(label);
-
- mDeviceComboBox = new KComboBox();
- mDeviceComboBox->addItem(i18nc("Mobile Connection Wizard", "Any GSM device"));
- mDeviceComboBox->setItemData(0, NetworkManager::ConnectionSettings::Gsm);
- mDeviceComboBox->addItem(i18nc("Mobile Connection Wizard", "Any CDMA device"));
- mDeviceComboBox->setItemData(1, NetworkManager::ConnectionSettings::Cdma);
- mDeviceComboBox->insertSeparator(NUMBER_OF_STATIC_ENTRIES-1);
- label->setBuddy(mDeviceComboBox);
- layout->addWidget(mDeviceComboBox);
-
- QObject::connect(NetworkManager::notifier(), SIGNAL(deviceAdded(QString)),
- this, SLOT(introDeviceAdded(QString)));
- QObject::connect(NetworkManager::notifier(), SIGNAL(deviceRemoved(QString)),
- this, SLOT(introDeviceRemoved(QString)));
- QObject::connect(NetworkManager::notifier(), SIGNAL(statusChanged(NetworkManager::Status)),
- this, SLOT(introStatusChanged(NetworkManager::Status)));
-
- introAddInitialDevices();
- }
-
- page->setLayout(layout);
-
- return page;
-}
-
-void MobileConnectionWizard::introAddDevice(const NetworkManager::Device::Ptr &device)
-{
- QString desc;
-
- ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(device->udi());
- if (modem) {
- ModemManager::Modem::Ptr modemInterface = modem->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
- if (modemInterface->powerState() == MM_MODEM_POWER_STATE_ON) {
- desc.append(modemInterface->manufacturer());
- desc.append(" ");
- desc.append(modemInterface->model());
- } else {
- QString deviceName = modemInterface->device();
- foreach (const Solid::Device &d, Solid::Device::allDevices()) {
- if (d.udi().contains(deviceName, Qt::CaseInsensitive)) {
- deviceName = d.product();
- if (!deviceName.startsWith(d.vendor())) {
- deviceName = d.vendor() + ' ' + deviceName;
- }
- desc.append(deviceName);
- break;
- }
- }
- }
- }
-
- NetworkManager::ModemDevice::Ptr nmModemIface = device.objectCast<NetworkManager::ModemDevice>();
- if (!nmModemIface) {
- return;
- }
-
- if (UiUtils::modemSubType(nmModemIface->currentCapabilities()) == NetworkManager::ModemDevice::GsmUmts) {
- if (desc.isEmpty()) {
- desc.append(i18nc("Mobile Connection Wizard", "Installed GSM device"));
- }
- } else if (UiUtils::modemSubType(nmModemIface->currentCapabilities()) == NetworkManager::ModemDevice::CdmaEvdo) {
- if (desc.isEmpty()) {
- desc.append(i18nc("Mobile Connection Wizard", "Installed CDMA device"));
- }
- } else {
- return;
- }
-
- mDeviceComboBox->addItem(desc, device->uni());
-
- if (mDeviceComboBox->count() == NUMBER_OF_STATIC_ENTRIES) {
- mDeviceComboBox->setCurrentIndex(0);
- } else {
- mDeviceComboBox->setCurrentIndex(NUMBER_OF_STATIC_ENTRIES);
- }
-}
-
-void MobileConnectionWizard::introDeviceAdded(const QString &uni)
-{
- introAddDevice(NetworkManager::findNetworkInterface(uni));
-}
-
-void MobileConnectionWizard::introDeviceRemoved(const QString &uni)
-{
- int index = mDeviceComboBox->findData(uni);
-
- mDeviceComboBox->removeItem(index);
-
- if (mDeviceComboBox->count() == NUMBER_OF_STATIC_ENTRIES) {
- mDeviceComboBox->setCurrentIndex(0);
- if (currentId() > 0) {
- close();
- }
- } else {
- mDeviceComboBox->setCurrentIndex(NUMBER_OF_STATIC_ENTRIES);
- }
-}
-
-void MobileConnectionWizard::introStatusChanged(NetworkManager::Status status)
-{
- switch (status) {
- case NetworkManager::Unknown:
- case NetworkManager::Asleep:
- case NetworkManager::Disconnected:
- case NetworkManager::Disconnecting:
- introRemoveAllDevices();
- break;
- case NetworkManager::Connecting:
- case NetworkManager::ConnectedLinkLocal:
- case NetworkManager::ConnectedSiteOnly:
- case NetworkManager::Connected:
- introAddInitialDevices();
- break;
- }
-}
-
-void MobileConnectionWizard::introAddInitialDevices()
-{
- foreach(const NetworkManager::Device::Ptr & n, NetworkManager::networkInterfaces()) {
- introAddDevice(n);
- }
-
- if (mDeviceComboBox->count() == NUMBER_OF_STATIC_ENTRIES) {
- mDeviceComboBox->setCurrentIndex(0);
- } else {
- mDeviceComboBox->setCurrentIndex(NUMBER_OF_STATIC_ENTRIES);
- }
-}
-
-void MobileConnectionWizard::introRemoveAllDevices()
-{
- mDeviceComboBox->clear();
- mDeviceComboBox->addItem(i18nc("Mobile Connection Wizard", "Any GSM device"));
- mDeviceComboBox->setItemData(0, NetworkManager::ConnectionSettings::Gsm);
- mDeviceComboBox->addItem(i18nc("Mobile Connection Wizard", "Any CDMA device"));
- mDeviceComboBox->setItemData(1, NetworkManager::ConnectionSettings::Cdma);
- mDeviceComboBox->insertSeparator(NUMBER_OF_STATIC_ENTRIES-1);
- mDeviceComboBox->setCurrentIndex(0);
-}
-
-/**********************************************************/
-/* Country page */
-/**********************************************************/
-
-QWizardPage * MobileConnectionWizard::createCountryPage()
-{
- QWizardPage *page = new QWizardPage();
- page->setTitle(i18nc("Mobile Connection Wizard", "Choose your Provider's Country"));
- QVBoxLayout *layout = new QVBoxLayout;
-
- QLabel *label = new QLabel(i18nc("Mobile Connection Wizard", "Country List:"));
- layout->addWidget(label);
-
- mCountryList = new QListWidget();
- mCountryList->addItem(i18nc("Mobile Connection Wizard", "My country is not listed"));
- mCountryList->insertItems(1, mProviders->getCountryList());
- layout->addWidget(mCountryList);
-
- page->setLayout(layout);
-
- return page;
-}
-
-/**********************************************************/
-/* Providers page */
-/**********************************************************/
-
-QWizardPage * MobileConnectionWizard::createProvidersPage()
-{
- QWizardPage *page = new QWizardPage();
- page->setTitle(i18nc("Mobile Connection Wizard", "Choose your Provider"));
- QVBoxLayout *layout = new QVBoxLayout;
-
- radioAutoProvider = new QRadioButton(i18nc("Mobile Connection Wizard", "Select your provider from a &list:"));
- radioAutoProvider->setChecked(true);
- layout->addWidget(radioAutoProvider);
-
- mProvidersList = new QListWidget();
- connect(mProvidersList, SIGNAL(itemSelectionChanged()), this, SLOT(slotCheckProviderList()));
- connect(mProvidersList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(slotCheckProviderList()));
- layout->addWidget(mProvidersList);
-
- radioManualProvider = new QRadioButton(i18nc("Mobile Connection Wizard", "I cannot find my provider and I wish to enter it &manually:"));
- layout->addWidget(radioManualProvider);
- connect(radioManualProvider, SIGNAL(toggled(bool)), this, SLOT(slotEnableProviderEdit(bool)));
-
- lineEditProvider = new KLineEdit();
- layout->addWidget(lineEditProvider);
- connect(lineEditProvider, SIGNAL(textEdited(QString)), this, SLOT(slotCheckProviderEdit()));
-
- page->setLayout(layout);
-
- return page;
-}
-
-void MobileConnectionWizard::slotEnableProviderEdit(bool checked)
-{
- if (checked) {
- lineEditProvider->setFocus();
- } else {
- mProvidersList->setFocus();
- }
-}
-
-void MobileConnectionWizard::slotCheckProviderEdit()
-{
- radioManualProvider->setChecked(true);
- // TODO: this does not work, try reimplementing QWizardPage::isComplete()
- //button(QWizard::NextButton)->setEnabled(true);
-}
-
-void MobileConnectionWizard::slotCheckProviderList()
-{
- radioAutoProvider->setChecked(true);
- lineEditProvider->clear();
-}
-
-/**********************************************************/
-/* Plan page */
-/**********************************************************/
-
-QWizardPage * MobileConnectionWizard::createPlansPage()
-{
- QWizardPage *page = new QWizardPage();
- page->setTitle(i18nc("Mobile Connection Wizard", "Choose your Billing Plan"));
- QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom);
-
- QLabel *label = new QLabel(i18nc("Mobile Connection Wizard", "&Select your plan:"));
- layout->addWidget(label);
-
- mPlanComboBox = new KComboBox();
- label->setBuddy(mPlanComboBox);
- layout->addWidget(mPlanComboBox);
-
- label = new QLabel('\n' + i18nc("Mobile Connection Wizard", "Selected plan &APN (Access Point Name):"));
- layout->addWidget(label);
-
- userApn = new KLineEdit();
- userApn->setEnabled(false);
- label->setBuddy(userApn);
- layout->addWidget(userApn);
-
- QHBoxLayout *layout2 = new QHBoxLayout();
- label = new QLabel();
- label->setPixmap(KIconLoader::global()->loadIcon("dialog-warning", KIconLoader::Dialog));
- layout2->addWidget(label, 0, Qt::AlignTop);
- label = new QLabel(i18nc("Mobile Connection Wizard", "Warning: Selecting an incorrect plan may result in billing issues for your broadband account or may prevent connectivity.\n\nIf you are unsure of your plan please ask your provider for your plan's APN."));
- label->setWordWrap(true);
- layout2->addWidget(label);
- layout->addWidget(new QLabel(""));
- layout->addLayout(layout2);
-
- page->setLayout(layout);
-
- return page;
-}
-
-void MobileConnectionWizard::slotEnablePlanEditBox(const QString & text)
-{
- if (type() != NetworkManager::ConnectionSettings::Gsm) {
- return;
- }
- if (text == i18nc("Mobile Connection Wizard", "My plan is not listed...")) {
- userApn->clear();
- userApn->setEnabled(true);
- } else {
- if (mProvidersList->currentItem() != 0) {
- int i = mPlanComboBox->currentIndex();
- if (i>0) i=i-1; // Skiping the separator (i==1)
- QStringList mApns = mProviders->getApns(mProvidersList->currentItem()->text());
- userApn->setText(mApns.at(i));
- }
- userApn->setEnabled(false);
- }
-}
-
-/**********************************************************/
-/* Confirm page */
-/**********************************************************/
-
-QWizardPage * MobileConnectionWizard::createConfirmPage()
-{
- QWizardPage *page = new QWizardPage();
- page->setTitle(i18nc("Mobile Connection Wizard", "Confirm Mobile Broadband Settings"));
- QVBoxLayout *layout = new QVBoxLayout;
-
- QLabel *label = new QLabel(i18nc("Mobile Connection Wizard", "Your mobile broadband connection is configured with the following settings:"));
- label->setWordWrap(true);
- layout->addWidget(label);
-
- label = new QLabel('\n' + i18nc("Mobile Connection Wizard", "Your Provider:"));
- layout->addWidget(label);
- labelProvider = new QLabel();
- layout->addWidget(labelProvider);
-
- labelPlanLabel = new QLabel('\n' + i18nc("Mobile Connection Wizard", "Your Plan:"));
- layout->addWidget(labelPlanLabel);
- labelPlan = new QLabel();
- layout->addWidget(labelPlan);
- labelApn = new QLabel();
- labelApn->setEnabled(false);
- layout->addWidget(labelApn);
-
- page->setLayout(layout);
-
- return page;
-}
+++ /dev/null
-/*
-Copyright 2010-2011 Lamarque Souza <lamarque@kde.org>
-Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of
-the License or (at your option) version 3 or any later version
-accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_MOBILE_CONNECTION_WIZARD_H
-#define PLASMA_NM_MOBILE_CONNECTION_WIZARD_H
-
-#include <QWizardPage>
-#include <QListWidget>
-#include <QRadioButton>
-#include <QLabel>
-
-#include <KComboBox>
-#include <KLineEdit>
-
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/ConnectionSettings>
-
-#include "mobileproviders.h"
-#include "plasmanm_export.h"
-
-class PLASMA_NM_EXPORT MobileConnectionWizard : public QWizard
-{
-Q_OBJECT
-public:
- /*
- * Do not use NetworkManager::ConnectionSettings::Bluetooth here, use either NetworkManager::ConnectionSettings::Gsm
- * or NetworkManager::ConnectionSettings::Cdma.
- */
- explicit MobileConnectionWizard(NetworkManager::ConnectionSettings::ConnectionType connectionType = NetworkManager::ConnectionSettings::Unknown,
- QWidget * parent = 0);
- ~MobileConnectionWizard();
-
- /*
- * Returns the information to configure one connection from the last wizard run.
- * The format is:
- * for GSM connections: provider's name + QList of Gsm NetworkIds for that provider (can be an empty QList) + QMap with apn information
- * where apn information is: dial number + apn + apn name (optional) + username (optional) + password (optional) + QList of name servers (optional)
- *
- * for CDMA connections: provider's name + QMap with cdma information.
- * where cdma information is: name (optional) + username (optional) + password (optional) + list of sids (optional)
- */
- QVariantList args();
-
- NetworkManager::ConnectionSettings::ConnectionType type() const { return mType; }
- MobileProviders::ErrorCodes getError();
-
-private Q_SLOTS:
- void introDeviceAdded(const QString &uni);
- void introDeviceRemoved(const QString &uni);
- void introStatusChanged(NetworkManager::Status);
- void slotEnablePlanEditBox(const QString & text);
- void slotEnableProviderEdit(bool enable);
- void slotCheckProviderEdit();
- void slotCheckProviderList();
-
-private:
- QWizardPage * createIntroPage();
- QWizardPage * createCountryPage();
- QWizardPage * createProvidersPage();
- QWizardPage * createPlansPage();
- QWizardPage * createConfirmPage();
- void initializePage(int id);
- int nextId() const;
-
- MobileProviders * mProviders;
- QString getCountryFromLocale();
- QString country;
- QString provider;
- QString apn;
- NetworkManager::ConnectionSettings::ConnectionType mType;
- bool mInitialMethodType;
-
- // Intro page
- KComboBox * mDeviceComboBox;
- void introAddInitialDevices();
- void introRemoveAllDevices();
- void introAddDevice(const NetworkManager::Device::Ptr &device);
-
- // Country page
- QListWidget * mCountryList;
-
- // Providers page
- QListWidget * mProvidersList;
- QRadioButton * radioAutoProvider;
- QRadioButton * radioManualProvider;
- KLineEdit * lineEditProvider;
-
- // Plan page
- KComboBox * mPlanComboBox;
- KLineEdit * userApn;
-
- // Confirm page
- QLabel * labelProvider;
- QLabel * labelPlanLabel;
- QLabel * labelPlan;
- QLabel * labelApn;
-};
-#endif // PLASMA_NM_MOBILE_CONNECTION_WIZARD_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "settingwidget.h"
-
-SettingWidget::SettingWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- QWidget(parent, f),
- m_type(setting->name())
-{
-}
-
-SettingWidget::~SettingWidget()
-{
-}
-
-void SettingWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- Q_UNUSED(setting);
-}
-
-void SettingWidget::readSecrets()
-{
-}
-
-QString SettingWidget::type() const
-{
- return m_type;
-}
-
-void SettingWidget::slotWidgetChanged()
-{
- emit validChanged(isValid());
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef SETTING_WIDGET_H
-#define SETTING_WIDGET_H
-
-#include <QtGui/QWidget>
-#include <NetworkManagerQt/Setting>
-
-#include <KAcceleratorManager>
-
-#include "plasmanm_export.h"
-
-class PLASMA_NM_EXPORT SettingWidget : public QWidget
-{
- Q_OBJECT
-public:
- class EnumPasswordStorageType
- {
- public:
- enum PasswordStorageType {Store = 0, AlwaysAsk, NotRequired};
- };
-
- explicit SettingWidget(const NetworkManager::Setting::Ptr &setting = NetworkManager::Setting::Ptr(), QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~SettingWidget();
-
- virtual void loadConfig(const NetworkManager::Setting::Ptr &setting);
- virtual void readSecrets();
-
- virtual QVariantMap setting(bool agentOwned = false) const = 0;
- QString type() const;
-
- virtual bool isValid() const { return true; }
-
-protected slots:
- void slotWidgetChanged();
-
-signals:
- void validChanged(bool isValid);
-
-private:
- QString m_type;
-};
-
-#endif // SETTING_WIDGET_H
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "ssidcombobox.h"
-#include "uiutils.h"
-
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/WirelessDevice>
-
-#include <QtAlgorithms>
-
-#include <KIcon>
-#include <KLocalizedString>
-
-bool signalCompare(const NetworkManager::WirelessNetwork::Ptr & one, const NetworkManager::WirelessNetwork::Ptr & two)
-{
- return one->signalStrength() > two->signalStrength();
-}
-
-SsidComboBox::SsidComboBox(QWidget *parent) :
- KComboBox(parent), m_dirty(false)
-{
- setEditable(true);
- setInsertPolicy(QComboBox::NoInsert);
-
- connect(this, SIGNAL(editTextChanged(QString)), SLOT(editTextChanged(QString)));
- connect(this, SIGNAL(activated(int)), SLOT(currentIndexChanged(int)));
-}
-
-QString SsidComboBox::ssid() const
-{
- QString result;
- if (!m_dirty)
- result = itemData(currentIndex()).toString();
- else
- result = currentText();
-
- //qDebug() << "Result:" << currentIndex() << result;
-
- return result;
-}
-
-void SsidComboBox::editTextChanged(const QString &)
-{
- m_dirty = true;
- emit ssidChanged();
-}
-
-void SsidComboBox::currentIndexChanged(int)
-{
- m_dirty = false;
- setEditText(ssid());
- emit ssidChanged();
-}
-
-void SsidComboBox::init(const QString &ssid)
-{
- m_initialSsid = ssid;
-
- //qDebug() << "Initial ssid:" << m_initialSsid;
-
- QList<NetworkManager::WirelessNetwork::Ptr> networks;
-
- foreach(const NetworkManager::Device::Ptr & device, NetworkManager::networkInterfaces()) {
- if (device->type() == NetworkManager::Device::Wifi) {
- NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
-
- foreach (const NetworkManager::WirelessNetwork::Ptr & newNetwork, wifiDevice->networks()) {
- bool found = false;
- foreach (const NetworkManager::WirelessNetwork::Ptr & existingNetwork, networks) {
- if (newNetwork->ssid() == existingNetwork->ssid()) {
- if (newNetwork->signalStrength() > existingNetwork->signalStrength()) {
- networks.removeOne(existingNetwork);
- break;
- } else {
- found = true;
- break;
- }
- }
- }
- if (!found) {
- networks << newNetwork;
- }
- }
- }
- }
-
- qSort(networks.begin(), networks.end(), signalCompare);
- addSsidsToCombo(networks);
-
- int index = findData(m_initialSsid);
- if (index == -1) {
- insertItem(0, m_initialSsid, m_initialSsid);
- setCurrentIndex(0);
- } else {
- setCurrentIndex(index);
- }
- setEditText(m_initialSsid);
-}
-
-void SsidComboBox::addSsidsToCombo(const QList<NetworkManager::WirelessNetwork::Ptr> &networks)
-{
- QList<NetworkManager::WirelessDevice::Ptr> wifiDevices;
-
- foreach (const NetworkManager::Device::Ptr & dev, NetworkManager::networkInterfaces()) {
- if (dev->type() == NetworkManager::Device::Wifi) {
- wifiDevices << dev.objectCast<NetworkManager::WirelessDevice>();
- }
- }
-
- QString longestSsid;
- bool empty = true;
-
- foreach (const NetworkManager::WirelessNetwork::Ptr & network, networks) {
- NetworkManager::AccessPoint::Ptr accessPoint = network->referenceAccessPoint();
-
- if (!accessPoint) {
- continue;
- }
-
- foreach (const NetworkManager::WirelessDevice::Ptr & wifiDev, wifiDevices) {
- if (wifiDev->findNetwork(network->ssid()) == network) {
- if (!empty) {
- insertSeparator(count());
- }
- empty = false;
-
- if (network->ssid().length() > longestSsid.length()) {
- longestSsid = network->ssid();
- }
-
- NetworkManager::Utils::WirelessSecurityType security = NetworkManager::Utils::findBestWirelessSecurity(wifiDev->wirelessCapabilities(), true, (wifiDev->mode() == NetworkManager::WirelessDevice::Adhoc), accessPoint->capabilities(), accessPoint->wpaFlags(), accessPoint->rsnFlags());
- if (security != NetworkManager::Utils::Unknown && security != NetworkManager::Utils::None) {
- QString text = i18n("%1 (%2%)\nSecurity: %3\nFrequency: %4 Mhz", accessPoint->ssid(), network->signalStrength(), UiUtils::labelFromWirelessSecurity(security), accessPoint->frequency());
- addItem(KIcon("object-locked"), text, accessPoint->ssid());
- } else {
- QString text = i18n("%1 (%2%)\nSecurity: Insecure\nFrequency: %3 Mhz", accessPoint->ssid(), network->signalStrength(), accessPoint->frequency());
- addItem(KIcon("object-unlocked"), text, accessPoint->ssid());
- }
- }
- }
- }
-
- QFontMetrics metrics(font());
- setMinimumWidth(metrics.width(longestSsid));
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_SSIDCOMBOBOX_H
-#define PLASMA_NM_SSIDCOMBOBOX_H
-
-#include <KComboBox>
-
-#include <NetworkManagerQt/WirelessNetwork>
-
-#include "plasmanm_export.h"
-
-class PLASMA_NM_EXPORT SsidComboBox : public KComboBox
-{
- Q_OBJECT
-public:
- explicit SsidComboBox(QWidget *parent = 0);
-
- void init(const QString & ssid);
-
- QString ssid() const;
-
-Q_SIGNALS:
- void ssidChanged();
-
-private slots:
- void editTextChanged(const QString &);
- void currentIndexChanged(int);
-
-private:
- void addSsidsToCombo(const QList<NetworkManager::WirelessNetwork::Ptr> &networks);
- QString m_initialSsid;
- bool m_dirty;
-};
-
-#endif // PLASMA_NM_SSIDCOMBOBOX_H
+++ /dev/null
-/*
- Copyright 2013 Dan Vratil <dvratil@redhat.com>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "globalconfig.h"
-
-// #include <QDebug>
-
-static GlobalConfig *s_instance = 0;
-
-GlobalConfig* GlobalConfig::instance()
-{
- if (s_instance == 0) {
- s_instance = new GlobalConfig(0);
- }
-
- return s_instance;
-}
-
-// This is called from instance()
-GlobalConfig::GlobalConfig(void *dummy)
- : QObject()
- , m_airplaneMode(false)
- , m_unit(KBytes)
-{
- Q_UNUSED(dummy);
-}
-
-// This one is called when instantiated in QML
-GlobalConfig::GlobalConfig()
- : QObject()
- , m_airplaneMode(false)
- , m_unit(KBytes)
-{
- GlobalConfig *singleton = instance();
-
- connect(singleton, SIGNAL(airplaneModeEnabledChanged()),
- this, SIGNAL(airplaneModeEnabledChanged()));
- connect(singleton, SIGNAL(detailKeysChanged()),
- this, SIGNAL(detailKeysChanged()));
- connect(singleton, SIGNAL(networkSpeedUnitChanged()),
- this, SIGNAL(networkSpeedUnitChanged()));
-}
-
-GlobalConfig::~GlobalConfig()
-{
-}
-
-bool GlobalConfig::airplaneModeEnabled() const
-{
- if (this != s_instance) {
- return s_instance->airplaneModeEnabled();
- }
-
- return m_airplaneMode;
-}
-
-void GlobalConfig::setAirplaneModeEnabled(bool enabled)
-{
- if (this != s_instance) {
- s_instance->setAirplaneModeEnabled(enabled);
- return;
- }
-
- if (m_airplaneMode != enabled) {
- m_airplaneMode = enabled;
- Q_EMIT airplaneModeEnabledChanged();
- }
-}
-
-QStringList GlobalConfig::detailKeys() const
-{
- if (this != s_instance) {
- return s_instance->detailKeys();
- }
-
- return m_keys;
-}
-
-void GlobalConfig::setDetailKeys(const QStringList& keys)
-{
- if (this != s_instance) {
- s_instance->setDetailKeys(keys);
- return;
- }
-
- if (m_keys != keys) {
- m_keys = keys;
- Q_EMIT detailKeysChanged();
- }
-}
-
-GlobalConfig::NetworkSpeedUnit GlobalConfig::networkSpeedUnit() const
-{
- if (this != s_instance) {
- return s_instance->m_unit;
- }
- return m_unit;
-}
-
-void GlobalConfig::setNetworkSpeedUnit(GlobalConfig::NetworkSpeedUnit unit)
-{
- if (this != s_instance) {
- s_instance->setNetworkSpeedUnit(unit);
- return;
- }
-
- if (m_unit != unit) {
- m_unit = unit;
- Q_EMIT networkSpeedUnitChanged();
- }
-}
+++ /dev/null
-/*
- Copyright 2013 Dan Vratil <dvratil@redhat.com>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_GLOBAL_CONFIG_H
-#define PLASMA_NM_GLOBAL_CONFIG_H
-
-#include <QObject>
-#include <QStringList>
-
-#include "plasmanm_export.h"
-
-class PLASMA_NM_EXPORT GlobalConfig : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(bool airplaneModeEnabled
- READ airplaneModeEnabled
- WRITE setAirplaneModeEnabled
- NOTIFY airplaneModeEnabledChanged)
-Q_PROPERTY(QStringList detailKeys
- READ detailKeys
- WRITE setDetailKeys
- NOTIFY detailKeysChanged)
-Q_PROPERTY(NetworkSpeedUnit networkSpeedUnit
- READ networkSpeedUnit
- WRITE setNetworkSpeedUnit
- NOTIFY networkSpeedUnitChanged)
-public:
- enum NetworkSpeedUnit { KBytes, KBits };
- Q_ENUMS(NetworkSpeedUnit)
-
- explicit GlobalConfig();
- virtual ~GlobalConfig();
-
-public Q_SLOTS:
- bool airplaneModeEnabled() const;
- void setAirplaneModeEnabled(bool enabled);
-
- QStringList detailKeys() const;
- void setDetailKeys(const QStringList& keys);
-
- NetworkSpeedUnit networkSpeedUnit() const;
- void setNetworkSpeedUnit(NetworkSpeedUnit unit);
-
-Q_SIGNALS:
- void airplaneModeEnabledChanged();
- void detailKeysChanged();
- void networkSpeedUnitChanged();
-
-private:
- explicit GlobalConfig(void *dummy);
- GlobalConfig * instance();
-
- bool m_airplaneMode;
- QStringList m_keys;
- NetworkSpeedUnit m_unit;
-};
-
-#endif // PLASMA_NM_GLOBAL_CONFIG_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "handler.h"
-#include "connectiondetaileditor.h"
-#include "uiutils.h"
-
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/AccessPoint>
-#include <NetworkManagerQt/WiredDevice>
-#include <NetworkManagerQt/WirelessDevice>
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/Setting>
-#include <NetworkManagerQt/Utils>
-#include <NetworkManagerQt/ConnectionSettings>
-#include <NetworkManagerQt/WiredSetting>
-#include <NetworkManagerQt/WirelessSetting>
-#include <NetworkManagerQt/ActiveConnection>
-
-#include <QInputDialog>
-#include <QDBusError>
-
-#include <KNotification>
-#include <KUser>
-#include <KIcon>
-#include <KDebug>
-#include <KProcess>
-#include <KService>
-#include <KServiceTypeTrader>
-#include <KWindowSystem>
-#include <KWallet/Wallet>
-
-Handler::Handler(QObject* parent)
- : QObject(parent)
- , m_tmpBluetoothEnabled(isBtEnabled())
- , m_tmpWimaxEnabled(NetworkManager::isWimaxEnabled())
- , m_tmpWirelessEnabled(NetworkManager::isWirelessEnabled())
- , m_tmpWwanEnabled(NetworkManager::isWwanEnabled())
- , m_agentIface(QLatin1String("org.kde.kded"), QLatin1String("/modules/networkmanagement"),
- QLatin1String("org.kde.plasmanetworkmanagement"))
-{
- initKdedModule();
- QDBusConnection::sessionBus().connect(m_agentIface.service(), m_agentIface.path(), m_agentIface.interface(), QLatin1String("registered"),
- this, SLOT(initKdedModule()));
-}
-
-Handler::~Handler()
-{
-}
-
-void Handler::activateConnection(const QString& connection, const QString& device, const QString& specificObject)
-{
- NetworkManager::Connection::Ptr con = NetworkManager::findConnection(connection);
-
- if (!con) {
- kWarning() << "Not possible to activate this connection";
- return;
- }
-
- if (con->settings()->connectionType() == NetworkManager::ConnectionSettings::Vpn) {
- NetworkManager::VpnSetting::Ptr vpnSetting = con->settings()->setting(NetworkManager::Setting::Vpn).staticCast<NetworkManager::VpnSetting>();
- if (vpnSetting) {
- kWarning() << "Checking VPN" << con->name() << "type:" << vpnSetting->serviceType();
- // get the list of supported VPN service types
- const KService::List services = KServiceTypeTrader::self()->query("PlasmaNetworkManagement/VpnUiPlugin",
- QString::fromLatin1("[X-NetworkManager-Services]=='%1'").arg(vpnSetting->serviceType()));
- if (services.isEmpty()) {
- kWarning() << "VPN" << vpnSetting->serviceType() << "not found, skipping";
- KNotification *notification = new KNotification("MissingVpnPlugin", KNotification::CloseOnTimeout, this);
- notification->setComponentData(KComponentData("networkmanagement"));
- notification->setTitle(con->name());
- notification->setText(i18n("Missing VPN plugin"));
- notification->setPixmap(KIcon("dialog-warning").pixmap(64, 64));
- notification->sendEvent();
- return;
- }
- }
- }
-
- QDBusPendingReply<QDBusObjectPath> reply = NetworkManager::activateConnection(connection, device, specificObject);
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
- watcher->setProperty("action", Handler::ActivateConnection);
- watcher->setProperty("connection", con->name());
- connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(replyFinished(QDBusPendingCallWatcher*)));
-}
-
-void Handler::addAndActivateConnection(const QString& device, const QString& specificObject, const QString& password)
-{
- NetworkManager::AccessPoint::Ptr ap;
- NetworkManager::WirelessDevice::Ptr wifiDev;
- foreach (const NetworkManager::Device::Ptr & dev, NetworkManager::networkInterfaces()) {
- if (dev->type() == NetworkManager::Device::Wifi) {
- wifiDev = dev.objectCast<NetworkManager::WirelessDevice>();
- ap = wifiDev->findAccessPoint(specificObject);
- if (ap) {
- break;
- }
- }
- }
-
- if (!ap) {
- return;
- }
-
- NetworkManager::ConnectionSettings::Ptr settings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless));
- settings->setId(ap->ssid());
- settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
- settings->setAutoconnect(true);
- settings->addToPermissions(KUser().loginName(), QString());
-
- NetworkManager::WirelessSetting::Ptr wifiSetting = settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
- wifiSetting->setInitialized(true);
- wifiSetting = settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
- wifiSetting->setSsid(ap->ssid().toUtf8());
- if (ap->mode() == NetworkManager::AccessPoint::Adhoc) {
- wifiSetting->setMode(NetworkManager::WirelessSetting::Adhoc);
- }
- NetworkManager::WirelessSecuritySetting::Ptr wifiSecurity = settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
-
- NetworkManager::Utils::WirelessSecurityType securityType = NetworkManager::Utils::findBestWirelessSecurity(wifiDev->wirelessCapabilities(), true, (ap->mode() == NetworkManager::AccessPoint::Adhoc), ap->capabilities(), ap->wpaFlags(), ap->rsnFlags());
-
- if (securityType != NetworkManager::Utils::None) {
- wifiSecurity->setInitialized(true);
- wifiSetting->setSecurity("802-11-wireless-security");
- }
-
- if (securityType == NetworkManager::Utils::Leap ||
- securityType == NetworkManager::Utils::DynamicWep ||
- securityType == NetworkManager::Utils::Wpa2Eap ||
- securityType == NetworkManager::Utils::WpaEap) {
- if (securityType == NetworkManager::Utils::DynamicWep || securityType == NetworkManager::Utils::Leap) {
- wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::Ieee8021x);
- if (securityType == NetworkManager::Utils::Leap) {
- wifiSecurity->setAuthAlg(NetworkManager::WirelessSecuritySetting::Leap);
- }
- } else {
- wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
- }
- m_tmpConnectionUuid = settings->uuid();
- m_tmpDevicePath = device;
- m_tmpSpecificPath = specificObject;
-
- QPointer<ConnectionDetailEditor> editor = new ConnectionDetailEditor(settings, 0, 0, true);
- editor->show();
- KWindowSystem::setState(editor->winId(), NET::KeepAbove);
- KWindowSystem::forceActiveWindow(editor->winId());
- connect(editor, SIGNAL(accepted()), SLOT(editDialogAccepted()));
- } else {
- if (securityType == NetworkManager::Utils::StaticWep) {
- wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::Wep);
- wifiSecurity->setWepKey0(password);
- if (KWallet::Wallet::isEnabled()) {
- wifiSecurity->setWepKeyFlags(NetworkManager::Setting::AgentOwned);
- }
- } else {
- if (ap->mode() == NetworkManager::AccessPoint::Adhoc) {
- wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaNone);
- } else {
- wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
- }
- wifiSecurity->setPsk(password);
- if (KWallet::Wallet::isEnabled()) {
- wifiSecurity->setPskFlags(NetworkManager::Setting::AgentOwned);
- }
- }
- QDBusPendingReply<QDBusObjectPath> reply = NetworkManager::addAndActivateConnection(settings->toMap(), device, specificObject);
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
- watcher->setProperty("action", Handler::AddAndActivateConnection);
- watcher->setProperty("connection", settings->name());
- connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(replyFinished(QDBusPendingCallWatcher*)));
- }
-
- settings.clear();
-}
-
-void Handler::deactivateConnection(const QString& connection, const QString& device)
-{
- NetworkManager::Connection::Ptr con = NetworkManager::findConnection(connection);
-
- if (!con) {
- kWarning() << "Not possible to deactivate this connection";
- return;
- }
-
- foreach (const NetworkManager::ActiveConnection::Ptr & active, NetworkManager::activeConnections()) {
- if (active->uuid() == con->uuid() && ((!active->devices().isEmpty() && active->devices().first() == device) ||
- active->vpn())) {
- if (active->vpn()) {
- NetworkManager::deactivateConnection(active->path());
- } else {
- if (active->devices().isEmpty()) {
- NetworkManager::deactivateConnection(connection);
- }
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(active->devices().first());
- if (device) {
- device->disconnectInterface();
- }
- }
- }
- }
-}
-
-void Handler::disconnectAll()
-{
- foreach (const NetworkManager::Device::Ptr & device, NetworkManager::networkInterfaces()) {
- device->disconnectInterface();
- }
-}
-
-void Handler::enableAirplaneMode(bool enable)
-{
- if (enable) {
- m_tmpBluetoothEnabled = isBtEnabled();
- m_tmpWimaxEnabled = NetworkManager::isWimaxEnabled();
- m_tmpWirelessEnabled = NetworkManager::isWirelessEnabled();
- m_tmpWwanEnabled = NetworkManager::isWwanEnabled();
- enableBt(false);
- enableWimax(false);
- enableWireless(false);
- enableWwan(false);
- } else {
- if (m_tmpBluetoothEnabled) {
- enableBt(true);
- }
- if (m_tmpWimaxEnabled) {
- enableWimax(true);
- }
- if (m_tmpWirelessEnabled) {
- enableWireless(true);
- }
- if (m_tmpWwanEnabled) {
- enableWwan(true);
- }
- }
-}
-
-void Handler::enableNetworking(bool enable)
-{
- NetworkManager::setNetworkingEnabled(enable);
-}
-
-void Handler::enableWireless(bool enable)
-{
- NetworkManager::setWirelessEnabled(enable);
-}
-
-void Handler::enableWimax(bool enable)
-{
- NetworkManager::setWimaxEnabled(enable);
-}
-
-void Handler::enableWwan(bool enable)
-{
- NetworkManager::setWwanEnabled(enable);
-}
-
-bool Handler::isBtEnabled()
-{
- qDBusRegisterMetaType< QMap<QDBusObjectPath, NMVariantMapMap > >();
- bool result = false;
-
- QDBusInterface managerIface("org.bluez", "/", "org.freedesktop.DBus.ObjectManager", QDBusConnection::systemBus(), this);
- QDBusReply<QMap<QDBusObjectPath, NMVariantMapMap> > reply = managerIface.call("GetManagedObjects");
- if (reply.isValid()) {
- foreach(const QDBusObjectPath &path, reply.value().keys()) {
- const QString objPath = path.path();
- //qDebug() << "inspecting path" << objPath;
- const QStringList interfaces = reply.value().value(path).keys();
- //qDebug() << "interfaces:" << interfaces;
- if (interfaces.contains("org.bluez.Adapter1")) {
- QDBusInterface adapterIface("org.bluez", objPath, "org.bluez.Adapter1", QDBusConnection::systemBus(), this);
- const bool adapterEnabled = adapterIface.property("Powered").toBool();
- //qDebug() << "Adapter" << objPath << "enabled:" << adapterEnabled;
- result |= adapterEnabled;
- }
- }
- } else {
- qDebug() << "Failed to enumerate BT adapters";
- }
-
- return result;
-}
-
-void Handler::enableBt(bool enable)
-{
- QDBusInterface managerIface("org.bluez", "/", "org.freedesktop.DBus.ObjectManager", QDBusConnection::systemBus(), this);
- QDBusReply<QMap<QDBusObjectPath, NMVariantMapMap> > reply = managerIface.call("GetManagedObjects");
- if (reply.isValid()) {
- foreach(const QDBusObjectPath &path, reply.value().keys()) {
- const QString objPath = path.path();
- //qDebug() << "inspecting path" << objPath;
- const QStringList interfaces = reply.value().value(path).keys();
- //qDebug() << "interfaces:" << interfaces;
- if (interfaces.contains("org.bluez.Adapter1")) {
- QDBusInterface adapterIface("org.bluez", objPath, "org.bluez.Adapter1", QDBusConnection::systemBus(), this);
- //qDebug() << "Enabling adapter:" << objPath << (enable && m_btEnabled);
- adapterIface.setProperty("Powered", enable);
- }
- }
- } else {
- qDebug() << "Failed to enumerate BT adapters";
- }
-}
-
-void Handler::editConnection(const QString& uuid)
-{
- QStringList args;
- args << uuid;
- KProcess::startDetached("kde-nm-connection-editor", args);
-}
-
-void Handler::removeConnection(const QString& connection)
-{
- NetworkManager::Connection::Ptr con = NetworkManager::findConnection(connection);
-
- if (!con || con->uuid().isEmpty()) {
- kWarning() << "Not possible to remove connection " << connection;
- return;
- }
-
- foreach (const NetworkManager::Connection::Ptr &masterConnection, NetworkManager::listConnections()) {
- NetworkManager::ConnectionSettings::Ptr settings = masterConnection->settings();
- if (settings->master() == con->uuid()) {
- masterConnection->remove();
- }
- }
-
- con->remove();
-}
-
-void Handler::openEditor()
-{
- KProcess::startDetached("kde-nm-connection-editor");
-}
-
-void Handler::requestScan()
-{
- foreach (NetworkManager::Device::Ptr device, NetworkManager::networkInterfaces()) {
- if (device->type() == NetworkManager::Device::Wifi) {
- NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
- if (wifiDevice) {
- QDBusPendingReply<> reply = wifiDevice->requestScan();
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
- watcher->setProperty("action", Handler::RequestScan);
- connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(replyFinished(QDBusPendingCallWatcher*)));
- }
- }
- }
-}
-
-void Handler::editDialogAccepted()
-{
- NetworkManager::Connection::Ptr newConnection = NetworkManager::findConnectionByUuid(m_tmpConnectionUuid);
- if (newConnection) {
- activateConnection(newConnection->path(), m_tmpDevicePath, m_tmpSpecificPath);
- }
-}
-
-void Handler::initKdedModule()
-{
- m_agentIface.call(QLatin1String("init"));
-}
-
-void Handler::replyFinished(QDBusPendingCallWatcher * watcher)
-{
- QDBusPendingReply<> reply = *watcher;
- if (reply.isError() || !reply.isValid()) {
- KNotification *notification = 0;
- QString error = reply.error().message();
- Handler::HandlerAction action = (Handler::HandlerAction)watcher->property("action").toUInt();
- switch (action) {
- case Handler::ActivateConnection:
- notification = new KNotification("FailedToActivateConnection", KNotification::CloseOnTimeout, this);
- notification->setComponentData(KComponentData("networkmanagement"));
- notification->setTitle(i18n("Failed to activate %1", watcher->property("connection").toString()));
- break;
- case Handler::AddAndActivateConnection:
- notification = new KNotification("FailedToAddConnection", KNotification::CloseOnTimeout, this);
- notification->setComponentData(KComponentData("networkmanagement"));
- notification->setTitle(i18n("Failed to add %1", watcher->property("connection").toString()));
- break;
- case Handler::RequestScan:
- notification = new KNotification("FailedToRequestScan", KNotification::CloseOnTimeout, this);
- notification->setComponentData(KComponentData("networkmanagement"));
- notification->setTitle(i18n("Failed to request scan"));
- break;
- default:
- break;
- }
-
- if (notification) {
- notification->setText(error);
- notification->setPixmap(KIcon("dialog-warning").pixmap(64, 64));
- notification->sendEvent();
- }
- }
-
- watcher->deleteLater();
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_HANDLER_H
-#define PLASMA_NM_HANDLER_H
-
-#include <QDBusInterface>
-
-#include <NetworkManagerQt/Connection>
-
-#include "plasmanm_export.h"
-#include <config.h>
-
-#if !WITH_MODEMMANAGER_SUPPORT
-typedef QMap<QDBusObjectPath, NMVariantMapMap> NMDBusObjectVariantMapMap;
-Q_DECLARE_METATYPE(NMDBusObjectVariantMapMap)
-#endif
-
-class PLASMA_NM_EXPORT Handler : public QObject
-{
-Q_OBJECT
-
-public:
- enum HandlerAction {
- ActivateConnection,
- AddAndActivateConnection,
- RequestScan
- };
-
- explicit Handler(QObject* parent = 0);
- virtual ~Handler();
-
-public Q_SLOTS:
- /**
- * Activates given connection
- * @connection - d-bus path of the connection you want to activate
- * @device - d-bus path of the device where the connection should be activated
- * @specificParameter - d-bus path of the specific object you want to use for this activation, i.e access point
- */
- void activateConnection(const QString & connection, const QString & device, const QString & specificParameter);
- /**
- * Adds and activates a new wireless connection
- * @device - d-bus path of the wireless device where the connection should be activated
- * @specificParameter - d-bus path of the accesspoint you want to connect to
- * @password - pre-filled password which should be used for the new wireless connection
- * @autoConnect - boolean value whether this connection should be activated automatically when it's available
- *
- * Works automatically for wireless connections with WEP/WPA security, for wireless connections with WPA/WPA
- * it will open the connection editor for advanced configuration.
- * */
- void addAndActivateConnection(const QString & device, const QString & specificParameter, const QString & password = QString());
- /**
- * Deactivates given connection
- * @connection - d-bus path of the connection you want to deactivate
- * @device - d-bus path of the connection where the connection is activated
- */
- void deactivateConnection(const QString & connection, const QString & device);
- /**
- * Disconnects all connections
- */
- void disconnectAll();
- void enableAirplaneMode(bool enable);
- void enableBt(bool enable);
- void enableNetworking(bool enable);
- void enableWireless(bool enable);
- void enableWimax(bool enable);
- void enableWwan(bool enable);
-
- /**
- * Opens connection editor for given connection
- * @uuid - uuid of the connection you want to edit
- */
- void editConnection(const QString & uuid);
-
- /**
- * Removes given connection
- * @connection - d-bus path of the connection you want to edit
- */
- void removeConnection(const QString & connection);
- void openEditor();
- void requestScan();
-
-private Q_SLOTS:
- void editDialogAccepted();
- void initKdedModule();
- void replyFinished(QDBusPendingCallWatcher * watcher);
-
-private:
- bool m_tmpBluetoothEnabled;
- bool m_tmpWimaxEnabled;
- bool m_tmpWirelessEnabled;
- bool m_tmpWwanEnabled;
- QString m_tmpConnectionUuid;
- QString m_tmpDevicePath;
- QString m_tmpSpecificPath;
-
- bool isBtEnabled();
- QDBusInterface m_agentIface;
-};
-
-#endif // PLASMA_NM_HANDLER_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "appletproxymodel.h"
-#include "networkmodel.h"
-
-AppletProxyModel::SortedConnectionType AppletProxyModel::connectionTypeToSortedType(NetworkManager::ConnectionSettings::ConnectionType type)
-{
- switch (type) {
- case NetworkManager::ConnectionSettings::Unknown:
- return AppletProxyModel::AppletProxyModel::Unknown;
- break;
- case NetworkManager::ConnectionSettings::Adsl:
- return AppletProxyModel::AppletProxyModel::Adsl;
- break;
- case NetworkManager::ConnectionSettings::Bluetooth:
- return AppletProxyModel::Bluetooth;
- break;
- case NetworkManager::ConnectionSettings::Bond:
- return AppletProxyModel::Bond;
- break;
- case NetworkManager::ConnectionSettings::Bridge:
- return AppletProxyModel::Bridge;
- break;
- case NetworkManager::ConnectionSettings::Cdma:
- return AppletProxyModel::Cdma;
- break;
- case NetworkManager::ConnectionSettings::Gsm:
- return AppletProxyModel::Gsm;
- break;
- case NetworkManager::ConnectionSettings::Infiniband:
- return AppletProxyModel::Infiniband;
- break;
- case NetworkManager::ConnectionSettings::OLPCMesh:
- return AppletProxyModel::OLPCMesh;
- break;
- case NetworkManager::ConnectionSettings::Pppoe:
- return AppletProxyModel::Pppoe;
- break;
- case NetworkManager::ConnectionSettings::Vlan:
- return AppletProxyModel::Vlan;
- break;
- case NetworkManager::ConnectionSettings::Vpn:
- return AppletProxyModel::Vpn;
- break;
- case NetworkManager::ConnectionSettings::Wimax:
- return AppletProxyModel::Wimax;
- break;
- case NetworkManager::ConnectionSettings::Wired:
- return AppletProxyModel::Wired;
- break;
- case NetworkManager::ConnectionSettings::Wireless:
- return AppletProxyModel::Wireless;
- break;
- default:
- return AppletProxyModel::Unknown;
- break;
- }
-}
-
-AppletProxyModel::AppletProxyModel(QObject* parent)
- : QSortFilterProxyModel(parent)
-{
- setDynamicSortFilter(true);
- sort(0, Qt::DescendingOrder);
-}
-
-AppletProxyModel::~AppletProxyModel()
-{
-}
-
-bool AppletProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
-{
- const QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
-
- // slaves are always filtered-out
- const bool isSlave = sourceModel()->data(index, NetworkModel::SlaveRole).toBool();
- if (isSlave) {
- return false;
- }
-
-#if NM_CHECK_VERSION(0, 9, 10)
- const NetworkManager::ConnectionSettings::ConnectionType type = (NetworkManager::ConnectionSettings::ConnectionType) sourceModel()->data(index, NetworkModel::TypeRole).toUInt();
- if (type < NetworkManager::ConnectionSettings::Adsl || type > NetworkManager::ConnectionSettings::Wireless) {
- return false;
- }
-#endif
-
- NetworkModelItem::ItemType itemType = (NetworkModelItem::ItemType)sourceModel()->data(index, NetworkModel::ItemTypeRole).toUInt();
-
- if (itemType == NetworkModelItem::AvailableConnection ||
- itemType == NetworkModelItem::AvailableAccessPoint ||
- itemType == NetworkModelItem::AvailableNsp) {
- return true;
- }
-
- return false;
-}
-
-bool AppletProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const
-{
- const bool leftAvailable = (NetworkModelItem::ItemType)sourceModel()->data(left, NetworkModel::ItemTypeRole).toUInt() != NetworkModelItem::UnavailableConnection;
- const bool leftConnected = sourceModel()->data(left, NetworkModel::ConnectionStateRole).toUInt() == NetworkManager::ActiveConnection::Activated;
- const int leftConnectionState = sourceModel()->data(left, NetworkModel::ConnectionStateRole).toUInt();
- const QString leftName = sourceModel()->data(left, NetworkModel::NameRole).toString();
- const SortedConnectionType leftType = connectionTypeToSortedType((NetworkManager::ConnectionSettings::ConnectionType) sourceModel()->data(left, NetworkModel::TypeRole).toUInt());
- const QString leftUuid = sourceModel()->data(left, NetworkModel::UuidRole).toString();
- const int leftSignal = sourceModel()->data(left, NetworkModel::SignalRole).toInt();
- const QDateTime leftDate = sourceModel()->data(left, NetworkModel::TimeStampRole).toDateTime();
-
- const bool rightAvailable = (NetworkModelItem::ItemType)sourceModel()->data(right, NetworkModel::ItemTypeRole).toUInt() != NetworkModelItem::UnavailableConnection;
- const bool rightConnected = sourceModel()->data(right, NetworkModel::ConnectionStateRole).toUInt() == NetworkManager::ActiveConnection::Activated;
- const int rightConnectionState = sourceModel()->data(right, NetworkModel::ConnectionStateRole).toUInt();
- const QString rightName = sourceModel()->data(right, NetworkModel::NameRole).toString();
- const SortedConnectionType rightType = connectionTypeToSortedType((NetworkManager::ConnectionSettings::ConnectionType) sourceModel()->data(right, NetworkModel::TypeRole).toUInt());
- const QString rightUuid = sourceModel()->data(right, NetworkModel::UuidRole).toString();
- const int rightSignal = sourceModel()->data(right, NetworkModel::SignalRole).toInt();
- const QDateTime rightDate = sourceModel()->data(right, NetworkModel::TimeStampRole).toDateTime();
-
- if (leftAvailable < rightAvailable) {
- return true;
- } else if (leftAvailable > rightAvailable) {
- return false;
- }
-
- if (leftConnected < rightConnected) {
- return true;
- } else if (leftConnected > rightConnected) {
- return false;
- }
-
- if (leftConnectionState > rightConnectionState) {
- return true;
- } else if (leftConnectionState < rightConnectionState) {
- return false;
- }
-
- if (leftUuid.isEmpty() && !rightUuid.isEmpty()) {
- return true;
- } else if (!leftUuid.isEmpty() && rightUuid.isEmpty()) {
- return false;
- }
-
- if (leftType < rightType) {
- return false;
- } else if (leftType > rightType) {
- return true;
- }
-
- if (leftDate > rightDate) {
- return false;
- } else if (leftDate < rightDate) {
- return true;
- }
-
- if (leftSignal < rightSignal) {
- return true;
- } else if (leftSignal > rightSignal) {
- return false;
- }
-
- if (QString::localeAwareCompare(leftName, rightName) > 0) {
- return true;
- } else {
- return false;
- }
-}
+++ /dev/null
-/*
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_APPLET_PROXY_MODEL_H
-#define PLASMA_NM_APPLET_PROXY_MODEL_H
-
-#include <QSortFilterProxyModel>
-
-#include "networkmodelitem.h"
-
-class PLASMA_NM_EXPORT AppletProxyModel : public QSortFilterProxyModel
-{
-Q_OBJECT
-Q_PROPERTY(QAbstractItemModel * sourceModel READ sourceModel WRITE setSourceModel)
-public:
- enum SortedConnectionType {Wired, Wireless, Wimax, Gsm, Cdma, Pppoe, Adsl, Infiniband, OLPCMesh, Bluetooth, Vpn, Vlan, Bridge, Bond, Unknown };
-
- static SortedConnectionType connectionTypeToSortedType(NetworkManager::ConnectionSettings::ConnectionType type);
-
- explicit AppletProxyModel(QObject* parent = 0);
- virtual ~AppletProxyModel();
-
-protected:
- bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
- bool lessThan(const QModelIndex& left, const QModelIndex& right) const;
-
-};
-
-
-#endif // PLASMA_NM_APPLET_PROXY_MODEL_H
+++ /dev/null
-/*
- Copyright 2014 Jan Grulich <jgrulich@redhat.com>
- Copyright 2014 Lukáš Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "editoridentitymodel.h"
-#include "networkmodel.h"
-#include "networkmodelitem.h"
-#include "uiutils.h"
-
-#include <QIcon>
-#include <QFont>
-
-#include <KLocalizedString>
-#include <KIcon>
-
-EditorIdentityModel::EditorIdentityModel(QObject* parent)
- : QIdentityProxyModel(parent)
-{
- NetworkModel * baseModel = new NetworkModel(this);
- setSourceModel(baseModel);
-}
-
-EditorIdentityModel::~EditorIdentityModel()
-{
-}
-
-Qt::ItemFlags EditorIdentityModel::flags(const QModelIndex& index) const
-{
- const QModelIndex mappedProxyIndex = index.sibling(index.row(), 0);
- return QIdentityProxyModel::flags(mappedProxyIndex) | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
-}
-
-int EditorIdentityModel::columnCount(const QModelIndex& parent) const
-{
- Q_UNUSED(parent);
-
- return 2;
-}
-
-QVariant EditorIdentityModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
- switch (section) {
- case 0:
- return i18n("Connection name");
- case 1:
- return i18n("Last used");
- }
- }
-
- return QIdentityProxyModel::headerData(section, orientation, role);
-}
-
-QVariant EditorIdentityModel::data(const QModelIndex& index, int role) const
-{
- const QModelIndex sourceIndex = sourceModel()->index(index.row(), 0);
- const QString connectionName = sourceModel()->data(sourceIndex, NetworkModel::NameRole).toString();
- const QString lastUsed = sourceModel()->data(sourceIndex, NetworkModel::LastUsedDateOnlyRole).toString();
- const bool isActivated = (NetworkManager::ActiveConnection::State) sourceModel()->data(sourceIndex, NetworkModel::ConnectionStateRole).toInt()
- == NetworkManager::ActiveConnection::Activated;
- const bool isActivating = (NetworkManager::ActiveConnection::State) sourceModel()->data(sourceIndex, NetworkModel::ConnectionStateRole).toInt()
- == NetworkManager::ActiveConnection::Activating;
- NetworkManager::ConnectionSettings::ConnectionType type = static_cast<NetworkManager::ConnectionSettings::ConnectionType>(sourceModel()->data(sourceIndex, NetworkModel::TypeRole).toInt());
- QString tooltip;
- QString iconName = UiUtils::iconAndTitleForConnectionSettingsType(type, tooltip);
- const int column = index.column();
-
- if (role == Qt::DisplayRole) {
- switch (column) {
- case 0:
- if (type == NetworkManager::ConnectionSettings::Infiniband ||
- type == NetworkManager::ConnectionSettings::Bond ||
- type == NetworkManager::ConnectionSettings::Bridge ||
- type == NetworkManager::ConnectionSettings::Vlan) {
- return QString(connectionName + " (" + NetworkManager::ConnectionSettings::typeAsString(type) + ")");
- }
- return connectionName;
- case 1:
- return lastUsed;
- }
- } else if (role == Qt::DecorationRole) {
- if (column == 0) {
- return KIcon(iconName);
- }
- } else if (role == Qt::ToolTipRole) {
- if (column == 0)
- return tooltip;
- } else if (role == Qt::FontRole) {
- if (column == 0 && isActivated) {
- QFont f;
- f.setBold(true);
- return f;
- } else if (column == 0 && isActivating) {
- QFont f;
- f.setItalic(true);
- return f;
- }
- } else {
- return sourceModel()->data(index, role);
- }
-
- return QVariant();
-}
-
-QModelIndex EditorIdentityModel::index(int row, int column, const QModelIndex& parent) const
-{
- Q_UNUSED(parent);
- return createIndex(row, column);
-}
-
-QModelIndex EditorIdentityModel::mapToSource(const QModelIndex& proxyIndex) const
-{
- if (proxyIndex.column() > 0) {
- return QModelIndex();
- }
-
- return QIdentityProxyModel::mapToSource(proxyIndex);
-}
+++ /dev/null
-/*
- Copyright 2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_EDITOR_IDENTITY_MODEL_H
-#define PLASMA_NM_EDITOR_IDENTITY_MODEL_H
-
-#include <QIdentityProxyModel>
-#include <QModelIndex>
-
-#include "plasmanm_export.h"
-
-class PLASMA_NM_EXPORT EditorIdentityModel : public QIdentityProxyModel
-{
-Q_OBJECT
-
-public:
- explicit EditorIdentityModel(QObject* parent = 0);
- virtual ~EditorIdentityModel();
-
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- Qt::ItemFlags flags(const QModelIndex &index) const;
-
- int columnCount(const QModelIndex& parent = QModelIndex()) const;
- QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
-
- QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
-};
-
-#endif // PLASMA_NM_EDITOR_IDENTITY_MODEL_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "editorproxymodel.h"
-#include "networkmodelitem.h"
-#include "networkmodel.h"
-
-EditorProxyModel::EditorProxyModel(QObject* parent)
- : QSortFilterProxyModel(parent)
-{
- setDynamicSortFilter(true);
- setSortCaseSensitivity(Qt::CaseInsensitive);
- setSortLocaleAware(true);
- sort(0, Qt::DescendingOrder);
-}
-
-EditorProxyModel::~EditorProxyModel()
-{
-}
-
-bool EditorProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
-{
- const QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
-
- // slaves are always filtered-out
- const bool isSlave = sourceModel()->data(index, NetworkModel::SlaveRole).toBool();
- const bool isDuplicate = sourceModel()->data(index, NetworkModel::DuplicateRole).toBool();
-
- if (isSlave || isDuplicate) {
- return false;
- }
-
-#if NM_CHECK_VERSION(0, 9, 10)
- const NetworkManager::ConnectionSettings::ConnectionType type = (NetworkManager::ConnectionSettings::ConnectionType) sourceModel()->data(index, NetworkModel::TypeRole).toUInt();
- if (type < NetworkManager::ConnectionSettings::Adsl || type > NetworkManager::ConnectionSettings::Wireless) {
- return false;
- }
-#endif
-
- NetworkModelItem::ItemType itemType = (NetworkModelItem::ItemType)sourceModel()->data(index, NetworkModel::ItemTypeRole).toUInt();
- if (itemType == NetworkModelItem::AvailableAccessPoint || itemType == NetworkModelItem::AvailableNsp) {
- return false;
- }
-
- const QString pattern = filterRegExp().pattern();
- if (!pattern.isEmpty()) { // filtering on data (connection name), wildcard-only
- const QString data = sourceModel()->data(index, Qt::DisplayRole).toString();
- //qDebug() << "Filtering " << data << "with pattern" << pattern;
- return data.contains(pattern, Qt::CaseInsensitive);
- }
-
- return true;
-}
-
-bool EditorProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
-{
- if (sourceModel()) { // special sorting case, only for editor
- if (sortColumn() == 1) {
- const QDateTime leftDate = sourceModel()->data(left, NetworkModel::TimeStampRole).toDateTime();
- const QDateTime rightDate = sourceModel()->data(right, NetworkModel::TimeStampRole).toDateTime();
- return leftDate < rightDate;
- }
- }
-
- return QSortFilterProxyModel::lessThan(left, right);
-}
+++ /dev/null
-/*
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_EDITOR_PROXY_MODEL_H
-#define PLASMA_NM_EDITOR_PROXY_MODEL_H
-
-#include <QSortFilterProxyModel>
-
-#include "plasmanm_export.h"
-
-class PLASMA_NM_EXPORT EditorProxyModel : public QSortFilterProxyModel
-{
-Q_OBJECT
-Q_PROPERTY(QAbstractItemModel * sourceModel READ sourceModel WRITE setSourceModel)
-public:
- explicit EditorProxyModel(QObject* parent = 0);
- virtual ~EditorProxyModel();
-
-protected:
- bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
- bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
-};
-
-
-#endif // PLASMA_NM_EDITOR_PROXY_MODEL_H
+++ /dev/null
-/*
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "networkitemslist.h"
-#include "networkmodelitem.h"
-
-NetworkItemsList::NetworkItemsList(QObject* parent)
- : QObject(parent)
-{
-}
-
-NetworkItemsList::~NetworkItemsList()
-{
- qDeleteAll(m_items);
-}
-
-bool NetworkItemsList::contains(const NetworkItemsList::FilterType type, const QString& parameter) const
-{
- foreach (NetworkModelItem * item, m_items) {
- switch (type) {
- case NetworkItemsList::ActiveConnection:
- if (item->activeConnectionPath() == parameter) {
- return true;
- }
- break;
- case NetworkItemsList::Connection:
- if (item->connectionPath() == parameter) {
- return true;
- }
- break;
- case NetworkItemsList::Device:
- if (item->devicePath() == parameter) {
- return true;
- }
- break;
- case NetworkItemsList::Name:
- if (item->name() == parameter) {
- return true;
- }
- break;
- case NetworkItemsList::Nsp:
- if (item->nsp() == parameter) {
- return true;
- }
- break;
- case NetworkItemsList::Ssid:
- if (item->ssid() == parameter) {
- return true;
- }
- break;
- case NetworkItemsList::Uuid:
- if (item->uuid() == parameter) {
- return true;
- }
- break;
- case NetworkItemsList::Type:
- break;
- default: break;
- }
- }
-
- return false;
-}
-
-int NetworkItemsList::count() const
-{
- return m_items.count();
-}
-
-int NetworkItemsList::indexOf(NetworkModelItem* item) const
-{
- return m_items.indexOf(item);
-}
-
-void NetworkItemsList::insertItem(NetworkModelItem* item)
-{
- m_items << item;
-}
-
-NetworkModelItem* NetworkItemsList::itemAt(int index) const
-{
- return m_items.at(index);
-}
-
-QList< NetworkModelItem* > NetworkItemsList::items() const
-{
- return m_items;
-}
-
-void NetworkItemsList::removeItem(NetworkModelItem* item)
-{
- m_items.removeAll(item);
-}
-
-QList< NetworkModelItem* > NetworkItemsList::returnItems(const NetworkItemsList::FilterType type, const QString& parameter, const QString& additionalParameter) const
-{
- QList<NetworkModelItem*> result;
-
- foreach (NetworkModelItem * item, m_items) {
- switch (type) {
- case NetworkItemsList::ActiveConnection:
- if (item->activeConnectionPath() == parameter) {
- result << item;
- }
- break;
- case NetworkItemsList::Connection:
- if (item->connectionPath() == parameter) {
- if (additionalParameter.isEmpty()) {
- result << item;
- } else {
- if (item->devicePath() == additionalParameter) {
- result << item;
- }
- }
- }
- break;
- case NetworkItemsList::Device:
- if (item->devicePath() == parameter) {
- result << item;
- }
- break;
- case NetworkItemsList::Name:
- if (item->name() == parameter) {
- result << item;
- }
- break;
- case NetworkItemsList::Nsp:
- if (item->nsp() == parameter) {
- if (additionalParameter.isEmpty()) {
- result << item;
- } else {
- if (item->devicePath() == additionalParameter) {
- result << item;
- }
- }
- }
- break;
- case NetworkItemsList::Ssid:
- if (item->ssid() == parameter) {
- if (additionalParameter.isEmpty()) {
- result << item;
- } else {
- if (item->devicePath() == additionalParameter) {
- result << item;
- }
- }
- }
- break;
- case NetworkItemsList::Uuid:
- if (item->uuid() == parameter) {
- result << item;
- }
- break;
- case NetworkItemsList::Type:
- break;
- }
- }
-
- return result;
-}
-
-QList< NetworkModelItem* > NetworkItemsList::returnItems(const NetworkItemsList::FilterType type, NetworkManager::ConnectionSettings::ConnectionType typeParameter) const
-{
- QList<NetworkModelItem*> result;
-
- foreach (NetworkModelItem * item, m_items) {
- if (type == NetworkItemsList::Type) {
- if (item->type() == typeParameter) {
- result << item;
- }
- }
- }
- return result;
-}
+++ /dev/null
-/*
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_MODEL_NETWORK_ITEMS_LIST_H
-#define PLASMA_NM_MODEL_NETWORK_ITEMS_LIST_H
-
-#include <QtCore/QAbstractListModel>
-
-#include <NetworkManagerQt/ConnectionSettings>
-
-class NetworkModelItem;
-
-class NetworkItemsList : public QObject
-{
-Q_OBJECT
-public:
- enum FilterType {
- ActiveConnection,
- Connection,
- Device,
- Name,
- Nsp,
- Ssid,
- Uuid,
- Type
- };
-
- explicit NetworkItemsList(QObject* parent = 0);
- virtual ~NetworkItemsList();
-
- bool contains(const FilterType type, const QString& parameter) const;
- int count() const;
- int indexOf(NetworkModelItem * item) const;
- NetworkModelItem * itemAt(int index) const;
- QList<NetworkModelItem*> items() const;
- QList<NetworkModelItem*> returnItems(const FilterType type, const QString& parameter, const QString& additionalParameter = QString()) const;
- QList<NetworkModelItem*> returnItems(const FilterType type, NetworkManager::ConnectionSettings::ConnectionType typeParameter) const;
-
- void insertItem(NetworkModelItem * item);
- void removeItem(NetworkModelItem * item);
-private:
- QList<NetworkModelItem*> m_items;
-};
-
-#endif // PLASMA_NM_MODEL_NETWORK_ITEMS_LIST_H
+++ /dev/null
-/*
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "networkmodel.h"
-#include "networkmodelitem.h"
-#include "debug.h"
-#include "uiutils.h"
-
-#if WITH_MODEMMANAGER_SUPPORT
-#include <ModemManagerQt/manager.h>
-#include <ModemManagerQt/modem.h>
-#endif
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/WimaxSetting>
-
-NetworkModel::NetworkModel(QObject* parent)
- : QAbstractListModel(parent)
-{
- QHash<int, QByteArray> roles = roleNames();
- roles[ConnectionDetailsRole] = "ConnectionDetails";
- roles[ConnectionIconRole] = "ConnectionIcon";
- roles[ConnectionPathRole] = "ConnectionPath";
- roles[ConnectionStateRole] = "ConnectionState";
- roles[DeviceNameRole] = "DeviceName";
- roles[DevicePathRole] = "DevicePath";
- roles[DeviceStateRole] = "DeviceState";
- roles[DuplicateRole] = "Duplicate";
- roles[ItemUniqueNameRole] = "ItemUniqueName";
- roles[ItemTypeRole] = "ItemType";
- roles[LastUsedRole] = "LastUsed";
- roles[LastUsedDateOnlyRole] = "LastUsedDateOnly";
- roles[NameRole] = "Name";
- roles[NspRole] = "Nsp";
- roles[SectionRole] = "Section";
- roles[SignalRole] = "Signal";
- roles[SlaveRole] = "Slave";
- roles[SsidRole] = "Ssid";
- roles[SpecificPathRole] = "SpecificPath";
- roles[SecurityTypeRole] = "SecurityType";
- roles[SecurityTypeStringRole] = "SecurityTypeString";
- roles[TimeStampRole] = "TimeStamp";
- roles[TypeRole] = "Type";
- roles[UniRole] = "Uni";
- roles[UuidRole] = "Uuid";
- roles[VpnState] = "VpnState";
- setRoleNames(roles);
-
- initialize();
-}
-
-NetworkModel::~NetworkModel()
-{
-}
-
-QVariant NetworkModel::data(const QModelIndex& index, int role) const
-{
- const int row = index.row();
-
- if (row >= 0 && row < m_list.count()) {
- NetworkModelItem * item = m_list.itemAt(row);
-
- switch (role) {
- case ConnectionDetailsRole:
- return item->details();
- case ConnectionIconRole:
- return item->icon();
- case ConnectionPathRole:
- return item->connectionPath();
- case ConnectionStateRole:
- return item->connectionState();
- case DeviceNameRole:
- return item->deviceName();
- case DevicePathRole:
- return item->devicePath();
- case DeviceStateRole:
- return item->deviceState();
- case DuplicateRole:
- return item->duplicate();
- case ItemUniqueNameRole:
- if (m_list.returnItems(NetworkItemsList::Name, item->name()).count() > 1) {
- return item->originalName();
- } else {
- return item->name();
- }
- case ItemTypeRole:
- return item->itemType();
- case LastUsedRole:
- return UiUtils::formatLastUsedDateRelative(item->timestamp());
- case LastUsedDateOnlyRole:
- return UiUtils::formatDateRelative(item->timestamp());
- case NameRole:
- return item->name();
- case NspRole:
- return item->nsp();
- case SectionRole:
- return item->sectionType();
- case SignalRole:
- return item->signal();
- case SlaveRole:
- return item->slave();
- case SsidRole:
- return item->ssid();
- case SpecificPathRole:
- return item->specificPath();
- case SecurityTypeRole:
- return item->securityType();
- case SecurityTypeStringRole:
- return UiUtils::labelFromWirelessSecurity(item->securityType());
- case TimeStampRole:
- return item->timestamp();
- case TypeRole:
- return item->type();
- case UniRole:
- return item->uni();
- case UuidRole:
- return item->uuid();
- case VpnState:
- return item->vpnState();
- default:
- break;
- }
- }
-
- return QVariant();
-}
-
-int NetworkModel::rowCount(const QModelIndex& parent) const
-{
- Q_UNUSED(parent);
- return m_list.count();
-}
-
-void NetworkModel::initialize()
-{
- // Initialize existing connections
- foreach (const NetworkManager::Connection::Ptr& connection, NetworkManager::listConnections()) {
- addConnection(connection);
- }
-
- // Initialize existing devices
- foreach (const NetworkManager::Device::Ptr& dev, NetworkManager::networkInterfaces()) {
- addDevice(dev);
- }
-
- // Initialize existing active connections
- foreach (const NetworkManager::ActiveConnection::Ptr& active, NetworkManager::activeConnections()) {
- addActiveConnection(active);
- }
-
- initializeSignals();
-}
-
-void NetworkModel::initializeSignals()
-{
- connect(NetworkManager::notifier(), SIGNAL(activeConnectionAdded(QString)),
- SLOT(activeConnectionAdded(QString)), Qt::UniqueConnection);
- connect(NetworkManager::notifier(), SIGNAL(activeConnectionRemoved(QString)),
- SLOT(activeConnectionRemoved(QString)), Qt::UniqueConnection);
- connect(NetworkManager::settingsNotifier(), SIGNAL(connectionAdded(QString)),
- SLOT(connectionAdded(QString)), Qt::UniqueConnection);
- connect(NetworkManager::settingsNotifier(), SIGNAL(connectionRemoved(QString)),
- SLOT(connectionRemoved(QString)), Qt::UniqueConnection);
- connect(NetworkManager::notifier(), SIGNAL(deviceAdded(QString)),
- SLOT(deviceAdded(QString)), Qt::UniqueConnection);
- connect(NetworkManager::notifier(), SIGNAL(deviceRemoved(QString)),
- SLOT(deviceRemoved(QString)), Qt::UniqueConnection);
- connect(NetworkManager::notifier(), SIGNAL(statusChanged(NetworkManager::Status)),
- SLOT(statusChanged(NetworkManager::Status)), Qt::UniqueConnection);
-}
-
-void NetworkModel::initializeSignals(const NetworkManager::ActiveConnection::Ptr& activeConnection)
-{
- if (activeConnection->vpn()) {
- NetworkManager::VpnConnection::Ptr vpnConnection = activeConnection.objectCast<NetworkManager::VpnConnection>();
- if (vpnConnection) {
- connect(vpnConnection.data(), SIGNAL(stateChanged(NetworkManager::VpnConnection::State,NetworkManager::VpnConnection::StateChangeReason)),
- SLOT(activeVpnConnectionStateChanged(NetworkManager::VpnConnection::State,NetworkManager::VpnConnection::StateChangeReason)), Qt::UniqueConnection);
- }
- } else {
- connect(activeConnection.data(), SIGNAL(stateChanged(NetworkManager::ActiveConnection::State)),
- SLOT(activeConnectionStateChanged(NetworkManager::ActiveConnection::State)), Qt::UniqueConnection);
- }
-}
-
-void NetworkModel::initializeSignals(const NetworkManager::Connection::Ptr& connection)
-{
- connect(connection.data(), SIGNAL(updated()), SLOT(connectionUpdated()), Qt::UniqueConnection);
-}
-
-void NetworkModel::initializeSignals(const NetworkManager::Device::Ptr& device)
-{
- connect(device.data(), SIGNAL(availableConnectionAppeared(QString)),
- SLOT(availableConnectionAppeared(QString)), Qt::UniqueConnection);
- connect(device.data(), SIGNAL(availableConnectionDisappeared(QString)),
- SLOT(availableConnectionDisappeared(QString)), Qt::UniqueConnection);
- connect(device.data(), SIGNAL(ipV4ConfigChanged()),
- SLOT(ipConfigChanged()), Qt::UniqueConnection);
- connect(device.data(), SIGNAL(ipV6ConfigChanged()),
- SLOT(ipConfigChanged()), Qt::UniqueConnection);
- connect(device.data(), SIGNAL(ipInterfaceChanged()),
- SLOT(ipInterfaceChanged()));
- connect(device.data(), SIGNAL(stateChanged(NetworkManager::Device::State,NetworkManager::Device::State,NetworkManager::Device::StateChangeReason)),
- SLOT(deviceStateChanged(NetworkManager::Device::State,NetworkManager::Device::State,NetworkManager::Device::StateChangeReason)), Qt::UniqueConnection);
-
- if (device->type() == NetworkManager::Device::Wifi) {
- NetworkManager::WirelessDevice::Ptr wifiDev = device.objectCast<NetworkManager::WirelessDevice>();
- connect(wifiDev.data(), SIGNAL(networkAppeared(QString)),
- SLOT(wirelessNetworkAppeared(QString)), Qt::UniqueConnection);
- connect(wifiDev.data(), SIGNAL(networkDisappeared(QString)),
- SLOT(wirelessNetworkDisappeared(QString)), Qt::UniqueConnection);
- }
-
- if (device->type() == NetworkManager::Device::Wimax) {
- NetworkManager::WimaxDevice::Ptr wimaxDev = device.objectCast<NetworkManager::WimaxDevice>();
- connect(wimaxDev.data(), SIGNAL(nspAppeared(QString)),
- SLOT(wimaxNspAppeared(QString)));
- connect(wimaxDev.data(), SIGNAL(nspDisappeared(QString)),
- SLOT(wimaxNspDisappeared(QString)));
- }
-
-#if WITH_MODEMMANAGER_SUPPORT
- else if (device->type() == NetworkManager::Device::Modem) {
- NetworkManager::ModemDevice::Ptr modemDev = device.objectCast<NetworkManager::ModemDevice>();
- ModemManager::Modem::Ptr modemNetwork = modemDev->getModemNetworkIface();
- if (modemDev->isValid()) {
- connect(modemNetwork.data(), SIGNAL(signalQualityChanged(uint)),
- SLOT(gsmNetworkSignalQualityChanged(uint)), Qt::UniqueConnection);
- connect(modemNetwork.data(), SIGNAL(accessTechnologyChanged(ModemManager::Modem::AccessTechnologies)),
- SLOT(gsmNetworkAccessTechnologyChanged(ModemManager::Modem::AccessTechnologies)), Qt::UniqueConnection);
- connect(modemNetwork.data(), SIGNAL(currentModesChanged()),
- SLOT(gsmNetworkCurrentModesChanged()), Qt::UniqueConnection);
- }
- }
-#endif
-}
-
-void NetworkModel::initializeSignals(const NetworkManager::WimaxNsp::Ptr& nsp)
-{
- connect(nsp.data(), SIGNAL(signalQualityChanged(uint)),
- SLOT(wimaxNspSignalChanged(uint)));
-}
-
-void NetworkModel::initializeSignals(const NetworkManager::WirelessNetwork::Ptr& network)
-{
- connect(network.data(), SIGNAL(signalStrengthChanged(int)),
- SLOT(wirelessNetworkSignalChanged(int)), Qt::UniqueConnection);
- connect(network.data(), SIGNAL(referenceAccessPointChanged(QString)),
- SLOT(wirelessNetworkReferenceApChanged(QString)), Qt::UniqueConnection);
-}
-
-void NetworkModel::addActiveConnection(const NetworkManager::ActiveConnection::Ptr& activeConnection)
-{
- initializeSignals(activeConnection);
-
- NetworkManager::Device::Ptr device;
- NetworkManager::Connection::Ptr connection = activeConnection->connection();
-
- // Not necessary to have device for VPN connections
- if (activeConnection && !activeConnection->vpn() && !activeConnection->devices().isEmpty()) {
- device = NetworkManager::findNetworkInterface(activeConnection->devices().first());
- }
-
- // Check whether we have a base connection
- if (!m_list.contains(NetworkItemsList::Uuid, connection->uuid())) {
- // Active connection appeared before a base connection, so we have to add its base connection first
- addConnection(connection);
- }
-
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::NetworkItemsList::Uuid, connection->uuid())) {
- if (((device && device->uni() == item->devicePath()) || item->devicePath().isEmpty()) || item->type() == NetworkManager::ConnectionSettings::Vpn) {
- item->setActiveConnectionPath(activeConnection->path());
- item->setConnectionState(activeConnection->state());
- if (activeConnection->vpn()) {
- NetworkManager::VpnConnection::Ptr vpnConnection = activeConnection.objectCast<NetworkManager::VpnConnection>();
- NetworkManager::VpnConnection::State state = vpnConnection->state();
- if (state == NetworkManager::VpnConnection::Prepare ||
- state == NetworkManager::VpnConnection::NeedAuth ||
- state == NetworkManager::VpnConnection::Connecting ||
- state == NetworkManager::VpnConnection::GettingIpConfig) {
- item->setConnectionState(NetworkManager::ActiveConnection::Activating);
- } else if (state == NetworkManager::VpnConnection::Activated) {
- item->setConnectionState(NetworkManager::ActiveConnection::Activated);
- } else {
- item->setConnectionState(NetworkManager::ActiveConnection::Deactivated);
- }
- item->setVpnState(state);
- }
- updateItem(item);
- nmDebug() << "Item " << item->name() << ": active connection state changed to " << item->connectionState();
- }
- }
-}
-
-void NetworkModel::addAvailableConnection(const QString& connection, const NetworkManager::Device::Ptr& device)
-{
- checkAndCreateDuplicate(connection, device);
-
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Connection, connection)) {
- // The item is already associated with another device
- if (!item->devicePath().isEmpty()) {
- continue;
- }
-
- if (device->ipInterfaceName().isEmpty()) {
- item->setDeviceName(device->interfaceName());
- } else {
- item->setDeviceName(device->ipInterfaceName());
- }
- item->setDevicePath(device->uni());
- item->setDeviceState(device->state());
- nmDebug() << "Item " << item->name() << ": device changed to " << item->devicePath();
-#if WITH_MODEMMANAGER_SUPPORT
- if (device->type() == NetworkManager::Device::Modem) {
- ModemManager::ModemDevice::Ptr modemDevice = ModemManager::findModemDevice(device->udi());
- if (modemDevice) {
- ModemManager::Modem::Ptr modemInterface = modemDevice->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
- if (modemInterface) {
- item->setSignal(modemInterface->signalQuality().signal);
- nmDebug() << "Item " << item->name() << ": signal changed to " << item->signal();
- }
- }
- }
-#endif
- if (item->type() == NetworkManager::ConnectionSettings::Wireless && item->mode() == NetworkManager::WirelessSetting::Infrastructure) {
- // Find an accesspoint which could be removed, because it will be merged with a connection
- foreach (NetworkModelItem * secondItem, m_list.returnItems(NetworkItemsList::Ssid, item->ssid())) {
- if (secondItem->itemType() == NetworkModelItem::AvailableAccessPoint && secondItem->devicePath() == item->devicePath()) {
- const int row = m_list.indexOf(secondItem);
- nmDebug() << "Access point " << secondItem->name() << ": merged to " << item->name() << " connection";
- if (row >= 0) {
- beginRemoveRows(QModelIndex(), row, row);
- m_list.removeItem(secondItem);
- secondItem->deleteLater();
- endRemoveRows();
- }
- break;
- }
- }
-
- NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
- if (wifiDevice) {
- NetworkManager::WirelessNetwork::Ptr wifiNetwork = wifiDevice->findNetwork(item->ssid());
- if (wifiNetwork) {
- updateFromWirelessNetwork(item, wifiNetwork);
- }
- }
- }
-
- if (item->type() == NetworkManager::ConnectionSettings::Wimax) {
- // Find a nsp which could be removed, because it will be merged with a connection
- foreach (NetworkModelItem * secondItem, m_list.returnItems(NetworkItemsList::Nsp, item->nsp())) {
- if (secondItem->itemType() == NetworkModelItem::AvailableNsp && secondItem->devicePath() == item->devicePath()) {
- const int row = m_list.indexOf(secondItem);
- nmDebug() << "Nsp " << secondItem->name() << ": merged to " << item->name() << " connection";
- if (row >= 0) {
- beginRemoveRows(QModelIndex(), row, row);
- m_list.removeItem(secondItem);
- secondItem->deleteLater();
- endRemoveRows();
- }
- break;
- }
- }
-
- NetworkManager::WimaxDevice::Ptr wimaxDevice = device.objectCast<NetworkManager::WimaxDevice>();
- NetworkManager::WimaxNsp::Ptr nsp = wimaxDevice->findNsp(item->specificPath());
- if (nsp) {
- updateFromWimaxNsp(item, nsp);
- }
- }
-
- updateItem(item);
- break;
- }
-}
-
-void NetworkModel::addConnection(const NetworkManager::Connection::Ptr& connection)
-{
- // Can't add a connection without name or uuid
- if (connection->name().isEmpty() || connection->uuid().isEmpty()) {
- return;
- }
-
- initializeSignals(connection);
-
- NetworkManager::ConnectionSettings::Ptr settings = connection->settings();
- NetworkManager::WimaxSetting::Ptr wimaxSetting;
- NetworkManager::WirelessSetting::Ptr wirelessSetting;
-
- if (settings->connectionType() == NetworkManager::ConnectionSettings::Wireless) {
- wirelessSetting = settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
- }
-
- if (settings->connectionType() == NetworkManager::ConnectionSettings::Wimax) {
- wimaxSetting = settings->setting(NetworkManager::Setting::Wimax).dynamicCast<NetworkManager::WimaxSetting>();
- }
-
- // Check whether the connection is already in the model to avoid duplicates, but this shouldn't happen
- if (!m_list.contains(NetworkItemsList::Connection, connection->path())) {
- NetworkModelItem * item = new NetworkModelItem();
- item->setConnectionPath(connection->path());
- item->setName(settings->id());
- item->setTimestamp(settings->timestamp());
- item->setType(settings->connectionType());
- item->setUuid(settings->uuid());
- item->setSlave(settings->isSlave());
-
- if (item->type() == NetworkManager::ConnectionSettings::Wireless) {
- item->setMode(wirelessSetting->mode());
- item->setSecurityType(NetworkManager::Utils::securityTypeFromConnectionSetting(settings));
- item->setSsid(QString::fromUtf8(wirelessSetting->ssid()));
- }
-
- if (item->type() == NetworkManager::ConnectionSettings::Wimax) {
- item->setNsp(wimaxSetting->networkName());
- }
-
- item->updateDetails();
-
- const int index = m_list.count();
- beginInsertRows(QModelIndex(), index, index);
- m_list.insertItem(item);
- endInsertRows();
- nmDebug() << "New connection " << item->name() << " added";
- }
-}
-
-void NetworkModel::addDevice(const NetworkManager::Device::Ptr& device)
-{
- initializeSignals(device);
-
- if (device->type() == NetworkManager::Device::Wifi) {
- NetworkManager::WirelessDevice::Ptr wifiDev = device.objectCast<NetworkManager::WirelessDevice>();
- foreach (const NetworkManager::WirelessNetwork::Ptr& wifiNetwork, wifiDev->networks()) {
- addWirelessNetwork(wifiNetwork, wifiDev);
- }
- }
-
- if (device->type() == NetworkManager::Device::Wimax) {
- NetworkManager::WimaxDevice::Ptr wimaxDev = device.objectCast<NetworkManager::WimaxDevice>();
- foreach (const QString & nsp, wimaxDev->nsps()) {
- NetworkManager::WimaxNsp::Ptr wimaxNsp = wimaxDev->findNsp(nsp);
- if (wimaxNsp) {
- addWimaxNsp(wimaxNsp, wimaxDev);
- }
- }
- }
-
- foreach (const NetworkManager::Connection::Ptr & connection, device->availableConnections()) {
- addAvailableConnection(connection->path(), device);
- }
-}
-
-void NetworkModel::addWimaxNsp(const NetworkManager::WimaxNsp::Ptr& nsp, const NetworkManager::WimaxDevice::Ptr& device)
-{
- initializeSignals(nsp);
-
- NetworkModelItem * item = new NetworkModelItem();
- if (device->ipInterfaceName().isEmpty()) {
- item->setDeviceName(device->interfaceName());
- } else {
- item->setDeviceName(device->ipInterfaceName());
- }
- item->setDevicePath(device->uni());
- item->setName(nsp->name());
- item->setSignal(nsp->signalQuality());
- item->setSpecificPath(nsp->uni());
- item->setType(NetworkManager::ConnectionSettings::Wimax);
- item->updateDetails();
-
- const int index = m_list.count();
- beginInsertRows(QModelIndex(), index, index);
- m_list.insertItem(item);
- endInsertRows();
- nmDebug() << "New wireless network " << item->name() << " added";}
-
-void NetworkModel::addWirelessNetwork(const NetworkManager::WirelessNetwork::Ptr& network, const NetworkManager::WirelessDevice::Ptr& device)
-{
- initializeSignals(network);
-
- NetworkManager::WirelessSetting::NetworkMode mode = NetworkManager::WirelessSetting::Infrastructure;
- NetworkManager::Utils::WirelessSecurityType securityType = NetworkManager::Utils::Unknown;
- NetworkManager::AccessPoint::Ptr ap = network->referenceAccessPoint();
- if (ap && ap->capabilities() & NetworkManager::AccessPoint::Privacy) {
- securityType = NetworkManager::Utils::findBestWirelessSecurity(device->wirelessCapabilities(), true, (device->mode() == NetworkManager::WirelessDevice::Adhoc),
- ap->capabilities(), ap->wpaFlags(), ap->rsnFlags());
- if (network->referenceAccessPoint()->mode() == NetworkManager::AccessPoint::Infra) {
- mode = NetworkManager::WirelessSetting::Infrastructure;
- } else if (network->referenceAccessPoint()->mode() == NetworkManager::AccessPoint::Adhoc) {
- mode = NetworkManager::WirelessSetting::Adhoc;
- } else if (network->referenceAccessPoint()->mode() == NetworkManager::AccessPoint::ApMode) {
- mode = NetworkManager::WirelessSetting::Ap;
- }
- }
-
- NetworkModelItem * item = new NetworkModelItem();
- if (device->ipInterfaceName().isEmpty()) {
- item->setDeviceName(device->interfaceName());
- } else {
- item->setDeviceName(device->ipInterfaceName());
- }
- item->setDevicePath(device->uni());
- item->setMode(mode);
- item->setName(network->ssid());
- item->setSignal(network->signalStrength());
- item->setSpecificPath(network->referenceAccessPoint()->uni());
- item->setSsid(network->ssid());
- item->setType(NetworkManager::ConnectionSettings::Wireless);
- item->setSecurityType(securityType);
- item->updateDetails();
-
- const int index = m_list.count();
- beginInsertRows(QModelIndex(), index, index);
- m_list.insertItem(item);
- endInsertRows();
- nmDebug() << "New wireless network " << item->name() << " added";
-}
-
-void NetworkModel::checkAndCreateDuplicate(const QString& connection, const NetworkManager::Device::Ptr& device)
-{
- bool createDuplicate = false;
- NetworkModelItem * originalItem = 0;
-
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Connection, connection)) {
- if (!item->duplicate()) {
- originalItem = item;
- }
-
- if (!item->duplicate() && item->itemType() == NetworkModelItem::AvailableConnection && (item->devicePath() != device->uni() && !item->devicePath().isEmpty())) {
- createDuplicate = true;
- }
- }
-
- if (createDuplicate) {
- NetworkModelItem * duplicatedItem = new NetworkModelItem(originalItem);
- duplicatedItem->updateDetails();
-
- const int index = m_list.count();
- beginInsertRows(QModelIndex(), index, index);
- m_list.insertItem(duplicatedItem);
- endInsertRows();
- }
-}
-
-void NetworkModel::onItemUpdated()
-{
- NetworkModelItem * item = static_cast<NetworkModelItem*>(sender());
- if (item) {
- updateItem(item);
- }
-}
-
-void NetworkModel::updateItem(NetworkModelItem * item)
-{
- const int row = m_list.indexOf(item);
-
- if (row >= 0) {
- item->updateDetails();
- QModelIndex index = createIndex(row, 0);
- emit dataChanged(index, index);
- }
-}
-
-void NetworkModel::updateItems()
-{
- foreach (NetworkModelItem * item, m_list.items()) {
- updateItem(item);
- }
-}
-
-void NetworkModel::accessPointSignalStrengthChanged(int signal)
-{
- NetworkManager::AccessPoint * apPtr = qobject_cast<NetworkManager::AccessPoint*>(sender());
- if (apPtr) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Ssid, apPtr->ssid())) {
- if (item->specificPath() == apPtr->uni()) {
- item->setSignal(signal);
- updateItem(item);
- nmDebug() << "AccessPoint " << item->name() << ": signal changed to " << item->signal();
- }
- }
- }
-}
-
-void NetworkModel::activeConnectionAdded(const QString& activeConnection)
-{
- NetworkManager::ActiveConnection::Ptr activeCon = NetworkManager::findActiveConnection(activeConnection);
-
- if (activeCon) {
- addActiveConnection(activeCon);
- }
-}
-
-void NetworkModel::activeConnectionRemoved(const QString& activeConnection)
-{
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::ActiveConnection, activeConnection)) {
- item->setActiveConnectionPath(QString());
- item->setConnectionState(NetworkManager::ActiveConnection::Deactivated);
- item->setVpnState(NetworkManager::VpnConnection::Disconnected);
- updateItem(item);
- nmDebug() << "Item " << item->name() << ": active connection removed";
- }
-}
-
-void NetworkModel::activeConnectionStateChanged(NetworkManager::ActiveConnection::State state)
-{
- NetworkManager::ActiveConnection * activePtr = qobject_cast<NetworkManager::ActiveConnection*>(sender());
- if (activePtr) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::ActiveConnection, activePtr->path())) {
- item->setConnectionState(state);
- updateItem(item);
- nmDebug() << "Item " << item->name() << ": active connection changed to " << item->connectionState();
- }
- }
-}
-
-void NetworkModel::activeVpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason)
-{
- Q_UNUSED(reason)
- NetworkManager::ActiveConnection *activePtr = qobject_cast<NetworkManager::ActiveConnection*>(sender());
-
- if (activePtr) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::ActiveConnection, activePtr->path())) {
- if (state == NetworkManager::VpnConnection::Prepare ||
- state == NetworkManager::VpnConnection::NeedAuth ||
- state == NetworkManager::VpnConnection::Connecting ||
- state == NetworkManager::VpnConnection::GettingIpConfig) {
- item->setConnectionState(NetworkManager::ActiveConnection::Activating);
- } else if (state == NetworkManager::VpnConnection::Activated) {
- item->setConnectionState(NetworkManager::ActiveConnection::Activated);
- } else {
- item->setConnectionState(NetworkManager::ActiveConnection::Deactivated);
- }
- item->setVpnState(state);
- updateItem(item);
- nmDebug() << "Item " << item->name() << ": active connection changed to " << item->connectionState();
- }
- }
-}
-
-void NetworkModel::availableConnectionAppeared(const QString& connection)
-{
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(qobject_cast<NetworkManager::Device*>(sender())->uni());
- addAvailableConnection(connection, device);
-}
-
-void NetworkModel::availableConnectionDisappeared(const QString& connection)
-{
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Connection, connection)) {
- bool available = false;
- QString devicePath = item->devicePath();
- QString specificPath = item->specificPath();
-
- // We have to check whether the connection is still available, because it might be
- // presented in the model for more devices and we don't want to remove it for all of them.
-
- // Check whether the device is still available
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(devicePath);
- if (device) {
- // Check whether the connection is still listed as available
- foreach (const NetworkManager::Connection::Ptr & connection, device->availableConnections()) {
- if (connection->path() == item->connectionPath()) {
- available = true;
- break;
- }
- }
- }
-
- if (!available) {
- item->setDeviceName(QString());
- item->setDevicePath(QString());
- item->setDeviceState(NetworkManager::Device::UnknownState);
- item->setSignal(0);
- item->setSpecificPath(QString());
- nmDebug() << "Item " << item->name() << " removed as available connection";
- // Check whether the connection is still available as an access point, this happens
- // when we change its properties, like ssid, bssid, security etc.
- if (item->type() == NetworkManager::ConnectionSettings::Wireless && !specificPath.isEmpty()) {
- if (device && device->type() == NetworkManager::Device::Wifi) {
- NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
- if (wifiDevice) {
- NetworkManager::AccessPoint::Ptr ap = wifiDevice->findAccessPoint(specificPath);
- if (ap) {
- NetworkManager::WirelessNetwork::Ptr network = wifiDevice->findNetwork(ap->ssid());
- if (network) {
- addWirelessNetwork(network, wifiDevice);
- }
- }
- }
- }
- }
-
- // Same for Wimax
- if (item->type() == NetworkManager::ConnectionSettings::Wimax && !specificPath.isEmpty()) {
- if (device && device->type() == NetworkManager::Device::Wimax) {
- NetworkManager::WimaxDevice::Ptr wimaxDevice = device.objectCast<NetworkManager::WimaxDevice>();
- if (wimaxDevice) {
- NetworkManager::WimaxNsp::Ptr nsp = wimaxDevice->findNsp(specificPath);
- if (nsp) {
- addWimaxNsp(nsp, wimaxDevice);
- }
- }
- }
- }
-
- if (item->duplicate()) {
- const int row = m_list.indexOf(item);
- if (row >= 0) {
- nmDebug() << "Duplicate item " << item->name() << " removed completely";
- beginRemoveRows(QModelIndex(), row, row);
- m_list.removeItem(item);
- item->deleteLater();
- endRemoveRows();
- }
- } else {
- updateItem(item);
- }
- }
- available = false;
- }
-}
-
-void NetworkModel::connectionAdded(const QString& connection)
-{
- NetworkManager::Connection::Ptr newConnection = NetworkManager::findConnection(connection);
- if (newConnection) {
- addConnection(newConnection);
- }
-}
-
-void NetworkModel::connectionRemoved(const QString& connection)
-{
- bool remove = false;
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Connection, connection)) {
- // When the item type is wireless, we can remove only the connection and leave it as an available access point
- if (item->type() == NetworkManager::ConnectionSettings::Wireless && !item->devicePath().isEmpty()) {
- foreach (NetworkModelItem * secondItem, m_list.items()) {
- // Remove it entirely when there is another connection with the same configuration and for the same device
- // or it's a shared connection
- if ((item->mode() != NetworkManager::WirelessSetting::Infrastructure) ||
- (item->connectionPath() != secondItem->connectionPath() &&
- item->devicePath() == secondItem->devicePath() &&
- item->mode() == secondItem->mode() &&
- item->securityType() == secondItem->securityType() &&
- item->ssid() == secondItem->ssid())) {
- remove = true;
- }
- }
-
- if (!remove) {
- item->setConnectionPath(QString());
- item->setName(item->ssid());
- item->setSlave(false);
- item->setTimestamp(QDateTime());
- item->setUuid(QString());
- updateItem(item);
- nmDebug() << "Item " << item->name() << ": connection removed";
- }
- } else {
- remove = true;
- }
-
- if (remove) {
- const int row = m_list.indexOf(item);
- if (row >= 0) {
- nmDebug() << "Item " << item->name() << " removed completely";
- beginRemoveRows(QModelIndex(), row, row);
- m_list.removeItem(item);
- item->deleteLater();
- endRemoveRows();
- }
- }
- remove = false;
- }
-}
-
-void NetworkModel::connectionUpdated()
-{
- NetworkManager::Connection * connectionPtr = qobject_cast<NetworkManager::Connection*>(sender());
- if (connectionPtr) {
- NetworkManager::ConnectionSettings::Ptr settings = connectionPtr->settings();
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Connection, connectionPtr->path())) {
- item->setConnectionPath(connectionPtr->path());
- item->setName(settings->id());
- item->setTimestamp(settings->timestamp());
- item->setType(settings->connectionType());
- item->setUuid(settings->uuid());
-
- if (item->type() == NetworkManager::ConnectionSettings::Wireless) {
- NetworkManager::WirelessSetting::Ptr wirelessSetting;
- wirelessSetting = settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
- item->setMode(wirelessSetting->mode());
- item->setSecurityType(NetworkManager::Utils::securityTypeFromConnectionSetting(settings));
- item->setSsid(QString::fromUtf8(wirelessSetting->ssid()));
- // TODO check whether BSSID has changed and update the wireless info
- }
-
- if (item->type() == NetworkManager::ConnectionSettings::Wimax) {
- NetworkManager::WimaxSetting::Ptr wimaxSetting;
- wimaxSetting = settings->setting(NetworkManager::Setting::Wimax).dynamicCast<NetworkManager::WimaxSetting>();
- item->setNsp(wimaxSetting->networkName());
- }
-
- updateItem(item);
- nmDebug() << "Item " << item->name() << ": connection updated";
- }
- }
-}
-
-void NetworkModel::deviceAdded(const QString& device)
-{
- NetworkManager::Device::Ptr dev = NetworkManager::findNetworkInterface(device);
- if (dev) {
- addDevice(dev);
- }
-}
-
-void NetworkModel::deviceRemoved(const QString& device)
-{
- // Make all items unavailable
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, device)) {
- availableConnectionDisappeared(item->connectionPath());
- }
-}
-
-void NetworkModel::deviceStateChanged(NetworkManager::Device::State state, NetworkManager::Device::State oldState, NetworkManager::Device::StateChangeReason reason)
-{
- Q_UNUSED(oldState);
- Q_UNUSED(reason);
-
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(qobject_cast<NetworkManager::Device*>(sender())->uni());
-
- if (device) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, device->uni())) {
- item->setDeviceState(state);
- updateItem(item);
-// nmDebug() << "Item " << item->name() << ": device state changed to " << item->deviceState();
- }
- }
-}
-
-#if WITH_MODEMMANAGER_SUPPORT
-void NetworkModel::gsmNetworkAccessTechnologyChanged(ModemManager::Modem::AccessTechnologies technology)
-{
- Q_UNUSED(technology);
- ModemManager::Modem * gsmNetwork = qobject_cast<ModemManager::Modem*>(sender());
- if (gsmNetwork) {
- foreach (const NetworkManager::Device::Ptr & dev, NetworkManager::networkInterfaces()) {
- if (dev->type() == NetworkManager::Device::Modem) {
- NetworkManager::ModemDevice::Ptr modem = dev.objectCast<NetworkManager::ModemDevice>();
- if (modem) {
- if (modem->getModemNetworkIface()->device() == gsmNetwork->device()) {
- // TODO store access technology internally?
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, modem->uni())) {
- updateItem(item);
- }
- }
- }
- }
- }
- }
-}
-
-void NetworkModel::gsmNetworkCurrentModesChanged()
-{
- ModemManager::Modem * gsmNetwork = qobject_cast<ModemManager::Modem*>(sender());
- if (gsmNetwork) {
- foreach (const NetworkManager::Device::Ptr & dev, NetworkManager::networkInterfaces()) {
- if (dev->type() == NetworkManager::Device::Modem) {
- NetworkManager::ModemDevice::Ptr modem = dev.objectCast<NetworkManager::ModemDevice>();
- if (modem) {
- if (modem->getModemNetworkIface()->device() == gsmNetwork->device()) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, modem->uni())) {
- updateItem(item);
- }
- }
- }
- }
- }
- }
-}
-
-void NetworkModel::gsmNetworkSignalQualityChanged(uint signal)
-{
- ModemManager::Modem * gsmNetwork = qobject_cast<ModemManager::Modem*>(sender());
- if (gsmNetwork) {
- foreach (const NetworkManager::Device::Ptr & dev, NetworkManager::networkInterfaces()) {
- if (dev->type() == NetworkManager::Device::Modem) {
- NetworkManager::ModemDevice::Ptr modem = dev.objectCast<NetworkManager::ModemDevice>();
- if (modem) {
- if (modem->getModemNetworkIface()->device() == gsmNetwork->device()) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, modem->uni())) {
- item->setSignal(signal);
- updateItem(item);
- }
- }
- }
- }
- }
- }
-}
-
-#endif
-
-void NetworkModel::ipConfigChanged()
-{
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(qobject_cast<NetworkManager::Device*>(sender())->uni());
-
- if (device) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, device->uni())) {
- updateItem(item);
-// nmDebug() << "Item " << item->name() << ": device ipconfig changed";
- }
- }
-}
-
-void NetworkModel::ipInterfaceChanged()
-{
- NetworkManager::Device * device = qobject_cast<NetworkManager::Device*>(sender());
- if (device) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Device, device->uni())) {
- if (device->ipInterfaceName().isEmpty()) {
- item->setDeviceName(device->interfaceName());
- } else {
- item->setDeviceName(device->ipInterfaceName());
- }
- }
- }
-}
-
-void NetworkModel::statusChanged(NetworkManager::Status status)
-{
- Q_UNUSED(status);
-
- nmDebug() << "NetworkManager state changed to " << status;
- // This has probably effect only for VPN connections
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Type, NetworkManager::ConnectionSettings::Vpn)) {
- updateItem(item);
- }
-}
-
-void NetworkModel::wimaxNspAppeared(const QString& nsp)
-{
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(qobject_cast<NetworkManager::Device*>(sender())->uni());
- if (device && device->type() == NetworkManager::Device::Wimax) {
- NetworkManager::WimaxDevice::Ptr wimaxDevice = device.objectCast<NetworkManager::WimaxDevice>();
- NetworkManager::WimaxNsp::Ptr wimaxNsp = wimaxDevice->findNsp(nsp);
- if (wimaxNsp) {
- addWimaxNsp(wimaxNsp, wimaxDevice);
- }
- }
-}
-
-void NetworkModel::wimaxNspDisappeared(const QString& nsp)
-{
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(qobject_cast<NetworkManager::Device*>(sender())->uni());
- if (device) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Nsp, nsp, device->uni())) {
- // Remove the entire item, because it's only NSP or it's a duplicated available connection
- if (item->itemType() == NetworkModelItem::AvailableNsp || item->duplicate()) {
- const int row = m_list.indexOf(item);
- if (row >= 0) {
- nmDebug() << "Wimax Nsp " << item->name() << " removed completely";
- beginRemoveRows(QModelIndex(), row, row);
- m_list.removeItem(item);
- item->deleteLater();
- endRemoveRows();
- }
- // Remove only NSP and device from the item and leave it as an unavailable connection
- } else {
- item->setDeviceName(QString());
- item->setDevicePath(QString());
- item->setSpecificPath(QString());
- item->setSignal(0);
- updateItem(item);
- nmDebug() << "Item " << item->name() << ": wimax Nsp removed";
- }
- }
- }
-}
-
-void NetworkModel::wimaxNspSignalChanged(uint signal)
-{
- NetworkManager::WimaxNsp * nspPtr = qobject_cast<NetworkManager::WimaxNsp*>(sender());
- if (nspPtr) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Nsp, nspPtr->name())) {
- if (item->specificPath() == nspPtr->uni()) {
- item->setSignal(signal);
- updateItem(item);
-// nmDebug() << "Wimax Nsp " << item->name() << ": signal changed to " << item->signal();
- }
- }
- }
-}
-
-void NetworkModel::wirelessNetworkAppeared(const QString& ssid)
-{
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(qobject_cast<NetworkManager::Device*>(sender())->uni());
- if (device && device->type() == NetworkManager::Device::Wifi) {
- NetworkManager::WirelessDevice::Ptr wirelessDevice = device.objectCast<NetworkManager::WirelessDevice>();
- NetworkManager::WirelessNetwork::Ptr network = wirelessDevice->findNetwork(ssid);
- addWirelessNetwork(network, wirelessDevice);
- }
-}
-
-void NetworkModel::wirelessNetworkDisappeared(const QString& ssid)
-{
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(qobject_cast<NetworkManager::Device*>(sender())->uni());
- if (device) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Ssid, ssid, device->uni())) {
- // Remove the entire item, because it's only AP or it's a duplicated available connection
- if (item->itemType() == NetworkModelItem::AvailableAccessPoint || item->duplicate()) {
- const int row = m_list.indexOf(item);
- if (row >= 0) {
- nmDebug() << "Wireless network " << item->name() << " removed completely";
- beginRemoveRows(QModelIndex(), row, row);
- m_list.removeItem(item);
- item->deleteLater();
- endRemoveRows();
- }
- // Remove only AP and device from the item and leave it as an unavailable connection
- } else {
- if (item->mode() == NetworkManager::WirelessSetting::Infrastructure) {
- item->setDeviceName(QString());
- item->setDevicePath(QString());
- item->setSpecificPath(QString());
- }
- item->setSignal(0);
- updateItem(item);
- nmDebug() << "Item " << item->name() << ": wireless network removed";
- }
- }
- }
-}
-
-void NetworkModel::wirelessNetworkReferenceApChanged(const QString& accessPoint)
-{
- NetworkManager::WirelessNetwork * networkPtr = qobject_cast<NetworkManager::WirelessNetwork*>(sender());
-
- if (networkPtr) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Ssid, networkPtr->ssid(), networkPtr->device())) {
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnection(item->connectionPath());
- if (connection) {
- NetworkManager::WirelessSetting::Ptr wirelessSetting = connection->settings()->setting(NetworkManager::Setting::Wireless).staticCast<NetworkManager::WirelessSetting>();
- if (wirelessSetting) {
- if (wirelessSetting->bssid().isEmpty()) {
- item->setSpecificPath(accessPoint);
- updateItem(item);
- }
- }
- }
- }
- }
-}
-
-void NetworkModel::wirelessNetworkSignalChanged(int signal)
-{
- NetworkManager::WirelessNetwork * networkPtr = qobject_cast<NetworkManager::WirelessNetwork*>(sender());
- if (networkPtr) {
- foreach (NetworkModelItem * item, m_list.returnItems(NetworkItemsList::Ssid, networkPtr->ssid(), networkPtr->device())) {
- if (item->specificPath() == networkPtr->referenceAccessPoint()->uni()) {
- item->setSignal(signal);
- updateItem(item);
- nmDebug() << "Wireless network " << item->name() << ": signal changed to " << item->signal();
- }
- }
- }
-}
-
-NetworkManager::Utils::WirelessSecurityType NetworkModel::alternativeWirelessSecurity(const NetworkManager::Utils::WirelessSecurityType type)
-{
- if (type == NetworkManager::Utils::WpaPsk) {
- return NetworkManager::Utils::Wpa2Psk;
- } else if (type == NetworkManager::Utils::WpaEap) {
- return NetworkManager::Utils::Wpa2Eap;
- } else if (type == NetworkManager::Utils::Wpa2Psk) {
- return NetworkManager::Utils::WpaPsk;
- } else if (type == NetworkManager::Utils::Wpa2Eap) {
- return NetworkManager::Utils::WpaEap;
- }
- return type;
-}
-
-void NetworkModel::updateFromWimaxNsp(NetworkModelItem* item, const NetworkManager::WimaxNsp::Ptr& nsp)
-{
- item->setSignal(nsp->signalQuality());
- item->setSpecificPath(nsp->uni());
-}
-
-void NetworkModel::updateFromWirelessNetwork(NetworkModelItem* item, const NetworkManager::WirelessNetwork::Ptr& network)
-{
- // Check whether the connection is associated with some concrete AP
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnection(item->connectionPath());
- if (connection) {
- NetworkManager::WirelessSetting::Ptr wirelessSetting = connection->settings()->setting(NetworkManager::Setting::Wireless).staticCast<NetworkManager::WirelessSetting>();
- if (wirelessSetting) {
- if (!wirelessSetting->bssid().isEmpty()) {
- foreach (const NetworkManager::AccessPoint::Ptr ap, network->accessPoints()) {
- if (ap->hardwareAddress() == NetworkManager::Utils::macAddressAsString(wirelessSetting->bssid())) {
- item->setSignal(ap->signalStrength());
- item->setSpecificPath(ap->uni());
- // We need to watch this AP for signal changes
- connect(ap.data(), SIGNAL(signalStrengthChanged(int)), SLOT(accessPointSignalStrengthChanged(int)), Qt::UniqueConnection);
- }
- }
- } else {
- item->setSignal(network->signalStrength());
- item->setSpecificPath(network->referenceAccessPoint()->uni());
- }
- }
- }
-}
+++ /dev/null
-/*
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_NETWORK_MODEL_H
-#define PLASMA_NM_NETWORK_MODEL_H
-
-#include <QtCore/QAbstractListModel>
-
-#include <config.h>
-#include "networkitemslist.h"
-#include "plasmanm_export.h"
-
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/VpnConnection>
-#include <NetworkManagerQt/WirelessDevice>
-#include <NetworkManagerQt/WimaxDevice>
-#include <NetworkManagerQt/Utils>
-
-#if WITH_MODEMMANAGER_SUPPORT
-#include <ModemManagerQt/modem.h>
-#endif
-
-class PLASMA_NM_EXPORT NetworkModel : public QAbstractListModel
-{
-Q_OBJECT
-public:
- explicit NetworkModel(QObject* parent = 0);
- virtual ~NetworkModel();
-
- enum ItemRole {
- ConnectionDetailsRole = Qt::UserRole + 1,
- ConnectionIconRole,
- ConnectionPathRole,
- ConnectionStateRole,
- DeviceNameRole,
- DevicePathRole,
- DeviceStateRole,
- DuplicateRole,
- ItemUniqueNameRole,
- ItemTypeRole,
- LastUsedRole,
- LastUsedDateOnlyRole,
- NameRole,
- NspRole,
- SecurityTypeRole,
- SecurityTypeStringRole,
- SectionRole,
- SignalRole,
- SlaveRole,
- SsidRole,
- SpecificPathRole,
- TimeStampRole,
- TypeRole,
- UniRole,
- UuidRole,
- VpnState,
- };
-
- int rowCount(const QModelIndex& parent) const;
- QVariant data(const QModelIndex& index, int role) const;
-
-public Q_SLOTS:
- void onItemUpdated();
- void updateItems();
-
-private Q_SLOTS:
- void accessPointSignalStrengthChanged(int signal);
- void activeConnectionAdded(const QString& activeConnection);
- void activeConnectionRemoved(const QString& activeConnection);
- void activeConnectionStateChanged(NetworkManager::ActiveConnection::State state);
- void activeVpnConnectionStateChanged(NetworkManager::VpnConnection::State state,NetworkManager::VpnConnection::StateChangeReason reason);
- void availableConnectionAppeared(const QString& connection);
- void availableConnectionDisappeared(const QString& connection);
- void connectionAdded(const QString& connection);
- void connectionRemoved(const QString& connection);
- void connectionUpdated();
- void deviceAdded(const QString& device);
- void deviceRemoved(const QString& device);
- void deviceStateChanged(NetworkManager::Device::State state, NetworkManager::Device::State oldState, NetworkManager::Device::StateChangeReason reason);
-#if WITH_MODEMMANAGER_SUPPORT
- void gsmNetworkAccessTechnologyChanged(ModemManager::Modem::AccessTechnologies technology);
- void gsmNetworkCurrentModesChanged();
- void gsmNetworkSignalQualityChanged(uint signal);
-#endif
- void ipConfigChanged();
- void ipInterfaceChanged();
- void statusChanged(NetworkManager::Status status);
- void wimaxNspAppeared(const QString& nsp);
- void wimaxNspDisappeared(const QString& nsp);
- void wimaxNspSignalChanged(uint signal);
- void wirelessNetworkAppeared(const QString& ssid);
- void wirelessNetworkDisappeared(const QString& ssid);
- void wirelessNetworkSignalChanged(int signal);
- void wirelessNetworkReferenceApChanged(const QString& accessPoint);
-
- void initialize();
-
-private:
- NetworkItemsList m_list;
-
- void addActiveConnection(const NetworkManager::ActiveConnection::Ptr& activeConnection);
- void addAvailableConnection(const QString& connection, const NetworkManager::Device::Ptr& device);
- void addConnection(const NetworkManager::Connection::Ptr& connection);
- void addDevice(const NetworkManager::Device::Ptr& device);
- void addWimaxNsp(const NetworkManager::WimaxNsp::Ptr& nsp, const NetworkManager::WimaxDevice::Ptr& device);
- void addWirelessNetwork(const NetworkManager::WirelessNetwork::Ptr& network, const NetworkManager::WirelessDevice::Ptr& device);
- void checkAndCreateDuplicate(const QString& connection, const NetworkManager::Device::Ptr& device);
- void initializeSignals();
- void initializeSignals(const NetworkManager::ActiveConnection::Ptr& activeConnection);
- void initializeSignals(const NetworkManager::Connection::Ptr& connection);
- void initializeSignals(const NetworkManager::Device::Ptr& device);
- void initializeSignals(const NetworkManager::WimaxNsp::Ptr& nsp);
- void initializeSignals(const NetworkManager::WirelessNetwork::Ptr& network);
- void updateItem(NetworkModelItem * item);
- void updateFromWimaxNsp(NetworkModelItem * item, const NetworkManager::WimaxNsp::Ptr& nsp);
- void updateFromWirelessNetwork(NetworkModelItem * item, const NetworkManager::WirelessNetwork::Ptr& network);
-
- NetworkManager::Utils::WirelessSecurityType alternativeWirelessSecurity(const NetworkManager::Utils::WirelessSecurityType type);
-};
-
-#endif // PLASMA_NM_NETWORK_MODEL_H
+++ /dev/null
-/*
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "networkmodelitem.h"
-#include "globalconfig.h"
-#include "uiutils.h"
-
-#include <NetworkManagerQt/BluetoothDevice>
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/ModemDevice>
-#include <NetworkManagerQt/Settings>
-#include <NetworkManagerQt/Utils>
-#include <NetworkManagerQt/VpnConnection>
-#include <NetworkManagerQt/VpnSetting>
-#include <NetworkManagerQt/WimaxDevice>
-#include <NetworkManagerQt/WiredDevice>
-#include <NetworkManagerQt/WirelessDevice>
-#include <NetworkManagerQt/WirelessSetting>
-
-#include <KGlobal>
-#include <KLocale>
-#include <KLocalizedString>
-
-#include <Plasma/DataEngineManager>
-
-#if WITH_MODEMMANAGER_SUPPORT
-#include <ModemManagerQt/manager.h>
-#include <ModemManagerQt/modem.h>
-#endif
-
-NetworkModelItem::NetworkModelItem(QObject* parent)
- : QObject(parent)
- , m_connectionState(NetworkManager::ActiveConnection::Deactivated)
- , m_deviceState(NetworkManager::Device::UnknownState)
- , m_duplicate(false)
- , m_mode(NetworkManager::WirelessSetting::Infrastructure)
- , m_securityType(NetworkManager::Utils::None)
- , m_signal(0)
- , m_slave(false)
- , m_type(NetworkManager::ConnectionSettings::Unknown)
- , m_vpnState(NetworkManager::VpnConnection::Unknown)
-{
-}
-
-NetworkModelItem::NetworkModelItem(const NetworkModelItem* item, QObject* parent)
- : QObject(parent)
- , m_connectionPath(item->connectionPath())
- , m_connectionState(NetworkManager::ActiveConnection::Deactivated)
- , m_duplicate(true)
- , m_mode(item->mode())
- , m_name(item->name())
- , m_securityType(item->securityType())
- , m_slave(item->slave())
- , m_ssid(item->ssid())
- , m_timestamp(item->timestamp())
- , m_type(item->type())
- , m_uuid(item->uuid())
- , m_vpnState(NetworkManager::VpnConnection::Unknown)
-{
-}
-
-NetworkModelItem::~NetworkModelItem()
-{
-}
-
-QString NetworkModelItem::activeConnectionPath() const
-{
- return m_activeConnectionPath;
-}
-
-void NetworkModelItem::setActiveConnectionPath(const QString& path)
-{
- m_activeConnectionPath = path;
-}
-
-QString NetworkModelItem::connectionPath() const
-{
- return m_connectionPath;
-}
-
-void NetworkModelItem::setConnectionPath(const QString& path)
-{
- m_connectionPath = path;
-}
-
-NetworkManager::ActiveConnection::State NetworkModelItem::connectionState() const
-{
- return m_connectionState;
-}
-
-void NetworkModelItem::setConnectionState(NetworkManager::ActiveConnection::State state)
-{
- m_connectionState = state;
-}
-
-QString NetworkModelItem::details() const
-{
- return m_details;
-}
-
-QString NetworkModelItem::devicePath() const
-{
- return m_devicePath;
-}
-
-QString NetworkModelItem::deviceName() const
-{
- return m_deviceName;
-}
-
-void NetworkModelItem::setDeviceName(const QString& name)
-{
- m_deviceName = name;
-}
-
-void NetworkModelItem::setDevicePath(const QString& path)
-{
- m_devicePath = path;
-}
-
-QString NetworkModelItem::deviceState() const
-{
- return UiUtils::connectionStateToString(m_deviceState);
-}
-
-void NetworkModelItem::setDeviceState(const NetworkManager::Device::State state)
-{
- m_deviceState = state;
-}
-
-bool NetworkModelItem::duplicate() const
-{
- return m_duplicate;
-}
-
-QString NetworkModelItem::icon() const
-{
- switch (m_type) {
- case NetworkManager::ConnectionSettings::Adsl:
- return "network-mobile-100";
- break;
- case NetworkManager::ConnectionSettings::Bluetooth:
- if (connectionState() == NetworkManager::ActiveConnection::Activated) {
- return "network-bluetooth-activated";
- } else {
- return "network-bluetooth";
- }
- break;
- case NetworkManager::ConnectionSettings::Bond:
- break;
- case NetworkManager::ConnectionSettings::Bridge:
- break;
- case NetworkManager::ConnectionSettings::Cdma:
- case NetworkManager::ConnectionSettings::Gsm:
- if (m_signal == 0 ) {
- return "network-mobile-0";
- } else if (m_signal < 20) {
- return "network-mobile-20";
- } else if (m_signal < 40) {
- return "network-mobile-40";
- } else if (m_signal < 60) {
- return "network-mobile-60";
- } else if (m_signal < 80) {
- return "network-mobile-80";
- } else {
- return "network-mobile-100";
- }
- break;
- case NetworkManager::ConnectionSettings::Infiniband:
- break;
- case NetworkManager::ConnectionSettings::OLPCMesh:
- break;
- case NetworkManager::ConnectionSettings::Pppoe:
- return "network-mobile-100";
- break;
- case NetworkManager::ConnectionSettings::Vlan:
- break;
- case NetworkManager::ConnectionSettings::Vpn:
- return "network-vpn";
- break;
- case NetworkManager::ConnectionSettings::Wimax:
- if (m_signal == 0 ) {
- return "network-wireless-0";
- } else if (m_signal < 20) {
- return "network-wireless-20";
- } else if (m_signal < 40) {
- return "network-wireless-40";
- } else if (m_signal < 60) {
- return "network-wireless-60";
- } else if (m_signal < 80) {
- return "network-wireless-80";
- } else {
- return "network-wireless-100";
- }
- break;
- case NetworkManager::ConnectionSettings::Wired:
- if (connectionState() == NetworkManager::ActiveConnection::Activated) {
- return "network-wired-activated";
- } else {
- return "network-wired";
- }
- break;
- case NetworkManager::ConnectionSettings::Wireless:
- if (m_signal == 0 ) {
- if (m_mode == NetworkManager::WirelessSetting::Adhoc || m_mode == NetworkManager::WirelessSetting::Ap) {
- return (m_securityType <= NetworkManager::Utils::None) ? "network-wireless-100" : "network-wireless-100-locked";
- }
- return (m_securityType <= NetworkManager::Utils::None) ? "network-wireless-0" : "network-wireless-0-locked";
- } else if (m_signal < 20) {
- return (m_securityType <= NetworkManager::Utils::None) ? "network-wireless-20" : "network-wireless-20-locked";
- } else if (m_signal < 40) {
- return (m_securityType <= NetworkManager::Utils::None) ? "network-wireless-40" : "network-wireless-40-locked";
- } else if (m_signal < 60) {
- return (m_securityType <= NetworkManager::Utils::None) ? "network-wireless-60" : "network-wireless-60-locked";
- } else if (m_signal < 80) {
- return (m_securityType <= NetworkManager::Utils::None) ? "network-wireless-80" : "network-wireless-80-locked";
- } else {
- return (m_securityType <= NetworkManager::Utils::None) ? "network-wireless-100" : "network-wireless-100-locked";
- }
- break;
- default:
- break;
- }
-
- if (connectionState() == NetworkManager::ActiveConnection::Activated) {
- return "network-wired-activated";
- } else {
- return "network-wired";
- }
-}
-
-NetworkModelItem::ItemType NetworkModelItem::itemType() const
-{
- if (!m_devicePath.isEmpty() ||
- m_type == NetworkManager::ConnectionSettings::Bond ||
- m_type == NetworkManager::ConnectionSettings::Bridge ||
- m_type == NetworkManager::ConnectionSettings::Vlan ||
- ((NetworkManager::status() == NetworkManager::Connected ||
- NetworkManager::status() == NetworkManager::ConnectedLinkLocal ||
- NetworkManager::status() == NetworkManager::ConnectedSiteOnly) && m_type == NetworkManager::ConnectionSettings::Vpn)) {
- if (m_connectionPath.isEmpty() && m_type == NetworkManager::ConnectionSettings::Wireless) {
- return NetworkModelItem::AvailableAccessPoint;
- } else if (m_connectionPath.isEmpty() && m_type == NetworkManager::ConnectionSettings::Wimax) {
- return NetworkModelItem::AvailableNsp;
- } else {
- return NetworkModelItem::AvailableConnection;
- }
- }
- return NetworkModelItem::UnavailableConnection;
-}
-
-NetworkManager::WirelessSetting::NetworkMode NetworkModelItem::mode() const
-{
- return m_mode;
-}
-
-void NetworkModelItem::setMode(const NetworkManager::WirelessSetting::NetworkMode mode)
-{
- m_mode = mode;
-}
-
-QString NetworkModelItem::name() const
-{
- return m_name;
-}
-
-void NetworkModelItem::setName(const QString& name)
-{
- m_name = name;
-}
-
-QString NetworkModelItem::nsp() const
-{
- return m_nsp;
-}
-
-void NetworkModelItem::setNsp(const QString& nsp)
-{
- m_nsp = nsp;
-}
-
-QString NetworkModelItem::originalName() const
-{
- if (m_deviceName.isEmpty()) {
- return m_name;
- }
- return m_name + " (" + m_deviceName + ')';
-}
-
-QString NetworkModelItem::sectionType() const
-{
- if (m_connectionState == NetworkManager::ActiveConnection::Activated) {
- return i18n("Active connections");
- } else {
- return i18n("Available connections");
- }
-}
-
-NetworkManager::Utils::WirelessSecurityType NetworkModelItem::securityType() const
-{
- return m_securityType;
-}
-
-void NetworkModelItem::setSecurityType(NetworkManager::Utils::WirelessSecurityType type)
-{
- m_securityType = type;
-}
-
-int NetworkModelItem::signal() const
-{
- return m_signal;
-}
-
-void NetworkModelItem::setSignal(int signal)
-{
- m_signal = signal;
-}
-
-bool NetworkModelItem::slave() const
-{
- return m_slave;
-}
-
-void NetworkModelItem::setSlave(bool slave)
-{
- m_slave = slave;
-}
-
-QString NetworkModelItem::specificPath() const
-{
- return m_specificPath;
-}
-
-void NetworkModelItem::setSpecificPath(const QString& path)
-{
- m_specificPath = path;
-}
-
-QString NetworkModelItem::ssid() const
-{
- return m_ssid;
-}
-
-void NetworkModelItem::setSsid(const QString& ssid)
-{
- m_ssid = ssid;
-}
-
-NetworkManager::ConnectionSettings::ConnectionType NetworkModelItem::type() const
-{
- return m_type;
-}
-
-QDateTime NetworkModelItem::timestamp() const
-{
- return m_timestamp;
-}
-
-void NetworkModelItem::setTimestamp(const QDateTime& date)
-{
- m_timestamp = date;
-}
-
-void NetworkModelItem::setType(NetworkManager::ConnectionSettings::ConnectionType type)
-{
- m_type = type;
-}
-
-QString NetworkModelItem::uni() const
-{
- if (m_type == NetworkManager::ConnectionSettings::Wireless && m_uuid.isEmpty()) {
- return m_ssid + '%' + m_devicePath;
- } else if (m_type == NetworkManager::ConnectionSettings::Wimax && m_uuid.isEmpty()) {
- return m_nsp + '%' + m_devicePath;
- } else {
- return m_connectionPath + '%' + m_devicePath;
- }
-}
-
-QString NetworkModelItem::uuid() const
-{
- return m_uuid;
-}
-
-void NetworkModelItem::setUuid(const QString& uuid)
-{
- m_uuid = uuid;
-}
-
-QString NetworkModelItem::vpnState() const
-{
- return UiUtils::vpnConnectionStateToString(m_vpnState);
-}
-
-void NetworkModelItem::setVpnState(NetworkManager::VpnConnection::State state)
-{
- m_vpnState = state;
-}
-
-bool NetworkModelItem::operator==(const NetworkModelItem* item) const
-{
- if (!item->uuid().isEmpty() && !uuid().isEmpty()) {
- if (item->devicePath() == devicePath() && item->uuid() == uuid()) {
- return true;
- }
- } else if (item->type() == NetworkManager::ConnectionSettings::Wireless && type() == NetworkManager::ConnectionSettings::Wireless) {
- if (item->ssid() == ssid() && item->devicePath() == devicePath()) {
- return true;
- }
- } else if (item->type() == NetworkManager::ConnectionSettings::Wimax && type() == NetworkManager::ConnectionSettings::Wimax) {
- if (item->nsp() == nsp() && item->devicePath() == devicePath()) {
- return true;
- }
- }
-
- return false;
-}
-
-void NetworkModelItem::updateDetails()
-{
- if (itemType() == NetworkModelItem::UnavailableConnection) {
- return;
- }
-
- m_details = "<qt><table>";
-
- QStringList detailsList = GlobalConfig().detailKeys();
-
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnection(m_connectionPath);
- NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(m_devicePath);
-
- m_details += UiUtils::connectionDetails(device, connection, detailsList);
-
- if (m_type == NetworkManager::ConnectionSettings::Bluetooth) {
- NetworkManager::BluetoothDevice::Ptr btDevice = device.objectCast<NetworkManager::BluetoothDevice>();
- m_details += UiUtils::bluetoothDetails(btDevice, detailsList);
- } else if (m_type == NetworkManager::ConnectionSettings::Gsm || m_type == NetworkManager::ConnectionSettings::Cdma) {
- NetworkManager::ModemDevice::Ptr modemDevice = device.objectCast<NetworkManager::ModemDevice>();
- m_details += UiUtils::modemDetails(modemDevice, detailsList);
- } else if (m_type == NetworkManager::ConnectionSettings::Wimax) {
- NetworkManager::WimaxNsp::Ptr wimaxNsp;
- NetworkManager::WimaxDevice::Ptr wimaxDevice = device.objectCast<NetworkManager::WimaxDevice>();
- wimaxNsp = wimaxDevice->findNsp(m_specificPath);
- if (wimaxDevice && wimaxNsp) {
- m_details += UiUtils::wimaxDetails(wimaxDevice, wimaxNsp, connection, detailsList);
- }
- } else if (m_type == NetworkManager::ConnectionSettings::Wired) {
- NetworkManager::WiredDevice::Ptr wiredDevice;
- if (device) {
- wiredDevice = device.objectCast<NetworkManager::WiredDevice>();
- }
- m_details += UiUtils::wiredDetails(wiredDevice, connection, detailsList);
- } else if (m_type == NetworkManager::ConnectionSettings::Wireless) {
- NetworkManager::WirelessDevice::Ptr wirelessDevice;
- if (device) {
- wirelessDevice = device.objectCast<NetworkManager::WirelessDevice>();
- }
- NetworkManager::AccessPoint::Ptr ap;
- if (wirelessDevice) {
- ap = wirelessDevice->findAccessPoint(m_specificPath);
- }
- m_details += UiUtils::wirelessDetails(wirelessDevice, ap, connection, detailsList);
- } else if (m_type == NetworkManager::ConnectionSettings::Vpn) {
- NetworkManager::ActiveConnection::Ptr active = NetworkManager::findActiveConnection(m_activeConnectionPath);
- NetworkManager::Connection::Ptr connection = NetworkManager::findConnection(m_connectionPath);
- NetworkManager::ConnectionSettings::Ptr connectionSettings;
- NetworkManager::VpnSetting::Ptr vpnSetting;
- NetworkManager::VpnConnection::Ptr vpnConnection;
-
- if (connection) {
- connectionSettings = connection->settings();
- }
- if (connectionSettings) {
- vpnSetting = connectionSettings->setting(NetworkManager::Setting::Vpn).dynamicCast<NetworkManager::VpnSetting>();
- }
-
- if (active) {
- vpnConnection = NetworkManager::VpnConnection::Ptr(new NetworkManager::VpnConnection(active->path()), &QObject::deleteLater);
- }
- m_details += UiUtils::vpnDetails(vpnConnection, vpnSetting, detailsList);
- }
-
- m_details += "</table></qt>";
-}
+++ /dev/null
-/*
- Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_MODEL_NETWORK_MODEL_ITEM_H
-#define PLASMA_NM_MODEL_NETWORK_MODEL_ITEM_H
-
-#include <NetworkManagerQt/ActiveConnection>
-#include <NetworkManagerQt/Connection>
-#include <NetworkManagerQt/ConnectionSettings>
-#include <NetworkManagerQt/Device>
-#include <NetworkManagerQt/Utils>
-
-#include "networkmodel.h"
-#include "plasmanm_export.h"
-
-class PLASMA_NM_EXPORT NetworkModelItem : public QObject
-{
-Q_OBJECT
-public:
-
- enum ItemType { UnavailableConnection, AvailableConnection, AvailableAccessPoint, AvailableNsp };
-
- explicit NetworkModelItem(QObject * parent = 0);
- explicit NetworkModelItem(const NetworkModelItem * item, QObject* parent = 0);
- virtual ~NetworkModelItem();
-
- QString activeConnectionPath() const;
- void setActiveConnectionPath(const QString& path);
-
- QString connectionPath() const;
- void setConnectionPath(const QString& path);
-
- NetworkManager::ActiveConnection::State connectionState() const;
- void setConnectionState(NetworkManager::ActiveConnection::State state);
-
- QString details() const;
-
- QString deviceName() const;
- void setDeviceName(const QString& name);
-
- QString devicePath() const;
- void setDevicePath(const QString& path);
-
- QString deviceState() const;
- void setDeviceState(const NetworkManager::Device::State state);
-
- bool duplicate() const;
-
- QString icon() const;
-
- ItemType itemType() const;
-
- NetworkManager::WirelessSetting::NetworkMode mode() const;
- void setMode(const NetworkManager::WirelessSetting::NetworkMode mode);
-
- QString name() const;
- void setName(const QString& name);
-
- QString nsp() const;
- void setNsp(const QString& nsp);
-
- QString originalName() const;
-
- QString sectionType() const;
-
- NetworkManager::Utils::WirelessSecurityType securityType() const;
- void setSecurityType(NetworkManager::Utils::WirelessSecurityType type);
-
- int signal() const;
- void setSignal(int signal);
-
- bool slave() const;
- void setSlave(bool slave);
-
- QString specificPath() const;
- void setSpecificPath(const QString& path);
-
- QString ssid() const;
- void setSsid(const QString& ssid);
-
- QDateTime timestamp() const;
- void setTimestamp(const QDateTime& date);
-
- NetworkManager::ConnectionSettings::ConnectionType type() const;
- void setType(NetworkManager::ConnectionSettings::ConnectionType type);
-
- QString uni() const;
-
- QString uuid() const;
- void setUuid(const QString& uuid);
-
- QString vpnState() const;
- void setVpnState(NetworkManager::VpnConnection::State state);
-
- bool operator==(const NetworkModelItem * item) const;
-
-public Q_SLOTS:
- void updateDetails();
-
-private:
- QString m_activeConnectionPath;
- QString m_connectionPath;
- NetworkManager::ActiveConnection::State m_connectionState;
- QString m_devicePath;
- QString m_deviceName;
- NetworkManager::Device::State m_deviceState;
- QString m_details;
- bool m_duplicate;
- NetworkManager::WirelessSetting::NetworkMode m_mode;
- QString m_name;
- QString m_nsp;
- NetworkManager::Utils::WirelessSecurityType m_securityType;
- int m_signal;
- bool m_slave;
- QString m_specificPath;
- QString m_ssid;
- QDateTime m_timestamp;
- NetworkManager::ConnectionSettings::ConnectionType m_type;
- QString m_uuid;
- NetworkManager::VpnConnection::State m_vpnState;
-};
-
-#endif // PLASMA_NM_MODEL_NETWORK_MODEL_ITEM_H
+++ /dev/null
-/* This file is part of the KDE project
- Copyright (C) 2007 David Faure <faure@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef PLASMA_NM_EXPORT_H
-#define PLASMA_NM_EXPORT_H
-
-/* needed for KDE_EXPORT and KDE_IMPORT macros */
-#include <kdemacros.h>
-
-#ifndef PLASMA_NM_EXPORT
-# if defined(MAKE_PLASMA_NM_LIB)
- /* We are building this library */
-# define PLASMA_NM_EXPORT KDE_EXPORT
-# else
- /* We are using this library */
-# define PLASMA_NM_EXPORT KDE_IMPORT
-# endif
-#endif
-
-# ifndef PLASMA_NM_EXPORT_DEPRECATED
-# define PLASMA_NM_EXPORT_DEPRECATED KDE_DEPRECATED KDEPIM_EXPORT
-# endif
-
-#endif
-
+++ /dev/null
-/*
- Copyright 2008-2010 Sebastian Kügler <sebas@kde.org>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-// Own
-#include "uiutils.h"
-
-// KDE
-#include <KDebug>
-#include <KLocale>
-#include <KGlobal>
-
-#include <NetworkManagerQt/BluetoothDevice>
-#include <NetworkManagerQt/Manager>
-#include <NetworkManagerQt/Device>
-#include <NetworkManagerQt/AccessPoint>
-#include <NetworkManagerQt/WiredDevice>
-#include <NetworkManagerQt/WirelessDevice>
-#include <NetworkManagerQt/WirelessSetting>
-
-#if WITH_MODEMMANAGER_SUPPORT
-#include <ModemManagerQt/manager.h>
-#include <ModemManagerQt/modem.h>
-#include <ModemManagerQt/modemdevice.h>
-#include <ModemManagerQt/modem3gpp.h>
-#include <ModemManagerQt/modemcdma.h>
-#endif
-
-// Qt
-#include <QSizeF>
-#include <QHostAddress>
-
-#include <QString>
-
-using namespace NetworkManager;
-
-QString UiUtils::interfaceTypeLabel(const NetworkManager::Device::Type type, const NetworkManager::Device::Ptr iface)
-{
- QString deviceText;
- switch (type) {
- case NetworkManager::Device::Ethernet:
- deviceText = i18nc("title of the interface widget in nm's popup", "Wired Ethernet");
- break;
- case NetworkManager::Device::Wifi:
- deviceText = i18nc("title of the interface widget in nm's popup", "Wireless 802.11");
- break;
- case NetworkManager::Device::Bluetooth:
- deviceText = i18nc("title of the interface widget in nm's popup", "Bluetooth");
- break;
- case NetworkManager::Device::Wimax:
- deviceText = i18nc("title of the interface widget in nm's popup", "WiMAX");
- break;
- case NetworkManager::Device::InfiniBand:
- deviceText = i18nc("title of the interface widget in nm's popup", "Infiniband");
- break;
- case NetworkManager::Device::Adsl:
- deviceText = i18nc("title of the interface widget in nm's popup", "ADSL");
- break;
- case NetworkManager::Device::Bond:
- deviceText = i18nc("title of the interface widget in nm's popup", "Virtual (bond)");
- break;
- case NetworkManager::Device::Bridge:
- deviceText = i18nc("title of the interface widget in nm's popup", "Virtual (bridge)");
- break;
- case NetworkManager::Device::Vlan:
- deviceText = i18nc("title of the interface widget in nm's popup", "Virtual (vlan)");
- break;
- case NetworkManager::Device::Modem: {
- const NetworkManager::ModemDevice::Ptr nmModemIface = iface.objectCast<NetworkManager::ModemDevice>();
- if (nmModemIface) {
- switch(modemSubType(nmModemIface->currentCapabilities())) {
- case NetworkManager::ModemDevice::Pots:
- deviceText = i18nc("title of the interface widget in nm's popup", "Serial Modem");
- break;
- case NetworkManager::ModemDevice::GsmUmts:
- case NetworkManager::ModemDevice::CdmaEvdo:
- case NetworkManager::ModemDevice::Lte:
- deviceText = i18nc("title of the interface widget in nm's popup", "Mobile Broadband");
- break;
- case NetworkManager::ModemDevice::NoCapability:
- kWarning() << "Unhandled modem sub type: NetworkManager::ModemDevice::NoCapability";
- break;
- }
- }
- }
- break;
- default:
- deviceText = i18nc("title of the interface widget in nm's popup", "Wired Ethernet");
- break;
- }
- return deviceText;
-}
-
-QString UiUtils::iconAndTitleForConnectionSettingsType(NetworkManager::ConnectionSettings::ConnectionType type, QString &title)
-{
- QString text;
- QString icon = "network-wired";
- switch (type) {
- case ConnectionSettings::Adsl:
- text = i18n("ADSL");
- icon = "modem";
- break;
- case ConnectionSettings::Pppoe:
- text = i18n("DSL");
- icon = "modem";
- break;
- case ConnectionSettings::Bluetooth:
- text = i18n("Bluetooth");
- icon = "preferences-system-bluetooth";
- break;
- case ConnectionSettings::Bond:
- text = i18n("Bond");
- break;
- case ConnectionSettings::Bridge:
- text = i18n("Bridge");
- break;
- case ConnectionSettings::Gsm:
- case ConnectionSettings::Cdma:
- text = i18n("Mobile broadband");
- icon = "phone";
- break;
- case ConnectionSettings::Infiniband:
- text = i18n("Infiniband");
- break;
- case ConnectionSettings::OLPCMesh:
- text = i18n("Olpc mesh");
- break;
- case ConnectionSettings::Vlan:
- text = i18n("VLAN");
- break;
- case ConnectionSettings::Vpn:
- text = i18n("VPN");
- icon = "secure-card";
- break;
- case ConnectionSettings::Wimax:
- text = i18n("WiMAX");
- icon = "network-wireless";
- break;
- case ConnectionSettings::Wired:
- text = i18n("Wired");
- icon = "network-wired";
- break;
- case ConnectionSettings::Wireless:
- text = i18n("Wireless");
- icon = "network-wireless";
- break;
- default:
- text = i18n("Unknown connection type");
- break;
- }
- title = text;
- return icon;
-}
-
-QString UiUtils::prettyInterfaceName(NetworkManager::Device::Type type, const QString &interfaceName)
-{
- QString ret;
- switch (type) {
- case NetworkManager::Device::Wifi:
- ret = i18n("Wireless Interface (%1)", interfaceName);
- break;
- case NetworkManager::Device::Ethernet:
- ret = i18n("Wired Interface (%1)", interfaceName);
- break;
- case NetworkManager::Device::Bluetooth:
- ret = i18n("Bluetooth (%1)", interfaceName);
- break;
- case NetworkManager::Device::Modem:
- ret = i18n("Modem (%1)", interfaceName);
- break;
- case NetworkManager::Device::Adsl:
- ret = i18n("ADSL (%1)", interfaceName);
- break;
- case NetworkManager::Device::Vlan:
- ret = i18n("VLan (%1)", interfaceName);
- break;
- case NetworkManager::Device::Bridge:
- ret = i18n("Bridge (%1)", interfaceName);
- break;
- default:
- ret = interfaceName;
- }
- return ret;
-}
-
-QString UiUtils::connectionStateToString(NetworkManager::Device::State state, const QString &connectionName)
-{
- QString stateString;
- switch (state) {
- case NetworkManager::Device::UnknownState:
- stateString = i18nc("description of unknown network interface state", "Unknown");
- break;
- case NetworkManager::Device::Unmanaged:
- stateString = i18nc("description of unmanaged network interface state", "Unmanaged");
- break;
- case NetworkManager::Device::Unavailable:
- stateString = i18nc("description of unavailable network interface state", "Unavailable");
- break;
- case NetworkManager::Device::Disconnected:
- stateString = i18nc("description of unconnected network interface state", "Not connected");
- break;
- case NetworkManager::Device::Preparing:
- stateString = i18nc("description of preparing to connect network interface state", "Preparing to connect");
- break;
- case NetworkManager::Device::ConfiguringHardware:
- stateString = i18nc("description of configuring hardware network interface state", "Configuring interface");
- break;
- case NetworkManager::Device::NeedAuth:
- stateString = i18nc("description of waiting for authentication network interface state", "Waiting for authorization");
- break;
- case NetworkManager::Device::ConfiguringIp:
- stateString = i18nc("network interface doing dhcp request in most cases", "Setting network address");
- break;
- case NetworkManager::Device::CheckingIp:
- stateString = i18nc("is other action required to fully connect? captive portals, etc.", "Checking further connectivity");
- break;
- case NetworkManager::Device::WaitingForSecondaries:
- stateString = i18nc("a secondary connection (e.g. VPN) has to be activated first to continue", "Waiting for a secondary connection");
- break;
- case NetworkManager::Device::Activated:
- if (connectionName.isEmpty()) {
- stateString = i18nc("network interface connected state label", "Connected");
- } else {
- stateString = i18nc("network interface connected state label", "Connected to %1", connectionName);
- }
- break;
- case NetworkManager::Device::Deactivating:
- stateString = i18nc("network interface disconnecting state label", "Deactivating connection");
- break;
- case NetworkManager::Device::Failed:
- stateString = i18nc("network interface connection failed state label", "Connection Failed");
- break;
- default:
- stateString = i18nc("interface state", "Error: Invalid state");
- }
- return stateString;
-}
-
-QString UiUtils::vpnConnectionStateToString(VpnConnection::State state)
-{
- QString stateString;
- switch (state) {
- case VpnConnection::Unknown:
- stateString = i18nc("The state of the VPN connection is unknown", "Unknown");
- break;
- case VpnConnection::Prepare:
- stateString = i18nc("The VPN connection is preparing to connect", "Preparing to connect");
- break;
- case VpnConnection::NeedAuth:
- stateString = i18nc("The VPN connection needs authorization credentials", "Needs authorization");
- break;
- case VpnConnection::Connecting:
- stateString = i18nc("The VPN connection is being established", "Connecting");
- break;
- case VpnConnection::GettingIpConfig:
- stateString = i18nc("The VPN connection is getting an IP address", "Setting network address");
- break;
- case VpnConnection::Activated:
- stateString = i18nc("The VPN connection is active", "Activated");
- break;
- case VpnConnection::Failed:
- stateString = i18nc("The VPN connection failed", "Failed");
- break;
- case VpnConnection::Disconnected:
- stateString = i18nc("The VPN connection is disconnected", "Failed");
- break;
- default:
- stateString = i18nc("interface state", "Error: Invalid state"); }
- return stateString;
-}
-
-QString UiUtils::operationModeToString(NetworkManager::WirelessDevice::OperationMode mode)
-{
- QString modeString;
- switch (mode) {
- case NetworkManager::WirelessDevice::WirelessDevice::Unknown:
- modeString = i18nc("wireless network operation mode", "Unknown");
- break;
- case NetworkManager::WirelessDevice::Adhoc:
- modeString = i18nc("wireless network operation mode", "Adhoc");
- break;
- case NetworkManager::WirelessDevice::WirelessDevice::Infra:
- modeString = i18nc("wireless network operation mode", "Infrastructure");
- break;
- case NetworkManager::WirelessDevice::WirelessDevice::ApMode:
- modeString = i18nc("wireless network operation mode", "Access point");
- break;
- default:
- modeString = I18N_NOOP("INCORRECT MODE FIX ME");
- }
- return modeString;
-}
-
-QStringList UiUtils::wpaFlagsToStringList(NetworkManager::AccessPoint::WpaFlags flags)
-{
- /* for testing purposes
- flags = NetworkManager::AccessPoint::PairWep40
- | NetworkManager::AccessPoint::PairWep104
- | NetworkManager::AccessPoint::PairTkip
- | NetworkManager::AccessPoint::PairCcmp
- | NetworkManager::AccessPoint::GroupWep40
- | NetworkManager::AccessPoint::GroupWep104
- | NetworkManager::AccessPoint::GroupTkip
- | NetworkManager::AccessPoint::GroupCcmp
- | NetworkManager::AccessPoint::KeyMgmtPsk
- | NetworkManager::AccessPoint::KeyMgmt8021x; */
-
- QStringList flagList;
-
- if (flags.testFlag(NetworkManager::AccessPoint::PairWep40))
- flagList.append(i18nc("wireless network cipher", "Pairwise WEP40"));
- if (flags.testFlag(NetworkManager::AccessPoint::PairWep104))
- flagList.append(i18nc("wireless network cipher", "Pairwise WEP104"));
- if (flags.testFlag(NetworkManager::AccessPoint::PairTkip))
- flagList.append(i18nc("wireless network cipher", "Pairwise TKIP"));
- if (flags.testFlag(NetworkManager::AccessPoint::PairCcmp))
- flagList.append(i18nc("wireless network cipher", "Pairwise CCMP"));
- if (flags.testFlag(NetworkManager::AccessPoint::GroupWep40))
- flagList.append(i18nc("wireless network cipher", "Group WEP40"));
- if (flags.testFlag(NetworkManager::AccessPoint::GroupWep104))
- flagList.append(i18nc("wireless network cipher", "Group WEP104"));
- if (flags.testFlag(NetworkManager::AccessPoint::GroupTkip))
- flagList.append(i18nc("wireless network cipher", "Group TKIP"));
- if (flags.testFlag(NetworkManager::AccessPoint::GroupCcmp))
- flagList.append(i18nc("wireless network cipher", "Group CCMP"));
- if (flags.testFlag(NetworkManager::AccessPoint::KeyMgmtPsk))
- flagList.append(i18nc("wireless network cipher", "PSK"));
- if (flags.testFlag(NetworkManager::AccessPoint::KeyMgmt8021x))
- flagList.append(i18nc("wireless network cipher", "802.1x"));
-
- return flagList;
-}
-
-
-QString UiUtils::connectionSpeed(double bitrate)
-{
- QString out;
- if (bitrate < 1000) {
- out = i18nc("connection speed", "<numid>%1</numid> Bit/s", bitrate);
- } else if (bitrate < 1000000) {
- out = i18nc("connection speed", "<numid>%1</numid> MBit/s", bitrate/1000);
- } else {
- out = i18nc("connection speed", "<numid>%1</numid> GBit/s", bitrate/1000000);
- }
- return out;
-}
-
-QString UiUtils::wirelessBandToString(NetworkManager::WirelessSetting::FrequencyBand band)
-{
- switch (band) {
- case NetworkManager::WirelessSetting::Automatic:
- return QLatin1String("automatic");
- break;
- case NetworkManager::WirelessSetting::A:
- return QLatin1String("a");
- break;
- case NetworkManager::WirelessSetting::Bg:
- return QLatin1String("b/g");
- break;
- }
-
- return QString();
-}
-
-#if WITH_MODEMMANAGER_SUPPORT
-QString UiUtils::convertAllowedModeToString(ModemManager::Modem::ModemModes modes)
-{
- if (modes.testFlag(MM_MODEM_MODE_4G)) {
- return i18nc("Gsm modes (2G/3G/any)","LTE");
- } else if (modes.testFlag(MM_MODEM_MODE_3G)) {
- return i18nc("Gsm modes (2G/3G/any)","UMTS/HSxPA");
- } else if (modes.testFlag(MM_MODEM_MODE_2G)) {
- return i18nc("Gsm modes (2G/3G/any)","GPRS/EDGE");
- } else if (modes.testFlag(MM_MODEM_MODE_CS)) {
- return i18nc("Gsm modes (2G/3G/any)","GSM");
- } else if (modes.testFlag(MM_MODEM_MODE_ANY)) {
- return i18nc("Gsm modes (2G/3G/any)","Any");
- }
-
- return i18nc("Gsm modes (2G/3G/any)","Any");
-}
-
-QString UiUtils::convertAccessTechnologyToString(ModemManager::Modem::AccessTechnologies tech)
-{
- if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_LTE)) {
- return i18nc("Cellular access technology","LTE");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_EVDOB)) {
- return i18nc("Cellular access technology","CDMA2000 EVDO revision B");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_EVDOA)) {
- return i18nc("Cellular access technology","CDMA2000 EVDO revision A");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_EVDO0)) {
- return i18nc("Cellular access technology","CDMA2000 EVDO revision 0");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_1XRTT)) {
- return i18nc("Cellular access technology","CDMA2000 1xRTT");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_HSPA_PLUS)) {
- return i18nc("Cellular access technology","HSPA+");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_HSPA)) {
- return i18nc("Cellular access technology","HSPA");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_HSUPA)) {
- return i18nc("Cellular access technology","HSUPA");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_HSDPA)) {
- return i18nc("Cellular access technology","HSDPA");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_UMTS)) {
- return i18nc("Cellular access technology","UMTS");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_EDGE)) {
- return i18nc("Cellular access technology","EDGE");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_GPRS)) {
- return i18nc("Cellular access technology","GPRS");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_GSM_COMPACT)) {
- return i18nc("Cellular access technology","Compact GSM");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_GSM)) {
- return i18nc("Cellular access technology","GSM");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_POTS)) {
- return i18nc("Analog wireline modem","Analog");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN)) {
- return i18nc("Unknown cellular access technology","Unknown");
- } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_ANY)) {
- return i18nc("Any cellular access technology","Any");
- }
-
- return i18nc("Unknown cellular access technology","Unknown");
-}
-
-QString UiUtils::convertLockReasonToString(MMModemLock reason)
-{
- switch (reason) {
- case MM_MODEM_LOCK_NONE:
- return i18nc("possible SIM lock reason", "Modem is unlocked.");
- case MM_MODEM_LOCK_SIM_PIN:
- return i18nc("possible SIM lock reason", "SIM requires the PIN code.");
- case MM_MODEM_LOCK_SIM_PIN2:
- return i18nc("possible SIM lock reason", "SIM requires the PIN2 code.");
- case MM_MODEM_LOCK_SIM_PUK:
- return i18nc("possible SIM lock reason", "SIM requires the PUK code.");
- case MM_MODEM_LOCK_SIM_PUK2:
- return i18nc("possible SIM lock reason", "SIM requires the PUK2 code.");
- case MM_MODEM_LOCK_PH_SP_PIN:
- return i18nc("possible SIM lock reason", "Modem requires the service provider PIN code.");
- case MM_MODEM_LOCK_PH_SP_PUK:
- return i18nc("possible SIM lock reason", "Modem requires the service provider PUK code.");
- case MM_MODEM_LOCK_PH_NET_PIN:
- return i18nc("possible SIM lock reason", "Modem requires the network PIN code.");
- case MM_MODEM_LOCK_PH_NET_PUK:
- return i18nc("possible SIM lock reason", "Modem requires the network PUK code.");
- case MM_MODEM_LOCK_PH_SIM_PIN:
- return i18nc("possible SIM lock reason", "Modem requires the PIN code.");
- case MM_MODEM_LOCK_PH_CORP_PIN:
- return i18nc("possible SIM lock reason", "Modem requires the corporate PIN code.");
- case MM_MODEM_LOCK_PH_CORP_PUK:
- return i18nc("possible SIM lock reason", "Modem requires the corporate PUK code.");
- case MM_MODEM_LOCK_PH_FSIM_PIN:
- return i18nc("possible SIM lock reason", "Modem requires the PH-FSIM PIN code.");
- case MM_MODEM_LOCK_PH_FSIM_PUK:
- return i18nc("possible SIM lock reason", "Modem requires the PH-FSIM PUK code.");
- case MM_MODEM_LOCK_PH_NETSUB_PIN:
- return i18nc("possible SIM lock reason", "Modem requires the network subset PIN code.");
- case MM_MODEM_LOCK_PH_NETSUB_PUK:
- return i18nc("possible SIM lock reason", "Modem requires the network subset PUK code.");
- case MM_MODEM_LOCK_UNKNOWN:
- default:
- return i18nc("possible SIM lock reason", "Lock reason unknown.");
- }
-}
-#endif
-
-QString UiUtils::convertNspTypeToString(WimaxNsp::NetworkType type)
-{
- switch (type) {
- case WimaxNsp::Unknown: return i18nc("Unknown", "Unknown Wimax NSP type");
- case WimaxNsp::Home: return i18n("Home");
- case WimaxNsp::Partner: return i18n("Partner");
- case WimaxNsp::RoamingPartner: return i18n("Roaming partner");
- }
-
- return i18nc("Unknown", "Unknown Wimax NSP type");
-}
-
-NetworkManager::ModemDevice::Capability UiUtils::modemSubType(NetworkManager::ModemDevice::Capabilities modemCaps)
-{
- if (modemCaps & NetworkManager::ModemDevice::Lte) {
- return NetworkManager::ModemDevice::Lte;
- } else if (modemCaps & NetworkManager::ModemDevice::CdmaEvdo) {
- return NetworkManager::ModemDevice::CdmaEvdo;
- } else if (modemCaps & NetworkManager::ModemDevice::GsmUmts) {
- return NetworkManager::ModemDevice::GsmUmts;
- } else if (modemCaps & NetworkManager::ModemDevice::Pots) {
- return NetworkManager::ModemDevice::Pots;
- }
- return NetworkManager::ModemDevice::NoCapability;
-}
-
-QString UiUtils::labelFromWirelessSecurity(NetworkManager::Utils::WirelessSecurityType type)
-{
- QString tip;
- switch (type) {
- case NetworkManager::Utils::None:
- tip = i18nc("@label no security", "Insecure");
- break;
- case NetworkManager::Utils::StaticWep:
- tip = i18nc("@label WEP security", "WEP");
- break;
- case NetworkManager::Utils::Leap:
- tip = i18nc("@label LEAP security", "LEAP");
- break;
- case NetworkManager::Utils::DynamicWep:
- tip = i18nc("@label Dynamic WEP security", "Dynamic WEP");
- break;
- case NetworkManager::Utils::WpaPsk:
- tip = i18nc("@label WPA-PSK security", "WPA-PSK");
- break;
- case NetworkManager::Utils::WpaEap:
- tip = i18nc("@label WPA-EAP security", "WPA-EAP");
- break;
- case NetworkManager::Utils::Wpa2Psk:
- tip = i18nc("@label WPA2-PSK security", "WPA2-PSK");
- break;
- case NetworkManager::Utils::Wpa2Eap:
- tip = i18nc("@label WPA2-EAP security", "WPA2-EAP");
- break;
- default:
- tip = i18nc("@label unknown security", "Unknown security type");
- break;
- }
- return tip;
-}
-
-QString UiUtils::shortToolTipFromWirelessSecurity(NetworkManager::Utils::WirelessSecurityType type)
-{
- QString tip;
- switch (type) {
- case NetworkManager::Utils::None:
- tip = i18nc("@info:tooltip no security", "Insecure");
- break;
- case NetworkManager::Utils::StaticWep:
- tip = i18nc("@info:tooltip WEP security", "WEP");
- break;
- case NetworkManager::Utils::Leap:
- tip = i18nc("@info:tooltip LEAP security", "LEAP");
- break;
- case NetworkManager::Utils::DynamicWep:
- tip = i18nc("@info:tooltip Dynamic WEP security", "Dynamic WEP");
- break;
- case NetworkManager::Utils::WpaPsk:
- tip = i18nc("@info:tooltip WPA-PSK security", "WPA-PSK");
- break;
- case NetworkManager::Utils::WpaEap:
- tip = i18nc("@info:tooltip WPA-EAP security", "WPA-EAP");
- break;
- case NetworkManager::Utils::Wpa2Psk:
- tip = i18nc("@info:tooltip WPA2-PSK security", "WPA2-PSK");
- break;
- case NetworkManager::Utils::Wpa2Eap:
- tip = i18nc("@info:tooltip WPA2-EAP security", "WPA2-EAP");
- break;
- default:
- tip = i18nc("@info:tooltip unknown security", "Unknown security type");
- break;
- }
- return tip;
-}
-
-QString UiUtils::connectionDetails(const Device::Ptr& device, const Connection::Ptr& connection, const QStringList& keys)
-{
- const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
- QString details;
-
- const bool connected = device && connection && device->activeConnection() &&
- device->activeConnection()->connection() == connection && device->activeConnection()->state() == ActiveConnection::Activated;
-
- foreach (const QString& key, keys) {
- if (key == "interface:name") {
- if (device) {
- QString name;
- if (device->ipInterfaceName().isEmpty()) {
- name = device->interfaceName();
- } else {
- name = device->ipInterfaceName();
- }
- details += QString(format).arg(i18n("System name:"), name);
- }
- } else if (key == "ipv4:address") {
- if (device && device->ipV4Config().isValid() && connected) {
- if (device->ipV4Config().addresses().isEmpty()) {
- continue;
- }
- QHostAddress addr = device->ipV4Config().addresses().first().ip();
- if (!addr.isNull()) {
- details += QString(format).arg(i18n("IPv4 Address:"), addr.toString());
- }
- }
- } else if (key == "ipv4:gateway") {
- if (device && device->ipV4Config().isValid() && connected) {
- if (device->ipV4Config().addresses().isEmpty()) {
- continue;
- }
- QHostAddress addr = device->ipV4Config().addresses().first().gateway();
- if (!addr.isNull()) {
- details += QString(format).arg(i18n("IPv4 Gateway:"), addr.toString());
- }
- }
- } else if (key == "ipv6:address") {
- if (device && device->ipV6Config().isValid() && connected) {
- if (device->ipV6Config().addresses().isEmpty()) {
- continue;
- }
- QHostAddress addr = device->ipV6Config().addresses().first().ip();
- if (!addr.isNull()) {
- details += QString(format).arg(i18n("IPv6 Address:"), addr.toString());
- }
- }
- } else if (key == "ipv6:gateway") {
- if (device && device->ipV6Config().isValid() && connected) {
- if (device->ipV6Config().addresses().isEmpty()) {
- continue;
- }
- QHostAddress addr = device->ipV6Config().addresses().first().gateway();
- if (!addr.isNull() && addr.toString() != "::") {
- details += QString(format).arg(i18n("IPv6 Gateway:"), addr.toString());
- }
- }
- } else if (key == "interface:driver") {
- if (device) {
- details += QString(format).arg(i18n("Driver:"), device->driver());
- }
- }
- }
-
- return details;
-}
-
-QString UiUtils::bluetoothDetails(const BluetoothDevice::Ptr& btDevice, const QStringList& keys)
-{
- const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
- QString details;
-
- foreach (const QString& key, keys) {
- if (key == "bluetooth:name") {
- if (btDevice) {
- details += QString(format).arg(i18nc("Name", "Bluetooth name"), btDevice->name());
- }
- } else if (key == "interface:hardwareAddress") {
- if (btDevice) {
- details += QString(format).arg(i18n("MAC Address:"), btDevice->hardwareAddress());
- }
- }
- }
-
- return details;
-}
-
-QString UiUtils::modemDetails(const ModemDevice::Ptr& modemDevice, const QStringList& keys)
-{
-#if WITH_MODEMMANAGER_SUPPORT
- const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
- QString details;
- ModemManager::Modem::Ptr modemNetwork;
- ModemManager::Modem3gpp::Ptr gsmNet;
- ModemManager::ModemCdma::Ptr cdmaNet;
-
- ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(modemDevice->udi());
- if (modem) {
- modemNetwork = modem->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
- gsmNet = modem->interface(ModemManager::ModemDevice::GsmInterface).objectCast<ModemManager::Modem3gpp>();
- cdmaNet = modem->interface(ModemManager::ModemDevice::CdmaInterface).objectCast<ModemManager::ModemCdma>();
- }
-
- foreach (const QString& key, keys) {
- if (key == "mobile:operator") {
- if (gsmNet) {
- details += QString(format).arg(i18n("Operator:"), gsmNet->operatorName());
- } else if (cdmaNet) {
- details += QString(format).arg(i18n("Network ID:"), cdmaNet->nid());
- }
- } else if (key == "mobile:quality") {
- if (modemNetwork) {
- details += QString(format).arg(i18n("Signal Quality:"), QString("%1%").arg(modemNetwork->signalQuality().signal));
- }
- } else if (key == "mobile:technology") {
- if (modemNetwork) {
- details += QString(format).arg(i18n("Access Technology:"), UiUtils::convertAccessTechnologyToString(modemNetwork->accessTechnologies()));
- }
- } else if (key == "mobile:mode") {
- if (modemNetwork) {
- details += QString(format).arg(i18n("Allowed Mode:"), UiUtils::convertAllowedModeToString(modemNetwork->currentModes().allowed));
- }
- } else if (key == "mobile:unlock") {
- if (modemNetwork) {
- details += QString(format).arg(i18n("Unlock Required:"), UiUtils::convertLockReasonToString(modemNetwork->unlockRequired()));
- }
- } else if (key == "mobile:imei") {
- if (modemNetwork) {
- details += QString(format).arg(i18n("IMEI:"), modemNetwork->equipmentIdentifier());
- }
- } else if (key == "mobile:imsi") {
- if (modemDevice) {
- ModemManager::Sim::Ptr simCard;
- simCard = modemDevice->getModemCardIface();
- if (simCard) {
- details += QString(format).arg(i18n("IMSI:"), simCard->imsi());
- }
- }
- }
- }
- return details;
-#else
- Q_UNUSED(modemDevice)
- Q_UNUSED(keys)
- return QString();
-#endif
-}
-
-QString UiUtils::vpnDetails(const VpnConnection::Ptr& vpnConnection, const VpnSetting::Ptr& vpnSetting, const QStringList& keys)
-{
- const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
- QString details;
-
- foreach (const QString& key, keys) {
- if (key == "vpn:plugin") {
- if (vpnSetting) {
- details += QString(format).arg(i18n("VPN plugin:"), vpnSetting->serviceType().section('.', -1));
- }
- } else if (key == "vpn:banner") {
- if (vpnConnection && !vpnConnection->banner().isEmpty()) {
- details += QString(format).arg(i18n("Banner:"), vpnConnection->banner().simplified());
- }
- }
- }
-
- return details;
-}
-
-QString UiUtils::wimaxDetails(const NetworkManager::WimaxDevice::Ptr& wimaxDevice, const WimaxNsp::Ptr& wimaxNsp, const NetworkManager::Connection::Ptr& connection, const QStringList& keys)
-{
- const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
- QString details;
-
- const bool connected = wimaxDevice && connection && wimaxDevice->activeConnection() &&
- wimaxDevice->activeConnection()->connection() == connection && wimaxDevice->activeConnection()->state() == ActiveConnection::Activated;
-
- foreach (const QString& key, keys) {
- if (key == "wimax:bsid") {
- if (connected && wimaxDevice) {
- details += QString(format).arg(i18n("Bsid:"), wimaxDevice->bsid());
- }
- } else if (key == "wimax:nsp") {
- if (wimaxNsp) {
- details += QString(format).arg(i18n("NSP Name:"), wimaxNsp->name());
- }
- } else if (key == "wimax:signal") {
- if (wimaxNsp) {
- details += QString(format).arg(i18n("Signal Quality:"), i18n("%1%", wimaxNsp->signalQuality()));
- }
- } else if (key == "wimax:type") {
- if (wimaxNsp) {
- details += QString(format).arg(i18n("Network Type:"), UiUtils::convertNspTypeToString(wimaxNsp->networkType()));
- }
- }
- }
-
- return details;
-}
-
-QString UiUtils::wiredDetails(const WiredDevice::Ptr& wiredDevice, const NetworkManager::Connection::Ptr& connection, const QStringList& keys)
-{
- const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
- QString details;
-
- const bool connected = wiredDevice && connection && wiredDevice->activeConnection() &&
- wiredDevice->activeConnection()->connection() == connection && wiredDevice->activeConnection()->state() == ActiveConnection::Activated;
-
- foreach (const QString& key, keys) {
- if (key == "interface:bitrate") {
- if (wiredDevice && connected) {
- details += QString(format).arg(i18n("Connection speed:"), UiUtils::connectionSpeed(wiredDevice->bitRate()));
- }
- } else if (key == "interface:hardwareaddress") {
- if (wiredDevice) {
- details += QString(format).arg(i18n("MAC Address:"), wiredDevice->permanentHardwareAddress());
- }
- }
- }
-
- return details;
-}
-
-QString UiUtils::wirelessDetails(const WirelessDevice::Ptr& wirelessDevice, const AccessPoint::Ptr& ap, const NetworkManager::Connection::Ptr& connection, const QStringList& keys)
-{
- const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
- QString details;
-
- const bool connected = wirelessDevice && connection && wirelessDevice->activeConnection() &&
- wirelessDevice->activeConnection()->connection() == connection && wirelessDevice->activeConnection()->state() == ActiveConnection::Activated;
-
-
- foreach (const QString& key, keys) {
- if (key == "interface:bitrate") {
- if (wirelessDevice && connected) {
- details += QString(format).arg(i18n("Connection speed:"), UiUtils::connectionSpeed(wirelessDevice->bitRate()));
- }
- } else if (key == "interface:hardwareaddress") {
- if (wirelessDevice) {
- details += QString(format).arg(i18n("MAC Address:"), wirelessDevice->permanentHardwareAddress());
- }
- } else if (key == "wireless:mode") {
- if (wirelessDevice) {
- details += QString(format).arg(i18n("Mode:"), UiUtils::operationModeToString(wirelessDevice->mode()));
- }
- } else if (key == "wireless:signal") {
- if (ap) {
- details += QString(format).arg(i18n("Signal strength:"), i18n("%1%", ap->signalStrength()));
- }
- } else if (key == "wireless:ssid") {
- if (ap) {
- details += QString(format).arg(i18n("Access point (SSID):"), ap->ssid());
- }
- } else if (key == "wireless:accesspoint") {
- if (ap) {
- details += QString(format).arg(i18n("Access point (BSSID):"), ap->hardwareAddress());
- }
- } else if (key == "wireless:channel") {
- if (ap) {
- details += QString(format).arg(i18nc("Wifi AP channel and frequency", "Channel:"), i18n("%1 (%2 MHz)", NetworkManager::Utils::findChannel(ap->frequency()), ap->frequency()));
- }
- } else if (key == "wireless:security") {
- NetworkManager::Utils::WirelessSecurityType security = Utils::Unknown;
- if (ap) {
- security = NetworkManager::Utils::findBestWirelessSecurity(wirelessDevice->wirelessCapabilities(), true, (wirelessDevice->mode() == NetworkManager::WirelessDevice::Adhoc),
- ap->capabilities(), ap->wpaFlags(), ap->rsnFlags());
- if (security != Utils::Unknown) {
- details += QString(format).arg(i18n("Security:"), UiUtils::labelFromWirelessSecurity(security));
- }
- } else if (connection) {
- // Necessary for example for AdHoc connections
- security = Utils::securityTypeFromConnectionSetting(connection->settings());
- if (security != Utils::Unknown) {
- details += QString(format).arg(i18n("Security:"), UiUtils::labelFromWirelessSecurity(security));
- }
- }
- } else if (key == "wireless:band") {
- if (ap) {
- details += QString(format).arg(i18n("Frequency band:"), UiUtils::wirelessBandToString(NetworkManager::Utils::findFrequencyBand(ap->frequency())));
- }
- }
- }
-
- return details;
-}
-
-QString UiUtils::formatDateRelative(const QDateTime & lastUsed)
-{
- QString lastUsedText;
- if (lastUsed.isValid()) {
- const QDateTime now = QDateTime::currentDateTime();
- if (lastUsed.daysTo(now) == 0 ) {
- int secondsAgo = lastUsed.secsTo(now);
- if (secondsAgo < (60 * 60 )) {
- int minutesAgo = secondsAgo / 60;
- lastUsedText = i18ncp(
- "Label for last used time for a network connection used in the last hour, as the number of minutes since usage",
- "One minute ago",
- "%1 minutes ago",
- minutesAgo);
- } else {
- int hoursAgo = secondsAgo / (60 * 60);
- lastUsedText = i18ncp(
- "Label for last used time for a network connection used in the last day, as the number of hours since usage",
- "One hour ago",
- "%1 hours ago",
- hoursAgo);
- }
- } else if (lastUsed.daysTo(now) == 1) {
- lastUsedText = i18nc("Label for last used time for a network connection used the previous day", "Yesterday");
- } else {
- lastUsedText = KGlobal::locale()->formatDate(lastUsed.date(), KLocale::ShortDate);
- }
- } else {
- lastUsedText = i18nc("Label for last used time for a "
- "network connection that has never been used", "Never");
- }
- return lastUsedText;
-}
-
-QString UiUtils::formatLastUsedDateRelative(const QDateTime & lastUsed)
-{
- QString lastUsedText;
- if (lastUsed.isValid()) {
- const QDateTime now = QDateTime::currentDateTime();
- if (lastUsed.daysTo(now) == 0 ) {
- const int secondsAgo = lastUsed.secsTo(now);
- if (secondsAgo < (60 * 60 )) {
- const int minutesAgo = secondsAgo / 60;
- lastUsedText = i18ncp(
- "Label for last used time for a network connection used in the last hour, as the number of minutes since usage",
- "Last used one minute ago",
- "Last used %1 minutes ago",
- minutesAgo);
- } else {
- const int hoursAgo = secondsAgo / (60 * 60);
- lastUsedText = i18ncp(
- "Label for last used time for a network connection used in the last day, as the number of hours since usage",
- "Last used one hour ago",
- "Last used %1 hours ago",
- hoursAgo);
- }
- } else if (lastUsed.daysTo(now) == 1) {
- lastUsedText = i18nc("Label for last used time for a network connection used the previous day", "Last used yesterday");
- } else {
- lastUsedText = i18n("Last used on %1", KGlobal::locale()->formatDate(lastUsed.date(), KLocale::ShortDate));
- }
- } else {
- lastUsedText = i18nc("Label for last used time for a "
- "network connection that has never been used", "Never used");
- }
- return lastUsedText;
-}
+++ /dev/null
-/*
- Copyright 2008-2010 Sebastian Kügler <sebas@kde.org>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_UIUTILS_H
-#define PLASMA_NM_UIUTILS_H
-
-class QSizeF;
-
-#include <NetworkManagerQt/Device>
-#include <NetworkManagerQt/ModemDevice>
-#include <NetworkManagerQt/WirelessDevice>
-#include <NetworkManagerQt/WirelessSetting>
-#include <NetworkManagerQt/AccessPoint>
-#include <NetworkManagerQt/WimaxNsp>
-#include <NetworkManagerQt/Utils>
-#include <NetworkManagerQt/BluetoothDevice>
-#include <NetworkManagerQt/WimaxDevice>
-#include <NetworkManagerQt/WiredDevice>
-#include <NetworkManagerQt/VpnConnection>
-#include <NetworkManagerQt/VpnSetting>
-
-#if WITH_MODEMMANAGER_SUPPORT
-#include <ModemManager/ModemManager.h>
-#include <ModemManagerQt/modem.h>
-#endif
-
-#include "plasmanm_export.h"
-#include <config.h>
-
-class PLASMA_NM_EXPORT UiUtils
-{
-public:
-
- /**
- * @return a human-readable description for the network interface type for use as label
- * @param type the type of the network interface
- */
- static QString interfaceTypeLabel(const NetworkManager::Device::Type type, const NetworkManager::Device::Ptr iface);
-
- /**
- * @return a human-readable name for a given network interface according to the configured
- * naming style
- * @param type type of the network interface
- * @param interfaceName name of the network interface (eg eth0)
- */
- static QString prettyInterfaceName(NetworkManager::Device::Type type, const QString &interfaceName);
- /**
- * @return a human-readable description of the connection state of a given network interface
- * @param state The connection state
- */
- static QString connectionStateToString(NetworkManager::Device::State state, const QString &connectionName = QString());
-
- static QString vpnConnectionStateToString(NetworkManager::VpnConnection::State state);
-
- static QString iconAndTitleForConnectionSettingsType(NetworkManager::ConnectionSettings::ConnectionType type,
- QString &title);
- /**
- * @return a human-readable description of operation mode.
- * @param mode the operation mode
- */
- static QString operationModeToString(NetworkManager::WirelessDevice::OperationMode mode);
-
- /**
- * @return string list with a human-readable description of wpa flags.
- * @param flags the wpa flags
- */
- static QStringList wpaFlagsToStringList(NetworkManager::AccessPoint::WpaFlags flags);
-
- /**
- * @return localized string showing a human-readable connection speed. 1000 is used as base.
- * @param bitrate bitrate of the connection per second
- */
- static QString connectionSpeed(double bitrate);
-
- /**
- * @param band The band of a wireless network. The value corresponds to the type enum in Knm::WirelessSetting::EnumBand
- * @return A string representation
- */
- static QString wirelessBandToString(NetworkManager::WirelessSetting::FrequencyBand band);
-
-#if WITH_MODEMMANAGER_SUPPORT
- static QString convertAllowedModeToString(ModemManager::Modem::ModemModes mode);
- static QString convertAccessTechnologyToString(ModemManager::Modem::AccessTechnologies tech);
- static QString convertLockReasonToString(MMModemLock reason);
-#endif
- static NetworkManager::ModemDevice::Capability modemSubType(NetworkManager::ModemDevice::Capabilities modemCaps);
- static QString convertNspTypeToString(NetworkManager::WimaxNsp::NetworkType type);
-
- static QString shortToolTipFromWirelessSecurity(NetworkManager::Utils::WirelessSecurityType type);
- static QString labelFromWirelessSecurity(NetworkManager::Utils::WirelessSecurityType type);
-
- static QString connectionDetails(const NetworkManager::Device::Ptr & device, const NetworkManager::Connection::Ptr & connection, const QStringList & keys);
- static QString bluetoothDetails(const NetworkManager::BluetoothDevice::Ptr & btDevice, const QStringList & keys);
- static QString modemDetails(const NetworkManager::ModemDevice::Ptr & modemDevice, const QStringList & keys);
- static QString vpnDetails(const NetworkManager::VpnConnection::Ptr & vpnConnection, const NetworkManager::VpnSetting::Ptr & vpnSetting, const QStringList & keys);
- static QString wimaxDetails(const NetworkManager::WimaxDevice::Ptr & wimaxDevice, const NetworkManager::WimaxNsp::Ptr & wimaxNsp, const NetworkManager::Connection::Ptr & connection, const QStringList & keys);
- static QString wiredDetails(const NetworkManager::WiredDevice::Ptr & wiredDevice, const NetworkManager::Connection::Ptr & connection, const QStringList & keys);
- static QString wirelessDetails(const NetworkManager::WirelessDevice::Ptr & wirelessDevice, const NetworkManager::AccessPoint::Ptr & network, const NetworkManager::Connection::Ptr & connection, const QStringList & keys);
- static QString formatDateRelative(const QDateTime & lastUsed);
- static QString formatLastUsedDateRelative(const QDateTime & lastUsed);
-};
-#endif // UIUTILS_H
+++ /dev/null
-add_subdirectory(details)
-add_subdirectory(notifications)
+++ /dev/null
-set(plasmanetworkmanagement_config_widgets_SRCS
- detailkeyseditor.cpp
- detailkeyseditordesignfactory.cpp
- detailkeyswidget.ui
-)
-
-kde4_add_plugin(plasmanetworkmanagementwidgets SHARED
- ${plasmanetworkmanagement_config_widgets_SRCS})
-
-target_link_libraries(plasmanetworkmanagementwidgets
- ${KDE4_KDEUI_LIBS}
-)
-
-install( TARGETS plasmanetworkmanagementwidgets DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/designer )
+++ /dev/null
-/*
- Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "detailkeyseditor.h"
-#include "ui_detailkeyswidget.h"
-#include <config.h>
-
-#include <KLocalizedString>
-#include <KDebug>
-#include <QList>
-
-#include <KConfigDialogManager>
-#include <KAcceleratorManager>
-
-#define DetailTagRole Qt::UserRole + 1
-
-class DetailKeysEditorPrivate
-{
-public:
- Ui_DetailKeysWidget ui;
-};
-
-DetailKeysEditor::DetailKeysEditor(QWidget *parent)
- : QWidget(parent), d_ptr(new DetailKeysEditorPrivate)
-{
- Q_D(DetailKeysEditor);
- d->ui.setupUi(this);
-
- setContentsMargins(QMargins());
- d->ui.gridLayout->setSpacing(0);
-
- loadAllDetailElements();
-
- QMap<QString, QPair<QString, QString> >::const_iterator it = m_allDetailsElements.constBegin();
- while (it != m_allDetailsElements.constEnd()) {
- d->ui.availDetails->addTopLevelItem(constructItem(it.key()));
- ++it;
- }
-
- setupCommon();
-
- KAcceleratorManager::manage(this);
-
- KConfigDialogManager::changedMap()->insert("DetailKeysEditor", SIGNAL(currentDetailsChanged(const QStringList &)));
-}
-
-DetailKeysEditor::~DetailKeysEditor()
-{
- Q_D(DetailKeysEditor);
- d->ui.currentDetails->clear();
- d->ui.availDetails->clear();
- delete d_ptr;
-}
-
-void DetailKeysEditor::loadSelectedElements(const QStringList& keys)
-{
- Q_D(DetailKeysEditor);
-
- foreach (const QString & key, keys) {
- for (int i = 0; i < d->ui.availDetails->topLevelItemCount(); i++) {
- QTreeWidgetItem * item = d->ui.availDetails->topLevelItem(i);
- if (key == item->data(DetailKeysEditor::Key, DetailTagRole).toString()) {
- int index = d->ui.availDetails->indexOfTopLevelItem(item);
- d->ui.availDetails->takeTopLevelItem(index);
- d->ui.currentDetails->addTopLevelItem(item);
- break;
- }
- }
- }
-}
-
-void DetailKeysEditor::loadAllDetailElements()
-{
- m_allDetailsElements.insert("interface:driver", QPair<QString, QString>(i18n("Driver"), i18n("Device driver")));
- m_allDetailsElements.insert("interface:bitrate", QPair<QString, QString>(i18n("Connection Speed"), i18n("Connection speed")));
- m_allDetailsElements.insert("interface:name", QPair<QString, QString>(i18n("System Name"), i18n("System Name")));
- m_allDetailsElements.insert("interface:hardwareaddress", QPair<QString, QString>(i18n("MAC Address"), i18n("Hardware address")));
-
- // IPv4
- m_allDetailsElements.insert("ipv4:address", QPair<QString, QString>(i18n("IPv4 Address"), i18n("IP version 4 address")));
-// m_allDetailsElements.insert("ipv4:nameservers", QPair<QString, QString>(i18n("IPv4 Name Servers"), i18n("IP version 4 Name servers")));
-// m_allDetailsElements.insert("ipv4:domains", QPair<QString, QString>(i18n("IPv4 Domains"), i18n("IPv version 4 DNS domain names")));
- m_allDetailsElements.insert("ipv4:gateway", QPair<QString, QString>(i18n("IPv4 Gateway"), i18n("IP version 4 default gateway")));
-
- // IPv6
- m_allDetailsElements.insert("ipv6:address", QPair<QString, QString>(i18n("IPv6 Address"), i18n("IP version 6 address")));
-// m_allDetailsElements.insert("ipv6:nameservers", QPair<QString, QString>(i18n("IPv6 Name Servers"), i18n("IP version 6 Name servers")));
-// m_allDetailsElements.insert("ipv6:domains", QPair<QString, QString>(i18n("IPv6 Domains"), i18n("IPv version 6 DNS domain names")));
- m_allDetailsElements.insert("ipv6:gateway", QPair<QString, QString>(i18n("IPv6 Gateway"), i18n("IP version 6 default gateway")));
-
- // Wimax
- m_allDetailsElements.insert("wimax:bsid", QPair<QString, QString>(i18n("WiMAX Bsid"), i18n("The ID of the serving base station as received from the network")));
- m_allDetailsElements.insert("wimax:nsp", QPair<QString, QString>(i18n("WiMAX NSP"), i18n("The name of the NSP")));
- m_allDetailsElements.insert("wimax:signal", QPair<QString, QString>(i18n("WiMAX Signal"), i18n("The current signal quality of the NSP, in percent.")));
- m_allDetailsElements.insert("wimax:type", QPair<QString, QString>(i18n("WiMAX NSP Type"), i18n("The network type of the NSP.")));
-
- // Wireless
- m_allDetailsElements.insert("wireless:ssid", QPair<QString, QString>(i18n("Access Point (SSID)"), i18n("Wireless Access Point's SSID")));
- m_allDetailsElements.insert("wireless:signal", QPair<QString, QString>(i18n("Signal Strength"), i18n("Wireless Access Point's signal strength")));
- m_allDetailsElements.insert("wireless:accesspoint", QPair<QString, QString>(i18n("Access Point (MAC)"), i18n("Wireless Access Point's Hardware Address")));
- m_allDetailsElements.insert("wireless:band", QPair<QString, QString>(i18n("Wireless Band"), i18n("Wireless Frequency Band")));
- m_allDetailsElements.insert("wireless:channel", QPair<QString, QString>(i18n("Wireless Channel"), i18n("Wireless Frequency Channel")));
- m_allDetailsElements.insert("wireless:security", QPair<QString, QString>(i18n("Wireless Security"), i18n("Describes the security capabilities of the access point")));
- m_allDetailsElements.insert("wireless:mode", QPair<QString, QString>(i18n("Wireless Mode"), i18n("The operating mode of the wireless device")));
-
- // Mobile Broadband
- m_allDetailsElements.insert("mobile:operator", QPair<QString, QString>(i18n("Mobile Operator"), i18n("Mobile Operator's Name")));
- m_allDetailsElements.insert("mobile:quality", QPair<QString, QString>(i18n("Mobile Signal Quality"), i18n("Mobile Signal Quality")));
- m_allDetailsElements.insert("mobile:technology", QPair<QString, QString>(i18n("Mobile Access Technology"), i18n("Mobile Access Technology")));
-
- m_allDetailsElements.insert("mobile:mode", QPair<QString, QString>(i18n("Mobile Allowed Mode"), i18n("Mobile Allowed Mode")));
- m_allDetailsElements.insert("mobile:unlock", QPair<QString, QString>(i18n("Mobile Unlock Required"), i18n("Mobile Master Device")));
- m_allDetailsElements.insert("mobile:imei", QPair<QString, QString>(i18n("Mobile Device IMEI"), i18n("Mobile Device Serial Number")));
- m_allDetailsElements.insert("mobile:imsi", QPair<QString, QString>(i18n("Mobile Device IMSI"), i18n("Mobile Device Identity Number")));
-
- // Others
- m_allDetailsElements.insert("bluetooth:name", QPair<QString, QString>(i18n("Bluetooth Name"), i18n("Bluetooth name of the device")));
- m_allDetailsElements.insert("vpn:plugin", QPair<QString, QString>(i18n("VPN Plugin"), i18n("VPN plugin type")));
- m_allDetailsElements.insert("vpn:banner", QPair<QString, QString>(i18n("VPN Banner"), i18n("VPN connection banner")));
-}
-
-void DetailKeysEditor::setupCommon()
-{
- Q_D(DetailKeysEditor);
- connect(d->ui.arrowUp, SIGNAL(clicked()), this, SLOT(upArrowClicked()));
- connect(d->ui.arrowLeft, SIGNAL(clicked()), this, SLOT(leftArrowClicked()));
- connect(d->ui.arrowRight, SIGNAL(clicked()), this, SLOT(rightArrowClicked()));
- connect(d->ui.arrowDown, SIGNAL(clicked()), this, SLOT(downArrowClicked()));
- d->ui.availDetails->sortByColumn(DetailKeysEditor::Name, Qt::AscendingOrder);
- d->ui.availDetails->setSortingEnabled(true);
-}
-
-QTreeWidgetItem * DetailKeysEditor::constructItem(const QString & key)
-{
- QStringList data;
- data << m_allDetailsElements[key].first;
- QTreeWidgetItem *item = new QTreeWidgetItem(data);
- item->setData(DetailKeysEditor::Key, DetailTagRole, key);
- item->setToolTip(DetailKeysEditor::Name, m_allDetailsElements[key].second);
- return item;
-}
-
-QStringList DetailKeysEditor::currentDetails()
-{
- Q_D(DetailKeysEditor);
- QStringList details;
- int itemCount = d->ui.currentDetails->topLevelItemCount();
- for (int i = 0; i < itemCount; i++) {
- QTreeWidgetItem *item = d->ui.currentDetails->topLevelItem(i);
- details << item->data(DetailKeysEditor::Key, DetailTagRole).toString();
- }
- return details;
-}
-
-void DetailKeysEditor::upArrowClicked()
-{
- Q_D(DetailKeysEditor);
-
- foreach (QTreeWidgetItem *item, d->ui.currentDetails->selectedItems()) {
- int index = d->ui.currentDetails->indexOfTopLevelItem(item);
- if (index > 0) {
- d->ui.currentDetails->takeTopLevelItem(index);
- d->ui.currentDetails->insertTopLevelItem(index-1, item);
- item->setSelected(true);
- }
- }
-
- Q_EMIT currentDetailsChanged(currentDetails());
-}
-
-void DetailKeysEditor::downArrowClicked()
-{
- Q_D(DetailKeysEditor);
-
- if (d->ui.currentDetails->selectedItems().isEmpty()) {
- return;
- }
-
- QList<QTreeWidgetItem *> list = d->ui.currentDetails->selectedItems();
- for (int i = list.size()-1; i >= 0; --i) {
- QTreeWidgetItem * item = list[i];
- int index = d->ui.currentDetails->indexOfTopLevelItem(item);
- d->ui.currentDetails->takeTopLevelItem(index);
- d->ui.currentDetails->insertTopLevelItem(index+1, item);
- item->setSelected(true);
- }
-
- Q_EMIT currentDetailsChanged(currentDetails());
-}
-
-void DetailKeysEditor::rightArrowClicked()
-{
- Q_D(DetailKeysEditor);
- foreach (QTreeWidgetItem *item, d->ui.availDetails->selectedItems()) {
- int index = d->ui.availDetails->indexOfTopLevelItem(item);
- d->ui.availDetails->takeTopLevelItem(index);
- d->ui.currentDetails->addTopLevelItem(item);
- }
-
- Q_EMIT currentDetailsChanged(currentDetails());
-}
-
-void DetailKeysEditor::leftArrowClicked()
-{
- Q_D(DetailKeysEditor);
- foreach (QTreeWidgetItem *item, d->ui.currentDetails->selectedItems()) {
- int index = d->ui.currentDetails->indexOfTopLevelItem(item);
- d->ui.currentDetails->takeTopLevelItem(index);
- d->ui.availDetails->addTopLevelItem(item);
- }
-
- Q_EMIT currentDetailsChanged(currentDetails());
-}
+++ /dev/null
-/*
- Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_DETAIL_KEYS_EDITOR_H
-#define PLASMA_NM_DETAIL_KEYS_EDITOR_H
-
-#include <QWidget>
-#include <QMap>
-#include <QPair>
-
-class QTreeWidgetItem;
-class DetailKeysEditorPrivate;
-
-class DetailKeysEditor : public QWidget
-{
-Q_OBJECT
-Q_PROPERTY(QStringList currentDetails READ currentDetails WRITE loadSelectedElements NOTIFY currentDetailsChanged USER true)
-Q_DECLARE_PRIVATE(DetailKeysEditor)
-public:
- explicit DetailKeysEditor(QWidget * parent = 0);
- ~DetailKeysEditor();
-
- QStringList currentDetails();
-
-protected:
- DetailKeysEditorPrivate *d_ptr;
-
-private:
- enum Columns {Name = 0, Key = 1};
-
- void loadSelectedElements(const QStringList & keys);
- void loadAllDetailElements();
- void setupCommon();
- QTreeWidgetItem * constructItem(const QString &);
- QMap<QString, QPair<QString, QString> > m_allDetailsElements;
-
-Q_SIGNALS:
- void currentDetailsChanged(const QStringList & keys);
-private Q_SLOTS:
- void upArrowClicked();
- void leftArrowClicked();
- void rightArrowClicked();
- void downArrowClicked();
-};
-
-#endif // PLASMA_NM_DETAIL_KEYS_EDITOR_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "detailkeyseditordesignfactory.h"
-#include "detailkeyseditor.h"
-
-#include <QtPlugin>
-
-#include <KGlobal>
-
-static const KCatalogLoader loader(QLatin1String("plasma_applet_org.kde.networkmanagement"));
-
-DetailKeysEditorDesignerFactory::DetailKeysEditorDesignerFactory(QObject *parent)
-: QObject(parent)
-{
-}
-
-bool DetailKeysEditorDesignerFactory::isContainer() const
-{
- return false;
-}
-
-QIcon DetailKeysEditorDesignerFactory::icon() const
-{
- return QIcon();
-}
-
-QString DetailKeysEditorDesignerFactory::group() const
-{
- return QString();
-}
-
-QString DetailKeysEditorDesignerFactory::includeFile() const
-{
- return "detailkeyseditor.h";
-}
-
-QString DetailKeysEditorDesignerFactory::name() const
-{
- return "DetailKeysEditor";
-}
-
-QString DetailKeysEditorDesignerFactory::toolTip() const
-{
- return QString();
-}
-
-QString DetailKeysEditorDesignerFactory::whatsThis() const
-{
- return QString();
-}
-
-QWidget * DetailKeysEditorDesignerFactory::createWidget(QWidget *parent)
-{
- return new DetailKeysEditor(parent);
-}
-
-Q_EXPORT_PLUGIN2(plasmanetworkmanagementwidgets, DetailKeysEditorDesignerFactory)
-
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_DETAIL_KEYS_EDITOR_DESIGN_FACTORY_H
-#define PLASMA_NM_DETAIL_KEYS_EDITOR_DESIGN_FACTORY_H
-
-#include <QDesignerCustomWidgetInterface>
-#include <QObject>
-
-class DetailKeysEditorDesignerFactory : public QObject, public QDesignerCustomWidgetInterface
-{
- Q_OBJECT
- Q_INTERFACES(QDesignerCustomWidgetInterface)
-public:
- explicit DetailKeysEditorDesignerFactory(QObject *parent = 0);
-
- bool isContainer() const;
- QIcon icon() const;
- QString group() const;
- QString includeFile() const;
- QString name() const;
- QString toolTip() const;
- QString whatsThis() const;
- QWidget *createWidget(QWidget *parent);
-};
-
-#endif // PLASMA_NM_DETAIL_KEYS_EDITOR_DESIGN_FACTORY_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>DetailKeysWidget</class>
- <widget class="QWidget" name="DetailKeysWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>630</width>
- <height>249</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Available Details</string>
- </property>
- <property name="buddy">
- <cstring>availDetails</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTreeWidget" name="availDetails">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="editTriggers">
- <set>QAbstractItemView::NoEditTriggers</set>
- </property>
- <property name="showDropIndicator" stdset="0">
- <bool>false</bool>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::ExtendedSelection</enum>
- </property>
- <property name="rootIsDecorated">
- <bool>false</bool>
- </property>
- <property name="uniformRowHeights">
- <bool>true</bool>
- </property>
- <property name="itemsExpandable">
- <bool>false</bool>
- </property>
- <property name="allColumnsShowFocus">
- <bool>true</bool>
- </property>
- <property name="columnCount">
- <number>1</number>
- </property>
- <attribute name="headerDefaultSectionSize">
- <number>100</number>
- </attribute>
- <column>
- <property name="text">
- <string comment="title of a table's column">Name</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="1">
- <widget class="KPushButton" name="arrowUp">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>32</width>
- <height>32</height>
- </size>
- </property>
- <property name="icon">
- <iconset theme="arrow-up">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="KPushButton" name="arrowLeft">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>32</width>
- <height>32</height>
- </size>
- </property>
- <property name="icon">
- <iconset theme="arrow-left">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="KPushButton" name="arrowRight">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>32</width>
- <height>32</height>
- </size>
- </property>
- <property name="icon">
- <iconset theme="arrow-right">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="KPushButton" name="arrowDown">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>32</width>
- <height>32</height>
- </size>
- </property>
- <property name="icon">
- <iconset theme="arrow-down">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Details to Show</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- <property name="buddy">
- <cstring>currentDetails</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTreeWidget" name="currentDetails">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="editTriggers">
- <set>QAbstractItemView::NoEditTriggers</set>
- </property>
- <property name="showDropIndicator" stdset="0">
- <bool>false</bool>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::ExtendedSelection</enum>
- </property>
- <property name="rootIsDecorated">
- <bool>false</bool>
- </property>
- <property name="uniformRowHeights">
- <bool>true</bool>
- </property>
- <property name="itemsExpandable">
- <bool>false</bool>
- </property>
- <property name="allColumnsShowFocus">
- <bool>true</bool>
- </property>
- <property name="columnCount">
- <number>1</number>
- </property>
- <attribute name="headerDefaultSectionSize">
- <number>100</number>
- </attribute>
- <column>
- <property name="text">
- <string comment="title of a table's column">Name</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-set(plasma_networkmanagement_notifications_SRCS
- notifications.cpp
-)
-
-kde4_add_plugin(networkmanagement_notifications ${plasma_networkmanagement_notifications_SRCS})
-
-target_link_libraries(networkmanagement_notifications ${KDE4_KDEUI_LIBS} ${KDE4_KNOTIFYCONFIG_LIBRARY})
-
-install(TARGETS networkmanagement_notifications DESTINATION ${PLUGIN_INSTALL_DIR})
-install(FILES networkmanagement_notifications.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+++ /dev/null
-[Desktop Entry]
-Name=Notifications
-Name[bg]=Уведомления
-Name[bs]=obavještenja
-Name[ca]=Notificacions
-Name[ca@valencia]=Notificacions
-Name[cs]=Oznamování
-Name[da]=Bekendtgørelser
-Name[de]=Benachrichtigungen
-Name[el]=Ειδοποιήσεις
-Name[en_GB]=Notifications
-Name[es]=Notificaciones
-Name[et]=Märguanded
-Name[fi]=Ilmoitukset
-Name[fr]=Notifications
-Name[hu]=Értesítések
-Name[it]=Notifiche
-Name[ko]=알림
-Name[lt]=Pranešimai
-Name[nb]=Varslinger
-Name[nds]=Bescheden
-Name[nl]=Meldingen
-Name[pl]=Powiadomienia
-Name[pt]=Notificações
-Name[pt_BR]=Notificações
-Name[ro]=Notificări
-Name[sk]=Upozornenia
-Name[sl]=Obvestila
-Name[sv]=Underrättelser
-Name[tr]=Bildirimler
-Name[ug]=ئۇقتۇرۇشلار
-Name[uk]=Сповіщення
-Name[x-test]=xxNotificationsxx
-Name[zh_CN]=通知
-Comment=Configure the Network Management notifications
-Comment[bg]=Настройки на уведомления на управлението на мрежата
-Comment[bs]=Definiše Network Management za upravljanje mrežom
-Comment[ca]=Configura les notificacions del Gestor de la xarxa
-Comment[ca@valencia]=Configura les notificacions del Gestor de la xarxa
-Comment[cs]=Nastavit oznamování správy sítě
-Comment[da]=Indstil bekendtgørelser for netværkshåndtering
-Comment[de]=Einrichtung der Benachrichtigungen für die Netzwerkverwaltung
-Comment[el]=Διαμόρφωση ειδοποιήσεων της διαχείρισης δικτύων
-Comment[en_GB]=Configure the Network Management notifications
-Comment[es]=Configure las notificaciones del gestor de red
-Comment[et]=Võrguhalduri märguannete seadistamine
-Comment[fi]=Verkonhallinnan ilmoitusten asetukset
-Comment[fr]=Configure les notifications de gestion de réseau
-Comment[hu]=A hálózatkezelő értesítéseinek beállítása
-Comment[it]=Configura le notifiche della gestione di rete
-Comment[ko]=네트워크 관리 알림 설정
-Comment[lt]=Konfigūruoti Tinklo valdymo pranešimus
-Comment[nb]=Sett opp varslinger for nettverkstyring
-Comment[nds]=De Nettwarkpleeg-Bescheden instellen
-Comment[nl]=Stel de meldingen van netwerkbeheer in
-Comment[pl]=Ustawienia powiadomień zarządzania siecią
-Comment[pt]=Configurar as notificações da Gestão da Rede
-Comment[pt_BR]=Configura as notificações do gerenciamento de redes
-Comment[ro]=Configurează notificările gestiunii de rețea
-Comment[sk]=Nastaviť upozornenia správy siete
-Comment[sl]=Nastavi obvestila za omrežno upravljanje
-Comment[sv]=Anpassa underrättelser för nätverkshantering
-Comment[tr]=Ağ Yönetim bilgilendirmelerini yapılandır
-Comment[uk]=Налаштування сповіщень щодо керування мережею
-Comment[x-test]=xxConfigure the Network Management notificationsxx
-Comment[zh_CN]=配置网络管理通知
-Type=Service
-Exec=kcmshell4 networkmanagement_notifications
-Icon=preferences-desktop-notification
-X-KDE-ServiceTypes=KCModule
-X-KDE-Library=networkmanagement_notifications
-Categories=Qt;KDE;X-KDE-settings-system;
-Visible=false;
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "notifications.h"
-
-#include <QHBoxLayout>
-
-#include <KAboutData>
-#include <KLocale>
-#include <KPluginFactory>
-#include <KNotifyConfigWidget>
-
-
-K_PLUGIN_FACTORY(NotificationsWidgetFactory, registerPlugin<NotificationsWidget>();)
-K_EXPORT_PLUGIN(NotificationsWidgetFactory("networkmanagement_notifications", "plasma_applet_org.kde.networkmanagement"))
-
-NotificationsWidget::NotificationsWidget(QWidget *parent, const QVariantList &args)
- : KCModule(NotificationsWidgetFactory::componentData(), parent, args),
- m_notifyWidget(new KNotifyConfigWidget(this))
-{
- QHBoxLayout * layout = new QHBoxLayout(this);
- m_notifyWidget->setApplication("networkmanagement"); // name of the .notifyrc file
- layout->addWidget(m_notifyWidget);
- setLayout(layout);
-
- setButtons(KCModule::Apply); // apply calls the save() method
-}
-
-NotificationsWidget::~NotificationsWidget()
-{
-}
-
-void NotificationsWidget::save()
-{
- m_notifyWidget->save();
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_NOTIFICATIONS_H
-#define PLASMA_NM_NOTIFICATIONS_H
-
-#include <KCModule>
-
-class KNotifyConfigWidget;
-
-class NotificationsWidget : public KCModule
-{
-Q_OBJECT
-public:
- explicit NotificationsWidget(QWidget * parent = 0, const QVariantList & args = QVariantList());
- virtual ~NotificationsWidget();
-
-public slots:
- virtual void save();
-
-private:
- KNotifyConfigWidget * m_notifyWidget;
-};
-
-#endif // PLASMA_NM_NOTIFICATION_WIDGET_H
+++ /dev/null
-include_directories(${PROJECT_SOURCE_DIR}/libs/editor/widgets)
-
-add_subdirectory(vpnc)
-add_subdirectory(openvpn)
-add_subdirectory(l2tp)
-add_subdirectory(pptp)
-add_subdirectory(openswan)
-add_subdirectory(openconnect)
-add_subdirectory(strongswan)
+++ /dev/null
-set(l2tp_SRCS
- l2tp.cpp
- l2tpwidget.cpp
- l2tpauth.cpp
- l2tpadvancedwidget.cpp
- l2tppppwidget.cpp
- l2tp.ui
- l2tpadvanced.ui
- l2tpauth.ui
- l2tpppp.ui
-)
-
-kde4_add_plugin(plasmanetworkmanagement_l2tpui ${l2tp_SRCS})
-
-target_link_libraries(plasmanetworkmanagement_l2tpui plasmanetworkmanagement-editor ${NETWORKMANAGERQT_LDFLAGS} ${KDE4_KIO_LIBS})
-
-install(TARGETS plasmanetworkmanagement_l2tpui DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install(FILES plasmanetworkmanagement_l2tpui.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
-$XGETTEXT `find . -name "*.cpp"` -o $podir/plasmanetworkmanagement_l2tpui.pot
-rm -f rc.cpp
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "l2tp.h"
-
-#include <KPluginFactory>
-#include <KLocale>
-#include "nm-l2tp-service.h"
-
-#include <NetworkManagerQt/VpnSetting>
-
-#include "l2tpwidget.h"
-#include "l2tpauth.h"
-
-K_PLUGIN_FACTORY(L2tpUiPluginFactory, registerPlugin<L2tpUiPlugin>();)
-K_EXPORT_PLUGIN(L2tpUiPluginFactory("plasmanetworkmanagement_l2tpui"))
-
-L2tpUiPlugin::L2tpUiPlugin(QObject * parent, const QVariantList &):
- VpnUiPlugin(parent)
-{
-}
-
-L2tpUiPlugin::~L2tpUiPlugin()
-{
-}
-
-SettingWidget * L2tpUiPlugin::widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new L2tpWidget(setting, parent);
-}
-
-SettingWidget *L2tpUiPlugin::askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new L2tpAuthDialog(setting, parent);
-}
-
-QString L2tpUiPlugin::suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const
-{
- Q_UNUSED(connection);
- return QString();
-}
-
-QString L2tpUiPlugin::supportedFileExtensions() const
-{
- return QString();
-}
-
-NMVariantMapMap L2tpUiPlugin::importConnectionSettings(const QString &fileName)
-{
- Q_UNUSED(fileName);
- mError = VpnUiPlugin::NotImplemented;
- return NMVariantMapMap();
-}
-
-bool L2tpUiPlugin::exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName)
-{
- Q_UNUSED(connection);
- Q_UNUSED(fileName);
- mError = VpnUiPlugin::NotImplemented;
- return false;
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_L2TP_H
-#define PLASMA_NM_L2TP_H
-
-#include "vpnuiplugin.h"
-#include "plasmanm_export.h"
-
-#include <QVariant>
-
-class PLASMA_NM_EXPORT L2tpUiPlugin : public VpnUiPlugin
-{
- Q_OBJECT
-public:
- explicit L2tpUiPlugin(QObject * parent = 0, const QVariantList& = QVariantList());
- virtual ~L2tpUiPlugin();
- virtual SettingWidget * widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- virtual SettingWidget * askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
-
- QString suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const;
- QString supportedFileExtensions() const;
- NMVariantMapMap importConnectionSettings(const QString &fileName);
- bool exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName);
-};
-
-#endif // PLASMA_NM_L2TP_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>L2tpWidget</class>
- <widget class="QWidget" name="L2tpWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>450</width>
- <height>388</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Gateway:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="gateway"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>User name:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="username"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Password:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout" stretch="3,1">
- <item>
- <widget class="KLineEdit" name="password">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="cboUserPasswordType">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item row="3" column="1">
- <widget class="QCheckBox" name="cbShowPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>NT Domain:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QLineEdit" name="domain"/>
- </item>
- <item row="5" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>216</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="6" column="0" colspan="2">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>188</width>
- <height>22</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="btnIPSecSettings">
- <property name="text">
- <string>IPsec Settings...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnPPPSettings">
- <property name="text">
- <string>PPP Settings...</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>gateway</tabstop>
- <tabstop>username</tabstop>
- <tabstop>password</tabstop>
- <tabstop>cboUserPasswordType</tabstop>
- <tabstop>cbShowPassword</tabstop>
- <tabstop>domain</tabstop>
- <tabstop>btnIPSecSettings</tabstop>
- <tabstop>btnPPPSettings</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>L2tpAdvancedWidget</class>
- <widget class="QWidget" name="L2tpAdvancedWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>382</width>
- <height>139</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0" colspan="2">
- <widget class="QCheckBox" name="cbEnableTunnelToHost">
- <property name="text">
- <string>Enable IPsec tunnel to L2TP host</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Group Name:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="groupName">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Gateway ID:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLineEdit" name="gatewayId">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Pre-shared Key:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QLineEdit" name="presharedKey">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="2">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>cbEnableTunnelToHost</sender>
- <signal>toggled(bool)</signal>
- <receiver>gatewayId</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>159</x>
- <y>14</y>
- </hint>
- <hint type="destinationlabel">
- <x>209</x>
- <y>65</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cbEnableTunnelToHost</sender>
- <signal>toggled(bool)</signal>
- <receiver>groupName</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>159</x>
- <y>14</y>
- </hint>
- <hint type="destinationlabel">
- <x>209</x>
- <y>39</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cbEnableTunnelToHost</sender>
- <signal>toggled(bool)</signal>
- <receiver>presharedKey</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>159</x>
- <y>14</y>
- </hint>
- <hint type="destinationlabel">
- <x>209</x>
- <y>91</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>L2tpAdvancedWidget</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>190</x>
- <y>119</y>
- </hint>
- <hint type="destinationlabel">
- <x>190</x>
- <y>68</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>L2tpAdvancedWidget</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>190</x>
- <y>119</y>
- </hint>
- <hint type="destinationlabel">
- <x>190</x>
- <y>68</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "l2tpadvancedwidget.h"
-#include "ui_l2tpadvanced.h"
-#include "nm-l2tp-service.h"
-
-#include <QDebug>
-#include <KLocalizedString>
-#include <KAcceleratorManager>
-
-L2tpAdvancedWidget::L2tpAdvancedWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent) :
- QDialog(parent),
- m_ui(new Ui::L2tpAdvancedWidget)
-{
- m_ui->setupUi(this);
-
- setWindowTitle(i18n("L2TP IPsec Options"));
-
- KAcceleratorManager::manage(this);
-
- loadConfig(setting);
-}
-
-L2tpAdvancedWidget::~L2tpAdvancedWidget()
-{
- delete m_ui;
-}
-
-void L2tpAdvancedWidget::loadConfig(const NetworkManager::VpnSetting::Ptr &setting)
-{
- if (setting->data().value(NM_L2TP_KEY_IPSEC_ENABLE) == "yes") {
- m_ui->cbEnableTunnelToHost->setChecked(true);
- m_ui->gatewayId->setText(setting->data().value(NM_L2TP_KEY_IPSEC_GATEWAY_ID));
- m_ui->groupName->setText(setting->data().value(NM_L2TP_KEY_IPSEC_GROUP_NAME));
- m_ui->presharedKey->setText(setting->data().value(NM_L2TP_KEY_IPSEC_PSK));
- } else {
- m_ui->cbEnableTunnelToHost->setChecked(false);
- }
-}
-
-NMStringMap L2tpAdvancedWidget::setting() const
-{
- NMStringMap result;
-
- if (m_ui->cbEnableTunnelToHost->isChecked()) {
- result.insert(NM_L2TP_KEY_IPSEC_ENABLE, "yes");
-
- if (!m_ui->gatewayId->text().isEmpty()) {
- result.insert(NM_L2TP_KEY_IPSEC_GATEWAY_ID, m_ui->gatewayId->text());
- }
-
- if (!m_ui->groupName->text().isEmpty()) {
- result.insert(NM_L2TP_KEY_IPSEC_GROUP_NAME, m_ui->groupName->text());
- }
-
- if (!m_ui->presharedKey->text().isEmpty()) {
- result.insert(NM_L2TP_KEY_IPSEC_PSK, m_ui->presharedKey->text());
- }
- }
-
- return result;
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_L2TP_ADVANCED_WIDGET_H
-#define PLASMA_NM_L2TP_ADVANCED_WIDGET_H
-
-#include <QDialog>
-
-#include <NetworkManagerQt/VpnSetting>
-
-namespace Ui
-{
-class L2tpAdvancedWidget;
-}
-
-class L2tpAdvancedWidget : public QDialog
-{
- Q_OBJECT
-public:
- explicit L2tpAdvancedWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent = 0);
- ~L2tpAdvancedWidget();
-
- NMStringMap setting() const;
-
-private:
- void loadConfig(const NetworkManager::VpnSetting::Ptr &setting);
- Ui::L2tpAdvancedWidget * m_ui;
-};
-
-#endif // PLASMA_NM_L2TP_ADVANCED_WIDGET_H
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "l2tpauth.h"
-#include "ui_l2tpauth.h"
-#include "nm-l2tp-service.h"
-
-#include <QString>
-
-class L2tpAuthDialogPrivate
-{
-public:
- Ui_L2tpAuth ui;
- NetworkManager::VpnSetting::Ptr setting;
-};
-
-L2tpAuthDialog::L2tpAuthDialog(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
- : SettingWidget(setting, parent), d_ptr(new L2tpAuthDialogPrivate)
-{
- Q_D(L2tpAuthDialog);
- d->ui.setupUi(this);
- d->setting = setting;
- connect(d->ui.cbShowPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswordsChanged(bool)));
-
- KAcceleratorManager::manage(this);
-
- readSecrets();
-}
-
-L2tpAuthDialog::~L2tpAuthDialog()
-{
- delete d_ptr;
-}
-
-void L2tpAuthDialog::readSecrets()
-{
- Q_D(L2tpAuthDialog);
- const NMStringMap data = d->setting->data();
- const NMStringMap secrets = d->setting->secrets();
-
- QString user = data.value(NM_L2TP_KEY_USER);
- if (!user.isEmpty()) {
- d->ui.leUserName->setText(user);
- }
- bool haveUserPassword = true;
- if (!((NetworkManager::Setting::SecretFlags)data.value(NM_L2TP_KEY_PASSWORD"-flags").toInt()).testFlag(NetworkManager::Setting::NotRequired)) {
- d->ui.leUserPassword->setText(secrets.value(QLatin1String(NM_L2TP_KEY_PASSWORD)));
- } else {
- d->ui.userNameLabel->setVisible(false);
- d->ui.leUserName->setVisible(false);
- d->ui.userPasswordLabel->setVisible(false);
- d->ui.leUserPassword->setVisible(false);
- haveUserPassword = false;
- }
-
- if (haveUserPassword && d->ui.leUserPassword->text().isEmpty()) {
- d->ui.leUserPassword->setFocus(Qt::OtherFocusReason);
- }
-}
-
-QVariantMap L2tpAuthDialog::setting(bool agentOwned) const
-{
- Q_D(const L2tpAuthDialog);
- Q_UNUSED(agentOwned)
-
- NMStringMap secrets;
- QVariantMap result;
-
- if (!d->ui.leUserPassword->text().isEmpty()) {
- secrets.insert(NM_L2TP_KEY_PASSWORD, d->ui.leUserPassword->text());
- }
-
- result.insert("secrets", QVariant::fromValue<NMStringMap>(secrets));
-
- return result;
-}
-
-void L2tpAuthDialog::showPasswordsChanged(bool show)
-{
- Q_D(L2tpAuthDialog);
- d->ui.leUserPassword->setPasswordMode(!show);
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_L2TP_AUTH_H
-#define PLASMA_NM_L2TP_AUTH_H
-
-#include <NetworkManagerQt/VpnSetting>
-
-#include "settingwidget.h"
-
-class L2tpAuthDialogPrivate;
-
-class L2tpAuthDialog : public SettingWidget
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(L2tpAuthDialog)
-public:
- explicit L2tpAuthDialog(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~L2tpAuthDialog();
- virtual void readSecrets();
- virtual QVariantMap setting(bool agentOwned = false) const;
-
-private slots:
- void showPasswordsChanged(bool);
-
-private:
- L2tpAuthDialogPrivate * d_ptr;
-};
-
-#endif // PLASMA_NM_L2TP_AUTH_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>L2tpAuth</class>
- <widget class="QWidget" name="L2tpAuth">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>378</width>
- <height>133</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="userNameLabel">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>leUserName</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="leUserName">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="userPasswordLabel">
- <property name="text">
- <string>User Password:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>leUserPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="leUserPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QCheckBox" name="cbShowPasswords">
- <property name="text">
- <string>Show passwords</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>L2tpPppWidget</class>
- <widget class="QWidget" name="L2tpPppWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>376</width>
- <height>553</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout_3">
- <item row="0" column="0" colspan="2">
- <widget class="QGroupBox" name="grp_authenfication">
- <property name="title">
- <string>Authentication</string>
- </property>
- <layout class="QFormLayout" name="formLayout_5">
- <item row="0" column="0">
- <widget class="QLabel" name="lblauth">
- <property name="text">
- <string>Allow following authentication methods:</string>
- </property>
- <property name="buddy">
- <cstring>listWidget</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QListWidget" name="listWidget">
- <item>
- <property name="text">
- <string>PAP</string>
- </property>
- <property name="checkState">
- <enum>Checked</enum>
- </property>
- </item>
- <item>
- <property name="text">
- <string>CHAP</string>
- </property>
- <property name="checkState">
- <enum>Checked</enum>
- </property>
- </item>
- <item>
- <property name="text">
- <string>MSCHAP</string>
- </property>
- <property name="checkState">
- <enum>Checked</enum>
- </property>
- </item>
- <item>
- <property name="text">
- <string>MSCHAPv2</string>
- </property>
- <property name="checkState">
- <enum>Checked</enum>
- </property>
- </item>
- <item>
- <property name="text">
- <string>EAP</string>
- </property>
- <property name="checkState">
- <enum>Checked</enum>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QGroupBox" name="gbMPPE">
- <property name="toolTip">
- <string>Use Microsoft Point-to-Point Encryption</string>
- </property>
- <property name="title">
- <string>Use MPPE Encryption</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <layout class="QFormLayout" name="formLayout_4">
- <item row="0" column="0">
- <widget class="QLabel" name="lblMMPEcrypto">
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Crypto:</string>
- </property>
- <property name="buddy">
- <cstring>cbMPPECrypto</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="cbMPPECrypto">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string comment="like in use Any configuration">Any</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>128 bit</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>40 bit</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QCheckBox" name="cbstatefulEncryption">
- <property name="text">
- <string>Use stateful encryption</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QGroupBox" name="grp_cryptoAndCompression">
- <property name="title">
- <string>Compression</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <property name="labelAlignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <item row="0" column="0">
- <widget class="QCheckBox" name="cbBSD">
- <property name="text">
- <string>Allow BSD compression</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="cbdeflate">
- <property name="text">
- <string>Allow Deflate compression</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="cbTCPheaders">
- <property name="text">
- <string>Allow TCP header compression</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="cbCompressionNegotiation">
- <property name="text">
- <string>Use protocol field compression negotiation</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="tristate">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QCheckBox" name="cbAddressControlCompression">
- <property name="text">
- <string>Use Address/Control compression</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QGroupBox" name="grp_echo">
- <property name="title">
- <string>Echo</string>
- </property>
- <layout class="QFormLayout" name="formLayout_2">
- <item row="0" column="0">
- <widget class="QCheckBox" name="cbsendEcho">
- <property name="text">
- <string>Send PPP echo packets </string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="4" column="0" colspan="2">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- <zorder>grp_authenfication</zorder>
- <zorder>grp_echo</zorder>
- <zorder>grp_cryptoAndCompression</zorder>
- <zorder>gbMPPE</zorder>
- <zorder>buttonBox</zorder>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>listWidget</tabstop>
- <tabstop>gbMPPE</tabstop>
- <tabstop>cbMPPECrypto</tabstop>
- <tabstop>cbstatefulEncryption</tabstop>
- <tabstop>cbBSD</tabstop>
- <tabstop>cbdeflate</tabstop>
- <tabstop>cbTCPheaders</tabstop>
- <tabstop>cbCompressionNegotiation</tabstop>
- <tabstop>cbAddressControlCompression</tabstop>
- <tabstop>cbsendEcho</tabstop>
- <tabstop>buttonBox</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>L2tpPppWidget</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>187</x>
- <y>536</y>
- </hint>
- <hint type="destinationlabel">
- <x>187</x>
- <y>276</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>L2tpPppWidget</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>187</x>
- <y>536</y>
- </hint>
- <hint type="destinationlabel">
- <x>187</x>
- <y>276</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>gbMPPE</sender>
- <signal>toggled(bool)</signal>
- <receiver>cbMPPECrypto</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>187</x>
- <y>250</y>
- </hint>
- <hint type="destinationlabel">
- <x>239</x>
- <y>248</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>gbMPPE</sender>
- <signal>toggled(bool)</signal>
- <receiver>cbstatefulEncryption</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>187</x>
- <y>250</y>
- </hint>
- <hint type="destinationlabel">
- <x>187</x>
- <y>277</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "l2tppppwidget.h"
-#include "ui_l2tpppp.h"
-#include "nm-l2tp-service.h"
-
-#include <QDebug>
-#include <KLocalizedString>
-#include <KAcceleratorManager>
-
-L2tpPPPWidget::L2tpPPPWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent) :
- QDialog(parent),
- m_ui(new Ui::L2tpPppWidget)
-{
- m_ui->setupUi(this);
-
- setWindowTitle(i18n("L2TP PPP Options"));
-
- KAcceleratorManager::manage(this);
-
- loadConfig(setting);
-}
-
-L2tpPPPWidget::~L2tpPPPWidget()
-{
- delete m_ui;
-}
-
-void L2tpPPPWidget::loadConfig(const NetworkManager::VpnSetting::Ptr &setting)
-{
- // General settings
- const NMStringMap dataMap = setting->data();
-
- // Authentication options
- const QString yesString = QLatin1String("yes");
- bool refuse_pap = (dataMap[NM_L2TP_KEY_REFUSE_PAP] == yesString);
- bool refuse_chap = (dataMap[NM_L2TP_KEY_REFUSE_CHAP] == yesString);
- bool refuse_mschap = (dataMap[NM_L2TP_KEY_REFUSE_MSCHAP] == yesString);
- bool refuse_mschapv2 = (dataMap[NM_L2TP_KEY_REFUSE_MSCHAPV2] == yesString);
- bool refuse_eap = (dataMap[NM_L2TP_KEY_REFUSE_EAP] == yesString);
-
- QListWidgetItem * item = 0;
- item = m_ui->listWidget->item(0); // PAP
- item->setCheckState(refuse_pap ? Qt::Unchecked : Qt::Checked);
- item = m_ui->listWidget->item(1); // CHAP
- item->setCheckState(refuse_chap ? Qt::Unchecked : Qt::Checked);
- item = m_ui->listWidget->item(2); // MSCHAP
- item->setCheckState(refuse_mschap ? Qt::Unchecked : Qt::Checked);
- item = m_ui->listWidget->item(3); // MSCHAPv2
- item->setCheckState(refuse_mschapv2 ? Qt::Unchecked : Qt::Checked);
- item = m_ui->listWidget->item(4); // EAP
- item->setCheckState(refuse_eap ? Qt::Unchecked : Qt::Checked);
-
- // Cryptography and compression
- const bool mppe = (dataMap[NM_L2TP_KEY_REQUIRE_MPPE] == yesString);
- const bool mppe40 = (dataMap[NM_L2TP_KEY_REQUIRE_MPPE_40] == yesString);
- const bool mppe128 = (dataMap[NM_L2TP_KEY_REQUIRE_MPPE_128] == yesString);
- const bool mppe_stateful = (dataMap[NM_L2TP_KEY_MPPE_STATEFUL] == yesString);
-
- if (mppe || mppe40 || mppe128) { // If MPPE is use
- m_ui->gbMPPE->setChecked(mppe || mppe40 || mppe128);
- if (mppe128) {
- m_ui->cbMPPECrypto->setCurrentIndex(1); // 128 bit
- }
- else if (mppe40) {
- m_ui->cbMPPECrypto->setCurrentIndex(2); // 40 bit
- }
- else {
- m_ui->cbMPPECrypto->setCurrentIndex(0); // Any
- }
- m_ui->cbstatefulEncryption->setChecked(mppe_stateful);
- }
-
- const bool nobsd = (dataMap[NM_L2TP_KEY_NOBSDCOMP] == yesString);
- m_ui->cbBSD->setChecked(!nobsd);
-
- const bool nodeflate = (dataMap[NM_L2TP_KEY_NODEFLATE] == yesString);
- m_ui->cbdeflate->setChecked(!nodeflate);
-
- const bool novjcomp = (dataMap[NM_L2TP_KEY_NO_VJ_COMP] == yesString);
- m_ui->cbTCPheaders->setChecked(!novjcomp);
-
- const bool nopcomp = (dataMap[NM_L2TP_KEY_NO_PCOMP] == yesString);
- m_ui->cbCompressionNegotiation->setChecked(!nopcomp);
-
- const bool noaccomp = (dataMap[NM_L2TP_KEY_NO_ACCOMP] == yesString);
- m_ui->cbAddressControlCompression->setChecked(!noaccomp);
-
- // Echo
- const int lcp_echo_interval = QString(dataMap[NM_L2TP_KEY_LCP_ECHO_INTERVAL]).toInt();
- m_ui->cbsendEcho->setChecked(lcp_echo_interval > 0);
-}
-
-NMStringMap L2tpPPPWidget::setting() const
-{
- NMStringMap result;
-
- QListWidgetItem * item = 0;
- item = m_ui->listWidget->item(0); // PAP
- const QString yesString = QLatin1String("yes");
- if (item->checkState() == Qt::Unchecked)
- result.insert(NM_L2TP_KEY_REFUSE_PAP, yesString);
- item = m_ui->listWidget->item(1); // CHAP
- if (item->checkState() == Qt::Unchecked)
- result.insert(NM_L2TP_KEY_REFUSE_CHAP, yesString);
- item = m_ui->listWidget->item(2); // MSCHAP
- if (item->checkState() == Qt::Unchecked)
- result.insert(NM_L2TP_KEY_REFUSE_MSCHAP, yesString);
- item = m_ui->listWidget->item(3); // MSCHAPv2
- if (item->checkState() == Qt::Unchecked)
- result.insert(NM_L2TP_KEY_REFUSE_MSCHAPV2, yesString);
- item = m_ui->listWidget->item(4); // EAP
- if (item->checkState() == Qt::Unchecked)
- result.insert(NM_L2TP_KEY_REFUSE_EAP, yesString);
-
- // Cryptography and compression
- if (m_ui->gbMPPE->isChecked()) {
- int index = m_ui->cbMPPECrypto->currentIndex();
-
- switch (index) {
- case 0: // "Any"
- result.insert(NM_L2TP_KEY_REQUIRE_MPPE, yesString);
- break;
- case 1: // "128 bit"
- result.insert(NM_L2TP_KEY_REQUIRE_MPPE_128, yesString);
- break;
- case 2: // "40 bit"
- result.insert(NM_L2TP_KEY_REQUIRE_MPPE_40, yesString);
- break;
- }
-
- if (m_ui->cbstatefulEncryption->isChecked()) {
- result.insert(NM_L2TP_KEY_MPPE_STATEFUL, yesString);
- }
- }
-
- if (!m_ui->cbBSD->isChecked()) {
- result.insert(NM_L2TP_KEY_NOBSDCOMP, yesString);
-
- }
- if (!m_ui->cbdeflate->isChecked()) {
- result.insert(NM_L2TP_KEY_NODEFLATE, yesString);
- }
-
- if (!m_ui->cbTCPheaders->isChecked()) {
- result.insert(NM_L2TP_KEY_NO_VJ_COMP, yesString);
- }
-
- if (!m_ui->cbCompressionNegotiation->isChecked()) {
- result.insert(NM_L2TP_KEY_NO_PCOMP, yesString);
- }
-
- if (!m_ui->cbAddressControlCompression->isChecked()) {
- result.insert(NM_L2TP_KEY_NO_ACCOMP, yesString);
- }
-
- // Echo
- if (m_ui->cbsendEcho->isChecked()) {
- result.insert(NM_L2TP_KEY_LCP_ECHO_FAILURE, "5");
- result.insert(NM_L2TP_KEY_LCP_ECHO_INTERVAL, "30");
- }
-
- qDebug() << "RESULT - " << result;
- return result;
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_L2TP_PPP_WIDGET_H
-#define PLASMA_NM_L2TP_PPP_WIDGET_H
-
-#include <QDialog>
-
-#include <NetworkManagerQt/VpnSetting>
-
-namespace Ui
-{
-class L2tpPppWidget;
-}
-
-class L2tpPPPWidget : public QDialog
-{
- Q_OBJECT
-public:
- explicit L2tpPPPWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent = 0);
- ~L2tpPPPWidget();
-
- NMStringMap setting() const;
-
-private:
- void loadConfig(const NetworkManager::VpnSetting::Ptr &setting);
- Ui::L2tpPppWidget * m_ui;
-};
-
-#endif // PLASMA_NM_L2TP_PPP_WIDGET_H
-
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "l2tpwidget.h"
-#include "l2tpadvancedwidget.h"
-#include "l2tppppwidget.h"
-#include "ui_l2tp.h"
-#include "nm-l2tp-service.h"
-
-#include <NetworkManagerQt/Setting>
-
-#include <QDBusMetaType>
-#include <QDebug>
-
-L2tpWidget::L2tpWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::L2tpWidget),
- m_setting(setting)
-{
- qDBusRegisterMetaType<NMStringMap>();
-
- m_ui->setupUi(this);
-
- connect(m_ui->cboUserPasswordType, SIGNAL(currentIndexChanged(int)), SLOT(userPasswordTypeChanged(int)));
- connect(m_ui->cbShowPassword, SIGNAL(toggled(bool)), SLOT(showPassword(bool)));
- connect(m_ui->btnIPSecSettings, SIGNAL(clicked(bool)), SLOT(showAdvanced()));
- connect(m_ui->btnPPPSettings, SIGNAL(clicked(bool)), SLOT(showPpp()));
-
- connect(m_ui->gateway, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (m_setting)
- loadConfig(setting);
-}
-
-L2tpWidget::~L2tpWidget()
-{
- m_tmpAdvancedSetting.clear();
- m_tmpPppSetting.clear();
- delete m_ui;
-}
-
-void L2tpWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- Q_UNUSED(setting);
-
- const NMStringMap data = m_setting->data();
- const NMStringMap secrets = m_setting->secrets();
-
- const QString gateway = data.value(NM_L2TP_KEY_GATEWAY);
- if (!gateway.isEmpty()) {
- m_ui->gateway->setText(gateway);
- }
-
- const QString user = data.value(NM_L2TP_KEY_USER);
- if (!user.isEmpty()) {
- m_ui->username->setText(user);
- }
-
- const QString userPassword = secrets.value(NM_L2TP_KEY_PASSWORD);
- if (!userPassword.isEmpty()) {
- m_ui->password->setText(userPassword);
- }
-
- const NetworkManager::Setting::SecretFlags userPassType = static_cast<NetworkManager::Setting::SecretFlags>(data.value(NM_L2TP_KEY_PASSWORD"-flags").toInt());
- if (userPassType.testFlag(NetworkManager::Setting::NotSaved)) {
- m_ui->cboUserPasswordType->setCurrentIndex(SettingWidget::EnumPasswordStorageType::AlwaysAsk);
- } else if (userPassType.testFlag(NetworkManager::Setting::NotRequired)) {
- m_ui->cboUserPasswordType->setCurrentIndex(SettingWidget::EnumPasswordStorageType::NotRequired);
- } else {
- m_ui->cboUserPasswordType->setCurrentIndex(SettingWidget::EnumPasswordStorageType::Store);
- }
-
- const QString domain = data.value(NM_L2TP_KEY_DOMAIN);
- if (!domain.isEmpty()) {
- m_ui->domain->setText(domain);
- }
-}
-
-QVariantMap L2tpWidget::setting(bool agentOwned) const
-{
- NetworkManager::VpnSetting setting;
- setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_L2TP));
- NMStringMap data;
- if (!m_tmpAdvancedSetting.isNull()) {
- data = m_tmpAdvancedSetting->data();
- }
- if (!m_tmpPppSetting.isNull()) {
- data.unite(m_tmpPppSetting->data());
- }
- NMStringMap secrets;
-
- if (!m_ui->gateway->text().isEmpty()) {
- data.insert(NM_L2TP_KEY_GATEWAY, m_ui->gateway->text());
- }
-
- if (!m_ui->username->text().isEmpty()) {
- data.insert(NM_L2TP_KEY_USER, m_ui->username->text());
- }
-
- if (m_ui->password->isEnabled() && !m_ui->password->text().isEmpty()) {
- secrets.insert(NM_L2TP_KEY_PASSWORD, m_ui->password->text());
- }
-
- const int userPasswordTypeIndex = m_ui->cboUserPasswordType->currentIndex();
- if (userPasswordTypeIndex == SettingWidget::EnumPasswordStorageType::AlwaysAsk) {
- data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotSaved));
- } else if (userPasswordTypeIndex == SettingWidget::EnumPasswordStorageType::NotRequired) {
- data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotRequired));
- } else { // SettingWidget::EnumPasswordStorageType::Store
- if (agentOwned) {
- data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::AgentOwned));
- } else {
- data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::None));
- }
- }
-
- if (!m_ui->domain->text().isEmpty())
- data.insert(NM_L2TP_KEY_DOMAIN, m_ui->domain->text());
-
- setting.setData(data);
- setting.setSecrets(secrets);
- return setting.toMap();
-}
-
-
-void L2tpWidget::userPasswordTypeChanged(int index)
-{
- m_ui->password->setEnabled(index == SettingWidget::EnumPasswordStorageType::Store);
-}
-
-void L2tpWidget::showPassword(bool show)
-{
- m_ui->password->setPasswordMode(!show);
-}
-
-void L2tpWidget::showAdvanced()
-{
- QPointer<L2tpAdvancedWidget> adv;
- if (m_tmpAdvancedSetting.isNull()) {
- adv = new L2tpAdvancedWidget(m_setting, this);
- } else {
- adv = new L2tpAdvancedWidget(m_tmpAdvancedSetting, this);
- }
- if (adv->exec() == QDialog::Accepted) {
- NMStringMap advData = adv->setting();
- if (!advData.isEmpty()) {
- if (m_tmpAdvancedSetting.isNull()) {
- m_tmpAdvancedSetting = NetworkManager::VpnSetting::Ptr(new NetworkManager::VpnSetting);
- }
- m_tmpAdvancedSetting->setData(advData);
- }
- }
-
- if (adv) {
- adv->deleteLater();
- }
-}
-
-void L2tpWidget::showPpp()
-{
- QPointer<L2tpPPPWidget> adv;
- if (m_tmpPppSetting.isNull()) {
- adv = new L2tpPPPWidget(m_setting, this);
- } else {
- adv = new L2tpPPPWidget(m_tmpPppSetting, this);
- }
- if (adv->exec() == QDialog::Accepted) {
- NMStringMap advData = adv->setting();
- if (!advData.isEmpty()) {
- if (m_tmpPppSetting.isNull()) {
- m_tmpPppSetting = NetworkManager::VpnSetting::Ptr(new NetworkManager::VpnSetting);
- }
- m_tmpPppSetting->setData(advData);
- }
- }
-
- if (adv) {
- adv->deleteLater();
- }
-}
-
-bool L2tpWidget::isValid() const
-{
- return !m_ui->gateway->text().isEmpty();
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_L2TP_WIDGET_H
-#define PLASMA_NM_L2TP_WIDGET_H
-
-#include <NetworkManagerQt/VpnSetting>
-
-#include "settingwidget.h"
-
-namespace Ui
-{
-class L2tpWidget;
-}
-
-class L2tpWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit L2tpWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~L2tpWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void userPasswordTypeChanged(int index);
- void showPassword(bool show);
- void showAdvanced();
- void showPpp();
-
-private:
- Ui::L2tpWidget * m_ui;
- NetworkManager::VpnSetting::Ptr m_setting;
- NetworkManager::VpnSetting::Ptr m_tmpAdvancedSetting;
- NetworkManager::VpnSetting::Ptr m_tmpPppSetting;
-};
-
-#endif // PLASMA_NM_L2TP_WIDGET_H
+++ /dev/null
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* nm-l2tp-service - L2TP VPN integration with NetworkManager
- *
- * Dan Williams <dcbw@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This 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.
- *
- * (C) Copyright 2008 Red Hat, Inc.
- */
-
-#ifndef NM_L2TP_SERVICE_H
-#define NM_L2TP_SERVICE_H
-
-#define NM_DBUS_SERVICE_L2TP_PPP "org.freedesktop.NetworkManager.l2tp-ppp"
-#define NM_DBUS_PATH_L2TP_PPP "/org/freedesktop/NetworkManager/l2tp/ppp"
-#define NM_DBUS_INTERFACE_L2TP_PPP "org.freedesktop.NetworkManager.l2tp.ppp"
-
-/* For the NM <-> VPN plugin service */
-#define NM_DBUS_SERVICE_L2TP "org.freedesktop.NetworkManager.l2tp"
-#define NM_DBUS_INTERFACE_L2TP "org.freedesktop.NetworkManager.l2tp"
-#define NM_DBUS_PATH_L2TP "/org/freedesktop/NetworkManager/l2tp"
-
-#define NM_L2TP_KEY_GATEWAY "gateway"
-#define NM_L2TP_KEY_USER "user"
-#define NM_L2TP_KEY_PASSWORD "password"
-#define NM_L2TP_KEY_DOMAIN "domain"
-#define NM_L2TP_KEY_REFUSE_EAP "refuse-eap"
-#define NM_L2TP_KEY_REFUSE_PAP "refuse-pap"
-#define NM_L2TP_KEY_REFUSE_CHAP "refuse-chap"
-#define NM_L2TP_KEY_REFUSE_MSCHAP "refuse-mschap"
-#define NM_L2TP_KEY_REFUSE_MSCHAPV2 "refuse-mschapv2"
-#define NM_L2TP_KEY_REQUIRE_MPPE "require-mppe"
-#define NM_L2TP_KEY_REQUIRE_MPPE_40 "require-mppe-40"
-#define NM_L2TP_KEY_REQUIRE_MPPE_128 "require-mppe-128"
-#define NM_L2TP_KEY_MPPE_STATEFUL "mppe-stateful"
-#define NM_L2TP_KEY_NOBSDCOMP "nobsdcomp"
-#define NM_L2TP_KEY_NODEFLATE "nodeflate"
-#define NM_L2TP_KEY_NO_VJ_COMP "no-vj-comp"
-#define NM_L2TP_KEY_NO_PCOMP "nopcomp"
-#define NM_L2TP_KEY_NO_ACCOMP "noaccomp"
-#define NM_L2TP_KEY_LCP_ECHO_FAILURE "lcp-echo-failure"
-#define NM_L2TP_KEY_LCP_ECHO_INTERVAL "lcp-echo-interval"
-
-#define NM_L2TP_KEY_IPSEC_ENABLE "ipsec-enabled"
-#define NM_L2TP_KEY_IPSEC_GATEWAY_ID "ipsec-gateway-id"
-#define NM_L2TP_KEY_IPSEC_GROUP_NAME "ipsec-group-name"
-#define NM_L2TP_KEY_IPSEC_PSK "ipsec-psk"
-
-#endif /* NM_L2TP_SERVICE_H */
+++ /dev/null
-[Desktop Entry]
-Type=Service
-Icon=
-ServiceTypes=PlasmaNetworkManagement/VpnUiPlugin
-X-KDE-Library=plasmanetworkmanagement_l2tpui
-X-NetworkManager-Services=org.freedesktop.NetworkManager.l2tp
-X-KDE-PluginInfo-Author=Jan Grulich
-X-KDE-PluginInfo-Email=jgrulich@redhat.com
-X-KDE-PluginInfo-Name=plasmanetworkmanagement_l2tpui
-X-KDE-PluginInfo-Version=0.1
-X-KDE-PluginInfo-Website=
-X-KDE-PluginInfo-Category=VPNService
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=false
-Name=L2TP
-Name[bg]=L2TP
-Name[bs]=L2TP
-Name[ca]=L2TP
-Name[ca@valencia]=L2TP
-Name[cs]=L2TP
-Name[da]=L2TP
-Name[de]=L2TP
-Name[el]=L2TP
-Name[en_GB]=L2TP
-Name[es]=L2TP
-Name[et]=L2TP
-Name[fi]=L2TP
-Name[fr]=L2TP
-Name[hu]=L2TP
-Name[it]=L2TP
-Name[ko]=L2TP
-Name[lt]=L2TP
-Name[nb]=L2TP
-Name[nds]=L2TP
-Name[nl]=L2TP
-Name[pl]=L2TP
-Name[pt]=L2TP
-Name[pt_BR]=L2TP
-Name[ro]=L2TP
-Name[ru]=L2TP
-Name[sk]=L2TP
-Name[sl]=L2TP
-Name[sv]=L2TP
-Name[tr]=L2TP
-Name[uk]=L2TP
-Name[x-test]=xxL2TPxx
-Name[zh_CN]=L2TP
-Comment=L2TP plugin
-Comment[bg]=Приставка за L2TP
-Comment[bs]=L2TP dodatak
-Comment[ca]=Connector de L2TP
-Comment[ca@valencia]=Connector de L2TP
-Comment[cs]=Modul L2TP
-Comment[da]=L2TP-plugin
-Comment[de]=L2TP-Modul
-Comment[el]=Πρόσθετο L2TP
-Comment[en_GB]=L2TP plugin
-Comment[es]=Complemento L2TP
-Comment[et]=L2TP plugin
-Comment[fi]=L2TP-liitännäinen
-Comment[fr]=Module externe L2TP
-Comment[hu]=L2TP bővítmény
-Comment[it]=Estensione L2TP
-Comment[ko]=L2TP 플러그인
-Comment[lt]=L2TP įskiepis
-Comment[nb]=L2TP programtillegg
-Comment[nds]=L2TP-Moduul
-Comment[nl]=L2TP-plug-in
-Comment[pl]=Wtyczka L2TP
-Comment[pt]='Plugin' do L2TP
-Comment[pt_BR]=Plugin do L2TP
-Comment[ro]=Extensie L2TP
-Comment[ru]=Модуль L2TP
-Comment[sk]=Plugin L2TP
-Comment[sl]=Vstavek L2TP
-Comment[sv]=Insticksprogram för L2TP
-Comment[tr]=L2TP eklentisi
-Comment[uk]=Додаток L2TP
-Comment[x-test]=xxL2TP pluginxx
-Comment[zh_CN]=L2TP 插件
-
+++ /dev/null
-set (MINIMUM_OPENCONNECT_VERSION_REQUIRED "3.99")
-
-set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH})
-
-macro_optional_find_package(OpenConnect ${MINIMUM_OPENCONNECT_VERSION_REQUIRED})
-if (OPENCONNECT_FOUND)
- if (${OPENCONNECT_VERSION} VERSION_LESS "3.99")
- macro_optional_find_package(OpenSSL)
- macro_log_feature(OPENSSL_FOUND "OpenSSL headers" "Encryption suite" "http://www.openssl.org" FALSE "" "Needed for OpenConnect support in Network Management")
- if (OPENSSL_FOUND)
- set (MINIMUM_OPENCONNECT_VERSION_REQUIRED "3.03")
- set (maybe_OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES})
- endif()
- endif()
-
- if (${OPENCONNECT_VERSION} VERSION_GREATER ${MINIMUM_OPENCONNECT_VERSION_REQUIRED} OR
- ${OPENCONNECT_VERSION} VERSION_EQUAL ${MINIMUM_OPENCONNECT_VERSION_REQUIRED})
-
- include_directories(${OPENCONNECT_INCLUDE_DIRS})
-
- set(openconnect_SRCS
- openconnectui.cpp
- openconnectwidget.cpp
- openconnectauth.cpp
- openconnectauthworkerthread.cpp
- openconnectprop.ui
- openconnectauth.ui)
-
- kde4_add_plugin(plasmanetworkmanagement_openconnectui ${openconnect_SRCS})
-
- target_link_libraries(plasmanetworkmanagement_openconnectui plasmanetworkmanagement-editor NetworkManagerQt ${KDE4_KIO_LIBS} ${OPENCONNECT_LIBRARIES} ${maybe_OPENSSL_LIBRARIES})
- install(TARGETS plasmanetworkmanagement_openconnectui DESTINATION ${PLUGIN_INSTALL_DIR})
-
- install( FILES plasmanetworkmanagement_openconnectui.desktop DESTINATION ${SERVICES_INSTALL_DIR})
- else()
- message("ERROR: OpenConnection version '${OPENCONNECT_VERSION}' does not match minimum required (${MINIMUM_OPENCONNECT_VERSION_REQUIRED})")
- message("OpenConnect plugin will not be built")
- set(OPENCONNECT_FOUND False)
- endif()
-else (OPENCONNECT_FOUND)
- message("OpenConnect plugin will not be built")
-endif (OPENCONNECT_FOUND)
-
-macro_log_feature(OPENCONNECT_FOUND "OpenConnect headers and library" "Cisco AnyConnect compatible VPN client" "http://www.infradead.org/openconnect.html" FALSE ${MINIMUM_OPENCONNECT_VERSION_REQUIRED} "Needed for OpenConnect support in Plasma NM")
+++ /dev/null
-# - Try to find OpenConnect
-# Once done this will define
-#
-# OPENCONNECT_FOUND - system has OpenConnect
-# OPENCONNECT_INCLUDE_DIRS - the OpenConnect include directories
-# OPENCONNECT_LIBRARIES - the libraries needed to use OpenConnect
-# OPENCONNECT_CFLAGS - Compiler switches required for using OpenConnect
-# OPENCONNECT_VERSION - version number of OpenConnect
-
-# Copyright (c) 2011, Ilia Kats <ilia-kats@gmx.net>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-
-IF (OPENCONNECT_INCLUDE_DIRS)
- # in cache already
- SET(OpenConnect_FIND_QUIETLY TRUE)
-ENDIF (OPENCONNECT_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(OPENCONNECT openconnect)
-ENDIF (NOT WIN32)
-
-IF (OPENCONNECT_FOUND)
- IF (NOT OpenConnect_FIND_QUIETLY)
- MESSAGE(STATUS "Found OpenConnect ${OPENCONNECT_VERSION}: ${OPENCONNECT_LIBRARIES}")
- ENDIF (NOT OpenConnect_FIND_QUIETLY)
-ELSE (OPENCONNECT_FOUND)
- IF (OpenConnect_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could NOT find OpenConnect, check FindPkgConfig output above!")
- ENDIF (OpenConnect_FIND_REQUIRED)
-ENDIF (OPENCONNECT_FOUND)
-
-MARK_AS_ADVANCED(OPENCONNECT_INCLUDE_DIRS OPENCONNECT_LIBRARIES OPENCONNECT_STATIC_LIBRARIES)
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
-$XGETTEXT `find . -name "*.cpp"` -o $podir/plasmanetworkmanagement_openconnectui.pot
-rm -f rc.cpp
+++ /dev/null
-README taken with slight modifications from the network-manager-openconnect
-auth dialog
-
-AnyConnect works over HTTPS; authentication is through HTTP forms and
-POST responses. Once you've filled in the forms that the server demands,
-you're rewarded with an HTTP cookie which is handed on to OpenConnect to
-actually make the connection.
-
-The auth-dialog handles the arbitrary forms as the server presents them,
-and spits out the cookie after a successful authentication. It's just a
-really simple web-browser, effectively. (It has its own HTTP client
-implementation instead of using libsoup because it needs to be able to
-support certificates from a TPM, and to work around Cisco bugs).
-
-To make it slightly more fun, you have a *choice* of servers; an
-AnyConnect VPN is provisioned with an XML file that gives various pieces
-of configuration for the client. We ignore most of the XML file, except
-the list of available VPN server addresses.
-
-So this is a brief flow of what the auth-dialog does...
-
- 1. Choose a server to connect to.
-
- If we already have the XML configuration file for this VPN, you get
- to choose a server from the list. Otherwise, you only have the host
- that you configured in the VPN setup.
-
- The auth-dialog will give you the choice of automatically connecting
- to the last server you used. It does so by storing the boolean
- 'autoconnect' option, as well as the address of the last successful
- server, in "secrets" that NetworkManager stores for it, but which
- aren't actually used by OpenConnect itself at all.
-
- 2. Offer your SSL certificate and fill in all the forms it presents.
-
- The server will present a sequence of forms which are filled in just
- like normal web forms. At this point, the auth-dialog is just acting
- like a really simple web browser. It uses the same trick with fake
- secrets to remember the answers for any multiple-choice selection,
- or input elements of type 'text'. Input elements of type 'password'
- are not currently saved, but probably should be.
-
- The choices and input boxes that we fill in at this point may not be
- limited to *just* authenticating ourselves. You may also get to make
- choices which affect your resulting connectivity. Some networks
- offer the choice of full-tunnel or split-tunnel routing, IPv6 or
- Legacy-only connectivity, etc. (The routing configuration is not
- handled by the auth-dialog; that just manifests itself in the IP
- configuration which is given to OpenConnect by the server, much
- later when the connection is actually made.)
-
-(
- 2½. Run the "Cisco Secure Desktop"[sic] trojan.
-
- In some cases you are required to download a strange executable from
- the server and run it. It is supposed to perform various "checks" on
- your system and report its results to the server. The authentication
- sequence is kept in a holding pattern with HTTP refresh responses
- until the "trojan" has done its job.
-
- Most people seem to bypass this crap and run a local tool of their
- own devising to report the "correct" results. It's just another
- simple HTTP POST, although the exact results that are expected may
- vary from one server/configuration to another.
-
- Try not to think about it. It will only make you sad.
-)
-
- 3. Note the 'webvpn' cookie.
-
- Once authentication is complete, the server's HTTP response will
- include a 'webvpn' cookie.
-
- This cookie is one of the three *real* secrets which are actually
- passed to OpenConnect to make the connection. The other two are
- the address of the server we finally ended up talking to (after
- the user's initial choice and any HTTP redirects), and a hash of
- the server's SSL certificate (to prevent MiTM attacks).
-
- 4. Check the XML configuration file.
-
- With a successful authentication, we are *also* given the SHA1 of
- the current XML configuration for this VPN connection. If it differs
- from what we have, we are expected to fetch the new one. We store
- this, base64-encoded, in yet another fake "secret".
-
- 5. Dump all the "secrets" to NetworkManager.
-
- Finally, we write the secrets into the setting, so that NM can use them.
+++ /dev/null
-/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
-/* NetworkManager -- Network link manager
- *
- * 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.
- *
- * Copyright © 2008 - 2009 Intel Corporation. //krazy:exclude=copyright
- *
- * Based on nm-openconnect-vpnc.h:
- * Copyright © 2005 - 2008 Red Hat, Inc. //krazy:exclude=copyright
- * Copyright © 2007 - 2008 Novell, Inc. //krazy:exclude=copyright
- */
-
-#ifndef NM_OPENCONNECT_SERVICE_H
-#define NM_OPENCONNECT_SERVICE_H
-
-#define NM_DBUS_SERVICE_OPENCONNECT "org.freedesktop.NetworkManager.openconnect"
-#define NM_DBUS_INTERFACE_OPENCONNECT "org.freedesktop.NetworkManager.openconnect"
-#define NM_DBUS_PATH_OPENCONNECT "/org/freedesktop/NetworkManager/openconnect"
-
-#define NM_OPENCONNECT_KEY_GATEWAY "gateway"
-#define NM_OPENCONNECT_KEY_COOKIE "cookie"
-#define NM_OPENCONNECT_KEY_GWCERT "gwcert"
-#define NM_OPENCONNECT_KEY_AUTHTYPE "authtype"
-#define NM_OPENCONNECT_KEY_USERCERT "usercert"
-#define NM_OPENCONNECT_KEY_CACERT "cacert"
-#define NM_OPENCONNECT_KEY_PRIVKEY "userkey"
-#define NM_OPENCONNECT_KEY_MTU "mtu"
-#define NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID "pem_passphrase_fsid"
-#define NM_OPENCONNECT_KEY_PROXY "proxy"
-#define NM_OPENCONNECT_KEY_CSD_ENABLE "enable_csd_trojan"
-#define NM_OPENCONNECT_KEY_CSD_WRAPPER "csd_wrapper"
-
-#define NM_OPENCONNECT_USER "nm-openconnect"
-
-#endif /* NM_OPENCONNECT_PLUGIN_H */
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "openconnectauth.h"
-#include "openconnectauthworkerthread.h"
-#include "ui_openconnectauth.h"
-
-#include <KDialog>
-#include <KLineEdit>
-#include <KDialogButtonBox>
-#include <KPushButton>
-#include <KComboBox>
-#include <KDebug>
-#include <KLocale>
-
-#include <QPushButton>
-#include <QString>
-#include <QLabel>
-#include <QEventLoop>
-#include <QFormLayout>
-#include <QDomDocument>
-#include <QMutex>
-#include <QWaitCondition>
-#include <QCryptographicHash>
-#include <QFile>
-#include <QTimer>
-
-#include "nm-openconnect-service.h"
-
-#include <cstdarg>
-
-extern "C"
-{
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-}
-
-// name/address: IP/domain name of the host (OpenConnect accepts both, so no difference here)
-// group: user group on the server
-typedef struct {
- QString name;
- QString group;
- QString address;
-} VPNHost;
-
-class OpenconnectAuthWidgetPrivate
-{
-public:
- Ui_OpenconnectAuth ui;
- NetworkManager::VpnSetting::Ptr setting;
- struct openconnect_info *vpninfo;
- NMStringMap secrets;
- NMStringMap tmpSecrets;
- QMutex mutex;
- QWaitCondition workerWaiting;
- OpenconnectAuthWorkerThread *worker;
- QList<VPNHost> hosts;
- bool userQuit;
- bool formGroupChanged;
- int cancelPipes[2];
- QList<QPair<QString, int> > serverLog;
-
- enum LogLevels {Error = 0, Info, Debug, Trace};
-};
-
-
-OpenconnectAuthWidget::OpenconnectAuthWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
- : SettingWidget(setting, parent), d_ptr(new OpenconnectAuthWidgetPrivate)
-{
- Q_D(OpenconnectAuthWidget);
- d->setting = setting;
- d->ui.setupUi(this);
- d->userQuit = false;
- d->formGroupChanged = false;
-
- if (pipe2(d->cancelPipes, O_NONBLOCK|O_CLOEXEC)) {
- // Should never happen. Just don't do real cancellation if it does
- d->cancelPipes[0] = -1;
- d->cancelPipes[1] = -1;
- }
-
- connect(d->ui.cmbLogLevel, SIGNAL(currentIndexChanged(int)), this, SLOT(logLevelChanged(int)));
- connect(d->ui.viewServerLog, SIGNAL(toggled(bool)), this, SLOT(viewServerLogToggled(bool)));
- connect(d->ui.btnConnect, SIGNAL(clicked()), this, SLOT(connectHost()));
-
- d->ui.cmbLogLevel->setCurrentIndex(OpenconnectAuthWidgetPrivate::Debug);
- d->ui.btnConnect->setIcon(KIcon("network-connect"));
- d->ui.viewServerLog->setChecked(false);
-
- d->worker = new OpenconnectAuthWorkerThread(&d->mutex, &d->workerWaiting, &d->userQuit, &d->formGroupChanged, d->cancelPipes[0]);
-
- // gets the pointer to struct openconnect_info (defined in openconnect.h), which contains data that OpenConnect needs,
- // and which needs to be populated with settings we get from NM, like host, certificate or private key
- d->vpninfo = d->worker->getOpenconnectInfo();
-
- connect(d->worker, SIGNAL(validatePeerCert(QString,QString,QString,bool*)), this, SLOT(validatePeerCert(QString,QString,QString,bool*)));
- connect(d->worker, SIGNAL(processAuthForm(oc_auth_form*)), this, SLOT(processAuthForm(oc_auth_form*)));
- connect(d->worker, SIGNAL(updateLog(QString,int)), this, SLOT(updateLog(QString,int)));
- connect(d->worker, SIGNAL(writeNewConfig(QString)), this, SLOT(writeNewConfig(QString)));
- connect(d->worker, SIGNAL(cookieObtained(int)), this, SLOT(workerFinished(int)));
-
- readConfig();
- readSecrets();
-
- // This might be set by readSecrets() so don't connect it until now
- connect(d->ui.cmbHosts, SIGNAL(currentIndexChanged(int)), this, SLOT(connectHost()));
-
- KAcceleratorManager::manage(this);
-}
-
-OpenconnectAuthWidget::~OpenconnectAuthWidget()
-{
- Q_D(OpenconnectAuthWidget);
- d->userQuit = true;
- if (write(d->cancelPipes[1], "x", 1)) {
- // not a lot we can do
- }
- d->workerWaiting.wakeAll();
- d->worker->wait();
- ::close(d->cancelPipes[0]);
- ::close(d->cancelPipes[1]);
- deleteAllFromLayout(d->ui.loginBoxLayout);
- delete d->worker;
- delete d;
-}
-
-void OpenconnectAuthWidget::readConfig()
-{
- Q_D(OpenconnectAuthWidget);
-
- const NMStringMap dataMap = d->setting->data();
-
- if (!dataMap[NM_OPENCONNECT_KEY_GATEWAY].isEmpty()) {
- const QString gw = dataMap[NM_OPENCONNECT_KEY_GATEWAY];
- VPNHost host;
- const int index = gw.indexOf(QLatin1Char('/'));
- if (index > -1) {
- host.name = host.address = gw.left(index);
- host.group = gw.right(gw.length() - index - 1);
- } else {
- host.name = host.address = gw;
- }
- d->hosts.append(host);
- }
- if (!dataMap[NM_OPENCONNECT_KEY_CACERT].isEmpty()) {
- const QByteArray crt = QFile::encodeName(dataMap[NM_OPENCONNECT_KEY_CACERT]);
- openconnect_set_cafile(d->vpninfo, OC3DUP(crt.data()));
- }
- if (dataMap[NM_OPENCONNECT_KEY_CSD_ENABLE] == "yes") {
- char *wrapper;
- wrapper = 0;
- if (!dataMap[NM_OPENCONNECT_KEY_CSD_WRAPPER].isEmpty()) {
- const QByteArray wrapperScript = QFile::encodeName(dataMap[NM_OPENCONNECT_KEY_CSD_WRAPPER]);
- wrapper = strdup(wrapperScript.data());
- }
- openconnect_setup_csd(d->vpninfo, getuid(), 1, wrapper);
- }
- if (!dataMap[NM_OPENCONNECT_KEY_PROXY].isEmpty()) {
- const QByteArray proxy = QFile::encodeName(dataMap[NM_OPENCONNECT_KEY_PROXY]);
- openconnect_set_http_proxy(d->vpninfo, OC3DUP(proxy.data()));
- }
- if (!dataMap[NM_OPENCONNECT_KEY_USERCERT].isEmpty()) {
- const QByteArray crt = QFile::encodeName(dataMap[NM_OPENCONNECT_KEY_USERCERT]);
- const QByteArray key = QFile::encodeName(dataMap[NM_OPENCONNECT_KEY_PRIVKEY]);
- openconnect_set_client_cert (d->vpninfo, OC3DUP(crt.data()), OC3DUP(key.data()));
-
- if (!crt.isEmpty() && dataMap[NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID] == "yes") {
- openconnect_passphrase_from_fsid(d->vpninfo);
- }
- }
-}
-
-void OpenconnectAuthWidget::readSecrets()
-{
- Q_D(OpenconnectAuthWidget);
-
- d->secrets = d->setting->secrets();
-
- if (!d->secrets["xmlconfig"].isEmpty()) {
- const QByteArray config = QByteArray::fromBase64(d->secrets["xmlconfig"].toAscii());
-
- QCryptographicHash hash(QCryptographicHash::Sha1);
- hash.addData(config.data(), config.size());
- const char *sha1_text = hash.result().toHex();
- openconnect_set_xmlsha1 (d->vpninfo, (char *)sha1_text, strlen(sha1_text)+1);
-
- QDomDocument xmlconfig;
- xmlconfig.setContent(config);
- const QDomNode anyConnectProfile = xmlconfig.elementsByTagName(QLatin1String("AnyConnectProfile")).at(0);
- bool matchedGw = false;
- const QDomNode serverList = anyConnectProfile.firstChildElement(QLatin1String("ServerList"));
- for (QDomElement entry = serverList.firstChildElement(QLatin1String("HostEntry")); !entry.isNull(); entry = entry.nextSiblingElement(QLatin1String("HostEntry"))) {
- VPNHost host;
- host.name = entry.firstChildElement(QLatin1String("HostName")).text();
- host.group = entry.firstChildElement(QLatin1String("UserGroup")).text();
- host.address = entry.firstChildElement(QLatin1String("HostAddress")).text();
- // We added the originally configured host in readConfig(). But if
- // it matches one of the ones in the XML config (as presumably it
- // should), remove the original and use the one with the pretty name.
- if (!matchedGw && host.address == d->hosts.at(0).address) {
- d->hosts.removeFirst();
- matchedGw = true;
- }
- d->hosts.append(host);
- }
- }
-
- for (int i = 0; i < d->hosts.size(); i++) {
- d->ui.cmbHosts->addItem(d->hosts.at(i).name, i);
- if (d->secrets["lasthost"] == d->hosts.at(i).name || d->secrets["lasthost"] == d->hosts.at(i).address)
- d->ui.cmbHosts->setCurrentIndex(i);
- }
-
- if (d->secrets["autoconnect"] == "yes") {
- d->ui.chkAutoconnect->setChecked(true);
- QTimer::singleShot(0, this, SLOT(connectHost()));
- }
-
- if (d->secrets["save_passwords"] == "yes") {
- d->ui.chkStorePasswords->setChecked(true);
- }
-}
-
-void OpenconnectAuthWidget::acceptDialog()
-{
- KDialog *dialog = qobject_cast<KDialog*>(parentWidget());
- if (dialog) {
- dialog->accept();
- }
-}
-
-// This starts the worker thread, which connects to the selected AnyConnect host
-// and retrieves the login form
-void OpenconnectAuthWidget::connectHost()
-{
- Q_D(OpenconnectAuthWidget);
- d->userQuit = true;
- if (write(d->cancelPipes[1], "x", 1)) {
- // not a lot we can do
- }
- d->workerWaiting.wakeAll();
- d->worker->wait();
- d->userQuit = false;
-
- /* Suck out the cancel byte(s) */
- char buf;
- while (read(d->cancelPipes[0], &buf, 1) == 1)
- ;
- deleteAllFromLayout(d->ui.loginBoxLayout);
- int i = d->ui.cmbHosts->currentIndex();
- if (i == -1)
- return;
- i = d->ui.cmbHosts->itemData(i).toInt();
- const VPNHost &host = d->hosts.at(i);
- if (openconnect_parse_url(d->vpninfo, host.address.toAscii().data())) {
- kWarning() << "Failed to parse server URL" << host.address;
- openconnect_set_hostname(d->vpninfo, OC3DUP(host.address.toAscii().data()));
- }
- if (!openconnect_get_urlpath(d->vpninfo) && !host.group.isEmpty())
- openconnect_set_urlpath(d->vpninfo, OC3DUP(host.group.toAscii().data()));
- d->secrets["lasthost"] = host.name;
- addFormInfo(QLatin1String("dialog-information"), i18n("Contacting host, please wait..."));
- d->worker->start();
-}
-
-QVariantMap OpenconnectAuthWidget::setting(bool agentOwned) const
-{
- Q_D(const OpenconnectAuthWidget);
- Q_UNUSED(agentOwned)
-
- NMStringMap secrets;
- QVariantMap secretData;
-
- secrets.unite(d->secrets);
- QString host(openconnect_get_hostname(d->vpninfo));
- const QString port = QString::number(openconnect_get_port(d->vpninfo));
- secrets.insert(QLatin1String(NM_OPENCONNECT_KEY_GATEWAY), host + ':' + port);
-
- secrets.insert(QLatin1String(NM_OPENCONNECT_KEY_COOKIE), QLatin1String(openconnect_get_cookie(d->vpninfo)));
- openconnect_clear_cookie(d->vpninfo);
-
-#if OPENCONNECT_CHECK_VER(5,0)
- const char *fingerprint = openconnect_get_peer_cert_hash(d->vpninfo);
-#else
- OPENCONNECT_X509 *cert = openconnect_get_peer_cert(d->vpninfo);
- char fingerprint[41];
- openconnect_get_cert_sha1(d->vpninfo, cert, fingerprint);
-#endif
- secrets.insert(QLatin1String(NM_OPENCONNECT_KEY_GWCERT), QLatin1String(fingerprint));
- secrets.insert(QLatin1String("autoconnect"), d->ui.chkAutoconnect->isChecked() ? "yes" : "no");
- secrets.insert(QLatin1String("save_passwords"), d->ui.chkStorePasswords->isChecked() ? "yes" : "no");
-
- NMStringMap::iterator i = secrets.begin();
- while (i != secrets.end()) {
- if (i.value().isEmpty())
- i = secrets.erase(i);
- else
- i++;
- }
-
- secretData.insert("secrets", QVariant::fromValue<NMStringMap>(secrets));
-
- // These secrets are not officially part of the secrets which would be returned back to NetworkManager. We just
- // need to somehow get them to our secret agent which will handle them separately and store them.
- if (!d->tmpSecrets.isEmpty()) {
- secretData.insert("tmp-secrets", QVariant::fromValue<NMStringMap>(d->tmpSecrets));
- }
- return secretData;
-}
-
-void OpenconnectAuthWidget::writeNewConfig(const QString & buf)
-{
- Q_D(OpenconnectAuthWidget);
- d->secrets["xmlconfig"] = buf;
-}
-
-void OpenconnectAuthWidget::updateLog(const QString &message, const int &level)
-{
- Q_D(OpenconnectAuthWidget);
- QPair<QString, int> pair;
- pair.first = message;
- if (pair.first.endsWith(QLatin1String("\n")))
- pair.first.chop(1);
- switch (level)
- {
- case PRG_ERR:
- pair.second = OpenconnectAuthWidgetPrivate::Error;
- break;
- case PRG_INFO:
- pair.second = OpenconnectAuthWidgetPrivate::Info;
- break;
- case PRG_DEBUG:
- pair.second = OpenconnectAuthWidgetPrivate::Debug;
- break;
- case PRG_TRACE:
- pair.second = OpenconnectAuthWidgetPrivate::Trace;
- break;
- }
- if (pair.second <= d->ui.cmbLogLevel->currentIndex()) {
- d->ui.serverLog->append(pair.first);
- }
-
- d->serverLog.append(pair);
- if (d->serverLog.size() > 100) {
- d->serverLog.removeFirst();
- }
-}
-
-void OpenconnectAuthWidget::logLevelChanged(int newLevel)
-{
- Q_D(OpenconnectAuthWidget);
- d->ui.serverLog->clear();
- QList<QPair<QString, int> >::const_iterator i;
-
- for (i = d->serverLog.constBegin(); i != d->serverLog.constEnd(); ++i) {
- QPair<QString, int> pair = *i;
- if(pair.second <= newLevel) {
- d->ui.serverLog->append(pair.first);
- }
- }
-}
-
-void OpenconnectAuthWidget::addFormInfo(const QString &iconName, const QString &message)
-{
- Q_D(OpenconnectAuthWidget);
- QHBoxLayout *layout = new QHBoxLayout();
- QLabel *icon = new QLabel(this);
- QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- sizePolicy.setHorizontalStretch(0);
- sizePolicy.setVerticalStretch(0);
- sizePolicy.setHeightForWidth(icon->sizePolicy().hasHeightForWidth());
- icon->setSizePolicy(sizePolicy);
- icon->setMinimumSize(QSize(16, 16));
- icon->setMaximumSize(QSize(16, 16));
- layout->addWidget(icon);
-
- QLabel *text = new QLabel(this);
- text->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
- text->setWordWrap(false);
- layout->addWidget(text);
-
- icon->setPixmap(KIcon(iconName).pixmap(QSize(16,16)));
- text->setText(message);
-
- d->ui.loginBoxLayout->addLayout(layout);
-}
-
-void OpenconnectAuthWidget::processAuthForm(struct oc_auth_form *form)
-{
- Q_D(OpenconnectAuthWidget);
- deleteAllFromLayout(d->ui.loginBoxLayout);
- if (form->banner) {
- addFormInfo(QLatin1String("dialog-information"), form->banner);
- }
- if (form->message) {
- addFormInfo(QLatin1String("dialog-information"), form->message);
- }
- if (form->error) {
- addFormInfo(QLatin1String("dialog-error"), form->error);
- }
-
- struct oc_form_opt *opt;
- QFormLayout *layout = new QFormLayout();
- QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- QCheckBox *togglePasswordMode = new QCheckBox(this);
- togglePasswordMode->setText(i18n("&Show password"));
- togglePasswordMode->setChecked(false);
- connect(togglePasswordMode, SIGNAL(toggled(bool)), this, SLOT(passwordModeToggled(bool)));
- int passwordnumber = 0;
- bool focusSet = false;
- for (opt = form->opts; opt; opt = opt->next) {
- if (opt->type == OC_FORM_OPT_HIDDEN || IGNORE_OPT(opt))
- continue;
- QLabel *text = new QLabel(this);
- text->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
- text->setText(QString(opt->label));
- QWidget *widget = 0;
- const QString key = QString("form:%1:%2").arg(QLatin1String(form->auth_id)).arg(QLatin1String(opt->name));
- const QString value = d->secrets.value(key);
- if (opt->type == OC_FORM_OPT_PASSWORD || opt->type == OC_FORM_OPT_TEXT) {
- KLineEdit *le = new KLineEdit(this);
- if (opt->type == OC_FORM_OPT_PASSWORD) {
- le->setPasswordMode(true);
- le->setText(value);
- passwordnumber++;
- }
- else {
- le->setText(value);
- }
- if (!focusSet && le->text().isEmpty()) {
- le->setFocus(Qt::OtherFocusReason);
- focusSet = true;
- }
- widget = qobject_cast<QWidget*>(le);
- } else if (opt->type == OC_FORM_OPT_SELECT) {
- KComboBox *cmb = new KComboBox(this);
- struct oc_form_opt_select *sopt = reinterpret_cast<oc_form_opt_select *>(opt);
- for (int i = 0; i < sopt->nr_choices; i++) {
- cmb->addItem(QString::fromUtf8(FORMCHOICE(sopt, i)->label),
- QString::fromUtf8(FORMCHOICE(sopt, i)->name));
- if (value == QString::fromUtf8(FORMCHOICE(sopt, i)->name)) {
- cmb->setCurrentIndex(i);
- if (sopt == AUTHGROUP_OPT(form) &&
- i != AUTHGROUP_SELECTION(form)) {
- QTimer::singleShot(0, this, SLOT(formGroupChanged()));
- }
- }
- }
- if (sopt == AUTHGROUP_OPT(form)) {
- connect(cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(formGroupChanged()));
- }
- widget = qobject_cast<QWidget*>(cmb);
- }
- if (widget) {
- widget->setProperty("openconnect_opt", (quintptr)opt);
- widget->setSizePolicy(policy);
- layout->addRow(text, widget);
- }
- }
- d->ui.loginBoxLayout->addLayout(layout);
- d->ui.loginBoxLayout->addWidget(togglePasswordMode);
- if (passwordnumber == 0)
- togglePasswordMode->setVisible(false);
- KDialogButtonBox *box = new KDialogButtonBox(this);
- QPushButton *btn = box->addButton(QDialogButtonBox::Ok);
- btn->setText(i18n("Login"));
- btn->setDefault(true);
- d->ui.loginBoxLayout->addWidget(box);
- box->setProperty("openconnect_form", (quintptr)form);
-
- connect(box, SIGNAL(accepted()), this, SLOT(formLoginClicked()));
-}
-
-void OpenconnectAuthWidget::validatePeerCert(const QString &fingerprint,
- const QString &peerCert, const QString &reason, bool *accepted)
-{
- Q_D(OpenconnectAuthWidget);
-
- const QString host = QLatin1String(openconnect_get_hostname(d->vpninfo));
- const QString port = QString::number(openconnect_get_port(d->vpninfo));
- const QString key = QString("certificate:%1:%2").arg(host, port);
- const QString value = d->secrets.value(key);
-
-#if !OPENCONNECT_CHECK_VER(5,0)
-#define openconnect_check_peer_cert_hash(v,d) strcmp(d, fingerprint.toUtf8().data())
-#endif
-
- if (openconnect_check_peer_cert_hash(d->vpninfo, value.toUtf8().data())) {
- QWidget *widget = new QWidget();
- QVBoxLayout *verticalLayout;
- QHBoxLayout *horizontalLayout;
- QLabel *icon;
- QLabel *infoText;
- QTextBrowser *certificate;
-
- verticalLayout = new QVBoxLayout(widget);
- horizontalLayout = new QHBoxLayout(widget);
- icon = new QLabel(widget);
- QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- sizePolicy.setHorizontalStretch(0);
- sizePolicy.setVerticalStretch(0);
- sizePolicy.setHeightForWidth(icon->sizePolicy().hasHeightForWidth());
- icon->setSizePolicy(sizePolicy);
- icon->setMinimumSize(QSize(48, 48));
- icon->setMaximumSize(QSize(48, 48));
-
- horizontalLayout->addWidget(icon);
-
- infoText = new QLabel(widget);
- infoText->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
-
- horizontalLayout->addWidget(infoText);
-
- verticalLayout->addLayout(horizontalLayout);
-
- certificate = new QTextBrowser(widget);
- certificate->setTextInteractionFlags(Qt::TextSelectableByMouse);
- certificate->setOpenLinks(false);
-
- verticalLayout->addWidget(certificate);
-
- icon->setPixmap(KIcon("dialog-information").pixmap(QSize(48,48)));
- infoText->setText(i18n("Check failed for certificate from VPN server \"%1\".\n"
- "Reason: %2\nAccept it anyway?", openconnect_get_hostname(d->vpninfo),reason));
- infoText->setWordWrap(true);
- certificate->setText(peerCert);
-
- QWeakPointer<KDialog> dialog = new KDialog(this);
- dialog.data()->setWindowModality(Qt::WindowModal);
- dialog.data()->setButtons(KDialog::Yes | KDialog::No);
- dialog.data()->setMainWidget(widget);
- if(dialog.data()->exec() == KDialog::Yes) {
- *accepted = true;
- } else {
- *accepted = false;
- }
- if (dialog) {
- dialog.data()->deleteLater();
- }
- widget->deleteLater();
- } else {
- *accepted = true;
- }
- if (*accepted)
- d->secrets.insert(key, QString(fingerprint));
- d->mutex.lock();
- d->workerWaiting.wakeAll();
- d->mutex.unlock();
-}
-
-void OpenconnectAuthWidget::formGroupChanged()
-{
- Q_D(OpenconnectAuthWidget);
-
- d->formGroupChanged = true;
- formLoginClicked();
-}
-
-// Writes the user input from the form into the oc_auth_form structs we got from
-// libopenconnect, and wakes the worker thread up to try to log in and obtain a
-// cookie with this data
-void OpenconnectAuthWidget::formLoginClicked()
-{
- Q_D(OpenconnectAuthWidget);
-
- const int lastIndex = d->ui.loginBoxLayout->count() - 1;
- QLayout *layout = d->ui.loginBoxLayout->itemAt(lastIndex - 2)->layout();
- struct oc_auth_form *form = (struct oc_auth_form *) d->ui.loginBoxLayout->itemAt(lastIndex)->widget()->property("openconnect_form").value<quintptr>();
-
- for (int i = 0; i < layout->count(); i++) {
- QLayoutItem *item = layout->itemAt(i);
- QWidget *widget = item->widget();
- if (widget && widget->property("openconnect_opt").isValid()) {
- struct oc_form_opt *opt = (struct oc_form_opt *) widget->property("openconnect_opt").value<quintptr>();
- const QString key = QString("form:%1:%2").arg(QLatin1String(form->auth_id)).arg(QLatin1String(opt->name));
- if (opt->type == OC_FORM_OPT_PASSWORD || opt->type == OC_FORM_OPT_TEXT) {
- KLineEdit *le = qobject_cast<KLineEdit*>(widget);
- QByteArray text = le->text().toUtf8();
- openconnect_set_option_value(opt, text.data());
- if (opt->type == OC_FORM_OPT_TEXT) {
- d->secrets.insert(key, le->text());
- } else {
- d->tmpSecrets.insert(key, le->text());
- }
- } else if (opt->type == OC_FORM_OPT_SELECT) {
- KComboBox *cbo = qobject_cast<KComboBox*>(widget);
- QByteArray text = cbo->itemData(cbo->currentIndex()).toString().toAscii();
- openconnect_set_option_value(opt, text.data());
- d->secrets.insert(key,cbo->itemData(cbo->currentIndex()).toString());
- }
- }
- }
-
- deleteAllFromLayout(d->ui.loginBoxLayout);
- d->workerWaiting.wakeAll();
-}
-
-void OpenconnectAuthWidget::workerFinished(const int &ret)
-{
- Q_D(OpenconnectAuthWidget);
- if (ret < 0) {
- QString message;
- QList<QPair<QString, int> >::const_iterator i;
- for (i = d->serverLog.constEnd()-1; i >= d->serverLog.constBegin(); --i) {
- QPair<QString, int> pair = *i;
- if(pair.second <= OpenconnectAuthWidgetPrivate::Error) {
- message = pair.first;
- break;
- }
- }
- if (message.isEmpty())
- message = i18n("Connection attempt was unsuccessful.");
- deleteAllFromLayout(d->ui.loginBoxLayout);
- addFormInfo(QLatin1String("dialog-error"), message);
- } else {
- deleteAllFromLayout(d->ui.loginBoxLayout);
- acceptDialog();
- }
-}
-
-void OpenconnectAuthWidget::deleteAllFromLayout(QLayout *layout)
-{
- while (QLayoutItem *item = layout->takeAt(0)) {
- if (QLayout *itemLayout = item->layout()) {
- deleteAllFromLayout(itemLayout);
- itemLayout->deleteLater();
- }
- else
- item->widget()->deleteLater();
- delete item;
- }
- layout->invalidate();
-}
-
-void OpenconnectAuthWidget::viewServerLogToggled(bool toggled)
-{
- Q_D(OpenconnectAuthWidget);
- d->ui.lblLogLevel->setVisible(toggled);
- d->ui.cmbLogLevel->setVisible(toggled);
- if (toggled) {
- QLayoutItem *item = d->ui.verticalLayout->takeAt(5);
- if (item) {
- delete item;
- }
- QSizePolicy policy = d->ui.serverLogBox->sizePolicy();
- policy.setVerticalPolicy(QSizePolicy::Expanding);
- d->ui.serverLogBox->setSizePolicy(policy);
- d->ui.serverLog->setVisible(true);
- } else {
- QSpacerItem *verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
- d->ui.verticalLayout->addItem(verticalSpacer);
- d->ui.serverLog->setVisible(false);
- QSizePolicy policy = d->ui.serverLogBox->sizePolicy();
- policy.setVerticalPolicy(QSizePolicy::Fixed);
- d->ui.serverLogBox->setSizePolicy(policy);
- }
-}
-
-void OpenconnectAuthWidget::passwordModeToggled(bool toggled)
-{
- Q_D(OpenconnectAuthWidget);
- const int lastIndex = d->ui.loginBoxLayout->count() - 1;
- QLayout *layout = d->ui.loginBoxLayout->itemAt(lastIndex - 2)->layout();
- for (int i = 0; i < layout->count(); i++) {
- QLayoutItem *item = layout->itemAt(i);
- QWidget *widget = item->widget();
- if (widget && widget->property("openconnect_opt").isValid()) {
- struct oc_form_opt *opt = (struct oc_form_opt *) widget->property("openconnect_opt").value<quintptr>();
- if (opt->type == OC_FORM_OPT_PASSWORD) {
- KLineEdit *le = qobject_cast<KLineEdit*>(widget);
- le->setPasswordMode(!toggled);
- }
- }
- }
-}
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef OPENCONNECTAUTH_H
-#define OPENCONNECTAUTH_H
-
-#include "settingwidget.h"
-
-#include <NetworkManagerQt/VpnSetting>
-
-#include <QString>
-
-class QLayout;
-struct openconnect_info;
-struct oc_auth_form;
-
-class OpenconnectAuthWidgetPrivate;
-
-class OpenconnectAuthWidget : public SettingWidget
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(OpenconnectAuthWidget)
-public:
- explicit OpenconnectAuthWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~OpenconnectAuthWidget();
- virtual void readSecrets();
- void readConfig();
- virtual QVariantMap setting(bool agentOwned = false) const;
-
-private:
- OpenconnectAuthWidgetPrivate * d_ptr;
- void acceptDialog();
- void addFormInfo(const QString &, const QString &);
- void deleteAllFromLayout(QLayout *);
-
-private slots:
- void writeNewConfig(const QString &);
- void validatePeerCert(const QString &, const QString &, const QString &, bool*);
- void processAuthForm(struct oc_auth_form *);
- void updateLog(const QString &, const int &);
- void logLevelChanged(int);
- void formLoginClicked();
- void formGroupChanged();
- void workerFinished(const int&);
- void viewServerLogToggled(bool);
- void passwordModeToggled(bool);
- void connectHost();
-};
-
-#endif // OPENCONNECTAUTH_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OpenconnectAuth</class>
- <widget class="QWidget" name="OpenconnectAuth">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>341</width>
- <height>297</height>
- </rect>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property name="windowTitle">
- <string>OpenConnect VPN Authentication</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="sizeConstraint">
- <enum>QLayout::SetMinimumSize</enum>
- </property>
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="label_3">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>VPN Host</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="cmbHosts"/>
- </item>
- <item>
- <widget class="KPushButton" name="btnConnect">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Connect</string>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- <property name="default">
- <bool>false</bool>
- </property>
- <property name="flat">
- <bool>false</bool>
- </property>
- <property name="isDragEnabled" stdset="0">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QCheckBox" name="chkAutoconnect">
- <property name="text">
- <string>Automatically start connecting next time</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="chkStorePasswords">
- <property name="text">
- <string>Store passwords</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="loginBox">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property name="title">
- <string notr="true"/>
- </property>
- <layout class="QVBoxLayout" name="loginBoxLayout"/>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="serverLogBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <layout class="QVBoxLayout" name="logLayout">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QCheckBox" name="viewServerLog">
- <property name="text">
- <string>View Log</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="lblLogLevel">
- <property name="text">
- <string>Log Level:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="cmbLogLevel">
- <item>
- <property name="text">
- <string>Error</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Info</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="like in Debug log level">Debug</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Trace</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QTextBrowser" name="serverLog">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Sunken</enum>
- </property>
- <property name="acceptRichText">
- <bool>false</bool>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::TextSelectableByMouse</set>
- </property>
- <property name="openLinks">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "openconnectauthworkerthread.h"
-
-#include <QThread>
-#include <QMutex>
-#include <QWaitCondition>
-#include <QString>
-#include <QByteArray>
-
-extern "C"
-{
-#include <openconnect.h>
-#include <stdlib.h>
-#if !OPENCONNECT_CHECK_VER(1,5)
-#include <openssl/ssl.h>
-#include <openssl/bio.h>
-#include <openssl/ossl_typ.h>
-#endif
-#include <errno.h>
-}
-
-#include <cstdarg>
-
-class OpenconnectAuthStaticWrapper
-{
-public:
-#if OPENCONNECT_CHECK_VER(5,0)
- static int writeNewConfig(void *obj, const char *str, int num)
- {
- if (obj)
- return static_cast<OpenconnectAuthWorkerThread*>(obj)->writeNewConfig(str, num);
- return -1;
- }
- static int validatePeerCert(void *obj, const char *str)
- {
- if (obj)
- return static_cast<OpenconnectAuthWorkerThread*>(obj)->validatePeerCert(NULL, str);
- return -1;
- }
-#else
- static int writeNewConfig(void *obj, char *str, int num)
- {
- if (obj)
- return static_cast<OpenconnectAuthWorkerThread*>(obj)->writeNewConfig(str, num);
- return -1;
- }
- static int validatePeerCert(void *obj, OPENCONNECT_X509 *cert, const char *str)
- {
- if (obj)
- return static_cast<OpenconnectAuthWorkerThread*>(obj)->validatePeerCert(cert, str);
- return -1;
- }
-#endif
- static int processAuthForm(void *obj, struct oc_auth_form *form)
- {
- if (obj)
- return static_cast<OpenconnectAuthWorkerThread*>(obj)->processAuthFormP(form);
- return OC_FORM_RESULT_ERR;
- }
- static void writeProgress(void *obj, int level, const char *str, ...)
- {
- if (obj) {
- va_list argPtr;
- va_start(argPtr, str);
- static_cast<OpenconnectAuthWorkerThread*>(obj)->writeProgress(level, str, argPtr);
- va_end(argPtr);
- }
- }
-};
-
-OpenconnectAuthWorkerThread::OpenconnectAuthWorkerThread(QMutex *mutex, QWaitCondition *waitForUserInput, bool *userDecidedToQuit, bool *formGroupChanged, int cancelFd)
- : QThread(), m_mutex(mutex), m_waitForUserInput(waitForUserInput), m_userDecidedToQuit(userDecidedToQuit), m_formGroupChanged(formGroupChanged)
-{
- m_openconnectInfo = openconnect_vpninfo_new((char*)"OpenConnect VPN Agent (PlasmaNM - running on KDE)",
- OpenconnectAuthStaticWrapper::validatePeerCert,
- OpenconnectAuthStaticWrapper::writeNewConfig,
- OpenconnectAuthStaticWrapper::processAuthForm,
- OpenconnectAuthStaticWrapper::writeProgress,
- this);
-#if OPENCONNECT_CHECK_VER(1,4)
- openconnect_set_cancel_fd(m_openconnectInfo, cancelFd);
-#else
- // Silence warning about unused parameter
- Q_UNUSED(cancelFd);
-#endif
-}
-
-OpenconnectAuthWorkerThread::~OpenconnectAuthWorkerThread()
-{
- openconnect_vpninfo_free(m_openconnectInfo);
-}
-
-void OpenconnectAuthWorkerThread::run()
-{
- openconnect_init_ssl();
- int ret = openconnect_obtain_cookie(m_openconnectInfo);
- if (*m_userDecidedToQuit)
- return;
- emit cookieObtained(ret);
-}
-
-struct openconnect_info* OpenconnectAuthWorkerThread::getOpenconnectInfo()
-{
- return m_openconnectInfo;
-}
-
-int OpenconnectAuthWorkerThread::writeNewConfig(const char *buf, int buflen)
-{
- Q_UNUSED(buflen)
- if (*m_userDecidedToQuit)
- return -EINVAL;
- emit writeNewConfig(QString(QByteArray(buf).toBase64()));
- return 0;
-}
-
-#if !OPENCONNECT_CHECK_VER(1,5)
-static char *openconnect_get_cert_details(struct openconnect_info *vpninfo,
- OPENCONNECT_X509 *cert)
-{
- Q_UNUSED(vpninfo)
-
- BIO *bp = BIO_new(BIO_s_mem());
- BUF_MEM *certinfo;
- char zero = 0;
- char *ret;
-
- X509_print_ex(bp, cert, 0, 0);
- BIO_write(bp, &zero, 1);
- BIO_get_mem_ptr(bp, &certinfo);
-
- ret = strdup(certinfo->data);
- BIO_free(bp);
-
- return ret;
-}
-#endif
-
-int OpenconnectAuthWorkerThread::validatePeerCert(void *cert, const char *reason)
-{
- if (*m_userDecidedToQuit)
- return -EINVAL;
-
-#if OPENCONNECT_CHECK_VER(5,0)
- (void)cert;
- const char *fingerprint = openconnect_get_peer_cert_hash(m_openconnectInfo);
- char *details = openconnect_get_peer_cert_details(m_openconnectInfo);
-#else
- char fingerprint[41];
- int ret = 0;
-
- ret = openconnect_get_cert_sha1(m_openconnectInfo, cert, fingerprint);
- if (ret)
- return ret;
-
- char *details = openconnect_get_cert_details(m_openconnectInfo, cert);
-#endif
- bool accepted = false;
- m_mutex->lock();
- QString qFingerprint(fingerprint);
- QString qCertinfo(details);
- QString qReason(reason);
- emit validatePeerCert(qFingerprint, qCertinfo, qReason, &accepted);
- m_waitForUserInput->wait(m_mutex);
- m_mutex->unlock();
- openconnect_free_cert_info(m_openconnectInfo, details);
- if (*m_userDecidedToQuit)
- return -EINVAL;
-
- if (accepted)
- return 0;
- else
- return -EINVAL;
-
-}
-
-int OpenconnectAuthWorkerThread::processAuthFormP(struct oc_auth_form *form)
-{
- if (*m_userDecidedToQuit)
- return -1;
-
- m_mutex->lock();
- *m_formGroupChanged = false;
- emit processAuthForm(form);
- m_waitForUserInput->wait(m_mutex);
- m_mutex->unlock();
- if (*m_userDecidedToQuit)
- return OC_FORM_RESULT_CANCELLED;
-
- if (*m_formGroupChanged)
- return OC_FORM_RESULT_NEWGROUP;
- return OC_FORM_RESULT_OK;
-}
-
-void OpenconnectAuthWorkerThread::writeProgress(int level, const char *fmt, va_list argPtr)
-{
- if (*m_userDecidedToQuit)
- return;
- QString msg;
- msg.vsprintf(fmt, argPtr);
- emit updateLog(msg, level);
-}
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef OPENCONNECTAUTHWORKERTHREAD_H
-#define OPENCONNECTAUTHWORKERTHREAD_H
-
-extern "C" {
-#include <openconnect.h>
-}
-
-#if OPENCONNECT_API_VERSION_MAJOR == 1
-#define openconnect_vpninfo_new openconnect_vpninfo_new_with_cbdata
-#define openconnect_init_ssl openconnect_init_openssl
-#endif
-
-#ifndef OPENCONNECT_CHECK_VER
-#define OPENCONNECT_CHECK_VER(x,y) 0
-#endif
-
-#if !OPENCONNECT_CHECK_VER(1,5)
-struct x509_st;
-#define OPENCONNECT_X509 struct x509_st
-#define OPENCONNECT_OPENSSL
-#endif
-
-#if OPENCONNECT_CHECK_VER(3,0)
-#define NEWGROUP_SUPPORTED 1
-#define AUTHGROUP_OPT(form) (void *)(form)->authgroup_opt
-#define AUTHGROUP_SELECTION(form) (form)->authgroup_selection
-#define FORMCHOICE(sopt, i) ((sopt)->choices[i])
-#define IGNORE_OPT(opt) ((opt)->flags & OC_FORM_OPT_IGNORE)
-#else
-#define NEWGROUP_SUPPORTED 0
-#define AUTHGROUP_OPT(form) NULL
-#define AUTHGROUP_SELECTION(form) 0
-#define FORMCHOICE(sopt, i) (&(sopt)->choices[i])
-#define IGNORE_OPT(opt) 0
-
-#define OC_FORM_RESULT_ERR -1
-#define OC_FORM_RESULT_OK 0
-#define OC_FORM_RESULT_CANCELLED 1
-#define OC_FORM_RESULT_NEWGROUP 2
-#endif
-
-#if OPENCONNECT_CHECK_VER(4,0)
-#define OC3DUP(x) (x)
-#else
-#define openconnect_set_option_value(opt, val) do { \
- struct oc_form_opt *_o = (opt); \
- free(_o->value); _o->value = strdup(val); \
- } while (0)
-#define openconnect_free_cert_info(v, x) ::free(x)
-#define OC3DUP(x) strdup(x)
-#endif
-
-#include <QThread>
-
-class QMutex;
-class QWaitCondition;
-struct openconnect_info;
-
-class OpenconnectAuthWorkerThread : public QThread
-{
- Q_OBJECT
- friend class OpenconnectAuthStaticWrapper;
-public:
- OpenconnectAuthWorkerThread(QMutex *, QWaitCondition *, bool *, bool *, int);
- ~OpenconnectAuthWorkerThread();
- struct openconnect_info* getOpenconnectInfo();
-
-signals:
- void validatePeerCert(const QString &, const QString &, const QString &, bool*);
- void processAuthForm(struct oc_auth_form *);
- void updateLog(const QString &, const int&);
- void writeNewConfig(const QString &);
- void cookieObtained(const int&);
-
-protected:
- void run();
-
-private:
- int writeNewConfig(const char *, int);
- int validatePeerCert(void *, const char *);
- int processAuthFormP(struct oc_auth_form *);
- void writeProgress(int level, const char *, va_list);
-
- QMutex *m_mutex;
- QWaitCondition *m_waitForUserInput;
- bool *m_userDecidedToQuit;
- bool *m_formGroupChanged;
- struct openconnect_info *m_openconnectInfo;
-};
-
-#endif
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OpenconnectProp</class>
- <widget class="QWidget" name="OpenconnectProp">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>306</width>
- <height>327</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>OpenConnect Settings</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QGroupBox" name="grp_general">
- <property name="title">
- <string comment="like in General settings">General</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Gateway:</string>
- </property>
- <property name="buddy">
- <cstring>leGateway</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="leGateway"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>CA Certificate:</string>
- </property>
- <property name="buddy">
- <cstring>leCaCertificate</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KUrlRequester" name="leCaCertificate"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Proxy:</string>
- </property>
- <property name="buddy">
- <cstring>leProxy</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KLineEdit" name="leProxy"/>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>CSD Wrapper Script:</string>
- </property>
- <property name="buddy">
- <cstring>leCsdWrapperScript</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QCheckBox" name="chkAllowTrojan">
- <property name="text">
- <string>Allow Cisco Secure Desktop &trojan</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KUrlRequester" name="leCsdWrapperScript"/>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Certificate Authentication</string>
- </property>
- <layout class="QFormLayout" name="formLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>User Certificate:</string>
- </property>
- <property name="buddy">
- <cstring>leUserCert</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Private Key:</string>
- </property>
- <property name="buddy">
- <cstring>leUserPrivateKey</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KUrlRequester" name="leUserCert"/>
- </item>
- <item row="1" column="1">
- <widget class="KUrlRequester" name="leUserPrivateKey"/>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QCheckBox" name="chkUseFsid">
- <property name="text">
- <string>Use FSID for key passphrase</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KUrlRequester</class>
- <extends>QFrame</extends>
- <header>kurlrequester.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "openconnectui.h"
-
-#include <KPluginFactory>
-
-#include "openconnectwidget.h"
-#include "openconnectauth.h"
-
-K_PLUGIN_FACTORY(OpenconnectUiPluginFactory, registerPlugin<OpenconnectUiPlugin>();)
-K_EXPORT_PLUGIN(OpenconnectUiPluginFactory("plasmanetworkmanagement_openconnectui"))
-
-OpenconnectUiPlugin::OpenconnectUiPlugin(QObject * parent, const QVariantList &) : VpnUiPlugin(parent)
-{
-
-}
-
-OpenconnectUiPlugin::~OpenconnectUiPlugin()
-{
-
-}
-
-SettingWidget * OpenconnectUiPlugin::widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new OpenconnectSettingWidget(setting, parent);
-}
-
-SettingWidget * OpenconnectUiPlugin::askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new OpenconnectAuthWidget(setting, parent);
-}
-
-QString OpenconnectUiPlugin::suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const
-{
- Q_UNUSED(connection);
- return QString();
-}
-
-QString OpenconnectUiPlugin::supportedFileExtensions() const
-{
- return QString();
-}
-
-QMessageBox::StandardButtons OpenconnectUiPlugin::suggestedAuthDialogButtons() const
-{
- return QMessageBox::Close;
-}
-
-NMVariantMapMap OpenconnectUiPlugin::importConnectionSettings(const QString &fileName)
-{
- Q_UNUSED(fileName);
-
- // TODO : import the Openconnect connection from file and return settings
- mError = VpnUiPlugin::NotImplemented;
- return NMVariantMapMap();
-}
-
-bool OpenconnectUiPlugin::exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName)
-{
- Q_UNUSED(connection);
- Q_UNUSED(fileName);
-
- // TODO : export Openconnect connection to file
- mError = VpnUiPlugin::NotImplemented;
- return false;
-}
+++ /dev/null
-/*
-Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
-Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) version 3, or any
-later version accepted by the membership of KDE e.V. (or its
-successor approved by the membership of KDE e.V.), which shall
-act as a proxy defined in Section 6 of version 3 of the license.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef OPENCONNECT_UI_H
-#define OPENCONNECT_UI_H
-
-#include "vpnuiplugin.h"
-
-#include <QVariant>
-#include <KDialog>
-
-class OpenconnectUiPlugin : public VpnUiPlugin
-{
- Q_OBJECT
-public:
- explicit OpenconnectUiPlugin(QObject * parent = 0, const QVariantList& = QVariantList());
- virtual ~OpenconnectUiPlugin();
- virtual SettingWidget * widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- virtual SettingWidget * askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
-
- virtual QString suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const;
- virtual QString supportedFileExtensions() const;
- virtual QMessageBox::StandardButtons suggestedAuthDialogButtons() const;
- virtual NMVariantMapMap importConnectionSettings(const QString &fileName);
- virtual bool exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName);
-};
-
-#endif // OPENCONNECT_UI_H
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.de>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "openconnectwidget.h"
-#include <KDialog>
-
-#include "ui_openconnectprop.h"
-
-#include <QString>
-#include "nm-openconnect-service.h"
-
-class OpenconnectSettingWidgetPrivate
-{
-public:
- Ui_OpenconnectProp ui;
- NetworkManager::VpnSetting::Ptr setting;
-};
-
-OpenconnectSettingWidget::OpenconnectSettingWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-: SettingWidget(setting, parent), d_ptr(new OpenconnectSettingWidgetPrivate)
-{
- Q_D(OpenconnectSettingWidget);
- d->ui.setupUi(this);
- d->setting = setting;
-
- connect(d->ui.leGateway, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (d->setting)
- loadConfig(d->setting);
-}
-
-OpenconnectSettingWidget::~OpenconnectSettingWidget()
-{
- delete d_ptr;
-}
-
-void OpenconnectSettingWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- Q_D(OpenconnectSettingWidget);
- Q_UNUSED(setting)
-
- // General settings
- const NMStringMap dataMap = d->setting->data();
-
- d->ui.leGateway->setText(dataMap[NM_OPENCONNECT_KEY_GATEWAY]);
- d->ui.leCaCertificate->setUrl(KUrl(dataMap[NM_OPENCONNECT_KEY_CACERT]));
- d->ui.leProxy->setText(dataMap[NM_OPENCONNECT_KEY_PROXY]);
- d->ui.chkAllowTrojan->setChecked(dataMap[NM_OPENCONNECT_KEY_CSD_ENABLE] == "yes");
- d->ui.leCsdWrapperScript->setUrl(KUrl(dataMap[NM_OPENCONNECT_KEY_CSD_WRAPPER]));
- d->ui.leUserCert->setUrl(KUrl(dataMap[NM_OPENCONNECT_KEY_USERCERT]));
- d->ui.leUserPrivateKey->setUrl(KUrl(dataMap[NM_OPENCONNECT_KEY_PRIVKEY]));
- d->ui.chkUseFsid->setChecked(dataMap[NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID] == "yes");
-}
-
-QVariantMap OpenconnectSettingWidget::setting(bool agentOwned) const
-{
- Q_D(const OpenconnectSettingWidget);
- Q_UNUSED(agentOwned)
-
- NetworkManager::VpnSetting setting;
- setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_OPENCONNECT));
-
- NMStringMap data;
-
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_GATEWAY), d->ui.leGateway->text());
- if (!d->ui.leCaCertificate->url().isEmpty())
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_CACERT), d->ui.leCaCertificate->url().path());
- if (!d->ui.leProxy->text().isEmpty())
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_PROXY), d->ui.leProxy->text());
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_CSD_ENABLE), d->ui.chkAllowTrojan->isChecked() ? "yes" : "no");
- if (!d->ui.leCsdWrapperScript->url().isEmpty())
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_CSD_WRAPPER), d->ui.leCsdWrapperScript->url().path());
- if (!d->ui.leUserCert->url().isEmpty())
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_USERCERT), d->ui.leUserCert->url().path());
- if (!d->ui.leUserPrivateKey->url().isEmpty())
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_PRIVKEY), d->ui.leUserPrivateKey->url().path());
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID), d->ui.chkUseFsid->isChecked() ? "yes" : "no");
-
- // Restore previous flags, this is necessary for keeping secrets stored in KWallet
- foreach (const QString &key, d->setting->data().keys()) {
- if (key.contains(QLatin1String("-flags"))) {
- data.insert(key, d->setting->data().value(key));
- }
- }
-
- /* These are different for every login session, and should not be stored */
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_COOKIE"-flags"), QString::number(NetworkManager::Setting::NotSaved));
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_GWCERT"-flags"), QString::number(NetworkManager::Setting::NotSaved));
- data.insert(QLatin1String(NM_OPENCONNECT_KEY_GATEWAY"-flags"), QString::number(NetworkManager::Setting::NotSaved));
-
- setting.setData(data);
- setting.setSecrets(d->setting->secrets());
-
- return setting.toMap();
-}
-
-bool OpenconnectSettingWidget::isValid() const
-{
- Q_D(const OpenconnectSettingWidget);
- return !d->ui.leGateway->text().isEmpty();
-}
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef OPENCONNECTWIDGET_H
-#define OPENCONNECTWIDGET_H
-
-#include "settingwidget.h"
-
-#include <NetworkManagerQt/VpnSetting>
-
-class OpenconnectSettingWidgetPrivate;
-
-class OpenconnectSettingWidget : public SettingWidget
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(OpenconnectSettingWidget)
-public:
- explicit OpenconnectSettingWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~OpenconnectSettingWidget();
- virtual void loadConfig(const NetworkManager::Setting::Ptr &setting);
- virtual QVariantMap setting(bool agentOwned = false) const;
- virtual bool isValid() const;
-
-private:
- OpenconnectSettingWidgetPrivate * d_ptr;
-};
-
-#endif // OPENCONNECTWIDGET_H
+++ /dev/null
-[Desktop Entry]
-Type=Service
-Icon=
-ServiceTypes=PlasmaNetworkManagement/VpnUiPlugin
-X-KDE-Library=plasmanetworkmanagement_openconnectui
-X-NetworkManager-Services=org.freedesktop.NetworkManager.openconnect
-X-KDE-PluginInfo-Author=Lukáš Tinkl
-X-KDE-PluginInfo-Email=ltinkl@redhat.com
-X-KDE-PluginInfo-Name=plasmanetworkmanagement_openconnectui
-X-KDE-PluginInfo-Version=0.1
-X-KDE-PluginInfo-Website=
-X-KDE-PluginInfo-Category=VPNService
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=false
-Name=OpenConnect
-Name[bg]=OpenConnect
-Name[bs]=OpenConnect
-Name[ca]=OpenConnect
-Name[ca@valencia]=OpenConnect
-Name[cs]=OpenConnect
-Name[da]=OpenConnect
-Name[de]=OpenConnect
-Name[el]=OpenConnect
-Name[en_GB]=OpenConnect
-Name[es]=OpenConnect
-Name[et]=OpenConnect
-Name[fi]=OpenConnect
-Name[fr]=OpenConnect
-Name[hu]=OpenConnect
-Name[it]=OpenConnect
-Name[ko]=OpenConnect
-Name[lt]=OpenConnect
-Name[nb]=OpenConnect
-Name[nds]=OpenConnect
-Name[nl]=OpenConnect
-Name[pl]=OpenConnect
-Name[pt]=OpenConnect
-Name[pt_BR]=OpenConnect
-Name[ro]=OpenConnect
-Name[ru]=OpenConnect
-Name[sk]=OpenConnect
-Name[sl]=OpenConnect
-Name[sv]=OpenConnect
-Name[tr]=OpenConnect
-Name[ug]=OpenConnect
-Name[uk]=OpenConnect
-Name[x-test]=xxOpenConnectxx
-Name[zh_CN]=OpenConnect
-Comment=OpenConnect Plugin
-Comment[bg]=Приставка за OpenConnect
-Comment[bs]=OpenConnect dodatak
-Comment[ca]=Connector d'OpenConnect
-Comment[ca@valencia]=Connector d'OpenConnect
-Comment[cs]=Modul OpenConnect
-Comment[da]=OpenConnect-plugin
-Comment[de]=OpenConnect-Modul
-Comment[el]=Πρόσθετο OpenConnect
-Comment[en_GB]=OpenConnect Plugin
-Comment[es]=Complemento OpenConnect
-Comment[et]=OpenConnecti plugin
-Comment[fi]=OpenConnect-liitännäinen
-Comment[fr]=Module externe OpenConnect
-Comment[hu]=OpenConnect bővítmény
-Comment[it]=Estensione OpenConnect
-Comment[ko]=OpenConnect 플러그인
-Comment[lt]=OpenConnect papildinys
-Comment[nb]=OpenConnect programtillegg
-Comment[nds]=OpenConnect-Moduul
-Comment[nl]=OpenConnect-plug-in
-Comment[pl]=Wtyczka OpenConnect
-Comment[pt]='Plugin' do OpenConnect
-Comment[pt_BR]=Plugin do OpenConnect
-Comment[ro]=Extensie OpenConnect
-Comment[ru]=Модуль OpenConnect
-Comment[sk]=Plugin OpenConnect
-Comment[sl]=Vstavek OpenConnect
-Comment[sv]=Insticksprogram för OpenConnect
-Comment[tr]=OpenConnect Eklentisi
-Comment[ug]=OpenConnect قىستۇرمىسى
-Comment[uk]=Додаток OpenConnect
-Comment[x-test]=xxOpenConnect Pluginxx
-Comment[zh_CN]=OpenConnect 插件
+++ /dev/null
-set(openswan_SRCS
- openswan.cpp
- openswanwidget.cpp
- openswanauth.cpp
- openswan.ui
- openswanauth.ui
-)
-
-kde4_add_plugin(plasmanetworkmanagement_openswanui ${openswan_SRCS})
-
-target_link_libraries(plasmanetworkmanagement_openswanui plasmanetworkmanagement-editor ${NETWORKMANAGERQT_LDFLAGS} ${KDE4_KIO_LIBS})
-
-install(TARGETS plasmanetworkmanagement_openswanui DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install(FILES plasmanetworkmanagement_openswanui.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
-$XGETTEXT `find . -name "*.cpp"` -o $podir/plasmanetworkmanagement_openswanui.pot
-rm -f rc.cpp
+++ /dev/null
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager-openswan -- openswan plugin for Network manager
- *
- * 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.
- *
- * (C) Copyright 2010 Red Hat, Inc.
- */
-
-#ifndef NM_OPENSWAN_SERVICE_H
-#define NM_OPENSWAN_SERVICE_H
-
-#define NM_DBUS_SERVICE_OPENSWAN "org.freedesktop.NetworkManager.openswan"
-#define NM_DBUS_INTERFACE_OPENSWAN "org.freedesktop.NetworkManager.openswan"
-#define NM_DBUS_PATH_OPENSWAN "/org/freedesktop/NetworkManager/openswan"
-
-#define NM_OPENSWAN_RIGHT "right"
-#define NM_OPENSWAN_LEFTID "leftid"
-#define NM_OPENSWAN_PSK_VALUE "pskvalue"
-#define NM_OPENSWAN_PSK_INPUT_MODES "pskinputmodes"
-#define NM_OPENSWAN_LEFTXAUTHUSER "leftxauthusername"
-#define NM_OPENSWAN_XAUTH_PASSWORD "xauthpassword"
-#define NM_OPENSWAN_XAUTH_PASSWORD_INPUT_MODES "xauthpasswordinputmodes"
-#define NM_OPENSWAN_DOMAIN "Domain"
-#define NM_OPENSWAN_DHGROUP "dhgroup"
-#define NM_OPENSWAN_PFSGROUP "pfsgroup"
-#define NM_OPENSWAN_DPDTIMEOUT "dpdtimeout"
-#define NM_OPENSWAN_IKE "ike"
-#define NM_OPENSWAN_ESP "esp"
-
-#define NM_OPENSWAN_PW_TYPE_SAVE "save"
-#define NM_OPENSWAN_PW_TYPE_ASK "ask"
-#define NM_OPENSWAN_PW_TYPE_UNUSED "unused"
-
-#endif /* NM_OPENSWAN_SERVICE_H */
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "openswan.h"
-
-#include <KPluginFactory>
-
-#include "openswanwidget.h"
-#include "openswanauth.h"
-
-
-K_PLUGIN_FACTORY(OpenswanUiPluginFactory, registerPlugin<OpenswanUiPlugin>(); )
-K_EXPORT_PLUGIN(OpenswanUiPluginFactory("plasmanetworkmanagement_openswanui"))
-
-OpenswanUiPlugin::OpenswanUiPlugin(QObject * parent, const QVariantList &):
- VpnUiPlugin(parent)
-{
-}
-
-OpenswanUiPlugin::~OpenswanUiPlugin()
-{
-}
-
-SettingWidget * OpenswanUiPlugin::widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new OpenswanWidget(setting, parent);
-}
-
-SettingWidget * OpenswanUiPlugin::askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new OpenswanAuthDialog(setting, parent);
-}
-
-QString OpenswanUiPlugin::suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const
-{
- Q_UNUSED(connection);
- return QString();
-}
-
-QString OpenswanUiPlugin::supportedFileExtensions() const
-{
- return QString();
-}
-
-NMVariantMapMap OpenswanUiPlugin::importConnectionSettings(const QString &fileName)
-{
- Q_UNUSED(fileName);
-
- // TODO : import the Openconnect connection from file and return settings
- mError = VpnUiPlugin::NotImplemented;
- return NMVariantMapMap();
-}
-
-bool OpenswanUiPlugin::exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName)
-{
- Q_UNUSED(connection);
- Q_UNUSED(fileName);
-
- // TODO : export Openconnect connection to file
- mError = VpnUiPlugin::NotImplemented;
- return false;
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_OPENSWAN_H
-#define PLASMA_NM_OPENSWAN_H
-
-#include "vpnuiplugin.h"
-
-#include <QVariant>
-
-class OpenswanUiPlugin : public VpnUiPlugin
-{
- Q_OBJECT
-public:
- explicit OpenswanUiPlugin(QObject * parent = 0, const QVariantList& = QVariantList());
- virtual ~OpenswanUiPlugin();
- virtual SettingWidget * widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- virtual SettingWidget * askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
-
- QString suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const;
- QString supportedFileExtensions() const;
- NMVariantMapMap importConnectionSettings(const QString &fileName);
- bool exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName);
-};
-
-#endif // PLASMA_NM_OPENSWAN_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OpenswanWidget</class>
- <widget class="QWidget" name="OpenswanWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>446</width>
- <height>300</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Gateway:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="gateway"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Group name:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="groupname"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>User password:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="KLineEdit" name="userPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="cbUsernamePasswordMode">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Group password:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="KLineEdit" name="groupPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="cbGroupPasswordMode">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item row="4" column="1">
- <widget class="QCheckBox" name="ckShowPasswords">
- <property name="text">
- <string>Show passwords</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>28</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>User name:</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="QLineEdit" name="username"/>
- </item>
- <item row="7" column="0">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Phase1 algorithms:</string>
- </property>
- </widget>
- </item>
- <item row="7" column="1">
- <widget class="QLineEdit" name="phase1"/>
- </item>
- <item row="8" column="0">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>Phase2 algorithms:</string>
- </property>
- </widget>
- </item>
- <item row="8" column="1">
- <widget class="QLineEdit" name="phase2"/>
- </item>
- <item row="9" column="0">
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>Domain:</string>
- </property>
- </widget>
- </item>
- <item row="9" column="1">
- <widget class="QLineEdit" name="domain"/>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>gateway</tabstop>
- <tabstop>groupname</tabstop>
- <tabstop>userPassword</tabstop>
- <tabstop>cbUsernamePasswordMode</tabstop>
- <tabstop>groupPassword</tabstop>
- <tabstop>cbGroupPasswordMode</tabstop>
- <tabstop>ckShowPasswords</tabstop>
- <tabstop>username</tabstop>
- <tabstop>phase1</tabstop>
- <tabstop>phase2</tabstop>
- <tabstop>domain</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "openswanauth.h"
-#include "ui_openswanauth.h"
-#include "nm-openswan-service.h"
-
-#include <QString>
-
-class OpenswanAuthDialogPrivate
-{
-public:
- Ui_OpenswanAuth ui;
- NetworkManager::VpnSetting::Ptr setting;
-};
-
-OpenswanAuthDialog::OpenswanAuthDialog(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
- : SettingWidget(setting, parent), d_ptr(new OpenswanAuthDialogPrivate)
-{
- Q_D(OpenswanAuthDialog);
- d->ui.setupUi(this);
- d->setting = setting;
- connect(d->ui.cbShowPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswordsChanged(bool)));
-
- readSecrets();
-
- KAcceleratorManager::manage(this);
-}
-
-OpenswanAuthDialog::~OpenswanAuthDialog()
-{
- delete d_ptr;
-}
-
-void OpenswanAuthDialog::readSecrets()
-{
- Q_D(OpenswanAuthDialog);
- const NMStringMap data = d->setting->data();
- const NMStringMap secrets = d->setting->secrets();
-
- const QString groupName = data.value(NM_OPENSWAN_LEFTID);
- if (!groupName.isEmpty()) {
- d->ui.leGroupName->setText(groupName);
- }
-
- bool haveUserPassword = true;
- if (data.value(NM_OPENSWAN_XAUTH_PASSWORD_INPUT_MODES) != NM_OPENSWAN_PW_TYPE_UNUSED) {
- d->ui.leUserPassword->setText(secrets.value(NM_OPENSWAN_XAUTH_PASSWORD));
- } else {
- d->ui.leUserPassword->setVisible(false);
- d->ui.userPasswordLabel->setVisible(false);
- haveUserPassword = false;
- }
-
- bool haveGroupPassword = true;
- if (data.value(NM_OPENSWAN_PSK_INPUT_MODES) != NM_OPENSWAN_PW_TYPE_UNUSED) {
- d->ui.leGroupPassword->setText(secrets.value(NM_OPENSWAN_PSK_VALUE));
- } else {
- d->ui.leGroupPassword->setVisible(false);
- d->ui.groupPasswordLabel->setVisible(false);
- haveGroupPassword = false;
- }
-
- if (haveUserPassword && d->ui.leUserPassword->text().isEmpty()) {
- d->ui.leUserPassword->setFocus(Qt::OtherFocusReason);
- } else if (haveGroupPassword && d->ui.leGroupPassword->text().isEmpty()) {
- d->ui.leGroupPassword->setFocus(Qt::OtherFocusReason);
- }
-}
-
-QVariantMap OpenswanAuthDialog::setting(bool agentOwned) const
-{
- Q_D(const OpenswanAuthDialog);
- Q_UNUSED(agentOwned)
-
- NMStringMap secrets;
- QVariantMap result;
-
- if (!d->ui.leUserPassword->text().isEmpty()) {
- secrets.insert(NM_OPENSWAN_XAUTH_PASSWORD, d->ui.leUserPassword->text());
- }
-
- if (!d->ui.leGroupPassword->text().isEmpty()) {
- secrets.insert(NM_OPENSWAN_PSK_VALUE, d->ui.leGroupPassword->text());
- }
-
- result.insert("secrets", QVariant::fromValue<NMStringMap>(secrets));
-
- return result;
-}
-
-void OpenswanAuthDialog::showPasswordsChanged(bool show)
-{
- Q_D(OpenswanAuthDialog);
- d->ui.leUserPassword->setPasswordMode(!show);
- d->ui.leGroupPassword->setPasswordMode(!show);
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_OPENSWAN_AUTH_H
-#define PLASMA_NM_OPENSWAN_AUTH_H
-
-#include <NetworkManagerQt/VpnSetting>
-
-#include "settingwidget.h"
-
-class OpenswanAuthDialogPrivate;
-
-class OpenswanAuthDialog : public SettingWidget
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(OpenswanAuthDialog)
-public:
- explicit OpenswanAuthDialog(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~OpenswanAuthDialog();
- virtual void readSecrets();
- virtual QVariantMap setting(bool agentOwned = false) const;
-
-private slots:
- void showPasswordsChanged(bool);
-
-private:
- OpenswanAuthDialogPrivate * d_ptr;
-};
-
-#endif // PLASMA_NM_OPENSWAN_AUTH_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OpenswanAuth</class>
- <widget class="QWidget" name="OpenswanAuth">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>408</width>
- <height>136</height>
- </rect>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="groupNameLabel">
- <property name="text">
- <string>Group name:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>leGroupName</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="leGroupName">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="userPasswordLabel">
- <property name="text">
- <string>User password:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>leUserPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="leUserPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="groupPasswordLabel">
- <property name="text">
- <string>Group password:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>leGroupPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KLineEdit" name="leGroupPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QCheckBox" name="cbShowPasswords">
- <property name="text">
- <string>Show passwords</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "openswanwidget.h"
-#include "ui_openswan.h"
-#include "nm-openswan-service.h"
-
-#include <NetworkManagerQt/Setting>
-
-#include <QDBusMetaType>
-#include <QDebug>
-
-OpenswanWidget::OpenswanWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::OpenswanWidget),
- m_setting(setting)
-{
- qDBusRegisterMetaType<NMStringMap>();
-
- m_ui->setupUi(this);
-
- connect(m_ui->cbUsernamePasswordMode, SIGNAL(currentIndexChanged(int)), SLOT(userPasswordTypeChanged(int)));
- connect(m_ui->cbGroupPasswordMode, SIGNAL(currentIndexChanged(int)), SLOT(groupPasswordTypeChanged(int)));
-
- connect(m_ui->ckShowPasswords, SIGNAL(toggled(bool)), SLOT(showPassword(bool)));
-
- connect(m_ui->gateway, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
- connect(m_ui->groupname, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (m_setting)
- loadConfig(setting);
-}
-
-OpenswanWidget::~OpenswanWidget()
-{
- delete m_ui;
-}
-
-void OpenswanWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- Q_UNUSED(setting);
-
- const NMStringMap data = m_setting->data();
- const NMStringMap secrets = m_setting->secrets();
-
- const QString gateway = data.value(NM_OPENSWAN_RIGHT);
- if (!gateway.isEmpty()) {
- m_ui->gateway->setText(gateway);
- }
-
- const QString groupName = data.value(NM_OPENSWAN_LEFTID);
- if (!groupName.isEmpty()) {
- m_ui->groupname->setText(groupName);
- }
-
- const QString userPassword = secrets.value(NM_OPENSWAN_XAUTH_PASSWORD);
- if (!userPassword.isEmpty()) {
- m_ui->userPassword->setText(userPassword);
- }
-
- const QString groupPassword = secrets.value(NM_OPENSWAN_PSK_VALUE);
- if (!groupPassword.isEmpty()) {
- m_ui->groupPassword->setText(groupPassword);
- }
-
- const QString userPasswordMode = data.value(NM_OPENSWAN_XAUTH_PASSWORD_INPUT_MODES);
- if (userPasswordMode == NM_OPENSWAN_PW_TYPE_SAVE) {
- m_ui->cbUsernamePasswordMode->setCurrentIndex(0);
- } else if (userPasswordMode == NM_OPENSWAN_PW_TYPE_ASK) {
- m_ui->cbUsernamePasswordMode->setCurrentIndex(1);
- } else if (userPasswordMode == NM_OPENSWAN_PW_TYPE_UNUSED) {
- m_ui->cbUsernamePasswordMode->setCurrentIndex(2);
- }
-
- const QString groupPasswordMode = data.value(NM_OPENSWAN_PSK_INPUT_MODES);
- if (groupPasswordMode == NM_OPENSWAN_PW_TYPE_SAVE) {
- m_ui->cbGroupPasswordMode->setCurrentIndex(0);
- } else if (groupPasswordMode == NM_OPENSWAN_PW_TYPE_ASK) {
- m_ui->cbGroupPasswordMode->setCurrentIndex(1);
- } else if (groupPasswordMode == NM_OPENSWAN_PW_TYPE_UNUSED) {
- m_ui->cbGroupPasswordMode->setCurrentIndex(2);
- }
-
- const QString username = data.value(NM_OPENSWAN_LEFTXAUTHUSER);
- if (!username.isEmpty()) {
- m_ui->username->setText(username);
- }
-
- const QString phase1 = data.value(NM_OPENSWAN_IKE);
- if (!phase1.isEmpty()) {
- m_ui->phase1->setText(phase1);
- }
-
- const QString phase2 = data.value(NM_OPENSWAN_ESP);
- if (!phase2.isEmpty()) {
- m_ui->phase2->setText(phase2);
- }
-
- const QString domain = data.value(NM_OPENSWAN_DOMAIN);
- if (!domain.isEmpty()) {
- m_ui->domain->setText(domain);
- }
-}
-
-QVariantMap OpenswanWidget::setting(bool agentOwned) const
-{
- NetworkManager::VpnSetting setting;
- setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_OPENSWAN));
- NMStringMap data;
- NMStringMap secrets;
-
- if (!m_ui->gateway->text().isEmpty()) {
- data.insert(NM_OPENSWAN_RIGHT, m_ui->gateway->text());
- }
-
- if (!m_ui->groupname->text().isEmpty()) {
- data.insert(NM_OPENSWAN_LEFTID, m_ui->groupname->text());
- }
-
- if (!m_ui->userPassword->text().isEmpty()) {
- secrets.insert(NM_OPENSWAN_XAUTH_PASSWORD, m_ui->userPassword->text());
- }
-
- const int usernamePasswordMode = m_ui->cbUsernamePasswordMode->currentIndex();
- if (usernamePasswordMode == 0) {
- data.insert(NM_OPENSWAN_XAUTH_PASSWORD_INPUT_MODES, NM_OPENSWAN_PW_TYPE_SAVE);
- if (agentOwned) {
- data.insert(NM_OPENSWAN_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::AgentOwned));
- } else {
- data.insert(NM_OPENSWAN_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::None));
- }
- } else if (usernamePasswordMode == 1) {
- data.insert(NM_OPENSWAN_XAUTH_PASSWORD_INPUT_MODES, NM_OPENSWAN_PW_TYPE_ASK);
- data.insert(NM_OPENSWAN_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotSaved));
- } else {
- data.insert(NM_OPENSWAN_XAUTH_PASSWORD_INPUT_MODES, NM_OPENSWAN_PW_TYPE_UNUSED);
- data.insert(NM_OPENSWAN_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotRequired));
- }
-
- if (!m_ui->groupPassword->text().isEmpty()) {
- secrets.insert(NM_OPENSWAN_PSK_VALUE, m_ui->groupPassword->text());
- }
-
- const int groupPasswordMode = m_ui->cbGroupPasswordMode->currentIndex();
- if (groupPasswordMode == 0) {
- data.insert(NM_OPENSWAN_PSK_INPUT_MODES, NM_OPENSWAN_PW_TYPE_SAVE);
- if (agentOwned) {
- data.insert(NM_OPENSWAN_PSK_VALUE"-flags", QString::number(NetworkManager::Setting::AgentOwned));
- } else {
- data.insert(NM_OPENSWAN_PSK_VALUE"-flags", QString::number(NetworkManager::Setting::None));
- }
- } else if (groupPasswordMode == 1) {
- data.insert(NM_OPENSWAN_PSK_INPUT_MODES, NM_OPENSWAN_PW_TYPE_ASK);
- data.insert(NM_OPENSWAN_PSK_VALUE"-flags", QString::number(NetworkManager::Setting::NotSaved));
- } else {
- data.insert(NM_OPENSWAN_PSK_INPUT_MODES, NM_OPENSWAN_PW_TYPE_UNUSED);
- data.insert(NM_OPENSWAN_PSK_VALUE"-flags", QString::number(NetworkManager::Setting::NotRequired));
- }
-
- if (!m_ui->username->text().isEmpty()) {
- data.insert(NM_OPENSWAN_LEFTXAUTHUSER, m_ui->username->text());
- }
-
- if (!m_ui->phase1->text().isEmpty()) {
- data.insert(NM_OPENSWAN_IKE, m_ui->phase1->text());
- }
-
- if (!m_ui->phase2->text().isEmpty()) {
- data.insert(NM_OPENSWAN_ESP, m_ui->phase2->text());
- }
-
- if (!m_ui->domain->text().isEmpty()) {
- data.insert(NM_OPENSWAN_DOMAIN, m_ui->domain->text());
- }
-
- setting.setData(data);
- setting.setSecrets(secrets);
- return setting.toMap();
-}
-
-void OpenswanWidget::userPasswordTypeChanged(int index)
-{
- if (index == 1 || index == 2) {
- m_ui->userPassword->setEnabled(false);
- } else {
- m_ui->userPassword->setEnabled(true);
- }
-}
-
-void OpenswanWidget::groupPasswordTypeChanged(int index)
-{
- if (index == 1 || index == 2) {
- m_ui->groupPassword->setEnabled(false);
- } else {
- m_ui->groupPassword->setEnabled(true);
- }
-}
-
-void OpenswanWidget::showPassword(bool show)
-{
- m_ui->userPassword->setPasswordMode(!show);
- m_ui->groupPassword->setPasswordMode(!show);
-}
-
-bool OpenswanWidget::isValid() const
-{
- return !m_ui->gateway->text().isEmpty() && !m_ui->groupname->text().isEmpty();
-}
+++ /dev/null
-/*
- Copyright 2013 Jan Grulich <jgrulich@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_OPENSWAN_WIDGET_H
-#define PLASMA_NM_OPENSWAN_WIDGET_H
-
-#include <NetworkManagerQt/VpnSetting>
-
-#include "settingwidget.h"
-
-namespace Ui
-{
-class OpenswanWidget;
-}
-
-class OpenswanWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit OpenswanWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~OpenswanWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void userPasswordTypeChanged(int index);
- void groupPasswordTypeChanged(int index);
- void showPassword(bool show);
-
-private:
- Ui::OpenswanWidget * m_ui;
- NetworkManager::VpnSetting::Ptr m_setting;
-};
-
-#endif // PLASMA_NM_OPENSWAN_WIDGET_H
+++ /dev/null
-[Desktop Entry]
-Type=Service
-Icon=
-ServiceTypes=PlasmaNetworkManagement/VpnUiPlugin
-X-KDE-Library=plasmanetworkmanagement_openswanui
-X-NetworkManager-Services=org.freedesktop.NetworkManager.openswan
-X-KDE-PluginInfo-Author=Jan Grulich
-X-KDE-PluginInfo-Email=jgrulich@redhat.com
-X-KDE-PluginInfo-Name=plasmanetworkmanagement_openswanui
-X-KDE-PluginInfo-Version=0.1
-X-KDE-PluginInfo-Website=
-X-KDE-PluginInfo-Category=VPNService
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=false
-Name=OpenSwan
-Name[bg]=OpenSwan
-Name[bs]=OpenSwan
-Name[ca]=OpenSwan
-Name[ca@valencia]=OpenSwan
-Name[cs]=OpenSwan
-Name[da]=OpenSwan
-Name[de]=OpenSwan
-Name[el]=OpenSwan
-Name[en_GB]=OpenSwan
-Name[es]=OpenSwan
-Name[et]=OpenSwan
-Name[fi]=OpenSwan
-Name[fr]=OpenSwan
-Name[hu]=OpenSwan
-Name[it]=OpenSwan
-Name[ko]=OpenSwan
-Name[lt]=OpenSwan
-Name[nb]=OpenSwan
-Name[nds]=OpenSwan
-Name[nl]=OpenSwan
-Name[pl]=OpenSwan
-Name[pt]=OpenSwan
-Name[pt_BR]=OpenSwan
-Name[ro]=OpenSwan
-Name[ru]=OpenSwan
-Name[sk]=OpenSwan
-Name[sl]=OpenSwan
-Name[sv]=OpenSwan
-Name[tr]=OpenSwan
-Name[uk]=OpenSwan
-Name[x-test]=xxOpenSwanxx
-Name[zh_CN]=OpenSwan
-Comment=OpenSwan Plugin
-Comment[bg]=Приставка за OpenSwan
-Comment[bs]=OpenSwan dodatak
-Comment[ca]=Connector d'OpenSwan
-Comment[ca@valencia]=Connector d'OpenSwan
-Comment[cs]=Modul OpenSwan
-Comment[da]=OpenSwan-plugin
-Comment[de]=OpenSwan-Modul
-Comment[el]=Πρόσθετο OpenSwan
-Comment[en_GB]=OpenSwan Plugin
-Comment[es]=Complemento OpenSwan
-Comment[et]=OpenSwani plugin
-Comment[fi]=OpenSwan-liitännäinen
-Comment[fr]=Module externe OpenSwan
-Comment[hu]=OpenSwan bővítmény
-Comment[it]=Estensione OpenSwan
-Comment[ko]=OpenSwan 플러그인
-Comment[lt]=OpenSwan įskiepis
-Comment[nb]=OpenSwan programtillegg
-Comment[nds]=OpenSwan-Moduul
-Comment[nl]=Plug-in voor OpenSwan
-Comment[pl]=Wtyczka OpenSwan
-Comment[pt]='Plugin' do OpenSwan
-Comment[pt_BR]=Plugin do OpenSwan
-Comment[ro]=Extensie OpenSwan
-Comment[ru]=Модуль OpenSwan
-Comment[sk]=Plugin OpenSwan
-Comment[sl]=Vstavek OpenSwan
-Comment[sv]=Insticksprogram för OpenSwan
-Comment[tr]=OpenSwan Eklentisi
-Comment[uk]=Додаток OpenSwan
-Comment[x-test]=xxOpenSwan Pluginxx
-Comment[zh_CN]=OpenSwan 插件
+++ /dev/null
-set(openvpn_SRCS
- openvpn.cpp
- openvpnwidget.cpp
- openvpnauth.cpp
- openvpnadvancedwidget.cpp
- openvpn.ui
- openvpnauth.ui
- openvpnadvanced.ui
-)
-
-kde4_add_plugin(plasmanetworkmanagement_openvpnui ${openvpn_SRCS})
-
-target_link_libraries(plasmanetworkmanagement_openvpnui plasmanetworkmanagement-editor ${NETWORKMANAGERQT_LDFLAGS} ${KDE4_KIO_LIBS})
-
-install(TARGETS plasmanetworkmanagement_openvpnui DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install(FILES plasmanetworkmanagement_openvpnui.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
-$XGETTEXT `find . -name "*.cpp"` -o $podir/plasmanetworkmanagement_openvpnui.pot
-rm -f rc.cpp
+++ /dev/null
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* nm-openvpn-service - openvpn integration with NetworkManager
- *
- * Copyright (C) 2005 - 2008 Tim Niemueller <tim@niemueller.de>
- * Copyright (C) 2005 - 2008 Dan Williams <dcbw@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This 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.
- *
- */
-
-#ifndef NM_OPENVPN_SERVICE_H
-#define NM_OPENVPN_SERVICE_H
-
-#define NM_DBUS_SERVICE_OPENVPN "org.freedesktop.NetworkManager.openvpn"
-#define NM_DBUS_INTERFACE_OPENVPN "org.freedesktop.NetworkManager.openvpn"
-#define NM_DBUS_PATH_OPENVPN "/org/freedesktop/NetworkManager/openvpn"
-
-#define NM_OPENVPN_KEY_AUTH "auth"
-#define NM_OPENVPN_KEY_CA "ca"
-#define NM_OPENVPN_KEY_CERT "cert"
-#define NM_OPENVPN_KEY_CIPHER "cipher"
-#define NM_OPENVPN_KEY_COMP_LZO "comp-lzo"
-#define NM_OPENVPN_KEY_CONNECTION_TYPE "connection-type"
-#define NM_OPENVPN_KEY_FRAGMENT_SIZE "fragment-size"
-#define NM_OPENVPN_KEY_KEY "key"
-#define NM_OPENVPN_KEY_LOCAL_IP "local-ip" /* ??? */
-#define NM_OPENVPN_KEY_MSSFIX "mssfix"
-#define NM_OPENVPN_KEY_PORT "port"
-#define NM_OPENVPN_KEY_PROTO_TCP "proto-tcp"
-#define NM_OPENVPN_KEY_PROXY_TYPE "proxy-type"
-#define NM_OPENVPN_KEY_PROXY_SERVER "proxy-server"
-#define NM_OPENVPN_KEY_PROXY_PORT "proxy-port"
-#define NM_OPENVPN_KEY_PROXY_RETRY "proxy-retry"
-#define NM_OPENVPN_KEY_HTTP_PROXY_USERNAME "http-proxy-username"
-#define NM_OPENVPN_KEY_REMOTE "remote"
-#define NM_OPENVPN_KEY_REMOTE_IP "remote-ip"
-#define NM_OPENVPN_KEY_STATIC_KEY "static-key"
-#define NM_OPENVPN_KEY_STATIC_KEY_DIRECTION "static-key-direction"
-#define NM_OPENVPN_KEY_TA "ta"
-#define NM_OPENVPN_KEY_TA_DIR "ta-dir"
-#define NM_OPENVPN_KEY_TUNNEL_MTU "tunnel-mtu"
-#define NM_OPENVPN_KEY_USERNAME "username"
-#define NM_OPENVPN_KEY_TAP_DEV "tap-dev"
-#define NM_OPENVPN_KEY_TLS_REMOTE "tls-remote"
-#define NM_OPENVPN_KEY_REMOTE_CERT_TLS "remote-cert-tls"
-
-#define NM_OPENVPN_KEY_PASSWORD "password"
-#define NM_OPENVPN_KEY_CERTPASS "cert-pass"
-#define NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD "http-proxy-password"
-/* Internal auth-dialog -> service token indicating that no secrets are
- * required for the connection.
- */
-#define NM_OPENVPN_KEY_NOSECRET "no-secret"
-
-#define NM_OPENVPN_KEY_RENEG_SECONDS "reneg-seconds"
-
-#define NM_OPENVPN_AUTH_NONE "none"
-#define NM_OPENVPN_AUTH_RSA_MD4 "RSA-MD4"
-#define NM_OPENVPN_AUTH_MD5 "MD5"
-#define NM_OPENVPN_AUTH_SHA1 "SHA1"
-#define NM_OPENVPN_AUTH_SHA224 "SHA224"
-#define NM_OPENVPN_AUTH_SHA256 "SHA256"
-#define NM_OPENVPN_AUTH_SHA384 "SHA384"
-#define NM_OPENVPN_AUTH_SHA512 "SHA512"
-#define NM_OPENVPN_AUTH_RIPEMD160 "RIPEMD160"
-
-#define NM_OPENVPN_CONTYPE_TLS "tls"
-#define NM_OPENVPN_CONTYPE_STATIC_KEY "static-key"
-#define NM_OPENVPN_CONTYPE_PASSWORD "password"
-#define NM_OPENVPN_CONTYPE_PASSWORD_TLS "password-tls"
-
-#endif /* NM_OPENVPN_SERVICE_H */
+++ /dev/null
-/*
- Copyright 2008 Will Stephenson <wstephenson@kde.org>
- Copyright 2011-2012 Rajeesh K Nambiar <rajeeshknambiar@gmail.com>
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2012-2014 Lamarque V. Souza <lamarque@kde.org>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "openvpn.h"
-
-#include <QStringBuilder>
-#include <KPluginFactory>
-#include <KMessageBox>
-#include <KStandardDirs>
-#include <KLocale>
-
-#include <NetworkManagerQt/Connection>
-#include <NetworkManagerQt/VpnSetting>
-#include <NetworkManagerQt/Ipv4Setting>
-
-#include "openvpnwidget.h"
-#include "openvpnauth.h"
-
-#include "nm-openvpn-service.h"
-
-//#include <nm-setting-ip4-config.h>
-#define NM_SETTING_IP4_CONFIG_NEVER_DEFAULT "never-default"
-
-K_PLUGIN_FACTORY(OpenVpnUiPluginFactory, registerPlugin<OpenVpnUiPlugin>();)
-K_EXPORT_PLUGIN(OpenVpnUiPluginFactory("plasmanetworkmanagement_openvpnui"))
-
-#define AUTH_TAG "auth"
-#define AUTH_USER_PASS_TAG "auth-user-pass"
-#define CA_TAG "ca"
-#define CERT_TAG "cert"
-#define CIPHER_TAG "cipher"
-#define CLIENT_TAG "client"
-#define COMP_TAG "comp-lzo"
-#define DEV_TAG "dev"
-#define FRAGMENT_TAG "fragment"
-#define IFCONFIG_TAG "ifconfig"
-#define KEY_TAG "key"
-#define MSSFIX_TAG "mssfix"
-#define PKCS12_TAG "pkcs12"
-#define PORT_TAG "port"
-#define PROTO_TAG "proto"
-#define HTTP_PROXY_TAG "http-proxy"
-#define HTTP_PROXY_RETRY_TAG "http-proxy-retry"
-#define SOCKS_PROXY_TAG "socks-proxy"
-#define SOCKS_PROXY_RETRY_TAG "socks-proxy-retry"
-#define REMOTE_TAG "remote"
-#define RENEG_SEC_TAG "reneg-sec"
-#define RPORT_TAG "rport"
-#define SECRET_TAG "secret"
-#define TLS_AUTH_TAG "tls-auth"
-#define TLS_CLIENT_TAG "tls-client"
-#define TLS_REMOTE_TAG "tls-remote"
-#define TUNMTU_TAG "tun-mtu"
-#define KEY_DIRECTION_TAG "key-direction"
-
-#define BEGIN_KEY_CA_TAG "<ca>"
-#define END_KEY_CA_TAG "</ca>"
-#define BEGIN_KEY_CERT_TAG "<cert>"
-#define END_KEY_CERT_TAG "</cert>"
-#define BEGIN_KEY_KEY_TAG "<key>"
-#define END_KEY_KEY_TAG "</key>"
-#define BEGIN_KEY_SECRET_TAG "<secret>"
-#define END_KEY_SECRET_TAG "</secret>"
-#define BEGIN_TLS_AUTH_TAG "<tls-auth>"
-#define END_TLS_AUTH_TAG "</tls_auth>"
-
-#define PROC_TYPE_TAG "Proc-Type: 4,ENCRYPTED"
-#define PKCS8_TAG "-----BEGIN ENCRYPTED PRIVATE KEY-----"
-
-QString unQuote(QString &certVal, const QString &fileName)
-{
- /* Unquote according to openvpn rules
- * Unquoted filename is returned, and @certVal is modified
- * to the leftover string
- */
- int nextSep;
- QString certFile = certVal.trimmed();
- if (certFile.startsWith('"') || certFile.startsWith('\'')) { // Quoted
- certFile.remove(0,1); // Remove the starting quote
- nextSep = 0;
- while ((nextSep = certFile.indexOf(QRegExp("\"|'"), nextSep)) != -1) {
- if (nextSep > 0 && certFile.at(nextSep - 1) != '\\') { // Quote not escaped
- certVal = certFile.right(certFile.length() - nextSep - 1); // Leftover string
- certFile.truncate(nextSep); // Quoted string
- break;
- }
- }
- }
- else {
- nextSep = certFile.indexOf(QRegExp("\\s")); // First whitespace
- if (nextSep != -1) {
- certVal = certFile.right(certFile.length() - nextSep - 1); // Leftover
- certFile = certFile.left(nextSep); // value
- }
- else {
- certVal.clear();
- }
- }
- certFile.replace("\\\\", "\\"); // Replace '\\' with '\'
- certFile.replace("\\ ", " "); // Replace escaped space with space
- if (QFileInfo(certFile).isRelative())
- certFile = QFileInfo(fileName).dir().absolutePath() + '/' + certFile;
- return certFile;
-}
-
-bool isEncrypted(const QString &fileName)
-{
- bool encrypted = false;
- // TODO: if is_pkcs12(fileName) return true;
- // NOTE: will have to use SEC_PKCS12DecoderStart and friends from <p12.h>, which will
- // build a new dependency on nss-devel. See NetworkManager/libnm-util/crypto_nss.c+453
-
- QFile inFile(fileName);
- if (!inFile.open(QFile::ReadOnly))
- return false;
- QTextStream in(&inFile);
- while (!in.atEnd()) {
- QString line = in.readLine();
- if (!line.isEmpty() && (line.startsWith(PROC_TYPE_TAG) || line.startsWith(PKCS8_TAG))) {
- encrypted = true;
- break;
- }
- }
- inFile.close();
- return encrypted;
-}
-
-OpenVpnUiPlugin::OpenVpnUiPlugin(QObject * parent, const QVariantList &) : VpnUiPlugin(parent)
-{
-}
-
-OpenVpnUiPlugin::~OpenVpnUiPlugin()
-{
-}
-
-SettingWidget * OpenVpnUiPlugin::widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- OpenVpnSettingWidget * wid = new OpenVpnSettingWidget(setting, parent);
- return wid;
-}
-
-SettingWidget * OpenVpnUiPlugin::askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new OpenVpnAuthWidget(setting, parent);
-}
-
-QString OpenVpnUiPlugin::suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const
-{
- return connection->id() + "_openvpn.conf";
-}
-
-QString OpenVpnUiPlugin::supportedFileExtensions() const
-{
- return "*.ovpn *.conf";
-}
-
-NMVariantMapMap OpenVpnUiPlugin::importConnectionSettings(const QString &fileName)
-{
- NMVariantMapMap result;
-
- QFile impFile(fileName);
- if (!impFile.open(QFile::ReadOnly|QFile::Text)) {
- mError = VpnUiPlugin::Error;
- mErrorMessage = i18n("Could not open file");
- return result;
- }
-
- bool copyCertificates;
- KMessageBox::ButtonCode buttonCode;
- if (KMessageBox::shouldBeShownYesNo(QLatin1String("copyCertificatesDialog"), buttonCode)) {
- copyCertificates = KMessageBox::questionYesNo(0, i18n("Do you want to copy your certificates to %1?", KStandardDirs::locateLocal("data", "networkmanagement/certificates/")),
- i18n("Copy certificates"), KStandardGuiItem::yes(), KStandardGuiItem::no(), QLatin1String("copyCertificatesDialog")) == KMessageBox::Yes;
- } else {
- copyCertificates = buttonCode == KMessageBox::Yes;
- }
-
- const QString connectionName = QFileInfo(fileName).completeBaseName();
- NMStringMap dataMap;
- NMStringMap secretData;
- QVariantMap ipv4Data;
-
- QString proxy_type;
- QString proxy_user;
- QString proxy_passwd;
- bool have_client = false;
- bool have_remote = false;
- bool proxy_set = false;
- bool have_pass = false;
- bool have_sk = false;
- int key_direction = -1;
-
- QTextStream in(&impFile);
- while (!in.atEnd()) {
- QStringList key_value;
- QString line = in.readLine();
- // Skip comments
- if (line.indexOf('#') >= 0)
- line.truncate(line.indexOf('#'));
- if (line.indexOf(';') >= 0)
- line.truncate(line.indexOf(';'));
- if (line.isEmpty())
- continue;
- key_value.clear();
- key_value << line.split(QRegExp("\\s+")); // Split at one or more whitespaces
-
- if (key_value[0] == CLIENT_TAG || key_value[0] == TLS_CLIENT_TAG) {
- have_client = true;
- continue;
- }
- if (key_value[0] == DEV_TAG) {
- if (key_value.count() == 2) {
- if (key_value[1].startsWith(QLatin1String("tun"))) {
- // ignore; default is tun
- }
- else if (key_value[1].startsWith(QLatin1String("tap"))) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TAP_DEV), "yes");
- }
- else {
- KMessageBox::information(0, i18n("Unknown option: %1", line));
- }
- }
- else {
- KMessageBox::information(0, i18n("Invalid number of arguments (expected 1) in option: %1", line));
- }
- continue;
- }
- if (key_value[0] == PROTO_TAG) {
- if (key_value.count() == 2) {
- /* Valid parameters are "udp", "tcp-client" and "tcp-server".
- * 'tcp' isn't technically valid, but it used to be accepted so
- * we'll handle it here anyway.
- */
- if (key_value[1] == "udp") {
- // ignore; default is udp
- }
- else if (key_value[1] == "tcp-client" || key_value[1] == "tcp-server" || key_value[1] == "tcp") {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_PROTO_TCP), "yes");
- }
- else {
- KMessageBox::information(0, i18n("Unknown option: %1", line));
- }
- }
- else {
- KMessageBox::information(0, i18n("Invalid number of arguments (expected 1) in option: %1", line));
- }
- continue;
- }
- if (key_value[0] == MSSFIX_TAG) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_MSSFIX), "yes");
- continue;
- }
- if (key_value[0] == TUNMTU_TAG) {
- if (key_value.count() == 2) {
- if (key_value[1].toLong() >= 0 && key_value[1].toLong() < 0xFFFF ) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TUNNEL_MTU), key_value[1]);
- }
- else {
- KMessageBox::information(0, i18n("Invalid size (should be between 0 and 0xFFFF) in option: %1", line));
- }
- }
- else {
- KMessageBox::information(0, i18n("Invalid number of arguments (expected 1) in option: %1", line));
- }
- continue;
- }
- if (key_value[0] == FRAGMENT_TAG) {
- if (key_value.count() == 2) {
- if (key_value[1].toLong() >= 0 && key_value[1].toLong() < 0xFFFF ) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_FRAGMENT_SIZE), key_value[1]);
- }
- else {
- KMessageBox::information(0, i18n("Invalid size (should be between 0 and 0xFFFF) in option: %1", line));
- }
- }
- else {
- KMessageBox::information(0, i18n("Invalid number of arguments (expected 1) in option: %1", line));
- }
- continue;
- }
- if (key_value[0] == COMP_TAG) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_COMP_LZO), "yes");
- continue;
- }
- if (key_value[0] == RENEG_SEC_TAG) {
- if (key_value.count() == 2) {
- if (key_value[1].toLong() >= 0 && key_value[1].toLong() <= 604800 ) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_RENEG_SECONDS), key_value[1]);
- }
- else {
- KMessageBox::information(0, i18n("Invalid size (should be between 0 and 604800) in option: %1", line));
- }
- }
- else {
- KMessageBox::information(0, i18n("Invalid number of arguments (expected 1) in option: %1", line));
- }
- continue;
- }
- if (key_value[0] == HTTP_PROXY_RETRY_TAG || key_value[0] == SOCKS_PROXY_RETRY_TAG) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_RETRY), "yes");
- continue;
- }
- if (key_value[0] == HTTP_PROXY_TAG)
- proxy_type = "http";
- if (key_value[0] == SOCKS_PROXY_TAG)
- proxy_type = "socks";
- if (!proxy_type.isEmpty() && !proxy_set && key_value.count() >= 3) {
- bool success = true;
- if (proxy_type == "http" && key_value.count() >= 4) {
- // Parse the HTTP proxy file
- QFile httpProxyFile(QFileInfo(fileName).dir().absolutePath() + '/' + key_value[3]);
- if (httpProxyFile.open(QFile::ReadOnly|QFile::Text)) {
- QTextStream httpProxyIn(&httpProxyFile);
- while (!httpProxyIn.atEnd()) {
- QString httpProxyLine = httpProxyIn.readLine();
- if (httpProxyLine.isEmpty())
- continue;
- if (proxy_user.isEmpty())
- proxy_user = httpProxyLine;
- if (proxy_passwd.isEmpty()) {
- proxy_passwd = httpProxyLine;
- break;
- }
- }
- if (proxy_user.isEmpty()||proxy_passwd.isEmpty())
- success = false;
- }
- }
- if (success && !proxy_type.isEmpty() && key_value[2].toLong() > 0 // Port
- && key_value[2].toLong() < 65536) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_TYPE), proxy_type);
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_SERVER), key_value[1]); // Proxy server
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_PORT), key_value[2]); // Port
- if (!proxy_user.isEmpty())
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_HTTP_PROXY_USERNAME), proxy_user);
- if (!proxy_passwd.isEmpty()) {
- secretData.insert(QLatin1String(NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD), proxy_passwd);
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD"-flags"), QString::number(NetworkManager::Setting::NotSaved));
- }
- proxy_set = true;
- }
- if (!success)
- KMessageBox::information(0, i18n("Invalid proxy option: %1", line));
- continue;
- }
- if (key_value[0] == REMOTE_TAG) {
- if (key_value.count() >= 2 && key_value.count() <= 4) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_REMOTE), key_value[1]);
- have_remote = true;
- if (key_value.count() >= 3 && key_value[2].toLong() > 0
- && key_value[2].toLong() < 65536) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_PORT), key_value[2]);
- if (key_value.count() == 4) {
- // TODO
- }
- }
- }
- }
- if (key_value[0] == PORT_TAG || key_value[0] == RPORT_TAG) {
- // Port specified in 'remote' always takes precedence
- if (!dataMap.contains(NM_OPENVPN_KEY_PORT)) {
- if (key_value.count() == 2 ) {
- if (key_value[1].toLong() > 0 && key_value[1].toLong() < 65536)
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_PORT), key_value[1]);
- else
- KMessageBox::information(0, i18n("Invalid port (should be between 1 and 65535) in option: %1", line));
- }
- else
- KMessageBox::information(0, i18n("Invalid number of arguments (expected 1) in option: %1", line));
- }
- continue;
- }
- if (key_value[0] == PKCS12_TAG && key_value.count() > 1) {
- key_value[1] = line.right(line.length() - line.indexOf(QRegExp("\\s"))); // Get whole string after key
- QString certFile = unQuote(key_value[1], fileName);
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CA), certFile);
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CERT), certFile);
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_KEY), certFile);
- continue;
- }
- if (key_value[0] == CA_TAG && key_value.count() > 1) {
- key_value[1] = line.right(line.length() - line.indexOf(QRegExp("\\s"))); // Get whole string after key
- if (copyCertificates) {
- const QString absoluteFilePath = tryToCopyToCertificatesDirectory(connectionName, unQuote(key_value[1], fileName));
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CA), absoluteFilePath);
- } else {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CA), unQuote(key_value[1], fileName));
- }
- continue;
- }
- if (key_value[0] == CERT_TAG && key_value.count() > 1) {
- key_value[1] = line.right(line.length() - line.indexOf(QRegExp("\\s"))); // Get whole string after key
- if (copyCertificates) {
- const QString absoluteFilePath = tryToCopyToCertificatesDirectory(connectionName, unQuote(key_value[1], fileName));
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CERT), absoluteFilePath);
- } else {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CERT), unQuote(key_value[1], fileName));
- }
- continue;
- }
- if (key_value[0] == KEY_TAG && key_value.count() > 1) {
- key_value[1] = line.right(line.length() - line.indexOf(QRegExp("\\s"))); // Get whole string after key
- if (copyCertificates) {
- const QString absoluteFilePath = tryToCopyToCertificatesDirectory(connectionName, unQuote(key_value[1], fileName));
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_KEY), absoluteFilePath);
- } else {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_KEY), unQuote(key_value[1], fileName));
- }
- continue;
- }
- if (key_value[0] == SECRET_TAG && key_value.count() > 1) {
- key_value[1] = line.right(line.length() - line.indexOf(QRegExp("\\s"))); // Get whole string after key
- if (copyCertificates) {
- const QString absoluteFilePath = tryToCopyToCertificatesDirectory(connectionName, unQuote(key_value[1], fileName));
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_STATIC_KEY), absoluteFilePath);
- } else {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_STATIC_KEY), unQuote(key_value[1], fileName));
- }
- if (key_value.count() > 2) {
- key_value[2] = key_value[1];
- if (!key_value[2].isEmpty() && (key_value[2].toLong() == 0 ||key_value[2].toLong() == 1))
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_STATIC_KEY_DIRECTION), key_value[2]);
- }
- have_sk = true;
- continue;
- }
- if (key_value[0] == TLS_AUTH_TAG && key_value.count() >1) {
- key_value[1] = line.right(line.length() - line.indexOf(QRegExp("\\s"))); // Get whole string after key
- if (copyCertificates) {
- const QString absoluteFilePath = tryToCopyToCertificatesDirectory(connectionName, unQuote(key_value[1], fileName));
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TA), absoluteFilePath);
- } else {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TA), unQuote(key_value[1], fileName));
- }
- if (key_value.count() > 2) {
- key_value[2] = key_value[1];
- if (!key_value[2].isEmpty() && (key_value[2].toLong() == 0 ||key_value[2].toLong() == 1))
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TA_DIR), key_value[2]);
- }
- continue;
- }
- if (key_value[0] == CIPHER_TAG) {
- if (key_value.count() == 2) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CIPHER), key_value[1]);
- }
- else {
- KMessageBox::information(0, i18n("Invalid number of arguments (expected 1) in option: %1", line));
- }
- continue;
- }
- if (key_value[0] == TLS_REMOTE_TAG) {
- if (!unQuote(key_value[1], fileName).isEmpty()) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TLS_REMOTE), key_value[1]);
- }
- else {
- KMessageBox::information(0, i18n("Unknown option: %1", line));
- }
- continue;
- }
- if (key_value[0] == IFCONFIG_TAG) {
- if (key_value.count() == 3) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_LOCAL_IP), key_value[1]);
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_REMOTE_IP), key_value[2]);
- }
- else {
- KMessageBox::information(0, i18n("Invalid number of arguments (expected 2) in option: %1", line));
- }
- continue;
- }
- if (key_value[0] == AUTH_USER_PASS_TAG) {
- have_pass = true;
- }
- if (key_value[0] == AUTH_TAG) {
- if (key_value.count() == 2) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_AUTH), key_value[1]);
- }
- else {
- KMessageBox::information(0, i18n("Invalid number of arguments (expected 1) in option: %1", line));
- }
- continue;
- }
- if (key_value[0] == KEY_DIRECTION_TAG) {
- if (key_value.count() == 2) {
- key_direction = key_value[1].toInt();
- }
-
- if (key_direction != 0 && key_direction != 1) {
- KMessageBox::information(0, i18n("Invalid argument in option: %1", line));
- key_direction = -1;
- }
- continue;
- }
-
- if (key_value[0] == BEGIN_KEY_CA_TAG) {
- const QString caAbsolutePath = saveFile(in, QLatin1String(END_KEY_CA_TAG), connectionName, "ca.crt");
- if (!caAbsolutePath.isEmpty()) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CA), caAbsolutePath);
- }
- continue;
- } else if (key_value[0] == BEGIN_KEY_CERT_TAG) {
- const QString certAbsolutePath = saveFile(in, QLatin1String(END_KEY_CERT_TAG), connectionName, "cert.crt");
- if (!certAbsolutePath.isEmpty()) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CERT), certAbsolutePath);
- }
- continue;
- } else if (key_value[0] == BEGIN_KEY_KEY_TAG) {
- const QString keyAbsolutePath = saveFile(in, QLatin1String(END_KEY_KEY_TAG), connectionName, "private.key");
- if (!keyAbsolutePath.isEmpty()) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_KEY), keyAbsolutePath);
- }
- continue;
- } else if (key_value[0] == BEGIN_KEY_SECRET_TAG) {
- const QString secretAbsolutePath = saveFile(in, QLatin1String(END_KEY_SECRET_TAG), connectionName, "secret.key");
- if (!secretAbsolutePath.isEmpty()) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_KEY), secretAbsolutePath);
- have_sk = true;
-
- if (key_direction > -1) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_STATIC_KEY_DIRECTION), QString().setNum(key_direction));
- }
- }
- continue;
- } else if (key_value[0] == BEGIN_TLS_AUTH_TAG) {
- const QString tlsAuthAbsolutePath = saveFile(in, QLatin1String(END_TLS_AUTH_TAG), connectionName, "tls_auth.key");
- if (!tlsAuthAbsolutePath.isEmpty()) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TA), tlsAuthAbsolutePath);
-
- if (key_direction > -1) {
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_TA_DIR), QString().setNum(key_direction));
- }
- }
- continue;
- }
-
- // Import X-NM-Routes if present
- if (key_value[0] == "X-NM-Routes") {
- ipv4Data.insert("X-NM-Routes", key_value[1]);
- continue;
- }
- }
- if (!have_client && !have_sk) {
- mError = VpnUiPlugin::Error;
- mErrorMessage = i18n("File %1 is not a valid OpenVPN's client configuration file", fileName);
- return result;
- }
- else if (!have_remote) {
- mError = VpnUiPlugin::Error;
- mErrorMessage = i18n("File %1 is not a valid OpenVPN configuration (no remote).", fileName);
- return result;
- }
- else {
- QString conType;
- bool have_certs = false;
- bool have_ca = false;
-
- if (dataMap.contains(NM_OPENVPN_KEY_CA))
- have_ca = true;
- if (have_ca && dataMap.contains(NM_OPENVPN_KEY_CERT) && dataMap.contains(NM_OPENVPN_KEY_KEY))
- have_certs = true;
- // Determine connection type
- if (have_pass) {
- if (have_certs)
- conType = NM_OPENVPN_CONTYPE_PASSWORD_TLS;
- else if (have_ca)
- conType = NM_OPENVPN_CONTYPE_PASSWORD;
- }
- else if (have_certs) {
- conType = NM_OPENVPN_CONTYPE_TLS;
- }
- else if (have_sk) {
- conType = NM_OPENVPN_CONTYPE_STATIC_KEY;
- }
- if (conType.isEmpty())
- conType = NM_OPENVPN_CONTYPE_TLS;
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CONNECTION_TYPE), conType);
- // Default secret flags to be agent-owned
- if (have_pass)
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_PASSWORD"-flags"), QString::number(NetworkManager::Setting::NotSaved));
- if (have_certs) {
- if (dataMap.contains(NM_OPENVPN_KEY_KEY) && isEncrypted(dataMap[NM_OPENVPN_KEY_KEY]))
- dataMap.insert(QLatin1String(NM_OPENVPN_KEY_CERTPASS"-flags"), QString::number(NetworkManager::Setting::NotSaved));
- }
- }
-
- // Set the '...-type' and '...-flags' value also
- NetworkManager::VpnSetting setting;
- setting.setServiceType("org.freedesktop.NetworkManager.openvpn");
- setting.setData(dataMap);
- setting.setSecrets(secretData);
-
- QVariantMap conn;
- conn.insert("id", connectionName);
- conn.insert("type", "vpn");
- result.insert("connection", conn);
-
- result.insert("vpn", setting.toMap());
-
- if (!ipv4Data.isEmpty()) {
- result.insert("ipv4", ipv4Data);
- }
-
- impFile.close();
- return result;
-}
-
-QString OpenVpnUiPlugin::saveFile(QTextStream &in, const QString &endTag, const QString &connectionName, const QString &fileName)
-{
- const QString certificatesDirectory = KStandardDirs::locateLocal("data", "networkmanagement/certificates/" + connectionName);
- const QString absoluteFilePath = certificatesDirectory + '/' + fileName;
- QFile outFile(absoluteFilePath);
-
- QDir().mkpath(certificatesDirectory);
- if (!outFile.open(QFile::WriteOnly | QFile::Text)) {
- KMessageBox::information(0, i18n("Error saving file %1: %2", absoluteFilePath, outFile.errorString()));
- return QString();
- }
-
- QTextStream out(&outFile);
- while (!in.atEnd()) {
- const QString line = in.readLine();
-
- if (line.indexOf(endTag) >= 0) {
- break;
- }
-
- out << line << "\n";
- }
-
- outFile.close();
- return absoluteFilePath;
-}
-
-QString OpenVpnUiPlugin::tryToCopyToCertificatesDirectory(const QString &connectionName, const QString &sourceFilePath)
-{
- const QString certificatesDirectory = KStandardDirs::locateLocal("data", "networkmanagement/certificates/");
- const QString absoluteFilePath = certificatesDirectory + connectionName + '_' + QFileInfo(sourceFilePath).fileName();
-
- QFile sourceFile(sourceFilePath);
-
- QDir().mkpath(certificatesDirectory);
- if (!sourceFile.copy(absoluteFilePath)) {
- KMessageBox::information(0, i18n("Error copying certificate to %1: %2", absoluteFilePath, sourceFile.errorString()));
- return sourceFilePath;
- }
-
- return absoluteFilePath;
-}
-
-bool OpenVpnUiPlugin::exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName)
-{
- QFile expFile(fileName);
- if (! expFile.open(QIODevice::WriteOnly | QIODevice::Text) ) {
- mError = VpnUiPlugin::Error;
- mErrorMessage = i18n("Could not open file for writing");
- return false;
- }
-
- NMStringMap dataMap;
- NMStringMap secretData;
-
- NetworkManager::VpnSetting::Ptr vpnSetting = connection->setting(NetworkManager::Setting::Vpn).dynamicCast<NetworkManager::VpnSetting>();
- dataMap = vpnSetting->data();
- secretData = vpnSetting->secrets();
-
- QString line;
- QString cacert, user_cert, private_key;
-
- line = QString(CLIENT_TAG) + '\n';
- expFile.write(line.toLatin1());
- line = QString("%1 %2").arg(REMOTE_TAG, dataMap[NM_OPENVPN_KEY_REMOTE]);
- if (dataMap[NM_OPENVPN_KEY_PORT].isEmpty()) {
- line.append('\n');
- } else {
- line.append(' ' + dataMap[NM_OPENVPN_KEY_PORT] + '\n');
- }
- expFile.write(line.toLatin1());
- if (dataMap[NM_OPENVPN_KEY_CONNECTION_TYPE] == NM_OPENVPN_CONTYPE_TLS ||
- dataMap[NM_OPENVPN_KEY_CONNECTION_TYPE] == NM_OPENVPN_CONTYPE_PASSWORD ||
- dataMap[NM_OPENVPN_KEY_CONNECTION_TYPE] == NM_OPENVPN_CONTYPE_PASSWORD_TLS) {
- if (!dataMap[NM_OPENVPN_KEY_CA].isEmpty())
- cacert = dataMap[NM_OPENVPN_KEY_CA];
- }
- if (dataMap[NM_OPENVPN_KEY_CONNECTION_TYPE] == NM_OPENVPN_CONTYPE_TLS ||
- dataMap[NM_OPENVPN_KEY_CONNECTION_TYPE] == NM_OPENVPN_CONTYPE_PASSWORD_TLS) {
- if (!dataMap[NM_OPENVPN_KEY_CERT].isEmpty())
- user_cert = dataMap[NM_OPENVPN_KEY_CERT];
- if (!dataMap[NM_OPENVPN_KEY_KEY].isEmpty())
- private_key = dataMap[NM_OPENVPN_KEY_KEY];
-
- }
- // Handle PKCS#12 (all certs are the same file)
- if (!cacert.isEmpty() && !user_cert.isEmpty() && !private_key.isEmpty()
- && cacert == user_cert && cacert == private_key) {
- line = QString("%1 \"%2\"\n").arg(PKCS12_TAG, cacert);
- expFile.write(line.toLatin1());
- }
- else {
- if (!cacert.isEmpty()) {
- line = QString("%1 \"%2\"\n").arg(CA_TAG, cacert);
- expFile.write(line.toLatin1());
- }
- if (!user_cert.isEmpty()) {
- line = QString("%1 \"%2\"\n").arg(CERT_TAG, user_cert);
- expFile.write(line.toLatin1());
- }
- if (!private_key.isEmpty()) {
- line = QString("%1 \"%2\"\n").arg(KEY_TAG, private_key);
- expFile.write(line.toLatin1());
- }
- }
- if (dataMap[NM_OPENVPN_KEY_CONNECTION_TYPE] == NM_OPENVPN_CONTYPE_PASSWORD ||
- dataMap[NM_OPENVPN_KEY_CONNECTION_TYPE] == NM_OPENVPN_CONTYPE_PASSWORD_TLS) {
- line = QString(AUTH_USER_PASS_TAG) + '\n';
- expFile.write(line.toLatin1());
- if (!dataMap[NM_OPENVPN_KEY_TLS_REMOTE].isEmpty()) {
- line = QString(TLS_REMOTE_TAG) + " \"" + dataMap[NM_OPENVPN_KEY_TLS_REMOTE] + "\"\n";
- expFile.write(line.toLatin1());
- }
- if (!dataMap[NM_OPENVPN_KEY_TA].isEmpty()) {
- line = QString(TLS_AUTH_TAG) + " \"" + dataMap[NM_OPENVPN_KEY_TA] + '\"';
- if (dataMap[NM_OPENVPN_KEY_TA_DIR].isEmpty()) {
- line.append("\n");
- } else {
- line.append(' ' + dataMap[NM_OPENVPN_KEY_TA_DIR] + '\n');
- }
- expFile.write(line.toLatin1());
- }
- }
- if (dataMap[NM_OPENVPN_KEY_CONNECTION_TYPE] == NM_OPENVPN_CONTYPE_STATIC_KEY) {
- line = QString(SECRET_TAG) + " \"" + dataMap[NM_OPENVPN_KEY_STATIC_KEY] + '\"';
- if (dataMap[NM_OPENVPN_KEY_STATIC_KEY_DIRECTION].isEmpty()) {
- line.append("\n");
- } else {
- line.append(' ' + dataMap[NM_OPENVPN_KEY_STATIC_KEY_DIRECTION] + '\n');
- }
- expFile.write(line.toLatin1());
- }
- if (dataMap.contains(NM_OPENVPN_KEY_RENEG_SECONDS) && !dataMap[NM_OPENVPN_KEY_RENEG_SECONDS].isEmpty()) {
- line = QString(RENEG_SEC_TAG) + ' ' + dataMap[NM_OPENVPN_KEY_RENEG_SECONDS] + '\n';
- expFile.write(line.toLatin1());
- }
- if (!dataMap[NM_OPENVPN_KEY_CIPHER].isEmpty()) {
- line = QString(CIPHER_TAG) + ' ' + dataMap[NM_OPENVPN_KEY_CIPHER] + '\n';
- expFile.write(line.toLatin1());
- }
- if (dataMap[NM_OPENVPN_KEY_COMP_LZO] == "yes") {
- line = QString(COMP_TAG) + " yes\n";
- expFile.write(line.toLatin1());
- }
- if (dataMap[NM_OPENVPN_KEY_MSSFIX] == "yes") {
- line = QString(MSSFIX_TAG) + '\n';
- expFile.write(line.toLatin1());
- }
- if (!dataMap[NM_OPENVPN_KEY_TUNNEL_MTU].isEmpty()) {
- line = QString(TUNMTU_TAG) + ' ' + dataMap[NM_OPENVPN_KEY_TUNNEL_MTU] + '\n';
- expFile.write(line.toLatin1());
- }
- if (!dataMap[NM_OPENVPN_KEY_FRAGMENT_SIZE].isEmpty()) {
- line = QString(FRAGMENT_TAG) + ' ' + dataMap[NM_OPENVPN_KEY_FRAGMENT_SIZE] + '\n';
- expFile.write(line.toLatin1());
- }
- line = QString(DEV_TAG) + (dataMap[NM_OPENVPN_KEY_TAP_DEV] == "yes" ? " tap\n" : " tun\n");
- expFile.write(line.toLatin1());
- line = QString(PROTO_TAG) + (dataMap[NM_OPENVPN_KEY_PROTO_TCP] == "yes" ? " tcp\n" : " udp\n");
- expFile.write(line.toLatin1());
- // Proxy stuff
- if (!dataMap[NM_OPENVPN_KEY_PROXY_TYPE].isEmpty()) {
- QString proxy_port = dataMap[NM_OPENVPN_KEY_PROXY_PORT];
- if (dataMap[NM_OPENVPN_KEY_PROXY_TYPE] == "http" && !dataMap[NM_OPENVPN_KEY_PROXY_SERVER].isEmpty()
- && dataMap.contains(NM_OPENVPN_KEY_PROXY_PORT)) {
- if (proxy_port.toInt() == 0)
- proxy_port = "8080";
- line = QString(HTTP_PROXY_TAG) + ' ' + dataMap[NM_OPENVPN_KEY_PROXY_SERVER] + ' ' + proxy_port;
- if (dataMap[NM_OPENVPN_KEY_HTTP_PROXY_USERNAME].isEmpty()) {
- line.append("\n");
- } else {
- line.append(' ' + fileName + "-httpauthfile\n");
- }
- expFile.write(line.toLatin1());
- if (dataMap[NM_OPENVPN_KEY_PROXY_RETRY] == "yes") {
- line = QString(HTTP_PROXY_RETRY_TAG) + '\n';
- expFile.write(line.toLatin1());
- }
- // If there is a username, need to write an authfile
- if (!dataMap[NM_OPENVPN_KEY_HTTP_PROXY_USERNAME].isEmpty()) {
- QFile authFile(fileName + "-httpauthfile");
- if (authFile.open(QFile::WriteOnly | QFile::Text)) {
- line = dataMap[NM_OPENVPN_KEY_HTTP_PROXY_USERNAME];
- if (dataMap[NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD].isEmpty()) {
- line.append("\n");
- } else {
- line.append(dataMap[NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD] + '\n');
- }
- authFile.write(line.toLatin1());
- authFile.close();
- }
- }
- }
- else if (dataMap[NM_OPENVPN_KEY_PROXY_TYPE] == "socks" && !dataMap[NM_OPENVPN_KEY_PROXY_SERVER].isEmpty() && dataMap.contains(NM_OPENVPN_KEY_PROXY_PORT)) {
- if (proxy_port.toInt() == 0)
- proxy_port = "1080";
- line = QString(SOCKS_PROXY_TAG) + dataMap[NM_OPENVPN_KEY_PROXY_SERVER] + ' ' + proxy_port + '\n';
- expFile.write(line.toLatin1());
- if (dataMap[NM_OPENVPN_KEY_PROXY_RETRY] == "yes") {
- line = QString(SOCKS_PROXY_RETRY_TAG) + '\n';
- expFile.write(line.toLatin1());
- }
- }
- }
- // Export never default setting.
- NetworkManager::Ipv4Setting::Ptr ipv4Setting = connection->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
- // Export X-NM-Routes
- if (!ipv4Setting->routes().isEmpty()) {
- QString routes;
- foreach(const NetworkManager::IpRoute &route, ipv4Setting->routes()) {
- routes += route.ip().toString() % QLatin1Char('/') % QString::number(route.prefixLength()) % QLatin1Char(' ');
- }
- if (!routes.isEmpty()) {
- routes = "X-NM-Routes " + routes.trimmed();
- expFile.write(routes.toLatin1());
- }
- }
- // Add hard-coded stuff
- expFile.write("nobind\n"
- "auth-nocache\n"
- "script-security 2\n"
- "persist-key\n"
- "persist-tun\n"
- "user nobody\n"
- "group nobody\n");
- expFile.close();
- return true;
-}
+++ /dev/null
-/*
- Copyright 2008 Will Stephenson <wstephenson@kde.org>
- Copyright 2011 Rajeesh K Nambiar <rajeeshknambiar@gmail.com>
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2014 Lamarque V. Souza <lamarque@kde.org>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMANM_OPENVPN_H
-#define PLASMANM_OPENVPN_H
-
-#include "vpnuiplugin.h"
-
-#include <QTextStream>
-#include <QVariant>
-
-class OpenVpnUiPlugin : public VpnUiPlugin
-{
-Q_OBJECT
-public:
- explicit OpenVpnUiPlugin(QObject * parent = 0, const QVariantList& = QVariantList());
- virtual ~OpenVpnUiPlugin();
- SettingWidget * widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- SettingWidget * askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
-
- QString suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const;
- QString supportedFileExtensions() const;
- NMVariantMapMap importConnectionSettings(const QString &fileName);
- bool exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName);
-
-private:
- QString saveFile(QTextStream &in, const QString &endTag, const QString &connectionName, const QString &fileName);
- QString tryToCopyToCertificatesDirectory(const QString &connectionName, const QString &sourceFilePath);
-};
-
-#endif // PLASMANM_OPENVPN_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OpenVPNProp</class>
- <widget class="QWidget" name="OpenVPNProp">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>495</width>
- <height>422</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="3" column="2">
- <widget class="QPushButton" name="btnAdvanced">
- <property name="text">
- <string>Advanced...</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="chkShowPasswords">
- <property name="text">
- <string>Show Passwords</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="3">
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="textLabel3">
- <property name="text">
- <string>Gateway:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>gateway</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="gateway"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="labelConnectionType">
- <property name="text">
- <string>Connection type:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>cmbConnectionType</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KComboBox" name="cmbConnectionType">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>X.509 Certificates</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Pre-shared Key</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Password</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>X.509 With Password</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0" colspan="3">
- <widget class="QStackedWidget" name="stackedWidget">
- <widget class="QWidget" name="page">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QFormLayout" name="formLayout_3">
- <item row="0" column="0">
- <widget class="QLabel" name="textLabel2">
- <property name="text">
- <string>CA file:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>x509CaFile</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KUrlRequester" name="x509CaFile"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="textLabel3_2">
- <property name="text">
- <string>Certificate:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>x509Cert</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KUrlRequester" name="x509Cert"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="textLabel4">
- <property name="text">
- <string>Key:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>x509Key</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KUrlRequester" name="x509Key"/>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>Key password:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="KLineEdit" name="x509KeyPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="x509KeyPasswordStorage">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>347</width>
- <height>206</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="page_2">
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QFormLayout" name="formLayout_4">
- <item row="0" column="0">
- <widget class="QLabel" name="textLabel5">
- <property name="text">
- <string>Shared Key:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>pskSharedKey</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KUrlRequester" name="pskSharedKey"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="textLabel6">
- <property name="text">
- <string>Local IP:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>pskLocalIp</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KLineEdit" name="pskLocalIp"/>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="textLabel7">
- <property name="text">
- <string>Remote IP:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>pskRemoteIp</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="KLineEdit" name="pskRemoteIp">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_16">
- <property name="text">
- <string>Key Direction:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KComboBox" name="cmbKeyDirection">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="whatsThis">
- <string>If key direction is used, it must be the opposite of that used on the VPN peer.</string>
- </property>
- <item>
- <property name="text">
- <string comment="like in None setting selected">None</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>0</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>1</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="page_3">
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <layout class="QFormLayout" name="formLayout_5">
- <item row="0" column="0">
- <widget class="QLabel" name="textLabel8">
- <property name="text">
- <string>CA File:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>passCaFile</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KUrlRequester" name="passCaFile"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="textLabel9">
- <property name="text">
- <string comment="like in Username for athentication">Username:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>passUserName</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="passUserName"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_11">
- <item>
- <widget class="KLineEdit" name="passPassword">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="passPasswordStorage">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="page_4">
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <item>
- <layout class="QFormLayout" name="formLayout_6">
- <item row="0" column="0">
- <widget class="QLabel" name="textLabel2_2">
- <property name="text">
- <string>CA file:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>x509PassCaFile</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KUrlRequester" name="x509PassCaFile"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="textLabel3_2_2">
- <property name="text">
- <string>Certificate:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>x509PassCert</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KUrlRequester" name="x509PassCert"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="textLabel4_2">
- <property name="text">
- <string>Key:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>x509PassKey</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KUrlRequester" name="x509PassKey"/>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Key password:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="textLabel9_2">
- <property name="text">
- <string comment="like in Username for athentication">Username:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>x509PassUsername</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KLineEdit" name="x509PassUsername"/>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Password:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_12">
- <item>
- <widget class="KLineEdit" name="x509PassKeyPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="x509PassKeyPasswordStorage">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item row="5" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_13">
- <item>
- <widget class="KLineEdit" name="x509PassPassword">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="x509PassPasswordStorage">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer_4">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- <item row="3" column="1">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KUrlRequester</class>
- <extends>QFrame</extends>
- <header>kurlrequester.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>gateway</tabstop>
- <tabstop>cmbConnectionType</tabstop>
- <tabstop>x509CaFile</tabstop>
- <tabstop>x509Cert</tabstop>
- <tabstop>x509Key</tabstop>
- <tabstop>x509KeyPassword</tabstop>
- <tabstop>x509KeyPasswordStorage</tabstop>
- <tabstop>chkShowPasswords</tabstop>
- <tabstop>pskSharedKey</tabstop>
- <tabstop>cmbKeyDirection</tabstop>
- <tabstop>pskLocalIp</tabstop>
- <tabstop>pskRemoteIp</tabstop>
- <tabstop>passCaFile</tabstop>
- <tabstop>passUserName</tabstop>
- <tabstop>passPassword</tabstop>
- <tabstop>passPasswordStorage</tabstop>
- <tabstop>x509PassCaFile</tabstop>
- <tabstop>x509PassCert</tabstop>
- <tabstop>x509PassKey</tabstop>
- <tabstop>x509PassKeyPassword</tabstop>
- <tabstop>x509PassKeyPasswordStorage</tabstop>
- <tabstop>x509PassUsername</tabstop>
- <tabstop>x509PassPassword</tabstop>
- <tabstop>x509PassPasswordStorage</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>cmbConnectionType</sender>
- <signal>currentIndexChanged(int)</signal>
- <receiver>stackedWidget</receiver>
- <slot>setCurrentIndex(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>228</x>
- <y>80</y>
- </hint>
- <hint type="destinationlabel">
- <x>584</x>
- <y>150</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OpenVpnAdvancedWidget</class>
- <widget class="QWidget" name="OpenVpnAdvancedWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>573</width>
- <height>471</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="KTabWidget" name="tabWidget">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="generalTab">
- <attribute name="title">
- <string>General</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout_6">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Gateway Port:</string>
- </property>
- <property name="buddy">
- <cstring>sbCustomPort</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="sbCustomPort">
- <property name="specialValueText">
- <string comment="like in use Automatic configuration">Automatic</string>
- </property>
- <property name="maximum">
- <number>65536</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_8">
- <item>
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>Tunnel MTU:</string>
- </property>
- <property name="buddy">
- <cstring>sbMtu</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KIntSpinBox" name="sbMtu">
- <property name="specialValueText">
- <string comment="like in use Automatic configuration">Automatic</string>
- </property>
- <property name="maximum">
- <number>65533</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_9">
- <item>
- <widget class="QLabel" name="label_9">
- <property name="text">
- <string>UDP fragment size:</string>
- </property>
- <property name="buddy">
- <cstring>sbUdpFragmentSize</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KIntSpinBox" name="sbUdpFragmentSize">
- <property name="specialValueText">
- <string comment="like in use Automatic configuration">Automatic</string>
- </property>
- <property name="maximum">
- <number>65535</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_7">
- <item>
- <widget class="QCheckBox" name="chkUseCustomReneg">
- <property name="text">
- <string>Use custom renegotiation interval</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KIntSpinBox" name="sbCustomReneg">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="maximum">
- <number>604800</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QCheckBox" name="chkUseLZO">
- <property name="text">
- <string>Use LZO compression</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="chkUseTCP">
- <property name="text">
- <string>Use TCP connection</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="chkUseTAP">
- <property name="text">
- <string>Use TAP device</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="chkMssRestrict">
- <property name="text">
- <string>Restrict TCP maximum segment size (MSS)</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_5">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>306</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="securityTab">
- <attribute name="title">
- <string>Security</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout_7">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Cipher:</string>
- </property>
- <property name="buddy">
- <cstring>cboCipher</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="cboCipher">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>Obtaining available ciphers...</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>HMAC Authentication:</string>
- </property>
- <property name="buddy">
- <cstring>cboHmac</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="cboHmac">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string comment="like in use Default configuration">Default</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="like in None setting selected">None</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>MD-4</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>MD-5</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>SHA-1</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>SHA-224</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>SHA-256</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>SHA-384</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>SHA-512</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>RIPEMD-160</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer_6">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="tlsTab">
- <attribute name="title">
- <string>TLS Settings</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_10">
- <item>
- <widget class="QLabel" name="label_10">
- <property name="text">
- <string>Subject Match:</string>
- </property>
- <property name="buddy">
- <cstring>subjectMatch</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KLineEdit" name="subjectMatch">
- <property name="whatsThis">
- <string>Connect only to servers whose certificate matches the given subject. Example: /CN=myvpn.company.com</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QCheckBox" name="chkRemoteCertTls">
- <property name="text">
- <string>Verify peer (server) certificate usage signature</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="labelRemoteCertTls">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Remote peer certificate TLS type:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="cmbRemoteCertTls">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <item>
- <property name="text">
- <string>Server</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Client</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QGroupBox" name="useExtraTlsAuth">
- <property name="title">
- <string>Use additional TLS authentication</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_8">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_6">
- <item>
- <widget class="QLabel" name="textLabel4_3">
- <property name="text">
- <string>Key:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>kurlTlsAuthKey</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KUrlRequester" name="kurlTlsAuthKey"/>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QLabel" name="textLabel1">
- <property name="text">
- <string>Key Direction:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>cboDirection</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="cboDirection">
- <item>
- <property name="text">
- <string comment="like in None setting selected">None</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Server (0)</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Client (1)</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_7">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>533</width>
- <height>178</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="proxyTab">
- <attribute name="title">
- <string>Proxies</string>
- </attribute>
- <layout class="QFormLayout" name="formLayout_2">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_11">
- <property name="text">
- <string>Proxy Type:</string>
- </property>
- <property name="buddy">
- <cstring>cmbProxyType</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="cmbProxyType">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>HTTP</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>SOCKS</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_12">
- <property name="text">
- <string>Server Address:</string>
- </property>
- <property name="buddy">
- <cstring>proxyServerAddress</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KLineEdit" name="proxyServerAddress"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_13">
- <property name="text">
- <string>Port:</string>
- </property>
- <property name="buddy">
- <cstring>sbProxyPort</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KIntSpinBox" name="sbProxyPort">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximum">
- <number>65535</number>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QCheckBox" name="chkProxyRetry">
- <property name="text">
- <string>Retry indefinitely when errors occur</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_14">
- <property name="text">
- <string>Proxy Username:</string>
- </property>
- <property name="buddy">
- <cstring>proxyUsername</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="label_15">
- <property name="text">
- <string>Proxy Password:</string>
- </property>
- <property name="buddy">
- <cstring>proxyPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KLineEdit" name="proxyUsername"/>
- </item>
- <item row="6" column="1">
- <widget class="QCheckBox" name="chkProxyShowPassword">
- <property name="text">
- <string>Show Password</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_14">
- <item>
- <widget class="KLineEdit" name="proxyPassword">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="passwordMode" stdset="0">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="proxyPasswordStorage">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KIntSpinBox</class>
- <extends>QSpinBox</extends>
- <header>knuminput.h</header>
- </customwidget>
- <customwidget>
- <class>KUrlRequester</class>
- <extends>QFrame</extends>
- <header>kurlrequester.h</header>
- <container>1</container>
- </customwidget>
- <customwidget>
- <class>KTabWidget</class>
- <extends>QTabWidget</extends>
- <header>ktabwidget.h</header>
- <container>1</container>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>tabWidget</tabstop>
- <tabstop>sbCustomPort</tabstop>
- <tabstop>sbMtu</tabstop>
- <tabstop>sbUdpFragmentSize</tabstop>
- <tabstop>chkUseCustomReneg</tabstop>
- <tabstop>sbCustomReneg</tabstop>
- <tabstop>chkUseLZO</tabstop>
- <tabstop>chkUseTCP</tabstop>
- <tabstop>chkUseTAP</tabstop>
- <tabstop>chkMssRestrict</tabstop>
- <tabstop>cboCipher</tabstop>
- <tabstop>cboHmac</tabstop>
- <tabstop>subjectMatch</tabstop>
- <tabstop>chkRemoteCertTls</tabstop>
- <tabstop>cmbRemoteCertTls</tabstop>
- <tabstop>useExtraTlsAuth</tabstop>
- <tabstop>cboDirection</tabstop>
- <tabstop>cmbProxyType</tabstop>
- <tabstop>proxyServerAddress</tabstop>
- <tabstop>sbProxyPort</tabstop>
- <tabstop>chkProxyRetry</tabstop>
- <tabstop>proxyUsername</tabstop>
- <tabstop>proxyPassword</tabstop>
- <tabstop>proxyPasswordStorage</tabstop>
- <tabstop>chkProxyShowPassword</tabstop>
- <tabstop>buttonBox</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>chkUseCustomReneg</sender>
- <signal>toggled(bool)</signal>
- <receiver>sbCustomReneg</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>172</x>
- <y>131</y>
- </hint>
- <hint type="destinationlabel">
- <x>392</x>
- <y>131</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>chkRemoteCertTls</sender>
- <signal>toggled(bool)</signal>
- <receiver>labelRemoteCertTls</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>279</x>
- <y>73</y>
- </hint>
- <hint type="destinationlabel">
- <x>145</x>
- <y>100</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>chkRemoteCertTls</sender>
- <signal>toggled(bool)</signal>
- <receiver>cmbRemoteCertTls</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>279</x>
- <y>73</y>
- </hint>
- <hint type="destinationlabel">
- <x>413</x>
- <y>100</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "openvpnadvancedwidget.h"
-#include "ui_openvpnadvanced.h"
-#include "nm-openvpn-service.h"
-#include "settingwidget.h"
-
-#include <KLocalizedString>
-#include <KProcess>
-#include <KStandardDirs>
-#include <KAcceleratorManager>
-
-class OpenVpnAdvancedWidget::Private {
-public:
- NetworkManager::VpnSetting::Ptr setting;
- KProcess * openvpnProcess;
- QByteArray openVpnCiphers;
- bool gotOpenVpnCiphers;
- bool readConfig;
-
- class EnumProxyType
- {
- public:
- enum ProxyType {NotRequired = 0, HTTP = 1, SOCKS = 2};
- };
- class EnumHashingAlgorithms
- {
- public:
- enum HashingAlgorithms {Default = 0, None, Md4, Md5, Sha1, Sha224, Sha256, Sha384, Sha512, Ripemd160};
- };
-};
-
-OpenVpnAdvancedWidget::OpenVpnAdvancedWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent) :
- QDialog(parent),
- m_ui(new Ui::OpenVpnAdvancedWidget),
- d(new Private)
-{
- m_ui->setupUi(this);
- m_ui->kurlTlsAuthKey->setMode(KFile::LocalOnly);
-
- setWindowTitle(i18nc("@title: window advanced openvpn properties", "Advanced OpenVPN properties"));
-
- d->openvpnProcess = 0;
- d->gotOpenVpnCiphers = false;
- d->readConfig = false;
- d->setting = setting;
-
- connect(m_ui->proxyPasswordStorage, SIGNAL(currentIndexChanged(int)), this, SLOT(proxyPasswordStorageChanged(int)));
- connect(m_ui->chkProxyShowPassword, SIGNAL(toggled(bool)), this, SLOT(proxyPasswordToggled(bool)));
- connect(m_ui->cmbProxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(proxyTypeChanged(int)));
-
- // start openVPN process and get its cipher list
- const QString openVpnBinary = KStandardDirs::findExe("openvpn", "/sbin:/usr/sbin");
- const QStringList args(QLatin1String("--show-ciphers"));
- d->openvpnProcess = new KProcess(this);
- d->openvpnProcess->setOutputChannelMode(KProcess::OnlyStdoutChannel);
- d->openvpnProcess->setReadChannel(QProcess::StandardOutput);
- connect(d->openvpnProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(openVpnError(QProcess::ProcessError)));
- connect(d->openvpnProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(gotOpenVpnOutput()));
- connect(d->openvpnProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(openVpnFinished(int,QProcess::ExitStatus)));
-
- d->openvpnProcess->setProgram(openVpnBinary, args);
-
- connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(accept()));
- connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
-
- KAcceleratorManager::manage(this);
-
- loadConfig();
-}
-
-OpenVpnAdvancedWidget::~OpenVpnAdvancedWidget()
-{
- delete d;
-}
-
-void OpenVpnAdvancedWidget::init()
-{
- d->openvpnProcess->start();
-}
-
-void OpenVpnAdvancedWidget::gotOpenVpnOutput()
-{
- d->openVpnCiphers.append(d->openvpnProcess->readAll());
-}
-
-void OpenVpnAdvancedWidget::openVpnError(QProcess::ProcessError)
-{
- m_ui->cboCipher->removeItem(0);
- m_ui->cboCipher->addItem(i18nc("@item:inlistbox Item added when OpenVPN cipher lookup failed", "OpenVPN cipher lookup failed"));
-}
-
-void OpenVpnAdvancedWidget::openVpnFinished(int exitCode, QProcess::ExitStatus exitStatus)
-{
- m_ui->cboCipher->removeItem(0);
- if (!exitCode && exitStatus == QProcess::NormalExit) {
- m_ui->cboCipher->addItem(i18nc("@item::inlist Default openvpn cipher item", "Default"));
- const QList<QByteArray> rawOutputLines = d->openVpnCiphers.split('\n');
- bool foundFirstSpace = false;;
- foreach (const QByteArray &cipher, rawOutputLines) {
- if (cipher.length() == 0) {
- foundFirstSpace = true;
- } else if (foundFirstSpace) {
- m_ui->cboCipher->addItem(QString::fromLocal8Bit(cipher.left(cipher.indexOf(' '))));
- }
- }
-
- if (m_ui->cboCipher->count()) {
- m_ui->cboCipher->setEnabled(true);
- } else {
- m_ui->cboCipher->addItem(i18nc("@item:inlistbox Item added when OpenVPN cipher lookup failed", "No OpenVPN ciphers found"));
- }
- } else {
- m_ui->cboCipher->addItem(i18nc("@item:inlistbox Item added when OpenVPN cipher lookup failed", "OpenVPN cipher lookup failed"));
- }
- delete d->openvpnProcess;
- d->openvpnProcess = 0;
- d->openVpnCiphers = QByteArray();
- d->gotOpenVpnCiphers = true;
-
- if (d->readConfig) {
- const NMStringMap dataMap = d->setting->data();
- if (dataMap.contains(NM_OPENVPN_KEY_CIPHER)) {
- m_ui->cboCipher->setCurrentIndex(m_ui->cboCipher->findText(dataMap.value(NM_OPENVPN_KEY_CIPHER)));
- }
- }
-}
-
-void OpenVpnAdvancedWidget::loadConfig()
-{
- const NMStringMap dataMap = d->setting->data();
- const NMStringMap secrets = d->setting->secrets();
-
- // Optional Settings
- if (dataMap.contains(NM_OPENVPN_KEY_PORT)) {
- m_ui->sbCustomPort->setValue(dataMap[NM_OPENVPN_KEY_PORT].toUInt());
- } else {
- m_ui->sbCustomPort->setValue(0);
- }
- if (dataMap.contains(NM_OPENVPN_KEY_TUNNEL_MTU)) {
- m_ui->sbMtu->setValue(dataMap[NM_OPENVPN_KEY_TUNNEL_MTU].toUInt());
- } else {
- m_ui->sbMtu->setValue(0);
- }
- if (dataMap.contains(NM_OPENVPN_KEY_FRAGMENT_SIZE)) {
- m_ui->sbUdpFragmentSize->setValue(dataMap[NM_OPENVPN_KEY_FRAGMENT_SIZE].toUInt());
- } else {
- m_ui->sbUdpFragmentSize->setValue(0);
- }
- if (dataMap.contains(NM_OPENVPN_KEY_RENEG_SECONDS)) {
- m_ui->chkUseCustomReneg->setChecked(true);
- m_ui->sbCustomReneg->setValue(dataMap[NM_OPENVPN_KEY_RENEG_SECONDS].toUInt());
- } else {
- m_ui->chkUseCustomReneg->setChecked(false);
- m_ui->sbCustomReneg->setValue(0);
- }
- m_ui->chkUseLZO->setChecked( dataMap[NM_OPENVPN_KEY_COMP_LZO] == "yes" );
- m_ui->chkUseTCP->setChecked( dataMap[NM_OPENVPN_KEY_PROTO_TCP] == "yes" );
- m_ui->chkUseTAP->setChecked( dataMap[NM_OPENVPN_KEY_TAP_DEV] == "yes" );
- m_ui->chkMssRestrict->setChecked(dataMap[NM_OPENVPN_KEY_MSSFIX] == "yes");
- // Optional Security Settings
- QString hmacKeyAuth = dataMap[NM_OPENVPN_KEY_AUTH];
- if (hmacKeyAuth == QLatin1String(NM_OPENVPN_AUTH_NONE)) {
- m_ui->cboHmac->setCurrentIndex(Private::EnumHashingAlgorithms::None);
- } else if (hmacKeyAuth == QLatin1String(NM_OPENVPN_AUTH_RSA_MD4)) {
- m_ui->cboHmac->setCurrentIndex(Private::EnumHashingAlgorithms::Md4);
- } else if (hmacKeyAuth == QLatin1String(NM_OPENVPN_AUTH_MD5)) {
- m_ui->cboHmac->setCurrentIndex(Private::EnumHashingAlgorithms::Md5);
- } else if (hmacKeyAuth == QLatin1String(NM_OPENVPN_AUTH_SHA1)) {
- m_ui->cboHmac->setCurrentIndex(Private::EnumHashingAlgorithms::Sha1);
- } else if (hmacKeyAuth == QLatin1String(NM_OPENVPN_AUTH_SHA224)) {
- m_ui->cboHmac->setCurrentIndex(Private::EnumHashingAlgorithms::Sha224);
- } else if (hmacKeyAuth == QLatin1String(NM_OPENVPN_AUTH_SHA256)) {
- m_ui->cboHmac->setCurrentIndex(Private::EnumHashingAlgorithms::Sha256);
- } else if (hmacKeyAuth == QLatin1String(NM_OPENVPN_AUTH_SHA384)) {
- m_ui->cboHmac->setCurrentIndex(Private::EnumHashingAlgorithms::Sha384);
- } else if (hmacKeyAuth == QLatin1String(NM_OPENVPN_AUTH_SHA512)) {
- m_ui->cboHmac->setCurrentIndex(Private::EnumHashingAlgorithms::Sha512);
- } else if (hmacKeyAuth == QLatin1String(NM_OPENVPN_AUTH_RIPEMD160)) {
- m_ui->cboHmac->setCurrentIndex(Private::EnumHashingAlgorithms::Ripemd160);
- } else {
- m_ui->cboHmac->setCurrentIndex(Private::EnumHashingAlgorithms::Default);
- }
- // ciphers populated above?
- if (d->gotOpenVpnCiphers && dataMap.contains(NM_OPENVPN_KEY_CIPHER)) {
- m_ui->cboCipher->setCurrentIndex(m_ui->cboCipher->findText(dataMap[NM_OPENVPN_KEY_CIPHER]));
- }
-
- // Optional TLS
- if (dataMap.contains(NM_OPENVPN_KEY_TLS_REMOTE)) {
- m_ui->subjectMatch->setText(dataMap[NM_OPENVPN_KEY_TLS_REMOTE]);
- }
-
- if (dataMap.contains(NM_OPENVPN_KEY_REMOTE_CERT_TLS)) {
- const QString remoteCertTls = dataMap[NM_OPENVPN_KEY_REMOTE_CERT_TLS];
- m_ui->chkRemoteCertTls->setChecked(true);
- m_ui->labelRemoteCertTls->setEnabled(true);
- m_ui->cmbRemoteCertTls->setEnabled(true);
- m_ui->cmbRemoteCertTls->setCurrentIndex(remoteCertTls == QLatin1String("server") ? 0 : 1);
- }
-
- m_ui->useExtraTlsAuth->setChecked(!dataMap[NM_OPENVPN_KEY_TA].isEmpty());
- m_ui->kurlTlsAuthKey->setUrl(KUrl(dataMap[NM_OPENVPN_KEY_TA]) );
- if (dataMap.contains(NM_OPENVPN_KEY_TA_DIR)) {
- const uint tlsAuthDirection = dataMap[NM_OPENVPN_KEY_TA_DIR].toUInt();
- m_ui->cboDirection->setCurrentIndex(tlsAuthDirection + 1);
- }
- // Proxies
- if (dataMap[NM_OPENVPN_KEY_PROXY_TYPE] == "http") {
- m_ui->cmbProxyType->setCurrentIndex(Private::EnumProxyType::HTTP);
- } else if (dataMap[NM_OPENVPN_KEY_PROXY_TYPE] == "socks") {
- m_ui->cmbProxyType->setCurrentIndex(Private::EnumProxyType::SOCKS);
- } else {
- m_ui->cmbProxyType->setCurrentIndex(Private::EnumProxyType::NotRequired);
- }
- proxyTypeChanged(m_ui->cmbProxyType->currentIndex());
- m_ui->proxyServerAddress->setText(dataMap[NM_OPENVPN_KEY_PROXY_SERVER]);
- if (dataMap.contains(NM_OPENVPN_KEY_PROXY_PORT)) {
- m_ui->sbProxyPort->setValue(dataMap[NM_OPENVPN_KEY_PROXY_PORT].toUInt());
- } else {
- m_ui->sbProxyPort->setValue(0);
- }
- m_ui->chkProxyRetry->setChecked(dataMap[NM_OPENVPN_KEY_PROXY_RETRY] == "yes");
- m_ui->proxyUsername->setText(dataMap[NM_OPENVPN_KEY_HTTP_PROXY_USERNAME]);
- d->readConfig = true;
-
- NetworkManager::Setting::SecretFlags type;
- type = (NetworkManager::Setting::SecretFlags)dataMap[NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD"-flags"].toInt();
- if (!(type & NetworkManager::Setting::NotSaved || type & NetworkManager::Setting::NotRequired)) {
- m_ui->proxyPassword->setText(secrets.value(NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD));
- }
- fillOnePasswordCombo(m_ui->proxyPasswordStorage, type);
-}
-
-void OpenVpnAdvancedWidget::setPasswordType(KLineEdit *edit, int type)
-{
- edit->setEnabled(type == SettingWidget::EnumPasswordStorageType::Store);
-}
-
-void OpenVpnAdvancedWidget::fillOnePasswordCombo(KComboBox * combo, NetworkManager::Setting::SecretFlags type)
-{
- if (type.testFlag(NetworkManager::Setting::AgentOwned) || type.testFlag(NetworkManager::Setting::None)) {
- combo->setCurrentIndex(SettingWidget::EnumPasswordStorageType::Store);
- } else if (type.testFlag(NetworkManager::Setting::NotRequired)) {
- combo->setCurrentIndex(SettingWidget::EnumPasswordStorageType::NotRequired);
- } else if (type.testFlag(NetworkManager::Setting::NotSaved)) {
- combo->setCurrentIndex(SettingWidget::EnumPasswordStorageType::AlwaysAsk);
- }
-}
-
-NetworkManager::VpnSetting::Ptr OpenVpnAdvancedWidget::setting() const
-{
- NMStringMap data;
- NMStringMap secretData;
-
- // optional settings
- if ( m_ui->sbCustomPort->value() > 0 ) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_PORT), QString::number(m_ui->sbCustomPort->value()));
- }
- if ( m_ui->sbMtu->value() > 0 ) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_TUNNEL_MTU), QString::number(m_ui->sbMtu->value()));
- }
- if ( m_ui->sbUdpFragmentSize->value() > 0 ) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_FRAGMENT_SIZE), QString::number(m_ui->sbUdpFragmentSize->value()));
- }
- if (m_ui->chkUseCustomReneg->isChecked()) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_RENEG_SECONDS), QString::number(m_ui->sbCustomReneg->value()));
- }
- data.insert( QLatin1String(NM_OPENVPN_KEY_PROTO_TCP), m_ui->chkUseTCP->isChecked() ? "yes" : "no" );
- data.insert( QLatin1String(NM_OPENVPN_KEY_COMP_LZO), m_ui->chkUseLZO->isChecked() ? "yes" : "no" );
- data.insert( QLatin1String(NM_OPENVPN_KEY_TAP_DEV), m_ui->chkUseTAP->isChecked() ? "yes" : "no" );
- data.insert( QLatin1String(NM_OPENVPN_KEY_MSSFIX), m_ui->chkMssRestrict->isChecked() ? "yes" : "no" );
-
- // Optional Security
- switch ( m_ui->cboHmac->currentIndex()) {
- case Private::EnumHashingAlgorithms::Default:
- break;
- case Private::EnumHashingAlgorithms::None:
- data.insert(QLatin1String(NM_OPENVPN_KEY_AUTH), QLatin1String(NM_OPENVPN_AUTH_NONE));
- break;
- case Private::EnumHashingAlgorithms::Md4:
- data.insert(QLatin1String(NM_OPENVPN_KEY_AUTH), QLatin1String(NM_OPENVPN_AUTH_RSA_MD4));
- break;
- case Private::EnumHashingAlgorithms::Md5:
- data.insert(QLatin1String(NM_OPENVPN_KEY_AUTH), QLatin1String(NM_OPENVPN_AUTH_MD5));
- break;
- case Private::EnumHashingAlgorithms::Sha1:
- data.insert(QLatin1String(NM_OPENVPN_KEY_AUTH), QLatin1String(NM_OPENVPN_AUTH_SHA1));
- break;
- case Private::EnumHashingAlgorithms::Sha224:
- data.insert(QLatin1String(NM_OPENVPN_KEY_AUTH), QLatin1String(NM_OPENVPN_AUTH_SHA224));
- break;
- case Private::EnumHashingAlgorithms::Sha256:
- data.insert(QLatin1String(NM_OPENVPN_KEY_AUTH), QLatin1String(NM_OPENVPN_AUTH_SHA256));
- break;
- case Private::EnumHashingAlgorithms::Sha384:
- data.insert(QLatin1String(NM_OPENVPN_KEY_AUTH), QLatin1String(NM_OPENVPN_AUTH_SHA384));
- break;
- case Private::EnumHashingAlgorithms::Sha512:
- data.insert(QLatin1String(NM_OPENVPN_KEY_AUTH), QLatin1String(NM_OPENVPN_AUTH_SHA512));
- break;
- case Private::EnumHashingAlgorithms::Ripemd160:
- data.insert(QLatin1String(NM_OPENVPN_KEY_AUTH), QLatin1String(NM_OPENVPN_AUTH_RIPEMD160));
- break;
- }
- if (m_ui->cboCipher->currentIndex() != 0) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_CIPHER), m_ui->cboCipher->currentText());
- }
-
- // optional tls authentication
- if (!m_ui->subjectMatch->text().isEmpty()) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_TLS_REMOTE), m_ui->subjectMatch->text());
- }
-
- if (m_ui->chkRemoteCertTls->isChecked()) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_REMOTE_CERT_TLS), m_ui->cmbRemoteCertTls->currentText().toLower());
- }
-
- if (m_ui->useExtraTlsAuth->isChecked()) {
- KUrl tlsAuthKeyUrl = m_ui->kurlTlsAuthKey->url();
- if (!tlsAuthKeyUrl.isEmpty()) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_TA), tlsAuthKeyUrl.path());
- }
- if (m_ui->cboDirection->currentIndex() > 0) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_TA_DIR), QString::number(m_ui->cboDirection->currentIndex() - 1));
- }
- }
-
- // Proxies
- switch (m_ui->cmbProxyType->currentIndex()) {
- case Private::EnumProxyType::NotRequired:
- break;
- case Private::EnumProxyType::HTTP:
- data.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_TYPE), "http");
- data.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_SERVER), m_ui->proxyServerAddress->text());
- data.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_PORT), QString::number(m_ui->sbProxyPort->value()));
- data.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_RETRY), m_ui->chkProxyRetry->isChecked() ? "yes" : "no");
- if (!m_ui->proxyUsername->text().isEmpty()) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_HTTP_PROXY_USERNAME), m_ui->proxyUsername->text());
- secretData.insert(QLatin1String(NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD), m_ui->proxyPassword->text());
- handleOnePasswordType(m_ui->proxyPasswordStorage, QLatin1String(NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD"-flags"), data);
- }
- break;
- case Private::EnumProxyType::SOCKS:
- data.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_TYPE), "socks");
- data.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_SERVER), m_ui->proxyServerAddress->text());
- data.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_PORT), QString::number(m_ui->sbProxyPort->value()));
- data.insert(QLatin1String(NM_OPENVPN_KEY_PROXY_RETRY), m_ui->chkProxyRetry->isChecked() ? "yes" : "no");
- break;
- }
-
- d->setting->setData(data);
- d->setting->setSecrets(secretData);
-
- return d->setting;
-}
-
-void OpenVpnAdvancedWidget::proxyPasswordStorageChanged(int index)
-{
- setPasswordType(m_ui->proxyPassword, index);
-}
-
-void OpenVpnAdvancedWidget::proxyPasswordToggled(bool toggled)
-{
- m_ui->proxyPassword->setPasswordMode(!toggled);
-}
-
-void OpenVpnAdvancedWidget::proxyTypeChanged(int type)
-{
- switch (type)
- {
- case Private::EnumProxyType::NotRequired:
- m_ui->proxyServerAddress->setEnabled(false);
- m_ui->sbProxyPort->setEnabled(false);
- m_ui->chkProxyRetry->setEnabled(false);
- m_ui->proxyUsername->setEnabled(false);
- m_ui->proxyPassword->setEnabled(false);
- m_ui->proxyPasswordStorage->setEnabled(false);
- m_ui->chkProxyShowPassword->setEnabled(false);
- break;
- case Private::EnumProxyType::HTTP:
- m_ui->proxyServerAddress->setEnabled(true);
- m_ui->sbProxyPort->setEnabled(true);
- m_ui->chkProxyRetry->setEnabled(true);
- m_ui->proxyUsername->setEnabled(true);
- m_ui->proxyPasswordStorage->setEnabled(true);
- setPasswordType(m_ui->proxyPassword, m_ui->proxyPasswordStorage->currentIndex());
- m_ui->chkProxyShowPassword->setEnabled(true);
- break;
- case Private::EnumProxyType::SOCKS:
- m_ui->proxyServerAddress->setEnabled(true);
- m_ui->sbProxyPort->setEnabled(true);
- m_ui->chkProxyRetry->setEnabled(true);
- m_ui->proxyUsername->setEnabled(false);
- m_ui->proxyPassword->setEnabled(false);
- m_ui->proxyPasswordStorage->setEnabled(false);
- m_ui->chkProxyShowPassword->setEnabled(false);
- break;
- }
-}
-
-uint OpenVpnAdvancedWidget::handleOnePasswordType(const KComboBox * combo, const QString & key, NMStringMap & data) const
-{
- uint type = combo->currentIndex();
- switch (type) {
- case SettingWidget::EnumPasswordStorageType::AlwaysAsk:
- data.insert(key, QString::number(NetworkManager::Setting::NotSaved));
- break;
- case SettingWidget::EnumPasswordStorageType::Store:
- data.insert(key, QString::number(NetworkManager::Setting::AgentOwned));
- break;
- case SettingWidget::EnumPasswordStorageType::NotRequired:
- data.insert(key, QString::number(NetworkManager::Setting::NotRequired));
- break;
- }
- return type;
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_OPENVPN_ADVANCED_WIDGET_H
-#define PLASMA_NM_OPENVPN_ADVANCED_WIDGET_H
-
-#include <QDialog>
-#include <QProcess>
-
-#include <KLineEdit>
-#include <KComboBox>
-
-#include <NetworkManagerQt/VpnSetting>
-
-namespace Ui
-{
-class OpenVpnAdvancedWidget;
-}
-
-class OpenVpnAdvancedWidget : public QDialog
-{
- Q_OBJECT
-public:
- explicit OpenVpnAdvancedWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent = 0);
- ~OpenVpnAdvancedWidget();
- void init();
-
- NetworkManager::VpnSetting::Ptr setting() const;
-
-private slots:
- void gotOpenVpnOutput();
- void openVpnError(QProcess::ProcessError);
- void openVpnFinished(int, QProcess::ExitStatus);
-
- void proxyPasswordStorageChanged(int);
- void proxyPasswordToggled(bool);
- void proxyTypeChanged(int);
-
-private:
- void loadConfig();
- void setPasswordType(KLineEdit *edit, int type);
- void fillOnePasswordCombo(KComboBox * combo, NetworkManager::Setting::SecretFlags type);
- uint handleOnePasswordType(const KComboBox * combo, const QString & key, NMStringMap & data) const;
- Ui::OpenVpnAdvancedWidget * m_ui;
- class Private;
- Private * d;
-};
-
-#endif // PLASMA_NM_OPENVPN_ADVANCED_WIDGET_H
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "openvpnauth.h"
-
-#include <QString>
-#include <QFormLayout>
-#include <QLabel>
-#include <QCheckBox>
-
-#include <KLineEdit>
-#include <KLocale>
-
-#include "nm-openvpn-service.h"
-
-class OpenVpnAuthWidgetPrivate
-{
-public:
- NetworkManager::VpnSetting::Ptr setting;
- QFormLayout *layout;
-};
-
-OpenVpnAuthWidget::OpenVpnAuthWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
- : SettingWidget(setting, parent), d_ptr(new OpenVpnAuthWidgetPrivate)
-{
- Q_D(OpenVpnAuthWidget);
- d->setting = setting;
- d->layout = new QFormLayout(this);
- setLayout(d->layout);
-
- readSecrets();
-
- KAcceleratorManager::manage(this);
-}
-
-OpenVpnAuthWidget::~OpenVpnAuthWidget()
-{
- delete d_ptr;
-}
-
-void OpenVpnAuthWidget::readSecrets()
-{
- Q_D(OpenVpnAuthWidget);
- const NMStringMap secrets = d->setting->secrets();
- const NMStringMap dataMap = d->setting->data();
- const QString cType = dataMap[NM_OPENVPN_KEY_CONNECTION_TYPE];
- QLabel *label;
- KLineEdit *lineEdit;
-
- NetworkManager::Setting::SecretFlags certType = (NetworkManager::Setting::SecretFlags)dataMap.value(NM_OPENVPN_KEY_CERTPASS"-flags").toInt();
- NetworkManager::Setting::SecretFlags passType = (NetworkManager::Setting::SecretFlags)dataMap.value(NM_OPENVPN_KEY_PASSWORD"-flags").toInt();
- NetworkManager::Setting::SecretFlags proxyType = (NetworkManager::Setting::SecretFlags)dataMap.value(NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD"-flags").toInt();
-
- if (cType == QLatin1String(NM_OPENVPN_CONTYPE_TLS) && !(certType.testFlag(NetworkManager::Setting::NotRequired))) {
- label = new QLabel(this);
- label->setText(i18n("Key Password:"));
- lineEdit = new KLineEdit(this);
- lineEdit->setPasswordMode(true);
- lineEdit->setProperty("nm_secrets_key", QLatin1String(NM_OPENVPN_KEY_CERTPASS));
- lineEdit->setText(secrets.value(QLatin1String(NM_OPENVPN_KEY_CERTPASS)));
- d->layout->addRow(label, lineEdit);
- } else if (cType == QLatin1String(NM_OPENVPN_CONTYPE_PASSWORD) && !(passType.testFlag(NetworkManager::Setting::NotRequired))) {
- label = new QLabel(this);
- label->setText(i18n("Password:"));
- lineEdit = new KLineEdit(this);
- lineEdit->setPasswordMode(true);
- lineEdit->setProperty("nm_secrets_key", QLatin1String(NM_OPENVPN_KEY_PASSWORD));
- lineEdit->setText(secrets.value(QLatin1String(NM_OPENVPN_KEY_PASSWORD)));
- d->layout->addRow(label, lineEdit);
- } else if (cType == QLatin1String(NM_OPENVPN_CONTYPE_PASSWORD_TLS)) {
- if (!(passType.testFlag(NetworkManager::Setting::NotRequired))) {
- label = new QLabel(this);
- label->setText(i18n("Password:"));
- lineEdit = new KLineEdit(this);
- lineEdit->setPasswordMode(true);
- lineEdit->setProperty("nm_secrets_key", QLatin1String(NM_OPENVPN_KEY_PASSWORD));
- lineEdit->setText(secrets.value(QLatin1String(NM_OPENVPN_KEY_PASSWORD)));
- d->layout->addRow(label, lineEdit);
- }
- if (!(certType.testFlag(NetworkManager::Setting::NotRequired))) {
- label = new QLabel(this);
- label->setText(i18n("Key Password:"));
- lineEdit = new KLineEdit(this);
- lineEdit->setPasswordMode(true);
- lineEdit->setProperty("nm_secrets_key", QLatin1String(NM_OPENVPN_KEY_CERTPASS));
- lineEdit->setText(secrets.value(QLatin1String(NM_OPENVPN_KEY_CERTPASS)));
- d->layout->addRow(label, lineEdit);
- }
- }
-
- if (dataMap.contains(NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD"-flags") && !(proxyType.testFlag(NetworkManager::Setting::NotRequired))) {
- label = new QLabel(this);
- label->setText(i18n("Proxy Password:"));
- lineEdit = new KLineEdit(this);
- lineEdit->setPasswordMode(true);
- lineEdit->setProperty("nm_secrets_key", QLatin1String(NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD));
- lineEdit->setText(secrets.value(QLatin1String(NM_OPENVPN_KEY_HTTP_PROXY_PASSWORD)));
- d->layout->addRow(label, lineEdit);
- }
-
- for (int i = 0; i < d->layout->rowCount(); i++) {
- KLineEdit *le = qobject_cast<KLineEdit*>(d->layout->itemAt(i, QFormLayout::FieldRole)->widget());
- if (le && le->text().isEmpty()) {
- le->setFocus(Qt::OtherFocusReason);
- break;
- }
- }
-
- QCheckBox *showPasswords = new QCheckBox(this);
- showPasswords->setText(i18n("&Show password"));
- d->layout->addRow(showPasswords);
- connect(showPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswordsToggled(bool)));
-}
-
-QVariantMap OpenVpnAuthWidget::setting(bool agentOwned) const
-{
- Q_D(const OpenVpnAuthWidget);
- Q_UNUSED(agentOwned)
-
- NMStringMap secrets;
- QVariantMap secretData;
- for (int i = 0; i < d->layout->rowCount() - 1; i++) {
- KLineEdit *le = qobject_cast<KLineEdit*>(d->layout->itemAt(i, QFormLayout::FieldRole)->widget());
- if (le && !le->text().isEmpty()) {
- const QString key = le->property("nm_secrets_key").toString();
- secrets.insert(key, le->text());
- }
- }
-
- secretData.insert("secrets", QVariant::fromValue<NMStringMap>(secrets));
- return secretData;
-}
-
-void OpenVpnAuthWidget::showPasswordsToggled(bool toggled)
-{
- Q_D(OpenVpnAuthWidget);
- for (int i = 0; i < d->layout->rowCount() - 1; i++) {
- KLineEdit *le = qobject_cast<KLineEdit*>(d->layout->itemAt(i, QFormLayout::FieldRole)->widget());
- if (le) {
- le->setPasswordMode(!toggled);
- }
- }
-}
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef OPENVPNAUTH_H
-#define OPENVPNAUTH_H
-
-#include <NetworkManagerQt/VpnSetting>
-
-#include "settingwidget.h"
-
-class OpenVpnAuthWidgetPrivate;
-
-class OpenVpnAuthWidget : public SettingWidget
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(OpenVpnAuthWidget)
-public:
- explicit OpenVpnAuthWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~OpenVpnAuthWidget();
- virtual void readSecrets();
- virtual QVariantMap setting(bool agentOwned = false) const;
-
-protected slots:
- void showPasswordsToggled(bool);
-
-private:
- OpenVpnAuthWidgetPrivate * d_ptr;
-};
-
-#endif // OPENVPNAUTH_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OpenVPNAuthenticationWidget</class>
- <widget class="QWidget" name="OpenVPNAuthenticationWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>429</width>
- <height>175</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>OpenVPNAuthentication</string>
- </property>
- <layout class="QGridLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="textLabel1">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <spacer name="spacer2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="1">
- <spacer name="spacer1">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="1">
- <widget class="KPasswordEdit" name="editUserPassword" native="true"/>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
- <customwidgets>
- <customwidget>
- <class>KPasswordEdit</class>
- <extends>QWidget</extends>
- <header>kpasswordedit.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2008 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "openvpnwidget.h"
-#include "openvpnadvancedwidget.h"
-
-#include <QDBusMetaType>
-
-#include <KDebug>
-#include <KProcess>
-#include <KStandardDirs>
-#include <KUrlRequester>
-#include <KLineEdit>
-
-#include "nm-openvpn-service.h"
-
-class OpenVpnSettingWidget::Private
-{
-public:
- Ui_OpenVPNProp ui;
- NetworkManager::VpnSetting::Ptr setting;
- class EnumConnectionType
- {
- public:
- enum ConnectionType {Certificates = 0, Psk, Password, CertsPassword};
- };
- class EnumKeyDirection
- {
- public:
- enum KeyDirection {None = 0, D0, D1};
- };
-};
-
-
-OpenVpnSettingWidget::OpenVpnSettingWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
- : SettingWidget(setting, parent), d(new Private)
-{
- qDBusRegisterMetaType<NMStringMap>();
-
- d->ui.setupUi(this);
- d->ui.x509CaFile->setMode(KFile::LocalOnly);
- d->ui.x509Cert->setMode(KFile::LocalOnly);
- d->ui.x509Key->setMode(KFile::LocalOnly);
- d->ui.passCaFile->setMode(KFile::LocalOnly);
- d->setting = setting;
-
- // use requesters' urlSelected signals to set other requester's startDirs to save clicking
- // around the filesystem
- QList<const KUrlRequester *> requesters;
- requesters << d->ui.x509CaFile << d->ui.x509Cert << d->ui.x509Key << d->ui.pskSharedKey << d->ui.passCaFile
- << d->ui.x509PassCaFile << d->ui.x509PassCert << d->ui.x509PassKey;
- foreach (const KUrlRequester * requester, requesters) {
- connect(requester, SIGNAL(urlSelected(KUrl)), this, SLOT(updateStartDir(KUrl)));
- }
-
- connect(d->ui.x509KeyPasswordStorage, SIGNAL(currentIndexChanged(int)), this, SLOT(x509KeyPasswordStorageChanged(int)));
- connect(d->ui.passPasswordStorage, SIGNAL(currentIndexChanged(int)), this, SLOT(passPasswordStorageChanged(int)));
- connect(d->ui.x509PassKeyPasswordStorage, SIGNAL(currentIndexChanged(int)), this, SLOT(x509PassKeyPasswordStorageChanged(int)));
- connect(d->ui.x509PassPasswordStorage, SIGNAL(currentIndexChanged(int)), this, SLOT(x509PassPasswordStorageChanged(int)));
- connect(d->ui.chkShowPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswordsToggled(bool)));
- connect(d->ui.btnAdvanced, SIGNAL(clicked()), SLOT(showAdvanced()));
-
- connect(d->ui.gateway, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (d->setting)
- loadConfig(d->setting);
-}
-
-OpenVpnSettingWidget::~OpenVpnSettingWidget()
-{
- delete d;
-}
-
-void OpenVpnSettingWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- Q_UNUSED(setting)
-
- // General settings
- const NMStringMap dataMap = d->setting->data();
- const QString cType = dataMap.value(NM_OPENVPN_KEY_CONNECTION_TYPE);
- const NMStringMap secrets = d->setting->secrets();
-
- if ( cType == QLatin1String( NM_OPENVPN_CONTYPE_PASSWORD_TLS ) ) {
- d->ui.cmbConnectionType->setCurrentIndex( Private::EnumConnectionType::CertsPassword);
- d->ui.x509PassUsername->setText( dataMap[NM_OPENVPN_KEY_USERNAME]);
- d->ui.x509PassCaFile->setUrl( KUrl(dataMap[NM_OPENVPN_KEY_CA]) );
- d->ui.x509PassCert->setUrl(KUrl( dataMap[NM_OPENVPN_KEY_CERT] ));
- d->ui.x509PassKey->setUrl(KUrl( dataMap[NM_OPENVPN_KEY_KEY] ));
- } else if ( cType == QLatin1String( NM_OPENVPN_CONTYPE_STATIC_KEY ) ) {
- d->ui.cmbConnectionType->setCurrentIndex( Private::EnumConnectionType::Psk );
- d->ui.pskSharedKey->setText( dataMap[NM_OPENVPN_KEY_STATIC_KEY]);
- if (dataMap.contains(NM_OPENVPN_KEY_STATIC_KEY_DIRECTION)) {
- switch (dataMap[NM_OPENVPN_KEY_STATIC_KEY_DIRECTION].toUInt())
- {
- case 0:
- d->ui.cmbKeyDirection->setCurrentIndex(Private::EnumKeyDirection::D0);
- break;
- case 1:
- d->ui.cmbKeyDirection->setCurrentIndex(Private::EnumKeyDirection::D1);
- break;
- }
- } else {
- d->ui.cmbKeyDirection->setCurrentIndex(Private::EnumKeyDirection::None);
- }
- d->ui.pskRemoteIp->setText( dataMap[NM_OPENVPN_KEY_REMOTE_IP]);
- d->ui.pskLocalIp->setText( dataMap[NM_OPENVPN_KEY_LOCAL_IP]);
- } else if ( cType == QLatin1String( NM_OPENVPN_CONTYPE_PASSWORD ) ) {
- d->ui.cmbConnectionType->setCurrentIndex( Private::EnumConnectionType::Password );
- d->ui.passUserName->setText( dataMap[NM_OPENVPN_KEY_USERNAME] );
- d->ui.passCaFile->setUrl(KUrl( dataMap[NM_OPENVPN_KEY_CA] ));
- } else if ( cType == QLatin1String( NM_OPENVPN_CONTYPE_TLS ) ) {
- d->ui.cmbConnectionType->setCurrentIndex( Private::EnumConnectionType::Certificates );
- d->ui.x509CaFile->setUrl(KUrl( dataMap[NM_OPENVPN_KEY_CA] ));
- d->ui.x509Cert->setUrl(KUrl( dataMap[NM_OPENVPN_KEY_CERT] ));
- d->ui.x509Key->setUrl(KUrl( dataMap[NM_OPENVPN_KEY_KEY] ));
- }
-
- d->ui.gateway->setText( dataMap[NM_OPENVPN_KEY_REMOTE] );
-
- NetworkManager::Setting::SecretFlags type;
-
- if (cType == QLatin1String(NM_OPENVPN_CONTYPE_TLS)) {
- type = (NetworkManager::Setting::SecretFlags)dataMap[NM_OPENVPN_KEY_CERTPASS"-flags"].toInt();
- if (!(type & NetworkManager::Setting::NotSaved || type & NetworkManager::Setting::NotRequired)) {
- d->ui.x509KeyPassword->setText(secrets.value(NM_OPENVPN_KEY_CERTPASS));
- }
- fillOnePasswordCombo(d->ui.x509KeyPasswordStorage, type);
- } else if (cType == QLatin1String(NM_OPENVPN_CONTYPE_PASSWORD)) {
- type = (NetworkManager::Setting::SecretFlags)dataMap[NM_OPENVPN_KEY_PASSWORD"-flags"].toInt();
- if (!(type & NetworkManager::Setting::NotSaved || type & NetworkManager::Setting::NotRequired)) {
- d->ui.passPassword->setText(secrets.value(NM_OPENVPN_KEY_PASSWORD));
- }
- fillOnePasswordCombo(d->ui.passPasswordStorage, type);
- } else if (cType == QLatin1String(NM_OPENVPN_CONTYPE_PASSWORD_TLS)) {
- type = (NetworkManager::Setting::SecretFlags)dataMap[NM_OPENVPN_KEY_PASSWORD"-flags"].toInt();
- if (!(type & NetworkManager::Setting::NotSaved || type & NetworkManager::Setting::NotRequired)) {
- d->ui.x509PassPassword->setText(secrets.value(NM_OPENVPN_KEY_PASSWORD));
- }
- fillOnePasswordCombo(d->ui.x509PassPasswordStorage, type);
-
- type = (NetworkManager::Setting::SecretFlags)dataMap[NM_OPENVPN_KEY_CERTPASS"-flags"].toInt();
- if (!(type & NetworkManager::Setting::NotSaved || type & NetworkManager::Setting::NotRequired)) {
- d->ui.x509PassKeyPassword->setText(secrets.value(NM_OPENVPN_KEY_CERTPASS));
- }
- fillOnePasswordCombo(d->ui.x509PassKeyPasswordStorage, type);
- }
-}
-
-QVariantMap OpenVpnSettingWidget::setting(bool agentOwned) const
-{
- NMStringMap data = d->setting->data();
- NMStringMap secretData = d->setting->secrets();
- NetworkManager::VpnSetting setting;
- setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_OPENVPN));
- // required settings
- data.insert(QLatin1String(NM_OPENVPN_KEY_REMOTE), d->ui.gateway->text());
-
- QString contype;
-
- switch ( d->ui.cmbConnectionType->currentIndex())
- {
- case Private::EnumConnectionType::Certificates:
- contype = QLatin1String(NM_OPENVPN_CONTYPE_TLS);
- kDebug() << "saving VPN TLS settings as urls:" << d->ui.x509CaFile->url().path() << d->ui.x509Cert->url().path() << d->ui.x509Key->url().path();
- data.insert(QLatin1String(NM_OPENVPN_KEY_CA), d->ui.x509CaFile->url().path());
- data.insert(QLatin1String(NM_OPENVPN_KEY_CERT), d->ui.x509Cert->url().path());
- data.insert(QLatin1String(NM_OPENVPN_KEY_KEY), d->ui.x509Key->url().path());
- // key password
- if (!d->ui.x509KeyPassword->text().isEmpty()) {
- secretData.insert(QLatin1String(NM_OPENVPN_KEY_CERTPASS), d->ui.x509KeyPassword->text());
- }
- handleOnePasswordType(d->ui.x509KeyPasswordStorage, QLatin1String(NM_OPENVPN_KEY_CERTPASS"-flags"), data, agentOwned);
- break;
- case Private::EnumConnectionType::Psk:
- contype = QLatin1String(NM_OPENVPN_CONTYPE_STATIC_KEY);
- data.insert(QLatin1String(NM_OPENVPN_KEY_STATIC_KEY), d->ui.pskSharedKey->url().path());
- switch (d->ui.cmbKeyDirection->currentIndex()) {
- case Private::EnumKeyDirection::None:
- break;
- case Private::EnumKeyDirection::D0:
- data.insert(QLatin1String(NM_OPENVPN_KEY_STATIC_KEY_DIRECTION), QString::number(0));
- break;
- case Private::EnumKeyDirection::D1:
- data.insert(QLatin1String(NM_OPENVPN_KEY_STATIC_KEY_DIRECTION), QString::number(1));
- break;
- }
- // ip addresses
- data.insert(QLatin1String(NM_OPENVPN_KEY_REMOTE_IP), d->ui.pskRemoteIp->text());
- data.insert(QLatin1String(NM_OPENVPN_KEY_LOCAL_IP), d->ui.pskLocalIp->text());
- break;
- case Private::EnumConnectionType::Password:
- contype = QLatin1String(NM_OPENVPN_CONTYPE_PASSWORD);
- // username
- if (!d->ui.passUserName->text().isEmpty()) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_USERNAME), d->ui.passUserName->text());
- }
- // password
- if (!d->ui.passPassword->text().isEmpty()) {
- secretData.insert(QLatin1String(NM_OPENVPN_KEY_PASSWORD ), d->ui.passPassword->text());
- }
- handleOnePasswordType(d->ui.passPasswordStorage, QLatin1String(NM_OPENVPN_KEY_PASSWORD"-flags"), data, agentOwned);
- // ca
- data.insert(QLatin1String(NM_OPENVPN_KEY_CA), d->ui.passCaFile->url().path());
- break;
- case Private::EnumConnectionType::CertsPassword:
- contype = QLatin1String(NM_OPENVPN_CONTYPE_PASSWORD_TLS);
- // username
- if (!d->ui.x509PassUsername->text().isEmpty()) {
- data.insert(QLatin1String(NM_OPENVPN_KEY_USERNAME), d->ui.x509PassUsername->text());
- }
- // ca
- data.insert(QLatin1String(NM_OPENVPN_KEY_CA), d->ui.x509PassCaFile->url().path());
- // cert
- data.insert(QLatin1String(NM_OPENVPN_KEY_CERT), d->ui.x509PassCert->url().path());
- // key file
- data.insert(QLatin1String(NM_OPENVPN_KEY_KEY), d->ui.x509PassKey->url().path());
- // key password
- if (!d->ui.x509PassKeyPassword->text().isEmpty()) {
- secretData.insert(QLatin1String(NM_OPENVPN_KEY_CERTPASS), d->ui.x509PassKeyPassword->text());
- }
- handleOnePasswordType(d->ui.x509PassKeyPasswordStorage, QLatin1String(NM_OPENVPN_KEY_CERTPASS"-flags"), data, agentOwned);
- // password
- if (!d->ui.x509PassPassword->text().isEmpty()) {
- secretData.insert(QLatin1String(NM_OPENVPN_KEY_PASSWORD), d->ui.x509PassPassword->text());
- }
- handleOnePasswordType(d->ui.x509PassPasswordStorage, QLatin1String(NM_OPENVPN_KEY_PASSWORD"-flags"), data, agentOwned);
- break;
- }
- data.insert(QLatin1String(NM_OPENVPN_KEY_CONNECTION_TYPE), contype);
-
- setting.setData(data);
- setting.setSecrets(secretData);
-
- return setting.toMap();
-}
-
-void OpenVpnSettingWidget::updateStartDir(const KUrl & url)
-{
- QList<KUrlRequester *> requesters;
- requesters << d->ui.x509CaFile << d->ui.x509Cert << d->ui.x509Key << d->ui.pskSharedKey << d->ui.passCaFile << d->ui.x509PassCaFile
- << d->ui.x509PassCert << d->ui.x509PassKey;
- foreach (KUrlRequester * requester, requesters) {
- requester->setStartDir(KUrl(url.directory()));
- }
-}
-
-void OpenVpnSettingWidget::x509KeyPasswordStorageChanged(int index)
-{
- setPasswordType(d->ui.x509KeyPassword, index);
-}
-
-void OpenVpnSettingWidget::passPasswordStorageChanged(int index)
-{
- setPasswordType(d->ui.passPassword, index);
-}
-
-void OpenVpnSettingWidget::x509PassKeyPasswordStorageChanged(int index)
-{
- setPasswordType(d->ui.x509PassKeyPassword, index);
-}
-
-void OpenVpnSettingWidget::x509PassPasswordStorageChanged(int index)
-{
- setPasswordType(d->ui.x509PassPassword, index);
-}
-
-void OpenVpnSettingWidget::setPasswordType(KLineEdit *edit, int type)
-{
- edit->setEnabled(type == SettingWidget::EnumPasswordStorageType::Store);
-}
-
-void OpenVpnSettingWidget::fillOnePasswordCombo(KComboBox * combo, NetworkManager::Setting::SecretFlags type)
-{
- if (type.testFlag(NetworkManager::Setting::AgentOwned) || type.testFlag(NetworkManager::Setting::None)) {
- combo->setCurrentIndex(SettingWidget::EnumPasswordStorageType::Store);
- } else if (type.testFlag(NetworkManager::Setting::NotRequired)) {
- combo->setCurrentIndex(SettingWidget::EnumPasswordStorageType::NotRequired);
- } else if (type.testFlag(NetworkManager::Setting::NotSaved)) {
- combo->setCurrentIndex(SettingWidget::EnumPasswordStorageType::AlwaysAsk);
- }
-}
-
-uint OpenVpnSettingWidget::handleOnePasswordType(const KComboBox * combo, const QString & key, NMStringMap &data, bool agentOwned) const
-{
- const uint type = combo->currentIndex();
- switch (type) {
- case SettingWidget::EnumPasswordStorageType::AlwaysAsk:
- data.insert(key, QString::number(NetworkManager::Setting::NotSaved));
- break;
- case SettingWidget::EnumPasswordStorageType::Store:
- if (agentOwned)
- data.insert(key, QString::number(NetworkManager::Setting::AgentOwned));
- else
- data.insert(key, QString::number(NetworkManager::Setting::None));
- break;
- case SettingWidget::EnumPasswordStorageType::NotRequired:
- data.insert(key, QString::number(NetworkManager::Setting::NotRequired));
- break;
- }
- return type;
-}
-
-void OpenVpnSettingWidget::showPasswordsToggled(bool toggled)
-{
- d->ui.x509KeyPassword->setPasswordMode(!toggled);
- d->ui.passPassword->setPasswordMode(!toggled);
- d->ui.x509PassKeyPassword->setPasswordMode(!toggled);
- d->ui.x509PassPassword->setPasswordMode(!toggled);
-}
-
-void OpenVpnSettingWidget::showAdvanced()
-{
- QPointer<OpenVpnAdvancedWidget> adv = new OpenVpnAdvancedWidget(d->setting, this);
- adv->init();
- if (adv->exec() == QDialog::Accepted) {
- NetworkManager::VpnSetting::Ptr advData = adv->setting();
- if (!advData.isNull()) {
- d->setting->setData(advData->data());
- d->setting->setSecrets(advData->secrets());
- }
- }
-
- if (adv) {
- adv->deleteLater();
- }
-}
-
-bool OpenVpnSettingWidget::isValid() const
-{
- return !d->ui.gateway->text().isEmpty();
-}
+++ /dev/null
-/*
- Copyright 2008 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef OPENVPNWIDGET_H
-#define OPENVPNWIDGET_H
-
-#include "settingwidget.h"
-
-#include <QProcess>
-
-#include "ui_openvpn.h"
-
-#include <NetworkManagerQt/VpnSetting>
-
-class KUrl;
-class KLineEdit;
-class KComboBox;
-
-class OpenVpnSettingWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit OpenVpnSettingWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~OpenVpnSettingWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void updateStartDir(const KUrl &);
- void x509KeyPasswordStorageChanged(int);
- void passPasswordStorageChanged(int);
- void x509PassKeyPasswordStorageChanged(int);
- void x509PassPasswordStorageChanged(int);
- void showPasswordsToggled(bool);
- void showAdvanced();
-
-private:
- class Private;
- Private * d;
- void setPasswordType(KLineEdit *, int);
- void fillOnePasswordCombo(KComboBox *, NetworkManager::Setting::SecretFlags);
- uint handleOnePasswordType(const KComboBox *, const QString &, NMStringMap &, bool agentOwned) const;
-};
-
-#endif // OPENVPNWIDGET_H
+++ /dev/null
-[Desktop Entry]
-Type=Service
-Icon=
-ServiceTypes=PlasmaNetworkManagement/VpnUiPlugin
-X-KDE-Library=plasmanetworkmanagement_openvpnui
-X-NetworkManager-Services=org.freedesktop.NetworkManager.openvpn
-X-KDE-PluginInfo-Author=Lukáš Tinkl
-X-KDE-PluginInfo-Email=lukas@kde.org
-X-KDE-PluginInfo-Name=plasmanetworkmanagement_openvpnui
-X-KDE-PluginInfo-Version=0.1
-X-KDE-PluginInfo-Website=
-X-KDE-PluginInfo-Category=VPNService
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=false
-Name=OpenVPN
-Name[bg]=OpenVPN
-Name[bs]=OpenVPN
-Name[ca]=OpenVPN
-Name[ca@valencia]=OpenVPN
-Name[cs]=OpenVPN
-Name[da]=OpenVPN
-Name[de]=OpenVPN
-Name[el]=OpenVPN
-Name[en_GB]=OpenVPN
-Name[es]=OpenVPN
-Name[et]=OpenVPN
-Name[fi]=OpenVPN
-Name[fr]=OpenVPN
-Name[hu]=OpenVPN
-Name[it]=OpenVPN
-Name[ko]=OpenVPN
-Name[lt]=OpenVPN
-Name[nb]=OpenVPN
-Name[nds]=OpenVPN
-Name[nl]=OpenVPN
-Name[pl]=OpenVPN
-Name[pt]=OpenVPN
-Name[pt_BR]=OpenVPN
-Name[ro]=OpenVPN
-Name[ru]=OpenVPN
-Name[sk]=OpenVPN
-Name[sl]=OpenVPN
-Name[sv]=OpenVPN
-Name[tr]=OpenVPN
-Name[ug]=OpenVPN
-Name[uk]=OpenVPN
-Name[x-test]=xxOpenVPNxx
-Name[zh_CN]=OpenVPN
-Comment=OpenVPN plugin
-Comment[bg]=Приставка за OpenVPN
-Comment[bs]=OpenVPN priključak
-Comment[ca]=Connector d'OpenVPN
-Comment[ca@valencia]=Connector d'OpenVPN
-Comment[cs]=Modul OpenVPN
-Comment[da]=OpenVPN-plugin
-Comment[de]=OpenVPN-Modul
-Comment[el]=Πρόσθετο OpenVPN
-Comment[en_GB]=OpenVPN plugin
-Comment[es]=Complemento OpenVPN
-Comment[et]=OpenVPN-i plugin
-Comment[fi]=OpenVPN-liitännäinen
-Comment[fr]=Module externe OpenVPN
-Comment[hu]=OpenVPN bővítmény
-Comment[it]=Estensione OpenVPN
-Comment[ko]=OpenVPN 플러그인
-Comment[lt]=OpenVPN papildinys
-Comment[nb]=OpenVPN programtillegg
-Comment[nds]=OpenVPN-Moduul
-Comment[nl]=OpenVPN-plug-in
-Comment[pl]=Wtyczka OpenVPN
-Comment[pt]='Plugin' do OpenVPN
-Comment[pt_BR]=Plugin do OpenVPN
-Comment[ro]=Extensie OpenVPN
-Comment[ru]=Модуль OpenVPN
-Comment[sk]=OpenVPN plugin
-Comment[sl]=Vstavek OpenVPN
-Comment[sv]=Insticksprogram för OpenVPN
-Comment[tr]=OpenVPN eklentisi
-Comment[ug]=OpenVPN قىستۇرمىسى
-Comment[uk]=Додаток OpenVPN
-Comment[x-test]=xxOpenVPN pluginxx
-Comment[zh_CN]=OpenVPN 插件
-
+++ /dev/null
-set(pptp_SRCS
- pptp.cpp
- pptpwidget.cpp
- pptpauth.cpp
- pptpprop.ui
- pptpadvanced.ui
- pptpauth.ui
-)
-
-kde4_add_plugin(plasmanetworkmanagement_pptpui ${pptp_SRCS})
-
-target_link_libraries(plasmanetworkmanagement_pptpui ${NETWORKMANAGERQT_LDFLAGS} ${KDE4_KIO_LIBS} plasmanetworkmanagement-editor)
-
-install(TARGETS plasmanetworkmanagement_pptpui DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install( FILES plasmanetworkmanagement_pptpui.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
-$XGETTEXT `find . -name "*.cpp"` -o $podir/plasmanetworkmanagement_pptpui.pot
-rm -f rc.cpp
+++ /dev/null
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* nm-pptp-service - PPTP VPN integration with NetworkManager
- *
- * Dan Williams <dcbw@redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This 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.
- *
- * (C) Copyright 2008 Red Hat, Inc. //krazy:exclude=copyright
- */
-
-#ifndef NM_PPTP_SERVICE_H
-#define NM_PPTP_SERVICE_H
-
-#define NM_DBUS_SERVICE_PPTP_PPP "org.freedesktop.NetworkManager.pptp-ppp"
-#define NM_DBUS_PATH_PPTP_PPP "/org/freedesktop/NetworkManager/pptp/ppp"
-#define NM_DBUS_INTERFACE_PPTP_PPP "org.freedesktop.NetworkManager.pptp.ppp"
-
-
-/* For the NM <-> VPN plugin service */
-#define NM_DBUS_SERVICE_PPTP "org.freedesktop.NetworkManager.pptp"
-#define NM_DBUS_INTERFACE_PPTP "org.freedesktop.NetworkManager.pptp"
-#define NM_DBUS_PATH_PPTP "/org/freedesktop/NetworkManager/pptp"
-
-#define NM_PPTP_KEY_GATEWAY "gateway"
-#define NM_PPTP_KEY_USER "user"
-#define NM_PPTP_KEY_PASSWORD "password"
-#define NM_PPTP_KEY_DOMAIN "domain"
-#define NM_PPTP_KEY_REFUSE_EAP "refuse-eap"
-#define NM_PPTP_KEY_REFUSE_PAP "refuse-pap"
-#define NM_PPTP_KEY_REFUSE_CHAP "refuse-chap"
-#define NM_PPTP_KEY_REFUSE_MSCHAP "refuse-mschap"
-#define NM_PPTP_KEY_REFUSE_MSCHAPV2 "refuse-mschapv2"
-#define NM_PPTP_KEY_REQUIRE_MPPE "require-mppe"
-#define NM_PPTP_KEY_REQUIRE_MPPE_40 "require-mppe-40"
-#define NM_PPTP_KEY_REQUIRE_MPPE_128 "require-mppe-128"
-#define NM_PPTP_KEY_MPPE_STATEFUL "mppe-stateful"
-#define NM_PPTP_KEY_NOBSDCOMP "nobsdcomp"
-#define NM_PPTP_KEY_NODEFLATE "nodeflate"
-#define NM_PPTP_KEY_NO_VJ_COMP "no-vj-comp"
-#define NM_PPTP_KEY_LCP_ECHO_FAILURE "lcp-echo-failure"
-#define NM_PPTP_KEY_LCP_ECHO_INTERVAL "lcp-echo-interval"
-
-
-#endif /* NM_PPTP_PLUGIN_H */
+++ /dev/null
-[Desktop Entry]
-Type=Service
-Icon=
-ServiceTypes=PlasmaNetworkManagement/VpnUiPlugin
-X-KDE-Library=plasmanetworkmanagement_pptpui
-X-NetworkManager-Services=org.freedesktop.NetworkManager.pptp
-X-KDE-PluginInfo-Author=Lukáš Tinkl
-X-KDE-PluginInfo-Email=ltinkl@redhat.com
-X-KDE-PluginInfo-Name=plasmanetworkmanagement_pptpui
-X-KDE-PluginInfo-Version=0.1
-X-KDE-PluginInfo-Website=
-X-KDE-PluginInfo-Category=VPNService
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=false
-Name=PPTP
-Name[bg]=PPTP
-Name[bs]=PPTP
-Name[ca]=PPTP
-Name[ca@valencia]=PPTP
-Name[cs]=PPTP
-Name[da]=PPTP
-Name[de]=PPTP
-Name[el]=PPTP
-Name[en_GB]=PPTP
-Name[es]=PPTP
-Name[et]=PPTP
-Name[fi]=PPTP
-Name[fr]=PPTP
-Name[hu]=PPTP
-Name[it]=PPTP
-Name[ko]=PPTP
-Name[lt]=PPTP
-Name[nb]=PPTP
-Name[nds]=PPTP
-Name[nl]=PPTP
-Name[pl]=PPTP
-Name[pt]=PPTP
-Name[pt_BR]=PPTP
-Name[ro]=PPTP
-Name[ru]=PPTP
-Name[sk]=PPTP
-Name[sl]=PPTP
-Name[sv]=PPTP
-Name[tr]=PPTP
-Name[ug]=PPTP
-Name[uk]=PPTP
-Name[x-test]=xxPPTPxx
-Name[zh_CN]=PPTP
-Comment=PPTP Plugin
-Comment[bg]=Приставка за PPTP
-Comment[bs]=PPTP Dodatak
-Comment[ca]=Connector de PPTP
-Comment[ca@valencia]=Connector de PPTP
-Comment[cs]=Modul PPTP
-Comment[da]=PPTP-plugin
-Comment[de]=PPTP-Modul
-Comment[el]=Πρόσθετο PPTP
-Comment[en_GB]=PPTP Plugin
-Comment[es]=Complemento PPTP
-Comment[et]=PPTP plugin
-Comment[fi]=PPTP-liitännäinen
-Comment[fr]=Module externe PPTP
-Comment[hu]=PPTP bővítmény
-Comment[it]=Estensione PPTP
-Comment[ko]=PPTP 플러그인
-Comment[lt]=PPTP papildinys
-Comment[nb]=PPTP programtillegg
-Comment[nds]=PPTP-Moduul
-Comment[nl]=PPTP-plug-in
-Comment[pl]=Wtyczka PPTP
-Comment[pt]='Plugin' de PPTP
-Comment[pt_BR]=Plugin de PPTP
-Comment[ro]=Modul PPTP
-Comment[ru]=Модуль PPTP
-Comment[sk]=PPTP modul
-Comment[sl]=Vstavek PPTP
-Comment[sv]=Insticksprogram för PPTP
-Comment[tr]=PPTP Eklentisi
-Comment[ug]=PPTP قىستۇرمىسى
-Comment[uk]=Додаток PPTP
-Comment[x-test]=xxPPTP Pluginxx
-Comment[zh_CN]=PPTP 插件
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "pptp.h"
-
-#include <KPluginFactory>
-
-#include "pptpwidget.h"
-#include "pptpauth.h"
-
-K_PLUGIN_FACTORY(PptpUiPluginFactory, registerPlugin<PptpUiPlugin>();)
-K_EXPORT_PLUGIN(PptpUiPluginFactory("plasmanetworkmanagement_pptpui"))
-
-PptpUiPlugin::PptpUiPlugin(QObject * parent, const QVariantList &) : VpnUiPlugin(parent)
-{
-
-}
-
-PptpUiPlugin::~PptpUiPlugin()
-{
-
-}
-
-SettingWidget * PptpUiPlugin::widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new PptpSettingWidget(setting, parent);
-}
-
-SettingWidget * PptpUiPlugin::askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new PptpAuthWidget(setting, parent);
-}
-
-
-QString PptpUiPlugin::suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const
-{
- Q_UNUSED(connection);
- return QString();
-}
-
-QString PptpUiPlugin::supportedFileExtensions() const
-{
- return QString();
-}
-
-NMVariantMapMap PptpUiPlugin::importConnectionSettings(const QString &fileName)
-{
- Q_UNUSED(fileName);
-
- // TODO : import the Openconnect connection from file and return settings
- mError = VpnUiPlugin::NotImplemented;
- return NMVariantMapMap();
-}
-
-bool PptpUiPlugin::exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName)
-{
- Q_UNUSED(connection);
- Q_UNUSED(fileName);
-
- // TODO : export Openconnect connection to file
- mError = VpnUiPlugin::NotImplemented;
- return false;
-}
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_PPTP_H
-#define PLASMA_NM_PPTP_H
-
-#include "vpnuiplugin.h"
-
-#include <QVariant>
-
-class PptpUiPlugin : public VpnUiPlugin
-{
-Q_OBJECT
-public:
- explicit PptpUiPlugin(QObject * parent = 0, const QVariantList& = QVariantList());
- virtual ~PptpUiPlugin();
- virtual SettingWidget * widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- virtual SettingWidget * askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
-
- QString suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const;
- QString supportedFileExtensions() const;
- NMVariantMapMap importConnectionSettings(const QString &fileName);
- bool exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName);
-};
-
-#endif // PLASMA_NM_PPTP_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PptpAdvanced</class>
- <widget class="QWidget" name="PptpAdvanced">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>376</width>
- <height>479</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <widget class="QGroupBox" name="grp_authenfication">
- <property name="title">
- <string>Authentication</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="lbl_auth">
- <property name="text">
- <string>Allow following authentication methods:</string>
- </property>
- <property name="buddy">
- <cstring>listWidget</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QListWidget" name="listWidget">
- <item>
- <property name="text">
- <string>PAP</string>
- </property>
- <property name="checkState">
- <enum>Checked</enum>
- </property>
- </item>
- <item>
- <property name="text">
- <string>CHAP</string>
- </property>
- <property name="checkState">
- <enum>Checked</enum>
- </property>
- </item>
- <item>
- <property name="text">
- <string>MSCHAP</string>
- </property>
- <property name="checkState">
- <enum>Checked</enum>
- </property>
- </item>
- <item>
- <property name="text">
- <string>MSCHAPv2</string>
- </property>
- <property name="checkState">
- <enum>Checked</enum>
- </property>
- </item>
- <item>
- <property name="text">
- <string>EAP</string>
- </property>
- <property name="checkState">
- <enum>Checked</enum>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="gb_MPPE">
- <property name="toolTip">
- <string>Use Microsoft Point-to-Point Encryption</string>
- </property>
- <property name="title">
- <string>Use MPPE Encryption</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <layout class="QFormLayout" name="formLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="lbl_MMPEcrypto">
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Crypto:</string>
- </property>
- <property name="buddy">
- <cstring>cb_MPPECrypto</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="cb_MPPECrypto">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string comment="like in use Any configuration">Any</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>128 bit</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>40 bit</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QCheckBox" name="cb_statefulEncryption">
- <property name="text">
- <string>Use stateful encryption</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="grp_cryptoAndCompression">
- <property name="title">
- <string>Compression</string>
- </property>
- <layout class="QFormLayout" name="formLayout_3">
- <property name="labelAlignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <item row="0" column="0">
- <widget class="QCheckBox" name="cb_BSD">
- <property name="text">
- <string>Allow BSD compression</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="cb_deflate">
- <property name="text">
- <string>Allow Deflate compression</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="cb_TCPheaders">
- <property name="text">
- <string>Allow TCP header compression</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="grp_echo">
- <property name="title">
- <string>Echo</string>
- </property>
- <layout class="QFormLayout" name="formLayout_4">
- <item row="0" column="0">
- <widget class="QCheckBox" name="cb_sendEcho">
- <property name="text">
- <string>Send PPP echo packets </string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- <zorder>grp_authenfication</zorder>
- <zorder>grp_echo</zorder>
- <zorder>grp_cryptoAndCompression</zorder>
- <zorder>gb_MPPE</zorder>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>listWidget</tabstop>
- <tabstop>gb_MPPE</tabstop>
- <tabstop>cb_MPPECrypto</tabstop>
- <tabstop>cb_statefulEncryption</tabstop>
- <tabstop>cb_BSD</tabstop>
- <tabstop>cb_deflate</tabstop>
- <tabstop>cb_TCPheaders</tabstop>
- <tabstop>cb_sendEcho</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "pptpauth.h"
-#include "ui_pptpauth.h"
-
-#include "nm-pptp-service.h"
-
-class PptpAuthWidgetPrivate
-{
-public:
- NetworkManager::VpnSetting::Ptr setting;
- Ui_PptpAuthenticationWidget ui;
-};
-
-PptpAuthWidget::PptpAuthWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-: SettingWidget(setting, parent), d_ptr(new PptpAuthWidgetPrivate)
-{
- Q_D(PptpAuthWidget);
- d->setting = setting;
- d->ui.setupUi(this);
- connect(d->ui.chkShowPassword, SIGNAL(toggled(bool)), this, SLOT(showPasswordsToggled(bool)));
-
- KAcceleratorManager::manage(this);
-}
-
-PptpAuthWidget::~PptpAuthWidget()
-{
- delete d_ptr;
-}
-
-QVariantMap PptpAuthWidget::setting(bool agentOwned) const
-{
- Q_D(const PptpAuthWidget);
- Q_UNUSED(agentOwned)
-
- NMStringMap secrets;
- QVariantMap secretData;
-
- if (!d->ui.lePassword->text().isEmpty()) {
- secrets.insert(QLatin1String(NM_PPTP_KEY_PASSWORD), d->ui.lePassword->text());
- }
-
- secretData.insert("secrets", QVariant::fromValue<NMStringMap>(secrets));
- return secretData;
-}
-
-void PptpAuthWidget::showPasswordsToggled(bool toggled)
-{
- Q_D(PptpAuthWidget);
- d->ui.lePassword->setPasswordMode(!toggled);
-}
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PPTPAUTH_H
-#define PPTPAUTH_H
-
-#include <NetworkManagerQt/VpnSetting>
-
-#include "settingwidget.h"
-
-class PptpAuthWidgetPrivate;
-
-class PptpAuthWidget : public SettingWidget
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(PptpAuthWidget)
-public:
- explicit PptpAuthWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~PptpAuthWidget();
-
- virtual QVariantMap setting(bool agentOwned = false) const;
-
-private slots:
- void showPasswordsToggled(bool);
-
-private:
- PptpAuthWidgetPrivate * d_ptr;
-};
-
-#endif // PPTPAUTH_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PptpAuthenticationWidget</class>
- <widget class="QWidget" name="PptpAuthenticationWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>372</width>
- <height>85</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>PPTPAuthentication</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <property name="sizeConstraint">
- <enum>QLayout::SetMinimumSize</enum>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="textLabel1">
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>lePassword</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QCheckBox" name="chkShowPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="lePassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>lePassword</tabstop>
- <tabstop>chkShowPassword</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PptpProp</class>
- <widget class="QWidget" name="PptpProp">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>361</width>
- <height>341</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>PPTP Settings</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QGroupBox" name="grp_general">
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>100</height>
- </size>
- </property>
- <property name="title">
- <string comment="like in General settings">General</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="lbl_gateway">
- <property name="text">
- <string>Gateway:</string>
- </property>
- <property name="buddy">
- <cstring>edt_gateway</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KLineEdit" name="edt_gateway"/>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="grp_additional">
- <property name="title">
- <string comment="like in Additional settings">Additional</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_4">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QLabel" name="lbl_login">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>90</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>Login:</string>
- </property>
- <property name="buddy">
- <cstring>edt_login</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KLineEdit" name="edt_login"/>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="QLabel" name="lbl_password">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>90</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>Password:</string>
- </property>
- <property name="buddy">
- <cstring>edt_password</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KLineEdit" name="edt_password">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="cmbPasswordStorage">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QCheckBox" name="cb_showPassword">
- <property name="text">
- <string>Show password</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_6">
- <item>
- <widget class="QLabel" name="lbl_ntdomain">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>90</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>NT Domain:</string>
- </property>
- <property name="buddy">
- <cstring>edt_ntDomain</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KLineEdit" name="edt_ntDomain"/>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_7">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="btnAdvanced">
- <property name="text">
- <string comment="like in Advanced settings">Advanced...</string>
- </property>
- <property name="flat">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>edt_gateway</tabstop>
- <tabstop>edt_login</tabstop>
- <tabstop>edt_password</tabstop>
- <tabstop>cmbPasswordStorage</tabstop>
- <tabstop>cb_showPassword</tabstop>
- <tabstop>edt_ntDomain</tabstop>
- <tabstop>btnAdvanced</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2009 Pavel Andreev <apavelm@gmail.com>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "pptpwidget.h"
-#include <KDialog>
-
-#include "ui_pptpprop.h"
-#include "ui_pptpadvanced.h"
-
-#include <QString>
-#include "nm-pptp-service.h"
-
-class PptpSettingWidgetPrivate
-{
-public:
- Ui_PptpProp ui;
- Ui_PptpAdvanced advUi;
- NetworkManager::VpnSetting::Ptr setting;
- KDialog * advancedDlg;
- QWidget * advancedWid;
-};
-
-PptpSettingWidget::PptpSettingWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
- : SettingWidget(setting, parent), d_ptr(new PptpSettingWidgetPrivate)
-{
- Q_D(PptpSettingWidget);
- d->ui.setupUi(this);
-
- d->setting = setting;
-
- connect(d->ui.btnAdvanced, SIGNAL(clicked()), this, SLOT(doAdvancedDialog()));
- connect (d->ui.cmbPasswordStorage, SIGNAL(currentIndexChanged(int)), this, SLOT(passwordTypeChanged(int)));
- connect(d->ui.cb_showPassword, SIGNAL(toggled(bool)), this, SLOT(setShowPassword(bool)));
- d->advancedDlg = new KDialog(this);
- d->advancedWid = new QWidget(this);
- d->advUi.setupUi(d->advancedWid);
- d->advancedDlg->setMainWidget(d->advancedWid);
-
- connect(d->ui.edt_gateway, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (d->setting)
- loadConfig(d->setting);
-}
-
-PptpSettingWidget::~PptpSettingWidget()
-{
- delete d_ptr;
-}
-
-void PptpSettingWidget::passwordTypeChanged(int index)
-{
- Q_D(PptpSettingWidget);
- d->ui.edt_password->setEnabled(index == SettingWidget::EnumPasswordStorageType::Store);
-}
-
-void PptpSettingWidget::setShowPassword(bool show)
-{
- Q_D(PptpSettingWidget);
- d->ui.edt_password->setPasswordMode(!show);
-}
-
-void PptpSettingWidget::doAdvancedDialog()
-{
- Q_D(PptpSettingWidget);
- d->advancedDlg->exec();
-}
-
-void PptpSettingWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- Q_D(PptpSettingWidget);
- Q_UNUSED(setting)
-
- // General settings
- const NMStringMap dataMap = d->setting->data();
- const NMStringMap secrets = d->setting->secrets();
-
- // Authentication
- const QString sGateway = dataMap[NM_PPTP_KEY_GATEWAY];
- if (!sGateway.isEmpty())
- {
- d->ui.edt_gateway->setText(sGateway);
- }
-
- const QString sLogin = dataMap[NM_PPTP_KEY_USER];
- if (!sLogin.isEmpty())
- {
- d->ui.edt_login->setText(sLogin);
- }
-
- const QString sPassword = secrets[NM_PPTP_KEY_PASSWORD];
- if (!sPassword.isEmpty()) {
- d->ui.edt_password->setText(sPassword);
- }
-
- const QString sDomain = dataMap[NM_PPTP_KEY_DOMAIN];
- if (!sDomain.isEmpty())
- {
- d->ui.edt_ntDomain->setText(sDomain);
- }
-
- // Options below is belongs to "Advanced" dialog
-
- // Authentication options
- const QString yesString = QLatin1String("yes");
- bool refuse_pap = (dataMap[NM_PPTP_KEY_REFUSE_PAP] == yesString);
- bool refuse_chap = (dataMap[NM_PPTP_KEY_REFUSE_CHAP] == yesString);
- bool refuse_mschap = (dataMap[NM_PPTP_KEY_REFUSE_MSCHAP] == yesString);
- bool refuse_mschapv2 = (dataMap[NM_PPTP_KEY_REFUSE_MSCHAPV2] == yesString);
- bool refuse_eap = (dataMap[NM_PPTP_KEY_REFUSE_EAP] == yesString);
-
- QListWidgetItem * item = 0;
- item = d->advUi.listWidget->item(0); // PAP
- item->setCheckState(refuse_pap ? Qt::Unchecked : Qt::Checked);
- item = d->advUi.listWidget->item(1); // CHAP
- item->setCheckState(refuse_chap ? Qt::Unchecked : Qt::Checked);
- item = d->advUi.listWidget->item(2); // MSCHAP
- item->setCheckState(refuse_mschap ? Qt::Unchecked : Qt::Checked);
- item = d->advUi.listWidget->item(3); // MSCHAPv2
- item->setCheckState(refuse_mschapv2 ? Qt::Unchecked : Qt::Checked);
- item = d->advUi.listWidget->item(4); // EAP
- item->setCheckState(refuse_eap ? Qt::Unchecked : Qt::Checked);
-
- // Cryptography and compression
- const bool mppe = (dataMap[NM_PPTP_KEY_REQUIRE_MPPE] == yesString);
- const bool mppe40 = (dataMap[NM_PPTP_KEY_REQUIRE_MPPE_40] == yesString);
- const bool mppe128 = (dataMap[NM_PPTP_KEY_REQUIRE_MPPE_128] == yesString);
- const bool mppe_stateful = (dataMap[NM_PPTP_KEY_MPPE_STATEFUL] == yesString);
-
- if (mppe || mppe40 || mppe128) { // If MPPE is use
- d->advUi.gb_MPPE->setChecked(mppe || mppe40 || mppe128);
- if (mppe128) {
- d->advUi.cb_MPPECrypto->setCurrentIndex(1); // 128 bit
- }
- else if (mppe40) {
- d->advUi.cb_MPPECrypto->setCurrentIndex(2); // 40 bit
- }
- else {
- d->advUi.cb_MPPECrypto->setCurrentIndex(0); // Any
- }
- d->advUi.cb_statefulEncryption->setChecked(mppe_stateful);
- }
-
- const bool nobsd = (dataMap[NM_PPTP_KEY_NOBSDCOMP] == yesString);
- d->advUi.cb_BSD->setChecked(!nobsd);
-
- const bool nodeflate = (dataMap[NM_PPTP_KEY_NODEFLATE] == yesString);
- d->advUi.cb_deflate->setChecked(!nodeflate);
-
- const bool novjcomp = (dataMap[NM_PPTP_KEY_NO_VJ_COMP] == yesString);
- d->advUi.cb_TCPheaders->setChecked(!novjcomp);
-
- // Echo
- const int lcp_echo_interval = QString(dataMap[NM_PPTP_KEY_LCP_ECHO_INTERVAL]).toInt();
- d->advUi.cb_sendEcho->setChecked(lcp_echo_interval > 0);
-
- // secrets
- const NetworkManager::Setting::SecretFlags type = (NetworkManager::Setting::SecretFlags)dataMap[NM_PPTP_KEY_PASSWORD"-flags"].toInt();
- if (type & NetworkManager::Setting::AgentOwned || type & NetworkManager::Setting::None || !type) {
- d->ui.edt_password->setText(secrets.value(QLatin1String(NM_PPTP_KEY_PASSWORD)));
- }
- fillOnePasswordCombo(d->ui.cmbPasswordStorage, type);
-}
-
-QVariantMap PptpSettingWidget::setting(bool agentOwned) const
-{
- Q_D(const PptpSettingWidget);
-
- NetworkManager::VpnSetting setting;
- setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_PPTP));
-
- // save the main dialog's data in the setting
- // if the advanced dialog is dirty, save its data in the vpn setting too
- //
- NMStringMap data;
- NMStringMap secretData;
-
- data.insert(NM_PPTP_KEY_GATEWAY, d->ui.edt_gateway->text());
- data.insert(NM_PPTP_KEY_USER, d->ui.edt_login->text());
- if (!d->ui.edt_password->text().isEmpty()) {
- secretData.insert(QLatin1String(NM_PPTP_KEY_PASSWORD), d->ui.edt_password->text());
- }
- handleOnePasswordType(d->ui.cmbPasswordStorage, NM_PPTP_KEY_PASSWORD"-flags", data, agentOwned);
- if (!d->ui.edt_ntDomain->text().isEmpty()) {
- data.insert(NM_PPTP_KEY_DOMAIN, d->ui.edt_ntDomain->text());
- }
-
- // Advanced dialog settings
-
- // Authenfication options
- QListWidgetItem * item = 0;
- item = d->advUi.listWidget->item(0); // PAP
- const QString yesString = QLatin1String("yes");
- if (item->checkState() == Qt::Unchecked)
- data.insert(NM_PPTP_KEY_REFUSE_PAP, yesString);
- item = d->advUi.listWidget->item(1); // CHAP
- if (item->checkState() == Qt::Unchecked)
- data.insert(NM_PPTP_KEY_REFUSE_CHAP, yesString);
- item = d->advUi.listWidget->item(2); // MSCHAP
- if (item->checkState() == Qt::Unchecked)
- data.insert(NM_PPTP_KEY_REFUSE_MSCHAP, yesString);
- item = d->advUi.listWidget->item(3); // MSCHAPv2
- if (item->checkState() == Qt::Unchecked)
- data.insert(NM_PPTP_KEY_REFUSE_MSCHAPV2, yesString);
- item = d->advUi.listWidget->item(4); // EAP
- if (item->checkState() == Qt::Unchecked)
- data.insert(NM_PPTP_KEY_REFUSE_EAP, yesString);
-
- // Cryptography and compression
- if (d->advUi.gb_MPPE->isChecked())
- {
- int index = d->advUi.cb_MPPECrypto->currentIndex();
-
- switch (index)
- {
- case 0:
- {
- // "Any"
- data.insert(NM_PPTP_KEY_REQUIRE_MPPE, yesString);
- }
- break;
- case 1:
- {
- // "128 bit"
- data.insert(NM_PPTP_KEY_REQUIRE_MPPE_128, yesString);
- }
- break;
- case 2:
- {
- // "40 bit"
- data.insert(NM_PPTP_KEY_REQUIRE_MPPE_40, yesString);
- }
- break;
- }
-
- if (d->advUi.cb_statefulEncryption->isChecked()) {
- data.insert(NM_PPTP_KEY_MPPE_STATEFUL, yesString);
- }
- }
-
- if (!d->advUi.cb_BSD->isChecked()) {
- data.insert(NM_PPTP_KEY_NOBSDCOMP, yesString);
-
- }
- if (!d->advUi.cb_deflate->isChecked()) {
- data.insert(NM_PPTP_KEY_NODEFLATE, yesString);
- }
-
- if (!d->advUi.cb_TCPheaders->isChecked()) {
- data.insert(NM_PPTP_KEY_NO_VJ_COMP, yesString);
- }
- // Echo
- if (d->advUi.cb_sendEcho->isChecked()) {
- data.insert(NM_PPTP_KEY_LCP_ECHO_FAILURE, "5");
- data.insert(NM_PPTP_KEY_LCP_ECHO_INTERVAL, "30");
- }
-
- // save it all
- setting.setData(data);
- setting.setSecrets(secretData);
-
- return setting.toMap();
-}
-
-void PptpSettingWidget::fillOnePasswordCombo(KComboBox * combo, NetworkManager::Setting::SecretFlags type)
-{
- if (type.testFlag(NetworkManager::Setting::AgentOwned) || type.testFlag(NetworkManager::Setting::None)) { // store
- combo->setCurrentIndex(0);
- } else if (type.testFlag(NetworkManager::Setting::NotRequired)) { // not required
- combo->setCurrentIndex(2);
- } else if (type.testFlag(NetworkManager::Setting::NotSaved)) { // always ask
- combo->setCurrentIndex(1);
- }
-}
-
-uint PptpSettingWidget::handleOnePasswordType(const KComboBox * combo, const QString & key, NMStringMap & data, bool agentOwned) const
-{
- const uint type = combo->currentIndex();
- switch (type) {
- case 1:
- data.insert(key, QString::number(NetworkManager::Setting::NotSaved)); // always ask
- break;
- case 0:
- if (agentOwned)
- data.insert(key, QString::number(NetworkManager::Setting::AgentOwned)); // store
- else
- data.insert(key, QString::number(NetworkManager::Setting::None));
- break;
- case 2:
- data.insert(key, QString::number(NetworkManager::Setting::NotRequired)); // not required
- break;
- }
- return type;
-}
-
-bool PptpSettingWidget::isValid() const
-{
- Q_D(const PptpSettingWidget);
-
- return !d->ui.edt_gateway->text().isEmpty();
-}
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 Lukáš Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PPTPWIDGET_H
-#define PPTPWIDGET_H
-
-#include "settingwidget.h"
-
-#include <NetworkManagerQt/VpnSetting>
-
-class KComboBox;
-class PptpSettingWidgetPrivate;
-
-class PptpSettingWidget : public SettingWidget
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(PptpSettingWidget)
-public:
- explicit PptpSettingWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~PptpSettingWidget();
- virtual void loadConfig(const NetworkManager::Setting::Ptr &setting);
- virtual QVariantMap setting(bool agentOwned = false) const;
- virtual bool isValid() const;
-
-private slots:
- void doAdvancedDialog();
- void passwordTypeChanged(int);
- void setShowPassword(bool);
-
-private:
- PptpSettingWidgetPrivate * d_ptr;
- void fillOnePasswordCombo(KComboBox *, NetworkManager::Setting::SecretFlags);
- uint handleOnePasswordType(const KComboBox *, const QString &, NMStringMap &, bool agentOwned) const;
-};
-
-#endif // PPTPWIDGET_H
+++ /dev/null
-set(strongswan_SRCS
- strongswan.cpp
- strongswanwidget.cpp
- strongswanauth.cpp
- strongswanprop.ui
- strongswanauth.ui
-)
-
-kde4_add_plugin(plasmanetworkmanagement_strongswanui ${strongswan_SRCS})
-
-target_link_libraries(plasmanetworkmanagement_strongswanui ${NETWORKMANAGERQT_LDFLAGS} ${KDE4_KIO_LIBS} plasmanetworkmanagement-editor)
-
-install(TARGETS plasmanetworkmanagement_strongswanui DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install( FILES plasmanetworkmanagement_strongswanui.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
-$XGETTEXT `find . -name "*.cpp"` -o $podir/plasmanetworkmanagement_strongswanui.pot
-rm -f rc.cpp
+++ /dev/null
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager -- Network link manager
- *
- * 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.
- *
- * (C) Copyright 2005 - 2008 Red Hat, Inc. //krazy:exclude=copyright
- * (C) Copyright 2007 - 2008 Novell, Inc. //krazy:exclude=copyright
- */
-
-#ifndef NM_STRONGSWAN_SERVICE_H
-#define NM_STRONGSWAN_SERVICE_H
-
-#define NM_DBUS_SERVICE_STRONGSWAN "org.freedesktop.NetworkManager.strongswan"
-#define NM_DBUS_INTERFACE_STRONGSWAN "org.freedesktop.NetworkManager.strongswan"
-#define NM_DBUS_PATH_STRONGSWAN "/org/freedesktop/NetworkManager/strongswan"
-
-#define NM_STRONGSWAN_GATEWAY "address"
-#define NM_STRONGSWAN_CERTIFICATE "certificate"
-#define NM_STRONGSWAN_USER "user"
-#define NM_STRONGSWAN_METHOD "method"
-#define NM_STRONGSWAN_USERKEY "userkey"
-#define NM_STRONGSWAN_USERCERT "usercert"
-#define NM_STRONGSWAN_SECRET "password"
-#define NM_STRONGSWAN_SECRET_TYPE "secret_type"
-#define NM_STRONGSWAN_INNERIP "virtual"
-#define NM_STRONGSWAN_ENCAP "encap"
-#define NM_STRONGSWAN_IPCOMP "ipcomp"
-
-#define NM_STRONGSWAN_AUTH_KEY "key"
-#define NM_STRONGSWAN_AUTH_AGENT "agent"
-#define NM_STRONGSWAN_AUTH_SMARTCARD "smartcard"
-#define NM_STRONGSWAN_AUTH_EAP "eap"
-
-#define NM_STRONGSWAN_PW_TYPE_SAVE "save"
-#define NM_STRONGSWAN_PW_TYPE_ASK "ask"
-#define NM_STRONGSWAN_PW_TYPE_UNUSED "unused"
-
-#endif /* NM_Strongswan_PLUGIN_H */
+++ /dev/null
-[Desktop Entry]
-Type=Service
-Icon=
-ServiceTypes=PlasmaNetworkManagement/VpnUiPlugin
-X-KDE-Library=plasmanetworkmanagement_strongswanui
-X-NetworkManager-Services=org.freedesktop.NetworkManager.strongswan
-X-KDE-PluginInfo-Author=Lukáš Tinkl
-X-KDE-PluginInfo-Email=ltinkl@redhat.com
-X-KDE-PluginInfo-Name=plasmanetworkmanagement_strongswanui
-X-KDE-PluginInfo-Version=0.1
-X-KDE-PluginInfo-Website=
-X-KDE-PluginInfo-Category=VPNService
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=false
-Name=StrongSwan
-Name[bg]=StrongSwan
-Name[bs]=StrongSwan
-Name[ca]=StrongSwan
-Name[ca@valencia]=StrongSwan
-Name[cs]=StrongSwan
-Name[da]=StrongSwan
-Name[de]=StrongSwan
-Name[el]=StrongSwan
-Name[en_GB]=StrongSwan
-Name[es]=StrongSwan
-Name[et]=StrongSwan
-Name[fi]=StrongSwan
-Name[fr]=StrongSwan
-Name[hu]=StrongSwan
-Name[it]=StrongSwan
-Name[ko]=StrongSwan
-Name[lt]=StrongSwan
-Name[nb]=StrongSwan
-Name[nds]=StrongSwan
-Name[nl]=StrongSwan
-Name[pl]=StrongSwan
-Name[pt]=StrongSwan
-Name[pt_BR]=StrongSwan
-Name[ro]=StrongSwan
-Name[ru]=StrongSwan
-Name[sk]=StrongSwan
-Name[sl]=StrongSwan
-Name[sv]=StrongSwan
-Name[tr]=StrongSwan
-Name[uk]=StrongSwan
-Name[x-test]=xxStrongSwanxx
-Name[zh_CN]=StrongSwan
-Comment=StrongSwan Plugin
-Comment[bg]=Приставка за StrongSwan
-Comment[bs]=StrongSwan Dodatak
-Comment[ca]=Connector de StrongSwan
-Comment[ca@valencia]=Connector de StrongSwan
-Comment[cs]=Modul StrongSwan
-Comment[da]=StrongSwan-plugin
-Comment[de]=StrongSwan-Modul
-Comment[el]=Πρόσθετο StrongSwan
-Comment[en_GB]=StrongSwan Plugin
-Comment[es]=Complemento StrongSwan
-Comment[et]=StrongSwani plugin
-Comment[fi]=StrongSwan-liitännäinen
-Comment[fr]=Module externe StrongSwan
-Comment[hu]=StrongSwan bővítmény
-Comment[it]=Estensione StrongSwan
-Comment[ko]=StrongSwan 플러그인
-Comment[lt]=StrongSwan papildinys
-Comment[nb]=StrongSwan programtillegg
-Comment[nds]=StrongSwan-Moduul
-Comment[nl]=Plugin voor StrongSwan
-Comment[pl]=Wtyczka StrongSwan
-Comment[pt]='Plugin' do StrongSwan
-Comment[pt_BR]=Plugin do StrongSwan
-Comment[ro]=Modul StrongSwan
-Comment[ru]=Модуль StrongSwan
-Comment[sk]=StrongSwan modul
-Comment[sl]=Vstavek StrongSwan
-Comment[sv]=Insticksprogram för StrongSwan
-Comment[tr]=StrongSwan Eklentisi
-Comment[uk]=Додаток StrongSwan
-Comment[x-test]=xxStrongSwan Pluginxx
-Comment[zh_CN]=StrongSwan 插件
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2010 Maurus Rohrer <maurus.rohrer@gmail.com>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "strongswan.h"
-#include "strongswanwidget.h"
-#include "strongswanauth.h"
-
-#include <KPluginFactory>
-
-K_PLUGIN_FACTORY(StrongswanUiPluginFactory, registerPlugin<StrongswanUiPlugin>();)
-K_EXPORT_PLUGIN(StrongswanUiPluginFactory("plasmanetworkmanagement_strongswanui"))
-
-StrongswanUiPlugin::StrongswanUiPlugin(QObject * parent, const QVariantList &)
- : VpnUiPlugin(parent)
-{
-}
-
-StrongswanUiPlugin::~StrongswanUiPlugin()
-{
-}
-
-SettingWidget * StrongswanUiPlugin::widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new StrongswanSettingWidget(setting, parent);
-}
-
-SettingWidget * StrongswanUiPlugin::askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new StrongswanAuthWidget(setting, parent);
-}
-
-QString StrongswanUiPlugin::suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const
-{
- Q_UNUSED(connection);
-
- // TODO : implement suggested file name
- return QString();
-}
-
-QString StrongswanUiPlugin::supportedFileExtensions() const
-{
- // TODO : return supported file extensions
- return QString();
-}
-
-NMVariantMapMap StrongswanUiPlugin::importConnectionSettings(const QString &fileName)
-{
- Q_UNUSED(fileName);
-
- // TODO : import the StrongSwan connection from file and return settings
- mError = VpnUiPlugin::NotImplemented;
- return NMVariantMapMap();
-}
-
-bool StrongswanUiPlugin::exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName)
-{
- Q_UNUSED(connection);
- Q_UNUSED(fileName);
-
- // TODO : export StrongSwan connection to file
- mError = VpnUiPlugin::NotImplemented;
- return false;
-}
-
-// vim: sw=4 sts=4 et tw=100
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2010 Maurus Rohrer <maurus.rohrer@gmail.com>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMANM_STRONGSWAN_H
-#define PLASMANM_STRONGSWAN_H
-
-#include "vpnuiplugin.h"
-
-#include <QVariant>
-
-class StrongswanUiPlugin : public VpnUiPlugin
-{
-Q_OBJECT
-public:
- explicit StrongswanUiPlugin(QObject * parent = 0, const QVariantList& = QVariantList());
- virtual ~StrongswanUiPlugin();
- virtual SettingWidget * widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- virtual SettingWidget * askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- virtual QString suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const;
- virtual QString supportedFileExtensions() const;
-
- virtual NMVariantMapMap importConnectionSettings(const QString &fileName);
- virtual bool exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName);
-};
-
-#endif // PLASMANM_STRONGSWAN_H
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "strongswanauth.h"
-#include "ui_strongswanauth.h"
-#include "nm-strongswan-service.h"
-
-#include <KDialog>
-#include <KMessageBox>
-#include <KLocale>
-#include <QString>
-#include <QProcessEnvironment>
-
-class StrongswanAuthWidgetPrivate
-{
-public:
- Ui_StrongswanAuth ui;
- bool acceptOnShow;
- NetworkManager::VpnSetting::Ptr setting;
-};
-
-StrongswanAuthWidget::StrongswanAuthWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
- : SettingWidget(setting, parent), d_ptr(new StrongswanAuthWidgetPrivate)
-{
- Q_D(StrongswanAuthWidget);
- d->setting = setting;
- d->ui.setupUi(this);
- d->acceptOnShow = false;
- connect(d->ui.chkShowPass, SIGNAL(toggled(bool)), this, SLOT(showPasswordsChanged(bool)));
-
- readSecrets();
-
- KAcceleratorManager::manage(this);
-}
-
-StrongswanAuthWidget::~StrongswanAuthWidget()
-{
- delete d_ptr;
-}
-
-void StrongswanAuthWidget::readSecrets()
-{
- Q_D(StrongswanAuthWidget);
- const NMStringMap dataMap = d->setting->data();
-
- const QString method = dataMap[NM_STRONGSWAN_METHOD];
- if (method == QLatin1String(NM_STRONGSWAN_AUTH_AGENT) || dataMap[NM_STRONGSWAN_SECRET_TYPE] == QLatin1String(NM_STRONGSWAN_PW_TYPE_UNUSED)) {
- if (isVisible())
- acceptDialog();
- else
- d->acceptOnShow = true;
- } else if (method == QLatin1String(NM_STRONGSWAN_AUTH_KEY)) {
- d->ui.passwordLabel->setText(i18nc("@label:textbox password label for private key password", "Private Key Password:"));
- } else if (method == QLatin1String(NM_STRONGSWAN_AUTH_SMARTCARD)) {
- d->ui.passwordLabel->setText(i18nc("@label:textbox password label for smartcard pin", "PIN:"));
- } else if (method == QLatin1String(NM_STRONGSWAN_AUTH_EAP)) {
- d->ui.passwordLabel->setText(i18nc("@label:textbox password label for EAP password", "Password:"));
- }
-}
-
-void StrongswanAuthWidget::setVisible(bool visible)
-{
- Q_D(StrongswanAuthWidget);
-
- SettingWidget::setVisible(visible);
-
- if (visible) {
- if (d->acceptOnShow) {
- acceptDialog();
- } else {
- SettingWidget::setVisible(visible);
- }
- } else {
- SettingWidget::setVisible(visible);
- }
-}
-
-void StrongswanAuthWidget::acceptDialog()
-{
- KDialog *dialog = qobject_cast<KDialog*>(parentWidget());
- if (dialog) {
- dialog->accept();
- }
-}
-
-QVariantMap StrongswanAuthWidget::setting(bool agentOwned) const
-{
- Q_UNUSED(agentOwned)
- Q_D(const StrongswanAuthWidget);
-
- NMStringMap secrets;
- QVariantMap secretData;
-
- if (d->setting->data()[NM_STRONGSWAN_METHOD] == QLatin1String(NM_STRONGSWAN_AUTH_AGENT)) {
- const QString agent = QProcessEnvironment::systemEnvironment().value(QLatin1String("SSH_AUTH_SOCK"));
- if (!agent.isEmpty()) {
- secrets.insert(NM_STRONGSWAN_AUTH_AGENT, agent);
- } else {
- KMessageBox::error(0, i18nc("@label:textbox error message while saving configuration", "Configuration uses ssh-agent for authentication, but no ssh-agent found running."));
- }
- } else {
- secrets.insert(NM_STRONGSWAN_SECRET, d->ui.password->text());
- }
-
- secretData.insert("secrets", QVariant::fromValue<NMStringMap>(secrets));
- return secretData;
-}
-
-void StrongswanAuthWidget::showPasswordsChanged(bool show)
-{
- Q_D(StrongswanAuthWidget);
- d->ui.password->setPasswordMode(!show);
-}
+++ /dev/null
-/*
- Copyright 2011 Ilia Kats <ilia-kats@gmx.net>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef STRONGSWANAUTH_H
-#define STRONGSWANAUTH_H
-
-#include "settingwidget.h"
-
-#include <NetworkManagerQt/VpnSetting>
-
-class StrongswanAuthWidgetPrivate;
-
-class StrongswanAuthWidget : public SettingWidget
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(StrongswanAuthWidget)
-public:
- explicit StrongswanAuthWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~StrongswanAuthWidget();
-
- virtual void readSecrets();
-
- virtual QVariantMap setting(bool agentOwned = false) const;
-
-public slots:
- void setVisible(bool);
-
-private slots:
- void showPasswordsChanged(bool show);
-
-private:
- StrongswanAuthWidgetPrivate * const d_ptr;
- void acceptDialog();
-};
-
-#endif // STRONGSWANAUTH_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>StrongswanAuth</class>
- <widget class="QWidget" name="StrongswanAuth">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>309</width>
- <height>89</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Strong Swan VPN</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="passwordLabel">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="password">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QCheckBox" name="chkShowPass">
- <property name="text">
- <string>&Show passwords</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>StrongswanProp</class>
- <widget class="QWidget" name="StrongswanProp">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>490</width>
- <height>420</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Strong Swan VPN</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Gateway</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="textLabel3">
- <property name="text">
- <string>Gateway:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>leGateway</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="leGateway"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Certificate:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KUrlRequester" name="leGatewayCertificate"/>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>Authentication</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <widget class="KComboBox" name="cmbMethod">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="editable">
- <bool>false</bool>
- </property>
- <item>
- <property name="text">
- <string>Certificate/private key</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Certificate/ssh-agent</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Smartcard</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>EAP</string>
- </property>
- </item>
- </widget>
- </item>
- <item>
- <widget class="QStackedWidget" name="swMethods">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="page_4">
- <layout class="QFormLayout" name="formLayout_4">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Certificate:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KUrlRequester" name="leAuthPrivatekeyCertificate"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Private key:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KUrlRequester" name="leAuthPrivatekeyKey"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>Private Key Password:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="KLineEdit" name="lePrivateKeyPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="cboPrivateKeyPassOptions">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="sizeAdjustPolicy">
- <enum>QComboBox::AdjustToContents</enum>
- </property>
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="page_3">
- <layout class="QFormLayout" name="formLayout_3">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Certificate:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KUrlRequester" name="leAuthSshCertificate"/>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="page_2">
- <layout class="QFormLayout" name="formLayout_5">
- <item row="0" column="0">
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>PIN:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="KLineEdit" name="lePin"/>
- </item>
- <item>
- <widget class="KComboBox" name="cboPinOptions">
- <property name="sizeAdjustPolicy">
- <enum>QComboBox::AdjustToContents</enum>
- </property>
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="page">
- <layout class="QFormLayout" name="formLayout_2">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>&Username:</string>
- </property>
- <property name="buddy">
- <cstring>leUserName</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="leUserName"/>
- </item>
- <item row="1" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="KLineEdit" name="leUserPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="cboUserPassOptions">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>User &Password</string>
- </property>
- <property name="buddy">
- <cstring>leUserPassword</cstring>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="cbShowPasswords">
- <property name="text">
- <string>&Show passwords</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_3">
- <property name="title">
- <string>Options</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QCheckBox" name="innerIP">
- <property name="autoFillBackground">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Request an inner IP address</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="tristate">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="udpEncap">
- <property name="text">
- <string>Enforce UDP encapsulation</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="ipComp">
- <property name="text">
- <string>Use IP compression</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KUrlRequester</class>
- <extends>QFrame</extends>
- <header>kurlrequester.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections>
- <connection>
- <sender>cmbMethod</sender>
- <signal>currentIndexChanged(int)</signal>
- <receiver>swMethods</receiver>
- <slot>setCurrentIndex(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>231</x>
- <y>129</y>
- </hint>
- <hint type="destinationlabel">
- <x>231</x>
- <y>186</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cbShowPasswords</sender>
- <signal>toggled(bool)</signal>
- <receiver>leUserPassword</receiver>
- <slot>setPasswordMode(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>331</x>
- <y>169</y>
- </hint>
- <hint type="destinationlabel">
- <x>313</x>
- <y>108</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cbShowPasswords</sender>
- <signal>toggled(bool)</signal>
- <receiver>lePrivateKeyPassword</receiver>
- <slot>setPasswordMode(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>236</x>
- <y>243</y>
- </hint>
- <hint type="destinationlabel">
- <x>246</x>
- <y>212</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cbShowPasswords</sender>
- <signal>toggled(bool)</signal>
- <receiver>lePin</receiver>
- <slot>setPasswordMode(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>236</x>
- <y>243</y>
- </hint>
- <hint type="destinationlabel">
- <x>194</x>
- <y>160</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-/*
- Copyright 2008 Will Stephenson <wstephenson@kde.org>
- Copyright 2010 Maurus Rohrer <maurus.rohrer@gmail.com>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "strongswanwidget.h"
-#include "nm-strongswan-service.h"
-#include "ui_strongswanprop.h"
-
-#include <QString>
-
-class StrongswanSettingWidgetPrivate
-{
-public:
- Ui_StrongswanProp ui;
- NetworkManager::VpnSetting::Ptr setting;
- enum AuthType {PrivateKey = 0, SshAgent, Smartcard, Eap};
-};
-
-StrongswanSettingWidget::StrongswanSettingWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
- : SettingWidget(setting, parent), d_ptr(new StrongswanSettingWidgetPrivate)
-{
- Q_D(StrongswanSettingWidget);
- d->ui.setupUi(this);
- d->setting = setting;
- connect(d->ui.cboUserPassOptions, SIGNAL(currentIndexChanged(int)), this, SLOT(userPasswordTypeChanged(int)));
- connect(d->ui.cboPrivateKeyPassOptions, SIGNAL(currentIndexChanged(int)), this, SLOT(privateKeyPasswordTypeChanged(int)));
- connect(d->ui.cboPinOptions, SIGNAL(currentIndexChanged(int)), this, SLOT(pinTypeChanged(int)));
- connect(d->ui.cmbMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(methodChanged(int)));
- connect(d->ui.cbShowPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswordsChanged(bool)));
-
- connect(d->ui.leGateway, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- if (d->setting)
- loadConfig(d->setting);
-}
-
-StrongswanSettingWidget::~StrongswanSettingWidget()
-{
- delete d_ptr;
-}
-
-void StrongswanSettingWidget::userPasswordTypeChanged(int index)
-{
- Q_D(StrongswanSettingWidget);
- d->ui.leUserPassword->setEnabled(index == 0);
-}
-
-void StrongswanSettingWidget::privateKeyPasswordTypeChanged(int index)
-{
- Q_D(StrongswanSettingWidget);
- d->ui.lePrivateKeyPassword->setEnabled(index == 0);
-}
-
-void StrongswanSettingWidget::pinTypeChanged(int index)
-{
- Q_D(StrongswanSettingWidget);
- d->ui.lePin->setEnabled(index == 0);
-}
-
-void StrongswanSettingWidget::methodChanged(int index)
-{
- Q_D(StrongswanSettingWidget);
- d->ui.cbShowPasswords->setEnabled(index != StrongswanSettingWidgetPrivate::SshAgent);
-}
-
-void StrongswanSettingWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- Q_UNUSED(setting)
- Q_D(StrongswanSettingWidget);
-
- // General settings
- const NMStringMap dataMap = d->setting->data();
- // Gateway Address
- const QString gateway = dataMap[NM_STRONGSWAN_GATEWAY];
- if (!gateway.isEmpty()) {
- d->ui.leGateway->setText(gateway);
- }
- // Certificate
- d->ui.leGatewayCertificate->setUrl(KUrl(dataMap[NM_STRONGSWAN_CERTIFICATE]) );
-
- // Authentication
- const QString method = dataMap[NM_STRONGSWAN_METHOD];
- if (method == QLatin1String(NM_STRONGSWAN_AUTH_KEY)) {
- d->ui.cmbMethod->setCurrentIndex(StrongswanSettingWidgetPrivate::PrivateKey);
- d->ui.leAuthPrivatekeyCertificate->setUrl(KUrl(dataMap[NM_STRONGSWAN_USERCERT]));
- d->ui.leAuthPrivatekeyKey->setUrl(KUrl(dataMap[NM_STRONGSWAN_USERKEY]));
- } else if (method == QLatin1String(NM_STRONGSWAN_AUTH_AGENT)) {
- d->ui.cmbMethod->setCurrentIndex(StrongswanSettingWidgetPrivate::SshAgent);
- d->ui.leAuthSshCertificate->setUrl(KUrl(dataMap[NM_STRONGSWAN_USERCERT]));
- } else if (method == QLatin1String(NM_STRONGSWAN_AUTH_SMARTCARD)) {
- d->ui.cmbMethod->setCurrentIndex(StrongswanSettingWidgetPrivate::Smartcard);
- } else if (method == QLatin1String(NM_STRONGSWAN_AUTH_EAP)) {
- d->ui.cmbMethod->setCurrentIndex(StrongswanSettingWidgetPrivate::Eap);
- d->ui.leUserName->setText(dataMap[NM_STRONGSWAN_USER]);
- }
-
- // Settings
- d->ui.innerIP->setChecked(dataMap[NM_STRONGSWAN_INNERIP] == "yes");
- d->ui.udpEncap->setChecked(dataMap[NM_STRONGSWAN_ENCAP] == "yes");
- d->ui.ipComp->setChecked(dataMap[NM_STRONGSWAN_IPCOMP] == "yes");
-
- // secrets
- const NMStringMap secrets = d->setting->secrets();
- if (d->setting->data().value(NM_STRONGSWAN_SECRET_TYPE) == QLatin1String(NM_STRONGSWAN_PW_TYPE_SAVE)) {
- switch (d->ui.cmbMethod->currentIndex())
- {
- case StrongswanSettingWidgetPrivate::PrivateKey:
- d->ui.lePrivateKeyPassword->setText(secrets.value(QLatin1String(NM_STRONGSWAN_SECRET)));
- fillOnePasswordCombo(d->ui.cboPrivateKeyPassOptions, NM_STRONGSWAN_SECRET_TYPE, d->setting->data(), !d->ui.leAuthPrivatekeyKey->url().isEmpty());
- break;
- case StrongswanSettingWidgetPrivate::Smartcard:
- d->ui.lePin->setText(secrets.value(QLatin1String(NM_STRONGSWAN_SECRET)));
- fillOnePasswordCombo(d->ui.cboPinOptions, NM_STRONGSWAN_SECRET_TYPE, d->setting->data(), true);
- break;
- case StrongswanSettingWidgetPrivate::Eap:
- d->ui.leUserPassword->setText(secrets.value(QLatin1String(NM_STRONGSWAN_SECRET)));
- fillOnePasswordCombo(d->ui.cboUserPassOptions, NM_STRONGSWAN_SECRET_TYPE, d->setting->data(), !d->ui.leUserName->text().isEmpty());
- break;
- default:
- break;
- }
- }
-}
-
-QVariantMap StrongswanSettingWidget::setting(bool agentOwned) const
-{
- Q_D(const StrongswanSettingWidget);
-
- NetworkManager::VpnSetting setting;
- setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_STRONGSWAN));
-
- NMStringMap data;
- NMStringMap secretData;
-
- // General settings
- // Gateway
- if (!d->ui.leGateway->text().isEmpty()) {
- data.insert(NM_STRONGSWAN_GATEWAY, d->ui.leGateway->text());
- }
- data.insert( NM_STRONGSWAN_CERTIFICATE, d->ui.leGatewayCertificate->url().path());
-
- // Authentication
- switch (d->ui.cmbMethod->currentIndex())
- {
- case StrongswanSettingWidgetPrivate::PrivateKey:
- data.insert(NM_STRONGSWAN_METHOD, NM_STRONGSWAN_AUTH_KEY);
- data.insert(NM_STRONGSWAN_USERCERT, d->ui.leAuthPrivatekeyCertificate->url().path());
- data.insert(NM_STRONGSWAN_USERKEY, d->ui.leAuthPrivatekeyKey->url().path());
- break;
- case StrongswanSettingWidgetPrivate::SshAgent:
- data.insert(NM_STRONGSWAN_METHOD, NM_STRONGSWAN_AUTH_AGENT);
- data.insert(NM_STRONGSWAN_USERCERT, d->ui.leAuthSshCertificate->url().path());
- break;
- case StrongswanSettingWidgetPrivate::Smartcard:
- data.insert(NM_STRONGSWAN_METHOD, NM_STRONGSWAN_AUTH_SMARTCARD);
- break;
- case StrongswanSettingWidgetPrivate::Eap:
- data.insert(NM_STRONGSWAN_METHOD, NM_STRONGSWAN_AUTH_EAP);
- if (!d->ui.leUserName->text().isEmpty())
- data.insert(NM_STRONGSWAN_USER, d->ui.leUserName->text());
- //StrongSwan-nm 1.2 does not appear to be able to save secrets, the must be entered through the auth dialog
- if (!d->ui.leUserPassword->text().isEmpty() && d->ui.cboUserPassOptions->currentIndex() == 1)
- secretData.insert(NM_STRONGSWAN_SECRET, d->ui.leUserPassword->text());
- handleOnePasswordType(d->ui.cboUserPassOptions, NM_STRONGSWAN_SECRET_TYPE, data, agentOwned);
- break;
- }
-
- //Options
- data.insert(NM_STRONGSWAN_INNERIP, d->ui.innerIP->isChecked() ? "yes" : "no");
- data.insert(NM_STRONGSWAN_ENCAP, d->ui.udpEncap->isChecked() ? "yes" : "no");
- data.insert(NM_STRONGSWAN_IPCOMP, d->ui.ipComp->isChecked() ? "yes" : "no");
-
- // save it all
- setting.setData(data);
- setting.setSecrets(secretData);
-
- return setting.toMap();
-}
-
-void StrongswanSettingWidget::fillOnePasswordCombo(KComboBox * combo, const QString & key, const NMStringMap & data, bool hasPassword)
-{
- if (data.contains(key)) {
- if (data.value(key) == NM_STRONGSWAN_PW_TYPE_SAVE) {
- combo->setCurrentIndex(0);
- } else if (data.value(key) == NM_STRONGSWAN_PW_TYPE_UNUSED) {
- combo->setCurrentIndex(2);
- }
- } else if (!hasPassword) {
- combo->setCurrentIndex(1);
- }
-}
-
-uint StrongswanSettingWidget::handleOnePasswordType(const KComboBox * combo, const QString & key, NMStringMap & data, bool agentOwned) const
-{
- const uint type = combo->currentIndex();
- switch (type) {
- case 1:
- data.insert(key, QString::number(NetworkManager::Setting::NotSaved));
- break;
- case 0:
- if (agentOwned)
- data.insert(key, QString::number(NetworkManager::Setting::AgentOwned));
- else
- data.insert(key, QString::number(NetworkManager::Setting::None));
- break;
- case 2:
- data.insert(key, QString::number(NetworkManager::Setting::NotRequired));
- break;
- }
- return type;
-}
-
-bool StrongswanSettingWidget::isValid() const
-{
- Q_D(const StrongswanSettingWidget);
- return !d->ui.leGateway->text().isEmpty();
-}
-
-void StrongswanSettingWidget::showPasswordsChanged(bool show)
-{
- Q_D(StrongswanSettingWidget);
- d->ui.lePrivateKeyPassword->setPasswordMode(!show);
- d->ui.leUserPassword->setPasswordMode(!show);
-}
+++ /dev/null
-/*
- Copyright 2009 Will Stephenson <wstephenson@kde.org>
- Copyright 2010 Maurus Rohrer <maurus.rohrer@gmail.com>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef STRONGSWANWIDGET_H
-#define STRONGSWANWIDGET_H
-
-#include "settingwidget.h"
-
-#include <NetworkManagerQt/VpnSetting>
-
-class KComboBox;
-class StrongswanSettingWidgetPrivate;
-
-class StrongswanSettingWidget : public SettingWidget
-{
-Q_OBJECT
-Q_DECLARE_PRIVATE(StrongswanSettingWidget)
-public:
- explicit StrongswanSettingWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~StrongswanSettingWidget();
-
- virtual void loadConfig(const NetworkManager::Setting::Ptr &setting);
- virtual QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-protected Q_SLOTS:
- void userPasswordTypeChanged(int);
- void privateKeyPasswordTypeChanged(int);
- void pinTypeChanged(int);
- void methodChanged(int);
- void showPasswordsChanged(bool show);
-private:
- void fillOnePasswordCombo(KComboBox * combo, const QString & key, const NMStringMap & data, bool hasPassword);
- uint handleOnePasswordType(const KComboBox * combo, const QString & key, NMStringMap & data, bool agentOwned) const;
- StrongswanSettingWidgetPrivate * const d_ptr;
-};
-
-#endif // STRONGSWANWIDGET_H
+++ /dev/null
-set(vpnc_SRCS
- vpnc.cpp
- vpncwidget.cpp
- vpncadvancedwidget.cpp
- vpncauth.cpp
- vpnc.ui
- vpncadvanced.ui
- vpncauth.ui
-)
-
-kde4_add_plugin(plasmanetworkmanagement_vpncui ${vpnc_SRCS})
-
-target_link_libraries(plasmanetworkmanagement_vpncui plasmanetworkmanagement-editor ${NETWORKMANAGERQT_LDFLAGS} ${KDE4_KIO_LIBS})
-
-install(TARGETS plasmanetworkmanagement_vpncui DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install(FILES plasmanetworkmanagement_vpncui.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
-$XGETTEXT `find . -name "*.cpp"` -o $podir/plasmanetworkmanagement_vpncui.pot
-rm -f rc.cpp
+++ /dev/null
-/* NetworkManager -- Network link manager
- *
- * 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.
- *
- * (C) Copyright 2005 - 2012 Red Hat, Inc.
- * (C) Copyright 2007 - 2008 Novell, Inc.
- */
-
-#ifndef NM_VPNC_SERVICE_H
-#define NM_VPNC_SERVICE_H
-
-#define NM_DBUS_SERVICE_VPNC "org.freedesktop.NetworkManager.vpnc"
-#define NM_DBUS_INTERFACE_VPNC "org.freedesktop.NetworkManager.vpnc"
-#define NM_DBUS_PATH_VPNC "/org/freedesktop/NetworkManager/vpnc"
-
-#define NM_VPNC_KEY_GATEWAY "IPSec gateway"
-#define NM_VPNC_KEY_ID "IPSec ID"
-#define NM_VPNC_KEY_SECRET "IPSec secret"
-#define NM_VPNC_KEY_XAUTH_USER "Xauth username"
-#define NM_VPNC_KEY_XAUTH_PASSWORD "Xauth password"
-#define NM_VPNC_KEY_DOMAIN "Domain"
-#define NM_VPNC_KEY_DHGROUP "IKE DH Group"
-#define NM_VPNC_KEY_PERFECT_FORWARD "Perfect Forward Secrecy"
-#define NM_VPNC_KEY_VENDOR "Vendor"
-#define NM_VPNC_KEY_APP_VERSION "Application Version"
-#define NM_VPNC_KEY_SINGLE_DES "Enable Single DES"
-#define NM_VPNC_KEY_NO_ENCRYPTION "Enable no encryption"
-#define NM_VPNC_KEY_NAT_TRAVERSAL_MODE "NAT Traversal Mode"
-#define NM_VPNC_KEY_DPD_IDLE_TIMEOUT "DPD idle timeout (our side)"
-#define NM_VPNC_KEY_CISCO_UDP_ENCAPS_PORT "Cisco UDP Encapsulation Port"
-#define NM_VPNC_KEY_LOCAL_PORT "Local Port"
-#define NM_VPNC_KEY_AUTHMODE "IKE Authmode"
-#define NM_VPNC_KEY_CA_FILE "CA-File"
-
-#define NM_VPNC_NATT_MODE_NATT "natt"
-#define NM_VPNC_NATT_MODE_NONE "none"
-#define NM_VPNC_NATT_MODE_NATT_ALWAYS "force-natt"
-#define NM_VPNC_NATT_MODE_CISCO "cisco-udp"
-
-#define NM_VPNC_DHGROUP_DH1 "dh1"
-#define NM_VPNC_DHGROUP_DH2 "dh2"
-#define NM_VPNC_DHGROUP_DH5 "dh5"
-
-#define NM_VPNC_PFS_SERVER "server"
-#define NM_VPNC_PFS_NOPFS "nopfs"
-#define NM_VPNC_PFS_DH1 "dh1"
-#define NM_VPNC_PFS_DH2 "dh2"
-#define NM_VPNC_PFS_DH5 "dh5"
-
-#define NM_VPNC_VENDOR_CISCO "cisco"
-#define NM_VPNC_VENDOR_NETSCREEN "netscreen"
-
-#endif /* NM_VPNC_SERVICE_H */
+++ /dev/null
-[Desktop Entry]
-Type=Service
-Icon=
-ServiceTypes=PlasmaNetworkManagement/VpnUiPlugin
-X-KDE-Library=plasmanetworkmanagement_vpncui
-X-NetworkManager-Services=org.freedesktop.NetworkManager.vpnc
-X-KDE-PluginInfo-Author=Lukáš Tinkl
-X-KDE-PluginInfo-Email=ltinkl@redhat.com
-X-KDE-PluginInfo-Name=plasmanetworkmanagement_vpncui
-X-KDE-PluginInfo-Version=0.1
-X-KDE-PluginInfo-Website=
-X-KDE-PluginInfo-Category=VPNService
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=false
-Name=VPNC
-Name[bg]=VPNC
-Name[bs]=VPNC
-Name[ca]=VPNC
-Name[ca@valencia]=VPNC
-Name[cs]=VPNC
-Name[da]=VPNC
-Name[de]=VPNC
-Name[el]=VPNC
-Name[en_GB]=VPNC
-Name[es]=VPNC
-Name[et]=VPNC
-Name[fi]=VPNC
-Name[fr]=VPNC
-Name[hu]=VPNC
-Name[it]=VPNC
-Name[ko]=VPNC
-Name[lt]=VPNC
-Name[nb]=VPNC
-Name[nds]=VPNC
-Name[nl]=VPNC
-Name[pl]=VPNC
-Name[pt]=VPNC
-Name[pt_BR]=VPNC
-Name[ro]=VPNC
-Name[ru]=VPNC
-Name[sk]=VPNC
-Name[sl]=VPNC
-Name[sv]=VPNC
-Name[tr]=VPNC
-Name[ug]=VPNC
-Name[uk]=VPNC
-Name[x-test]=xxVPNCxx
-Name[zh_CN]=VPNC
-Comment=VPNC Plugin
-Comment[bg]=Приставка за VPNC
-Comment[bs]=VPNC Dodatak
-Comment[ca]=Connector de VPNC
-Comment[ca@valencia]=Connector de VPNC
-Comment[cs]=Modul VPNC
-Comment[da]=VPNC-plugin
-Comment[de]=VPNC-Modul
-Comment[el]=Πρόσθετο VPNC
-Comment[en_GB]=VPNC Plugin
-Comment[es]=Complemento VPNC
-Comment[et]=VPNC plugin
-Comment[fi]=VPNC-liitännäinen
-Comment[fr]=Module externe VPNC
-Comment[hu]=VPNC bővítmény
-Comment[it]=Estensione VPNC
-Comment[ko]=VPNC 플러그인
-Comment[lt]=VPNC papildinys
-Comment[nb]=VPNC programtillegg
-Comment[nds]=VPNC-Moduul
-Comment[nl]=VPNC-plugin
-Comment[pl]=Wtyczka VPNC
-Comment[pt]='Plugin' do VPNC
-Comment[pt_BR]=Plugin do VPNC
-Comment[ro]=Modul VPNC
-Comment[ru]=Модуль VPNC
-Comment[sk]=VPNC modul
-Comment[sl]=Vstavek VPNC
-Comment[sv]=Insticksprogram för VPNC
-Comment[tr]=VPNC Eklentisi
-Comment[ug]=VPNC قىستۇرمىسى
-Comment[uk]=Додаток VPNC
-Comment[x-test]=xxVPNC Pluginxx
-Comment[zh_CN]=VPNC 插件
+++ /dev/null
-/*
- Copyright 2008 Will Stephenson <wstephenson@kde.org>
- Copyright 2011-2012 Rajeesh K Nambiar <rajeeshknambiar@gmail.com>
- Copyright 2011-2012 Lamarque V. Souza <lamarque@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "vpnc.h"
-
-#include <KPluginFactory>
-#include <KSharedConfig>
-#include <KStandardDirs>
-#include <KMessageBox>
-#include <KLocale>
-#include <KDebug>
-#include <KUrl>
-#include "nm-vpnc-service.h"
-
-#include <NetworkManagerQt/Connection>
-#include <NetworkManagerQt/VpnSetting>
-#include <NetworkManagerQt/Ipv4Setting>
-
-#include "vpncwidget.h"
-#include "vpncauth.h"
-
-VpncUiPluginPrivate::VpncUiPluginPrivate()
-{
- decryptedPasswd.clear();
- ciscoDecrypt = 0;
-}
-
-VpncUiPluginPrivate::~VpncUiPluginPrivate()
-{
-}
-
-QString VpncUiPluginPrivate::readStringKeyValue(const KConfigGroup & configGroup, const QString & key)
-{
- const QString retValue = configGroup.readEntry(key);
- if (retValue.isEmpty()) {
- // String key can also start with "!" in CISCO pcf file.
- return configGroup.readEntry('!' + key);
- } else {
- return retValue;
- }
-}
-
-void VpncUiPluginPrivate::gotCiscoDecryptOutput()
-{
- QByteArray output = ciscoDecrypt->readAll();
- if (!output.isEmpty()) {
- QList<QByteArray> lines = output.split('\n');
- if (!lines.isEmpty()) {
- decryptedPasswd = QString::fromUtf8(lines.first());
- }
- }
-}
-
-void VpncUiPluginPrivate::ciscoDecryptFinished(int exitCode, QProcess::ExitStatus exitStatus)
-{
- if (exitCode || exitStatus != QProcess::NormalExit)
- decryptedPasswd.clear();
-}
-
-void VpncUiPluginPrivate::ciscoDecryptError(QProcess::ProcessError pError)
-{
- if (!pError) {
- kDebug() << "Error in executing cisco-decrypt";
- KMessageBox::error(0, i18n("Error decrypting the obfuscated password"), i18n("Error"), KMessageBox::Notify);
- }
- decryptedPasswd.clear();
-}
-
-
-#define NM_VPNC_LOCAL_PORT_DEFAULT 500
-
-K_PLUGIN_FACTORY(VpncUiPluginFactory, registerPlugin<VpncUiPlugin>();)
-K_EXPORT_PLUGIN(VpncUiPluginFactory("plasmanetworkmanagement_vpncui"))
-
-VpncUiPlugin::VpncUiPlugin(QObject * parent, const QVariantList &) : VpnUiPlugin(parent)
-{
-
-}
-
-VpncUiPlugin::~VpncUiPlugin()
-{
-
-}
-
-SettingWidget * VpncUiPlugin::widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new VpncWidget(setting, parent);
-}
-
-SettingWidget *VpncUiPlugin::askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
-{
- return new VpncAuthDialog(setting, parent);
-}
-
-QString VpncUiPlugin::suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const
-{
- return connection->id() + ".pcf";
-}
-
-QString VpncUiPlugin::supportedFileExtensions() const
-{
- return "*.pcf";
-}
-
-NMVariantMapMap VpncUiPlugin::importConnectionSettings(const QString &fileName)
-{
- kDebug() << "Importing Cisco VPN connection from " << fileName;
-
- VpncUiPluginPrivate * decrPlugin = 0;
- NMVariantMapMap result;
-
- if (!fileName.endsWith(QLatin1String(".pcf"), Qt::CaseInsensitive)) {
- return result;
- }
-
- mError = VpnUiPlugin::Error;
-
- // NOTE: Cisco VPN pcf files follow ini style matching KConfig files
- // http://www.cisco.com/en/US/docs/security/vpn_client/cisco_vpn_client/vpn_client46/administration/guide/vcAch2.html#wp1155033
- KSharedConfig::Ptr config = KSharedConfig::openConfig(fileName);
- if (!config) {
- mErrorMessage = i18n("File %1 could not be opened.", fileName);
- return result;
- }
-
- KConfigGroup cg(config, "main"); // Keys&Values are stored under [main]
- if (cg.exists()) {
- // Setup cisco-decrypt binary to decrypt the passwords
- const QString ciscoDecryptBinary = KStandardDirs::findExe("cisco-decrypt", QString::fromLocal8Bit(qgetenv("PATH")) + ":/usr/lib/vpnc");
- if (ciscoDecryptBinary.isEmpty()) {
- mErrorMessage = i18n("Needed executable cisco-decrypt could not be found.");
- return result;
- }
-
- decrPlugin = new VpncUiPluginPrivate();
- decrPlugin->ciscoDecrypt = new KProcess(decrPlugin);
- decrPlugin->ciscoDecrypt->setOutputChannelMode(KProcess::OnlyStdoutChannel);
- decrPlugin->ciscoDecrypt->setReadChannel(QProcess::StandardOutput);
- connect(decrPlugin->ciscoDecrypt, SIGNAL(error(QProcess::ProcessError)), decrPlugin, SLOT(ciscoDecryptError(QProcess::ProcessError)));
- connect(decrPlugin->ciscoDecrypt, SIGNAL(finished(int,QProcess::ExitStatus)), decrPlugin, SLOT(ciscoDecryptFinished(int,QProcess::ExitStatus)));
- connect(decrPlugin->ciscoDecrypt, SIGNAL(readyReadStandardOutput()), decrPlugin, SLOT(gotCiscoDecryptOutput()));
-
- NMStringMap data;
- NMStringMap secretData;
- QVariantMap ipv4Data;
-
- // gateway
- data.insert(NM_VPNC_KEY_GATEWAY, decrPlugin->readStringKeyValue(cg,"Host"));
- // group name
- data.insert(NM_VPNC_KEY_ID, decrPlugin->readStringKeyValue(cg,"GroupName"));
- // user password
- if (!decrPlugin->readStringKeyValue(cg,"UserPassword").isEmpty()) {
- secretData.insert(NM_VPNC_KEY_XAUTH_PASSWORD, decrPlugin->readStringKeyValue(cg,"UserPassword"));
- }
- else if (!decrPlugin->readStringKeyValue(cg,"enc_UserPassword").isEmpty() && !ciscoDecryptBinary.isEmpty()) {
- // Decrypt the password and insert into map
- decrPlugin->ciscoDecrypt->setProgram(ciscoDecryptBinary);
- decrPlugin->ciscoDecrypt->start();
- decrPlugin->ciscoDecrypt->waitForStarted();
- decrPlugin->ciscoDecrypt->write(decrPlugin->readStringKeyValue(cg,"enc_UserPassword").toUtf8());
- if (decrPlugin->ciscoDecrypt->waitForFinished()) {
- secretData.insert(NM_VPNC_KEY_XAUTH_PASSWORD, decrPlugin->decryptedPasswd);
- }
- }
- // Save user password
- switch (cg.readEntry("SaveUserPassword").toInt())
- {
- case 0:
- data.insert(NM_VPNC_KEY_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotSaved));
- break;
- case 1:
- data.insert(NM_VPNC_KEY_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::AgentOwned));
- break;
- case 2:
- data.insert(NM_VPNC_KEY_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotRequired));
- break;
- }
-
- // group password
- if (!decrPlugin->readStringKeyValue(cg,"GroupPwd").isEmpty()) {
- secretData.insert(NM_VPNC_KEY_SECRET, decrPlugin->readStringKeyValue(cg,"GroupPwd"));
- data.insert(NM_VPNC_KEY_SECRET"-flags", QString::number(NetworkManager::Setting::AgentOwned));
- } else if (!decrPlugin->readStringKeyValue(cg,"enc_GroupPwd").isEmpty() && !ciscoDecryptBinary.isEmpty()) {
- //Decrypt the password and insert into map
- decrPlugin->ciscoDecrypt->setProgram(ciscoDecryptBinary);
- decrPlugin->ciscoDecrypt->start();
- decrPlugin->ciscoDecrypt->waitForStarted();
- decrPlugin->ciscoDecrypt->write(decrPlugin->readStringKeyValue(cg,"enc_GroupPwd").toUtf8());
- if (decrPlugin->ciscoDecrypt->waitForFinished()) {
- secretData.insert(NM_VPNC_KEY_SECRET, decrPlugin->decryptedPasswd);
- data.insert(NM_VPNC_KEY_SECRET"-flags", QString::number(NetworkManager::Setting::AgentOwned));
- }
- }
-
- // Auth Type
- if (!cg.readEntry("AuthType").isEmpty() && cg.readEntry("AuthType").toInt() == 5) {
- data.insert(NM_VPNC_KEY_AUTHMODE, QLatin1String("hybrid"));
- }
-
- // Optional settings
- // username
- if (!decrPlugin->readStringKeyValue(cg,"Username").isEmpty()) {
- data.insert(NM_VPNC_KEY_XAUTH_USER, decrPlugin->readStringKeyValue(cg,"Username"));
- }
- // domain
- if (!decrPlugin->readStringKeyValue(cg,"NTDomain").isEmpty()) {
- data.insert(NM_VPNC_KEY_DOMAIN, decrPlugin->readStringKeyValue(cg,"NTDomain"));
- }
- // encryption
- if (!cg.readEntry("SingleDES").isEmpty() && cg.readEntry("SingleDES").toInt() != 0) {
- data.insert(NM_VPNC_KEY_SINGLE_DES, QLatin1String("yes"));
- }
- /* Disable all NAT Traversal if explicit EnableNat=0 exists, otherwise
- * default to NAT-T which is newer and standardized. If EnableNat=1, then
- * use Cisco-UDP like always; but if the key "X-NM-Use-NAT-T" is set, then
- * use NAT-T. If the key "X-NM-Force-NAT-T" is set then force NAT-T always
- * on. See vpnc documentation for more information on what the different
- * NAT modes are.
- */
- // enable NAT
- if (cg.readEntry("EnableNat").toInt() == 1) {
- data.insert(NM_VPNC_KEY_NAT_TRAVERSAL_MODE, QLatin1String(NM_VPNC_NATT_MODE_CISCO));
- // NAT traversal
- if (!cg.readEntry("X-NM-Use-NAT-T").isEmpty()) {
- if (cg.readEntry("X-NM-Use-NAT-T").toInt() == 1) {
- data.insert(NM_VPNC_KEY_NAT_TRAVERSAL_MODE, QLatin1String(NM_VPNC_NATT_MODE_NATT));
- }
- if (cg.readEntry("X-NM-Force-NAT-T").toInt() == 1) {
- data.insert(NM_VPNC_KEY_NAT_TRAVERSAL_MODE, QLatin1String(NM_VPNC_NATT_MODE_NATT_ALWAYS));
- }
- }
- }
- else {
- data.insert(NM_VPNC_KEY_NAT_TRAVERSAL_MODE, QLatin1String(NM_VPNC_NATT_MODE_NONE));
- }
- // dead peer detection
- data.insert(NM_VPNC_KEY_DPD_IDLE_TIMEOUT, cg.readEntry("PeerTimeout"));
- // UseLegacyIKEPort=0 uses dynamic source IKE port instead of 500.
- if (cg.readEntry("UseLegacyIKEPort").isEmpty() || cg.readEntry("UseLegacyIKEPort").toInt() != 0) {
- data.insert(NM_VPNC_KEY_LOCAL_PORT, QString::number(NM_VPNC_LOCAL_PORT_DEFAULT));
- }
- // DH Group
- data.insert(NM_VPNC_KEY_DHGROUP, decrPlugin->readStringKeyValue(cg,"DHGroup"));
- // Tunneling Mode - not supported by vpnc
- if (cg.readEntry("TunnelingMode").toInt() == 1) {
- KMessageBox::error(0, i18n("The VPN settings file '%1' specifies that VPN traffic should be tunneled through TCP which is currently not supported in the vpnc software.\n\nThe connection can still be created, with TCP tunneling disabled, however it may not work as expected.", fileName), i18n("Not supported"), KMessageBox::Notify);
- }
- // EnableLocalLAN and X-NM-Routes are to be added to IPv4Setting
- if (!cg.readEntry("EnableLocalLAN").isEmpty()) {
- ipv4Data.insert("never-default", cg.readEntry("EnableLocalLAN"));
- }
- if (!decrPlugin->readStringKeyValue(cg,"X-NM-Routes").isEmpty()) {
- ipv4Data.insert("X-NM-Routes", decrPlugin->readStringKeyValue(cg,"X-NM-Routes"));
- }
-
- // Set the '...-type' and '...-flags' value also
- NetworkManager::VpnSetting setting;
- setting.setServiceType("org.freedesktop.NetworkManager.vpnc");
- setting.setData(data);
- setting.setSecrets(secretData);
-
- QVariantMap conn;
- if (decrPlugin->readStringKeyValue(cg,"Description").isEmpty()) {
- KUrl name = fileName;
- conn.insert("id", name.fileName().remove(QLatin1String(".pcf"), Qt::CaseInsensitive));
- } else {
- conn.insert("id", decrPlugin->readStringKeyValue(cg,"Description"));
- }
- conn.insert("type", "vpn");
- result.insert("connection", conn);
-
- result.insert("vpn", setting.toMap());
-
- if (!ipv4Data.isEmpty()) {
- result.insert("ipv4", ipv4Data);
- }
-
- delete decrPlugin;
- } else {
- mErrorMessage = i18n("%1: file format error.", fileName);
- return result;
- }
-
- mError = VpncUiPlugin::NoError;
- return result;
-}
-
-bool VpncUiPlugin::exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName)
-{
- NMStringMap data;
- NMStringMap secretData;
-
- NetworkManager::VpnSetting::Ptr vpnSetting = connection->setting(NetworkManager::Setting::Vpn).dynamicCast<NetworkManager::VpnSetting>();
- data = vpnSetting->data();
- secretData = vpnSetting->secrets();
-
- KSharedConfig::Ptr config = KSharedConfig::openConfig(fileName);
- if (!config) {
- mErrorMessage = i18n("%1: file could not be created", fileName);
- return false;
- }
- KConfigGroup cg(config,"main");
-
- cg.writeEntry("Description", connection->id());
- cg.writeEntry("Host", data.value(NM_VPNC_KEY_GATEWAY));
- if (data.value(NM_VPNC_KEY_AUTHMODE) == QLatin1String("hybrid"))
- cg.writeEntry("AuthType", "5");
- else
- cg.writeEntry("AuthType", "1");
- cg.writeEntry("GroupName", data.value(NM_VPNC_KEY_ID));
- cg.writeEntry("GroupPwd", secretData.value(NM_VPNC_KEY_SECRET));
- cg.writeEntry("UserPassword", secretData.value(NM_VPNC_KEY_XAUTH_PASSWORD));
- cg.writeEntry("enc_GroupPwd", "");
- cg.writeEntry("enc_UserPassword", "");
- if ((NetworkManager::Setting::SecretFlags)data.value(NM_VPNC_KEY_XAUTH_PASSWORD"-flags").toInt() & NetworkManager::Setting::NotSaved) {
- cg.writeEntry("SaveUserPassword", "0");
- }
- if ((NetworkManager::Setting::SecretFlags)data.value(NM_VPNC_KEY_XAUTH_PASSWORD"-flags").toInt() & NetworkManager::Setting::AgentOwned) {
- cg.writeEntry("SaveUserPassword", "1");
- }
- if ((NetworkManager::Setting::SecretFlags)data.value(NM_VPNC_KEY_XAUTH_PASSWORD"-flags").toInt() & NetworkManager::Setting::NotRequired) {
- cg.writeEntry("SaveUserPassword", "2");
- }
- cg.writeEntry("Username", data.value(NM_VPNC_KEY_XAUTH_USER));
- cg.writeEntry("EnableISPConnect", "0");
- cg.writeEntry("ISPConnectType", "0");
- cg.writeEntry("ISPConnect", "");
- cg.writeEntry("ISPCommand", "");
- cg.writeEntry("EnableBackup", "0");
- cg.writeEntry("BackupServer", "");
- cg.writeEntry("CertStore", "0");
- cg.writeEntry("CertName", "");
- cg.writeEntry("CertPath", "");
- cg.writeEntry("CertSubjectName", "");
- cg.writeEntry("CertSerialHash", "");
- cg.writeEntry("DHGroup", data.value(NM_VPNC_KEY_DHGROUP));
- cg.writeEntry("ForceKeepAlives", "0");
- cg.writeEntry("NTDomain", data.value(NM_VPNC_KEY_DOMAIN));
- cg.writeEntry("EnableMSLogon", "0");
- cg.writeEntry("MSLogonType", "0");
- cg.writeEntry("TunnelingMode", "0");
- cg.writeEntry("TcpTunnelingPort", "10000");
- cg.writeEntry("PeerTimeout", data.value(NM_VPNC_KEY_DPD_IDLE_TIMEOUT));
- cg.writeEntry("EnableLocalLAN", "1");
- cg.writeEntry("SendCertChain", "0");
- cg.writeEntry("VerifyCertDN", "");
- cg.writeEntry("EnableSplitDNS", "1");
- cg.writeEntry("SPPhonebook", "");
- if (data.value(NM_VPNC_KEY_SINGLE_DES) == "yes") {
- cg.writeEntry("SingleDES", "1");
- }
- if (data.value(NM_VPNC_KEY_NAT_TRAVERSAL_MODE) == NM_VPNC_NATT_MODE_CISCO) {
- cg.writeEntry("EnableNat", "1");
- }
- if (data.value(NM_VPNC_KEY_NAT_TRAVERSAL_MODE) == NM_VPNC_NATT_MODE_NATT) {
- cg.writeEntry("EnableNat", "1");
- cg.writeEntry("X-NM-Use-NAT-T", "1");
- }
- if (data.value(NM_VPNC_KEY_NAT_TRAVERSAL_MODE) == NM_VPNC_NATT_MODE_NATT_ALWAYS) {
- cg.writeEntry("EnableNat", "1");
- cg.writeEntry("X-NM-Force-NAT-T", "1");
- }
- // Export X-NM-Routes
- NetworkManager::Ipv4Setting::Ptr ipv4Setting = connection->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
- if (!ipv4Setting->routes().isEmpty()) {
- QString routes;
- foreach(const NetworkManager::IpRoute &route, ipv4Setting->routes()) {
- routes += route.ip().toString() + QLatin1Char('/') + QString::number(route.prefixLength()) + QLatin1Char(' ');
- }
- cg.writeEntry("X-NM-Routes", routes.trimmed());
- }
-
- cg.sync();
-
- mError = VpncUiPlugin::NoError;
- return true;
-}
+++ /dev/null
-/*
- Copyright 2008 Will Stephenson <wstephenson@kde.org>
- Copyright 2011-2012 Rajeesh K Nambiar <rajeeshknambiar@gmail.com>
- Copyright 2011-2012 Lamarque V. Souza <lamarque@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_VPNC_H
-#define PLASMA_NM_VPNC_H
-
-#include "vpnuiplugin.h"
-#include "plasmanm_export.h"
-
-#include <QVariant>
-
-#include <KProcess>
-#include <KConfigGroup>
-
-class VpncUiPluginPrivate: public QObject
-{
- Q_OBJECT
-public:
- VpncUiPluginPrivate();
- ~VpncUiPluginPrivate();
- QString readStringKeyValue(const KConfigGroup & configGroup, const QString & key);
- KProcess * ciscoDecrypt;
- QString decryptedPasswd;
-
-protected slots:
- void gotCiscoDecryptOutput();
- void ciscoDecryptError(QProcess::ProcessError pError);
- void ciscoDecryptFinished(int exitCode, QProcess::ExitStatus exitStatus);
-};
-
-class PLASMA_NM_EXPORT VpncUiPlugin : public VpnUiPlugin
-{
- Q_OBJECT
-
-public:
- explicit VpncUiPlugin(QObject * parent = 0, const QVariantList& = QVariantList());
- virtual ~VpncUiPlugin();
- virtual SettingWidget * widget(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- virtual SettingWidget * askUser(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
-
- QString suggestedFileName(const NetworkManager::ConnectionSettings::Ptr &connection) const;
- QString supportedFileExtensions() const;
- NMVariantMapMap importConnectionSettings(const QString &fileName);
- bool exportConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connection, const QString &fileName);
-};
-
-#endif // PLASMA_NM_VPNC_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <ltinkl@redhat.com></author>
- <class>VpncWidget</class>
- <widget class="QWidget" name="VpncWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>449</width>
- <height>405</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Gateway:</string>
- </property>
- <property name="buddy">
- <cstring>gateway</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="KLineEdit" name="gateway"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>User name:</string>
- </property>
- <property name="buddy">
- <cstring>user</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="KLineEdit" name="user"/>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>User password:</string>
- </property>
- <property name="buddy">
- <cstring>userPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="KLineEdit" name="userPassword">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="cboUserPasswordType">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Group name:</string>
- </property>
- <property name="buddy">
- <cstring>group</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="2">
- <widget class="KLineEdit" name="group"/>
- </item>
- <item row="4" column="0" colspan="2">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Group password:</string>
- </property>
- <property name="buddy">
- <cstring>groupPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="2">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="KLineEdit" name="groupPassword">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="cboGroupPasswordType">
- <item>
- <property name="text">
- <string>Store</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Always Ask</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Not Required</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item row="5" column="2">
- <widget class="QCheckBox" name="cbShowPasswords">
- <property name="text">
- <string>Show passwords</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Preferred</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>144</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="7" column="0" colspan="3">
- <widget class="QCheckBox" name="useHybridAuth">
- <property name="text">
- <string>Use hybrid authentication</string>
- </property>
- </widget>
- </item>
- <item row="8" column="0">
- <widget class="QLabel" name="label_6">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>CA &file:</string>
- </property>
- <property name="buddy">
- <cstring>caFile</cstring>
- </property>
- </widget>
- </item>
- <item row="8" column="2">
- <widget class="KUrlRequester" name="caFile">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="filter">
- <string>*.pem *.crt *.cer</string>
- </property>
- </widget>
- </item>
- <item row="9" column="2">
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="btnAdvanced">
- <property name="text">
- <string>Advanced...</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KUrlRequester</class>
- <extends>QFrame</extends>
- <header>kurlrequester.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>gateway</tabstop>
- <tabstop>user</tabstop>
- <tabstop>userPassword</tabstop>
- <tabstop>cboUserPasswordType</tabstop>
- <tabstop>group</tabstop>
- <tabstop>groupPassword</tabstop>
- <tabstop>cboGroupPasswordType</tabstop>
- <tabstop>cbShowPasswords</tabstop>
- <tabstop>useHybridAuth</tabstop>
- <tabstop>caFile</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>useHybridAuth</sender>
- <signal>toggled(bool)</signal>
- <receiver>caFile</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>58</x>
- <y>391</y>
- </hint>
- <hint type="destinationlabel">
- <x>147</x>
- <y>421</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>useHybridAuth</sender>
- <signal>toggled(bool)</signal>
- <receiver>label_6</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>37</x>
- <y>395</y>
- </hint>
- <hint type="destinationlabel">
- <x>33</x>
- <y>424</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <author>Lukáš Tinkl <ltinkl@redhat.com></author>
- <class>VpncAdvancedWidget</class>
- <widget class="QWidget" name="VpncAdvancedWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>388</width>
- <height>379</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Identification</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Domain:</string>
- </property>
- <property name="buddy">
- <cstring>domain</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="domain"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Vendor:</string>
- </property>
- <property name="buddy">
- <cstring>vendor</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KComboBox" name="vendor">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>Transport and Security</string>
- </property>
- <layout class="QFormLayout" name="formLayout_2">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Encryption method:</string>
- </property>
- <property name="buddy">
- <cstring>encryption</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="encryption">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>NAT traversal:</string>
- </property>
- <property name="buddy">
- <cstring>nat</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="KComboBox" name="nat">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>IKE DH Group:</string>
- </property>
- <property name="buddy">
- <cstring>dhGroup</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KComboBox" name="dhGroup">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Perfect Forward Secrecy:</string>
- </property>
- <property name="buddy">
- <cstring>pfs</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="KComboBox" name="pfs">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QCheckBox" name="deadPeer">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Disable dead peer detection</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>Local Port:</string>
- </property>
- <property name="buddy">
- <cstring>localport</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="KIntNumInput" name="localport">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Local port to use (0-65535). 0 (default value) means random port.</string>
- </property>
- <property name="specialValueText">
- <string>Random</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KComboBox</class>
- <extends>QComboBox</extends>
- <header>kcombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- <customwidget>
- <class>KIntNumInput</class>
- <extends>QWidget</extends>
- <header>knuminput.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>VpncAdvancedWidget</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>247</x>
- <y>360</y>
- </hint>
- <hint type="destinationlabel">
- <x>0</x>
- <y>26</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>VpncAdvancedWidget</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>147</x>
- <y>360</y>
- </hint>
- <hint type="destinationlabel">
- <x>-1</x>
- <y>65</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "vpncadvancedwidget.h"
-#include "ui_vpncadvanced.h"
-#include "nm-vpnc-service.h"
-
-#include <KLocalizedString>
-#include <KAcceleratorManager>
-
-VpncAdvancedWidget::VpncAdvancedWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent) :
- QDialog(parent),
- m_ui(new Ui::VpncAdvancedWidget)
-{
- m_ui->setupUi(this);
-
- setWindowTitle(i18n("Advanced VPNC properties"));
-
- // vendor
- m_ui->vendor->addItem(i18nc("VPNC vendor name", "Cisco"), NM_VPNC_VENDOR_CISCO);
- m_ui->vendor->addItem(i18nc("VPNC vendor name", "Netscreen"), NM_VPNC_VENDOR_NETSCREEN);
-
- // encryption
- m_ui->encryption->addItem(i18nc("VPNC encryption method", "Secure (default)"));
- m_ui->encryption->addItem(i18nc("VPNC encryption method", "Weak (DES encryption, use with caution)"), NM_VPNC_KEY_SINGLE_DES);
- m_ui->encryption->addItem(i18nc("VPNC encryption method", "None (completely insecure)"), NM_VPNC_KEY_NO_ENCRYPTION);
-
- // NAT traversal
- m_ui->nat->addItem(i18nc("NAT traversal method", "NAT-T when available (default)"), NM_VPNC_NATT_MODE_NATT);
- m_ui->nat->addItem(i18nc("NAT traversal method", "NAT-T always"), NM_VPNC_NATT_MODE_NATT_ALWAYS);
- m_ui->nat->addItem(i18nc("NAT traversal method", "Cisco UDP"), NM_VPNC_NATT_MODE_CISCO);
- m_ui->nat->addItem(i18nc("NAT traversal method", "Disabled"), NM_VPNC_NATT_MODE_NONE);
-
- // IKE DH group
- m_ui->dhGroup->addItem(i18nc("IKE DH group", "DH Group 1"), NM_VPNC_DHGROUP_DH1);
- m_ui->dhGroup->addItem(i18nc("IKE DH group", "DH Group 2 (default)"), NM_VPNC_DHGROUP_DH2);
- m_ui->dhGroup->addItem(i18nc("IKE DH group", "DH Group 5"), NM_VPNC_DHGROUP_DH5);
-
- // PFS
- m_ui->pfs->addItem(i18nc("Perfect Forward Secrecy", "Server (default)"), NM_VPNC_PFS_SERVER);
- m_ui->pfs->addItem(i18nc("Perfect Forward Secrecy", "None"), NM_VPNC_PFS_NOPFS);
- m_ui->pfs->addItem(i18nc("Perfect Forward Secrecy", "DH Group 1"), NM_VPNC_PFS_DH1);
- m_ui->pfs->addItem(i18nc("Perfect Forward Secrecy", "DH Group 2"), NM_VPNC_PFS_DH2);
- m_ui->pfs->addItem(i18nc("Perfect Forward Secrecy", "DH Group 5"), NM_VPNC_PFS_DH5);
-
- // localport
- m_ui->localport->setRange(0, 65535, 1);
- m_ui->localport->setValue(0);
-
- loadConfig(setting);
-
- KAcceleratorManager::manage(this);
-}
-
-VpncAdvancedWidget::~VpncAdvancedWidget()
-{
- delete m_ui;
-}
-
-void VpncAdvancedWidget::loadConfig(const NetworkManager::VpnSetting::Ptr &setting)
-{
- m_ui->domain->setText(setting->data().value(NM_VPNC_KEY_DOMAIN));
-
- const QString vendor = setting->data().value(NM_VPNC_KEY_VENDOR);
- if (!vendor.isEmpty())
- m_ui->vendor->setCurrentIndex(m_ui->vendor->findData(vendor));
-
- if (setting->data().value(NM_VPNC_KEY_SINGLE_DES) == "yes")
- m_ui->encryption->setCurrentIndex(m_ui->encryption->findData(NM_VPNC_KEY_SINGLE_DES));
- else if (setting->data().value(NM_VPNC_KEY_NO_ENCRYPTION) == "yes")
- m_ui->encryption->setCurrentIndex(m_ui->encryption->findData(NM_VPNC_KEY_NO_ENCRYPTION));
-
- const QString nat = setting->data().value(NM_VPNC_KEY_NAT_TRAVERSAL_MODE);
- if (!nat.isEmpty())
- m_ui->nat->setCurrentIndex(m_ui->nat->findData(nat));
-
- const QString dhGroup = setting->data().value(NM_VPNC_KEY_DHGROUP);
- if (!dhGroup.isEmpty())
- m_ui->dhGroup->setCurrentIndex(m_ui->dhGroup->findData(dhGroup));
- else
- m_ui->dhGroup->setCurrentIndex(m_ui->dhGroup->findData(NM_VPNC_DHGROUP_DH2)); // default
-
- const QString pfs = setting->data().value(NM_VPNC_KEY_PERFECT_FORWARD);
- if (!pfs.isEmpty())
- m_ui->pfs->setCurrentIndex(m_ui->pfs->findData(pfs));
-
- bool ok = false;
- const QString localport = setting->data().value(NM_VPNC_KEY_LOCAL_PORT);
- if (!localport.isEmpty()) {
- const uint localportNum = localport.toUInt(&ok);
- if (ok && localportNum <= 65535) {
- m_ui->localport->setValue(localportNum);
- }
- }
-
- const uint dpd = setting->data().value(NM_VPNC_KEY_DPD_IDLE_TIMEOUT).toUInt(&ok);
- m_ui->deadPeer->setChecked(ok && dpd == 0);
-}
-
-NMStringMap VpncAdvancedWidget::setting() const
-{
- NMStringMap result;
- if (!m_ui->domain->text().isEmpty())
- result.insert(NM_VPNC_KEY_DOMAIN, m_ui->domain->text());
-
- result.insert(NM_VPNC_KEY_VENDOR, m_ui->vendor->itemData(m_ui->vendor->currentIndex()).toString());
-
- const QString encData = m_ui->encryption->itemData(m_ui->encryption->currentIndex()).toString();
- if (!encData.isEmpty()) {
- if (encData == NM_VPNC_KEY_SINGLE_DES)
- result.insert(NM_VPNC_KEY_SINGLE_DES, "yes");
- else if (encData == NM_VPNC_KEY_NO_ENCRYPTION)
- result.insert(NM_VPNC_KEY_NO_ENCRYPTION, "yes");
- }
-
- result.insert(NM_VPNC_KEY_NAT_TRAVERSAL_MODE, m_ui->nat->itemData(m_ui->nat->currentIndex()).toString());
-
- result.insert(NM_VPNC_KEY_DHGROUP, m_ui->dhGroup->itemData(m_ui->dhGroup->currentIndex()).toString());
-
- result.insert(NM_VPNC_KEY_PERFECT_FORWARD, m_ui->pfs->itemData(m_ui->pfs->currentIndex()).toString());
-
- result.insert(NM_VPNC_KEY_LOCAL_PORT, QString::number(m_ui->localport->value()));
-
- if (m_ui->deadPeer->isChecked())
- result.insert(NM_VPNC_KEY_DPD_IDLE_TIMEOUT, "0");
-
- return result;
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_VPNC_ADVANCED_WIDGET_H
-#define PLASMA_NM_VPNC_ADVANCED_WIDGET_H
-
-#include <QDialog>
-
-#include <NetworkManagerQt/VpnSetting>
-
-namespace Ui
-{
-class VpncAdvancedWidget;
-}
-
-class VpncAdvancedWidget : public QDialog
-{
- Q_OBJECT
-public:
- explicit VpncAdvancedWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent = 0);
- ~VpncAdvancedWidget();
-
- NMStringMap setting() const;
- void loadConfig(const NetworkManager::VpnSetting::Ptr &setting);
-
-private:
- Ui::VpncAdvancedWidget * m_ui;
-};
-
-#endif // PLASMA_NM_VPNC_ADVANCED_WIDGET_H
+++ /dev/null
-/*
- Copyright 2010 Andrey Borzenkov <arvidjaar@gmail.com>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#include "vpncauth.h"
-#include "ui_vpncauth.h"
-#include "nm-vpnc-service.h"
-
-#include <QString>
-
-class VpncAuthDialogPrivate
-{
-public:
- Ui_VpncAuth ui;
- NetworkManager::VpnSetting::Ptr setting;
-};
-
-VpncAuthDialog::VpncAuthDialog(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
- : SettingWidget(setting, parent), d_ptr(new VpncAuthDialogPrivate)
-{
- Q_D(VpncAuthDialog);
- d->ui.setupUi(this);
- d->setting = setting;
- connect(d->ui.cbShowPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswordsChanged(bool)));
-
- readSecrets();
-
- KAcceleratorManager::manage(this);
-}
-
-VpncAuthDialog::~VpncAuthDialog()
-{
- delete d_ptr;
-}
-
-void VpncAuthDialog::readSecrets()
-{
- Q_D(VpncAuthDialog);
- const NMStringMap data = d->setting->data();
- const NMStringMap secrets = d->setting->secrets();
-
- // username
- const QString user = data.value(NM_VPNC_KEY_XAUTH_USER);
- if (!user.isEmpty()) {
- d->ui.leUserName->setText(user);
- }
- // group name
- const QString group = data.value(NM_VPNC_KEY_ID);
- if (!group.isEmpty()) {
- d->ui.leGroupName->setText(group);
- }
-
- bool haveUserPassword = true;
- if (!((NetworkManager::Setting::SecretFlags)data.value(NM_VPNC_KEY_XAUTH_PASSWORD"-flags").toInt()).testFlag(NetworkManager::Setting::NotRequired)) {
- d->ui.leUserPassword->setText(secrets.value(QLatin1String(NM_VPNC_KEY_XAUTH_PASSWORD)));
- } else {
- d->ui.userNameLabel->setVisible(false);
- d->ui.leUserName->setVisible(false);
- d->ui.userPasswordLabel->setVisible(false);
- d->ui.leUserPassword->setVisible(false);
- haveUserPassword = false;
- }
-
- if (!((NetworkManager::Setting::SecretFlags)data.value(NM_VPNC_KEY_SECRET"-flags").toInt()).testFlag(NetworkManager::Setting::NotRequired)) {
- d->ui.leGroupPassword->setText(secrets.value(QLatin1String(NM_VPNC_KEY_SECRET)));
- } else {
- d->ui.groupNameLabel->setVisible(false);
- d->ui.leGroupName->setVisible(false);
- d->ui.groupPasswordLabel->setVisible(false);
- d->ui.leGroupPassword->setVisible(false);
- }
-
- if (haveUserPassword && d->ui.leUserPassword->text().isEmpty())
- d->ui.leUserPassword->setFocus(Qt::OtherFocusReason);
- else if (d->ui.leGroupPassword->text().isEmpty())
- d->ui.leGroupPassword->setFocus(Qt::OtherFocusReason);
-}
-
-QVariantMap VpncAuthDialog::setting(bool agentOwned) const
-{
- Q_D(const VpncAuthDialog);
- Q_UNUSED(agentOwned)
-
- NMStringMap secrets;
- QVariantMap result;
-
- // user password
- if (!d->ui.leUserPassword->text().isEmpty()) {
- secrets.insert(NM_VPNC_KEY_XAUTH_PASSWORD, d->ui.leUserPassword->text());
- }
- // group password
- if (!d->ui.leGroupPassword->text().isEmpty()) {
- secrets.insert(NM_VPNC_KEY_SECRET, d->ui.leGroupPassword->text());
- }
-
- result.insert("secrets", QVariant::fromValue<NMStringMap>(secrets));
-
- return result;
-}
-
-void VpncAuthDialog::showPasswordsChanged(bool show)
-{
- Q_D(VpncAuthDialog);
- d->ui.leUserPassword->setPasswordMode(!show);
- d->ui.leGroupPassword->setPasswordMode(!show);
-}
+++ /dev/null
-/*
- Copyright 2008 Will Stephenson <wstephenson@kde.org>
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License or (at your option) version 3 or any later version
- accepted by the membership 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_VPNC_AUTH_H
-#define PLASMA_NM_VPNC_AUTH_H
-
-#include <NetworkManagerQt/VpnSetting>
-
-#include "settingwidget.h"
-
-class VpncAuthDialogPrivate;
-
-class VpncAuthDialog : public SettingWidget
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(VpncAuthDialog)
-public:
- explicit VpncAuthDialog(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent = 0);
- ~VpncAuthDialog();
- virtual void readSecrets();
- virtual QVariantMap setting(bool agentOwned = false) const;
-
-private slots:
- void showPasswordsChanged(bool);
-
-private:
- VpncAuthDialogPrivate * d_ptr;
-};
-
-#endif // PLASMA_NM_VPNC_AUTH_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>VpncAuth</class>
- <widget class="QWidget" name="VpncAuth">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>372</width>
- <height>171</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>VPNCAuthentication</string>
- </property>
- <layout class="QGridLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <item row="1" column="0">
- <widget class="QLabel" name="userPasswordLabel">
- <property name="text">
- <string>User Password:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>leUserPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="groupPasswordLabel">
- <property name="text">
- <string>Group Password:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>leGroupPassword</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="KLineEdit" name="leUserPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <spacer name="spacer1">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="3" column="2">
- <widget class="KLineEdit" name="leGroupPassword">
- <property name="passwordMode">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="4" column="2">
- <widget class="QCheckBox" name="cbShowPasswords">
- <property name="text">
- <string>Show passwords</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="userNameLabel">
- <property name="text">
- <string>Username:</string>
- </property>
- <property name="buddy">
- <cstring>leUserName</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="KLineEdit" name="leUserName">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="groupNameLabel">
- <property name="text">
- <string>Group name:</string>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- <property name="buddy">
- <cstring>leGroupName</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="KLineEdit" name="leGroupName">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <customwidgets>
- <customwidget>
- <class>KLineEdit</class>
- <extends>QLineEdit</extends>
- <header>klineedit.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>leUserName</tabstop>
- <tabstop>leUserPassword</tabstop>
- <tabstop>leGroupName</tabstop>
- <tabstop>leGroupPassword</tabstop>
- <tabstop>cbShowPasswords</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "vpncwidget.h"
-#include "vpncadvancedwidget.h"
-#include "ui_vpnc.h"
-#include "nm-vpnc-service.h"
-
-#include <QDBusMetaType>
-#include <QDebug>
-
-VpncWidget::VpncWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
- SettingWidget(setting, parent, f),
- m_ui(new Ui::VpncWidget),
- m_setting(setting)
-{
- qDBusRegisterMetaType<NMStringMap>();
-
- m_ui->setupUi(this);
-
- connect(m_ui->cboUserPasswordType, SIGNAL(currentIndexChanged(int)), SLOT(userPasswordTypeChanged(int)));
- connect(m_ui->cboGroupPasswordType, SIGNAL(currentIndexChanged(int)), SLOT(groupPasswordTypeChanged(int)));
- connect(m_ui->cbShowPasswords, SIGNAL(toggled(bool)), SLOT(showPasswords(bool)));
- connect(m_ui->btnAdvanced, SIGNAL(clicked()), SLOT(showAdvanced()));
-
- connect(m_ui->gateway, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
-
- KAcceleratorManager::manage(this);
-
- m_advancedWidget = new VpncAdvancedWidget(m_setting, this);
- NMStringMap advData = m_advancedWidget->setting();
- if (!advData.isEmpty()) {
- if (m_tmpSetting.isNull()) {
- m_tmpSetting = NetworkManager::VpnSetting::Ptr(new NetworkManager::VpnSetting);
- }
- m_tmpSetting->setData(advData);
- }
-
- if (m_setting)
- loadConfig(setting);
-}
-
-VpncWidget::~VpncWidget()
-{
- m_tmpSetting.clear();
- m_advancedWidget->deleteLater();
- delete m_ui;
-}
-
-void VpncWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
-{
- Q_UNUSED(setting);
-
- const NMStringMap data = m_setting->data();
- const NMStringMap secrets = m_setting->secrets();
-
- const QString gateway = data.value(NM_VPNC_KEY_GATEWAY);
- if (!gateway.isEmpty())
- m_ui->gateway->setText(gateway);
-
- const QString user = data.value(NM_VPNC_KEY_XAUTH_USER);
- if (!user.isEmpty())
- m_ui->user->setText(user);
-
- const QString userPassword = secrets.value(NM_VPNC_KEY_XAUTH_PASSWORD);
- if (!userPassword.isEmpty())
- m_ui->userPassword->setText(userPassword);
-
- const NetworkManager::Setting::SecretFlags userPassType =
- static_cast<NetworkManager::Setting::SecretFlags>(data.value(NM_VPNC_KEY_XAUTH_PASSWORD"-flags").toInt());
- if (userPassType.testFlag(NetworkManager::Setting::NotSaved))
- m_ui->cboUserPasswordType->setCurrentIndex(SettingWidget::EnumPasswordStorageType::AlwaysAsk);
- else if (userPassType.testFlag(NetworkManager::Setting::NotRequired))
- m_ui->cboUserPasswordType->setCurrentIndex(SettingWidget::EnumPasswordStorageType::NotRequired);
- else
- m_ui->cboUserPasswordType->setCurrentIndex(SettingWidget::EnumPasswordStorageType::Store);
-
- const QString groupName = data.value(NM_VPNC_KEY_ID);
- if (!groupName.isEmpty())
- m_ui->group->setText(groupName);
-
- const QString groupPassword = secrets.value(NM_VPNC_KEY_SECRET);
- if (!groupPassword.isEmpty())
- m_ui->groupPassword->setText(groupPassword);
-
- const NetworkManager::Setting::SecretFlags groupPassType =
- static_cast<NetworkManager::Setting::SecretFlags>(data.value(NM_VPNC_KEY_SECRET"-flags").toInt());
- if (groupPassType.testFlag(NetworkManager::Setting::NotSaved))
- m_ui->cboGroupPasswordType->setCurrentIndex(SettingWidget::EnumPasswordStorageType::AlwaysAsk);
- else if (groupPassType.testFlag(NetworkManager::Setting::NotRequired))
- m_ui->cboGroupPasswordType->setCurrentIndex(SettingWidget::EnumPasswordStorageType::NotRequired);
- else
- m_ui->cboGroupPasswordType->setCurrentIndex(SettingWidget::EnumPasswordStorageType::Store);
-
- if (data.value(NM_VPNC_KEY_AUTHMODE) == QLatin1String("hybrid")) {
- m_ui->useHybridAuth->setChecked(true);
- m_ui->caFile->setUrl(KUrl::fromPath(data.value(NM_VPNC_KEY_CA_FILE)));
- }
-}
-
-QVariantMap VpncWidget::setting(bool agentOwned) const
-{
- NetworkManager::VpnSetting setting;
- setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_VPNC));
- NMStringMap data;
- NMStringMap secrets;
-
- if (!m_tmpSetting.isNull()) {
- data = m_tmpSetting->data();
- }
-
- if (!m_ui->gateway->text().isEmpty())
- data.insert(NM_VPNC_KEY_GATEWAY, m_ui->gateway->text());
-
- if (!m_ui->user->text().isEmpty())
- data.insert(NM_VPNC_KEY_XAUTH_USER, m_ui->user->text());
-
- if (m_ui->userPassword->isEnabled() && !m_ui->userPassword->text().isEmpty())
- secrets.insert(NM_VPNC_KEY_XAUTH_PASSWORD, m_ui->userPassword->text());
-
- const int userPasswordTypeIndex = m_ui->cboUserPasswordType->currentIndex();
- if (userPasswordTypeIndex == SettingWidget::EnumPasswordStorageType::AlwaysAsk) {
- data.insert(NM_VPNC_KEY_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotSaved));
- } else if (userPasswordTypeIndex == SettingWidget::EnumPasswordStorageType::NotRequired) {
- data.insert(NM_VPNC_KEY_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotRequired));
- } else { // none
- if (agentOwned) {
- data.insert(NM_VPNC_KEY_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::AgentOwned));
- } else {
- data.insert(NM_VPNC_KEY_XAUTH_PASSWORD"-flags", QString::number(NetworkManager::Setting::None));
- }
- }
-
- if (!m_ui->group->text().isEmpty())
- data.insert(NM_VPNC_KEY_ID, m_ui->group->text());
-
- if (m_ui->groupPassword->isEnabled() && !m_ui->groupPassword->text().isEmpty())
- secrets.insert(NM_VPNC_KEY_SECRET, m_ui->groupPassword->text());
-
- const int groupPasswordTypeIndex = m_ui->cboGroupPasswordType->currentIndex();
- if (groupPasswordTypeIndex == SettingWidget::EnumPasswordStorageType::AlwaysAsk) {
- data.insert(NM_VPNC_KEY_SECRET"-flags", QString::number(NetworkManager::Setting::NotSaved));
- } else if (groupPasswordTypeIndex == SettingWidget::EnumPasswordStorageType::NotRequired) {
- data.insert(NM_VPNC_KEY_SECRET"-flags", QString::number(NetworkManager::Setting::NotRequired));
- } else { // none
- if (agentOwned) {
- data.insert(NM_VPNC_KEY_SECRET"-flags", QString::number(NetworkManager::Setting::AgentOwned));
- } else {
- data.insert(NM_VPNC_KEY_SECRET"-flags", QString::number(NetworkManager::Setting::None));
- }
- }
-
- if (m_ui->useHybridAuth->isChecked() && !m_ui->caFile->url().isEmpty()) {
- data.insert(NM_VPNC_KEY_AUTHMODE, "hybrid");
- data.insert(NM_VPNC_KEY_CA_FILE, m_ui->caFile->url().toLocalFile());
- }
-
- setting.setData(data);
- setting.setSecrets(secrets);
- return setting.toMap();
-}
-
-void VpncWidget::userPasswordTypeChanged(int index)
-{
- m_ui->userPassword->setEnabled(index == SettingWidget::EnumPasswordStorageType::Store);
-}
-
-void VpncWidget::groupPasswordTypeChanged(int index)
-{
- m_ui->groupPassword->setEnabled(index == SettingWidget::EnumPasswordStorageType::Store);
-}
-
-void VpncWidget::showPasswords(bool show)
-{
- m_ui->userPassword->setPasswordMode(!show);
- m_ui->groupPassword->setPasswordMode(!show);
-}
-
-void VpncWidget::showAdvanced()
-{
- m_advancedWidget->loadConfig(m_tmpSetting);
- if (m_advancedWidget->exec() == QDialog::Accepted) {
- NMStringMap advData = m_advancedWidget->setting();
- if (!advData.isEmpty()) {
- m_tmpSetting->setData(advData);
- }
- }
-}
-
-bool VpncWidget::isValid() const
-{
- return !m_ui->gateway->text().isEmpty();
-}
+++ /dev/null
-/*
- Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) version 3, or any
- later version accepted by the membership of KDE e.V. (or its
- successor approved by the membership of KDE e.V.), which shall
- act as a proxy defined in Section 6 of version 3 of the license.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PLASMA_NM_VPNC_WIDGET_H
-#define PLASMA_NM_VPNC_WIDGET_H
-
-#include <NetworkManagerQt/VpnSetting>
-
-#include <QPointer>
-
-#include "settingwidget.h"
-#include "vpncadvancedwidget.h"
-
-namespace Ui
-{
-class VpncWidget;
-}
-
-class VpncWidget : public SettingWidget
-{
- Q_OBJECT
-public:
- explicit VpncWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget* parent = 0, Qt::WindowFlags f = 0);
- virtual ~VpncWidget();
-
- void loadConfig(const NetworkManager::Setting::Ptr &setting);
-
- QVariantMap setting(bool agentOwned = false) const;
-
- virtual bool isValid() const;
-
-private slots:
- void userPasswordTypeChanged(int index);
- void groupPasswordTypeChanged(int index);
- void showPasswords(bool show);
- void showAdvanced();
-
-private:
- Ui::VpncWidget * m_ui;
- NetworkManager::VpnSetting::Ptr m_setting;
- NetworkManager::VpnSetting::Ptr m_tmpSetting;
- QPointer<VpncAdvancedWidget> m_advancedWidget;
-};
-
-#endif // PLASMA_NM_VPNC_WIDGET_H