plasma-nm: say hello to my Delete button

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2016-09-10 04:15:29 +00:00
parent 01338814fb
commit 6df66df9c2
296 changed files with 0 additions and 40636 deletions

View file

@ -1,63 +0,0 @@
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)

View file

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

View file

@ -1,502 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
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.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and 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!

View file

@ -1,36 +0,0 @@
# - 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)

View file

@ -1,6 +0,0 @@
#!/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

View file

@ -1,46 +0,0 @@
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/

View file

@ -1,9 +0,0 @@
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)

View file

@ -1,22 +0,0 @@
<?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>

View file

@ -1,76 +0,0 @@
/*
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;
}
}
}
}

View file

@ -1,447 +0,0 @@
/*
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;
}
}
}

View file

@ -1,64 +0,0 @@
/*
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();
}
}
}

View file

@ -1,136 +0,0 @@
/*
* 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
}
}
}
}

View file

@ -1,77 +0,0 @@
/*
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();
}
}
}
}

View file

@ -1,108 +0,0 @@
/*
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();
}
}
}

View file

@ -1,36 +0,0 @@
/*
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;
}
}

View file

@ -1,93 +0,0 @@
<?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 &amp;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>

View file

@ -1,141 +0,0 @@
/*
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;
}
}

View file

@ -1,89 +0,0 @@
[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

View file

@ -1,7 +0,0 @@
install(FILES plasma-networkmanagement.svgz DESTINATION ${DATA_INSTALL_DIR}/desktoptheme/default/icons/ RENAME plasma-networkmanagement2.svgz)
kde4_install_icons(${ICON_INSTALL_DIR})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -1 +0,0 @@
#define PLASMA_NM_VERSION_STRING "${PLASMA_NM_VERSION}"

View file

@ -1,26 +0,0 @@
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)

View file

@ -1,4 +0,0 @@
#! /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

View file

@ -1,592 +0,0 @@
/*
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;
}
}

View file

@ -1,75 +0,0 @@
/*
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

View file

@ -1,92 +0,0 @@
<?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>

View file

@ -1,108 +0,0 @@
[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

View file

@ -1,34 +0,0 @@
<?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>

View file

@ -1,85 +0,0 @@
/*
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();
}

View file

@ -1,42 +0,0 @@
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)

View file

@ -1,4 +0,0 @@
#! /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

View file

@ -1,309 +0,0 @@
/*
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

View file

@ -1,56 +0,0 @@
/*
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

View file

@ -1,196 +0,0 @@
/*
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();
}

View file

@ -1,55 +0,0 @@
/*
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

View file

@ -1,75 +0,0 @@
[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;

View file

@ -1,283 +0,0 @@
[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

View file

@ -1,439 +0,0 @@
/*
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();
}

View file

@ -1,55 +0,0 @@
/*
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

View file

@ -1,153 +0,0 @@
/*
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);
}

View file

@ -1,69 +0,0 @@
/*
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

View file

@ -1,67 +0,0 @@
<?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>&amp;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>

View file

@ -1,270 +0,0 @@
/*
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();
}

View file

@ -1,87 +0,0 @@
/*
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

View file

@ -1,203 +0,0 @@
<?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>

View file

@ -1,623 +0,0 @@
/*
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();
}
}
}

View file

@ -1,126 +0,0 @@
/*
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

View file

@ -1,105 +0,0 @@
/*
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"

View file

@ -1,58 +0,0 @@
/*
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

View file

@ -1,30 +0,0 @@
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)

View file

@ -1,33 +0,0 @@
/*
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;
}

View file

@ -1,33 +0,0 @@
/*
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

View file

@ -1,28 +0,0 @@
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)

View file

@ -1,152 +0,0 @@
/*
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);
}
}

View file

@ -1,82 +0,0 @@
/*
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

View file

@ -1,635 +0,0 @@
/*
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);
}

View file

@ -1,94 +0,0 @@
/*
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

View file

@ -1,131 +0,0 @@
/*
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);
}

View file

@ -1,97 +0,0 @@
/*
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

View file

@ -1,30 +0,0 @@
/*
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()
{
}

View file

@ -1,77 +0,0 @@
/*
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

View file

@ -1,187 +0,0 @@
/*
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");
}

View file

@ -1,64 +0,0 @@
/*
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

View file

@ -1 +0,0 @@
plugin plasmanetworkmanagementplugins

View file

@ -1,62 +0,0 @@
/*
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)

View file

@ -1,32 +0,0 @@
/*
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

View file

@ -1,249 +0,0 @@
/*
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>&nbsp;%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%\">&nbsp;");
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>&nbsp;%2";
QString temp;
temp = QString("<qt><table align=\"left\" border=\"0\"><tr>");
temp += QString("<td width=\"20pt\" bgcolor=\"%1\">&nbsp;&nbsp;").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("&nbsp;&nbsp;</td></tr><tr><td width=\"20pt\" bgcolor=\"%1\">&nbsp;&nbsp;").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);
}

View file

@ -1,83 +0,0 @@
/*
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

View file

@ -1,88 +0,0 @@
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})

View file

@ -1,4 +0,0 @@
#! /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

View file

@ -1,545 +0,0 @@
/*
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);
}

View file

@ -1,80 +0,0 @@
/*
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

View file

@ -1,115 +0,0 @@
<?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>

View file

@ -1,324 +0,0 @@
/*
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;
}

View file

@ -1,65 +0,0 @@
/*
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

View file

@ -1,71 +0,0 @@
[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

View file

@ -1,792 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Lukáš Tinkl &lt;ltinkl@redhat.com&gt;</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 &amp;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>

View file

@ -1,310 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Lukáš Tinkl &lt;ltinkl@redhat.com&gt;</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>

View file

@ -1,284 +0,0 @@
/*
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;
}

View file

@ -1,68 +0,0 @@
/*
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

View file

@ -1,298 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Lukáš Tinkl &lt;ltinkl@redhat.com&gt;</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>

View file

@ -1,220 +0,0 @@
/*
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;
}

View file

@ -1,68 +0,0 @@
/*
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

View file

@ -1,71 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Lukáš Tinkl &lt;ltinkl@redhat.com&gt;</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>

View file

@ -1,76 +0,0 @@
/*
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();
}

View file

@ -1,53 +0,0 @@
/*
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

View file

@ -1,85 +0,0 @@
<?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>

View file

@ -1,75 +0,0 @@
/*
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);
}

View file

@ -1,54 +0,0 @@
/*
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

View file

@ -1,190 +0,0 @@
/*
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());
}
}

View file

@ -1,64 +0,0 @@
/*
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

View file

@ -1,184 +0,0 @@
<?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>

View file

@ -1,261 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Lukáš Tinkl &lt;lukas@redhat.com&gt;</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>

View file

@ -1,155 +0,0 @@
/*
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();
}

View file

@ -1,58 +0,0 @@
/*
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

View file

@ -1,113 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Lukáš Tinkl &lt;ltinkl@redhat.com&gt;</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>

View file

@ -1,91 +0,0 @@
/*
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();
}

View file

@ -1,53 +0,0 @@
/*
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

View file

@ -1,370 +0,0 @@
<?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>

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